From 83972b39cef6ae441547ff5432e184865e6997a8 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur <eldy@destailleur.fr> Date: Mon, 28 Nov 2016 23:58:36 +0100 Subject: [PATCH] Complete work on dol_banner. Fix errors due to missing columns. --- htdocs/compta/sociales/card.php | 181 ++++++++++-------- .../sociales/class/chargesociales.class.php | 15 +- htdocs/core/lib/functions.lib.php | 6 + .../install/mysql/migration/4.0.0-5.0.0.sql | 4 + .../mysql/tables/llx_chargesociales.sql | 3 + htdocs/langs/en_US/projects.lang | 4 +- 6 files changed, 132 insertions(+), 81 deletions(-) diff --git a/htdocs/compta/sociales/card.php b/htdocs/compta/sociales/card.php index 8c21bf32ceb..5b8409c0ddb 100644 --- a/htdocs/compta/sociales/card.php +++ b/htdocs/compta/sociales/card.php @@ -72,6 +72,14 @@ if ($action == 'reopen' && $user->rights->tax->charges->creer) { } } +if ($action == 'setlib' && $user->rights->tax->charges->creer) +{ + $object->fetch($id); + $result = $object->setValueFrom('libelle', GETPOST('lib'), '', '', 'text', '', $user, 'TAX_MODIFY'); + if ($result < 0) + setEventMessages($object->error, $object->errors, 'errors'); +} + // payment mode if ($action == 'setmode' && $user->rights->tax->charges->creer) { $object->fetch($id); @@ -356,6 +364,8 @@ if ($id > 0) { $head=tax_prepare_head($object); + $totalpaye = $object->getSommePaiement(); + // Clone confirmation if ($action === 'clone') { @@ -389,17 +399,34 @@ if ($id > 0) dol_fiche_head($head, 'card', $langs->trans("SocialContribution"),0,'bill'); - print '<table class="border" width="100%">'; - + + $morehtmlref='<div class="refidno">'; + // Ref customer + $morehtmlref.=$form->editfieldkey("Label", 'lib', $object->lib, $object, $user->rights->tax->charges->creer, 'string', '', 0, 1); + $morehtmlref.=$form->editfieldval("Label", 'lib', $object->lib, $object, $user->rights->tax->charges->creer, 'string', '', null, null, '', 1); + $morehtmlref.='</div>'; + $linkback = '<a href="' . DOL_URL_ROOT . '/compta/sociales/index.php">' . $langs->trans("BackToList") . '</a>'; + $object->totalpaye = $totalpaye; // To give a chance to dol_banner_tab to use already paid amount to show correct status + + dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', $morehtmlref, '', 0, '', $morehtmlright); + + print '<div class="fichecenter">'; + print '<div class="fichehalfleft">'; + print '<div class="underbanner clearboth"></div>'; + + print '<table class="border" width="100%">'; + + /* // Ref print '<tr><td class="fieldtitle">'.$langs->trans("Ref").'</td><td colspan="2">'; print $form->showrefnav($object,'id',$linkback); print "</td></tr>"; + */ // Label - if ($action == 'edit') + /*if ($action == 'edit') { print '<tr><td>'.$langs->trans("Label").'</td><td colspan="2">'; print '<input type="text" name="label" size="40" value="'.$object->lib.'">'; @@ -408,79 +435,10 @@ if ($id > 0) else { print '<tr><td>'.$langs->trans("Label").'</td><td colspan="2">'.$object->lib.'</td></tr>'; - } - + }*/ + // Type print "<tr><td>".$langs->trans("Type")."</td><td>".$object->type_libelle."</td>"; - - $rowspan=6; - if (! empty($conf->banque->enabled)) $rowspan++; - print '<td rowspan="'.$rowspan.'" valign="top">'; - - /* - * Payments - */ - $sql = "SELECT p.rowid, p.num_paiement, datep as dp, p.amount,"; - $sql.= "c.code as type_code,c.libelle as paiement_type"; - $sql.= " FROM ".MAIN_DB_PREFIX."paiementcharge as p"; - $sql.= ", ".MAIN_DB_PREFIX."c_paiement as c "; - $sql.= ", ".MAIN_DB_PREFIX."chargesociales as cs"; - $sql.= " WHERE p.fk_charge = ".$id; - $sql.= " AND p.fk_charge = cs.rowid"; - $sql.= " AND cs.entity = ".$conf->entity; - $sql.= " AND p.fk_typepaiement = c.id"; - $sql.= " ORDER BY dp DESC"; - - //print $sql; - $resql = $db->query($sql); - if ($resql) - { - $num = $db->num_rows($resql); - $i = 0; $total = 0; - print '<table class="nobordernopadding paymenttable" width="100%">'; - print '<tr class="liste_titre">'; - print '<td>'.$langs->trans("RefPayment").'</td>'; - print '<td>'.$langs->trans("Date").'</td>'; - print '<td>'.$langs->trans("Type").'</td>'; - print '<td align="right">'.$langs->trans("Amount").'</td>'; - print '<td> </td>'; - print '</tr>'; - - $var=True; - while ($i < $num) - { - $objp = $db->fetch_object($resql); - $var=!$var; - print "<tr ".$bc[$var]."><td>"; - print '<a href="'.DOL_URL_ROOT.'/compta/payment_sc/card.php?id='.$objp->rowid.'">'.img_object($langs->trans("Payment"),"payment").' '.$objp->rowid.'</a></td>'; - print '<td>'.dol_print_date($db->jdate($objp->dp),'day')."</td>\n"; - $labeltype=$langs->trans("PaymentType".$objp->type_code)!=("PaymentType".$objp->type_code)?$langs->trans("PaymentType".$objp->type_code):$objp->paiement_type; - print "<td>".$labeltype.' '.$objp->num_paiement."</td>\n"; - print '<td align="right">'.price($objp->amount)."</td><td> ".$langs->trans("Currency".$conf->currency)."</td>\n"; - print "</tr>"; - $totalpaye += $objp->amount; - $i++; - } - - if ($object->paye == 0) - { - print "<tr><td colspan=\"3\" align=\"right\">".$langs->trans("AlreadyPaid")." :</td><td align=\"right\"><b>".price($totalpaye)."</b></td><td> ".$langs->trans("Currency".$conf->currency)."</td></tr>\n"; - print "<tr><td colspan=\"3\" align=\"right\">".$langs->trans("AmountExpected")." :</td><td align=\"right\" bgcolor=\"#d0d0d0\">".price($object->amount)."</td><td bgcolor=\"#d0d0d0\"> ".$langs->trans("Currency".$conf->currency)."</td></tr>\n"; - - $resteapayer = $object->amount - $totalpaye; - - print "<tr><td colspan=\"3\" align=\"right\">".$langs->trans("RemainderToPay")." :</td>"; - print "<td align=\"right\" bgcolor=\"#f0f0f0\"><b>".price($resteapayer)."</b></td><td bgcolor=\"#f0f0f0\"> ".$langs->trans("Currency".$conf->currency)."</td></tr>\n"; - } - print "</table>"; - $db->free($resql); - } - else - { - dol_print_error($db); - } - print "</td>"; - print "</tr>"; // Period end date @@ -555,10 +513,83 @@ if ($id > 0) } // Status - print '<tr><td>'.$langs->trans("Status").'</td><td>'.$object->getLibStatut(4, $totalpaye).'</td></tr>'; + //print '<tr><td>'.$langs->trans("Status").'</td><td>'.$object->getLibStatut(4, $totalpaye).'</td></tr>'; print '</table>'; + print '</div>'; + print '<div class="fichehalfright">'; + print '<div class="ficheaddleft">'; + + /* + * Payments + */ + $sql = "SELECT p.rowid, p.num_paiement, datep as dp, p.amount,"; + $sql.= "c.code as type_code,c.libelle as paiement_type"; + $sql.= " FROM ".MAIN_DB_PREFIX."paiementcharge as p"; + $sql.= ", ".MAIN_DB_PREFIX."c_paiement as c "; + $sql.= ", ".MAIN_DB_PREFIX."chargesociales as cs"; + $sql.= " WHERE p.fk_charge = ".$id; + $sql.= " AND p.fk_charge = cs.rowid"; + $sql.= " AND cs.entity = ".$conf->entity; + $sql.= " AND p.fk_typepaiement = c.id"; + $sql.= " ORDER BY dp DESC"; + + //print $sql; + $resql = $db->query($sql); + if ($resql) + { + $num = $db->num_rows($resql); + $i = 0; $total = 0; + print '<table class="noborder paymenttable">'; + print '<tr class="liste_titre">'; + print '<td>'.$langs->trans("RefPayment").'</td>'; + print '<td>'.$langs->trans("Date").'</td>'; + print '<td>'.$langs->trans("Type").'</td>'; + print '<td align="right">'.$langs->trans("Amount").'</td>'; + print '<td> </td>'; + print '</tr>'; + + $var=True; + while ($i < $num) + { + $objp = $db->fetch_object($resql); + $var=!$var; + print "<tr ".$bc[$var]."><td>"; + print '<a href="'.DOL_URL_ROOT.'/compta/payment_sc/card.php?id='.$objp->rowid.'">'.img_object($langs->trans("Payment"),"payment").' '.$objp->rowid.'</a></td>'; + print '<td>'.dol_print_date($db->jdate($objp->dp),'day')."</td>\n"; + $labeltype=$langs->trans("PaymentType".$objp->type_code)!=("PaymentType".$objp->type_code)?$langs->trans("PaymentType".$objp->type_code):$objp->paiement_type; + print "<td>".$labeltype.' '.$objp->num_paiement."</td>\n"; + print '<td align="right">'.price($objp->amount)."</td><td> ".$langs->trans("Currency".$conf->currency)."</td>\n"; + print "</tr>"; + $totalpaye += $objp->amount; + $i++; + } + + if ($object->paye == 0) + { + print "<tr><td colspan=\"3\" align=\"right\">".$langs->trans("AlreadyPaid")." :</td><td align=\"right\"><b>".price($totalpaye)."</b></td><td> ".$langs->trans("Currency".$conf->currency)."</td></tr>\n"; + print "<tr><td colspan=\"3\" align=\"right\">".$langs->trans("AmountExpected")." :</td><td align=\"right\" bgcolor=\"#d0d0d0\">".price($object->amount)."</td><td bgcolor=\"#d0d0d0\"> ".$langs->trans("Currency".$conf->currency)."</td></tr>\n"; + + $resteapayer = $object->amount - $totalpaye; + + print "<tr><td colspan=\"3\" align=\"right\">".$langs->trans("RemainderToPay")." :</td>"; + print "<td align=\"right\" bgcolor=\"#f0f0f0\"><b>".price($resteapayer)."</b></td><td bgcolor=\"#f0f0f0\"> ".$langs->trans("Currency".$conf->currency)."</td></tr>\n"; + } + print "</table>"; + $db->free($resql); + } + else + { + dol_print_error($db); + } + + print '</div>'; + print '</div>'; + print '</div>'; + + print '<div class="clearboth"></div>'; + dol_fiche_end(); diff --git a/htdocs/compta/sociales/class/chargesociales.class.php b/htdocs/compta/sociales/class/chargesociales.class.php index ca9af965758..1ba0773afff 100644 --- a/htdocs/compta/sociales/class/chargesociales.class.php +++ b/htdocs/compta/sociales/class/chargesociales.class.php @@ -34,7 +34,8 @@ class ChargeSociales extends CommonObject public $element='chargesociales'; public $table='chargesociales'; public $table_element='chargesociales'; - + public $picto = 'bill'; + /** * {@inheritdoc} */ @@ -371,7 +372,7 @@ class ChargeSociales extends CommonObject /** * Retourne le libelle du statut d'une charge (impaye, payee) * - * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long + * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=short label + picto, 6=Long label + picto * @param double $alreadypaid 0=No payment already done, >0=Some payments were already done (we recommand to put here amount payed if you have it, 1 otherwise) * @return string Label */ @@ -384,7 +385,7 @@ class ChargeSociales extends CommonObject * Renvoi le libelle d'un statut donne * * @param int $statut Id statut - * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto + * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=short label + picto, 6=Long label + picto * @param double $alreadypaid 0=No payment already done, >0=Some payments were already done (we recommand to put here amount payed if you have it, 1 otherwise) * @return string Label */ @@ -428,7 +429,13 @@ class ChargeSociales extends CommonObject if ($statut == 0 && $alreadypaid > 0) return $langs->trans("BillStatusStarted").' '.img_picto($langs->trans("BillStatusStarted"), 'statut3'); if ($statut == 1) return $langs->trans("Paid").' '.img_picto($langs->trans("Paid"), 'statut6'); } - + if ($mode == 6) + { + if ($statut == 0 && $alreadypaid <= 0) return $langs->trans("Unpaid").' '.img_picto($langs->trans("Unpaid"), 'statut1'); + if ($statut == 0 && $alreadypaid > 0) return $langs->trans("BillStatusStarted").' '.img_picto($langs->trans("BillStatusStarted"), 'statut3'); + if ($statut == 1) return $langs->trans("Paid").' '.img_picto($langs->trans("Paid"), 'statut6'); + } + return "Error, mode/status not found"; } diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 7b69b17f89d..33be611442e 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -1055,6 +1055,12 @@ function dol_banner_tab($object, $paramid, $morehtml='', $shownav=1, $fieldid='r if (empty($tmptxt) || $tmptxt == $object->getLibStatut(3) || $conf->browser->layout=='phone') $tmptxt=$object->getLibStatut(5, $object->totalpaye); $morehtmlstatus.=$tmptxt; } + elseif ($object->element == 'chargesociales') + { + $tmptxt=$object->getLibStatut(6, $object->totalpaye); + if (empty($tmptxt) || $tmptxt == $object->getLibStatut(3) || $conf->browser->layout=='phone') $tmptxt=$object->getLibStatut(5, $object->totalpaye); + $morehtmlstatus.=$tmptxt; + } elseif ($object->element == 'facturerec') { $morehtmlstatus.='<!-- No status for recurring invoice -->'; diff --git a/htdocs/install/mysql/migration/4.0.0-5.0.0.sql b/htdocs/install/mysql/migration/4.0.0-5.0.0.sql index b602f5c1bf6..4d653644f39 100644 --- a/htdocs/install/mysql/migration/4.0.0-5.0.0.sql +++ b/htdocs/install/mysql/migration/4.0.0-5.0.0.sql @@ -64,6 +64,10 @@ ALTER TABLE llx_website ADD COLUMN virtualhost varchar(255) after fk_default_hom ALTER TABLE llx_chargesociales ADD COLUMN fk_account integer after fk_type; ALTER TABLE llx_chargesociales ADD COLUMN fk_mode_reglement integer after fk_account; +ALTER TABLE llx_chargesociales ADD COLUMN fk_user_author integer; +ALTER TABLE llx_chargesociales ADD COLUMN fk_user_modif integer; +ALTER TABLE llx_chargesociales ADD COLUMN fk_user_valid integer; + ALTER TABLE llx_ecm_files ADD COLUMN gen_or_uploaded varchar(12) after cover; diff --git a/htdocs/install/mysql/tables/llx_chargesociales.sql b/htdocs/install/mysql/tables/llx_chargesociales.sql index 0514811eb15..95ab50661b6 100644 --- a/htdocs/install/mysql/tables/llx_chargesociales.sql +++ b/htdocs/install/mysql/tables/llx_chargesociales.sql @@ -26,6 +26,9 @@ create table llx_chargesociales tms timestamp, date_creation datetime, -- date de creation date_valid datetime, -- date de validation + fk_user_author integer, -- user making creation + fk_user_modif integer, -- user making last change + fk_user_valid integer, -- user validating fk_type integer NOT NULL, fk_account integer, -- bank account fk_mode_reglement integer, -- mode de reglement diff --git a/htdocs/langs/en_US/projects.lang b/htdocs/langs/en_US/projects.lang index dedd187db6d..ecf61d17d36 100644 --- a/htdocs/langs/en_US/projects.lang +++ b/htdocs/langs/en_US/projects.lang @@ -20,8 +20,8 @@ OnlyOpenedProject=Only open projects are visible (projects in draft or closed st ClosedProjectsAreHidden=Closed projects are not visible. TasksPublicDesc=This view presents all projects and tasks you are allowed to read. TasksDesc=This view presents all projects and tasks (your user permissions grant you permission to view everything). -AllTaskVisibleButEditIfYouAreAssigned=All tasks for such project are visible, but you can enter time only for task you are assigned on. Assign task to you if you want to enter time on it. -OnlyYourTaskAreVisible=Only tasks you are assigned on are visible. Assign task to you if you want to enter time on it. +AllTaskVisibleButEditIfYouAreAssigned=All tasks for such project are visible, but you can enter time only for task assigned to you. Assign task to yourself if you need to enter time on it. +OnlyYourTaskAreVisible=Only tasks assigned to you are visible. Assign task to yourself if it is not visible and you need to enter time on it. ImportDatasetTasks=Tasks of projects NewProject=New project AddProject=Create project -- GitLab