From 158281b14c517acb84485d8ed5ddd43fa6c2ed74 Mon Sep 17 00:00:00 2001 From: Maxime Kohlhaas Date: Mon, 19 Oct 2015 17:13:02 +0200 Subject: [PATCH 1/4] Fix : minor typo --- htdocs/core/lib/functions.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index ec3705c825c..4b548a574e0 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -886,7 +886,7 @@ function dol_banner_tab($object, $paramid, $morehtml='', $shownav=1, $fieldid='r } else { $morehtmlright.=$object->getLibStatut(2); } - if (! empty($object->name_nalias)) $morehtmlref.='
'.$object->name_alias.'
'; + if (! empty($object->name_alias)) $morehtmlref.='
'.$object->name_alias.'
'; $morehtmlref.='
'; $morehtmlref.=$object->getBannerAddress('refaddress',$object); $morehtmlref.='
'; From a953a66616347229b86ea3747bfbfdfaa2813dcd Mon Sep 17 00:00:00 2001 From: Maxime Kohlhaas Date: Mon, 19 Oct 2015 19:05:04 +0200 Subject: [PATCH 2/4] New : allow to define list size for object list on customer card --- htdocs/admin/ihm.php | 12 ++++++++++++ htdocs/comm/card.php | 2 +- htdocs/install/mysql/data/llx_const.sql | 1 + htdocs/install/mysql/migration/3.8.0-3.9.0.sql | 1 + 4 files changed, 15 insertions(+), 1 deletion(-) diff --git a/htdocs/admin/ihm.php b/htdocs/admin/ihm.php index 8d93dfc950c..fc1cdaf8971 100644 --- a/htdocs/admin/ihm.php +++ b/htdocs/admin/ihm.php @@ -57,6 +57,7 @@ if ($action == 'update') dolibarr_set_const($db, "MAIN_LANG_DEFAULT", $_POST["main_lang_default"],'chaine',0,'',$conf->entity); dolibarr_set_const($db, "MAIN_MULTILANGS", $_POST["main_multilangs"],'chaine',0,'',$conf->entity); dolibarr_set_const($db, "MAIN_SIZE_LISTE_LIMIT", $_POST["main_size_liste_limit"],'chaine',0,'',$conf->entity); + dolibarr_set_const($db, "MAIN_SIZE_SHORTLISTE_LIMIT", $_POST["main_size_shortliste_limit"],'chaine',0,'',$conf->entity); dolibarr_set_const($db, "MAIN_DISABLE_JAVASCRIPT", $_POST["main_disable_javascript"],'chaine',0,'',$conf->entity); dolibarr_set_const($db, "MAIN_BUTTON_HIDE_UNAUTHORIZED", $_POST["MAIN_BUTTON_HIDE_UNAUTHORIZED"],'chaine',0,'',$conf->entity); dolibarr_set_const($db, "MAIN_START_WEEK", $_POST["MAIN_START_WEEK"],'chaine',0,'',$conf->entity); @@ -204,6 +205,12 @@ if ($action == 'edit') // Edit print ' '; print ''; + // Max size of short lists on customer card + $var=!$var; + print ''.$langs->trans("DefaultMaxSizeShortListCustomerCard").''; + print ' '; + print ''; + // Disable javascript and ajax $var=!$var; print ''.$langs->trans("DisableJavascript").''; @@ -385,6 +392,11 @@ else // Show print ''.$langs->trans("DefaultMaxSizeList").'' . $conf->global->MAIN_SIZE_LISTE_LIMIT . ''; print ' '; print ""; + + $var=!$var; + print ''.$langs->trans("DefaultMaxSizeShortListCustomerCard").'' . $conf->global->MAIN_SIZE_SHORTLISTE_LIMIT . ''; + print ' '; + print ""; // Disable javascript/ajax $var=!$var; diff --git a/htdocs/comm/card.php b/htdocs/comm/card.php index a44a79da1f0..edd64d97706 100644 --- a/htdocs/comm/card.php +++ b/htdocs/comm/card.php @@ -491,7 +491,7 @@ if ($id > 0) // Nbre max d'elements des petites listes - $MAXLIST=4; + $MAXLIST=$conf->global->MAIN_SIZE_SHORTLISTE_LIMIT; $tableaushown=1; // Lien recap diff --git a/htdocs/install/mysql/data/llx_const.sql b/htdocs/install/mysql/data/llx_const.sql index 2c25765223e..95dfb2683f9 100644 --- a/htdocs/install/mysql/data/llx_const.sql +++ b/htdocs/install/mysql/data/llx_const.sql @@ -53,6 +53,7 @@ insert into llx_const (name, value, type, note, visible, entity) values ('MAIN_M -- IHM -- insert into llx_const (name, value, type, note, visible, entity) values ('MAIN_SIZE_LISTE_LIMIT','25','chaine','Longueur maximum des listes',0,0); +insert into llx_const (name, value, type, note, visible, entity) values ('MAIN_SIZE_SHORTLISTE_LIMIT','4','chaine','Longueur maximum des listes courtes (fiche client)',0,0); insert into llx_const (name, value, type, note, visible, entity) values ('MAIN_SHOW_WORKBOARD','1','yesno','Affichage tableau de bord de travail Dolibarr',0,0); insert into llx_const (name, value, type, note, visible) values ('MAIN_MENU_STANDARD','eldy_menu.php','chaine','Menu manager for internal users',0); diff --git a/htdocs/install/mysql/migration/3.8.0-3.9.0.sql b/htdocs/install/mysql/migration/3.8.0-3.9.0.sql index 4942378e58c..34d75a695d9 100755 --- a/htdocs/install/mysql/migration/3.8.0-3.9.0.sql +++ b/htdocs/install/mysql/migration/3.8.0-3.9.0.sql @@ -20,6 +20,7 @@ INSERT INTO llx_const (name, value, type, note, visible) values (__ENCRYPT('MAIN_DELAY_EXPENSEREPORTS_TO_PAY')__,__ENCRYPT('31')__,'chaine','Tolérance de retard avant alerte (en jours) sur les notes de frais impayées',0); +INSERT INTO llx_const (name, value, type, note, visible) values ('MAIN_SIZE_SHORTLISTE_LIMIT','4','chaine','Longueur maximum des listes courtes (fiche client)',0); ALTER TABLE llx_accounting_system MODIFY COLUMN pcg_version varchar(32); ALTER TABLE llx_accountingaccount MODIFY COLUMN fk_pcg_version varchar(32); From 55657690bf398b0fa60582f12c77ccc3b82adac7 Mon Sep 17 00:00:00 2001 From: Maxime Kohlhaas Date: Mon, 19 Oct 2015 19:07:02 +0200 Subject: [PATCH 3/4] Remove unused var --- htdocs/comm/card.php | 3 --- 1 file changed, 3 deletions(-) diff --git a/htdocs/comm/card.php b/htdocs/comm/card.php index edd64d97706..5b9ada6c075 100644 --- a/htdocs/comm/card.php +++ b/htdocs/comm/card.php @@ -492,7 +492,6 @@ if ($id > 0) // Nbre max d'elements des petites listes $MAXLIST=$conf->global->MAIN_SIZE_SHORTLISTE_LIMIT; - $tableaushown=1; // Lien recap print ''; @@ -684,7 +683,6 @@ if ($id > 0) if ($num > 0) { print '
'; - $tableaushown=1; print ''; print '
'; print ''; @@ -868,7 +866,6 @@ if ($id > 0) { print '
'.$langs->trans("LastSendings",($num<=$MAXLIST?"":$MAXLIST)).''.$langs->trans("AllSendings").' '.$num.''.img_picto($langs->trans("Statistics"),'stats').'
'; - $tableaushown=1; print ''; print '
'; print ''; From 4de787411877e22295549bd45c7ab5733010ee6d Mon Sep 17 00:00:00 2001 From: Maxime Kohlhaas Date: Mon, 19 Oct 2015 20:36:25 +0200 Subject: [PATCH 4/4] New : review customer account summary and balance --- htdocs/comm/card.php | 26 ++--- htdocs/compta/recap-compta.php | 173 ++++++++++++++++++--------------- 2 files changed, 107 insertions(+), 92 deletions(-) diff --git a/htdocs/comm/card.php b/htdocs/comm/card.php index 5b9ada6c075..3e20d611785 100644 --- a/htdocs/comm/card.php +++ b/htdocs/comm/card.php @@ -376,17 +376,6 @@ if ($id > 0) $limit_field_type = (! empty($conf->global->MAIN_USE_JQUERY_JEDITABLE)) ? 'numeric' : 'amount'; print $form->editfieldval("OutstandingBill",'outstanding_limit',$object->outstanding_limit,$object,$user->rights->societe->creer,$limit_field_type,($object->outstanding_limit != '' ? price($object->outstanding_limit) : '')); if (empty($object->outstanding_limit)) print $langs->trans("NoLimit"); - // display amount and link to unpaid bill - $outstandingBills = $object->get_OutstandingBill(); - print ' (' . $langs->trans('CurrentOutstandingBill') . ': '; - print price($outstandingBills, '', $langs, 0, 0, - 1, $conf->currency); - if ($object->outstanding_limit != '') - { - if ($outstandingBills > $object->outstanding_limit) - print img_warning($langs->trans("OutstandingBillReached")); - //print ' / ' . price($soc->outstanding_limit); - } - print ')'; print ''; print ''; @@ -494,10 +483,21 @@ if ($id > 0) $MAXLIST=$conf->global->MAIN_SIZE_SHORTLISTE_LIMIT; // Lien recap + $outstandingBills = $object->get_OutstandingBill(); + $warn = ''; + if ($object->outstanding_limit != '' && $object->outstanding_limit < $outstandingBills) + { + $warn = img_warning($langs->trans("OutstandingBillReached")); + } + print '
'.$langs->trans("LastCustomersBills",($num<=$MAXLIST?"":$MAXLIST)).''.$langs->trans("AllBills").' '.$num.''.img_picto($langs->trans("Statistics"),'stats').'
'; print ''; - print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; print ''; print '
'; - print '
'.$langs->trans("Summary").''.$langs->trans("ShowCustomerPreview").'
'.$langs->trans("Summary").''.$langs->trans("ShowCustomerPreview").'
'.$langs->trans("CurrentOutstandingBill").''.price($outstandingBills).$warn.'
'; print '
'; diff --git a/htdocs/compta/recap-compta.php b/htdocs/compta/recap-compta.php index cfcd0a6f746..920419a8769 100644 --- a/htdocs/compta/recap-compta.php +++ b/htdocs/compta/recap-compta.php @@ -25,6 +25,7 @@ require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; +require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php'; $langs->load("companies"); if (! empty($conf->facture->enabled)) $langs->load("bills"); @@ -43,6 +44,7 @@ if ($user->societe_id > 0) * View */ +$form = new Form($db); $userstatic=new User($db); llxHeader(); @@ -58,28 +60,7 @@ if ($socid > 0) $head = societe_prepare_head($societe); dol_fiche_head($head, 'customer', $langs->trans("ThirdParty"), 0, 'company'); - - print "\n"; - print '
'; - - print ''; - - // Name - print ''; - - // Prefix - if (! empty($conf->global->SOCIETE_USEPREFIX)) // Old not used prefix field - { - print ''; - } - - print "
'.$langs->trans("Name").''.$societe->name.'
'.$langs->trans("Prefix").''; - print ($societe->prefix_comm?$societe->prefix_comm:' '); - print '
"; - - print "
\n"; - - print ''; + dol_banner_tab($societe, 'socid', '', ($user->societe_id?0:1), 'rowid', 'nom'); if (! empty($conf->facture->enabled) && $user->rights->facture->lire) { @@ -87,6 +68,18 @@ if ($socid > 0) print load_fiche_titre($langs->trans("CustomerPreview")); print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + + $TData = array(); + $TDataSort = array(); $sql = "SELECT s.nom, s.rowid as socid, f.facnumber, f.amount, f.datef as df,"; $sql.= " f.paye as paye, f.fk_statut as statut, f.rowid as facid,"; @@ -95,7 +88,7 @@ if ($socid > 0) $sql.= " WHERE f.fk_soc = s.rowid AND s.rowid = ".$societe->id; $sql.= " AND f.entity = ".$conf->entity; $sql.= " AND f.fk_user_valid = u.rowid"; - $sql.= " ORDER BY f.datef DESC"; + $sql.= " ORDER BY f.datef ASC"; $resql=$db->query($sql); if ($resql) @@ -103,23 +96,6 @@ if ($socid > 0) $var=true; $num = $db->num_rows($resql); - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - - if (! $num > 0) - { - print ''; - } - - $solde = 0; - // Boucle sur chaque facture for ($i = 0 ; $i < $num ; $i++) { @@ -133,29 +109,18 @@ if ($socid > 0) continue; } $totalpaye = $fac->getSommePaiement(); - - $var=!$var; - print ""; - - print "\n"; - print '\n"; - - print ''; - print '\n"; - if (($fac->statut == Facture::STATUS_ABANDONED ) || ($fac->statut == Facture::STATUS_CLOSED && ! $fact->close_code) ) $solde = $solde = $solde + $totalpaye; - else $solde = $solde + $fac->total_ttc; - - print ''; - print '\n"; - - // Author + $userstatic->id=$objf->userid; $userstatic->login=$objf->login; - print ''; - - print "\n"; + + $TData[] = array( + 'date' => $fac->date, + 'link' => $fac->getNomUrl(1), + 'status' => $fac->getLibStatut(2,$totalpaye), + 'amount' => $fac->total_ttc, + 'author' => $userstatic->getLoginUrl(1) + ); + $TDataSort[] = $fac->date; // Paiements $sql = "SELECT p.rowid, p.datep as dp, pf.amount, p.statut,"; @@ -166,6 +131,7 @@ if ($socid > 0) $sql.= " WHERE pf.fk_paiement = p.rowid"; $sql.= " AND p.entity = ".$conf->entity; $sql.= " AND pf.fk_facture = ".$fac->id; + $sql.= " ORDER BY p.datep ASC"; $resqlp = $db->query($sql); if ($resqlp) @@ -176,26 +142,21 @@ if ($socid > 0) while ($j < $nump) { $objp = $db->fetch_object($resqlp); - //$var=!$var; - print ""; - print '\n"; - print ''; - print "\n"; - print "\n"; - print ''; - $solde = $solde - $objp->amount; - print '\n"; - - // Author + + $paymentstatic = new Paiement($db); + $paymentstatic->id = $objp->rowid; + $userstatic->id=$objp->userid; $userstatic->login=$objp->login; - print ''; - - print ''; + + $TData[] = array( + 'date' => $db->jdate($objp->dp), + 'link' => $langs->trans("Payment") .' '. $paymentstatic->getNomUrl(1), + 'status' => '', + 'amount' => -$objp->amount, + 'author' => $userstatic->getLoginUrl(1) + ); + $TDataSort[] = $db->jdate($objp->dp); $j++; } @@ -212,9 +173,63 @@ if ($socid > 0) { dol_print_error($db); } + + if(empty($TData)) { + print ''; + } else { + + // Sort array by date + asort($TDataSort); + array_multisort($TData,$TDataSort); + + // Balance calculation + foreach($TData as &$data1) { + $balance += $data1['amount']; + $data1['balance'] += $balance; + } + + // Reverse array to have last elements on top + $TData = array_reverse($TData); + + $totalDebit = 0; + $totalCredit = 0; + + // Display array + foreach($TData as $data) { + $var=!$var; + print ""; + + print "\n"; + print '\n"; + + print ''; + print '\n"; + $totalDebit += ($data['amount'] > 0) ? abs($data['amount']) : 0; + print '\n"; + $totalCredit += ($data['amount'] > 0) ? 0 : abs($data['amount']); + print '\n"; + + // Author + print ''; + + print "\n"; + } + + print ''; + print ''; + print ''; + print ''; + print ''; + print "\n"; + } + print "
'.$langs->trans("Date").''.$langs->trans("Element").''.$langs->trans("Status").''.$langs->trans("Debit").''.$langs->trans("Credit").''.$langs->trans("Balance").''.$langs->trans("Author").'
'.$langs->trans("Date").' '.$langs->trans("Status").''.$langs->trans("Debit").''.$langs->trans("Credit").''.$langs->trans("Balance").' 
'.$langs->trans("NoInvoice").'
".dol_print_date($fac->date,'day')."'.img_object($langs->trans("ShowBill"),"bill")." ".$fac->ref."'.$fac->getLibStatut(2,$totalpaye).''.price($fac->total_ttc)." '.price($solde)."'; - print $userstatic->getLoginUrl(1); - print '
'.dol_print_date($db->jdate($objp->dp),'day')."'; - print '      '; // Decalage - print ''.img_object($langs->trans("ShowPayment"),"payment").' '.$langs->trans("Payment").' '.$objp->rowid.'  '.price($objp->amount).''.price($solde)."'; - print $userstatic->getLoginUrl(1); - print '
'.$langs->trans("NoInvoice").'
".dol_print_date($data['date'],'day')."'.$data['link']."'.$data['status'].''.(($data['amount'] > 0) ? price(abs($data['amount'])) : '')."'.(($data['amount'] > 0) ? '' : price(abs($data['amount'])))."'.price($data['balance'])."'; + print $data['author']; + print '
 '.price($totalDebit).''.price($totalCredit).' 
"; print "
"; } + + print ''; } else {