From ef0907d89e6d44daa701fc4cea194451867ad368 Mon Sep 17 00:00:00 2001 From: alexis Algoud Date: Tue, 13 Jun 2017 15:55:22 +0200 Subject: [PATCH 001/227] NEW log download or preview event on a validate bill --- htdocs/blockedlog/ajax/block-add.php | 19 ++++++++++++ htdocs/compta/facture/card.php | 31 +++++++++++++++++++ htdocs/core/class/html.formfile.class.php | 2 +- ..._modBlockedlog_ActionsBlockedLog.class.php | 3 +- htdocs/langs/en_US/blockedlog.lang | 4 ++- 5 files changed, 56 insertions(+), 3 deletions(-) create mode 100644 htdocs/blockedlog/ajax/block-add.php diff --git a/htdocs/blockedlog/ajax/block-add.php b/htdocs/blockedlog/ajax/block-add.php new file mode 100644 index 00000000000..247b01186fe --- /dev/null +++ b/htdocs/blockedlog/ajax/block-add.php @@ -0,0 +1,19 @@ +fetch($id)>0) { + $facture->call_trigger($action, $user); + } + + } + \ No newline at end of file diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index c4bf83293de..ffab33275a7 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -4248,6 +4248,37 @@ else if ($id > 0 || ! empty($ref)) $delallowed = $user->rights->facture->supprimer; print $formfile->showdocuments('facture', $filename, $filedir, $urlsource, $genallowed, $delallowed, $object->modelpdf, 1, 0, 0, 28, 0, '', '', '', $soc->default_lang); + + if(!empty($conf->blockedlog->enabled) && $object->statut>0) { + ?> + + numoffiles; // Show links to link elements diff --git a/htdocs/core/class/html.formfile.class.php b/htdocs/core/class/html.formfile.class.php index 89cf70951ad..44a90794790 100644 --- a/htdocs/core/class/html.formfile.class.php +++ b/htdocs/core/class/html.formfile.class.php @@ -712,7 +712,7 @@ class FormFile $out.= ''; $tmp = $this->showPreview($file,$modulepart,$relativepath,0,$param); $out.= ($tmp?$tmp.' ':''); - $out.= 'total_ttc; } else if($action === 'PAYMENT_CUSTOMER_CREATE' || $action === 'PAYMENT_ADD_TO_BANK') { diff --git a/htdocs/langs/en_US/blockedlog.lang b/htdocs/langs/en_US/blockedlog.lang index 7e64bfad17f..fcad52508bd 100644 --- a/htdocs/langs/en_US/blockedlog.lang +++ b/htdocs/langs/en_US/blockedlog.lang @@ -18,4 +18,6 @@ logBILL_VALIDATE=Customer bill set valid from draft logBILL_SENTBYMAIL=Customer bill send by mail BlockedlogInfoDialog=Log Details Fingerprint=Fingerprint -DownloadLogCSV=Download fingerprints CSV \ No newline at end of file +DownloadLogCSV=Download fingerprints CSV +logPREVIEW_BILL=Preview of a validated customer bill in order to print or download +logDOWNLOAD_BILL=Download of a validated customer bill in order to print or send \ No newline at end of file From 50aa40da3b67077476fefb70d5fdcb23d7be7714 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Wed, 14 Jun 2017 07:40:11 +0200 Subject: [PATCH 002/227] Fix: error when the project module not enabled --- htdocs/comm/action/card.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/htdocs/comm/action/card.php b/htdocs/comm/action/card.php index 60486ac6f01..5e38a85898e 100644 --- a/htdocs/comm/action/card.php +++ b/htdocs/comm/action/card.php @@ -2,7 +2,7 @@ /* Copyright (C) 2001-2005 Rodolphe Quiedeville * Copyright (C) 2004-2017 Laurent Destailleur * Copyright (C) 2005 Simon TOSSER - * Copyright (C) 2005-2012 Regis Houssin + * Copyright (C) 2005-2017 Regis Houssin * Copyright (C) 2010-2013 Juanjo Menent * Copyright (C) 2013 Florian Henry * Copyright (C) 2014 Cedric GROSS @@ -585,8 +585,6 @@ if ($action == 'mupdate') * View */ -$formproject=new FormProjets($db); - $help_url='EN:Module_Agenda_En|FR:Module_Agenda|ES:M&omodulodulo_Agenda'; llxHeader('',$langs->trans("Agenda"),$help_url); From d2db5f60a89604f2625bfc8a9111b58fa0e31478 Mon Sep 17 00:00:00 2001 From: phf Date: Wed, 14 Jun 2017 09:42:05 +0200 Subject: [PATCH 003/227] Fix css to apply "pair" and "impair" style --- htdocs/compta/facture.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php index 59e52ac7b5d..9bb97d8ff0b 100644 --- a/htdocs/compta/facture.php +++ b/htdocs/compta/facture.php @@ -3490,7 +3490,7 @@ else if ($id > 0 || ! empty($ref)) if ($object->type == Facture::TYPE_SITUATION && ! empty($conf->global->INVOICE_USE_SITUATION)) { if (count($object->tab_previous_situation_invoice) > 0 || count($object->tab_next_situation_invoice) > 0) - print ''; + print '
'; if (count($object->tab_previous_situation_invoice) > 0) { // List of previous invoices From 1b56e4a01c244505fa4ee9881c8ce5eba3ab84dc Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 14 Jun 2017 11:28:42 +0200 Subject: [PATCH 004/227] Fix look and feel v6 --- htdocs/comm/propal/list.php | 104 ++++++++-------- htdocs/commande/list.php | 6 +- htdocs/compta/facture/list.php | 8 +- htdocs/contrat/list.php | 48 ++++---- htdocs/core/class/html.formother.class.php | 13 +- htdocs/core/menus/init_menu_auguria.sql | 9 +- htdocs/core/menus/standard/auguria.lib.php | 2 + htdocs/expensereport/list.php | 26 ++-- htdocs/fourn/commande/list.php | 131 ++++++++++----------- htdocs/fourn/facture/list.php | 112 +++++++++--------- htdocs/holiday/list.php | 12 +- htdocs/projet/list.php | 6 +- htdocs/projet/tasks/list.php | 6 +- 13 files changed, 241 insertions(+), 242 deletions(-) diff --git a/htdocs/comm/propal/list.php b/htdocs/comm/propal/list.php index 220422a6404..47a35ff47a1 100644 --- a/htdocs/comm/propal/list.php +++ b/htdocs/comm/propal/list.php @@ -161,7 +161,7 @@ if (is_array($extrafields->attribute_label) && count($extrafields->attribute_lab } } -$object = new Propal($db); // To be passed as parameter of executeHooks that need +$object = new Propal($db); // To be passed as parameter of executeHooks that need /* @@ -359,12 +359,12 @@ if ($resql) else { $title = $langs->trans('ListOfProposals'); - } + } $num = $db->num_rows($resql); - + $arrayofselected=is_array($toselect)?$toselect:array(); - + $param='&viewstatut='.$viewstatut; if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage; if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit; @@ -389,7 +389,7 @@ if ($resql) $tmpkey=preg_replace('/search_options_/','',$key); if ($val != '') $param.='&search_options_'.$tmpkey.'='.urlencode($val); } - + // List of mass actions available $arrayofmassactions = array( 'presend'=>$langs->trans("SendByMail"), @@ -398,7 +398,7 @@ if ($resql) if ($user->rights->propal->supprimer) $arrayofmassactions['delete']=$langs->trans("Delete"); if ($massaction == 'presend') $arrayofmassactions=array(); $massactionbutton=$form->selectMassAction('', $arrayofmassactions); - + // Lignes des champs de filtre print '
'; if ($optioncss != '') print ''; @@ -408,13 +408,13 @@ if ($resql) print ''; print ''; print ''; - + print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'title_commercial.png', 0, '', '', $limit); - + if ($massaction == 'presend') { $langs->load("mails"); - + if (! GETPOST('cancel')) { $objecttmp=new Propal($db); @@ -433,17 +433,17 @@ if ($resql) } } } - + print ''; - + include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php'; $formmail = new FormMail($db); - + dol_fiche_head(null, '', ''); - + $topicmail="SendSupplierProposalRef"; $modelmail="supplier_proposal_send"; - + // Cree l'objet formulaire mail include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php'; $formmail = new FormMail($db); @@ -496,25 +496,25 @@ if ($resql) $formmail->substit['__REFCLIENT__']='__REFCLIENT__'; // We want to keep the tag $formmail->substit['__PERSONALIZED__']=''; $formmail->substit['__CONTACTCIVNAME__']=''; - + // Tableau des parametres complementaires du post $formmail->param['action']=$action; $formmail->param['models']=$modelmail; $formmail->param['models_id']=GETPOST('modelmailselected','int'); $formmail->param['id']=join(',',$arrayofselected); //$formmail->param['returnurl']=$_SERVER["PHP_SELF"].'?id='.$object->id; - + print $formmail->get_form(); - + dol_fiche_end(); } - + if ($sall) { foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val); print $langs->trans("FilterOnInto", $sall) . join(', ',$fieldstosearchall); } - + $i = 0; $moreforfilter=''; @@ -525,7 +525,7 @@ if ($resql) $langs->load("commercial"); $moreforfilter.='
'; $moreforfilter.=$langs->trans('ThirdPartiesOfSaleRepresentative'). ': '; - $moreforfilter.=$formother->select_salesrepresentatives($search_sale, 'search_sale', $user, 0, 1, 'maxwidth300'); + $moreforfilter.=$formother->select_salesrepresentatives($search_sale, 'search_sale', $user, 0, 1, 'maxwidth200'); $moreforfilter.='
'; } // If the user can view prospects other than his' @@ -533,7 +533,7 @@ if ($resql) { $moreforfilter.='
'; $moreforfilter.=$langs->trans('LinkedToSpecificUsers'). ': '; - $moreforfilter.=$form->select_dolusers($search_user, 'search_user', 1, '', 0, '', '', 0, 0, 0, '', 0, '', 'maxwidth300'); + $moreforfilter.=$form->select_dolusers($search_user, 'search_user', 1, '', 0, '', '', 0, 0, 0, '', 0, '', 'maxwidth200'); $moreforfilter.='
'; } // If the user can view products @@ -550,7 +550,7 @@ if ($resql) $reshook=$hookmanager->executeHooks('printFieldPreListTitle',$parameters); // Note that $action and $object may have been modified by hook if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint; else $moreforfilter = $hookmanager->resPrint; - + if (! empty($moreforfilter)) { print '
'; @@ -561,12 +561,12 @@ if ($resql) $varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage; $selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields if ($massactionbutton) $selectedfields.=$form->showCheckAddButtons('checkforselect', 1); - + print '
'; print '
'."\n"; print ''; - if (! empty($arrayfields['p.ref']['checked'])) + if (! empty($arrayfields['p.ref']['checked'])) { print ''; } // Date - if (! empty($arrayfields['p.date']['checked'])) + if (! empty($arrayfields['p.date']['checked'])) { print ''; } // Date end - if (! empty($arrayfields['p.fin_validite']['checked'])) + if (! empty($arrayfields['p.fin_validite']['checked'])) { print ''; } @@ -703,10 +703,10 @@ if ($resql) $searchpicto=$form->showFilterButtons(); print $searchpicto; print ''; - + print "\n"; - + // Fields title print ''; if (! empty($arrayfields['p.ref']['checked'])) print_liste_field_titre($arrayfields['p.ref']['label'],$_SERVER["PHP_SELF"],'p.ref','',$param,'',$sortfield,$sortorder); @@ -726,9 +726,9 @@ if ($resql) // Extra fields if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) { - foreach($extrafields->attribute_label as $key => $val) + foreach($extrafields->attribute_label as $key => $val) { - if (! empty($arrayfields["ef.".$key]['checked'])) + if (! empty($arrayfields["ef.".$key]['checked'])) { $align=$extrafields->getAlignFlag($key); print_liste_field_titre($langs->trans($extralabels[$key]),$_SERVER["PHP_SELF"],"ef.".$key,"",$param,($align?'align="'.$align.'"':''),$sortfield,$sortorder); @@ -744,24 +744,24 @@ if ($resql) if (! empty($arrayfields['p.fk_statut']['checked'])) print_liste_field_titre($arrayfields['p.fk_statut']['label'],$_SERVER["PHP_SELF"],"p.fk_statut","",$param,'align="right"',$sortfield,$sortorder); print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"],"",'','','align="center"',$sortfield,$sortorder,'maxwidthsearch '); print ''."\n"; - + $now = dol_now(); $i=0; $totalarray=array(); while ($i < min($num,$limit)) { $obj = $db->fetch_object($resql); - - + + $objectstatic->id=$obj->rowid; $objectstatic->ref=$obj->ref; - + print ''; - + if (! empty($arrayfields['p.ref']['checked'])) { print '\n"; if (! $i) $totalarray['nbfield']++; } - + if (! empty($arrayfields['p.ref_client']['checked'])) { // Customer ref @@ -803,12 +803,12 @@ if ($resql) print ''; if (! $i) $totalarray['nbfield']++; } - + $companystatic->id=$obj->socid; $companystatic->name=$obj->name; $companystatic->client=$obj->client; $companystatic->code_client=$obj->code_client; - + // Thirdparty if (! empty($arrayfields['s.nom']['checked'])) { @@ -817,7 +817,7 @@ if ($resql) print ''; if (! $i) $totalarray['nbfield']++; } - + // Town if (! empty($arrayfields['s.town']['checked'])) { @@ -858,7 +858,7 @@ if ($resql) print ''; if (! $i) $totalarray['nbfield']++; } - + // Date proposal if (! empty($arrayfields['p.date']['checked'])) { @@ -867,7 +867,7 @@ if ($resql) print "\n"; if (! $i) $totalarray['nbfield']++; } - + // Date end validity if (! empty($arrayfields['p.fin_validite']['checked'])) { @@ -882,7 +882,7 @@ if ($resql) } if (! $i) $totalarray['nbfield']++; } - + // Amount HT if (! empty($arrayfields['p.total_ht']['checked'])) { @@ -907,7 +907,7 @@ if ($resql) if (! $i) $totalarray['totalttcfield']=$totalarray['nbfield']; $totalarray['totalttc'] += $obj->total_ttc; } - + $userstatic->id=$obj->fk_user_author; $userstatic->login=$obj->login; @@ -920,7 +920,7 @@ if ($resql) print "\n"; if (! $i) $totalarray['nbfield']++; } - + // Extra fields if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) { @@ -1008,16 +1008,16 @@ if ($resql) } $db->free($resql); - + $parameters=array('arrayfields'=>$arrayfields, 'sql'=>$sql); $reshook=$hookmanager->executeHooks('printFieldListFooter',$parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; - + print '
'; print ''; @@ -608,7 +608,7 @@ if ($resql) print ''; //print $langs->trans('Month').': '; @@ -620,7 +620,7 @@ if ($resql) print ' 
'; - + print ''; // Picto + Ref print '
'; @@ -790,11 +790,11 @@ if ($resql) $urlsource=$_SERVER['PHP_SELF'].'?id='.$obj->rowid; print $formfile->getDocumentsLink($objectstatic->element, $filename, $filedir); print '
'; - + print "
'."\n"; print ''."\n"; print ''."\n"; - + if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) { /* @@ -1025,18 +1025,18 @@ if ($resql) */ $urlsource=$_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder; $urlsource.=str_replace('&','&',$param); - + $filedir=$diroutputmassaction; $genallowed=$user->rights->propal->lire; $delallowed=$user->rights->propal->lire; - + print $formfile->showdocuments('massfilesarea_proposals','',$filedir,$urlsource,0,$delallowed,'',1,1,0,48,1,$param,'',''); } else { print '
'.$langs->trans("ShowTempMassFilesArea").''; } - + } else { diff --git a/htdocs/commande/list.php b/htdocs/commande/list.php index c49c1b18a4a..daefc3c4cce 100644 --- a/htdocs/commande/list.php +++ b/htdocs/commande/list.php @@ -803,7 +803,7 @@ if ($resql) $langs->load("commercial"); $moreforfilter.='
'; $moreforfilter.=$langs->trans('ThirdPartiesOfSaleRepresentative'). ': '; - $moreforfilter.=$formother->select_salesrepresentatives($search_sale, 'search_sale', $user, 0, 1, 'maxwidth300'); + $moreforfilter.=$formother->select_salesrepresentatives($search_sale, 'search_sale', $user, 0, 1, 'maxwidth200'); $moreforfilter.='
'; } // If the user can view other users @@ -811,7 +811,7 @@ if ($resql) { $moreforfilter.='
'; $moreforfilter.=$langs->trans('LinkedToSpecificUsers'). ': '; - $moreforfilter.=$form->select_dolusers($search_user, 'search_user', 1, '', 0, '', '', 0, 0, 0, '', 0, '', 'maxwidth300'); + $moreforfilter.=$form->select_dolusers($search_user, 'search_user', 1, '', 0, '', '', 0, 0, 0, '', 0, '', 'maxwidth200'); $moreforfilter.='
'; } // If the user can view prospects other than his' @@ -821,7 +821,7 @@ if ($resql) $moreforfilter.='
'; $moreforfilter.=$langs->trans('IncludingProductWithTag'). ': '; $cate_arbo = $form->select_all_categories(Categorie::TYPE_PRODUCT, null, 'parent', null, null, 1); - $moreforfilter.=$form->selectarray('search_product_category', $cate_arbo, $search_product_category, 1, 0, 0, '', 0, 0, 0, 0, '', 1); + $moreforfilter.=$form->selectarray('search_product_category', $cate_arbo, $search_product_category, 1, 0, 0, '', 0, 0, 0, 0, 'maxwidth300', 1); $moreforfilter.='
'; } $parameters=array(); diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php index cf037942324..2716e3a87b1 100644 --- a/htdocs/compta/facture/list.php +++ b/htdocs/compta/facture/list.php @@ -191,7 +191,7 @@ if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'e include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; // Do we click on purge search criteria ? -if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter") || GETPOST("button_removefilter.x")) // Both test are required to be compatible with all browsers +if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter") || GETPOST("button_removefilter.x")) // All tests are required to be compatible with all browsers { $search_user=''; $search_sale=''; @@ -717,7 +717,7 @@ if ($resql) $langs->load("commercial"); $moreforfilter.='
'; $moreforfilter.=$langs->trans('ThirdPartiesOfSaleRepresentative'). ': '; - $moreforfilter.=$formother->select_salesrepresentatives($search_sale, 'search_sale', $user, 0, 1, 'maxwidth300'); + $moreforfilter.=$formother->select_salesrepresentatives($search_sale, 'search_sale', $user, 0, 1, 'maxwidth200'); $moreforfilter.='
'; } // If the user can view prospects other than his' @@ -725,7 +725,7 @@ if ($resql) { $moreforfilter.='
'; $moreforfilter.=$langs->trans('LinkedToSpecificUsers'). ': '; - $moreforfilter.=$form->select_dolusers($search_user, 'search_user', 1, '', 0, '', '', 0, 0, 0, '', 0, '', 'maxwidth300'); + $moreforfilter.=$form->select_dolusers($search_user, 'search_user', 1, '', 0, '', '', 0, 0, 0, '', 0, '', 'maxwidth200'); $moreforfilter.='
'; } // If the user can view prospects other than his' @@ -735,7 +735,7 @@ if ($resql) $moreforfilter.='
'; $moreforfilter.=$langs->trans('IncludingProductWithTag'). ': '; $cate_arbo = $form->select_all_categories(Categorie::TYPE_PRODUCT, null, 'parent', null, null, 1); - $moreforfilter.=$form->selectarray('search_product_category', $cate_arbo, $search_product_category, 1, 0, 0, '', 0, 0, 0, 0, '', 1); + $moreforfilter.=$form->selectarray('search_product_category', $cate_arbo, $search_product_category, 1, 0, 0, '', 0, 0, 0, 0, 'maxwidth300', 1); $moreforfilter.='
'; } $parameters=array(); diff --git a/htdocs/contrat/list.php b/htdocs/contrat/list.php index 29e13412892..a82535bfbb7 100644 --- a/htdocs/contrat/list.php +++ b/htdocs/contrat/list.php @@ -305,7 +305,7 @@ if ($resql) $i = 0; $arrayofselected=is_array($toselect)?$toselect:array(); - + $param=''; if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage; if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit; @@ -323,7 +323,7 @@ if ($resql) $tmpkey=preg_replace('/search_options_/','',$key); if ($val != '') $param.='&search_options_'.$tmpkey.'='.urlencode($val); } - + // List of mass actions available $arrayofmassactions = array( //'presend'=>$langs->trans("SendByMail"), @@ -332,7 +332,7 @@ if ($resql) if ($user->rights->contrat->supprimer) $arrayofmassactions['delete']=$langs->trans("Delete"); if ($massaction == 'presend') $arrayofmassactions=array(); $massactionbutton=$form->selectMassAction('', $arrayofmassactions); - + print '
'; if ($optioncss != '') print ''; print ''; @@ -341,7 +341,7 @@ if ($resql) print ''; print ''; print ''; - + print_barre_liste($langs->trans("ListOfContracts"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $totalnboflines, 'title_commercial.png', 0, '', '', $limit); if ($sall) @@ -349,16 +349,16 @@ if ($resql) foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val); print $langs->trans("FilterOnInto", $sall) . join(', ',$fieldstosearchall); } - + $moreforfilter=''; - + // If the user can view prospects other than his' if ($user->rights->societe->client->voir || $socid) { $langs->load("commercial"); $moreforfilter.='
'; $moreforfilter.=$langs->trans('ThirdPartiesOfSaleRepresentative'). ': '; - $moreforfilter.=$formother->select_salesrepresentatives($search_sale,'search_sale',$user,0,1,'maxwidth300'); + $moreforfilter.=$formother->select_salesrepresentatives($search_sale,'search_sale',$user,0,1,'maxwidth200'); $moreforfilter.='
'; } // If the user can view other users @@ -366,7 +366,7 @@ if ($resql) { $moreforfilter.='
'; $moreforfilter.=$langs->trans('LinkedToSpecificUsers'). ': '; - $moreforfilter.=$form->select_dolusers($search_user, 'search_user', 1, '', 0, '', '', 0, 0, 0, '', 0, '', 'maxwidth300'); + $moreforfilter.=$form->select_dolusers($search_user, 'search_user', 1, '', 0, '', '', 0, 0, 0, '', 0, '', 'maxwidth200'); $moreforfilter.='
'; } // If the user can view categories of products @@ -376,15 +376,15 @@ if ($resql) $moreforfilter.='
'; $moreforfilter.=$langs->trans('IncludingProductWithTag'). ': '; $cate_arbo = $form->select_all_categories(Categorie::TYPE_PRODUCT, null, 'parent', null, null, 1); - $moreforfilter.=$form->selectarray('search_product_category', $cate_arbo, $search_product_category, 1, 0, 0, '', 0, 0, 0, 0, '', 1); + $moreforfilter.=$form->selectarray('search_product_category', $cate_arbo, $search_product_category, 1, 0, 0, '', 0, 0, 0, 0, 'maxwidth300', 1); $moreforfilter.='
'; } - + $parameters=array(); $reshook=$hookmanager->executeHooks('printFieldPreListTitle',$parameters); // Note that $action and $object may have been modified by hook if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint; else $moreforfilter = $hookmanager->resPrint; - + if (! empty($moreforfilter)) { print '
'; @@ -395,7 +395,7 @@ if ($resql) $varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage; $selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields if ($massactionbutton) $selectedfields.=$form->showCheckAddButtons('checkforselect', 1); - + print '
'; print ''."\n"; @@ -514,7 +514,7 @@ if ($resql) print $searchpicto; print ''; print "\n"; - + print ''; if (! empty($arrayfields['c.ref']['checked'])) print_liste_field_titre($arrayfields['c.ref']['label'], $_SERVER["PHP_SELF"], "c.ref","","$param",'',$sortfield,$sortorder); if (! empty($arrayfields['c.ref_customer']['checked'])) print_liste_field_titre($arrayfields['c.ref_customer']['label'], $_SERVER["PHP_SELF"], "c.ref_customer","","$param",'',$sortfield,$sortorder); @@ -530,9 +530,9 @@ if ($resql) // Extra fields if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) { - foreach($extrafields->attribute_label as $key => $val) + foreach($extrafields->attribute_label as $key => $val) { - if (! empty($arrayfields["ef.".$key]['checked'])) + if (! empty($arrayfields["ef.".$key]['checked'])) { $align=$extrafields->getAlignFlag($key); print_liste_field_titre($langs->trans($extralabels[$key]),$_SERVER["PHP_SELF"],"ef.".$key,"",$param,($align?'align="'.$align.'"':''),$sortfield,$sortorder); @@ -558,12 +558,12 @@ if ($resql) while ($i < min($num,$limit)) { $obj = $db->fetch_object($resql); - + $contracttmp->ref=$obj->ref; $contracttmp->id=$obj->rowid; $contracttmp->ref_customer=$obj->ref_customer; $contracttmp->ref_supplier=$obj->ref_supplier; - + print ''; if (! empty($arrayfields['c.ref']['checked'])) { @@ -578,15 +578,15 @@ if ($resql) } print ''; } - if (! empty($arrayfields['c.ref_customer']['checked'])) + if (! empty($arrayfields['c.ref_customer']['checked'])) { print ''; } - if (! empty($arrayfields['c.ref_supplier']['checked'])) + if (! empty($arrayfields['c.ref_supplier']['checked'])) { print ''; } - if (! empty($arrayfields['s.nom']['checked'])) + if (! empty($arrayfields['s.nom']['checked'])) { print ''; } @@ -629,7 +629,7 @@ if ($resql) print $typenArray[$obj->typent_code]; print ''; if (! $i) $totalarray['nbfield']++; - } + } if (! empty($arrayfields['sale_representative']['checked'])) { // Sales representatives @@ -713,7 +713,7 @@ if ($resql) if (! $i) $totalarray['nbfield']++; } // Status - if (! empty($arrayfields['status']['checked'])) + if (! empty($arrayfields['status']['checked'])) { print ''; print ''; @@ -730,7 +730,7 @@ if ($resql) } print ''; if (! $i) $totalarray['nbfield']++; - + print "\n"; $i++; } @@ -738,7 +738,7 @@ if ($resql) print '
'.$obj->ref_customer.''.$obj->ref_supplier.''.img_object($langs->trans("ShowCompany"),"company").' '.$obj->name.''.($obj->nb_initial>0?$obj->nb_initial:'').''.($obj->nb_running>0?$obj->nb_running:'').'
'; print '
'; - + print ''; } else diff --git a/htdocs/core/class/html.formother.class.php b/htdocs/core/class/html.formother.class.php index c5344ab467a..5af4024f9c2 100644 --- a/htdocs/core/class/html.formother.class.php +++ b/htdocs/core/class/html.formother.class.php @@ -309,10 +309,11 @@ class FormOther * @param string $htmlname Name of combo list * @param int $nocateg Show also an entry "Not categorized" * @param int $showempty Add also an empty line - * @return string Html combo list code + * @param string $morecss More CSS + * @return string Html combo list code * @see select_all_categories */ - function select_categories($type,$selected=0,$htmlname='search_categ',$nocateg=0,$showempty=1) + function select_categories($type, $selected=0, $htmlname='search_categ', $nocateg=0, $showempty=1, $morecss='') { global $conf, $langs; require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; @@ -328,18 +329,16 @@ class FormOther $tab_categs = $static_categs->get_full_arbo($type); $moreforfilter = ''; - $nodatarole = ''; // Enhance with select2 if ($conf->use_javascript_ajax) { include_once DOL_DOCUMENT_ROOT . '/core/lib/ajax.lib.php'; $comboenhancement = ajax_combobox('select_categ_'.$htmlname); $moreforfilter.=$comboenhancement; - $nodatarole=($comboenhancement?' data-role="none"':''); } // Print a select with each of them - $moreforfilter.=''; if ($showempty) $moreforfilter.=''; // Should use -1 to say nothing if (is_array($tab_categs)) @@ -379,7 +378,6 @@ class FormOther $langs->load('users'); $out = ''; - $nodatarole = ''; // Enhance with select2 if ($conf->use_javascript_ajax) { @@ -389,11 +387,10 @@ class FormOther if ($comboenhancement) { $out.=$comboenhancement; - $nodatarole=($comboenhancement?' data-role="none"':''); } } // Select each sales and print them in a select input - $out.=''; if ($showempty) $out.=''; // Get list of users allowed to be viewed diff --git a/htdocs/core/menus/init_menu_auguria.sql b/htdocs/core/menus/init_menu_auguria.sql index 6115b6cff0d..c1de978d2df 100644 --- a/htdocs/core/menus/init_menu_auguria.sql +++ b/htdocs/core/menus/init_menu_auguria.sql @@ -166,8 +166,9 @@ insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, left -- Accountancy - Supplier invoice insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->supplier_invoice->enabled', __HANDLER__, 'left', 1600__+MAX_llx_menu__, 'accountancy', 'supplier_bills', 6__+MAX_llx_menu__, '/fourn/facture/list.php?leftmenu=suppliers_bills', 'BillsSuppliers', 0, 'bills', '$user->rights->fournisseur->facture->lire', '', 2, 3, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->supplier_invoice->enabled', __HANDLER__, 'left', 1601__+MAX_llx_menu__, 'accountancy', '', 1600__+MAX_llx_menu__, '/fourn/facture/card.php?action=create&leftmenu=suppliers_bills', 'NewBill', 1, 'bills', '$user->rights->fournisseur->facture->creer', '', 2, 0, __ENTITY__); -insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->supplier_invoice->enabled', __HANDLER__, 'left', 1602__+MAX_llx_menu__, 'accountancy', '', 1600__+MAX_llx_menu__, '/fourn/facture/impayees.php?leftmenu=suppliers_bills', 'Unpaid', 1, 'bills', '$user->rights->fournisseur->facture->lire', '', 2, 1, __ENTITY__); +insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->supplier_invoice->enabled', __HANDLER__, 'left', 1602__+MAX_llx_menu__, 'accountancy', '', 1600__+MAX_llx_menu__, '/fourn/facture/list.php?leftmenu=suppliers_bills', 'List', 1, 'bills', '$user->rights->fournisseur->facture->lire', '', 2, 1, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->supplier_invoice->enabled', __HANDLER__, 'left', 1603__+MAX_llx_menu__, 'accountancy', '', 1600__+MAX_llx_menu__, '/fourn/facture/paiement.php?leftmenu=suppliers_bills', 'Payments', 1, 'bills', '$user->rights->fournisseur->facture->lire', '', 2, 2, __ENTITY__); +insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->supplier_invoice->enabled', __HANDLER__, 'left', 1605__+MAX_llx_menu__, 'accountancy', '', 1603__+MAX_llx_menu__, '/fourn/facture/rapport.php?leftmenu=suppliers_bills', 'Reporting', 2, 'bills', '$user->rights->fournisseur->facture->lire', '', 2, 1, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->supplier_invoice->enabled', __HANDLER__, 'left', 1604__+MAX_llx_menu__, 'accountancy', '', 1600__+MAX_llx_menu__, '/compta/facture/stats/index.php?leftmenu=customers_bills&mode=supplier', 'Statistics', 1, 'bills', '$user->rights->fournisseur->facture->lire', '', 2, 8, __ENTITY__); -- Accountancy - Customer invoice insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->facture->enabled', __HANDLER__, 'left', 1700__+MAX_llx_menu__, 'accountancy', 'customer_bills', 6__+MAX_llx_menu__, '/compta/facture/list.php?leftmenu=customers_bills', 'BillsCustomers', 0, 'bills', '$user->rights->facture->lire', '', 2, 3, __ENTITY__); @@ -275,9 +276,9 @@ insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, left insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->banque->enabled && ($leftmenu=="bank" || $leftmenu=="checks" || $leftmenu=="withdraw")', __HANDLER__, 'left', 2603__+MAX_llx_menu__, 'accountancy', '', 2600__+MAX_llx_menu__, '/compta/bank/bankentries.php?leftmenu=bank', 'ListTransactions', 1, 'banks', '$user->rights->banque->lire', '', 0, 2, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->banque->enabled && ($leftmenu=="bank" || $leftmenu=="checks" || $leftmenu=="withdraw")', __HANDLER__, 'left', 2604__+MAX_llx_menu__, 'accountancy', '', 2600__+MAX_llx_menu__, '/compta/bank/budget.php?leftmenu=bank', 'ListTransactionsByCategory', 1, 'banks', '$user->rights->banque->lire', '', 0, 3, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->banque->enabled && ($leftmenu=="bank" || $leftmenu=="checks" || $leftmenu=="withdraw")', __HANDLER__, 'left', 2606__+MAX_llx_menu__, 'accountancy', '', 2600__+MAX_llx_menu__, '/compta/bank/transfer.php?leftmenu=bank', 'BankTransfers', 1, 'banks', '$user->rights->banque->transfer', '', 0, 5, __ENTITY__); --- Account - Categories -insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->categorie->enabled', __HANDLER__, 'left', 2650__+MAX_llx_menu__, 'accountancy', 'cat', 14__+MAX_llx_menu__, '/categories/index.php?leftmenu=cat&type=5', 'Categories', 0, 'categories', '$user->rights->categorie->lire', '', 2, 4, __ENTITY__); -insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->categorie->enabled', __HANDLER__, 'left', 2651__+MAX_llx_menu__, 'accountancy', '', 2650__+MAX_llx_menu__, '/categories/card.php?action=create&type=5', 'NewCategory', 1, 'categories', '$user->rights->categorie->creer', '', 2, 0, __ENTITY__); +-- Bank - Categories +insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->categorie->enabled', __HANDLER__, 'left', 2650__+MAX_llx_menu__, 'accountancy', 'cat', 14__+MAX_llx_menu__, '/categories/index.php?leftmenu=bank&type=5', 'Categories', 0, 'categories', '$user->rights->categorie->lire', '', 2, 4, __ENTITY__); +insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->categorie->enabled', __HANDLER__, 'left', 2651__+MAX_llx_menu__, 'accountancy', '', 2650__+MAX_llx_menu__, '/categories/card.php?leftmenu=bank&action=create&type=5', 'NewCategory', 1, 'categories', '$user->rights->categorie->creer', '', 2, 0, __ENTITY__); -- Project insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->projet->enabled', __HANDLER__, 'left', 3600__+MAX_llx_menu__, 'project', 'projects', 7__+MAX_llx_menu__, '/projet/index.php?leftmenu=projects', 'Projects', 0, 'projects', '$user->rights->projet->lire', '', 2, 0, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->projet->enabled', __HANDLER__, 'left', 3601__+MAX_llx_menu__, 'project', '', 3600__+MAX_llx_menu__, '/projet/card.php?leftmenu=projects&action=create', 'NewProject', 1, 'projects', '$user->rights->projet->creer', '', 2, 1, __ENTITY__); diff --git a/htdocs/core/menus/standard/auguria.lib.php b/htdocs/core/menus/standard/auguria.lib.php index 21761216f65..bbe41dbab10 100644 --- a/htdocs/core/menus/standard/auguria.lib.php +++ b/htdocs/core/menus/standard/auguria.lib.php @@ -300,6 +300,8 @@ function print_left_auguria_menu($db,$menu_array_before,$menu_array_after,&$tabM // We update newmenu for special dynamic menus if ($conf->banque->enabled && $user->rights->banque->lire && $mainmenu == 'bank') // Entry for each bank account { + include_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; // Required for to get Account::TYPE_CASH for example + $sql = "SELECT rowid, label, courant, rappro, courant"; $sql.= " FROM ".MAIN_DB_PREFIX."bank_account"; $sql.= " WHERE entity = ".$conf->entity; diff --git a/htdocs/expensereport/list.php b/htdocs/expensereport/list.php index 8a8014edcb6..bbf2266ab13 100644 --- a/htdocs/expensereport/list.php +++ b/htdocs/expensereport/list.php @@ -127,7 +127,7 @@ if (is_array($extrafields->attribute_label) && count($extrafields->attribute_lab /* - * Actions + * Actions */ if (GETPOST('cancel')) { $action='list'; $massaction=''; } @@ -320,7 +320,7 @@ if ($resql) $title = $langs->trans("ListTripsAndExpenses"); print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'title_generic.png', 0, '', '', $limit); - + if ($sall) { foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val); @@ -333,7 +333,7 @@ if ($resql) $reshook=$hookmanager->executeHooks('printFieldPreListTitle',$parameters); // Note that $action and $object may have been modified by hook if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint; else $moreforfilter = $hookmanager->resPrint; - + if (! empty($moreforfilter)) { print '
'; @@ -344,10 +344,10 @@ if ($resql) $varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage; $selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields if ($massactionbutton) $selectedfields.=$form->showCheckAddButtons('checkforselect', 1); - + print '
'; print ''."\n"; - + // Filters print ''; if (! empty($arrayfields['d.ref']['checked'])) @@ -362,7 +362,7 @@ if ($resql) if ($user->rights->expensereport->readall || $user->rights->expensereport->lire_tous) { print ''; } else { print ''; @@ -452,7 +452,7 @@ if ($resql) { print ''; - } + } // Status if (! empty($arrayfields['d.fk_statut']['checked'])) { @@ -498,7 +498,7 @@ if ($resql) if (! empty($arrayfields['d.tms']['checked'])) print_liste_field_titre($arrayfields['d.tms']['label'],$_SERVER["PHP_SELF"],"d.tms","",$param,'align="center" class="nowrap"',$sortfield,$sortorder); if (! empty($arrayfields['d.fk_statut']['checked'])) print_liste_field_titre($arrayfields['d.fk_statut']['label'],$_SERVER["PHP_SELF"],"d.fk_statut","",$param,'align="right"',$sortfield,$sortorder); print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"],"",'','','align="center"',$sortfield,$sortorder,'maxwidthsearch '); - print "\n"; + print "\n"; $total_total_ht = 0; $total_total_ttc = 0; @@ -527,8 +527,8 @@ if ($resql) $expensereportstatic->date_approve=$db->jdate($obj->date_approve); $expensereportstatic->note_private=$obj->note_private; $expensereportstatic->note_public=$obj->note_public; - - + + print ''; // Ref if (! empty($arrayfields['d.ref']['checked'])) { @@ -615,7 +615,7 @@ if ($resql) if (! $i) $totalarray['totalttcfield']=$totalarray['nbfield']; $totalarray['totalttc'] += $obj->total_ttc; } - + // Extra fields if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) { @@ -723,11 +723,11 @@ if ($resql) // Show list of available documents $urlsource=$_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder; $urlsource.=str_replace('&','&',$param); - + $filedir=$diroutputmassaction; $genallowed=$user->rights->expensereport->lire; $delallowed=$user->rights->expensereport->lire; - + print $formfile->showdocuments('massfilesarea_expensereport','',$filedir,$urlsource,0,$delallowed,'',1,1,0,48,1,$param,$title,''); } else diff --git a/htdocs/fourn/commande/list.php b/htdocs/fourn/commande/list.php index 9e8d841e976..bafdeeab4db 100644 --- a/htdocs/fourn/commande/list.php +++ b/htdocs/fourn/commande/list.php @@ -218,7 +218,7 @@ if (empty($reshook)) $toselect=''; $search_project_ref=''; $search_array_options=array(); - + // Mass actions $objectclass='Commande'; $objectlabel='Orders'; @@ -235,54 +235,54 @@ if (empty($reshook)) $permtodelete = $user->rights->fournisseur->commande->supprimer; $uploaddir = $conf->fournisseur->commande->dir_output; include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; - + // TODO Move this into mass action include - if ($massaction == 'confirm_createbills') + if ($massaction == 'confirm_createbills') { $orders = GETPOST('toselect'); $createbills_onebythird = GETPOST('createbills_onebythird', 'int'); $validate_invoices = GETPOST('valdate_invoices', 'int'); - + $TFact = array(); $TFactThird = array(); - + $nb_bills_created = 0; - + $db->begin(); - + foreach($orders as $id_order) { - + $cmd = new Commande($db); if($cmd->fetch($id_order) <= 0) continue; - + $object = new Facture($db); if(!empty($createbills_onebythird) && !empty($TFactThird[$cmd->socid])) $object = $TFactThird[$cmd->socid]; // If option "one bill per third" is set, we use already created order. else { - + $object->socid = $cmd->socid; $object->type = Facture::TYPE_STANDARD; $object->cond_reglement_id = $cmd->cond_reglement_id; $object->mode_reglement_id = $cmd->mode_reglement_id; $object->fk_project = $cmd->fk_project; - + $datefacture = dol_mktime(12, 0, 0, $_POST['remonth'], $_POST['reday'], $_POST['reyear']); if (empty($datefacture)) { $datefacture = dol_mktime(date("h"), date("M"), 0, date("m"), date("d"), date("Y")); } - + $object->date = $datefacture; $object->origin = 'commande'; $object->origin_id = $id_order; - + $res = $object->create($user); - + if($res > 0) $nb_bills_created++; - + } - + if($object->id > 0) { - + $db->begin(); $sql = "INSERT INTO ".MAIN_DB_PREFIX."element_element ("; $sql.= "fk_source"; @@ -295,7 +295,7 @@ if (empty($reshook)) $sql.= ", ".$object->id; $sql.= ", '".$object->element."'"; $sql.= ")"; - + if ($db->query($sql)) { $db->commit(); @@ -304,17 +304,17 @@ if (empty($reshook)) { $db->rollback(); } - + $lines = $cmd->lines; if (empty($lines) && method_exists($cmd, 'fetch_lines')) { $cmd->fetch_lines(); $lines = $cmd->lines; } - + $fk_parent_line=0; $num=count($lines); - + for ($i=0;$i<$num;$i++) { $desc=($lines[$i]->desc?$lines[$i]->desc:$lines[$i]->libelle); @@ -404,42 +404,42 @@ if (empty($reshook)) } } } - + } - + $cmd->classifyBilled($user); - + if(!empty($createbills_onebythird) && empty($TFactThird[$cmd->socid])) $TFactThird[$cmd->socid] = $object; else $TFact[$object->id] = $object; } - + // Build doc with all invoices $TAllFact = empty($createbills_onebythird) ? $TFact : $TFactThird; $toselect = array(); - + if(!empty($validate_invoices)) { - + $massaction = $action = 'builddoc'; - + foreach($TAllFact as &$object) { $object->validate($user); $toselect[] = $object->id; // For builddoc action - + // Fac builddoc $upload_dir = $conf->facture->dir_output; $permissioncreate=$user->rights->facture->creer; include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php'; } - + $objectclass='Facture'; $objectlabel='Invoice'; $permtoread = $user->rights->facture->lire; $permtodelete = $user->rights->facture->supprimer; $uploaddir = $conf->facture->dir_output; include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; - + } - + if (! $error) { $db->commit(); @@ -537,12 +537,11 @@ if ($billed != '' && $billed >= 0) $sql .= " AND cf.billed = ".$billed; //Required triple check because statut=0 means draft filter if (GETPOST('statut', 'alpha') !== '') { - $sql .= " AND cf.fk_statut IN (".GETPOST('statut', 'alpha').")"; + $sql .= " AND cf.fk_statut IN (".$db->escape(GETPOST('statut', 'alpha')).")"; } if ($search_status != '' && $search_status >= 0) { - if (strstr($search_status, ',')) $sql.=" AND cf.fk_statut IN (".$db->escape($search_status).")"; - else $sql.=" AND cf.fk_statut = ".$search_status; + $sql.=" AND cf.fk_statut IN (".$db->escape($search_status).")"; } if ($ordermonth > 0) { @@ -573,11 +572,11 @@ else if ($deliveryyear > 0) if ($search_town) $sql.= natural_search('s.town', $search_town); if ($search_zip) $sql.= natural_search("s.zip",$search_zip); if ($search_state) $sql.= natural_search("state.nom",$search_state); -if ($search_country) $sql .= " AND s.fk_pays IN (".$search_country.')'; -if ($search_type_thirdparty) $sql .= " AND s.fk_typent IN (".$search_type_thirdparty.')'; +if ($search_country) $sql .= " AND s.fk_pays IN (".$db->escape($search_country).')'; +if ($search_type_thirdparty) $sql .= " AND s.fk_typent IN (".$db->escape($search_type_thirdparty).')'; if ($search_company) $sql .= natural_search('s.nom', $search_company); -if ($search_sale > 0) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$search_sale; -if ($search_user > 0) $sql.= " AND ec.fk_c_type_contact = tc.rowid AND tc.element='supplier_order' AND tc.source='internal' AND ec.element_id = cf.rowid AND ec.fk_socpeople = ".$search_user; +if ($search_sale > 0) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$db->escape($search_sale); +if ($search_user > 0) $sql.= " AND ec.fk_c_type_contact = tc.rowid AND tc.element='supplier_order' AND tc.source='internal' AND ec.element_id = cf.rowid AND ec.fk_socpeople = ".$db->escape($search_user); if ($search_total_ht != '') $sql.= natural_search('cf.total_ht', $search_total_ht, 1); if ($search_total_vat != '') $sql.= natural_search('cf.tva', $search_total_vat, 1); if ($search_total_ttc != '') $sql.= natural_search('cf.total_ttc', $search_total_ttc, 1); @@ -629,7 +628,7 @@ if ($resql) $num = $db->num_rows($resql); $arrayofselected=is_array($toselect)?$toselect:array(); - + $param=''; if ($socid > 0) $param.='&socid='.$socid; if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage; @@ -670,7 +669,7 @@ if ($resql) if ($user->rights->fournisseur->commande->supprimer) $arrayofmassactions['delete']=$langs->trans("Delete"); if ($massaction == 'presend' || $massaction == 'createbills') $arrayofmassactions=array(); $massactionbutton=$form->selectMassAction('', $arrayofmassactions); - + // Lignes des champs de filtre print ''; if ($optioncss != '') print ''; @@ -688,7 +687,7 @@ if ($resql) if ($massaction == 'presend') { $langs->load("mails"); - + if (! GETPOST('cancel')) { $objecttmp=new CommandeFournisseur($db); @@ -707,23 +706,23 @@ if ($resql) } } } - + print ''; - + dol_fiche_head(null, '', ''); - + $topicmail="SendOrderRef"; $modelmail="order_send"; - + // Cree l'objet formulaire mail include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php'; $formmail = new FormMail($db); $formmail->withform=-1; $formmail->fromtype = (GETPOST('fromtype')?GETPOST('fromtype'):(!empty($conf->global->MAIN_MAIL_DEFAULT_FROMTYPE)?$conf->global->MAIN_MAIL_DEFAULT_FROMTYPE:'user')); - + if($formmail->fromtype === 'user'){ $formmail->fromid = $user->id; - + } if (! empty($conf->global->MAIN_EMAIL_ADD_TRACK_ID) && ($conf->global->MAIN_EMAIL_ADD_TRACK_ID & 1)) // If bit 1 is set { @@ -767,23 +766,23 @@ if ($resql) $formmail->substit['__REFCLIENT__']='__REFCLIENT__'; // We want to keep the tag $formmail->substit['__PERSONALIZED__']=''; $formmail->substit['__CONTACTCIVNAME__']=''; - + // Tableau des parametres complementaires du post $formmail->param['action']=$action; $formmail->param['models']=$modelmail; $formmail->param['models_id']=GETPOST('modelmailselected','int'); $formmail->param['id']=join(',',$arrayofselected); //$formmail->param['returnurl']=$_SERVER["PHP_SELF"].'?id='.$object->id; - + print $formmail->get_form(); - + dol_fiche_end(); } elseif ($massaction == 'createbills') { //var_dump($_REQUEST); print ''; - + print '
'; - print $form->select_dolusers($search_user, 'search_user', 1, '', 0, '', '', 0, 0, 0, '', 0, '', 'maxwidth300'); + print $form->select_dolusers($search_user, 'search_user', 1, '', 0, '', '', 0, 0, 0, '', 0, '', 'maxwidth200'); print ' '; print '
'; print ''; print ''; print ''; print '
'; @@ -810,7 +809,7 @@ if ($resql) print '
'; - + print '
'; print '
'; print ' '; @@ -818,7 +817,7 @@ if ($resql) print '
'; print '
'; } - + if ($sall) { foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val); @@ -833,7 +832,7 @@ if ($resql) $langs->load("commercial"); $moreforfilter.='
'; $moreforfilter.=$langs->trans('ThirdPartiesOfSaleRepresentative'). ': '; - $moreforfilter.=$formother->select_salesrepresentatives($search_sale, 'search_sale', $user, 0, 1, 'maxwidth300'); + $moreforfilter.=$formother->select_salesrepresentatives($search_sale, 'search_sale', $user, 0, 1, 'maxwidth200'); $moreforfilter.='
'; } // If the user can view other users @@ -841,7 +840,7 @@ if ($resql) { $moreforfilter.='
'; $moreforfilter.=$langs->trans('LinkedToSpecificUsers'). ': '; - $moreforfilter.=$form->select_dolusers($search_user, 'search_user', 1, '', 0, '', '', 0, 0, 0, '', 0, '', 'maxwidth300'); + $moreforfilter.=$form->select_dolusers($search_user, 'search_user', 1, '', 0, '', '', 0, 0, 0, '', 0, '', 'maxwidth200'); $moreforfilter.='
'; } // If the user can view prospects other than his' @@ -851,14 +850,14 @@ if ($resql) $moreforfilter.='
'; $moreforfilter.=$langs->trans('IncludingProductWithTag'). ': '; $cate_arbo = $form->select_all_categories(Categorie::TYPE_PRODUCT, null, 'parent', null, null, 1); - $moreforfilter.=$form->selectarray('search_product_category', $cate_arbo, $search_product_category, 1, 0, 0, '', 0, 0, 0, 0, '', 1); + $moreforfilter.=$form->selectarray('search_product_category', $cate_arbo, $search_product_category, 1, 0, 0, '', 0, 0, 0, 0, 'maxwidth300', 1); $moreforfilter.='
'; } $parameters=array(); $reshook=$hookmanager->executeHooks('printFieldPreListTitle',$parameters); // Note that $action and $object may have been modified by hook if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint; else $moreforfilter = $hookmanager->resPrint; - + if (! empty($moreforfilter)) { print '
'; @@ -1065,8 +1064,8 @@ if ($resql) if (! empty($arrayfields['cf.billed']['checked'])) print_liste_field_titre($arrayfields['cf.billed']['label'],$_SERVER["PHP_SELF"],'cf.billed','',$param,'align="center"',$sortfield,$sortorder,''); print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"],"",'','','align="center"',$sortfield,$sortorder,'maxwidthsearch '); print "\n"; - - + + $total=0; $subtotal=0; $productstat_cache=array(); @@ -1081,7 +1080,7 @@ if ($resql) while ($i < min($num,$limit)) { $obj = $db->fetch_object($resql); - + $objectstatic->id=$obj->rowid; $objectstatic->ref=$obj->ref; @@ -1098,7 +1097,7 @@ if ($resql) if (! empty($arrayfields['cf.ref']['checked'])) { print ''; - + print ''; // Picto + Ref print '
'; @@ -1113,7 +1112,7 @@ if ($resql) $filedir=$conf->fournisseur->dir_output.'/commande' . '/' . dol_sanitizeFileName($obj->ref); print $formfile->getDocumentsLink($objectstatic->element, $filename, $filedir); print '
'; - + print ''."\n"; if (! $i) $totalarray['nbfield']++; } @@ -1319,18 +1318,18 @@ if ($resql) */ $urlsource=$_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder; $urlsource.=str_replace('&','&',$param); - + $filedir=$diroutputmassaction; $genallowed=$user->rights->fournisseur->commande->lire; $delallowed=$user->rights->fournisseur->commande->lire; - + print $formfile->showdocuments('massfilesarea_supplier_order','',$filedir,$urlsource,0,$delallowed,'',1,1,0,48,1,$param,$title,''); } else { print '
'.$langs->trans("ShowTempMassFilesArea").''; } - + $db->free($resql); } else diff --git a/htdocs/fourn/facture/list.php b/htdocs/fourn/facture/list.php index 0e19c73615b..30d31c0ea02 100644 --- a/htdocs/fourn/facture/list.php +++ b/htdocs/fourn/facture/list.php @@ -193,7 +193,7 @@ if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'e if (empty($reshook)) { include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; - + if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter") || GETPOST("button_removefilter.x")) // All test must be present to be compatible with all browsers { $search_all=""; @@ -232,7 +232,7 @@ if (empty($reshook)) $filter=''; $option=''; } - + // Mass actions $objectclass='FactureFournisseur'; $objectlabel='SupplierInvoices'; @@ -242,7 +242,7 @@ if (empty($reshook)) include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; } - + /* * View */ @@ -267,7 +267,7 @@ $sql.= " state.code_departement as state_code, state.nom as state_name,"; $sql.= " p.rowid as project_id, p.ref as project_ref"; // We need dynamount_payed to be able to sort on status (value is surely wrong because we can count several lines several times due to other left join or link with contacts. But what we need is just 0 or > 0) // TODO Better solution to be able to sort on already payed or remain to pay is to store amount_payed in a denormalized field. -if (! $search_all) $sql.= ', SUM(pf.amount) as dynamount_payed'; +if (! $search_all) $sql.= ', SUM(pf.amount) as dynamount_payed'; // Add fields from extrafields foreach ($extrafields->attribute_label as $key => $val) $sql.=($extrafields->attribute_type[$key] != 'separate' ? ",ef.".$key.' as options_'.$key : ''); // Add fields from hooks @@ -396,7 +396,7 @@ if (! $search_all) foreach ($extrafields->attribute_label as $key => $val) //prevent error with sql_mode=only_full_group_by { $sql.=($extrafields->attribute_type[$key] != 'separate' ? ",ef.".$key : ''); - } + } } else { @@ -421,7 +421,7 @@ if ($resql) $num = $db->num_rows($resql); $arrayofselected=is_array($toselect)?$toselect:array(); - + if ($socid) { $soc = new Societe($db); @@ -460,7 +460,7 @@ if ($resql) $tmpkey=preg_replace('/search_options_/','',$key); if ($val != '') $param.='&search_options_'.$tmpkey.'='.urlencode($val); } - + // List of mass actions available $arrayofmassactions = array( //'presend'=>$langs->trans("SendByMail"), @@ -470,7 +470,7 @@ if ($resql) if ($user->rights->fournisseur->facture->supprimer) $arrayofmassactions['delete']=$langs->trans("Delete"); //if ($massaction == 'presend' || $massaction == 'createbills') $arrayofmassactions=array(); $massactionbutton=$form->selectMassAction('', $arrayofmassactions); - + $i = 0; print ''."\n"; if ($optioncss != '') print ''; @@ -484,11 +484,11 @@ if ($resql) print ''; print_barre_liste($langs->trans("BillsSuppliers").($socid?' '.$soc->name:''), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'title_accountancy', 0, '', '', $limit); - + if ($massaction == 'presend') { $langs->load("mails"); - + if (! GETPOST('cancel')) { $objecttmp=new FactureFourn($db); @@ -507,26 +507,26 @@ if ($resql) } } } - + print ''; - + include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php'; $formmail = new FormMail($db); - + dol_fiche_head(null, '', ''); - + $topicmail="SendBillRef"; $modelmail="supplier_invoice_send"; - + // Cree l'objet formulaire mail include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php'; $formmail = new FormMail($db); $formmail->withform=-1; $formmail->fromtype = (GETPOST('fromtype')?GETPOST('fromtype'):(!empty($conf->global->MAIN_MAIL_DEFAULT_FROMTYPE)?$conf->global->MAIN_MAIL_DEFAULT_FROMTYPE:'user')); - + if($formmail->fromtype === 'user'){ $formmail->fromid = $user->id; - + } if (! empty($conf->global->MAIN_EMAIL_ADD_TRACK_ID) && ($conf->global->MAIN_EMAIL_ADD_TRACK_ID & 1)) // If bit 1 is set { @@ -570,23 +570,23 @@ if ($resql) $formmail->substit['__REFCLIENT__']='__REFCLIENT__'; // We want to keep the tag $formmail->substit['__PERSONALIZED__']=''; $formmail->substit['__CONTACTCIVNAME__']=''; - + // Tableau des parametres complementaires du post $formmail->param['action']=$action; $formmail->param['models']=$modelmail; $formmail->param['models_id']=GETPOST('modelmailselected','int'); $formmail->param['id']=join(',',$arrayofselected); //$formmail->param['returnurl']=$_SERVER["PHP_SELF"].'?id='.$object->id; - + print $formmail->get_form(); - + dol_fiche_end(); } elseif ($massaction == 'createbills') { //var_dump($_REQUEST); print ''; - + print ''; print ''; print ''; print ''; print '
'; @@ -613,7 +613,7 @@ if ($resql) print '
'; - + print '
'; print '
'; print ' '; @@ -621,13 +621,13 @@ if ($resql) print '
'; print '
'; } - + if ($search_all) { foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val); print $langs->trans("FilterOnInto", $search_all) . join(', ',$fieldstosearchall); } - + // If the user can view prospects other than his' $moreforfilter=''; if ($user->rights->societe->client->voir || $socid) @@ -635,7 +635,7 @@ if ($resql) $langs->load("commercial"); $moreforfilter.='
'; $moreforfilter.=$langs->trans('ThirdPartiesOfSaleRepresentative'). ': '; - $moreforfilter.=$formother->select_salesrepresentatives($search_sale, 'search_sale', $user, 0, 1, 'maxwidth300'); + $moreforfilter.=$formother->select_salesrepresentatives($search_sale, 'search_sale', $user, 0, 1, 'maxwidth200'); $moreforfilter.='
'; } // If the user can view prospects other than his' @@ -643,7 +643,7 @@ if ($resql) { $moreforfilter.='
'; $moreforfilter.=$langs->trans('LinkedToSpecificUsers'). ': '; - $moreforfilter.=$form->select_dolusers($search_user, 'search_user', 1, '', 0, '', '', 0, 0, 0, '', 0, '', 'maxwidth300'); + $moreforfilter.=$form->select_dolusers($search_user, 'search_user', 1, '', 0, '', '', 0, 0, 0, '', 0, '', 'maxwidth200'); $moreforfilter.='
'; } // If the user can view prospects other than his' @@ -653,7 +653,7 @@ if ($resql) $moreforfilter.='
'; $moreforfilter.=$langs->trans('IncludingProductWithTag'). ': '; $cate_arbo = $form->select_all_categories(Categorie::TYPE_PRODUCT, null, 'parent', null, null, 1); - $moreforfilter.=$form->selectarray('search_product_category', $cate_arbo, $search_product_category, 1, 0, 0, '', 0, 0, 0, 0, '', 1); + $moreforfilter.=$form->selectarray('search_product_category', $cate_arbo, $search_product_category, 1, 0, 0, '', 0, 0, 0, 0, 'maxwidth300', 1); $moreforfilter.='
'; } $parameters=array(); @@ -671,7 +671,7 @@ if ($resql) $varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage; $selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields if ($massactionbutton) $selectedfields.=$form->showCheckAddButtons('checkforselect', 1); - + print '
'; print ''."\n"; @@ -900,12 +900,12 @@ if ($resql) if (! empty($arrayfields['f.tms']['checked'])) print_liste_field_titre($arrayfields['f.tms']['label'],$_SERVER["PHP_SELF"],"f.tms","",$param,'align="center" class="nowrap"',$sortfield,$sortorder); if (! empty($arrayfields['f.fk_statut']['checked'])) print_liste_field_titre($arrayfields['f.fk_statut']['label'],$_SERVER["PHP_SELF"],"fk_statut,paye","",$param,'align="right"',$sortfield,$sortorder); print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"],"",'','','align="center"',$sortfield,$sortorder,'maxwidthsearch '); - print "\n"; - + print "\n"; + $facturestatic=new FactureFournisseur($db); $supplierstatic=new Fournisseur($db); $projectstatic=new Project($db); - + if ($num > 0) { $i=0; @@ -915,7 +915,7 @@ if ($resql) while ($i < min($num,$limit)) { $obj = $db->fetch_object($resql); - + $datelimit=$db->jdate($obj->datelimite); $facturestatic->id=$obj->facid; $facturestatic->ref=$obj->ref; @@ -929,7 +929,7 @@ if ($resql) $totaldeposits = $facturestatic->getSumDepositsUsed(); $totalpay = $paiement + $totalcreditnotes + $totaldeposits; $remaintopay = $obj->total_ttc - $totalpay; - + print ''; if (! empty($arrayfields['f.ref']['checked'])) { @@ -950,11 +950,11 @@ if ($resql) $subdir = get_exdir($obj->facid,2,0,0,$facturestatic,'invoice_supplier').dol_sanitizeFileName($obj->ref); print $formfile->getDocumentsLink('facture_fournisseur', $subdir, $filedir); print '
'; - + print "\n"; if (! $i) $totalarray['nbfield']++; } - + // Customer ref if (! empty($arrayfields['f.ref_supplier']['checked'])) { @@ -963,7 +963,7 @@ if ($resql) print ''; if (! $i) $totalarray['nbfield']++; } - + // Label if (! empty($arrayfields['f.label']['checked'])) { @@ -972,7 +972,7 @@ if ($resql) print ''; if (! $i) $totalarray['nbfield']++; } - + // Date if (! empty($arrayfields['f.datef']['checked'])) { @@ -981,7 +981,7 @@ if ($resql) print ''; if (! $i) $totalarray['nbfield']++; } - + // Date limit if (! empty($arrayfields['f.date_lim_reglement']['checked'])) { @@ -993,7 +993,7 @@ if ($resql) print ''; if (! $i) $totalarray['nbfield']++; } - + // Project if (! empty($arrayfields['p.ref']['checked'])) { @@ -1007,7 +1007,7 @@ if ($resql) print ''; if (! $i) $totalarray['nbfield']++; } - + // Third party if (! empty($arrayfields['s.nom']['checked'])) { @@ -1061,7 +1061,7 @@ if ($resql) print ''; if (! $i) $totalarray['nbfield']++; } - + // Payment mode if (! empty($arrayfields['f.fk_mode_reglement']['checked'])) { @@ -1070,7 +1070,7 @@ if ($resql) print ''; if (! $i) $totalarray['nbfield']++; } - + // Amount HT if (! empty($arrayfields['f.total_ht']['checked'])) { @@ -1127,8 +1127,8 @@ if ($resql) if (! $i) $totalarray['totalrtpfield']=$totalarray['nbfield']; $totalarray['totalrtp'] += $remaintopay; } - - + + // Extra fields if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) { @@ -1176,7 +1176,7 @@ if ($resql) print ""; if (! $i) $totalarray['nbfield']++; } - + // Action column print ''; if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined @@ -1187,12 +1187,12 @@ if ($resql) } print ''; if (! $i) $totalarray['nbfield']++; - + print "\n"; - + $i++; } - + // Show total line if (isset($totalarray['totalhtfield']) || isset($totalarray['totalvatfield']) @@ -1215,7 +1215,7 @@ if ($resql) } elseif ($totalarray['totalhtfield'] == $i) print ''.price($totalarray['totalht']).''; elseif ($totalarray['totalvatfield'] == $i) print ''.price($totalarray['totalvat']).''; - elseif ($totalarray['totallocaltax1field'] == $i) print ''.price($totalarray['totallocaltax1']).''; + elseif ($totalarray['totallocaltax1field'] == $i) print ''.price($totalarray['totallocaltax1']).''; elseif ($totalarray['totallocaltax2field'] == $i) print ''.price($totalarray['totallocaltax2']).''; elseif ($totalarray['totalttcfield'] == $i) print ''.price($totalarray['totalttc']).''; elseif ($totalarray['totalamfield'] == $i) print ''.price($totalarray['totalam']).''; @@ -1223,32 +1223,32 @@ if ($resql) else print ''; } print ''; - + } } $db->free($resql); - + $parameters=array('arrayfields'=>$arrayfields, 'sql'=>$sql); $reshook=$hookmanager->executeHooks('printFieldListFooter',$parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; - + print "\n"; print '
'; - + print "\n"; - + /* if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) { // Show list of available documents $urlsource=$_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder; $urlsource.=str_replace('&','&',$param); - + $filedir=$diroutputmassaction; $genallowed=$user->rights->facture->lire; $delallowed=$user->rights->facture->lire; - + print $formfile->showdocuments('massfilesarea_invoices','',$filedir,$urlsource,0,$delallowed,'',1,1,0,48,1,$param,$title,''); } else diff --git a/htdocs/holiday/list.php b/htdocs/holiday/list.php index 30d3dc14f69..fa77287cbf4 100644 --- a/htdocs/holiday/list.php +++ b/htdocs/holiday/list.php @@ -66,7 +66,7 @@ $year_end = GETPOST('year_end'); $search_employe = GETPOST('search_employe'); $search_valideur = GETPOST('search_valideur'); $search_statut = GETPOST('select_statut'); -$type = GETPOST('type','int'); +$type = GETPOST('type','int'); // List of fields to search into when doing a "search in all" $fieldstosearchall = array( @@ -310,14 +310,14 @@ print ''; if ($user->rights->holiday->write_all) { print ''; - print $form->select_dolusers($search_employe,"search_employe",1,"",0,'','',0,32,0,'',0,'','maxwidth200'); + print $form->select_dolusers($search_employe,"search_employe",1,"",0,'','',0,0,0,'',0,'','maxwidth200'); print ''; } else { //print ' '; print ''; - print $form->select_dolusers($user->id,"search_employe",1,"",1,'','',0,32,0,'',0,'','maxwidth200'); + print $form->select_dolusers($user->id,"search_employe",1,"",1,'','',0,0,0,'',0,'','maxwidth200'); print ''; } @@ -331,7 +331,7 @@ if($user->rights->holiday->write_all) $valideurobjects = $validator->listUsersForGroup($excludefilter); $valideurarray = array(); foreach($valideurobjects as $val) $valideurarray[$val->id]=$val->id; - print $form->select_dolusers($search_valideur,"search_valideur",1,"",0,$valideurarray,'', 0, 32,0,'',0,'','maxwidth200'); + print $form->select_dolusers($search_valideur,"search_valideur",1,"",0,$valideurarray,'', 0, 0, 0, '', 0, '', 'maxwidth200'); print ''; } else @@ -408,7 +408,7 @@ if (! empty($holiday->holiday)) $userstatic->login=$infos_CP['user_login']; $userstatic->statut=$infos_CP['user_statut']; $userstatic->photo=$infos_CP['user_photo']; - + // Valideur $approbatorstatic->id=$infos_CP['fk_validator']; $approbatorstatic->lastname=$infos_CP['validator_lastname']; @@ -416,7 +416,7 @@ if (! empty($holiday->holiday)) $approbatorstatic->login=$infos_CP['validator_login']; $approbatorstatic->statut=$infos_CP['validator_statut']; $approbatorstatic->photo=$infos_CP['validator_photo']; - + $date = $infos_CP['date_create']; print ''; diff --git a/htdocs/projet/list.php b/htdocs/projet/list.php index 0c638f8dd6b..9c78387f95b 100644 --- a/htdocs/projet/list.php +++ b/htdocs/projet/list.php @@ -444,7 +444,7 @@ if (! empty($conf->categorie->enabled)) require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php'; $moreforfilter.='
'; $moreforfilter.=$langs->trans('ProjectCategories'). ': '; - $moreforfilter.=$formother->select_categories('project',$search_categ,'search_categ',1); + $moreforfilter.=$formother->select_categories('project', $search_categ, 'search_categ', 1, 1, 'maxwidth300'); $moreforfilter.='
'; } @@ -453,7 +453,7 @@ $moreforfilter.='
'; $moreforfilter.=$langs->trans('ProjectsWithThisUserAsContact'). ': '; $includeonly=''; if (empty($user->rights->user->user->lire)) $includeonly=array($user->id); -$moreforfilter.=$form->select_dolusers($search_project_user?$search_project_user:'', 'search_project_user', 1, '', 0, $includeonly, '', 0, 0, 0, '', 0, '', 'maxwidth300'); +$moreforfilter.=$form->select_dolusers($search_project_user?$search_project_user:'', 'search_project_user', 1, '', 0, $includeonly, '', 0, 0, 0, '', 0, '', 'maxwidth200'); $moreforfilter.='
'; // If the user can view thirdparties other than his' @@ -462,7 +462,7 @@ if ($user->rights->societe->client->voir || $socid) $langs->load("commercial"); $moreforfilter.='
'; $moreforfilter.=$langs->trans('ThirdPartiesOfSaleRepresentative'). ': '; - $moreforfilter.=$formother->select_salesrepresentatives($search_sale, 'search_sale', $user, 0, 1, 'maxwidth300'); + $moreforfilter.=$formother->select_salesrepresentatives($search_sale, 'search_sale', $user, 0, 1, 'maxwidth200'); $moreforfilter.='
'; } diff --git a/htdocs/projet/tasks/list.php b/htdocs/projet/tasks/list.php index 47387ec625a..7bff02fa864 100644 --- a/htdocs/projet/tasks/list.php +++ b/htdocs/projet/tasks/list.php @@ -442,7 +442,7 @@ if (! empty($conf->categorie->enabled)) require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php'; $moreforfilter.='
'; $moreforfilter.=$langs->trans('ProjectCategories'). ': '; - $moreforfilter.=$formother->select_categories('project',$search_categ,'search_categ',1); + $moreforfilter.=$formother->select_categories('project', $search_categ, 'search_categ', 1, 'maxwidth300'); $moreforfilter.='
'; } @@ -451,7 +451,7 @@ $moreforfilter.='
'; $moreforfilter.=$langs->trans('ProjectsWithThisUserAsContact'). ' '; $includeonly=''; if (empty($user->rights->user->user->lire)) $includeonly=array($user->id); -$moreforfilter.=$form->select_dolusers($search_project_user?$search_project_user:'', 'search_project_user', 1, '', 0, $includeonly, '', 0, 0, 0, '', 0, '', 'maxwidth300'); +$moreforfilter.=$form->select_dolusers($search_project_user?$search_project_user:'', 'search_project_user', 1, '', 0, $includeonly, '', 0, 0, 0, '', 0, '', 'maxwidth200'); $moreforfilter.='
'; // If the user can view users @@ -459,7 +459,7 @@ $moreforfilter.='
'; $moreforfilter.=$langs->trans('TasksWithThisUserAsContact'). ': '; $includeonly=''; if (empty($user->rights->user->user->lire)) $includeonly=array($user->id); -$moreforfilter.=$form->select_dolusers($search_task_user, 'search_task_user', 1, '', 0, $includeonly, '', 0, 0, 0, '', 0, '', 'maxwidth300'); +$moreforfilter.=$form->select_dolusers($search_task_user, 'search_task_user', 1, '', 0, $includeonly, '', 0, 0, 0, '', 0, '', 'maxwidth200'); $moreforfilter.='
'; if (! empty($moreforfilter)) From faabdd3f99fb923661485364c3a6c9dd0852c48c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 14 Jun 2017 11:34:35 +0200 Subject: [PATCH 005/227] Missing filter field --- htdocs/user/index.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/htdocs/user/index.php b/htdocs/user/index.php index 76d3385dd65..9c82216d5be 100644 --- a/htdocs/user/index.php +++ b/htdocs/user/index.php @@ -1,6 +1,6 @@ - * Copyright (C) 2004-2016 Laurent Destailleur + * Copyright (C) 2004-2017 Laurent Destailleur * Copyright (C) 2005-2017 Regis Houssin * Copyright (C) 2015 Alexandre Spangaro * Copyright (C) 2016 Marcos García @@ -204,7 +204,7 @@ else } if ($socid > 0) $sql.= " AND u.fk_soc = ".$socid; //if ($search_user != '') $sql.=natural_search(array('u.login', 'u.lastname', 'u.firstname'), $search_user); -if ($search_supervisor > 0) $sql.= " AND u.fk_user = ".$db->escape($search_supervisor); +if ($search_supervisor > 0) $sql.= " AND u.fk_user IN (".$db->escape($search_supervisor).")"; if ($search_thirdparty != '') $sql.= natural_search(array('s.nom'), $search_thirdparty); if ($search_login != '') $sql.= natural_search("u.login", $search_login); if ($search_lastname != '') $sql.= natural_search("u.lastname", $search_lastname); @@ -360,9 +360,12 @@ if (! empty($arrayfields['u.entity']['checked'])) { print ''; } +// Supervisor if (! empty($arrayfields['u.fk_user']['checked'])) { - print ''; + print ''; + print $form->select_dolusers($search_supervisor, 'search_supervisor', 1, array(), 0, '', 0, 0, 0, 0, '', 0, '', 'maxwidth200'); + print ''; } if (! empty($arrayfields['u.datelastlogin']['checked'])) { From ce9e1dfb98701836af7006c37eb4aa85276024b6 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 14 Jun 2017 11:37:04 +0200 Subject: [PATCH 006/227] Fix tag non closed --- htdocs/modulebuilder/template/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/modulebuilder/template/README.md b/htdocs/modulebuilder/template/README.md index ba723bf5195..3d2d8f6102b 100644 --- a/htdocs/modulebuilder/template/README.md +++ b/htdocs/modulebuilder/template/README.md @@ -3,4 +3,4 @@ ## Features MyModuleDescription -Other modules are available on Dolistore.com. +Other modules are available on Dolistore.com. From 0b6d7a5b575f2ddb74607659d85adff363c2d6da Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 14 Jun 2017 11:44:12 +0200 Subject: [PATCH 007/227] Modulebuilder --- htdocs/admin/modules.php | 11 +++- htdocs/langs/en_US/modulebuilder.lang | 9 ++- htdocs/modulebuilder/index.php | 62 +++++++++++++++--- htdocs/modulebuilder/template/admin/about.php | 6 +- htdocs/modulebuilder/template/admin/setup.php | 4 +- ...{object_mytest.png => object_mymodule.png} | Bin 6 files changed, 73 insertions(+), 19 deletions(-) rename htdocs/modulebuilder/template/img/{object_mytest.png => object_mymodule.png} (100%) diff --git a/htdocs/admin/modules.php b/htdocs/admin/modules.php index 57ed97c9b20..8bea1c6dcb7 100644 --- a/htdocs/admin/modules.php +++ b/htdocs/admin/modules.php @@ -865,6 +865,7 @@ if ($mode == 'deploy') print '
'; } + print '
'; if ($allowfromweb >= 0) { @@ -885,12 +886,20 @@ if ($mode == 'deploy') if ($allowfromweb == 1) { print $langs->trans("UnpackPackageInModulesRoot",$dirins).'
'; - print '
'; + + print '
'; + + print ''; print ''; print ''; print $langs->trans("YouCanSubmitFile").' '; print ''; print '
'; + + print '
'; + print '
'; + + print '
'; } else { diff --git a/htdocs/langs/en_US/modulebuilder.lang b/htdocs/langs/en_US/modulebuilder.lang index b717bafc57c..adce0950b88 100644 --- a/htdocs/langs/en_US/modulebuilder.lang +++ b/htdocs/langs/en_US/modulebuilder.lang @@ -11,7 +11,14 @@ ModuleBuilderDescobjects=Define here the new objects you want to manage with you ModuleBuilderDescmenus=This tab is dedicated to define menu entries provided by your module. ModuleBuilderDescpermissions=This tab is dedicated to define the new permissions you want to provide with your module. ModuleBuilderDesctriggers=This is the view of triggers provided by your module. To include code executed when a triggered business event is launched, just edit this file with your IDE. +ModuleBuilderDeschooks=This tab is dedicated to hooks. +ModuleBuilderDescwidgets=This tab is dedicated to manage/build widgets. ModuleBuilderDescbuildpackage=You can generate here a "ready to distribute" package file (a normalized .zip file) of your module. Just click on button to get your module package file. +ModuleBuilderDescdangerzone=You can delete your module. WARNING: All files of module will be definetly lost ! +DangerZone=Danger zone BuildPackage=Build package ModuleIsNotActive=This module was not activated yet (go into Home-Setup-Module to make it live) -ModuleIsLive=This module has been activated. Any change on it may break a current active feature. \ No newline at end of file +ModuleIsLive=This module has been activated. Any change on it may break a current active feature. +DescriptionLong=Long description +EditorName=Name of editor +EditorUrl=URL of editor \ No newline at end of file diff --git a/htdocs/modulebuilder/index.php b/htdocs/modulebuilder/index.php index 5b3a33c9d41..8cabec1bdfb 100644 --- a/htdocs/modulebuilder/index.php +++ b/htdocs/modulebuilder/index.php @@ -113,6 +113,19 @@ if ($dirins && $action == 'initmodule' && $modulename) } } +if ($dirins && $action == 'confirm_delete') +{ + $modulelowercase=strtolower($module); + + // Dir for module + $dir = $dirins.'/'.$modulelowercase; + + dol_delete_dir_recursive($dir); + + header("Location: ".DOL_URL_ROOT.'/modulebuilder/index.php?module=initmodule'); + exit; +} + if ($dirins && $action == 'generatepackage') { $modulelowercase=strtolower($module); @@ -373,16 +386,31 @@ elseif (! empty($module)) $head2[$h][2] = 'permissions'; $h++; + $head2[$h][0] = $_SERVER["PHP_SELF"].'?tab=hooks&module='.$module; + $head2[$h][1] = $langs->trans("Hooks"); + $head2[$h][2] = 'hooks'; + $h++; + $head2[$h][0] = $_SERVER["PHP_SELF"].'?tab=triggers&module='.$module; $head2[$h][1] = $langs->trans("Triggers"); $head2[$h][2] = 'triggers'; $h++; + $head2[$h][0] = $_SERVER["PHP_SELF"].'?tab=widgets&module='.$module; + $head2[$h][1] = $langs->trans("Widgets"); + $head2[$h][2] = 'widgets'; + $h++; + $head2[$h][0] = $_SERVER["PHP_SELF"].'?tab=buildpackage&module='.$module; $head2[$h][1] = $langs->trans("BuildPackage"); $head2[$h][2] = 'buildpackage'; $h++; + $head2[$h][0] = $_SERVER["PHP_SELF"].'?tab=dangerzone&module='.$module; + $head2[$h][1] = $langs->trans("DangerZone"); + $head2[$h][2] = 'dangerzone'; + $h++; + print $modulestatusinfo.'

'; dol_fiche_head($head2, $tab, '', -1, ''); @@ -421,7 +449,7 @@ elseif (! empty($module)) print ''; print $langs->trans("Family"); - print "
'crm','financial','hr','projects','products','ecm','technic','interface','other'"; + //print "
'crm','financial','hr','projects','products','ecm','technic','interface','other'"; print ''; print $moduleobj->family; print ''; @@ -445,7 +473,7 @@ elseif (! empty($module)) print ''; print ''; - print $langs->trans("LongDescription"); + print $langs->trans("DescriptionLong"); print ''; print $moduleobj->getDescLong(); print ''; @@ -453,14 +481,6 @@ elseif (! empty($module)) print ''; print '
'; - - print '

'; - print '
'; - print ''; - print ''; - print ''; - print ''; - print '
'; } if ($tab == 'objects') @@ -483,6 +503,12 @@ elseif (! empty($module)) } + if ($tab == 'hooks') + { + print $langs->trans("FeatureNotYetAvailable"); + + } + if ($tab == 'triggers') { require_once DOL_DOCUMENT_ROOT.'/core/class/interfaces.class.php'; @@ -520,6 +546,12 @@ elseif (! empty($module)) print '
'; } + if ($tab == 'widget') + { + print $langs->trans("FeatureNotYetAvailable"); + + } + if ($tab == 'buildpackage') { if (! class_exists('ZipArchive') && ! defined('ODTPHP_PATHTOPCLZIP')) @@ -536,6 +568,16 @@ elseif (! empty($module)) print ''; } + if ($tab == 'dangerzone') + { + print '
'; + print ''; + print ''; + print ''; + print ''; + print '
'; + } + dol_fiche_end(); } } diff --git a/htdocs/modulebuilder/template/admin/about.php b/htdocs/modulebuilder/template/admin/about.php index 844c444bad2..1306b0aef6a 100644 --- a/htdocs/modulebuilder/template/admin/about.php +++ b/htdocs/modulebuilder/template/admin/about.php @@ -20,8 +20,6 @@ * \file htdocs/modulebuilder/template/admin/about.php * \ingroup mymodule * \brief About page of module MyModule. - * - * MyModuleDescription. */ // Load Dolibarr environment @@ -84,8 +82,8 @@ echo $langs->trans("MyModuleAboutPage"); echo '
'; -require_once '../core/modulebuilder/mymodule/core/modules/modMyModule.class.php'; -$tmpmodule = new MyModule($db); +dol_include_once('/mymodule/core/modules/modMyModule.class.php'); +$tmpmodule = new modMyModule($db); print $tmpmodule->getDescLong(); // Page end diff --git a/htdocs/modulebuilder/template/admin/setup.php b/htdocs/modulebuilder/template/admin/setup.php index b3f2cc87d73..421452f06e8 100644 --- a/htdocs/modulebuilder/template/admin/setup.php +++ b/htdocs/modulebuilder/template/admin/setup.php @@ -19,9 +19,7 @@ /** * \file htdocs/modulebuilder/template/admin/setup.php * \ingroup mymodule - * \brief Example module setup page. - * - * Put detailed description here. + * \brief MyModule setup page. */ // Load Dolibarr environment diff --git a/htdocs/modulebuilder/template/img/object_mytest.png b/htdocs/modulebuilder/template/img/object_mymodule.png similarity index 100% rename from htdocs/modulebuilder/template/img/object_mytest.png rename to htdocs/modulebuilder/template/img/object_mymodule.png From 73977639ac44215c6680110fc3d5f4babdf761fa Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 14 Jun 2017 18:34:39 +0200 Subject: [PATCH 008/227] Update doc --- README-FR.md | 31 ++++++++++++++++++++++++++++--- README.md | 14 ++++++++++++-- 2 files changed, 40 insertions(+), 5 deletions(-) diff --git a/README-FR.md b/README-FR.md index 4129e2b7452..8e6a2c5aac0 100644 --- a/README-FR.md +++ b/README-FR.md @@ -98,7 +98,10 @@ Voir fichier ChangeLog. - Rapports - Imports/Exports des données - Connectivité LDAP -- De nombreuses autres fonctionnalités issues de modules officiels ou non (AWStats, Bittorrent, Gravatar, Google, Webcalendar...) +- Intégratn de ClickToDial +- Intégration RSS +- Intégation Skype +- Intégration de système de paiements (Paypal, Strip, Paybox...) - … ### Divers: @@ -114,17 +117,39 @@ Voir fichier ChangeLog. - Code simple et facilement personnalisable (pas de framework lourd; mécanisme de hook et triggers). - APIs. - Génération PDF et ODT des éléments (factures, propositions commerciales, commandes, bons expéditions, etc...) +- … + +### Extension + +Dolibarr peut aussi être étendu à volonté avec l'ajout de module/applications externes développées par des développeus tiers, disponible sur [DoliStore](https://www.dolistore.com). -## CE QUE DOLIBARR NE PEUT PAS FAIRE (TACHES A FAIRE) +## CE QUE DOLIBARR NE PEUT PAS (ENCORE) FAIRE Voici un liste de fonctionnalites pas encore gérées par Dolibarr: - Dolibarr ne contient pas de module de Gestion de la paie. - Les tâches du module de gestion de projets n'ont pas de dépendances entre elle. -- Dolibarr ne contient pas de Webmail. +- Dolibarr n'embarque pas de Webmail intégré nativement. - Dolibarr ne fait pas le café (pas encore). +## DOCUMENTATION + +Les documentations utilisateur, développeur et traducteur sont disponible sous forme de ressources de la communautés via la site [Wiki](https://wiki.dolibarr.org). + + +## CONTRIBUTING + +Voir le fichier [CONTRIBUTING](https://github.com/Dolibarr/dolibarr/blob/develop/.github/CONTRIBUTING.md) + + +## CREDITS + +Dolibarr est le résultat du travail de nombreux contributeurs depuis des années et utilise des librairies d'autres contributeurs. + +Voir le fichier [COPYRIGHT](https://github.com/Dolibarr/dolibarr/blob/develop/COPYRIGHT) + + ## ACTUALITES ET RESEAUX SOCIAUX Suivez le projet Dolibarr project sur les réseaux francophones diff --git a/README.md b/README.md index 29a7d4f9545..fbbbdddf665 100644 --- a/README.md +++ b/README.md @@ -12,6 +12,7 @@ You can use it as a standalone application or as a web application to be able to ![ScreenShot](https://www.dolibarr.org/images/dolibarr_screenshot1_640x400.png) + ## LICENSE Dolibarr is released under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version (GPL-3+). @@ -20,6 +21,7 @@ See the [COPYING](https://github.com/Dolibarr/dolibarr/blob/develop/COPYING) fil Other licenses apply for some included dependencies. See [COPYRIGHT](https://github.com/Dolibarr/dolibarr/blob/develop/COPYRIGHT) for a full list. + ## INSTALLING ### Download @@ -67,6 +69,7 @@ You can use a Web server and a supported database (MariaDb, MySql or Postgresql) - Follow the installer instructions + ## UPGRADING - Overwrite all old files from 'dolibarr' directory with files provided into the new version's package. @@ -75,10 +78,12 @@ You can use a Web server and a supported database (MariaDb, MySql or Postgresql) *Note: migration process can safely be done multiple times by calling the page /install/index.php* + ## WHAT'S NEW See the [ChangeLog](https://github.com/Dolibarr/dolibarr/blob/develop/ChangeLog) file. + ## FEATURES ### Main application/modules (all optional) @@ -120,7 +125,7 @@ See the [ChangeLog](https://github.com/Dolibarr/dolibarr/blob/develop/ChangeLog) - ClickToDial integration - RSS integration - Skype integration -- Payment platforms integration (PayBox, PayPal) +- Payment platforms integration (PayPal, Stripe, Paybox...) - … ### Other general features @@ -149,29 +154,34 @@ See the [ChangeLog](https://github.com/Dolibarr/dolibarr/blob/develop/ChangeLog) Dolibarr can be extended with a lot of other external application or modules from third party developers available at the [DoliStore](https://www.dolistore.com). + ## FUTURE These are features that Dolibarr does **not** yet fully support: - Tasks dependencies in projects - Payroll module -- Webmail +- No native embedded Webmail - Dolibarr can't do coffee (yet) + ## DOCUMENTATION Administrator, user, developer and translator's documentations are available along with other community resources on the [Wiki](https://wiki.dolibarr.org). + ## CONTRIBUTING See file [CONTRIBUTING](https://github.com/Dolibarr/dolibarr/blob/develop/.github/CONTRIBUTING.md) + ## CREDITS Dolibarr is the work of many contributors over the years and uses some fine libraries. See [COPYRIGHT](https://github.com/Dolibarr/dolibarr/blob/develop/COPYRIGHT) file. + ## NEWS AND SOCIAL NETWORKS Follow Dolibarr project on: From 71c0be20b972d0fd3efac0da60a2980d92bb83a5 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 15 Jun 2017 10:30:32 +0200 Subject: [PATCH 009/227] Change data structure for bookkeeping v6 --- dev/translation/erp_comparison_translation.txt | 4 ++-- htdocs/install/mysql/migration/5.0.0-6.0.0.sql | 11 ++++++++++- .../mysql/tables/llx_accounting_bookkeeping.sql | 5 +++-- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/dev/translation/erp_comparison_translation.txt b/dev/translation/erp_comparison_translation.txt index daa1bc79e92..fb96c17e3f9 100644 --- a/dev/translation/erp_comparison_translation.txt +++ b/dev/translation/erp_comparison_translation.txt @@ -8,7 +8,7 @@ Contact/address Contact person Partner/Contact (individual) Financial ?? Invoicing Income / Expense ?? Profit / Loss -Balance Net profit - +Balance ?? Net profit +Subledger account Subledger account ?? diff --git a/htdocs/install/mysql/migration/5.0.0-6.0.0.sql b/htdocs/install/mysql/migration/5.0.0-6.0.0.sql index bc09bf25ca3..46e3b698100 100644 --- a/htdocs/install/mysql/migration/5.0.0-6.0.0.sql +++ b/htdocs/install/mysql/migration/5.0.0-6.0.0.sql @@ -188,9 +188,18 @@ ALTER TABLE llx_bank_account ADD CONSTRAINT fk_bank_account_accountancy_journal --Update general ledger for FEC format & harmonization ALTER TABLE llx_accounting_bookkeeping MODIFY COLUMN code_tiers varchar(32); +ALTER TABLE llx_accounting_bookkeeping CHANGE COLUMN code_tiers thirdparty_code varchar(32); + +--Subledger account +ALTER TABLE llx_accounting_bookkeeping ADD COLUMN subledger_account varchar(32); +ALTER TABLE llx_accounting_bookkeeping CHANGE COLUMN thirdparty_label subledger_label varchar(255); -- If field was already created, rename it +ALTER TABLE llx_accounting_bookkeeping ADD COLUMN subledger_label varchar(255) AFTER subledger_account; -- If field dod not exists yet + +update llx_accounting_bookkeeping set subledger_account = numero_compte where subledger_account IS NULL; + ALTER TABLE llx_accounting_bookkeeping MODIFY COLUMN label_compte varchar(255); ALTER TABLE llx_accounting_bookkeeping MODIFY COLUMN code_journal varchar(32); -ALTER TABLE llx_accounting_bookkeeping ADD COLUMN thirdparty_label varchar(255) AFTER code_tiers; + ALTER TABLE llx_accounting_bookkeeping ADD COLUMN label_operation varchar(255) AFTER label_compte; ALTER TABLE llx_accounting_bookkeeping ADD COLUMN multicurrency_amount double AFTER sens; ALTER TABLE llx_accounting_bookkeeping ADD COLUMN multicurrency_code varchar(255) AFTER multicurrency_amount; diff --git a/htdocs/install/mysql/tables/llx_accounting_bookkeeping.sql b/htdocs/install/mysql/tables/llx_accounting_bookkeeping.sql index 651fee6c339..ad1160c356d 100644 --- a/htdocs/install/mysql/tables/llx_accounting_bookkeeping.sql +++ b/htdocs/install/mysql/tables/llx_accounting_bookkeeping.sql @@ -26,8 +26,9 @@ CREATE TABLE llx_accounting_bookkeeping doc_ref varchar(300) NOT NULL, -- | facture_client/reglement_client/... reference number fk_doc integer NOT NULL, -- | facture_client/reglement_client/... rowid fk_docdet integer NOT NULL, -- | facture_client/reglement_client/... line rowid - code_tiers varchar(32), -- FEC:CompAuxNum | account number of auxiliary account - thirdparty_label varchar(255), -- FEC:CompAuxLib | label of auxiliary account + thirdparty_code varchar(32), -- Third party code (customer or supplier) when record is saved (may help debug) + subledger_account varchar(32), -- FEC:CompAuxNum | account number of subledger account + subledger_label varchar(255), -- FEC:CompAuxLib | label of subledger account numero_compte varchar(32) NOT NULL, -- FEC:CompteNum | account number label_compte varchar(255) NOT NULL, -- FEC:CompteLib | label of account label_operation varchar(255), -- FEC:EcritureLib | label of the operation From 333304934102fd3afec2ccf5e2d2ff6e400a7205 Mon Sep 17 00:00:00 2001 From: phf Date: Thu, 15 Jun 2017 11:11:49 +0200 Subject: [PATCH 010/227] Fix total aren't aligned --- htdocs/compta/facture.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php index 9bb97d8ff0b..2d0208d0c2b 100644 --- a/htdocs/compta/facture.php +++ b/htdocs/compta/facture.php @@ -3524,7 +3524,7 @@ else if ($id > 0 || ! empty($ref)) } print ''; - print ''; + print ''; print '' . price($total_prev_ht) . ''; print '' . price($total_prev_ttc) . ''; print ' '; @@ -3564,7 +3564,7 @@ else if ($id > 0 || ! empty($ref)) } print ''; - print ''; + print ''; print '' . price($total_next_ht) . ''; print '' . price($total_next_ttc) . ''; print ' '; From 4009b1837cf1db251c8c5bab6fe185a1960be279 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 15 Jun 2017 11:17:02 +0200 Subject: [PATCH 011/227] Fix permissions --- htdocs/societe/class/api_contacts.class.php | 55 ++++++++++++--------- 1 file changed, 33 insertions(+), 22 deletions(-) diff --git a/htdocs/societe/class/api_contacts.class.php b/htdocs/societe/class/api_contacts.class.php index ad82db3e008..58fe15cf282 100644 --- a/htdocs/societe/class/api_contacts.class.php +++ b/htdocs/societe/class/api_contacts.class.php @@ -22,14 +22,14 @@ use Luracast\Restler\RestException; /** * API class for contacts * - * @access protected + * @access protected * @class DolibarrApiAccess {@requires user,external} */ class Contacts extends DolibarrApi { /** * - * @var array $FIELDS Mandatory fields, checked when create and update object + * @var array $FIELDS Mandatory fields, checked when create and update object */ static $FIELDS = array( 'lastname' @@ -56,13 +56,13 @@ class Contacts extends DolibarrApi * * @param int $id ID of contact * @return array|mixed data without useless information - * + * * @throws RestException */ function get($id) { if (!DolibarrApiAccess::$user->rights->societe->contact->lire) { - throw new RestException(401); + throw new RestException(401, 'No permission to read contacts'); } $result = $this->contact->fetch($id); @@ -81,9 +81,9 @@ class Contacts extends DolibarrApi /** * List contacts - * + * * Get a list of contacts - * + * * @param string $sortfield Sort field * @param string $sortorder Sort order * @param int $limit Limit for list @@ -91,7 +91,7 @@ class Contacts extends DolibarrApi * @param string $thirdparty_ids Thirdparty ids to filter projects of. {@example '1' or '1,2,3'} {@pattern /^[0-9,]*$/i} * @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.ref:like:'SO-%') and (t.date_creation:<:'20160101')" * @return array Array of contact objects - * + * * @throws RestException */ function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 0, $page = 0, $thirdparty_ids = '', $sqlfilters = '') { @@ -99,6 +99,11 @@ class Contacts extends DolibarrApi $obj_ret = array(); + if (!DolibarrApiAccess::$user->rights->societe->contact->lire) + { + throw new RestException(401, 'No permission to read contacts'); + } + // case of external user, $thirdparty_ids param is ignored and replaced by user's socid $socids = DolibarrApiAccess::$user->societe_id ? DolibarrApiAccess::$user->societe_id : $thirdparty_ids; @@ -111,7 +116,7 @@ class Contacts extends DolibarrApi $sql.= " FROM " . MAIN_DB_PREFIX . "socpeople as t"; if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) { // We need this table joined to the select in order to filter by sale - $sql.= ", " . MAIN_DB_PREFIX . "societe_commerciaux as sc"; + $sql.= ", " . MAIN_DB_PREFIX . "societe_commerciaux as sc"; } $sql.= " LEFT JOIN " . MAIN_DB_PREFIX . "societe as s ON t.fk_soc = s.rowid"; $sql.= ' WHERE t.entity IN (' . getEntity('socpeople') . ')'; @@ -127,7 +132,7 @@ class Contacts extends DolibarrApi $sql .= " AND sc.fk_user = " . $search_sale; } // Add sql filters - if ($sqlfilters) + if ($sqlfilters) { if (! DolibarrApi::_checkFilters($sqlfilters)) { @@ -136,7 +141,7 @@ class Contacts extends DolibarrApi $regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; $sql.=" AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; } - + $sql.= $db->order($sortfield, $sortorder); if ($limit) @@ -164,7 +169,7 @@ class Contacts extends DolibarrApi } $i++; } - } + } else { throw new RestException(503, 'Error when retreive contacts : ' . $sql); } @@ -184,7 +189,7 @@ class Contacts extends DolibarrApi function post($request_data = NULL) { if (!DolibarrApiAccess::$user->rights->societe->contact->creer) { - throw new RestException(401); + throw new RestException(401, 'No permission to create/update contacts'); } // Check mandatory fields $result = $this->_validate($request_data); @@ -203,13 +208,13 @@ class Contacts extends DolibarrApi * Update contact * * @param int $id Id of contact to update - * @param array $request_data Datas - * @return int + * @param array $request_data Datas + * @return int */ function put($id, $request_data = NULL) { if (!DolibarrApiAccess::$user->rights->societe->contact->creer) { - throw new RestException(401); + throw new RestException(401, 'No permission to create/update contacts'); } $result = $this->contact->fetch($id); @@ -244,7 +249,7 @@ class Contacts extends DolibarrApi function delete($id) { if (!DolibarrApiAccess::$user->rights->societe->contact->supprimer) { - throw new RestException(401); + throw new RestException(401, 'No permission to delete contacts'); } $result = $this->contact->fetch($id); if (!$result) @@ -273,23 +278,29 @@ class Contacts extends DolibarrApi //if (!DolibarrApiAccess::$user->rights->user->user->creer) { //throw new RestException(401); //} - + if (!isset($request_data["login"])) throw new RestException(400, "login field missing"); if (!isset($request_data["password"])) throw new RestException(400, "password field missing"); + if (!DolibarrApiAccess::$user->rights->societe->contact->lire) { - throw new RestException(401); + throw new RestException(401, 'No permission to read contacts'); } + if (!DolibarrApiAccess::$user->rights->user->user->creer) { + throw new RestException(401, 'No permission to create user'); + } + $contact = new Contact($this->db); $contact->fetch($id); if ($contact->id <= 0) { throw new RestException(404, 'Contact not found'); } - + if (!DolibarrApi::_checkAccessToResource('contact', $contact->id, 'socpeople&societe')) { throw new RestException(401, 'Access not allowed for login ' . DolibarrApiAccess::$user->login); } + // Check mandatory fields $login = $request_data["login"]; $password = $request_data["password"]; @@ -300,10 +311,10 @@ class Contacts extends DolibarrApi } // password parameter not used in create_from_contact $useraccount->setPassword($useraccount,$password); - + return $result; } - + /** * Get categories for a contact * @@ -324,7 +335,7 @@ class Contacts extends DolibarrApi /** * Validate fields before create or update object - * + * * @param array|null $data Data to validate * @return array * @throws RestException From 097be322a60c9365f12dd364ac1bd878f15d6e55 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 15 Jun 2017 19:29:00 +0200 Subject: [PATCH 012/227] Modify code to match new v6 structure. --- htdocs/accountancy/admin/categories_list.php | 22 +- htdocs/accountancy/admin/defaultaccounts.php | 94 +++++-- htdocs/accountancy/admin/journals_list.php | 27 +- htdocs/accountancy/bookkeeping/card.php | 46 ++-- htdocs/accountancy/bookkeeping/list.php | 38 +-- .../accountancy/bookkeeping/listbyaccount.php | 37 ++- htdocs/accountancy/bookkeeping/listbyyear.php | 58 +++-- .../class/accountancycategory.class.php | 20 +- .../class/accountancyexport.class.php | 34 +-- .../class/accountingjournal.class.php | 16 +- .../accountancy/class/bookkeeping.class.php | 234 +++++++++++------- htdocs/accountancy/index.php | 2 - htdocs/accountancy/journal/bankjournal.php | 28 +-- .../journal/expensereportsjournal.php | 15 +- .../accountancy/journal/purchasesjournal.php | 21 +- htdocs/accountancy/journal/sellsjournal.php | 24 +- htdocs/core/modules/modAccounting.class.php | 12 +- .../install/mysql/migration/5.0.0-6.0.0.sql | 1 + htdocs/langs/en_US/accountancy.lang | 24 +- htdocs/langs/en_US/compta.lang | 6 +- 20 files changed, 433 insertions(+), 326 deletions(-) diff --git a/htdocs/accountancy/admin/categories_list.php b/htdocs/accountancy/admin/categories_list.php index 1bf9a693efd..b10015baa6c 100644 --- a/htdocs/accountancy/admin/categories_list.php +++ b/htdocs/accountancy/admin/categories_list.php @@ -151,7 +151,7 @@ $sourceList=array(); if (GETPOST('button_removefilter') || GETPOST('button_removefilter.x') || GETPOST('button_removefilter_x')) { - $search_country_id = ''; + $search_country_id = ''; } // Actions add or modify an entry into a dictionary @@ -479,7 +479,7 @@ if ($id) else $sql.=" WHERE "; $sql.= " c.rowid = ".$search_country_id; } - + if ($sortfield) { // If sort order is "country", we use country_code instead @@ -506,7 +506,7 @@ if ($id) print '
'; print ''; print ''; - + print ''; // Form to add a new line @@ -546,9 +546,9 @@ if ($id) if ($fieldlist[$field]=='accountancy_code_buy'){ $valuetoshow=$langs->trans("AccountancyCodeBuy"); } if ($fieldlist[$field]=='pcg_version' || $fieldlist[$field]=='fk_pcg_version') { $valuetoshow=$langs->trans("Pcg_version"); } if ($fieldlist[$field]=='range_account') { $valuetoshow=$langs->trans("Range"); } - if ($fieldlist[$field]=='sens') { $valuetoshow=$langs->trans("Sens"); } + if ($fieldlist[$field]=='sens') { $valuetoshow=$langs->trans("Direction"); } if ($fieldlist[$field]=='category_type') { $valuetoshow=$langs->trans("Calculated"); } - + if ($valuetoshow != '') { print ''; print ''; - + // Title of lines print ''; foreach ($fieldlist as $field => $value) @@ -700,7 +700,7 @@ if ($id) if ($fieldlist[$field]=='pcg_subtype') { $valuetoshow=$langs->trans("Pcg_subtype"); } if ($fieldlist[$field]=='type_template') { $valuetoshow=$langs->trans("TypeOfTemplate"); } if ($fieldlist[$field]=='range_account') { $valuetoshow=$langs->trans("Range"); } - if ($fieldlist[$field]=='sens') { $valuetoshow=$langs->trans("Sens"); } + if ($fieldlist[$field]=='sens') { $valuetoshow=$langs->trans("Direction"); } if ($fieldlist[$field]=='category_type') { $valuetoshow=$langs->trans("Calculated"); } // Affiche nom du champ if ($showfield) @@ -754,7 +754,7 @@ if ($id) { foreach ($fieldlist as $field => $value) { - + $showfield=1; $align="left"; $valuetoshow=$obj->{$fieldlist[$field]}; diff --git a/htdocs/accountancy/admin/defaultaccounts.php b/htdocs/accountancy/admin/defaultaccounts.php index aaf98a0fa8b..ef39252ff87 100644 --- a/htdocs/accountancy/admin/defaultaccounts.php +++ b/htdocs/accountancy/admin/defaultaccounts.php @@ -50,23 +50,26 @@ if (! empty($user->rights->accountancy->chartofaccount)) $action = GETPOST('action', 'alpha'); +$list_account_main = array ( + 'ACCOUNTING_ACCOUNT_SUPPLIER', + 'ACCOUNTING_ACCOUNT_CUSTOMER', +); + $list_account = array ( - 'ACCOUNTING_ACCOUNT_SUPPLIER', - 'ACCOUNTING_ACCOUNT_CUSTOMER', - 'SALARIES_ACCOUNTING_ACCOUNT_PAYMENT', - 'ACCOUNTING_PRODUCT_BUY_ACCOUNT', - 'ACCOUNTING_PRODUCT_SOLD_ACCOUNT', - 'ACCOUNTING_SERVICE_BUY_ACCOUNT', - 'ACCOUNTING_SERVICE_SOLD_ACCOUNT', - 'ACCOUNTING_VAT_BUY_ACCOUNT', - 'ACCOUNTING_VAT_SOLD_ACCOUNT', - 'ACCOUNTING_VAT_PAY_ACCOUNT', - 'ACCOUNTING_ACCOUNT_SUSPENSE', - 'ACCOUNTING_ACCOUNT_TRANSFER_CASH', - 'DONATION_ACCOUNTINGACCOUNT', - 'LOAN_ACCOUNTING_ACCOUNT_CAPITAL', - 'LOAN_ACCOUNTING_ACCOUNT_INTEREST', - 'LOAN_ACCOUNTING_ACCOUNT_INSURANCE' + 'SALARIES_ACCOUNTING_ACCOUNT_PAYMENT', + 'ACCOUNTING_PRODUCT_BUY_ACCOUNT', + 'ACCOUNTING_PRODUCT_SOLD_ACCOUNT', + 'ACCOUNTING_SERVICE_BUY_ACCOUNT', + 'ACCOUNTING_SERVICE_SOLD_ACCOUNT', + 'ACCOUNTING_VAT_BUY_ACCOUNT', + 'ACCOUNTING_VAT_SOLD_ACCOUNT', + 'ACCOUNTING_VAT_PAY_ACCOUNT', + 'ACCOUNTING_ACCOUNT_SUSPENSE', + 'ACCOUNTING_ACCOUNT_TRANSFER_CASH', + 'DONATION_ACCOUNTINGACCOUNT', + 'LOAN_ACCOUNTING_ACCOUNT_CAPITAL', + 'LOAN_ACCOUNTING_ACCOUNT_INTEREST', + 'LOAN_ACCOUNTING_ACCOUNT_INSURANCE' ); @@ -93,15 +96,23 @@ if (GETPOST('change_chart')) if ($action == 'update') { $error = 0; - - foreach ( $list_account as $constname ) { + + foreach ( $list_account_main as $constname ) { $constvalue = GETPOST($constname, 'alpha'); - + if (! dolibarr_set_const($db, $constname, $constvalue, 'chaine', 0, '', $conf->entity)) { $error ++; } } - + + foreach ( $list_account as $constname ) { + $constvalue = GETPOST($constname, 'alpha'); + + if (! dolibarr_set_const($db, $constname, $constvalue, 'chaine', 0, '', $conf->entity)) { + $error ++; + } + } + if (! $error) { setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); } else { @@ -114,11 +125,11 @@ if ($action == 'update') { * View */ -llxHeader(); - $form = new Form($db); $formaccounting = new FormAccounting($db); +llxHeader(); + $linkback = ''; print load_fiche_titre($langs->trans('MenuDefaultAccounts'), $linkback, 'title_accountancy'); @@ -129,18 +140,47 @@ print ''; print ''; print ''; -// Define Chart of accounts + +// Define main accounts for thirdparty print '
'; @@ -617,7 +617,7 @@ if ($id) if ($sortorder) $paramwithsearch.= '&sortorder='.$sortorder; if ($sortfield) $paramwithsearch.= '&sortfield='.$sortfield; if (GETPOST('from')) $paramwithsearch.= '&from='.GETPOST('from','alpha'); - + // There is several pages if ($num > $listlimit) { @@ -632,9 +632,9 @@ if ($id) foreach ($fieldlist as $field => $value) { $showfield=1; // By defaut - + if ($fieldlist[$field]=='region_id' || $fieldlist[$field]=='country_id') { $showfield=0; } - + if ($showfield) { if ($value == 'country') @@ -661,7 +661,7 @@ if ($id) } print '
'; -foreach ( $list_account as $key ) { - +foreach ($list_account_main as $key) { + + print ''; + // Param + $label = $langs->trans($key); + $keydesc=$key.'_Desc'; + + $htmltext = $langs->trans($keydesc); + print ''; + // Value + print ''; + print ''; +} + + +print "
'; + print $form->textwithpicto($label, $htmltext); + print ''; // Do not force align=right, or it align also the content of the select box + print $formaccounting->select_account($conf->global->$key, $key, 1, '', 1, 1); + print '
\n"; + + +print '
'; + +// Define default accounts + +print ''; + +foreach ($list_account as $key) { + print ''; // Param $label = $langs->trans($key); - print ''; + print ''; // Value - print ''; print ''; diff --git a/htdocs/accountancy/admin/journals_list.php b/htdocs/accountancy/admin/journals_list.php index 68d5e5af5c0..dd1982d057c 100644 --- a/htdocs/accountancy/admin/journals_list.php +++ b/htdocs/accountancy/admin/journals_list.php @@ -127,7 +127,7 @@ complete_dictionary_with_modules($taborder,$tabname,$tablib,$tabsql,$tabsqlsort, // Define elementList and sourceList (used for dictionary type of contacts "llx_c_type_contact") $elementList = array(); - // Must match ids defined into eldy.lib.php + // Must match ids defined into eldy.lib.php $sourceList = array( '1' => $langs->trans('AccountingJournalType1'), '2' => $langs->trans('AccountingJournalType2'), @@ -142,7 +142,7 @@ $elementList = array(); if (GETPOST('button_removefilter') || GETPOST('button_removefilter.x') || GETPOST('button_removefilter_x')) { - $search_country_id = ''; + $search_country_id = ''; } // Actions add or modify an entry into a dictionary @@ -371,13 +371,6 @@ if ($id) print load_fiche_titre($titre,$linkback,$titlepicto); -if (empty($id)) -{ - print $langs->trans("DictionaryDesc"); - print " ".$langs->trans("OnlyActiveElementsAreShown")."
\n"; -} -print "
\n"; - // Confirmation de la suppression de la ligne if ($action == 'delete') @@ -400,7 +393,7 @@ if ($id) else $sql.=" WHERE "; $sql.= " c.rowid = ".$search_country_id; } - + if ($sortfield) { // If sort order is "country", we use country_code instead @@ -427,7 +420,7 @@ if ($id) print ''; print ''; print ''; - + print '
' . $label . '' . $label . ''; // Do not force align=right, or it align also the content of the select box + print ''; // Do not force align=right, or it align also the content of the select box print $formaccounting->select_account($conf->global->$key, $key, 1, '', 1, 1); print '
'; // Form to add a new line @@ -453,7 +446,7 @@ if ($id) $valuetoshow=$langs->trans("Label"); } if ($fieldlist[$field]=='nature') { $valuetoshow=$langs->trans("Nature"); } - + if ($valuetoshow != '') { print ''; print ''; - + if ($num) { // Lines with values @@ -621,7 +614,7 @@ if ($id) { foreach ($fieldlist as $field => $value) { - + $showfield=1; $align="left"; $valuetoshow=$obj->{$fieldlist[$field]}; @@ -682,10 +675,10 @@ if ($id) else print ''; print ''; - + print ''; } - + print "\n"; $i++; } diff --git a/htdocs/accountancy/bookkeeping/card.php b/htdocs/accountancy/bookkeeping/card.php index 4443fb959b2..3ef418e2e20 100644 --- a/htdocs/accountancy/bookkeeping/card.php +++ b/htdocs/accountancy/bookkeeping/card.php @@ -48,9 +48,9 @@ $piece_num = GETPOST("piece_num"); $mesg = ''; $account_number = GETPOST('account_number'); -$code_tiers = GETPOST('code_tiers'); -if ($code_tiers == - 1) { - $code_tiers = null; +$subledger_account = GETPOST('subledger_account'); +if ($subledger_account == - 1) { + $subledger_account = null; } $label_compte = GETPOST('label_compte'); $debit = price2num(GETPOST('debit')); @@ -82,7 +82,7 @@ if ($action == "confirm_update") { setEventMessages($book->error, $book->errors, 'errors'); } else { $book->numero_compte = $account_number; - $book->code_tiers = $code_tiers; + $book->subledger_account = $subledger_account; $book->label_compte = $label_compte; $book->debit = $debit; $book->credit = $credit; @@ -119,7 +119,7 @@ else if ($action == "add") { $book = new BookKeeping($db); $book->numero_compte = $account_number; - $book->code_tiers = $code_tiers; + $book->subledger_account = $subledger_account; $book->label_compte = $label_compte; $book->debit = $debit; $book->credit = $credit; @@ -171,7 +171,7 @@ else if ($action == "confirm_delete") { else if ($action == "confirm_create") { $error = 0; - + $book = new BookKeeping($db); if (! GETPOST('next_num_mvt')) @@ -179,7 +179,7 @@ else if ($action == "confirm_create") { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("NumPiece")), null, 'errors'); $error++; } - + if (! $error) { $book->label_compte = ''; @@ -192,9 +192,9 @@ else if ($action == "confirm_create") { $book->code_journal = GETPOST('code_journal'); $book->fk_doc = 0; $book->fk_docdet = 0; - + $book->montant = 0; - + $result = $book->createStd($user); if ($result < 0) { setEventMessages($book->error, $book->errors, 'errors'); @@ -289,9 +289,9 @@ if ($action == 'create') { print load_fiche_titre($langs->trans("UpdateMvts"), '' . $langs->trans('BackToList') . ''); dol_fiche_head(); - + print '
'; - + print '
'; @@ -522,7 +515,7 @@ if ($id) if ($sortorder) $paramwithsearch.= '&sortorder='.$sortorder; if ($sortfield) $paramwithsearch.= '&sortfield='.$sortfield; if (GETPOST('from')) $paramwithsearch.= '&from='.GETPOST('from','alpha'); - + // There is several pages if ($num > $listlimit) { @@ -582,7 +575,7 @@ if ($id) } print '
 
'; print ''; @@ -306,12 +306,12 @@ if ($action == 'create') { print ''; print ''; - print ''; - + print ''; print ''; print ''; @@ -335,13 +335,13 @@ if ($action == 'create') { print ''; print ''; print '
' . $langs->trans("Codejournal") . ''; + print ''; $accountingjournal = new AccountingJournal($db); $accountingjournal->fetch('',$book->code_journal); - print $accountingjournal->getNomUrl(0,1,1,'',1); + print $accountingjournal->getNomUrl(0,1,1,'',1); print '
' . $langs->trans("Docref") . '' . $book->doc_ref . '' . $typelabel . '
'; - + print '
'; - + dol_fiche_end(); print '
'; - + $result = $book->fetch_all_per_mvt($piece_num); if ($result < 0) { setEventMessages($book->error, $book->errors, 'errors'); @@ -358,7 +358,7 @@ if ($action == 'create') { print '' . "\n"; $var=False; - + print ""; if (count($book->linesmvt) > 0) { @@ -368,7 +368,7 @@ if ($action == 'create') { print ''; print_liste_field_titre($langs->trans("AccountAccountingShort")); - print_liste_field_titre($langs->trans("Code_tiers")); + print_liste_field_titre($langs->trans("subledger_account")); print_liste_field_titre($langs->trans("Labelcompte")); print_liste_field_titre($langs->trans("Debit"), "", "", "", "", 'align="right"'); print_liste_field_titre($langs->trans("Credit"), "", "", "", "", 'align="right"'); @@ -390,7 +390,7 @@ if ($action == 'create') { print $formaccounting->select_account($line->numero_compte, 'account_number', 0, array (), 1, 1, ''); print ''; print ''; print ''; print ''; @@ -403,7 +403,7 @@ if ($action == 'create') { print ''; } else { print ''; - print ''; + print ''; print ''; print ''; print ''; @@ -423,7 +423,7 @@ if ($action == 'create') { print "\n"; } - if ($total_debit != $total_credit) + if ($total_debit != $total_credit) { setEventMessages(null, array($langs->trans('MvtNotCorrectlyBalanced', $total_credit, $total_debit)), 'warnings'); } @@ -434,7 +434,7 @@ if ($action == 'create') { print $formaccounting->select_account($account_number, 'account_number', 0, array (), 1, 1, ''); print ''; print ''; print ''; print ''; diff --git a/htdocs/accountancy/bookkeeping/list.php b/htdocs/accountancy/bookkeeping/list.php index 26ab0fa4c4d..b6685248ca7 100644 --- a/htdocs/accountancy/bookkeeping/list.php +++ b/htdocs/accountancy/bookkeeping/list.php @@ -171,15 +171,15 @@ if (! empty($search_accountancy_code_end)) { $param .= '&search_accountancy_code_end=' . $search_accountancy_code_end; } if (! empty($search_accountancy_aux_code)) { - $filter['t.code_tiers'] = $search_accountancy_aux_code; + $filter['t.subledger_account'] = $search_accountancy_aux_code; $param .= '&search_accountancy_aux_code=' . $search_accountancy_aux_code; } if (! empty($search_accountancy_aux_code_start)) { - $filter['t.code_tiers>='] = $search_accountancy_aux_code_start; + $filter['t.subledger_account>='] = $search_accountancy_aux_code_start; $param .= '&search_accountancy_aux_code_start=' . $search_accountancy_aux_code_start; } if (! empty($search_accountancy_aux_code_end)) { - $filter['t.code_tiers<='] = $search_accountancy_aux_code_end; + $filter['t.subledger_account<='] = $search_accountancy_aux_code_end; $param .= '&search_accountancy_aux_code_end=' . $search_accountancy_aux_code_end; } if (! empty($search_mvt_label)) { @@ -223,7 +223,7 @@ if ($action == 'delbookkeepingyearconfirm') { $deljournal=0; } - if (! empty($delyear) || ! empty($deljournal)) + if (! empty($delyear) || ! empty($deljournal)) { $result = $object->deleteByYearAndJournal($delyear,$deljournal); if ($result < 0) { @@ -365,7 +365,7 @@ $groupby = ' ' . "\n"; +print '
'; - print $formaccounting->select_auxaccount($line->code_tiers, 'code_tiers', 1); + print $formaccounting->select_auxaccount($line->subledger_account, 'subledger_account', 1); print '' . length_accountg($line->numero_compte) . '' . length_accounta($line->code_tiers) . '' . length_accounta($line->subledger_account) . '' . $line->label_compte . '' . price($line->debit) . '' . price($line->credit) . '
'; - print $formaccounting->select_auxaccount($code_tiers, 'code_tiers', 1); + print $formaccounting->select_auxaccount($subledger_account, 'subledger_account', 1); print '
'; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; - print ''; + print ''; print ''; - print ''; - print ''; + print ''; + print ''; $accountingjournal = new AccountingJournal($db); - $accountingjournal->fetch('',$line->code_journal); - print ''; + $result = $accountingjournal->fetch('',$line->code_journal); + $journaltoshow = (($result > 0)?$accountingjournal->getNomUrl(0,0,0,'',0) : $line->code_journal); + print ''; print '\n"; print ''; -$var = True; $total_debit = 0; $total_credit = 0; $sous_total_debit = 0; $sous_total_credit = 0; -$displayed_account_number = null; // Start with undefined to be able to distinguish with empty +$displayed_account_number = null; // Start with undefined to be able to distinguish with empty foreach ( $object->lines as $line ) { @@ -272,10 +271,10 @@ foreach ( $object->lines as $line ) { $accountg = length_accountg($line->numero_compte); //if (empty($accountg)) $accountg = '-'; - + // Is it a break ? if ($accountg != $displayed_account_number || ! isset($displayed_account_number)) { - + // Affiche un Sous-Total par compte comptable if (isset($displayed_account_number)) { print ''; @@ -283,7 +282,7 @@ foreach ( $object->lines as $line ) { print "\n"; print ''; } - + // Show the break account $colspan = 9; print ""; @@ -292,7 +291,7 @@ foreach ( $object->lines as $line ) { else print ''.$langs->trans("Unknown").''; print ''; print ''; - + $displayed_account_number = $accountg; //if (empty($displayed_account_number)) $displayed_account_number='-'; $sous_total_debit = 0; @@ -303,24 +302,24 @@ foreach ( $object->lines as $line ) { print ''; print ''; print ''; - + // TODO Add a link according to doc_type and fk_doc print ''; - + // Affiche un lien vers la facture client/fournisseur $doc_ref = preg_replace('/\(.*\)/', '', $line->doc_ref); - print strlen(length_accounta($line->code_tiers)) == 0 ? '' : ''; + print strlen(length_accounta($line->subledger_account)) == 0 ? '' : ''; - print ''; - print ''; + print ''; + print ''; print ''; print ''; print "\n"; @@ -355,6 +354,4 @@ print "
'; +print '
'; print $langs->trans('From') . ': '; print $form->select_date($search_date_start, 'date_start', 0, 0, 1); -print '
'; +print '
'; +print '
'; print $langs->trans('to') . ': '; print $form->select_date($search_date_end, 'date_end', 0, 0, 1); +print '
'; print '
'; +print '
'; print $langs->trans('From'); print $formaccounting->select_account($search_accountancy_code_start, 'search_accountancy_code_start', 1, array (), 1, 1, ''); -print '
'; +print '
'; +print '
'; print $langs->trans('to'); print $formaccounting->select_account($search_accountancy_code_end, 'search_accountancy_code_end', 1, array (), 1, 1, ''); +print '
'; print '
'; +print '
'; print $langs->trans('From'); print $formaccounting->select_auxaccount($search_accountancy_aux_code_start, 'search_accountancy_aux_code_start', 1); -print '
'; +print '
'; +print '
'; print $langs->trans('to'); print $formaccounting->select_auxaccount($search_accountancy_aux_code_end, 'search_accountancy_aux_code_end', 1); +print '
'; print '
'; print ''; @@ -414,7 +423,7 @@ print_liste_field_titre($langs->trans("TransactionNumShort"), $_SERVER['PHP_SELF print_liste_field_titre($langs->trans("Docdate"), $_SERVER['PHP_SELF'], "t.doc_date", "", $param, 'align="center"', $sortfield, $sortorder); print_liste_field_titre($langs->trans("Docref"), $_SERVER['PHP_SELF'], "t.doc_ref", "", $param, "", $sortfield, $sortorder); print_liste_field_titre($langs->trans("AccountAccountingShort"), $_SERVER['PHP_SELF'], "t.numero_compte", "", $param, "", $sortfield, $sortorder); -print_liste_field_titre($langs->trans("Code_tiers"), $_SERVER['PHP_SELF'], "t.code_tiers", "", $param, "", $sortfield, $sortorder); +print_liste_field_titre($langs->trans("SubledgerAccount"), $_SERVER['PHP_SELF'], "t.subledger_account", "", $param, "", $sortfield, $sortorder); print_liste_field_titre($langs->trans("Label"), $_SERVER['PHP_SELF'], "t.label_compte", "", $param, "", $sortfield, $sortorder); print_liste_field_titre($langs->trans("Debit"), $_SERVER['PHP_SELF'], "t.debit", "", $param, 'align="right"', $sortfield, $sortorder); print_liste_field_titre($langs->trans("Credit"), $_SERVER['PHP_SELF'], "t.credit", "", $param, 'align="right"', $sortfield, $sortorder); @@ -440,14 +449,15 @@ foreach ($object->lines as $line ) { print '' . dol_print_date($line->doc_date, 'day') . '' . $line->doc_ref . '' . length_accountg($line->numero_compte) . '' . length_accounta($line->code_tiers) . '' . length_accounta($line->subledger_account) . '' . $line->label_compte . '' . price($line->debit) . '' . price($line->credit) . '' . ($line->debit ? price($line->debit) : ''). '' . ($line->credit ? price($line->credit) : '') . '' . $accountingjournal->getNomUrl(0,0,0,'',0) . '' . $journaltoshow . ''; print '' . img_edit() . ' '; diff --git a/htdocs/accountancy/bookkeeping/listbyaccount.php b/htdocs/accountancy/bookkeeping/listbyaccount.php index b9a5526a7ab..7d0ba2280ea 100644 --- a/htdocs/accountancy/bookkeeping/listbyaccount.php +++ b/htdocs/accountancy/bookkeeping/listbyaccount.php @@ -75,10 +75,6 @@ if (empty($search_date_end)) $search_date_end = dol_mktime(0, 0, 0, 12, 31, dol_ $object = new BookKeeping($db); -$formaccounting = new FormAccounting($db); -$formother = new FormOther($db); -$form = new Form($db); - $options = ''; $filter = array (); @@ -126,7 +122,7 @@ if (!GETPOST("button_removefilter_x") && !GETPOST("button_removefilter")) // Bot * Action */ -if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // All test are required to be compatible with all browsers +if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // All tests are required to be compatible with all browsers { $search_doc_date = ''; $search_accountancy_code = ''; @@ -156,6 +152,10 @@ if ($action == 'delmouvconfirm') { * View */ +$formaccounting = new FormAccounting($db); +$formother = new FormOther($db); +$form = new Form($db); + $title_page = $langs->trans("Bookkeeping") . ' ' . strtolower($langs->trans("By")) . ' ' . $langs->trans("AccountAccounting"); llxHeader('', $title_page); @@ -217,7 +217,7 @@ if ( preg_match('/^asc/i', $sortorder) ) else $sortorder = "desc"; -print '
' . "\n"; +print ''; @@ -257,13 +257,12 @@ print "
'.$langs->trans("SubTotal").':'.price($sous_total_debit).''.price($sous_total_credit).' 
 '.$line->piece_num.'' . dol_print_date($line->doc_date, 'day') . ''; //if ($line->doc_type == 'supplier_invoice') //if ($line->doc_type == 'customer_invoice') print $line->doc_ref; print '' . $line->label_compte . '' . $line->label_compte . '
(' . length_accounta($line->code_tiers) . ')
' . $line->label_compte . '' . $line->label_compte . '
(' . length_accounta($line->subledger_account) . ')
' . price($line->debit) . '' . price($line->credit) . '' . ($line->debit ? price($line->debit) :''). '' . ($line->credit ? price($line->credit) : '') . '' . $line->code_journal . ''; - print '' . img_edit() . ' '; + print '' . img_edit() . ' '; print '' . img_delete() . ''; print '
"; print ''; llxFooter(); - - $db->close(); diff --git a/htdocs/accountancy/bookkeeping/listbyyear.php b/htdocs/accountancy/bookkeeping/listbyyear.php index f4134a2e028..e7e51ae67e0 100644 --- a/htdocs/accountancy/bookkeeping/listbyyear.php +++ b/htdocs/accountancy/bookkeeping/listbyyear.php @@ -52,14 +52,14 @@ $search_numero_compte_end = GETPOST('search_numero_compte_end', 'alpha'); if ($search_numero_compte_end == - 1) { $search_numero_compte_end = ''; } -$search_code_tiers = GETPOST('search_code_tiers', 'alpha'); -$search_code_tiers_start = GETPOST('search_code_tiers_start', 'alpha'); -if ($search_code_tiers_start == - 1) { - $search_code_tiers_start = ''; +$search_subledger_account = GETPOST('search_subledger_account', 'alpha'); +$search_subledger_account_start = GETPOST('search_subledger_account_start', 'alpha'); +if ($search_subledger_account_start == - 1) { + $search_subledger_account_start = ''; } -$search_code_tiers_end = GETPOST('search_code_tiers_end', 'alpha'); -if ($search_code_tiers_end == - 1) { - $search_code_tiers_end = ''; +$search_subledger_account_end = GETPOST('search_subledger_account_end', 'alpha'); +if ($search_subledger_account_end == - 1) { + $search_subledger_account_end = ''; } $search_label_compte = GETPOST('search_label_compte', 'alpha'); $search_sens = GETPOST('search_sens', 'alpha'); @@ -81,15 +81,18 @@ if ($sortfield == "") $offset = $limit * $page; -llxHeader('', $langs->trans("Bookkeeping")); -if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter")) // Both test are required to be compatible with all browsers +/* + * Actions + */ + +if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // All tests are required to be compatible with all browsers { $search_doc_type = ""; $search_doc_date = ""; $search_doc_ref = ""; $search_numero_compte = ""; - $search_code_tiers = ""; + $search_subledger_account = ""; $search_label_compte = ""; $search_sens = ""; $search_code_journal = ""; @@ -129,17 +132,17 @@ if (! empty($search_numero_compte_end)) { $filter['t.numero_compte<='] = $search_numero_compte_end; $options .= '&search_numero_compte_end=' . $search_numero_compte_end; } -if (! empty($search_code_tiers)) { - $filter['t.code_tiers'] = $search_code_tiers; - $options .= '&search_code_tiers=' . $search_code_tiers; +if (! empty($search_subledger_account)) { + $filter['t.subledger_account'] = $search_subledger_account; + $options .= '&search_subledger_account=' . $search_subledger_account; } -if (! empty($search_code_tiers_start)) { - $filter['t.code_tiers>='] = $search_code_tiers_start; - $options .= '&search_code_tiers_start=' . $search_code_tiers_start; +if (! empty($search_subledger_account_start)) { + $filter['t.subledger_account>='] = $search_subledger_account_start; + $options .= '&search_subledger_account_start=' . $search_subledger_account_start; } -if (! empty($search_code_tiers_end)) { - $filter['t.code_tiers<='] = $search_code_tiers_end; - $options .= '&search_code_tiers_end=' . $search_code_tiers_end; +if (! empty($search_subledger_account_end)) { + $filter['t.subledger_account<='] = $search_subledger_account_end; + $options .= '&search_subledger_account_end=' . $search_subledger_account_end; } if (! empty($search_label_compte)) { $filter['t.label_compte'] = $search_label_compte; @@ -154,10 +157,13 @@ if (! empty($search_code_journal)) { $options .= '&search_code_journal=' . $search_code_journal; } + /* - * Mode List + * Actions */ +llxHeader('', $langs->trans("Bookkeeping")); + $nbtotalofrecords = ''; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $nbtotalofrecords = $object->fetchAll($sortorder, $sortfield, 0, 0); @@ -188,9 +194,9 @@ print $formaccounting->select_account($search_numero_compte_end, 'search_numero_ print '
'; print '
'; print $langs->trans('From') . ' ' . $langs->trans('ThirdPartyAccount') . ': '; -print $formaccounting->select_auxaccount($search_code_tiers_start, 'search_code_tiers_start', 1); +print $formaccounting->select_auxaccount($search_subledger_account_start, 'search_subledger_account_start', 1); print $langs->trans('To') . ' ' . $langs->trans('ThirdPartyAccount') . ': '; -print $formaccounting->select_auxaccount($search_code_tiers_end, 'searchcode_tiers_end', 1); +print $formaccounting->select_auxaccount($search_subledger_account_end, 'search_subledger_account_end', 1); print '
'; print ""; @@ -200,7 +206,7 @@ print_liste_field_titre($langs->trans("Doctype"), $_SERVER['PHP_SELF'], "t.doc_t print_liste_field_titre($langs->trans("Date"), $_SERVER['PHP_SELF'], "t.doc_date", "", $options, 'align="center"', $sortfield, $sortorder); print_liste_field_titre($langs->trans("Docref"), $_SERVER['PHP_SELF'], "t.doc_ref", "", $options, "", $sortfield, $sortorder); print_liste_field_titre($langs->trans("AccountAccounting"), $_SERVER['PHP_SELF'], "t.numero_compte", "", $options, "", $sortfield, $sortorder); -print_liste_field_titre($langs->trans("ThirdPartyAccount"), $_SERVER['PHP_SELF'], "t.code_tiers", "", $options, "", $sortfield, $sortorder); +print_liste_field_titre($langs->trans("ThirdPartyAccount"), $_SERVER['PHP_SELF'], "t.subledger_account", "", $options, "", $sortfield, $sortorder); print_liste_field_titre($langs->trans("Label"), $_SERVER['PHP_SELF'], "t.label_compte", "", $options, "", $sortfield, $sortorder); print_liste_field_titre($langs->trans("Debit"), $_SERVER['PHP_SELF'], "t.debit", "", $options, "", $sortfield, $sortorder); print_liste_field_titre($langs->trans("Credit"), $_SERVER['PHP_SELF'], "t.credit", "", $options, 'align="center"', $sortfield, $sortorder); @@ -232,7 +238,7 @@ print ''; print ''; print ''; print "\n"; -$var = True; - foreach ( $object->lines as $line ) { print ''; @@ -274,7 +278,7 @@ foreach ( $object->lines as $line ) { print ''; print ''; print ''; - print ''; + print ''; print ''; print ''; print ''; diff --git a/htdocs/accountancy/class/accountancycategory.class.php b/htdocs/accountancy/class/accountancycategory.class.php index 139498bd0b2..e4e3017ab15 100644 --- a/htdocs/accountancy/class/accountancycategory.class.php +++ b/htdocs/accountancy/class/accountancycategory.class.php @@ -138,7 +138,7 @@ class AccountancyCategory */ public function getAccountsWithNoCategory($id) { global $conf; - + $sql = "SELECT aa.account_number as numero_compte, aa.label as label_compte"; $sql .= " FROM " . MAIN_DB_PREFIX . "accounting_account as aa"; $sql .= " INNER JOIN " . MAIN_DB_PREFIX . "accounting_system as asy ON aa.fk_pcg_version = asy.pcg_version"; @@ -147,9 +147,9 @@ class AccountancyCategory $sql .= " AND aa.active = 1"; $sql .= " GROUP BY aa.account_number, aa.label"; $sql .= " ORDER BY aa.account_number, aa.label"; - + $this->lines_CptBk = array (); - + dol_syslog(__METHOD__, LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) { @@ -159,17 +159,17 @@ class AccountancyCategory $this->lines_cptbk[] = $obj; } } - + return $num; } else { $this->error = "Error " . $this->db->lasterror(); $this->errors[] = $this->error; dol_syslog(__METHOD__ . " " . implode(',' . $this->errors), LOG_ERR); - + return - 1; } } - + /** * Function to add an accounting account in an accounting category * @@ -191,7 +191,7 @@ class AccountancyCategory $sql .= " AND aa.active = 1"; $this->db->begin(); - + dol_syslog(__METHOD__, LOG_DEBUG); $resql = $this->db->query($sql); if (! $resql) { @@ -201,9 +201,9 @@ class AccountancyCategory return -1; } - while ( $obj = $this->db->fetch_object($resql)) + while ( $obj = $this->db->fetch_object($resql)) { - if (array_key_exists(length_accountg($obj->account_number), $cpts)) + if (array_key_exists(length_accountg($obj->account_number), $cpts)) { $sql = "UPDATE " . MAIN_DB_PREFIX . "accounting_account"; $sql .= " SET fk_accounting_category=" . $id_cat; @@ -332,7 +332,7 @@ class AccountancyCategory } /** - * Function to show result of an accounting account from the general ledger with a sens and a period + * Function to show result of an accounting account from the ledger with a direction and a period * * @param int $cpt Id accounting account * @param string $month Specifig month - Can be empty diff --git a/htdocs/accountancy/class/accountancyexport.class.php b/htdocs/accountancy/class/accountancyexport.class.php index 1af9e5d1a6b..dc2b3195ee3 100644 --- a/htdocs/accountancy/class/accountancyexport.class.php +++ b/htdocs/accountancy/class/accountancyexport.class.php @@ -172,7 +172,7 @@ class AccountancyExport print $date . $this->separator; print $line->doc_ref . $this->separator; print length_accountg($line->numero_compte) . $this->separator; - print length_accounta($line->code_tiers) . $this->separator; + print length_accounta($line->subledger_account) . $this->separator; print price($line->debit) . $this->separator; print price($line->credit) . $this->separator; print $line->code_journal . $this->separator; @@ -195,7 +195,7 @@ class AccountancyExport print $date . $separator; print $line->code_journal . $separator; print length_accountg($line->numero_compte) . $separator; - print length_accounta($line->code_tiers) . $separator; + print length_accounta($line->subledger_account) . $separator; print $line->sens . $separator; print price($line->montant) . $separator; print $line->label_compte . $separator; @@ -254,7 +254,7 @@ class AccountancyExport print price($line->debit) . $this->separator; print price($line->credit) . $this->separator; print 'E' . $this->separator; - print length_accountg($line->code_tiers) . $this->separator; + print length_accountg($line->subledger_account) . $this->separator; print $this->end_line; } } @@ -274,7 +274,7 @@ class AccountancyExport $date = dol_print_date($line->doc_date, '%d/%m/%Y'); print $date . $this->separator; - if (empty($line->code_tiers)) { + if (empty($line->subledger_account)) { print 'G' . $this->separator; print length_accounta($line->numero_compte) . $this->separator; } else { @@ -284,7 +284,7 @@ class AccountancyExport if (substr($line->numero_compte, 0, 3) == '401') { print 'F' . $this->separator; } - print length_accountg($line->code_tiers) . $this->separator; + print length_accountg($line->subledger_account) . $this->separator; } print price($line->debit) . $this->separator; @@ -307,11 +307,11 @@ class AccountancyExport $this->end_line ="\r\n"; $i = 1; - $date_ecriture = dol_print_date(time(), $conf->global->ACCOUNTING_EXPORT_DATE); // format must be yyyymmdd + $date_ecriture = dol_print_date(dol_now(), $conf->global->ACCOUNTING_EXPORT_DATE); // format must be yyyymmdd foreach ( $TData as $data ) { $code_compta = $data->numero_compte; - if (! empty($data->code_tiers)) - $code_compta = $data->code_tiers; + if (! empty($data->subledger_account)) + $code_compta = $data->subledger_account; $Tab = array (); $Tab['num_ecriture'] = str_pad($i, 5); @@ -349,8 +349,8 @@ class AccountancyExport $date_ecriture = dol_print_date(time(), $conf->global->ACCOUNTING_EXPORT_DATE); // format must be ddmmyy foreach ( $TData as $data ) { $code_compta = $data->numero_compte; - if (! empty($data->code_tiers)) - $code_compta = $data->code_tiers; + if (! empty($data->subledger_account)) + $code_compta = $data->subledger_account; $Tab = array (); $Tab['type_ligne'] = 'M'; @@ -436,19 +436,21 @@ class AccountancyExport print '"'.dol_trunc($line->piece_num,15,'right','UTF-8',1).'"'.$this->separator; print $date . $this->separator; print '"'.dol_trunc($line->piece_num,15,'right','UTF-8',1).'"'.$this->separator; - - if (empty($line->code_tiers)) { + + if (empty($line->subledger_account)) { print length_accountg($line->numero_compte) . $this->separator; } else { + // FIXME Because the subledger_account is already an accounting account, does we really need + // to concat 4011 or 401 to it ? if (substr($line->numero_compte, 0, 1) == 'C' || substr($line->numero_compte, 0, 1) == '9') { - print '411' . substr(str_replace(" ", "", $line->code_tiers), 0, 5) . $this->separator; + print '411' . substr(str_replace(" ", "", $line->subledger_account), 0, 5) . $this->separator; } if (substr($line->numero_compte, 0, 1) == 'F' || substr($line->numero_compte, 0, 1) == '0') { - print '401' . substr(str_replace(" ", "", $line->code_tiers), 0, 5) . $this->separator; + print '401' . substr(str_replace(" ", "", $line->subledger_account), 0, 5) . $this->separator; } } - - print length_accounta($line->code_tiers) . $this->separator; + + print length_accounta($line->subledger_account) . $this->separator; print price($line->debit) . $this->separator; print price($line->credit) . $this->separator; print price($line->montant).$this->separator; diff --git a/htdocs/accountancy/class/accountingjournal.class.php b/htdocs/accountancy/class/accountingjournal.class.php index 168934ee5a5..f47715ace58 100644 --- a/htdocs/accountancy/class/accountingjournal.class.php +++ b/htdocs/accountancy/class/accountingjournal.class.php @@ -46,7 +46,7 @@ class AccountingJournal extends CommonObject function __construct($db) { $this->db = $db; } - + /** * Load an object from database * @@ -62,9 +62,9 @@ class AccountingJournal extends CommonObject $sql.= " FROM ".MAIN_DB_PREFIX."accounting_journal"; $sql .= " WHERE"; if ($rowid) { - $sql .= " rowid = '" . $rowid . "'"; + $sql .= " rowid = " . (int) $rowid; } elseif ($journal_code) { - $sql .= " code = '" . $journal_code . "'"; + $sql .= " code = '" . $this->db->escape($journal_code) . "'"; } dol_syslog(get_class($this)."::fetch sql=" . $sql, LOG_DEBUG); @@ -96,7 +96,7 @@ class AccountingJournal extends CommonObject } return -1; } - + /** * Return clicable name (with picto eventually) * @@ -147,7 +147,7 @@ class AccountingJournal extends CommonObject { $linkstart = ''; $linkclose = ''; - $linkend = ''; + $linkend = ''; } $label_link = $this->code; @@ -158,7 +158,7 @@ class AccountingJournal extends CommonObject if ($withpicto != 2) $result.=$linkstart . $label_link . $linkend; return $result; } - + /** * Retourne le libelle du statut d'un user (actif, inactif) * @@ -169,7 +169,7 @@ class AccountingJournal extends CommonObject { return $this->LibType($this->nature,$mode); } - + /** * Return type of an accounting journal * @@ -182,7 +182,7 @@ class AccountingJournal extends CommonObject global $langs; $langs->load("accountancy"); - + if ($mode == 0) { $prefix=''; diff --git a/htdocs/accountancy/class/bookkeeping.class.php b/htdocs/accountancy/class/bookkeeping.class.php index 0fc4a936117..f7c1b4d8b89 100644 --- a/htdocs/accountancy/class/bookkeeping.class.php +++ b/htdocs/accountancy/class/bookkeeping.class.php @@ -20,14 +20,14 @@ /** * \file htdocs/accountancy/class/bookkeeping.class.php * \ingroup Advanced accountancy - * \brief File of class to manage general ledger + * \brief File of class to manage Ledger (General Ledger and Subledger) */ // Class require_once DOL_DOCUMENT_ROOT . '/core/class/commonobject.class.php'; /** - * Class to manage general ledger + * Class to manage Ledger (General Ledger and Subledger) */ class BookKeeping extends CommonObject { @@ -53,7 +53,7 @@ class BookKeeping extends CommonObject * * @var string Name of table without prefix where object is stored */ - public $table_element = 'accounting_bookkeeping'; + public $table_element = 'accounting_bookkeeping'; public $entity = 1; @@ -75,7 +75,9 @@ class BookKeeping extends CommonObject public $doc_ref; public $fk_doc; public $fk_docdet; - public $code_tiers; + public $thirdparty_code; + public $subledger_account; + public $subledger_label; public $numero_compte; public $label_compte; public $debit; @@ -127,8 +129,14 @@ class BookKeeping extends CommonObject if (isset($this->fk_docdet)) { $this->fk_docdet = trim($this->fk_docdet); } - if (isset($this->code_tiers)) { - $this->code_tiers = trim($this->code_tiers); + if (isset($this->thirdparty_code)) { + $this->thirdparty_code = trim($this->thirdparty_code); + } + if (isset($this->subledger_account)) { + $this->subledger_account = trim($this->subledger_account); + } + if (isset($this->subledger_label)) { + $this->subledger_label = trim($this->subledger_label); } if (isset($this->numero_compte)) { $this->numero_compte = trim($this->numero_compte); @@ -165,7 +173,7 @@ class BookKeeping extends CommonObject } if (empty($this->debit)) $this->debit = 0; if (empty($this->credit)) $this->credit = 0; - + // Check parameters if (empty($this->numero_compte) || $this->numero_compte == '-1') { @@ -176,7 +184,7 @@ class BookKeeping extends CommonObject } else { - $this->errors[]=$langs->trans('ErrorFieldAccountNotDefinedForInvoiceLine', $this->fk_doc, $this->doc_type); + $this->errors[]=$langs->trans('ErrorFieldAccountNotDefinedForInvoiceLine', $this->fk_doc, $this->doc_type); } return -1; @@ -191,7 +199,7 @@ class BookKeeping extends CommonObject $sql .= " FROM " . MAIN_DB_PREFIX . $this->table_element; $sql .= " WHERE doc_type = '" . $this->db->escape($this->doc_type) . "'"; $sql .= " AND fk_doc = " . $this->fk_doc; - $sql .= " AND fk_docdet = " . $this->fk_docdet; // This field can be 0 is record is for several lines + $sql .= " AND fk_docdet = " . $this->fk_docdet; // This field can be 0 is record is for several lines $sql .= " AND numero_compte = '" . $this->db->escape($this->numero_compte) . "'"; $sql .= " AND entity IN (" . getEntity('accountancy') . ")"; @@ -199,12 +207,12 @@ class BookKeeping extends CommonObject if ($resql) { $row = $this->db->fetch_object($resql); - if ($row->nb == 0) + if ($row->nb == 0) { // Determine piece_num $sqlnum = "SELECT piece_num"; $sqlnum .= " FROM " . MAIN_DB_PREFIX . $this->table_element; - $sqlnum .= " WHERE doc_type = '" . $this->db->escape($this->doc_type) . "'"; // For example doc_type = 'bank' + $sqlnum .= " WHERE doc_type = '" . $this->db->escape($this->doc_type) . "'"; // For example doc_type = 'bank' $sqlnum .= " AND fk_docdet = " . $this->db->escape($this->fk_docdet); // fk_docdet is rowid into llx_bank or llx_facturedet or llx_facturefourndet, or ... $sqlnum .= " AND doc_ref = '" . $this->db->escape($this->doc_ref) . "'"; // ref of source object $sqlnum .= " AND entity IN (" . getEntity('accountancy') . ")"; @@ -244,7 +252,9 @@ class BookKeeping extends CommonObject $sql .= ", doc_ref"; $sql .= ", fk_doc"; $sql .= ", fk_docdet"; - $sql .= ", code_tiers"; + $sql .= ", thirdparty_code"; + $sql .= ", subledger_account"; + $sql .= ", subledger_label"; $sql .= ", numero_compte"; $sql .= ", label_compte"; $sql .= ", debit"; @@ -256,25 +266,27 @@ class BookKeeping extends CommonObject $sql .= ", code_journal"; $sql .= ", journal_label"; $sql .= ", piece_num"; - $sql .= ', entity'; + $sql .= ', entity'; $sql .= ") VALUES ("; $sql .= "'" . $this->db->idate($this->doc_date) . "'"; - $sql .= ",'" . $this->doc_type . "'"; - $sql .= ",'" . $this->doc_ref . "'"; + $sql .= ",'" . $this->db->escape($this->doc_type) . "'"; + $sql .= ",'" . $this->db->escape($this->doc_ref) . "'"; $sql .= "," . $this->fk_doc; $sql .= "," . $this->fk_docdet; - $sql .= ",'" . $this->code_tiers . "'"; - $sql .= ",'" . $this->numero_compte . "'"; + $sql .= ",'" . $this->db->escape($this->thirdparty_code) . "'"; + $sql .= ",'" . $this->db->escape($this->subledger_account) . "'"; + $sql .= ",'" . $this->db->escape($this->subledger_label) . "'"; + $sql .= ",'" . $this->db->escape($this->numero_compte) . "'"; $sql .= ",'" . $this->db->escape($this->label_compte) . "'"; $sql .= "," . $this->debit; $sql .= "," . $this->credit; $sql .= "," . $this->montant; - $sql .= ",'" . $this->sens . "'"; - $sql .= ",'" . $this->fk_user_author . "'"; + $sql .= ",'" . $this->db->escape($this->sens) . "'"; + $sql .= ",'" . $this->db->escape($this->fk_user_author) . "'"; $sql .= ",'" . $this->db->idate($this->date_create). "'"; - $sql .= ",'" . $this->code_journal . "'"; - $sql .= ",'" . $this->journal_label . "'"; - $sql .= "," . $this->piece_num; + $sql .= ",'" . $this->db->escape($this->code_journal) . "'"; + $sql .= ",'" . $this->db->escape($this->journal_label) . "'"; + $sql .= "," . $this->db->escape($this->piece_num); $sql .= ", " . (! isset($this->entity) ? '1' : $this->entity); $sql .= ")"; @@ -282,7 +294,7 @@ class BookKeeping extends CommonObject $resql = $this->db->query($sql); if ($resql) { $id = $this->db->last_insert_id(MAIN_DB_PREFIX . $this->table_element); - + if ($id > 0) { $this->id = $id; $result = 0; @@ -312,11 +324,11 @@ class BookKeeping extends CommonObject } if (! $error) { - + if (! $notrigger) { // Uncomment this and change MYOBJECT to your own tag if you // want this action to call a trigger. - + // // Call triggers // $result=$this->call_trigger('MYOBJECT_CREATE',$user); // if ($result < 0) $error++; @@ -360,8 +372,14 @@ class BookKeeping extends CommonObject if (isset($this->fk_docdet)) { $this->fk_docdet = trim($this->fk_docdet); } - if (isset($this->code_tiers)) { - $this->code_tiers = trim($this->code_tiers); + if (isset($this->thirdparty_code)) { + $this->thirdparty_code = trim($this->thirdparty_code); + } + if (isset($this->subledger_account)) { + $this->subledger_account = trim($this->subledger_account); + } + if (isset($this->subledger_label)) { + $this->subledger_label = trim($this->subledger_label); } if (isset($this->numero_compte)) { $this->numero_compte = trim($this->numero_compte); @@ -409,7 +427,9 @@ class BookKeeping extends CommonObject $sql .= 'doc_ref,'; $sql .= 'fk_doc,'; $sql .= 'fk_docdet,'; - $sql .= 'code_tiers,'; + $sql .= 'thirdparty,'; + $sql .= 'subledger_account,'; + $sql .= 'subledger_label,'; $sql .= 'numero_compte,'; $sql .= 'label_compte,'; $sql .= 'debit,'; @@ -428,7 +448,9 @@ class BookKeeping extends CommonObject $sql .= ' ' . (! isset($this->doc_ref) ? 'NULL' : "'" . $this->db->escape($this->doc_ref) . "'") . ','; $sql .= ' ' . (empty($this->fk_doc) ? '0' : $this->fk_doc) . ','; $sql .= ' ' . (empty($this->fk_docdet) ? '0' : $this->fk_docdet) . ','; - $sql .= ' ' . (! isset($this->code_tiers) ? 'NULL' : "'" . $this->db->escape($this->code_tiers) . "'") . ','; + $sql .= ' ' . (! isset($this->thirdparty_code) ? 'NULL' : "'" . $this->db->escape($this->thirdparty_code) . "'") . ','; + $sql .= ' ' . (! isset($this->subledger_account) ? 'NULL' : "'" . $this->db->escape($this->subledger_account) . "'") . ','; + $sql .= ' ' . (! isset($this->subledger_label) ? 'NULL' : "'" . $this->db->escape($this->subledger_label) . "'") . ','; $sql .= ' ' . (! isset($this->numero_compte) ? "'NotDefined'" : "'" . $this->db->escape($this->numero_compte) . "'") . ','; $sql .= ' ' . (! isset($this->label_compte) ? 'NULL' : "'" . $this->db->escape($this->label_compte) . "'") . ','; $sql .= ' ' . (! isset($this->debit) ? 'NULL' : $this->debit ). ','; @@ -458,7 +480,7 @@ class BookKeeping extends CommonObject if (! $notrigger) { // Uncomment this and change MYOBJECT to your own tag if you // want this action to call a trigger. - + // // Call triggers // $result=$this->call_trigger('MYOBJECT_CREATE',$user); // if ($result < 0) $error++; @@ -483,7 +505,7 @@ class BookKeeping extends CommonObject * * @param int $id Id object * @param string $ref Ref - * + * * @return int <0 if KO, 0 if not found, >0 if OK */ public function fetch($id, $ref = null) { @@ -498,7 +520,9 @@ class BookKeeping extends CommonObject $sql .= " t.doc_ref,"; $sql .= " t.fk_doc,"; $sql .= " t.fk_docdet,"; - $sql .= " t.code_tiers,"; + $sql .= " t.thirdparty_code,"; + $sql .= " t.subledger_account,"; + $sql .= " t.subledger_label,"; $sql .= " t.numero_compte,"; $sql .= " t.label_compte,"; $sql .= " t.debit,"; @@ -532,7 +556,9 @@ class BookKeeping extends CommonObject $this->doc_ref = $obj->doc_ref; $this->fk_doc = $obj->fk_doc; $this->fk_docdet = $obj->fk_docdet; - $this->code_tiers = $obj->code_tiers; + $this->thirdparty_code = $obj->thirdparty_code; + $this->subledger_account = $obj->subledger_account; + $this->subledger_label = $obj->subledger_label; $this->numero_compte = $obj->numero_compte; $this->label_compte = $obj->label_compte; $this->debit = $obj->debit; @@ -555,11 +581,11 @@ class BookKeeping extends CommonObject } else { $this->errors[] = 'Error ' . $this->db->lasterror(); dol_syslog(__METHOD__ . ' ' . join(',', $this->errors), LOG_ERR); - + return - 1; } } - + /** * Load object in memory from the database * @@ -569,7 +595,7 @@ class BookKeeping extends CommonObject * @param int $offset offset limit * @param array $filter filter array * @param string $filtermode filter mode (AND or OR) - * + * * @return int <0 if KO, >0 if OK */ public function fetchAllByAccount($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, array $filter = array(), $filtermode = 'AND') { @@ -584,7 +610,9 @@ class BookKeeping extends CommonObject $sql .= " t.doc_ref,"; $sql .= " t.fk_doc,"; $sql .= " t.fk_docdet,"; - $sql .= " t.code_tiers,"; + $sql .= " t.thirdparty_code,"; + $sql .= " t.subledger_account,"; + $sql .= " t.subledger_label,"; $sql .= " t.numero_compte,"; $sql .= " t.label_compte,"; $sql .= " t.debit,"; @@ -604,11 +632,11 @@ class BookKeeping extends CommonObject $sqlwhere[] = $key . '=\'' . $this->db->idate($value) . '\''; } elseif ($key == 't.doc_date>=' || $key == 't.doc_date<=') { $sqlwhere[] = $key . '\'' . $this->db->idate($value) . '\''; - } elseif ($key == 't.numero_compte>=' || $key == 't.numero_compte<=' || $key == 't.code_tiers>=' || $key == 't.code_tiers<=') { + } elseif ($key == 't.numero_compte>=' || $key == 't.numero_compte<=' || $key == 't.subledger_account>=' || $key == 't.subledger_account<=') { $sqlwhere[] = $key . '\'' . $this->db->escape($value) . '\''; } elseif ($key == 't.fk_doc' || $key == 't.fk_docdet' || $key == 't.piece_num') { $sqlwhere[] = $key . '=' . $value; - } elseif ($key == 't.code_tiers' || $key == 't.numero_compte') { + } elseif ($key == 't.subledger_account' || $key == 't.numero_compte') { $sqlwhere[] = $key . ' LIKE \'' . $this->db->escape($value) . '%\''; } elseif ($key == 't.label_compte') { $sqlwhere[] = $key . ' LIKE \'' . $this->db->escape($value) . '%\''; @@ -630,7 +658,7 @@ class BookKeeping extends CommonObject } if (! empty($limit)) { $sql .= ' ' . $this->db->plimit($limit + 1, $offset); - } + } $this->lines = array (); $resql = $this->db->query($sql); @@ -647,7 +675,9 @@ class BookKeeping extends CommonObject $line->doc_ref = $obj->doc_ref; $line->fk_doc = $obj->fk_doc; $line->fk_docdet = $obj->fk_docdet; - $line->code_tiers = $obj->code_tiers; + $line->thirdparty_code = $obj->thirdparty_code; + $line->subledger_account = $obj->subledger_account; + $line->subledger_label = $obj->subledger_label; $line->numero_compte = $obj->numero_compte; $line->label_compte = $obj->label_compte; $line->debit = $obj->debit; @@ -672,8 +702,8 @@ class BookKeeping extends CommonObject return - 1; } } - - + + /** * Load object in memory from the database * @@ -683,7 +713,7 @@ class BookKeeping extends CommonObject * @param int $offset offset limit * @param array $filter filter array * @param string $filtermode filter mode (AND or OR) - * + * * @return int <0 if KO, >0 if OK */ public function fetchAll($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, array $filter = array(), $filtermode = 'AND') { @@ -698,7 +728,9 @@ class BookKeeping extends CommonObject $sql .= " t.doc_ref,"; $sql .= " t.fk_doc,"; $sql .= " t.fk_docdet,"; - $sql .= " t.code_tiers,"; + $sql .= " t.thirdparty_code,"; + $sql .= " t.subledger_account,"; + $sql .= " t.subledger_label,"; $sql .= " t.numero_compte,"; $sql .= " t.label_compte,"; $sql .= " t.debit,"; @@ -719,11 +751,11 @@ class BookKeeping extends CommonObject $sqlwhere[] = $key . '=\'' . $this->db->idate($value) . '\''; } elseif ($key == 't.doc_date>=' || $key == 't.doc_date<=') { $sqlwhere[] = $key . '\'' . $this->db->idate($value) . '\''; - } elseif ($key == 't.numero_compte>=' || $key == 't.numero_compte<=' || $key == 't.code_tiers>=' || $key == 't.code_tiers<=') { + } elseif ($key == 't.numero_compte>=' || $key == 't.numero_compte<=' || $key == 't.subledger_account>=' || $key == 't.subledger_account<=') { $sqlwhere[] = $key . '\'' . $this->db->escape($value) . '\''; } elseif ($key == 't.fk_doc' || $key == 't.fk_docdet' || $key == 't.piece_num') { $sqlwhere[] = $key . '=' . $value; - } elseif ($key == 't.code_tiers' || $key == 't.numero_compte') { + } elseif ($key == 't.subledger_account' || $key == 't.numero_compte') { $sqlwhere[] = $key . ' LIKE \'' . $this->db->escape($value) . '%\''; } else { $sqlwhere[] = $key . ' LIKE \'%' . $this->db->escape($value) . '%\''; @@ -758,7 +790,9 @@ class BookKeeping extends CommonObject $line->doc_ref = $obj->doc_ref; $line->fk_doc = $obj->fk_doc; $line->fk_docdet = $obj->fk_docdet; - $line->code_tiers = $obj->code_tiers; + $line->thirdparty_code = $obj->thirdparty_code; + $line->subledger_account = $obj->subledger_account; + $line->subledger_label = $obj->subledger_label; $line->numero_compte = $obj->numero_compte; $line->label_compte = $obj->label_compte; $line->debit = $obj->debit; @@ -814,11 +848,11 @@ class BookKeeping extends CommonObject $sqlwhere[] = $key . '=\'' . $this->db->idate($value) . '\''; } elseif ($key == 't.doc_date>=' || $key == 't.doc_date<=') { $sqlwhere[] = $key . '\'' . $this->db->idate($value) . '\''; - } elseif ($key == 't.numero_compte>=' || $key == 't.numero_compte<=' || $key == 't.code_tiers>=' || $key == 't.code_tiers<=') { + } elseif ($key == 't.numero_compte>=' || $key == 't.numero_compte<=' || $key == 't.subledger_account>=' || $key == 't.subledger_account<=') { $sqlwhere[] = $key . '\'' . $this->db->escape($value) . '\''; } elseif ($key == 't.fk_doc' || $key == 't.fk_docdet' || $key == 't.piece_num') { $sqlwhere[] = $key . '=' . $value; - } elseif ($key == 't.code_tiers' || $key == 't.numero_compte') { + } elseif ($key == 't.subledger_account' || $key == 't.numero_compte') { $sqlwhere[] = $key . ' LIKE \'' . $this->db->escape($value) . '%\''; } else { $sqlwhere[] = $key . ' LIKE \'%' . $this->db->escape($value) . '%\''; @@ -834,7 +868,7 @@ class BookKeeping extends CommonObject $sql .= ' GROUP BY t.numero_compte'; if (! empty($sortfield)) { - $sql .= $this->db->order($sortfield, $sortorder); + $sql .= $this->db->order($sortfield, $sortorder); } if (! empty($limit)) { $sql .= ' ' . $this->db->plimit($limit + 1, $offset); @@ -869,7 +903,7 @@ class BookKeeping extends CommonObject * * @param User $user User that modifies * @param bool $notrigger false=launch triggers after, true=disable triggers - * + * * @return int <0 if KO, >0 if OK */ public function update(User $user, $notrigger = false) { @@ -890,8 +924,14 @@ class BookKeeping extends CommonObject if (isset($this->fk_docdet)) { $this->fk_docdet = trim($this->fk_docdet); } - if (isset($this->code_tiers)) { - $this->code_tiers = trim($this->code_tiers); + if (isset($this->thirdparty_code)) { + $this->thirdparty_code = trim($this->thirdparty_code); + } + if (isset($this->subledger_account)) { + $this->subledger_account = trim($this->subledger_account); + } + if (isset($this->subledger_label)) { + $this->subledger_label = trim($this->subledger_label); } if (isset($this->numero_compte)) { $this->numero_compte = trim($this->numero_compte); @@ -937,7 +977,9 @@ class BookKeeping extends CommonObject $sql .= ' doc_ref = ' . (isset($this->doc_ref) ? "'" . $this->db->escape($this->doc_ref) . "'" : "null") . ','; $sql .= ' fk_doc = ' . (isset($this->fk_doc) ? $this->fk_doc : "null") . ','; $sql .= ' fk_docdet = ' . (isset($this->fk_docdet) ? $this->fk_docdet : "null") . ','; - $sql .= ' code_tiers = ' . (isset($this->code_tiers) ? "'" . $this->db->escape($this->code_tiers) . "'" : "null") . ','; + $sql .= ' thirdparty_code = ' . (isset($this->thirdparty_code) ? "'" . $this->db->escape($this->thirdparty_code) . "'" : "null") . ','; + $sql .= ' subledger_account = ' . (isset($this->subledger_account) ? "'" . $this->db->escape($this->subledger_account) . "'" : "null") . ','; + $sql .= ' subledger_label = ' . (isset($this->subledger_label) ? "'" . $this->db->escape($this->subledger_label) . "'" : "null") . ','; $sql .= ' numero_compte = ' . (isset($this->numero_compte) ? "'" . $this->db->escape($this->numero_compte) . "'" : "null") . ','; $sql .= ' label_compte = ' . (isset($this->label_compte) ? "'" . $this->db->escape($this->label_compte) . "'" : "null") . ','; $sql .= ' debit = ' . (isset($this->debit) ? $this->debit : "null") . ','; @@ -963,7 +1005,7 @@ class BookKeeping extends CommonObject if (! $error && ! $notrigger) { // Uncomment this and change MYOBJECT to your own tag if you // want this action calls a trigger. - + // // Call triggers // $result=$this->call_trigger('MYOBJECT_MODIFY',$user); // if ($result < 0) { $error++; //Do also what you must do to rollback action if trigger fail} @@ -987,7 +1029,7 @@ class BookKeeping extends CommonObject * * @param User $user User that deletes * @param bool $notrigger false=launch triggers after, true=disable triggers - * + * * @return int <0 if KO, >0 if OK */ public function delete(User $user, $notrigger = false) { @@ -1070,7 +1112,7 @@ class BookKeeping extends CommonObject function deleteByYearAndJournal($delyear='', $journal='') { global $conf; - if (empty($delyear) && empty($journal)) + if (empty($delyear) && empty($journal)) { return -1; } @@ -1137,7 +1179,7 @@ class BookKeeping extends CommonObject * Load an object from its id and create a new one in database * * @param int $fromid Id of object to clone - * + * * @return int New id of clone */ public function createFromClone($fromid) { @@ -1196,8 +1238,10 @@ class BookKeeping extends CommonObject $this->doc_ref = ''; $this->fk_doc = ''; $this->fk_docdet = ''; - $this->code_tiers = ''; - $this->numero_compte = ''; + $this->thirdparty_code = 'CU001'; + $this->subledger_account = '410CU001'; + $this->subledger_label = 'My customer company'; + $this->numero_compte = '410'; $this->label_compte = ''; $this->debit = 99.9; $this->credit = ''; @@ -1205,8 +1249,8 @@ class BookKeeping extends CommonObject $this->sens = ''; $this->fk_user_author = $user->id; $this->import_key = ''; - $this->code_journal = ''; - $this->journal_label = ''; + $this->code_journal = 'VT'; + $this->journal_label = 'Journal de vente'; $this->piece_num = ''; } @@ -1249,7 +1293,7 @@ class BookKeeping extends CommonObject * * @return string Next numero to use */ - public function getNextNumMvt() + public function getNextNumMvt() { global $conf; @@ -1281,7 +1325,7 @@ class BookKeeping extends CommonObject global $conf; $sql = "SELECT rowid, doc_date, doc_type,"; - $sql .= " doc_ref, fk_doc, fk_docdet, code_tiers,"; + $sql .= " doc_ref, fk_doc, fk_docdet, thirdparty_code, subledger_account, subledger_label,"; $sql .= " numero_compte, label_compte, debit, credit,"; $sql .= " montant, sens, fk_user_author, import_key, code_journal, journal_label, piece_num"; $sql .= " FROM " . MAIN_DB_PREFIX . $this->table_element; @@ -1303,7 +1347,9 @@ class BookKeeping extends CommonObject $line->doc_ref = $obj->doc_ref; $line->fk_doc = $obj->fk_doc; $line->fk_docdet = $obj->fk_docdet; - $line->code_tiers = $obj->code_tiers; + $line->thirdparty_code = $obj->thirdparty_code; + $line->subledger_account = $obj->subledger_account; + $line->subledger_label = $obj->subledger_label; $line->numero_compte = $obj->numero_compte; $line->label_compte = $obj->label_compte; $line->debit = $obj->debit; @@ -1335,7 +1381,7 @@ class BookKeeping extends CommonObject global $conf; $sql = "SELECT rowid, doc_date, doc_type,"; - $sql .= " doc_ref, fk_doc, fk_docdet, code_tiers,"; + $sql .= " doc_ref, fk_doc, fk_docdet, thirdparty_code, subledger_account, subledger_label,"; $sql .= " numero_compte, label_compte, debit, credit,"; $sql .= " montant, sens, fk_user_author, import_key, code_journal, piece_num"; $sql .= " FROM " . MAIN_DB_PREFIX . $this->table_element; @@ -1359,7 +1405,9 @@ class BookKeeping extends CommonObject $line->doc_ref = $obj->doc_ref; $line->fk_doc = $obj->fk_doc; $line->fk_docdet = $obj->fk_docdet; - $line->code_tiers = $obj->code_tiers; + $line->thirdparty_code = $obj->thirdparty_code; + $line->subledger_account = $obj->subledger_account; + $line->subledger_label = $obj->subledger_label; $line->numero_compte = $obj->numero_compte; $line->label_compte = $obj->label_compte; $line->debit = $obj->debit; @@ -1380,9 +1428,9 @@ class BookKeeping extends CommonObject return - 1; } } - - - + + + /** * Return list of accounts with label by chart of accounts * @@ -1397,11 +1445,11 @@ class BookKeeping extends CommonObject */ function select_account($selectid, $htmlname = 'account', $showempty = 0, $event = array(), $select_in = 0, $select_out = 0, $aabase = '') { global $conf; - + require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php'; - + $pcgver = $conf->global->CHARTOFACCOUNTS; - + $sql = "SELECT DISTINCT ab.numero_compte as account_number, aa.label as label, aa.rowid as rowid, aa.fk_pcg_version"; $sql .= " FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping as ab"; $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON aa.account_number = ab.numero_compte"; @@ -1410,43 +1458,43 @@ class BookKeeping extends CommonObject $sql .= " AND asy.rowid = " . $pcgver; $sql .= " AND ab.entity IN (" . getEntity('accountancy') . ")"; $sql .= " ORDER BY account_number ASC"; - + dol_syslog(get_class($this) . "::select_account", LOG_DEBUG); $resql = $this->db->query($sql); - + if (! $resql) { $this->error = "Error " . $this->db->lasterror(); dol_syslog(get_class($this) . "::select_account " . $this->error, LOG_ERR); return - 1; } - + $out = ajax_combobox($htmlname, $event); - + $options = array(); $selected = null; - + while ($obj = $this->db->fetch_object($resql)) { $label = length_accountg($obj->account_number) . ' - ' . $obj->label; - + $select_value_in = $obj->rowid; $select_value_out = $obj->rowid; - + if ($select_in == 1) { $select_value_in = $obj->account_number; } if ($select_out == 1) { $select_value_out = $obj->account_number; } - + // Remember guy's we store in database llx_facturedet the rowid of accounting_account and not the account_number // Because same account_number can be share between different accounting_system and do have the same meaning if (($selectid != '') && $selectid == $select_value_in) { $selected = $select_value_out; } - + $options[$select_value_out] = $label; } - + $out .= Form::selectarray($htmlname, $options, $selected, $showempty, 0, 0, '', 0, 0, 0, '', 'maxwidth300'); $this->db->free($resql); return $out; @@ -1454,7 +1502,7 @@ class BookKeeping extends CommonObject /** - * Description of a root accounting account + * Description of a root accounting account * * @param string $account Accounting account * @return string Root account @@ -1470,7 +1518,7 @@ class BookKeeping extends CommonObject $sql .= " AND asy.rowid = " . $pcgver; $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as parent ON aa.account_parent = parent.rowid"; $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as root ON parent.account_parent = root.rowid"; - $sql .= " WHERE aa.account_number = '" . $account . "'"; + $sql .= " WHERE aa.account_number = '" . $account . "'"; $sql .= " AND parent.active = 1"; $sql .= " AND root.active = 1"; $sql .= " AND aa.entity IN (" . getEntity('accountancy') . ")"; @@ -1480,7 +1528,7 @@ class BookKeeping extends CommonObject if ($resql) { $obj = ''; if ($this->db->num_rows($resql)) { - $obj = $this->db->fetch_object($resql); + $obj = $this->db->fetch_object($resql); } return $obj->label; @@ -1492,8 +1540,8 @@ class BookKeeping extends CommonObject return -1; } } - - + + /** * Description of accounting account * @@ -1519,7 +1567,7 @@ class BookKeeping extends CommonObject if ($resql) { $obj = ''; if ($this->db->num_rows($resql)) { - $obj = $this->db->fetch_object($resql); + $obj = $this->db->fetch_object($resql); } if(empty($obj->category)){ return $obj->label; @@ -1532,7 +1580,7 @@ class BookKeeping extends CommonObject return -1; } } - + } @@ -1547,7 +1595,9 @@ class BookKeepingLine public $doc_ref; public $fk_doc; public $fk_docdet; - public $code_tiers; + public $thirdparty_code; + public $subledger_account; + public $subledger_label; public $numero_compte; public $label_compte; public $debit; diff --git a/htdocs/accountancy/index.php b/htdocs/accountancy/index.php index 02549be2a94..bf3e80fe866 100644 --- a/htdocs/accountancy/index.php +++ b/htdocs/accountancy/index.php @@ -63,8 +63,6 @@ print load_fiche_titre($langs->trans("AccountancyArea"), '', 'title_accountancy' $step = 0; -print "
\n"; - print $langs->trans("AccountancyAreaDescIntro")."
\n"; print "
\n";print "
\n"; diff --git a/htdocs/accountancy/journal/bankjournal.php b/htdocs/accountancy/journal/bankjournal.php index 9eae2072243..6c391531662 100644 --- a/htdocs/accountancy/journal/bankjournal.php +++ b/htdocs/accountancy/journal/bankjournal.php @@ -364,7 +364,7 @@ if (! $error && $action == 'writebookkeeping') { $bookkeeping->date_create = $now; if ($tabtype[$key] == 'payment') { - $bookkeeping->code_tiers = $tabcompany[$key]['code_compta']; + $bookkeeping->subledger_account = $tabcompany[$key]['code_compta']; $sqlmid = 'SELECT fac.facnumber'; $sqlmid .= " FROM " . MAIN_DB_PREFIX . "facture fac"; @@ -378,7 +378,7 @@ if (! $error && $action == 'writebookkeeping') { $bookkeeping->doc_ref = $objmid->facnumber; // Ref of invoice } } else if ($tabtype[$key] == 'payment_supplier') { - $bookkeeping->code_tiers = $tabcompany[$key]['code_compta']; + $bookkeeping->subledger_account = $tabcompany[$key]['code_compta']; $sqlmid = 'SELECT facf.ref_supplier, facf.ref'; $sqlmid .= " FROM " . MAIN_DB_PREFIX . "facture_fourn facf"; @@ -392,7 +392,7 @@ if (! $error && $action == 'writebookkeeping') { $bookkeeping->doc_ref = $objmid->ref_supplier . ' (' . $objmid->ref . ')'; // Ref on invoice } } else if ($tabtype[$key] == 'payment_expensereport') { - $bookkeeping->code_tiers = $tabuser[$key]['accountancy_code']; + $bookkeeping->subledger_account = $tabuser[$key]['accountancy_code']; $sqlmid = 'SELECT e.ref'; $sqlmid .= " FROM " . MAIN_DB_PREFIX . "expensereport as e"; @@ -405,13 +405,13 @@ if (! $error && $action == 'writebookkeeping') { $bookkeeping->doc_ref = $objmid->ref; // Ref of expensereport } } else if ($tabtype[$key] == 'payment_vat') { - $bookkeeping->code_tiers = ''; + $bookkeeping->subledger_account = ''; $bookkeeping->doc_ref = $langs->trans("PaymentVat") . ' (' . $val["paymentvatid"] . ')'; // Rowid of vat payment } else if ($tabtype[$key] == 'payment_donation') { - $bookkeeping->code_tiers = ''; + $bookkeeping->subledger_account = ''; $bookkeeping->doc_ref = $langs->trans("Donation") . ' (' . $val["paymentdonationid"] . ')'; // Rowid of donation } else if ($tabtype[$key] == 'payment_salary') { - $bookkeeping->code_tiers = ''; + $bookkeeping->subledger_account = ''; $bookkeeping->label_compte = $tabuser[$key]['name']; $bookkeeping->doc_ref = $langs->trans("SalaryPayment") . ' (' . $val["paymentsalid"] . ')'; // Ref of salary payment } @@ -458,7 +458,7 @@ if (! $error && $action == 'writebookkeeping') { $bookkeeping->date_create = $now; if (in_array($tabtype[$key], array('sc', 'payment_sc'))) { // If payment is payment of social contribution - $bookkeeping->code_tiers = ''; + $bookkeeping->subledger_account = ''; $bookkeeping->numero_compte = $k; } else if ($tabtype[$key] == 'payment') { // If payment is payment of customer invoice, we get ref of invoice $sqlmid = 'SELECT fac.facnumber'; @@ -472,7 +472,7 @@ if (! $error && $action == 'writebookkeeping') { $objmid = $db->fetch_object($resultmid); $bookkeeping->doc_ref = $objmid->facnumber; } - $bookkeeping->code_tiers = $tabcompany[$key]['code_compta']; + $bookkeeping->subledger_account = $tabcompany[$key]['code_compta']; $bookkeeping->numero_compte = $k; } else if ($tabtype[$key] == 'payment_supplier') { // If payment is payment of supplier invoice, we get ref of invoice $sqlmid = 'SELECT facf.ref_supplier,facf.ref'; @@ -486,23 +486,23 @@ if (! $error && $action == 'writebookkeeping') { $objmid = $db->fetch_object($resultmid); $bookkeeping->doc_ref = $objmid->ref_supplier . ' (' . $objmid->ref . ')'; } - $bookkeeping->code_tiers = $tabcompany[$key]['code_compta']; + $bookkeeping->subledger_account = $tabcompany[$key]['code_compta']; $bookkeeping->numero_compte = $k; } else if ($tabtype[$key] == 'payment_vat') { - $bookkeeping->code_tiers = ''; + $bookkeeping->subledger_account = ''; $bookkeeping->numero_compte = $k; $bookkeeping->doc_ref = $langs->trans("PaymentVat") . ' (' . $val["paymentvatid"] . ')'; // Rowid of vat } else if ($tabtype[$key] == 'payment_donation') { - $bookkeeping->code_tiers = ''; + $bookkeeping->subledger_account = ''; $bookkeeping->numero_compte = $k; $bookkeeping->doc_ref = $langs->trans("Donation") . ' (' . $val["paymentdonationid"] . ')'; // Rowid of donation } else if ($tabtype[$key] == 'payment_salary') { - $bookkeeping->code_tiers = $tabuser[$key]['accountancy_code']; + $bookkeeping->subledger_account = $tabuser[$key]['accountancy_code']; $bookkeeping->numero_compte = $conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT; $bookkeeping->label_compte = $tabuser[$key]['name']; $bookkeeping->doc_ref = $langs->trans("SalaryPayment") . ' (' . $val["paymentsalid"] . ')'; // Rowid of salary payment } else if ($tabtype[$key] == 'banktransfert') { - $bookkeeping->code_tiers = ''; + $bookkeeping->subledger_account = ''; $bookkeeping->numero_compte = $k; } else { // FIXME Should be a temporary account ??? @@ -758,7 +758,7 @@ if (empty($action) || $action == 'view') { print ''; }*/ - print '
'; + print '
'; print ''; print '
'; diff --git a/htdocs/accountancy/journal/expensereportsjournal.php b/htdocs/accountancy/journal/expensereportsjournal.php index 557218a0ee6..759dca8dae9 100644 --- a/htdocs/accountancy/journal/expensereportsjournal.php +++ b/htdocs/accountancy/journal/expensereportsjournal.php @@ -62,7 +62,7 @@ if ($user->societe_id > 0) /* * Actions */ - + // Get informations of journal $accountingjournalstatic = new AccountingJournal($db); $accountingjournalstatic->fetch($id_journal); @@ -175,7 +175,8 @@ if ($action == 'writebookkeeping') { $bookkeeping->doc_type = 'expense_report'; $bookkeeping->fk_doc = $key; $bookkeeping->fk_docdet = $val["fk_expensereportdet"]; - $bookkeeping->code_tiers = $tabuser[$key]['user_accountancy_code']; + $bookkeeping->subledger_account = $tabuser[$key]['user_accountancy_code']; + $bookkeeping->subledger_label = $tabuser[$key]['user_accountancy_code']; $bookkeeping->label_compte = $tabuser[$key]['name']; $bookkeeping->numero_compte = $conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT; $bookkeeping->montant = $mt; @@ -222,7 +223,8 @@ if ($action == 'writebookkeeping') { $bookkeeping->doc_type = 'expense_report'; $bookkeeping->fk_doc = $key; $bookkeeping->fk_docdet = $val["fk_expensereportdet"]; - $bookkeeping->code_tiers = ''; + $bookkeeping->subledger_account = ''; + $bookkeeping->subledger_label = ''; $bookkeeping->label_compte = $accountingaccount->label; $bookkeeping->numero_compte = $k; $bookkeeping->montant = $mt; @@ -267,7 +269,8 @@ if ($action == 'writebookkeeping') { $bookkeeping->doc_type = 'expense_report'; $bookkeeping->fk_doc = $key; $bookkeeping->fk_docdet = $val["fk_expensereportdet"]; - $bookkeeping->code_tiers = ''; + $bookkeeping->subledger_account = ''; + $bookkeeping->subledger_label = ''; $bookkeeping->label_compte = $langs->trans("VAT"). ' '.$def_tva[$key]; $bookkeeping->numero_compte = $k; $bookkeeping->montant = $mt; @@ -462,7 +465,7 @@ if (empty($action) || $action == 'view') { print ''; }*/ - print '
'; + print '
'; print ''; print '
'; @@ -576,7 +579,7 @@ if (empty($action) || $action == 'view') { } else print $accountoshow; print ""; - print "
"; + print ""; print '"; print '"; print ""; diff --git a/htdocs/accountancy/journal/purchasesjournal.php b/htdocs/accountancy/journal/purchasesjournal.php index 3729860d29d..506c5517821 100644 --- a/htdocs/accountancy/journal/purchasesjournal.php +++ b/htdocs/accountancy/journal/purchasesjournal.php @@ -131,7 +131,7 @@ if ($result) { // contrôles $compta_soc = (! empty($obj->code_compta_fournisseur)) ? $obj->code_compta_fournisseur : $cptfour; - + $compta_prod = $obj->compte; if (empty($compta_prod)) { if ($obj->product_type == 0) @@ -214,9 +214,10 @@ if ($action == 'writebookkeeping') { $bookkeeping->doc_type = 'supplier_invoice'; $bookkeeping->fk_doc = $key; $bookkeeping->fk_docdet = 0; // Useless, can be several lines that are source of this record to add - $bookkeeping->code_tiers = $tabcompany[$key]['code_fournisseur']; - $bookkeeping->label_compte = dol_trunc($companystatic->name, 16) . ' - ' . $invoicestatic->refsupplier . ' - ' . $langs->trans("Code_tiers"); - $bookkeeping->numero_compte = $tabcompany[$key]['code_compta_fournisseur']; + $bookkeeping->thirdparty_code = $tabcompany[$key]['code_fournisseur']; + $bookkeeping->subledger_account = $tabcompany[$key]['code_compta_fournisseur']; + $bookkeeping->label_compte = dol_trunc($companystatic->name, 16) . ' - ' . $invoicestatic->refsupplier . ' - ' . $langs->trans("subledger_account"); + $bookkeeping->numero_compte = $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER; $bookkeeping->montant = $mt; $bookkeeping->sens = ($mt >= 0) ? 'C' : 'D'; $bookkeeping->debit = ($mt <= 0) ? $mt : 0; @@ -261,7 +262,8 @@ if ($action == 'writebookkeeping') { $bookkeeping->doc_type = 'supplier_invoice'; $bookkeeping->fk_doc = $key; $bookkeeping->fk_docdet = 0; // Useless, can be several lines that are source of this record to add - $bookkeeping->code_tiers = ''; + $bookkeeping->subledger_account = ''; + $bookkeeping->subledger_label = ''; $bookkeeping->label_compte = dol_trunc($companystatic->name, 16) . ' - ' . $invoicestatic->refsupplier . ' - ' . $accountingaccount->label; $bookkeeping->numero_compte = $k; $bookkeeping->montant = $mt; @@ -306,7 +308,8 @@ if ($action == 'writebookkeeping') { $bookkeeping->doc_type = 'supplier_invoice'; $bookkeeping->fk_doc = $key; $bookkeeping->fk_docdet = 0; // Useless, can be several lines that are source of this record to add - $bookkeeping->code_tiers = ''; + $bookkeeping->subledger_account = ''; + $bookkeeping->subledger_label = ''; $bookkeeping->label_compte = dol_trunc($companystatic->name, 16) . ' - ' . $invoicestatic->refsupplier . ' - ' . $langs->trans("VAT"). ' '.$def_tva[$key]; $bookkeeping->numero_compte = $k; $bookkeeping->montant = $mt; @@ -479,7 +482,7 @@ $companystatic = new Fournisseur($db); print '"' . $date . '"' . $sep; print '"' . $val["ref"] . '"' . $sep; print '"' . length_accounta(html_entity_decode($k)) . '"' . $sep; - print '"' . dol_trunc($companystatic->name, 16) . ' - ' . $val["refsuppliersologest"] . ' - ' . $langs->trans("Code_tiers") . '"' . $sep; + print '"' . dol_trunc($companystatic->name, 16) . ' - ' . $val["refsuppliersologest"] . ' - ' . $langs->trans("subledger_account") . '"' . $sep; print '"' . ($mt < 0 ? price(- $mt) : '') . '"' . $sep; print '"' . ($mt >= 0 ? price($mt) : '') . '"'; } @@ -518,7 +521,7 @@ if (empty($action) || $action == 'view') { print ''; }*/ - print '
'; + print '
'; print ''; print '
'; @@ -635,7 +638,7 @@ if (empty($action) || $action == 'view') { } else print $accountoshow; print ""; - print "
"; + print ""; // print ""; diff --git a/htdocs/accountancy/journal/sellsjournal.php b/htdocs/accountancy/journal/sellsjournal.php index 0d2e7ac19cc..8506b2a480b 100644 --- a/htdocs/accountancy/journal/sellsjournal.php +++ b/htdocs/accountancy/journal/sellsjournal.php @@ -231,10 +231,10 @@ if ($action == 'writebookkeeping') { $bookkeeping->doc_type = 'customer_invoice'; $bookkeeping->fk_doc = $key; $bookkeeping->fk_docdet = 0; // Useless, can be several lines that are source of this record to add - $bookkeeping->code_tiers = $tabcompany[$key]['code_client']; - $bookkeeping->numero_compte = $tabcompany[$key]['code_compta']; - // $bookkeeping->label_compte = $tabcompany[$key]['name']; - $bookkeeping->label_compte = dol_trunc($companystatic->name, 16) . ' - ' . $invoicestatic->ref . ' - ' . $langs->trans("Code_tiers"); + $bookkeeping->thirdparty_code = $tabcompany[$key]['code_client']; + $bookkeeping->subledger_account = $tabcompany[$key]['code_compta']; + $bookkeeping->numero_compte = $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER; + $bookkeeping->label_compte = dol_trunc($companystatic->name, 16) . ' - ' . $invoicestatic->ref . ' - ' . $langs->trans("subledger_account"); $bookkeeping->montant = $mt; $bookkeeping->sens = ($mt >= 0) ? 'D' : 'C'; $bookkeeping->debit = ($mt >= 0) ? $mt : 0; @@ -277,7 +277,8 @@ if ($action == 'writebookkeeping') { $bookkeeping->doc_type = 'customer_invoice'; $bookkeeping->fk_doc = $key; $bookkeeping->fk_docdet = 0; // Useless, can be several lines that are source of this record to add; - $bookkeeping->code_tiers = ''; + $bookkeeping->subledger_account = ''; + $bookkeeping->subledger_label = ''; $bookkeeping->numero_compte = $k; $bookkeeping->label_compte = dol_trunc($companystatic->name, 16) . ' - ' . $invoicestatic->ref . ' - ' . $accountingaccount->label; $bookkeeping->montant = $mt; @@ -321,7 +322,8 @@ if ($action == 'writebookkeeping') { $bookkeeping->doc_type = 'customer_invoice'; $bookkeeping->fk_doc = $key; $bookkeeping->fk_docdet = 0; // Useless, can be several lines that are source of this record to add - $bookkeeping->code_tiers = ''; + $bookkeeping->subledger_account = ''; + $bookkeeping->subledger_label = ''; $bookkeeping->numero_compte = $k; $bookkeeping->label_compte = dol_trunc($companystatic->name, 16) . ' - ' . $invoicestatic->ref . ' - ' . $langs->trans("VAT").' '.$def_tva[$key]; $bookkeeping->montant = $mt; @@ -373,7 +375,7 @@ if ($action == 'writebookkeeping') { { setEventMessages($langs->trans("GeneralLedgerSomeRecordWasNotRecorded"), null, 'warnings'); } - + $action=''; } @@ -416,7 +418,7 @@ $form = new Form($db); print length_accounta(html_entity_decode($k)) . $sep; print ($mt < 0 ? 'C' : 'D') . $sep; print ($mt <= 0 ? price(- $mt) : $mt) . $sep; - print dol_trunc($companystatic->name, 16) . ' - ' . $invoicestatic->ref . ' - ' . $langs->trans("Code_tiers") . $sep; + print dol_trunc($companystatic->name, 16) . ' - ' . $invoicestatic->ref . ' - ' . $langs->trans("subledger_account") . $sep; print $val["ref"]; print "\n"; } @@ -469,7 +471,7 @@ $form = new Form($db); print '"' . $date . '"' . $sep; print '"' . $val["ref"] . '"' . $sep; print '"' . length_accounta(html_entity_decode($k)) . '"' . $sep; - print '"' . dol_trunc($companystatic->name, 16) . ' - ' . $invoicestatic->ref . ' - ' . $langs->trans("Code_tiers") . '"' . $sep; + print '"' . dol_trunc($companystatic->name, 16) . ' - ' . $invoicestatic->ref . ' - ' . $langs->trans("subledger_account") . '"' . $sep; print '"' . ($mt >= 0 ? price($mt) : '') . '"' . $sep; print '"' . ($mt < 0 ? price(- $mt) : '') . '"'; print "\n"; @@ -535,7 +537,7 @@ if (empty($action) || $action == 'view') { } else { print ''; }*/ - print '
'; + print '
'; print ''; print '
'; @@ -602,7 +604,7 @@ if (empty($action) || $action == 'view') { // print "
'; - print ""; + print ""; print ""; print ""; print ""; diff --git a/htdocs/core/modules/modAccounting.class.php b/htdocs/core/modules/modAccounting.class.php index 1780da06456..af0874b8c30 100644 --- a/htdocs/core/modules/modAccounting.class.php +++ b/htdocs/core/modules/modAccounting.class.php @@ -224,7 +224,7 @@ class modAccounting extends DolibarrModules $this->rights[$r][4] = 'chartofaccount'; $this->rights[$r][5] = ''; $r++; - + $this->rights[$r][0] = 50401; $this->rights[$r][1] = 'Bind products and invoices with accounting accounts'; $this->rights[$r][2] = 'r'; @@ -242,9 +242,9 @@ class modAccounting extends DolibarrModules $this->rights[$r][5] = 'dispatch_advanced'; $r++; */ - + $this->rights[$r][0] = 50411; - $this->rights[$r][1] = 'Read operations in General Ledger'; + $this->rights[$r][1] = 'Read operations in Ledger'; $this->rights[$r][2] = 'r'; $this->rights[$r][3] = 0; $this->rights[$r][4] = 'mouvements'; @@ -252,7 +252,7 @@ class modAccounting extends DolibarrModules $r++; $this->rights[$r][0] = 50412; - $this->rights[$r][1] = 'Write/Edit operations in General Ledger'; + $this->rights[$r][1] = 'Write/Edit operations in Ledger'; $this->rights[$r][2] = 'w'; $this->rights[$r][3] = 0; $this->rights[$r][4] = 'mouvements'; @@ -260,7 +260,7 @@ class modAccounting extends DolibarrModules $r++; $this->rights[$r][0] = 50420; - $this->rights[$r][1] = 'Report and export reports (turnover, balance, journals, general ledger)'; + $this->rights[$r][1] = 'Report and export reports (turnover, balance, journals, ledger)'; $this->rights[$r][2] = 'r'; $this->rights[$r][3] = 0; $this->rights[$r][4] = 'comptarapport'; @@ -279,7 +279,7 @@ class modAccounting extends DolibarrModules // Menus //------- $this->menu = 1; // This module add menu entries. They are coded into menu manager. - + // Exports //-------- $r=0; diff --git a/htdocs/install/mysql/migration/5.0.0-6.0.0.sql b/htdocs/install/mysql/migration/5.0.0-6.0.0.sql index 46e3b698100..e5ee1866567 100644 --- a/htdocs/install/mysql/migration/5.0.0-6.0.0.sql +++ b/htdocs/install/mysql/migration/5.0.0-6.0.0.sql @@ -187,6 +187,7 @@ UPDATE llx_bank_account as ba set fk_accountancy_journal = (SELECT rowid FROM ll ALTER TABLE llx_bank_account ADD CONSTRAINT fk_bank_account_accountancy_journal FOREIGN KEY (fk_accountancy_journal) REFERENCES llx_accounting_journal (rowid); --Update general ledger for FEC format & harmonization + ALTER TABLE llx_accounting_bookkeeping MODIFY COLUMN code_tiers varchar(32); ALTER TABLE llx_accounting_bookkeeping CHANGE COLUMN code_tiers thirdparty_code varchar(32); diff --git a/htdocs/langs/en_US/accountancy.lang b/htdocs/langs/en_US/accountancy.lang index 5f3d4eef2da..8ff65371fa5 100644 --- a/htdocs/langs/en_US/accountancy.lang +++ b/htdocs/langs/en_US/accountancy.lang @@ -49,8 +49,8 @@ AccountancyAreaDescLoan=STEP %s: Define default accounting accounts for loans. F AccountancyAreaDescBank=STEP %s: Define accounting accounts for each bank and financial accounts. For this, go on the card of each financial account. You can start from page %s. AccountancyAreaDescProd=STEP %s: Define accounting accounts on your products/services. For this, use the menu entry %s. -AccountancyAreaDescBind=STEP %s: Check the binding between existing %s lines and accounting account is done, so application will be able to journalize transactions in General Ledger in one click. Complete missing bindings. For this, use the menu entry %s. -AccountancyAreaDescWriteRecords=STEP %s: Write transactions into the General Ledger. For this, go into menu %s, and click into button %s. +AccountancyAreaDescBind=STEP %s: Check the binding between existing %s lines and accounting account is done, so application will be able to journalize transactions in Ledger in one click. Complete missing bindings. For this, use the menu entry %s. +AccountancyAreaDescWriteRecords=STEP %s: Write transactions into the Ledger. For this, go into menu %s, and click into button %s. AccountancyAreaDescAnalyze=STEP %s: Add or edit existing transactions and generate reports and exports. AccountancyAreaDescClosePeriod=STEP %s: Close period so we can't make modification in a future. @@ -61,6 +61,8 @@ ChangeAndLoad=Change and load Addanaccount=Add an accounting account AccountAccounting=Accounting account AccountAccountingShort=Account +SubledgerAccount=Subledger Account +subledger_account=Subledger Account ShowAccountingAccount=Show accounting account ShowAccountingJournal=Show accounting journal AccountAccountingSuggest=Accounting account suggested @@ -77,8 +79,8 @@ SuppliersVentilation=Supplier invoice binding ExpenseReportsVentilation=Expense report binding CreateMvts=Create new transaction UpdateMvts=Modification of a transaction -WriteBookKeeping=Journalize transactions in General Ledger -Bookkeeping=General ledger +WriteBookKeeping=Journalize transactions in Ledger +Bookkeeping=Ledger AccountBalance=Account balance CAHTF=Total purchase supplier before tax @@ -141,16 +143,16 @@ TransactionNumShort=Num. transaction AccountingCategory=Accounting account groups GroupByAccountAccounting=Group by accounting account NotMatch=Not Set -DeleteMvt=Delete general ledger lines +DeleteMvt=Delete Ledger lines DelYear=Year to delete DelJournal=Journal to delete -ConfirmDeleteMvt=This will delete all lines of the general ledger for year and/or from a specific journal. At least one criteria is required. -ConfirmDeleteMvtPartial=This will delete the selected line(s) of the general ledger -DelBookKeeping=Delete record of the general ledger +ConfirmDeleteMvt=This will delete all lines of the Ledger for year and/or from a specific journal. At least one criteria is required. +ConfirmDeleteMvtPartial=This will delete the selected line(s) of the Ledger +DelBookKeeping=Delete record of the Ledger FinanceJournal=Finance journal ExpenseReportsJournal=Expense reports journal DescFinanceJournal=Finance journal including all the types of payments by bank account -DescJournalOnlyBindedVisible=This is a view of record that are bound to products/services accountancy account and can be recorded into the General Ledger. +DescJournalOnlyBindedVisible=This is a view of record that are bound to products/services accountancy account and can be recorded into the Ledger. VATAccountNotDefined=Account for VAT not defined ThirdpartyAccountNotDefined=Account for third party not defined ProductAccountNotDefined=Account for product not defined @@ -192,7 +194,7 @@ AutomaticBindingDone=Automatic binding done ErrorAccountancyCodeIsAlreadyUse=Error, you cannot delete this accounting account because it is used MvtNotCorrectlyBalanced=Mouvement not correctly balanced. Credit = %s. Debit = %s FicheVentilation=Binding card -GeneralLedgerIsWritten=Transactions are written in the general ledger +GeneralLedgerIsWritten=Transactions are written in the Ledger GeneralLedgerSomeRecordWasNotRecorded=Some of the transactions could not be dispatched. If there is no other error message, this is probably because they were already dispatched. NoNewRecordSaved=No new record dispatched ListOfProductsWithoutAccountingAccount=List of products not bound to any accounting account @@ -261,4 +263,4 @@ NoJournalDefined=No journal defined Binded=Lines bound ToBind=Lines to bind -WarningReportNotReliable=Warning, this report is not based on the General Ledger, so does not contains transaction modified manualy in the General ledger. It will be replaced by a more complete report in a next version. +WarningReportNotReliable=Warning, this report is not based on the Ledger, so does not contains transaction modified manualy in the Ledger. It will be replaced by a more complete report in a next version. diff --git a/htdocs/langs/en_US/compta.lang b/htdocs/langs/en_US/compta.lang index c85a2671c21..6f8a1b5e301 100644 --- a/htdocs/langs/en_US/compta.lang +++ b/htdocs/langs/en_US/compta.lang @@ -190,8 +190,10 @@ AccountancyJournal=Accountancy code journal ACCOUNTING_VAT_SOLD_ACCOUNT=Accounting account by default for collecting VAT - VAT on sales (used if not defined on VAT dictionary setup) ACCOUNTING_VAT_BUY_ACCOUNT=Accounting account by default for recovered VAT - VAT on purchases (used if not defined on VAT dictionary setup) ACCOUNTING_VAT_PAY_ACCOUNT=Accounting account by default for paying VAT -ACCOUNTING_ACCOUNT_CUSTOMER=Accounting account by default for customer third parties (used if not defined on third party card) -ACCOUNTING_ACCOUNT_SUPPLIER=Accounting account by default for supplier third parties (used if not defined on third party card) +ACCOUNTING_ACCOUNT_CUSTOMER=Accounting account used for customer third parties +ACCOUNTING_ACCOUNT_CUSTOMER_Desc=Dedicated accounting account defined on third party card will be used for Subledger accouting, this one for General Ledger or as default value of Subledger accounting if dedicated customer accouting account on third party is not defined +ACCOUNTING_ACCOUNT_SUPPLIER=Accounting account used for supplier third parties +ACCOUNTING_ACCOUNT_SUPPLIER_Desc=Dedicated accounting account defined on third party card will be used for Subledger accouting, this one for General Ledger or as default value of Subledger accounting if dedicated supplier accouting account on third party is not defined CloneTax=Clone a social/fiscal tax ConfirmCloneTax=Confirm the clone of a social/fiscal tax payment CloneTaxForNextMonth=Clone it for next month From f39fb5187a4f490378d672a88794f254af27c055 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 15 Jun 2017 20:27:40 +0200 Subject: [PATCH 013/227] Fix component to select journal --- htdocs/accountancy/bookkeeping/card.php | 2 +- htdocs/accountancy/bookkeeping/list.php | 6 +++--- htdocs/compta/bank/card.php | 4 ++-- htdocs/core/class/html.formaccounting.class.php | 17 +++++++---------- 4 files changed, 13 insertions(+), 16 deletions(-) diff --git a/htdocs/accountancy/bookkeeping/card.php b/htdocs/accountancy/bookkeeping/card.php index 3ef418e2e20..f40bfda856f 100644 --- a/htdocs/accountancy/bookkeeping/card.php +++ b/htdocs/accountancy/bookkeeping/card.php @@ -256,7 +256,7 @@ if ($action == 'create') { print ''; print ''; print ''; print ''; diff --git a/htdocs/accountancy/bookkeeping/list.php b/htdocs/accountancy/bookkeeping/list.php index b6685248ca7..cd93b1142f8 100644 --- a/htdocs/accountancy/bookkeeping/list.php +++ b/htdocs/accountancy/bookkeeping/list.php @@ -322,7 +322,7 @@ if ($action == 'delbookkeepingyear') { $delyear = dol_print_date(dol_now(), '%Y'); } $year_array = $formaccounting->selectyear_accountancy_bookkepping($delyear, 'delyear', 0, 'array'); - $journal_array = $formaccounting->selectjournal($deljournal, 'deljournal', '', 1, 'array', 1, 1); + $journal_array = $formaccounting->select_journal($deljournal, 'deljournal', '', 1, 1, 1, '', 0, 1); $form_question['delyear'] = array ( 'name' => 'delyear', @@ -333,9 +333,9 @@ if ($action == 'delbookkeepingyear') { ); $form_question['deljournal'] = array ( 'name' => 'deljournal', - 'type' => 'select', + 'type' => 'other', // We don't use select here, the journal_array is already a select html component 'label' => $langs->trans('DelJournal'), - 'values' => $journal_array, + 'value' => $journal_array, 'default' => $deljournal ); diff --git a/htdocs/compta/bank/card.php b/htdocs/compta/bank/card.php index 06918ff2846..1f55698d13f 100644 --- a/htdocs/compta/bank/card.php +++ b/htdocs/compta/bank/card.php @@ -524,7 +524,7 @@ if ($action == 'create') { print ''; print ''; } @@ -982,7 +982,7 @@ else { print ''; print ''; } diff --git a/htdocs/core/class/html.formaccounting.class.php b/htdocs/core/class/html.formaccounting.class.php index 2d444c1aefe..e37e1690ca2 100644 --- a/htdocs/core/class/html.formaccounting.class.php +++ b/htdocs/core/class/html.formaccounting.class.php @@ -54,15 +54,14 @@ class FormAccounting extends Form * @param string $htmlname Name of field in html form * @param int $nature Limit the list to a particular type of journals (1:various operations / 2:sale / 3:purchase / 4:bank / 9: has-new) * @param int $showempty Add an empty field - * @param array $event Event options * @param int $select_in 0=selectid value is the journal rowid (default) or 1=selectid is journal code * @param int $select_out Set value returned by select. 0=rowid (default), 1=code * @param string $morecss More css non HTML object * @param string $usecache Key to use to store result into a cache. Next call with same key will reuse the cache. - * + * @param int $disabledajaxcombo Disable ajax combo box. * @return string String with HTML select */ - function select_journal($selectid, $htmlname = 'journal', $nature=0, $showempty = 0, $event = array(), $select_in = 0, $select_out = 0, $morecss='maxwidth300 maxwidthonsmartphone', $usecache='') + function select_journal($selectid, $htmlname = 'journal', $nature=0, $showempty = 0, $select_in = 0, $select_out = 0, $morecss='maxwidth300 maxwidthonsmartphone', $usecache='', $disabledajaxcombo=0) { global $conf; @@ -92,8 +91,6 @@ class FormAccounting extends Form return -1; } - $out = ajax_combobox($htmlname, $event); - $selected = 0; while ($obj = $this->db->fetch_object($resql)) { @@ -125,7 +122,7 @@ class FormAccounting extends Form } } - $out .= Form::selectarray($htmlname, $options, $selected, $showempty, 0, 0, '', 0, 0, 0, '', $morecss, 1); + $out .= Form::selectarray($htmlname, $options, $selected, $showempty, 0, 0, '', 0, 0, 0, '', $morecss, ($disabledajaxcombo?0:1)); return $out; } @@ -204,9 +201,9 @@ class FormAccounting extends Form { dol_print_error($db,$db->lasterror()); } - - $out .= ajax_combobox($htmlname, $event); - + + $out .= ajax_combobox($htmlname, array()); + print $out; } @@ -260,7 +257,7 @@ class FormAccounting extends Form require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php'; $out = ''; - + $options = array(); if ($usecache && ! empty($this->options_cache[$usecache])) { From 78d5520741746af4874f0a628d48996a83e95094 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Thu, 15 Jun 2017 21:23:35 +0200 Subject: [PATCH 014/227] Fix: missing _cleanObjectDatas function --- htdocs/admin/agenda.php | 3 +- htdocs/admin/agenda_other.php | 1 + .../action/class/api_agendaevents.class.php | 58 +++++++++++++++++++ 3 files changed, 61 insertions(+), 1 deletion(-) diff --git a/htdocs/admin/agenda.php b/htdocs/admin/agenda.php index 22679ca697b..a30ebad4703 100644 --- a/htdocs/admin/agenda.php +++ b/htdocs/admin/agenda.php @@ -33,6 +33,7 @@ if (!$user->admin) $langs->load("admin"); $langs->load("other"); +$langs->load("agenda"); $action = GETPOST('action','alpha'); $cancel = GETPOST('cancel','alpha'); @@ -172,7 +173,7 @@ if (! empty($triggers)) if ($trigger['code'] == 'FICHINTER_CLASSIFY_BILLED' && empty($conf->global->FICHINTER_CLASSIFY_BILLED)) continue; if ($trigger['code'] == 'FICHINTER_CLASSIFY_UNBILLED' && empty($conf->global->FICHINTER_CLASSIFY_BILLED)) continue; - + print ''; print ''; print ''; diff --git a/htdocs/admin/agenda_other.php b/htdocs/admin/agenda_other.php index 44ec3ade889..31bcf1077e6 100644 --- a/htdocs/admin/agenda_other.php +++ b/htdocs/admin/agenda_other.php @@ -36,6 +36,7 @@ if (!$user->admin) $langs->load("admin"); $langs->load("other"); +$langs->load("agenda"); $action = GETPOST('action','alpha'); $value = GETPOST('value','alpha'); diff --git a/htdocs/comm/action/class/api_agendaevents.class.php b/htdocs/comm/action/class/api_agendaevents.class.php index f32c721a826..40737a83799 100644 --- a/htdocs/comm/action/class/api_agendaevents.class.php +++ b/htdocs/comm/action/class/api_agendaevents.class.php @@ -111,8 +111,11 @@ class AgendaEvents extends DolibarrApi if (! DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) $search_sale = DolibarrApiAccess::$user->id; $sql = "SELECT t.id as rowid"; + if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) $sql .= ", sc.fk_soc, sc.fk_user"; // We need these fields in order to filter by sale (including the case where the user can only see his prospects) $sql.= " FROM ".MAIN_DB_PREFIX."actioncomm as t"; + if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; // We need this table joined to the select in order to filter by sale $sql.= ' WHERE t.entity IN ('.getEntity('agenda').')'; + if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) $sql.= " AND t.fk_soc = sc.fk_soc"; if ($user_ids) $sql.=" AND t.fk_user_action IN (".$user_ids.")"; if ($socid > 0) $sql.= " AND t.fk_soc = ".$socid; // Insert sale filter @@ -298,4 +301,59 @@ class AgendaEvents extends DolibarrApi } return $event; } + + /** + * Clean sensible object datas + * + * @param object $object Object to clean + * @return array Array of cleaned object properties + */ + function _cleanObjectDatas($object) { + + $object = parent::_cleanObjectDatas($object); + + unset($object->import_key); + unset($object->array_options); + unset($object->linkedObjectsIds); + unset($object->context); + unset($object->canvas); + unset($object->fk_project); + unset($object->contact); + unset($object->contact_id); + unset($object->thirdparty); + unset($object->user); + unset($object->origin); + unset($object->origin_id); + unset($object->ref_ext); + unset($object->statut); + unset($object->country); + unset($object->country_id); + unset($object->country_code); + unset($object->barcode_type); + unset($object->barcode_type_code); + unset($object->barcode_type_label); + unset($object->barcode_type_coder); + unset($object->mode_reglement_id); + unset($object->cond_reglement_id); + unset($object->cond_reglement); + unset($object->fk_delivery_address); + unset($object->shipping_method_id); + unset($object->fk_account); + unset($object->total_ht); + unset($object->total_tva); + unset($object->total_localtax1); + unset($object->total_localtax2); + unset($object->total_ttc); + unset($object->fk_incoterms); + unset($object->libelle_incoterms); + unset($object->location_incoterms); + unset($object->name); + unset($object->lastname); + unset($object->firstname); + unset($object->civility_id); + unset($object->contact); + unset($object->societe); + + return $object; + } } From 8b7ca1f280e5b6f1465caddd1cd4d9c12adf920f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 15 Jun 2017 21:27:20 +0200 Subject: [PATCH 015/227] Fix missing vat_src_code into table of expense report --- htdocs/install/mysql/migration/5.0.0-6.0.0.sql | 3 +++ htdocs/install/mysql/tables/llx_expensereport_det.sql | 1 + 2 files changed, 4 insertions(+) diff --git a/htdocs/install/mysql/migration/5.0.0-6.0.0.sql b/htdocs/install/mysql/migration/5.0.0-6.0.0.sql index e5ee1866567..a66ef47fba6 100644 --- a/htdocs/install/mysql/migration/5.0.0-6.0.0.sql +++ b/htdocs/install/mysql/migration/5.0.0-6.0.0.sql @@ -90,6 +90,8 @@ ALTER TABLE llx_expedition ADD COLUMN fk_projet integer DEFAULT NULL after fk_so ALTER TABLE llx_expensereport ADD COLUMN import_key varchar(14); ALTER TABLE llx_expensereport ADD COLUMN extraparams varchar(255); + + ALTER TABLE llx_bank_account ADD COLUMN extraparams varchar(255); insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('PRODUCT_CREATE','Product or service created','Executed when a product or sevice is created','product',30); @@ -230,6 +232,7 @@ ALTER TABLE llx_societe_remise_except ADD CONSTRAINT fk_societe_remise_fk_invoic ALTER TABLE llx_societe_remise_except ADD CONSTRAINT fk_societe_remise_fk_invoice_supplier_source FOREIGN KEY (fk_invoice_supplier) REFERENCES llx_facture_fourn (rowid); ALTER TABLE llx_facture_rec ADD COLUMN vat_src_code varchar(10) DEFAULT ''; +ALTER TABLE llx_expensereport_det ADD COLUMN vat_src_code varchar(10) DEFAULT ''; DELETE FROM llx_const WHERE name = __ENCRYPT('ADHERENT_BANK_USE_AUTO')__; diff --git a/htdocs/install/mysql/tables/llx_expensereport_det.sql b/htdocs/install/mysql/tables/llx_expensereport_det.sql index 069cd534e4f..8d01f29de68 100644 --- a/htdocs/install/mysql/tables/llx_expensereport_det.sql +++ b/htdocs/install/mysql/tables/llx_expensereport_det.sql @@ -27,6 +27,7 @@ CREATE TABLE llx_expensereport_det qty real NOT NULL, value_unit real NOT NULL, remise_percent real, + vat_src_code varchar(10) DEFAULT '', -- Vat code used as source of vat fields. Not strict foreign key here. tva_tx double(6,3), -- Vat rate localtax1_tx double(6,3) DEFAULT 0, -- localtax1 rate localtax1_type varchar(10) NULL, -- localtax1 type From 9410466d727f94f6e2b99c390f43a2e4a4bc8e00 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Thu, 15 Jun 2017 21:51:31 +0200 Subject: [PATCH 016/227] Fix: better check and security --- .../action/class/api_agendaevents.class.php | 31 ++++++++++--------- htdocs/core/lib/security.lib.php | 4 +-- htdocs/societe/class/api_contacts.class.php | 10 +++--- 3 files changed, 25 insertions(+), 20 deletions(-) diff --git a/htdocs/comm/action/class/api_agendaevents.class.php b/htdocs/comm/action/class/api_agendaevents.class.php index 40737a83799..40fce1fd640 100644 --- a/htdocs/comm/action/class/api_agendaevents.class.php +++ b/htdocs/comm/action/class/api_agendaevents.class.php @@ -63,20 +63,20 @@ class AgendaEvents extends DolibarrApi */ function get($id) { - if(! DolibarrApiAccess::$user->rights->agenda->myactions->read) { + if (! DolibarrApiAccess::$user->rights->agenda->myactions->read) { throw new RestException(401, "Insuffisant rights to read an event"); } $result = $this->actioncomm->fetch($id); - if( ! $result ) { + if ( ! $result ) { throw new RestException(404, 'Agenda Events not found'); } - if(! DolibarrApiAccess::$user->rights->agenda->allactions->read && $this->actioncomm->ownerid != DolibarrApiAccess::$user->id) { + if (! DolibarrApiAccess::$user->rights->agenda->allactions->read && $this->actioncomm->ownerid != DolibarrApiAccess::$user->id) { throw new RestException(401, "Insuffisant rights to read event for owner id ".$request_data['userownerid'].' Your id is '.DolibarrApiAccess::$user->id); } - if( ! DolibarrApi::_checkAccessToResource('agenda',$this->actioncomm->id)) { + if ( ! DolibarrApi::_checkAccessToResource('agenda',$this->actioncomm->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } @@ -102,6 +102,10 @@ class AgendaEvents extends DolibarrApi $obj_ret = array(); + if (! DolibarrApiAccess::$user->rights->agenda->myactions->read) { + throw new RestException(401, "Insuffisant rights to read events"); + } + // case of external user $socid = 0; if (! empty(DolibarrApiAccess::$user->socid)) $socid = DolibarrApiAccess::$user->socid; @@ -155,7 +159,7 @@ class AgendaEvents extends DolibarrApi { $obj = $db->fetch_object($result); $actioncomm_static = new ActionComm($db); - if($actioncomm_static->fetch($obj->rowid)) { + if ($actioncomm_static->fetch($obj->rowid)) { $obj_ret[] = $this->_cleanObjectDatas($actioncomm_static); } $i++; @@ -164,7 +168,7 @@ class AgendaEvents extends DolibarrApi else { throw new RestException(503, 'Error when retrieve Agenda Event list : '.$db->lasterror()); } - if( ! count($obj_ret)) { + if ( ! count($obj_ret)) { throw new RestException(404, 'No Agenda Event found'); } return $obj_ret; @@ -178,10 +182,10 @@ class AgendaEvents extends DolibarrApi */ function post($request_data = NULL) { - if(! DolibarrApiAccess::$user->rights->agenda->myactions->create) { + if (! DolibarrApiAccess::$user->rights->agenda->myactions->create) { throw new RestException(401, "Insuffisant rights to create your Agenda Event"); } - if(! DolibarrApiAccess::$user->rights->agenda->allactions->create && DolibarrApiAccess::$user->id != $request_data['userownerid']) { + if (! DolibarrApiAccess::$user->rights->agenda->allactions->create && DolibarrApiAccess::$user->id != $request_data['userownerid']) { throw new RestException(401, "Insuffisant rights to create an Agenda Event for owner id ".$request_data['userownerid'].' Your id is '.DolibarrApiAccess::$user->id); } @@ -216,19 +220,19 @@ class AgendaEvents extends DolibarrApi */ /* function put($id, $request_data = NULL) { - if(! DolibarrApiAccess::$user->rights->agenda->myactions->create) { + if (! DolibarrApiAccess::$user->rights->agenda->myactions->create) { throw new RestException(401, "Insuffisant rights to create your Agenda Event"); } - if(! DolibarrApiAccess::$user->rights->agenda->allactions->create && DolibarrApiAccess::$user->id != $request_data['userownerid']) { + if (! DolibarrApiAccess::$user->rights->agenda->allactions->create && DolibarrApiAccess::$user->id != $request_data['userownerid']) { throw new RestException(401, "Insuffisant rights to create an Agenda Event for owner id ".$request_data['userownerid'].' Your id is '.DolibarrApiAccess::$user->id); } $result = $this->expensereport->fetch($id); - if( ! $result ) { + if ( ! $result ) { throw new RestException(404, 'expensereport not found'); } - if( ! DolibarrApi::_checkAccessToResource('expensereport',$this->expensereport->id)) { + if ( ! DolibarrApi::_checkAccessToResource('expensereport',$this->expensereport->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } foreach($request_data as $field => $value) { @@ -236,7 +240,7 @@ class AgendaEvents extends DolibarrApi $this->expensereport->$field = $value; } - if($this->expensereport->update($id, DolibarrApiAccess::$user,1,'','','update')) + if ($this->expensereport->update($id, DolibarrApiAccess::$user,1,'','','update')) return $this->get($id); return false; @@ -314,7 +318,6 @@ class AgendaEvents extends DolibarrApi unset($object->import_key); unset($object->array_options); - unset($object->linkedObjectsIds); unset($object->context); unset($object->canvas); unset($object->fk_project); diff --git a/htdocs/core/lib/security.lib.php b/htdocs/core/lib/security.lib.php index 9a9e78513c3..d3250263a6f 100644 --- a/htdocs/core/lib/security.lib.php +++ b/htdocs/core/lib/security.lib.php @@ -403,9 +403,9 @@ function checkUserAccessToObject($user, $featuresarray, $objectid=0, $tableandsh else if (in_array($feature,$checksoc)) // We check feature = checksoc { // If external user: Check permission for external users - if ($user->societe_id > 0) + if ($user->socid > 0) { - if ($user->societe_id <> $objectid) return false; + if ($user->socid <> $objectid) return false; } // If internal user: Check permission for internal users that are restricted on their objects else if (! empty($conf->societe->enabled) && ($user->rights->societe->lire && ! $user->rights->societe->client->voir)) diff --git a/htdocs/societe/class/api_contacts.class.php b/htdocs/societe/class/api_contacts.class.php index 58fe15cf282..f136d6895b2 100644 --- a/htdocs/societe/class/api_contacts.class.php +++ b/htdocs/societe/class/api_contacts.class.php @@ -43,7 +43,8 @@ class Contacts extends DolibarrApi /** * Constructor */ - function __construct() { + function __construct() + { global $db, $conf; $this->db = $db; $this->contact = new Contact($this->db); @@ -59,7 +60,8 @@ class Contacts extends DolibarrApi * * @throws RestException */ - function get($id) { + function get($id) + { if (!DolibarrApiAccess::$user->rights->societe->contact->lire) { throw new RestException(401, 'No permission to read contacts'); @@ -105,7 +107,7 @@ class Contacts extends DolibarrApi } // case of external user, $thirdparty_ids param is ignored and replaced by user's socid - $socids = DolibarrApiAccess::$user->societe_id ? DolibarrApiAccess::$user->societe_id : $thirdparty_ids; + $socids = DolibarrApiAccess::$user->socid ? DolibarrApiAccess::$user->socid : $thirdparty_ids; // If the internal user must only see his customers, force searching by him $search_sale = 0; @@ -171,7 +173,7 @@ class Contacts extends DolibarrApi } } else { - throw new RestException(503, 'Error when retreive contacts : ' . $sql); + throw new RestException(503, 'Error when retrieve contacts : ' . $sql); } if (!count($obj_ret)) { From 8149bf62a89ca60b0dfd44ec88bff6b600121ea1 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 15 Jun 2017 23:47:19 +0200 Subject: [PATCH 017/227] Fix ajaxcombo broken on accouting account edition on vat dictionary. --- htdocs/admin/dict.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/htdocs/admin/dict.php b/htdocs/admin/dict.php index c83a3aa39be..f920b04bf62 100644 --- a/htdocs/admin/dict.php +++ b/htdocs/admin/dict.php @@ -1502,9 +1502,12 @@ if ($id) } $class='tddict'; + if ($fieldlist[$field] == 'note' && $id == 10) $class.=' tdoverflowmax200'; if ($fieldlist[$field] == 'tracking') $class.=' tdoverflowauto'; if ($fieldlist[$field] == 'code') $class.=' width100'; if ($fieldlist[$field] == 'position') $class.=' right'; + if ($fieldlist[$field] == 'localtax1_type') $class.=' nowrap'; + if ($fieldlist[$field] == 'localtax2_type') $class.=' nowrap'; // Show value for field if ($showfield) print ''; } @@ -1694,7 +1697,7 @@ function fieldList($fieldlist, $obj='', $tabname='', $context='') } // For state page, we do not show the country input (we link to region, not country) print ''; } elseif ($fieldlist[$field] == 'country_id') @@ -1820,7 +1823,7 @@ function fieldList($fieldlist, $obj='', $tabname='', $context='') { $fieldname = $fieldlist[$field]; $accountancy_account = (! empty($obj->$fieldname) ? $obj->$fieldname : 0); - print $formaccounting->select_account($accountancy_account, $fieldlist[$field], 1, '', 1, 1, 'maxwidth200 maxwidthonsmartphone'); + print $formaccounting->select_account($accountancy_account, '.'.$fieldlist[$field], 1, '', 1, 1, 'maxwidth200 maxwidthonsmartphone'); } else { From ac708a8ee993457e43da17b7ddbcb1a06cd1e296 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 15 Jun 2017 23:58:56 +0200 Subject: [PATCH 018/227] Debug accounting module with new structure v6 Make accounting module compatible with the new vat code to identify 2 vat code with same rate. --- .../accountancy/class/bookkeeping.class.php | 7 +- htdocs/accountancy/journal/bankjournal.php | 10 ++- .../journal/expensereportsjournal.php | 28 ++++--- .../accountancy/journal/purchasesjournal.php | 47 ++++++++---- htdocs/accountancy/journal/sellsjournal.php | 48 +++++++----- .../core/class/html.formaccounting.class.php | 4 +- htdocs/core/lib/functions.lib.php | 73 ++++++++++++------- htdocs/langs/en_US/errors.lang | 2 + 8 files changed, 142 insertions(+), 77 deletions(-) diff --git a/htdocs/accountancy/class/bookkeeping.class.php b/htdocs/accountancy/class/bookkeeping.class.php index f7c1b4d8b89..9ed4ef29ac1 100644 --- a/htdocs/accountancy/class/bookkeeping.class.php +++ b/htdocs/accountancy/class/bookkeeping.class.php @@ -184,7 +184,8 @@ class BookKeeping extends CommonObject } else { - $this->errors[]=$langs->trans('ErrorFieldAccountNotDefinedForInvoiceLine', $this->fk_doc, $this->doc_type); + //$this->errors[]=$langs->trans('ErrorFieldAccountNotDefinedForInvoiceLine', $this->doc_ref, $this->label_compte); + $this->errors[]=$langs->trans('ErrorFieldAccountNotDefinedForLine', $this->label_compte); } return -1; @@ -451,7 +452,7 @@ class BookKeeping extends CommonObject $sql .= ' ' . (! isset($this->thirdparty_code) ? 'NULL' : "'" . $this->db->escape($this->thirdparty_code) . "'") . ','; $sql .= ' ' . (! isset($this->subledger_account) ? 'NULL' : "'" . $this->db->escape($this->subledger_account) . "'") . ','; $sql .= ' ' . (! isset($this->subledger_label) ? 'NULL' : "'" . $this->db->escape($this->subledger_label) . "'") . ','; - $sql .= ' ' . (! isset($this->numero_compte) ? "'NotDefined'" : "'" . $this->db->escape($this->numero_compte) . "'") . ','; + $sql .= ' ' . (! isset($this->numero_compte) ? "NULL" : "'" . $this->db->escape($this->numero_compte) . "'") . ','; $sql .= ' ' . (! isset($this->label_compte) ? 'NULL' : "'" . $this->db->escape($this->label_compte) . "'") . ','; $sql .= ' ' . (! isset($this->debit) ? 'NULL' : $this->debit ). ','; $sql .= ' ' . (! isset($this->credit) ? 'NULL' : $this->credit ). ','; @@ -461,7 +462,7 @@ class BookKeeping extends CommonObject $sql .= ' ' . (! isset($this->import_key) ? 'NULL' : "'" . $this->db->escape($this->import_key) . "'") . ','; $sql .= ' ' . (empty($this->code_journal) ? 'NULL' : "'" . $this->db->escape($this->code_journal) . "'") . ','; $sql .= ' ' . (empty($this->journal_label) ? 'NULL' : "'" . $this->db->escape($this->journal_label) . "'") . ','; - $sql .= ' ' . (empty($this->piece_num) ? 'NULL' : $this->piece_num).','; + $sql .= ' ' . (empty($this->piece_num) ? 'NULL' : $this->db->escape($this->piece_num)).','; $sql .= ' ' . (! isset($this->entity) ? '1' : $this->entity); $sql .= ')'; diff --git a/htdocs/accountancy/journal/bankjournal.php b/htdocs/accountancy/journal/bankjournal.php index 6c391531662..568edf051ff 100644 --- a/htdocs/accountancy/journal/bankjournal.php +++ b/htdocs/accountancy/journal/bankjournal.php @@ -103,8 +103,7 @@ if (empty($date_start) || empty($date_end)) // We define date_start and date_end $date_end = dol_get_last_day($pastmonthyear, $pastmonth, false); } -$p = explode(":", $conf->global->MAIN_INFO_SOCIETE_COUNTRY); -$idpays = $p[0]; +$idpays = $mysoc->country_id; $sql = "SELECT b.rowid, b.dateo as do, b.datev as dv, b.amount, b.label, b.rappro, b.num_releve, b.num_chq, b.fk_type,"; $sql .= " ba.courant, ba.ref as baref, ba.account_number, ba.fk_accountancy_journal,"; @@ -144,6 +143,7 @@ $result = $db->query($sql); if ($result) { $num = $db->num_rows($result); + // Variables $account_supplier = (! empty($conf->global->ACCOUNTING_ACCOUNT_SUPPLIER) ? $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER : $langs->trans("CodeNotDef")); $account_customer = (! empty($conf->global->ACCOUNTING_ACCOUNT_CUSTOMER) ? $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER : $langs->trans("CodeNotDef")); @@ -537,6 +537,12 @@ if (! $error && $action == 'writebookkeeping') { else { $db->rollback(); + + if ($error >= 10) + { + setEventMessages($langs->trans("ErrorTooManyErrorsProcessStopped"), null, 'errors'); + break; // Break in the foreach + } } } diff --git a/htdocs/accountancy/journal/expensereportsjournal.php b/htdocs/accountancy/journal/expensereportsjournal.php index 759dca8dae9..ca9d05e7e93 100644 --- a/htdocs/accountancy/journal/expensereportsjournal.php +++ b/htdocs/accountancy/journal/expensereportsjournal.php @@ -86,13 +86,13 @@ if (empty($date_start) || empty($date_end)) // We define date_start and date_end $date_end = dol_get_last_day($pastmonthyear, $pastmonth, false); } -$p = explode(":", $conf->global->MAIN_INFO_SOCIETE_COUNTRY); -$idpays = $p[0]; +$idpays = $mysoc->country_id; $sql = "SELECT er.rowid, er.ref, er.date_debut as de,"; -$sql .= " erd.rowid as erdid, erd.comments, erd.total_ttc, erd.tva_tx, erd.total_ht, erd.total_tva, erd.fk_code_ventilation,"; +$sql .= " erd.rowid as erdid, erd.comments, erd.total_ttc, erd.tva_tx, erd.total_ht, erd.total_tva, erd.fk_code_ventilation, erd.vat_src_code, "; $sql .= " u.rowid as uid, u.firstname, u.lastname, u.accountancy_code as user_accountancy_account,"; -$sql .= " f.accountancy_code, ct.accountancy_code_buy as account_tva, aa.rowid as fk_compte, aa.account_number as compte, aa.label as label_compte"; +$sql .= " f.accountancy_code, aa.rowid as fk_compte, aa.account_number as compte, aa.label as label_compte,"; +$sql .= " ct.accountancy_code_buy as account_tva"; $sql .= " FROM " . MAIN_DB_PREFIX . "expensereport_det as erd"; $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "c_tva as ct ON erd.tva_tx = ct.taux AND ct.fk_pays = '" . $idpays . "'"; $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "c_type_fees as f ON f.id = erd.fk_c_type_fees"; @@ -110,7 +110,8 @@ dol_syslog('accountancy/journal/expensereportsjournal.php:: $sql=' . $sql); $result = $db->query($sql); if ($result) { $num = $db->num_rows($result); - // les variables + + // Variables $account_salary = (! empty($conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT)) ? $conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT : $langs->trans("CodeNotDef"); $account_vat = (! empty($conf->global->ACCOUNTING_VAT_BUY_ACCOUNT)) ? $conf->global->ACCOUNTING_VAT_BUY_ACCOUNT : $langs->trans("CodeNotDef"); @@ -130,8 +131,11 @@ if ($result) { $compta_fees = $obj->compte; $compta_tva = (! empty($obj->account_tva) ? $obj->account_tva : $account_vat); - // Define array for display vat tx - $def_tva[$obj->rowid]=price($obj->tva_tx); + // Define array to display all VAT rates that use this accounting account $compta_tva + if (! empty(price2num($obj->tva_tx)) || ! empty($obj->vat_src_code)) + { + $def_tva[$obj->rowid][$compta_tva][vatrate($obj->tva_tx).($obj->vat_src_code?' ('.$obj->vat_src_code.')':'')]=(vatrate($obj->tva_tx).($obj->vat_src_code?' ('.$obj->vat_src_code.')':'')); + } $taber[$obj->rowid]["date"] = $db->jdate($obj->de); $taber[$obj->rowid]["ref"] = $obj->ref; @@ -271,7 +275,7 @@ if ($action == 'writebookkeeping') { $bookkeeping->fk_docdet = $val["fk_expensereportdet"]; $bookkeeping->subledger_account = ''; $bookkeeping->subledger_label = ''; - $bookkeeping->label_compte = $langs->trans("VAT"). ' '.$def_tva[$key]; + $bookkeeping->label_compte = $langs->trans("VAT"). ' '.join(', ',$def_tva[$key][$k]); $bookkeeping->numero_compte = $k; $bookkeeping->montant = $mt; $bookkeeping->sens = ($mt < 0) ? 'C' : 'D'; @@ -307,6 +311,12 @@ if ($action == 'writebookkeeping') { else { $db->rollback(); + + if ($error >= 10) + { + setEventMessages($langs->trans("ErrorTooManyErrorsProcessStopped"), null, 'errors'); + break; // Break in the foreach + } } } @@ -556,7 +566,7 @@ if (empty($action) || $action == 'view') { } else print $accountoshow; print ""; - print ""; + print ""; print '"; print '"; print ""; diff --git a/htdocs/accountancy/journal/purchasesjournal.php b/htdocs/accountancy/journal/purchasesjournal.php index 506c5517821..b5f763fe2b1 100644 --- a/htdocs/accountancy/journal/purchasesjournal.php +++ b/htdocs/accountancy/journal/purchasesjournal.php @@ -85,26 +85,27 @@ if (empty($date_start) || empty($date_end)) // We define date_start and date_end $date_end = dol_get_last_day($pastmonthyear, $pastmonth, false); } -$p = explode(":", $conf->global->MAIN_INFO_SOCIETE_COUNTRY); -$idpays = $p[0]; +$idpays = $mysoc->country_id; $sql = "SELECT f.rowid, f.ref, f.type, f.datef as df, f.libelle,f.ref_supplier,"; -$sql .= " fd.rowid as fdid, fd.description, fd.total_ttc, fd.tva_tx, fd.total_ht, fd.tva as total_tva, fd.product_type,"; +$sql .= " fd.rowid as fdid, fd.description, fd.total_ttc, fd.tva_tx, fd.total_ht, fd.tva as total_tva, fd.product_type, fd.vat_src_code,"; $sql .= " s.rowid as socid, s.nom as name, s.fournisseur, s.code_client, s.code_fournisseur, s.code_compta, s.code_compta_fournisseur,"; -$sql .= " p.accountancy_code_buy , ct.accountancy_code_buy as account_tva, aa.rowid as fk_compte, aa.account_number as compte, aa.label as label_compte"; +$sql .= " p.accountancy_code_buy , aa.rowid as fk_compte, aa.account_number as compte, aa.label as label_compte,"; +$sql .= " ct.accountancy_code_buy as account_tva"; $sql .= " FROM " . MAIN_DB_PREFIX . "facture_fourn_det as fd"; $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "c_tva as ct ON fd.tva_tx = ct.taux AND ct.fk_pays = '" . $idpays . "'"; $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product as p ON p.rowid = fd.fk_product"; $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON aa.rowid = fd.fk_code_ventilation"; $sql .= " JOIN " . MAIN_DB_PREFIX . "facture_fourn as f ON f.rowid = fd.fk_facture_fourn"; $sql .= " JOIN " . MAIN_DB_PREFIX . "societe as s ON s.rowid = f.fk_soc"; -$sql .= " WHERE f.fk_statut > 0 "; +$sql .= " WHERE f.fk_statut > 0"; // TODO Facture annulée ? $sql .= " AND fd.fk_code_ventilation > 0 "; $sql .= " AND f.entity IN (" . getEntity('facture_fourn', 0) . ")"; // We don't share object for accountancy -if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) - $sql .= " AND f.type IN (0,1,2)"; -else - $sql .= " AND f.type IN (0,1,2,3)"; +if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { + $sql .= " AND f.type IN (" . Facture::TYPE_STANDARD . "," . Facture::TYPE_REPLACEMENT . "," . Facture::TYPE_CREDIT_NOTE . "," . Facture::TYPE_SITUATION . ")"; +} else { + $sql .= " AND f.type IN (" . Facture::TYPE_STANDARD . "," . Facture::TYPE_REPLACEMENT . "," . Facture::TYPE_CREDIT_NOTE . "," . Facture::TYPE_DEPOSIT . "," . Facture::TYPE_SITUATION . ")"; +} if ($date_start && $date_end) $sql .= " AND f.datef >= '" . $db->idate($date_start) . "' AND f.datef <= '" . $db->idate($date_end) . "'"; $sql .= " ORDER BY f.datef"; @@ -114,7 +115,7 @@ $result = $db->query($sql); if ($result) { $num = $db->num_rows($result); - // les variables + // Variables $cptfour = (! empty($conf->global->ACCOUNTING_ACCOUNT_SUPPLIER)) ? $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER : $langs->trans("CodeNotDef"); $cpttva = (! empty($conf->global->ACCOUNTING_VAT_BUY_ACCOUNT)) ? $conf->global->ACCOUNTING_VAT_BUY_ACCOUNT : $langs->trans("CodeNotDef"); @@ -139,10 +140,15 @@ if ($result) { else $compta_prod = (! empty($conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT)) ? $conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT : $langs->trans("CodeNotDef"); } - $compta_tva = (! empty($obj->account_tva) ? $obj->account_tva : $cpttva); - //Define array for display vat tx - $def_tva[$obj->rowid]=price($obj->tva_tx); + $vatdata = getTaxesFromId($obj->tva_tx.($obj->vat_src_code?' ('.$obj->vat_src_code.')':''), $mysoc, $mysoc, 0); + $compta_tva = (! empty($vatdata['accountancy_code_buy']) ? $vatdata['accountancy_code_buy'] : $cpttva); + + // Define array to display all VAT rates that use this accounting account $compta_tva + if (! empty(price2num($obj->tva_tx)) || ! empty($obj->vat_src_code)) + { + $def_tva[$obj->rowid][$compta_tva][vatrate($obj->tva_tx).($obj->vat_src_code?' ('.$obj->vat_src_code.')':'')]=(vatrate($obj->tva_tx).($obj->vat_src_code?' ('.$obj->vat_src_code.')':'')); + } $tabfac[$obj->rowid]["date"] = $db->jdate($obj->df); $tabfac[$obj->rowid]["ref"] = $obj->ref_supplier . ' (' . $obj->ref . ')'; @@ -214,8 +220,9 @@ if ($action == 'writebookkeeping') { $bookkeeping->doc_type = 'supplier_invoice'; $bookkeeping->fk_doc = $key; $bookkeeping->fk_docdet = 0; // Useless, can be several lines that are source of this record to add - $bookkeeping->thirdparty_code = $tabcompany[$key]['code_fournisseur']; + $bookkeeping->thirdparty_code = $companystatic->code_fournisseur; $bookkeeping->subledger_account = $tabcompany[$key]['code_compta_fournisseur']; + $bookkeeping->subledger_label = ''; // TODO To complete $bookkeeping->label_compte = dol_trunc($companystatic->name, 16) . ' - ' . $invoicestatic->refsupplier . ' - ' . $langs->trans("subledger_account"); $bookkeeping->numero_compte = $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER; $bookkeeping->montant = $mt; @@ -262,6 +269,7 @@ if ($action == 'writebookkeeping') { $bookkeeping->doc_type = 'supplier_invoice'; $bookkeeping->fk_doc = $key; $bookkeeping->fk_docdet = 0; // Useless, can be several lines that are source of this record to add + $bookkeeping->thirdparty_code = $companystatic->code_fournisseur; $bookkeeping->subledger_account = ''; $bookkeeping->subledger_label = ''; $bookkeeping->label_compte = dol_trunc($companystatic->name, 16) . ' - ' . $invoicestatic->refsupplier . ' - ' . $accountingaccount->label; @@ -308,9 +316,10 @@ if ($action == 'writebookkeeping') { $bookkeeping->doc_type = 'supplier_invoice'; $bookkeeping->fk_doc = $key; $bookkeeping->fk_docdet = 0; // Useless, can be several lines that are source of this record to add + $bookkeeping->thirdparty_code = $companystatic->code_fournisseur; $bookkeeping->subledger_account = ''; $bookkeeping->subledger_label = ''; - $bookkeeping->label_compte = dol_trunc($companystatic->name, 16) . ' - ' . $invoicestatic->refsupplier . ' - ' . $langs->trans("VAT"). ' '.$def_tva[$key]; + $bookkeeping->label_compte = dol_trunc($companystatic->name, 16) . ' - ' . $invoicestatic->refsupplier . ' - ' . $langs->trans("VAT"). ' '.join(', ',$def_tva[$key][$k]); $bookkeeping->numero_compte = $k; $bookkeeping->montant = $mt; $bookkeeping->sens = ($mt < 0) ? 'C' : 'D'; @@ -346,6 +355,12 @@ if ($action == 'writebookkeeping') { else { $db->rollback(); + + if ($error >= 10) + { + setEventMessages($langs->trans("ErrorTooManyErrorsProcessStopped"), null, 'errors'); + break; // Break in the foreach + } } } @@ -615,7 +630,7 @@ if (empty($action) || $action == 'view') { } else print $accountoshow; print ""; - print ""; + print ""; print '"; print '"; print ""; diff --git a/htdocs/accountancy/journal/sellsjournal.php b/htdocs/accountancy/journal/sellsjournal.php index 8506b2a480b..24f5ae6e7aa 100644 --- a/htdocs/accountancy/journal/sellsjournal.php +++ b/htdocs/accountancy/journal/sellsjournal.php @@ -89,27 +89,26 @@ if (empty($date_start) || empty($date_end)) // We define date_start and date_end $date_end = dol_get_last_day($pastmonthyear, $pastmonth, false); } -$p = explode(":", $conf->global->MAIN_INFO_SOCIETE_COUNTRY); -$idpays = $p[0]; +$idpays = $mysoc->country_id; $sql = "SELECT f.rowid, f.facnumber, f.type, f.datef as df, f.ref_client,"; -$sql .= " fd.rowid as fdid, fd.description, fd.product_type, fd.total_ht, fd.total_tva, fd.tva_tx, fd.total_ttc,"; +$sql .= " fd.rowid as fdid, fd.description, fd.product_type, fd.total_ht, fd.total_tva, fd.tva_tx, fd.total_ttc, fd.situation_percent, fd.vat_src_code,"; $sql .= " s.rowid as socid, s.nom as name, s.code_client, s.code_fournisseur, s.code_compta, s.code_compta_fournisseur,"; -$sql .= " p.rowid as pid, p.ref as pref, p.accountancy_code_sell, aa.rowid as fk_compte, aa.account_number as compte, aa.label as label_compte,"; -$sql .= " fd.situation_percent,ct.accountancy_code_sell as account_tva"; +$sql .= " p.rowid as pid, p.ref as pref, p.accountancy_code_sell, aa.rowid as fk_compte, aa.account_number as compte, aa.label as label_compte"; +//$sql .= " ct.accountancy_code_sell as account_tva"; $sql .= " FROM " . MAIN_DB_PREFIX . "facturedet as fd"; $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product as p ON p.rowid = fd.fk_product"; $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON aa.rowid = fd.fk_code_ventilation"; $sql .= " JOIN " . MAIN_DB_PREFIX . "facture as f ON f.rowid = fd.fk_facture"; $sql .= " JOIN " . MAIN_DB_PREFIX . "societe as s ON s.rowid = f.fk_soc"; -$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "c_tva as ct ON fd.tva_tx = ct.taux AND ct.fk_pays = '" . $idpays . "'"; +//$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "c_tva as ct ON ((fd.vat_src_code <> '' AND fd.vat_src_code = ct.code) OR (fd.vat_src_code = '' AND fd.tva_tx = ct.taux)) AND ct.fk_pays = '" . $idpays . "'"; $sql .= " WHERE fd.fk_code_ventilation > 0"; $sql .= " AND f.entity IN (".getEntity('facture', 0).')'; // We don't share object for accountancy $sql .= " AND f.fk_statut > 0"; // TODO Facture annulée ? if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { $sql .= " AND f.type IN (" . Facture::TYPE_STANDARD . "," . Facture::TYPE_REPLACEMENT . "," . Facture::TYPE_CREDIT_NOTE . "," . Facture::TYPE_SITUATION . ")"; } else { - $sql .= " AND f.type IN (" . Facture::TYPE_STANDARD . "," . Facture::TYPE_STANDARD . "," . Facture::TYPE_CREDIT_NOTE . "," . Facture::TYPE_DEPOSIT . "," . Facture::TYPE_SITUATION . ")"; + $sql .= " AND f.type IN (" . Facture::TYPE_STANDARD . "," . Facture::TYPE_REPLACEMENT . "," . Facture::TYPE_CREDIT_NOTE . "," . Facture::TYPE_DEPOSIT . "," . Facture::TYPE_SITUATION . ")"; } $sql .= " AND fd.product_type IN (0,1)"; if ($date_start && $date_end) @@ -127,29 +126,33 @@ if ($result) { $tabcompany = array (); $num = $db->num_rows($result); - $i = 0; + // Variables $cptcli = (! empty($conf->global->ACCOUNTING_ACCOUNT_CUSTOMER)) ? $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER : $langs->trans("CodeNotDef"); + $cpttva = (! empty($conf->global->ACCOUNTING_VAT_SOLD_ACCOUNT)) ? $conf->global->ACCOUNTING_VAT_SOLD_ACCOUNT : $langs->trans("CodeNotDef"); + $i = 0; while ( $i < $num ) { $obj = $db->fetch_object($result); - // les variables $compta_soc = (! empty($obj->code_compta)) ? $obj->code_compta : $cptcli; $compta_prod = $obj->compte; if (empty($compta_prod)) { if ($obj->product_type == 0) $compta_prod = (! empty($conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT)) ? $conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT : $langs->trans("CodeNotDef"); - else - $compta_prod = (! empty($conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT)) ? $conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT : $langs->trans("CodeNotDef"); + else + $compta_prod = (! empty($conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT)) ? $conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT : $langs->trans("CodeNotDef"); } - $cpttva = (! empty($conf->global->ACCOUNTING_VAT_SOLD_ACCOUNT)) ? $conf->global->ACCOUNTING_VAT_SOLD_ACCOUNT : $langs->trans("CodeNotDef"); - $compta_tva = (! empty($obj->account_tva) ? $obj->account_tva : $cpttva); + $vatdata = getTaxesFromId($obj->tva_tx.($obj->vat_src_code?' ('.$obj->vat_src_code.')':''), $mysoc, $mysoc, 0); + $compta_tva = (! empty($vatdata['accountancy_code_sell']) ? $vatdata['accountancy_code_sell'] : $cpttva); - //Define array for display vat tx - $def_tva[$obj->rowid]=price($obj->tva_tx); + // Define array to display all VAT rates that use this accounting account $compta_tva + if (! empty(price2num($obj->tva_tx)) || ! empty($obj->vat_src_code)) + { + $def_tva[$obj->rowid][$compta_tva][vatrate($obj->tva_tx).($obj->vat_src_code?' ('.$obj->vat_src_code.')':'')]=(vatrate($obj->tva_tx).($obj->vat_src_code?' ('.$obj->vat_src_code.')':'')); + } // Situation invoices handling $line = new FactureLigne($db); @@ -231,8 +234,9 @@ if ($action == 'writebookkeeping') { $bookkeeping->doc_type = 'customer_invoice'; $bookkeeping->fk_doc = $key; $bookkeeping->fk_docdet = 0; // Useless, can be several lines that are source of this record to add - $bookkeeping->thirdparty_code = $tabcompany[$key]['code_client']; + $bookkeeping->thirdparty_code = $companystatic->code_client; $bookkeeping->subledger_account = $tabcompany[$key]['code_compta']; + $bookkeeping->subledger_label = ''; // TODO To complete $bookkeeping->numero_compte = $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER; $bookkeeping->label_compte = dol_trunc($companystatic->name, 16) . ' - ' . $invoicestatic->ref . ' - ' . $langs->trans("subledger_account"); $bookkeeping->montant = $mt; @@ -277,6 +281,7 @@ if ($action == 'writebookkeeping') { $bookkeeping->doc_type = 'customer_invoice'; $bookkeeping->fk_doc = $key; $bookkeeping->fk_docdet = 0; // Useless, can be several lines that are source of this record to add; + $bookkeeping->thirdparty_code = $companystatic->code_client; $bookkeeping->subledger_account = ''; $bookkeeping->subledger_label = ''; $bookkeeping->numero_compte = $k; @@ -322,10 +327,11 @@ if ($action == 'writebookkeeping') { $bookkeeping->doc_type = 'customer_invoice'; $bookkeeping->fk_doc = $key; $bookkeeping->fk_docdet = 0; // Useless, can be several lines that are source of this record to add + $bookkeeping->thirdparty_code = $companystatic->code_client; $bookkeeping->subledger_account = ''; $bookkeeping->subledger_label = ''; $bookkeeping->numero_compte = $k; - $bookkeeping->label_compte = dol_trunc($companystatic->name, 16) . ' - ' . $invoicestatic->ref . ' - ' . $langs->trans("VAT").' '.$def_tva[$key]; + $bookkeeping->label_compte = dol_trunc($companystatic->name, 16) . ' - ' . $invoicestatic->ref . ' - ' . $langs->trans("VAT").' '.join(', ',$def_tva[$key][$k]); $bookkeeping->montant = $mt; $bookkeeping->sens = ($mt < 0) ? 'D' : 'C'; $bookkeeping->debit = ($mt < 0) ? $mt : 0; @@ -360,6 +366,12 @@ if ($action == 'writebookkeeping') { else { $db->rollback(); + + if ($error >= 10) + { + setEventMessages($langs->trans("ErrorTooManyErrorsProcessStopped"), null, 'errors'); + break; // Break in the foreach + } } } @@ -651,7 +663,7 @@ if (empty($action) || $action == 'view') { } else print $accountoshow; print ""; - print ""; + print ""; // print ""; print ""; print ""; diff --git a/htdocs/core/class/html.formaccounting.class.php b/htdocs/core/class/html.formaccounting.class.php index e37e1690ca2..7248c4bda3a 100644 --- a/htdocs/core/class/html.formaccounting.class.php +++ b/htdocs/core/class/html.formaccounting.class.php @@ -241,7 +241,7 @@ class FormAccounting extends Form * Return list of accounts with label by chart of accounts * * @param string $selectid Preselected id or code of accounting accounts (depends on $select_in) - * @param string $htmlname Name of field in html form + * @param string $htmlname Name of HTML field id. If name start with '.', it is name of HTML css class, so several component with same name in different forms can be used. * @param int $showempty Add an empty field * @param array $event Event options * @param int $select_in 0=selectid value is a aa.rowid (default) or 1=selectid is aa.account_number @@ -284,8 +284,6 @@ class FormAccounting extends Form return -1; } - $out .= ajax_combobox($htmlname, $event); - $selected = 0; while ($obj = $this->db->fetch_object($resql)) { diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 49bcc265050..a582263185b 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -4099,29 +4099,49 @@ function get_localtax_by_third($local) /** - * Get vat rate and npr from id. - * You can call getLocalTaxesFromRate after to get other fields + * Get vat main information from Id. + * You can call getLocalTaxesFromRate after to get other fields. * - * @param int $vatrowid Line ID into vat rate table. - * @return array array(localtax_type1(1-6 / 0 if not found), rate of localtax1, ...) + * @param int|string $vatrate VAT ID or Rate. Value can be value or the string with code into parenthesis or rowid if $firstparamisid is 1. Example: '8.5' or '8.5 (8.5NPR)' or 123. + * @param Societe $buyer Company object + * @param Societe $seller Company object + * @param int $firstparamisid 1 if first param is id into table (use this if you can) + * @return array array('rowid'=> , 'code'=> ...) + * @see getLocalTaxesFromRate */ -function getTaxesFromId($vatrowid) +function getTaxesFromId($vatrate, $buyer=null, $seller=null, $firstparamisid=1) { global $db, $mysoc; - dol_syslog("getTaxesFromId vatrowid=".$vatrowid); + dol_syslog("getTaxesFromId vatrowid=".$vatrate); // Search local taxes - $sql = "SELECT t.rowid, t.code, t.taux as rate, t.recuperableonly as npr"; + $sql = "SELECT t.rowid, t.code, t.taux as rate, t.recuperableonly as npr, t.accountancy_code_sell, t.accountancy_code_buy"; $sql.= " FROM ".MAIN_DB_PREFIX."c_tva as t"; - $sql.= " WHERE t.rowid ='".$vatrowid."'"; + if ($firstparamisid) $sql.= " WHERE t.rowid = ".(int) $vatrate; + else + { + $vatratecleaned = $vatrate; + $vatratecode = ''; + if (preg_match('/^(.*)\s*\((.*)\)$/', $vatrate, $reg)) // If vat is "xx (yy)" + { + $vatratecleaned = $reg[1]; + $vatratecode = $reg[2]; + } + + $sql.=", ".MAIN_DB_PREFIX."c_country as c"; + if ($mysoc->country_code == 'ES') $sql .= " WHERE t.fk_pays = c.rowid AND c.code = '".$buyer->country_code."'"; // local tax in spain use the buyer country ?? + else $sql .= " WHERE t.fk_pays = c.rowid AND c.code = '".$seller->country_code."'"; + $sql.= " AND t.taux = ".((float) $vatratecleaned)." AND t.active = 1"; + if ($vatratecode) $sql.= " AND t.code = '".$vatratecode."'"; + } $resql=$db->query($sql); if ($resql) { $obj = $db->fetch_object($resql); - - return array('rowid'=>$obj->rowid, 'code'=>$obj->code, 'rate'=>$obj->rate, 'npr'=>$obj->npr); + if ($obj) return array('rowid'=>$obj->rowid, 'code'=>$obj->code, 'rate'=>$obj->rate, 'npr'=>$obj->npr, 'accountancy_code_sell'=>$obj->accountancy_code_sell, 'accountancy_code_buy'=>$obj->accountancy_code_buy); + else return array(); } else dol_print_error($db); @@ -4135,12 +4155,13 @@ function getTaxesFromId($vatrowid) * Instead this function must be called when adding a line to get the array of localtax and type, and then * provide it to the function calcul_price_total. * - * @param string $vatrate VAT Rate. Value can be value or the string with code into parenthesis or rowid if $firstparamisid is 1. Example: '8.5' or '8.5 (8.5NPR)' or 123. - * @param int $local Number of localtax (1 or 2, or 0 to return 1 & 2) - * @param Societe $buyer Company object - * @param Societe $seller Company object - * @param int $firstparamisid 1 if first param is id into table (use this if you can) - * @return array array(localtax_type1(1-6 / 0 if not found), rate of localtax1, ...) + * @param int|string $vatrate VAT ID or Rate. Value can be value or the string with code into parenthesis or rowid if $firstparamisid is 1. Example: '8.5' or '8.5 (8.5NPR)' or 123. + * @param int $local Number of localtax (1 or 2, or 0 to return 1 & 2) + * @param Societe $buyer Company object + * @param Societe $seller Company object + * @param int $firstparamisid 1 if first param is id into table (use this if you can) + * @return array array(localtax_type1(1-6 / 0 if not found), rate of localtax1, ...) + * @see getTaxesFromId */ function getLocalTaxesFromRate($vatrate, $local, $buyer, $seller, $firstparamisid=0) { @@ -4148,25 +4169,25 @@ function getLocalTaxesFromRate($vatrate, $local, $buyer, $seller, $firstparamisi dol_syslog("getLocalTaxesFromRate vatrate=".$vatrate." local=".$local); - $vatratecleaned = $vatrate; - $vatratecode = ''; - if (preg_match('/^(.*)\s*\((.*)\)$/', $vatrate, $reg)) // If vat is "xx (yy)" - { - $vatratecleaned = $reg[1]; - $vatratecode = $reg[2]; - } - // Search local taxes $sql = "SELECT t.localtax1, t.localtax1_type, t.localtax2, t.localtax2_type, t.accountancy_code_sell, t.accountancy_code_buy"; $sql .= " FROM ".MAIN_DB_PREFIX."c_tva as t"; - if ($firstparamisid) $sql.= " WHERE t.rowid ='".$vatrate."'"; + if ($firstparamisid) $sql.= " WHERE t.rowid = ".(int) $vatrate; else { + $vatratecleaned = $vatrate; + $vatratecode = ''; + if (preg_match('/^(.*)\s*\((.*)\)$/', $vatrate, $reg)) // If vat is "xx (yy)" + { + $vatratecleaned = $reg[1]; + $vatratecode = $reg[2]; + } + $sql.=", ".MAIN_DB_PREFIX."c_country as c"; if ($mysoc->country_code == 'ES') $sql .= " WHERE t.fk_pays = c.rowid AND c.code = '".$buyer->country_code."'"; // local tax in spain use the buyer country ?? else $sql .= " WHERE t.fk_pays = c.rowid AND c.code = '".$seller->country_code."'"; $sql.= " AND t.taux = ".((float) $vatratecleaned)." AND t.active = 1"; - if ($vatratecode) $sql.= " AND t.code ='".$vatratecode."'"; + if ($vatratecode) $sql.= " AND t.code = '".$vatratecode."'"; } $resql=$db->query($sql); diff --git a/htdocs/langs/en_US/errors.lang b/htdocs/langs/en_US/errors.lang index 0f49bd832d6..0f57a23d23c 100644 --- a/htdocs/langs/en_US/errors.lang +++ b/htdocs/langs/en_US/errors.lang @@ -182,6 +182,7 @@ ErrorFailedToLoadLoginFileForMode=Failed to get the login key for mode '%s'. ErrorModuleNotFound=File of module was not found. ErrorFieldAccountNotDefinedForBankLine=Value for Accounting account not defined for source line id %s (%s) ErrorFieldAccountNotDefinedForInvoiceLine=Value for Accounting account not defined for invoice id %s (%s) +ErrorFieldAccountNotDefinedForLine=Value for Accounting account not defined for the line (%s) ErrorBankStatementNameMustFollowRegex=Error, bank statement name must follow the following syntax rule %s ErrorPhpMailDelivery=Check that you don't use a too high number of recipients and that your email content is not similar to a Spam. Ask also your administrator to check firewall and server logs files for a more complete information. ErrorUserNotAssignedToTask=User must be assigned to task to be able to enter time consumed. @@ -191,6 +192,7 @@ ErrorFilenameDosNotMatchDolibarrPackageRules=The name of the module package ( Date: Fri, 16 Jun 2017 00:49:52 +0200 Subject: [PATCH 019/227] Debug accounting module with new structure v6 Make accounting module compatible with the new vat code to identify 2 vat code with same rate. --- htdocs/accountancy/admin/defaultaccounts.php | 2 +- htdocs/accountancy/bookkeeping/card.php | 8 +++--- htdocs/accountancy/bookkeeping/list.php | 4 +-- .../accountancy/class/bookkeeping.class.php | 7 ++++- .../journal/expensereportsjournal.php | 12 +++++---- .../accountancy/journal/purchasesjournal.php | 26 +++++++++++++------ htdocs/accountancy/journal/sellsjournal.php | 14 +++++++++- .../core/class/html.formaccounting.class.php | 16 +++++------- htdocs/langs/en_US/accountancy.lang | 1 + 9 files changed, 59 insertions(+), 31 deletions(-) diff --git a/htdocs/accountancy/admin/defaultaccounts.php b/htdocs/accountancy/admin/defaultaccounts.php index ef39252ff87..227949a3c1c 100644 --- a/htdocs/accountancy/admin/defaultaccounts.php +++ b/htdocs/accountancy/admin/defaultaccounts.php @@ -51,8 +51,8 @@ $action = GETPOST('action', 'alpha'); $list_account_main = array ( - 'ACCOUNTING_ACCOUNT_SUPPLIER', 'ACCOUNTING_ACCOUNT_CUSTOMER', + 'ACCOUNTING_ACCOUNT_SUPPLIER', ); $list_account = array ( diff --git a/htdocs/accountancy/bookkeeping/card.php b/htdocs/accountancy/bookkeeping/card.php index f40bfda856f..5c558ca0a90 100644 --- a/htdocs/accountancy/bookkeeping/card.php +++ b/htdocs/accountancy/bookkeeping/card.php @@ -387,10 +387,10 @@ if ($action == 'create') { if ($action == 'update' && $line->id == $id) { print ''; print ''; print ''; print ''; @@ -431,10 +431,10 @@ if ($action == 'create') { if ($action == "" || $action == 'add') { print ''; print ''; print ''; print ''; print ''; diff --git a/htdocs/accountancy/bookkeeping/list.php b/htdocs/accountancy/bookkeeping/list.php index cd93b1142f8..4a7bca5e1b7 100644 --- a/htdocs/accountancy/bookkeeping/list.php +++ b/htdocs/accountancy/bookkeeping/list.php @@ -389,11 +389,11 @@ print ''; print ''; } - // Assujeti a TVA ou pas + // VAT is used print ''; - print ''; + print ''; print ''; // Local Taxes - if ($mysoc->useLocalTax(1)) + // TODO Move this on same record than VATIsUsed + if ($mysoc->localtax1_assuj=="1") { print ''; } - if ($mysoc->useLocalTax(2)) + if ($mysoc->localtax1_assuj=="1") { print ''; - print ''; - print ''; From b416b22bcc00d198ff3ddfdc9e90ebd7187eaf69 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 16 Jun 2017 01:27:28 +0200 Subject: [PATCH 022/227] Fix phpcs --- htdocs/accountancy/journal/expensereportsjournal.php | 2 +- htdocs/accountancy/journal/purchasesjournal.php | 2 +- htdocs/accountancy/journal/sellsjournal.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/accountancy/journal/expensereportsjournal.php b/htdocs/accountancy/journal/expensereportsjournal.php index f73596c5aa4..3da9e09aeda 100644 --- a/htdocs/accountancy/journal/expensereportsjournal.php +++ b/htdocs/accountancy/journal/expensereportsjournal.php @@ -134,7 +134,7 @@ if ($result) { $compta_tva = (! empty($vatdata['accountancy_code_sell']) ? $vatdata['accountancy_code_sell'] : $account_vat); // Define array to display all VAT rates that use this accounting account $compta_tva - if (! empty(price2num($obj->tva_tx)) || ! empty($obj->vat_src_code)) + if ((! price2num($obj->tva_tx)) || ! empty($obj->vat_src_code)) { $def_tva[$obj->rowid][$compta_tva][vatrate($obj->tva_tx).($obj->vat_src_code?' ('.$obj->vat_src_code.')':'')]=(vatrate($obj->tva_tx).($obj->vat_src_code?' ('.$obj->vat_src_code.')':'')); } diff --git a/htdocs/accountancy/journal/purchasesjournal.php b/htdocs/accountancy/journal/purchasesjournal.php index 27dfd532981..9ef1afdac38 100644 --- a/htdocs/accountancy/journal/purchasesjournal.php +++ b/htdocs/accountancy/journal/purchasesjournal.php @@ -145,7 +145,7 @@ if ($result) { $compta_tva = (! empty($vatdata['accountancy_code_buy']) ? $vatdata['accountancy_code_buy'] : $cpttva); // Define array to display all VAT rates that use this accounting account $compta_tva - if (! empty(price2num($obj->tva_tx)) || ! empty($obj->vat_src_code)) + if ((! price2num($obj->tva_tx)) || ! empty($obj->vat_src_code)) { $def_tva[$obj->rowid][$compta_tva][vatrate($obj->tva_tx).($obj->vat_src_code?' ('.$obj->vat_src_code.')':'')]=(vatrate($obj->tva_tx).($obj->vat_src_code?' ('.$obj->vat_src_code.')':'')); } diff --git a/htdocs/accountancy/journal/sellsjournal.php b/htdocs/accountancy/journal/sellsjournal.php index 3150b74e9bd..4eb4dc72171 100644 --- a/htdocs/accountancy/journal/sellsjournal.php +++ b/htdocs/accountancy/journal/sellsjournal.php @@ -150,7 +150,7 @@ if ($result) { $compta_tva = (! empty($vatdata['accountancy_code_sell']) ? $vatdata['accountancy_code_sell'] : $cpttva); // Define array to display all VAT rates that use this accounting account $compta_tva - if (! empty(price2num($obj->tva_tx)) || ! empty($obj->vat_src_code)) + if ((! price2num($obj->tva_tx)) || ! empty($obj->vat_src_code)) { $def_tva[$obj->rowid][$compta_tva][vatrate($obj->tva_tx).($obj->vat_src_code?' ('.$obj->vat_src_code.')':'')]=(vatrate($obj->tva_tx).($obj->vat_src_code?' ('.$obj->vat_src_code.')':'')); } From f424f96589b6d43d2a0abb4631470717c9a464b3 Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Fri, 16 Jun 2017 05:15:00 +0200 Subject: [PATCH 023/227] Fix SPEC #7013 : use database type "numeric" to store monetary values --- .../install/mysql/migration/6.0.0-7.0.0.sql | 64 +++++++++++++++++++ .../tables/llx_accounting_bookkeeping.sql | 10 +-- .../install/mysql/tables/llx_blockedlog.sql | 2 +- .../mysql/tables/llx_chargesociales.sql | 2 +- htdocs/install/mysql/tables/llx_commande.sql | 2 +- .../mysql/tables/llx_commande_fournisseur.sql | 2 +- htdocs/install/mysql/tables/llx_don.sql | 2 +- .../mysql/tables/llx_loan_schedule.sql | 6 +- .../mysql/tables/llx_paiementcharge.sql | 2 +- .../mysql/tables/llx_paiementfourn.sql | 2 +- .../mysql/tables/llx_payment_donation.sql | 2 +- .../tables/llx_payment_expensereport.sql | 2 +- .../install/mysql/tables/llx_payment_loan.sql | 6 +- .../mysql/tables/llx_payment_salary.sql | 4 +- .../mysql/tables/llx_prelevement_bons.sql | 2 +- .../llx_prelevement_facture_demande.sql | 2 +- .../mysql/tables/llx_prelevement_lignes.sql | 2 +- htdocs/install/mysql/tables/llx_societe.sql | 2 +- htdocs/install/mysql/tables/llx_tva.sql | 4 +- 19 files changed, 92 insertions(+), 28 deletions(-) create mode 100644 htdocs/install/mysql/migration/6.0.0-7.0.0.sql diff --git a/htdocs/install/mysql/migration/6.0.0-7.0.0.sql b/htdocs/install/mysql/migration/6.0.0-7.0.0.sql new file mode 100644 index 00000000000..545b52ea4a7 --- /dev/null +++ b/htdocs/install/mysql/migration/6.0.0-7.0.0.sql @@ -0,0 +1,64 @@ +-- +-- Be carefull to requests order. +-- This file must be loaded by calling /install/index.php page +-- when current version is 6.0.0 or higher. +-- +-- To rename a table: ALTER TABLE llx_table RENAME TO llx_table_new; +-- To add a column: ALTER TABLE llx_table ADD COLUMN newcol varchar(60) NOT NULL DEFAULT '0' AFTER existingcol; +-- To rename a column: ALTER TABLE llx_table CHANGE COLUMN oldname newname varchar(60); +-- To drop a column: ALTER TABLE llx_table DROP COLUMN oldname; +-- To change type of field: ALTER TABLE llx_table MODIFY COLUMN name varchar(60); +-- To drop a foreign key: ALTER TABLE llx_table DROP FOREIGN KEY fk_name; +-- To drop an index: -- VMYSQL4.0 DROP INDEX nomindex on llx_table +-- To drop an index: -- VPGSQL8.0 DROP INDEX nomindex +-- To restrict request to Mysql version x.y minimum use -- VMYSQLx.y +-- To restrict request to Pgsql version x.y minimum use -- VPGSQLx.y +-- To make pk to be auto increment (mysql): -- VMYSQL4.3 ALTER TABLE llx_c_shipment_mode CHANGE COLUMN rowid rowid INTEGER NOT NULL AUTO_INCREMENT; +-- To make pk to be auto increment (postgres): -- VPGSQL8.2 NOT POSSIBLE. MUST DELETE/CREATE TABLE +-- To set a field as NULL: -- VMYSQL4.3 ALTER TABLE llx_table MODIFY COLUMN name varchar(60) NULL; +-- To set a field as NULL: -- VPGSQL8.2 ALTER TABLE llx_table ALTER COLUMN name DROP NOT NULL; +-- To set a field as NOT NULL: -- VMYSQL4.3 ALTER TABLE llx_table MODIFY COLUMN name varchar(60) NOT NULL; +-- To set a field as NOT NULL: -- VPGSQL8.2 ALTER TABLE llx_table ALTER COLUMN name SET NOT NULL; +-- To set a field as default NULL: -- VPGSQL8.2 ALTER TABLE llx_table ALTER COLUMN name SET DEFAULT NULL; +-- Note: fields with type BLOB/TEXT can't have default value. +-- -- VPGSQL8.2 DELETE FROM llx_usergroup_user WHERE fk_user NOT IN (SELECT rowid from llx_user); +-- -- VMYSQL4.1 DELETE FROM llx_usergroup_user WHERE fk_usergroup NOT IN (SELECT rowid from llx_usergroup); + + +-- Clean corrupted values for tms +-- VMYSQL4.1 SET sql_mode = 'ALLOW_INVALID_DATES'; +-- VMYSQL4.1 update llx_opensurvey_sondage set tms = date_fin where DATE(STR_TO_DATE(tms, '%Y-%m-%d')) IS NULL; +-- VMYSQL4.1 SET sql_mode = 'NO_ZERO_DATE'; +-- VMYSQL4.1 update llx_opensurvey_sondage set tms = date_fin where DATE(STR_TO_DATE(tms, '%Y-%m-%d')) IS NULL; +-- Remove default not null on date_fin +-- VMYSQL4.3 ALTER TABLE llx_opensurvey_sondage MODIFY COLUMN date_fin DATETIME NULL DEFAULT NULL; +-- VPGSQL8.2 ALTER TABLE llx_opensurvey_sondage ALTER COLUMN date_fin DROP NOT NULL; + +-- Move real to numeric for more precision for storing monetary amounts (no rouding) +-- https://wiki.dolibarr.org/index.php/Langages_et_normes#Structure_des_tables_et_champs +ALTER TABLE llx_accounting_bookkeeping MODIFY COLUMN debit numeric(24,8); +ALTER TABLE llx_accounting_bookkeeping MODIFY COLUMN credit numeric(24,8); +ALTER TABLE llx_accounting_bookkeeping MODIFY COLUMN montant numeric(24,8); +ALTER TABLE llx_accounting_bookkeeping MODIFY COLUMN multicurrency_amount numeric(24,8); +ALTER TABLE llx_blockedlog MODIFY COLUMN amounts numeric(24,8); +ALTER TABLE llx_chargessociales MODIFY COLUMN amount numeric(24,8); +ALTER TABLE llx_commande MODIFY COLUMN amount_ht numeric(24,8); +ALTER TABLE llx_commande_fournisseur MODIFY COLUMN amount_ht numeric(24,8); +ALTER TABLE llx_don MODIFY COLUMN amount numeric(24,8); +ALTER TABLE llx_loan_schedule MODIFY COLUMN amount_capital numeric(24,8); +ALTER TABLE llx_loan_schedule MODIFY COLUMN amount_insurance numeric(24,8); +ALTER TABLE llx_loan_schedule MODIFY COLUMN amount_interest numeric(24,8); +ALTER TABLE llx_paiementcharge MODIFY COLUMN amount numeric(24,8); +ALTER TABLE llx_paiementfourn MODIFY COLUMN amount numeric(24,8); +ALTER TABLE llx_payment_donation MODIFY COLUMN amount numeric(24,8); +ALTER TABLE llx_payment_expensereport MODIFY COLUMN amount numeric(24,8); +ALTER TABLE llx_payment_loan MODIFY COLUMN amount_capital numeric(24,8); +ALTER TABLE llx_payment_loan MODIFY COLUMN amount_insurance numeric(24,8); +ALTER TABLE llx_payment_loan MODIFY COLUMN amount_interest numeric(24,8); +ALTER TABLE llx_payment_salary MODIFY COLUMN salary numeric(24,8); +ALTER TABLE llx_payment_salary MODIFY COLUMN amount numeric(24,8); +ALTER TABLE llx_prelevement_bons MODIFY COLUMN amount numeric(24,8); +ALTER TABLE llx_prelevement_facture_demande MODIFY COLUMN amount numeric(24,8); +ALTER TABLE llx_prelevement_lignes MODIFY COLUMN amount numeric(24,8); +ALTER TABLE llx_societe MODIFY COLUMN capital numeric(24,8); +ALTER TABLE llx_tva MODIFY COLUMN amount numeric(24,8); diff --git a/htdocs/install/mysql/tables/llx_accounting_bookkeeping.sql b/htdocs/install/mysql/tables/llx_accounting_bookkeeping.sql index ad1160c356d..01ced5b07f4 100644 --- a/htdocs/install/mysql/tables/llx_accounting_bookkeeping.sql +++ b/htdocs/install/mysql/tables/llx_accounting_bookkeeping.sql @@ -26,17 +26,17 @@ CREATE TABLE llx_accounting_bookkeeping doc_ref varchar(300) NOT NULL, -- | facture_client/reglement_client/... reference number fk_doc integer NOT NULL, -- | facture_client/reglement_client/... rowid fk_docdet integer NOT NULL, -- | facture_client/reglement_client/... line rowid - thirdparty_code varchar(32), -- Third party code (customer or supplier) when record is saved (may help debug) + thirdparty_code varchar(32), -- Third party code (customer or supplier) when record is saved (may help debug) subledger_account varchar(32), -- FEC:CompAuxNum | account number of subledger account subledger_label varchar(255), -- FEC:CompAuxLib | label of subledger account numero_compte varchar(32) NOT NULL, -- FEC:CompteNum | account number label_compte varchar(255) NOT NULL, -- FEC:CompteLib | label of account label_operation varchar(255), -- FEC:EcritureLib | label of the operation - debit double NOT NULL, -- FEC:Debit - credit double NOT NULL, -- FEC:Credit - montant double NOT NULL, -- FEC:Montant (Not necessary) + debit numeric(24,8) NOT NULL, -- FEC:Debit + credit numeric(24,8) NOT NULL, -- FEC:Credit + montant numeric(24,8) NOT NULL, -- FEC:Montant (Not necessary) sens varchar(1) DEFAULT NULL, -- FEC:Sens (Not necessary) - multicurrency_amount double, -- FEC:Montantdevise + multicurrency_amount numeric(24,8), -- FEC:Montantdevise multicurrency_code varchar(255), -- FEC:Idevise lettering_code varchar(255), -- FEC:EcritureLet date_lettering datetime, -- FEC:DateLet diff --git a/htdocs/install/mysql/tables/llx_blockedlog.sql b/htdocs/install/mysql/tables/llx_blockedlog.sql index ae696a0d6d1..59c8e262817 100644 --- a/htdocs/install/mysql/tables/llx_blockedlog.sql +++ b/htdocs/install/mysql/tables/llx_blockedlog.sql @@ -4,7 +4,7 @@ CREATE TABLE llx_blockedlog rowid integer AUTO_INCREMENT PRIMARY KEY, tms timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, action varchar(50), - amounts real NOT NULL, + amounts numeric(24,8) NOT NULL, signature varchar(100) NOT NULL, signature_line varchar(100) NOT NULL, element varchar(50), diff --git a/htdocs/install/mysql/tables/llx_chargesociales.sql b/htdocs/install/mysql/tables/llx_chargesociales.sql index 519ceacc9e5..093b635a964 100644 --- a/htdocs/install/mysql/tables/llx_chargesociales.sql +++ b/htdocs/install/mysql/tables/llx_chargesociales.sql @@ -34,7 +34,7 @@ create table llx_chargesociales fk_type integer NOT NULL, fk_account integer, -- bank account fk_mode_reglement integer, -- mode de reglement - amount real default 0 NOT NULL, + amount numeric(24,8) default 0 NOT NULL, paye smallint default 0 NOT NULL, periode date, fk_projet integer DEFAULT NULL, diff --git a/htdocs/install/mysql/tables/llx_commande.sql b/htdocs/install/mysql/tables/llx_commande.sql index 98740c232ac..6964abdcd57 100644 --- a/htdocs/install/mysql/tables/llx_commande.sql +++ b/htdocs/install/mysql/tables/llx_commande.sql @@ -42,7 +42,7 @@ create table llx_commande fk_user_cloture integer, -- user closing source smallint, -- not used, except by setting this to 42 for orders coming for replenishment and 0 in other case ? fk_statut smallint default 0, - amount_ht real default 0, + amount_ht numeric(24,8) default 0, remise_percent real default 0, remise_absolue real default 0, remise real default 0, diff --git a/htdocs/install/mysql/tables/llx_commande_fournisseur.sql b/htdocs/install/mysql/tables/llx_commande_fournisseur.sql index 6d291dcfa00..24158903eb1 100644 --- a/htdocs/install/mysql/tables/llx_commande_fournisseur.sql +++ b/htdocs/install/mysql/tables/llx_commande_fournisseur.sql @@ -46,7 +46,7 @@ create table llx_commande_fournisseur source smallint NOT NULL, -- not used, except by setting this to 42 for orders coming for replenishment and 0 in other case ? fk_statut smallint default 0, billed smallint default 0, - amount_ht real default 0, + amount_ht numeric(24,8) default 0, remise_percent real default 0, remise real default 0, tva double(24,8) default 0, diff --git a/htdocs/install/mysql/tables/llx_don.sql b/htdocs/install/mysql/tables/llx_don.sql index b7b7c89f9cd..63b2cd111ea 100644 --- a/htdocs/install/mysql/tables/llx_don.sql +++ b/htdocs/install/mysql/tables/llx_don.sql @@ -28,7 +28,7 @@ create table llx_don tms timestamp, fk_statut smallint NOT NULL DEFAULT 0, -- Status of donation promise or validate datedon datetime, -- Date of the donation/promise - amount real DEFAULT 0, + amount numeric(24,8) DEFAULT 0, fk_payment integer, paid smallint default 0 NOT NULL, firstname varchar(50), diff --git a/htdocs/install/mysql/tables/llx_loan_schedule.sql b/htdocs/install/mysql/tables/llx_loan_schedule.sql index c682b22f276..eb43238255a 100644 --- a/htdocs/install/mysql/tables/llx_loan_schedule.sql +++ b/htdocs/install/mysql/tables/llx_loan_schedule.sql @@ -24,9 +24,9 @@ create table llx_loan_schedule datec datetime, -- creation date tms timestamp, datep datetime, -- payment date - amount_capital real DEFAULT 0, - amount_insurance real DEFAULT 0, - amount_interest real DEFAULT 0, + amount_capital numeric(24,8) DEFAULT 0, + amount_insurance numeric(24,8) DEFAULT 0, + amount_interest numeric(24,8) DEFAULT 0, fk_typepayment integer NOT NULL, num_payment varchar(50), note_private text, diff --git a/htdocs/install/mysql/tables/llx_paiementcharge.sql b/htdocs/install/mysql/tables/llx_paiementcharge.sql index 2efca933dba..086bafae0fa 100644 --- a/htdocs/install/mysql/tables/llx_paiementcharge.sql +++ b/htdocs/install/mysql/tables/llx_paiementcharge.sql @@ -23,7 +23,7 @@ create table llx_paiementcharge datec datetime, -- date de creation tms timestamp, datep datetime, -- payment date - amount real DEFAULT 0, + amount numeric(24,8) DEFAULT 0, fk_typepaiement integer NOT NULL, num_paiement varchar(50), note text, diff --git a/htdocs/install/mysql/tables/llx_paiementfourn.sql b/htdocs/install/mysql/tables/llx_paiementfourn.sql index 0e9b1885c97..16d63a32076 100644 --- a/htdocs/install/mysql/tables/llx_paiementfourn.sql +++ b/htdocs/install/mysql/tables/llx_paiementfourn.sql @@ -25,7 +25,7 @@ create table llx_paiementfourn tms timestamp, datec datetime, -- date de creation de l'enregistrement datep datetime, -- date de paiement - amount real DEFAULT 0, -- montant + amount numeric(24,8) DEFAULT 0, -- montant multicurrency_amount double(24,8) DEFAULT 0, -- multicurrency amount fk_user_author integer, -- auteur fk_paiement integer NOT NULL, -- moyen de paiement diff --git a/htdocs/install/mysql/tables/llx_payment_donation.sql b/htdocs/install/mysql/tables/llx_payment_donation.sql index afa5075cd4e..1859c7aa796 100644 --- a/htdocs/install/mysql/tables/llx_payment_donation.sql +++ b/htdocs/install/mysql/tables/llx_payment_donation.sql @@ -23,7 +23,7 @@ create table llx_payment_donation datec datetime, -- date de creation tms timestamp, datep datetime, -- payment date - amount real DEFAULT 0, + amount numeric(24,8) DEFAULT 0, fk_typepayment integer NOT NULL, num_payment varchar(50), note text, diff --git a/htdocs/install/mysql/tables/llx_payment_expensereport.sql b/htdocs/install/mysql/tables/llx_payment_expensereport.sql index 40e39771978..1857246e22e 100644 --- a/htdocs/install/mysql/tables/llx_payment_expensereport.sql +++ b/htdocs/install/mysql/tables/llx_payment_expensereport.sql @@ -23,7 +23,7 @@ create table llx_payment_expensereport datec datetime, -- date de creation tms timestamp, datep datetime, -- payment date - amount real DEFAULT 0, + amount numeric(24,8) DEFAULT 0, fk_typepayment integer NOT NULL, num_payment varchar(50), note text, diff --git a/htdocs/install/mysql/tables/llx_payment_loan.sql b/htdocs/install/mysql/tables/llx_payment_loan.sql index d023c039391..3b6111a7b2f 100644 --- a/htdocs/install/mysql/tables/llx_payment_loan.sql +++ b/htdocs/install/mysql/tables/llx_payment_loan.sql @@ -24,9 +24,9 @@ create table llx_payment_loan datec datetime, -- creation date tms timestamp, datep datetime, -- payment date - amount_capital real DEFAULT 0, - amount_insurance real DEFAULT 0, - amount_interest real DEFAULT 0, + amount_capital numeric(24,8) DEFAULT 0, + amount_insurance numeric(24,8) DEFAULT 0, + amount_interest numeric(24,8) DEFAULT 0, fk_typepayment integer NOT NULL, num_payment varchar(50), note_private text, diff --git a/htdocs/install/mysql/tables/llx_payment_salary.sql b/htdocs/install/mysql/tables/llx_payment_salary.sql index 38364c6812e..3b6da16b9cb 100644 --- a/htdocs/install/mysql/tables/llx_payment_salary.sql +++ b/htdocs/install/mysql/tables/llx_payment_salary.sql @@ -24,8 +24,8 @@ create table llx_payment_salary fk_user integer NOT NULL, datep date, -- date de paiement datev date, -- date de valeur (this field should not be here, only into bank tables) - salary real, -- salary of user when payment was done - amount real NOT NULL DEFAULT 0, + salary numeric(24,8), -- salary of user when payment was done + amount numeric(24,8) NOT NULL DEFAULT 0, fk_typepayment integer NOT NULL, num_payment varchar(50), -- ref label varchar(255), diff --git a/htdocs/install/mysql/tables/llx_prelevement_bons.sql b/htdocs/install/mysql/tables/llx_prelevement_bons.sql index e92342eb001..40fff2e842d 100644 --- a/htdocs/install/mysql/tables/llx_prelevement_bons.sql +++ b/htdocs/install/mysql/tables/llx_prelevement_bons.sql @@ -29,7 +29,7 @@ create table llx_prelevement_bons ref varchar(12), -- reference entity integer DEFAULT 1 NOT NULL, -- multi company id datec datetime, -- date de creation - amount real DEFAULT 0, -- montant total du prelevement + amount numeric(24,8) DEFAULT 0, -- montant total du prelevement statut smallint DEFAULT 0, -- statut credite smallint DEFAULT 0, -- indique si le prelevement a ete credite note text, diff --git a/htdocs/install/mysql/tables/llx_prelevement_facture_demande.sql b/htdocs/install/mysql/tables/llx_prelevement_facture_demande.sql index 3bdc0e2ed81..1d1b59bf3f5 100644 --- a/htdocs/install/mysql/tables/llx_prelevement_facture_demande.sql +++ b/htdocs/install/mysql/tables/llx_prelevement_facture_demande.sql @@ -21,7 +21,7 @@ create table llx_prelevement_facture_demande ( rowid integer AUTO_INCREMENT PRIMARY KEY, fk_facture integer NOT NULL, - amount real NOT NULL, + amount numeric(24,8) NOT NULL, date_demande datetime NOT NULL, traite smallint DEFAULT 0, date_traite datetime, diff --git a/htdocs/install/mysql/tables/llx_prelevement_lignes.sql b/htdocs/install/mysql/tables/llx_prelevement_lignes.sql index 04b6e1ebf5e..448b3846d71 100644 --- a/htdocs/install/mysql/tables/llx_prelevement_lignes.sql +++ b/htdocs/install/mysql/tables/llx_prelevement_lignes.sql @@ -24,7 +24,7 @@ create table llx_prelevement_lignes statut smallint DEFAULT 0, client_nom varchar(255), - amount real DEFAULT 0, + amount numeric(24,8) DEFAULT 0, code_banque varchar(128), code_guichet varchar(6), number varchar(255), diff --git a/htdocs/install/mysql/tables/llx_societe.sql b/htdocs/install/mysql/tables/llx_societe.sql index 20440b692d7..7c88a74de07 100644 --- a/htdocs/install/mysql/tables/llx_societe.sql +++ b/htdocs/install/mysql/tables/llx_societe.sql @@ -64,7 +64,7 @@ create table llx_societe idprof5 varchar(128), -- IDProf5: nu for france idprof6 varchar(128), -- IDProf6: nu for france tva_intra varchar(20), -- tva - capital real, -- capital de la societe + capital numeric(24,8), -- capital de la societe fk_stcomm integer DEFAULT 0 NOT NULL, -- commercial statut note_private text, -- note_public text, -- diff --git a/htdocs/install/mysql/tables/llx_tva.sql b/htdocs/install/mysql/tables/llx_tva.sql index 9abf63d6ad9..d2a7b67c835 100644 --- a/htdocs/install/mysql/tables/llx_tva.sql +++ b/htdocs/install/mysql/tables/llx_tva.sql @@ -24,11 +24,11 @@ create table llx_tva datec datetime, -- Create date datep date, -- date de paiement datev date, -- date de valeur - amount real NOT NULL DEFAULT 0, + amount numeric(24,8) NOT NULL DEFAULT 0, fk_typepayment integer NULL, num_payment varchar(50), label varchar(255), - entity integer DEFAULT 1 NOT NULL, -- multi company id + entity integer DEFAULT 1 NOT NULL, -- multi company id note text, fk_bank integer, fk_user_creat integer, -- utilisateur who create record From c2901ae8cda0ec59b5ff61327e60112077eb1558 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Fri, 16 Jun 2017 11:01:58 +0200 Subject: [PATCH 024/227] Fix: add/remove unset unsused fields --- htdocs/comm/action/class/api_agendaevents.class.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/comm/action/class/api_agendaevents.class.php b/htdocs/comm/action/class/api_agendaevents.class.php index 40fce1fd640..a607998cfa8 100644 --- a/htdocs/comm/action/class/api_agendaevents.class.php +++ b/htdocs/comm/action/class/api_agendaevents.class.php @@ -316,11 +316,12 @@ class AgendaEvents extends DolibarrApi $object = parent::_cleanObjectDatas($object); + unset($object->usermod); + unset($object->libelle); unset($object->import_key); unset($object->array_options); unset($object->context); unset($object->canvas); - unset($object->fk_project); unset($object->contact); unset($object->contact_id); unset($object->thirdparty); From 1c8daf9700676064bd7adaac2dcee8e30cec2f65 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 16 Jun 2017 11:51:33 +0200 Subject: [PATCH 025/227] Standardize and debug code of module BlockedLog --- htdocs/blockedlog/admin/blockedlog.php | 13 +- htdocs/blockedlog/admin/fingerprints.php | 103 ++++--- htdocs/blockedlog/ajax/authority.php | 112 +++++--- htdocs/blockedlog/ajax/block-add.php | 64 +++-- htdocs/blockedlog/ajax/block-info.php | 58 +++- htdocs/blockedlog/ajax/check_signature.php | 83 ++++-- htdocs/blockedlog/class/blockedlog.class.php | 262 +++++++++--------- htdocs/blockedlog/lib/blockedlog.lib.php | 8 +- htdocs/compta/facture/card.php | 31 --- htdocs/core/modules/modBlockedLog.class.php | 6 +- ..._modBlockedlog_ActionsBlockedLog.class.php | 24 +- htdocs/langs/en_US/admin.lang | 4 +- htdocs/langs/en_US/blockedlog.lang | 23 +- htdocs/main.inc.php | 36 ++- 14 files changed, 486 insertions(+), 341 deletions(-) diff --git a/htdocs/blockedlog/admin/blockedlog.php b/htdocs/blockedlog/admin/blockedlog.php index f77c6e9edd8..b3822a9acb7 100644 --- a/htdocs/blockedlog/admin/blockedlog.php +++ b/htdocs/blockedlog/admin/blockedlog.php @@ -17,7 +17,7 @@ /** * \file htdocs/blockedlog/admin/blockedlog.php - * \ingroup system + * \ingroup blockedlog * \brief Page setup for blockedlog module */ @@ -31,12 +31,13 @@ $langs->load("other"); $langs->load("blockedlog"); if (! $user->admin) accessforbidden(); - + $action = GETPOST('action','alpha'); /* * Actions */ + if (preg_match('/set_(.*)/',$action,$reg)) { $code=$reg[1]; @@ -77,7 +78,7 @@ $form=new Form($db); llxHeader('',$langs->trans("BlockedLogSetup")); $linkback=''.$langs->trans("BackToModuleList").''; -print load_fiche_titre($langs->trans("ModuleSetup").' BlockedLog',$linkback); +print load_fiche_titre($langs->trans("ModuleSetup").' '.$langs->trans('BlockedLog'),$linkback); $head=blockedlogadmin_prepare_head(); @@ -95,13 +96,11 @@ print "\n"; print ''; print ''; -if(!empty($conf->global->BLOCKEDLOG_USE_REMOTE_AUTHORITY)) { +if (!empty($conf->global->BLOCKEDLOG_USE_REMOTE_AUTHORITY)) { // Example with a yes / no select $var=!$var; print ''; diff --git a/htdocs/blockedlog/admin/fingerprints.php b/htdocs/blockedlog/admin/fingerprints.php index f585b883c65..da149d4340d 100644 --- a/htdocs/blockedlog/admin/fingerprints.php +++ b/htdocs/blockedlog/admin/fingerprints.php @@ -16,8 +16,8 @@ */ /** - * \file htdocs/blockedlog/admin/blockedlog.php - * \ingroup system + * \file htdocs/blockedlog/admin/fingerprints.php + * \ingroup blockedlog * \brief Page setup for blockedlog module */ @@ -32,39 +32,39 @@ $langs->load("other"); $langs->load("blockedlog"); if (! $user->admin) accessforbidden(); - + $action = GETPOST('action','alpha'); $showonlyerrors = GETPOST('showonlyerrors','int'); $block_static = new BlockedLog($db); if($action === 'downloadblockchain') { - + $auth = new BlockedLogAuthority($db); - + $bc = $auth->getLocalBlockChain(); - + header('Content-Type: application/octet-stream'); header("Content-Transfer-Encoding: Binary"); - header("Content-disposition: attachment; filename=\"" .$auth->signature. ".certif\""); - + header("Content-disposition: attachment; filename=\"" .$auth->signature. ".certif\""); + echo $bc; - + exit; } else if($action === 'downloadcsv') { - + $res = $db->query("SELECT rowid,tms,action,amounts,element,fk_object,date_object,ref_object,signature,fk_user FROM ".MAIN_DB_PREFIX."blockedlog ORDER BY rowid ASC"); - + if($res) { - + $signature = $block_static->getSignature(); - + header('Content-Type: application/octet-stream'); header("Content-Transfer-Encoding: Binary"); header("Content-disposition: attachment; filename=\"" .$signature. ".csv\""); - + print $langs->transnoentities('Id') .';'.$langs->transnoentities('Timestamp') .';'.$langs->transnoentities('Action') @@ -75,9 +75,9 @@ else if($action === 'downloadcsv') { .';'.$langs->transnoentities('Ref') .';'.$langs->transnoentities('Fingerprint') .';'.$langs->transnoentities('User')."\n"; - + while($obj = $db->fetch_object($res)) { - + print $obj->rowid .';'.$obj->tms .';'.$obj->action @@ -88,15 +88,15 @@ else if($action === 'downloadcsv') { .';'.$obj->ref_object .';'.$obj->signature .';'.$obj->fk_user."\n"; - + } - + exit; } else{ setEventMessage($db->lasterror, 'errors'); } - + } /* @@ -110,7 +110,7 @@ $form=new Form($db); llxHeader('',$langs->trans("BlockedLogSetup")); $linkback=''.$langs->trans("BackToModuleList").''; -print load_fiche_titre($langs->trans("ModuleSetup").' BlockedLog',$linkback); +print load_fiche_titre($langs->trans("ModuleSetup").' '.$langs->trans('BlockedLog'),$linkback); $head=blockedlogadmin_prepare_head(); @@ -131,52 +131,63 @@ print ' '; print '
'; -print ''; +print ''; print ''; @@ -264,8 +270,6 @@ print '
' . dol_print_date($line->doc_date) . '' . $line->doc_ref . '' . length_accountg($line->numero_compte) . '' . length_accounta($line->code_tiers) . '' . length_accounta($line->subledger_account) . '' . $line->label_compte . '' . price($line->debit) . '' . price($line->credit) . '" . $userstatic->getNomUrl(0, 'user', 16) . ' - ' . $langs->trans("Code_tiers") . "" . $userstatic->getNomUrl(0, 'user', 16) . ' - ' . $langs->trans("subledger_account") . "' . ($mt < 0 ? - price(- $mt) : '') . "' . ($mt >= 0 ? price($mt) : '') . "
" . $companystatic->getNomUrl(0, 'supplier', 16) . ' - ' . $invoicestatic->refsupplier . ' - ' . $langs->trans("Code_tiers") . "" . $companystatic->getNomUrl(0, 'supplier', 16) . ' - ' . $invoicestatic->refsupplier . ' - ' . $langs->trans("subledger_account") . "" . $langs->trans("ThirdParty"); // print ' (' . $companystatic->getNomUrl(0, 'supplier', 16) . ')'; // print "" . $langs->trans("ThirdParty"); // print ' (' . $companystatic->getNomUrl(0, 'customer', 16) . ')'; print '" . $companystatic->getNomUrl(0, 'customer', 16) . ' - ' . $invoicestatic->ref . ' - ' . $langs->trans("Code_tiers") . "" . $companystatic->getNomUrl(0, 'customer', 16) . ' - ' . $invoicestatic->ref . ' - ' . $langs->trans("subledger_account") . "" . ($mt >= 0 ? price($mt) : '') . "" . ($mt < 0 ? price(- $mt) : '') . "
'.$langs->trans("AccountancyJournal").''; - print $formaccountancy->select_journal('', 'code_journal', '', 0, '', 1, 1, 1, 1); + print $formaccountancy->select_journal('', 'code_journal', '', 0, 1, 1, 1, 1); print '
'.$langs->trans("AccountancyJournal").''; - print $formaccounting->select_journal($object->fk_accountancy_journal, 'fk_accountancy_journal', 4, 1, '', 0, 0); + print $formaccounting->select_journal($object->fk_accountancy_journal, 'fk_accountancy_journal', 4, 1, 0, 0); print '
'.$langs->trans("AccountancyJournal").''; - print $formaccounting->select_journal($object->fk_accountancy_journal, 'fk_accountancy_journal', 4, 1, '', 0, 0); + print $formaccounting->select_journal($object->fk_accountancy_journal, 'fk_accountancy_journal', 4, 1, 0, 0); print '
'.$trigger['code'].''.$trigger['label'].''.$valuetoshow.''; $fieldname='country'; - print $form->select_country((! empty($obj->country_code)?$obj->country_code:(! empty($obj->country)?$obj->country:'')), $fieldname, '', 28, 'maxwidth200 maxwidthonsmartphone'); + print $form->select_country((! empty($obj->country_code)?$obj->country_code:(! empty($obj->country)?$obj->country:'')), $fieldname, '', 28, 'maxwidth150 maxwidthonsmartphone'); print '" . $userstatic->getNomUrl(0, 'user', 16) . ' - ' . $langs->trans("VAT"). ' '.$def_tva[$key]. "" . $userstatic->getNomUrl(0, 'user', 16) . ' - ' . $langs->trans("VAT"). ' '.join(', ',$def_tva[$key][$k]). "' . ($mt >= 0 ? price($mt) : '') . "' . ($mt < 0 ? price(- $mt) : '') . "
" . $companystatic->getNomUrl(0, 'supplier', 16) . ' - ' . $invoicestatic->refsupplier . ' - ' . $langs->trans("VAT"). ' '.$def_tva[$key]. "" . $companystatic->getNomUrl(0, 'supplier', 16) . ' - ' . $invoicestatic->refsupplier . ' - ' . $langs->trans("VAT"). ' '.join(', ',$def_tva[$key][$k]). "' . ($mt >= 0 ? price($mt) : '') . "' . ($mt < 0 ? price(- $mt) : '') . "
" . $companystatic->getNomUrl(0, 'customer', 16) . ' - ' . $invoicestatic->ref . ' - ' . $langs->trans("VAT") . ' '.$def_tva[$key]. "" . $companystatic->getNomUrl(0, 'customer', 16) . ' - ' . $invoicestatic->ref . ' - ' . $langs->trans("VAT") . ' '.join(', ',$def_tva[$key][$k]). "" . $langs->trans("VAT") . "" . ($mt < 0 ? price(- $mt) : '') . "" . ($mt >= 0 ? price($mt) : '') . "'; - print $formaccounting->select_account($line->numero_compte, 'account_number', 0, array (), 1, 1, ''); + print $formaccounting->select_account($line->numero_compte, 'account_number', 0, array (), 1, 1, 'maxwidth300'); print ''; - print $formaccounting->select_auxaccount($line->subledger_account, 'subledger_account', 1); + print $formaccounting->select_auxaccount($line->subledger_account, 'subledger_account', 1, 'maxwidth300'); print '
'; - print $formaccounting->select_account($account_number, 'account_number', 0, array (), 1, 1, ''); + print $formaccounting->select_account($account_number, 'account_number', 0, array (), 1, 1, 'maxwidth300'); print ''; - print $formaccounting->select_auxaccount($subledger_account, 'subledger_account', 1); + print $formaccounting->select_auxaccount($subledger_account, 'subledger_account', 1, 'maxwidth300'); print ''; print '
'; print $langs->trans('From'); -print $formaccounting->select_account($search_accountancy_code_start, 'search_accountancy_code_start', 1, array (), 1, 1, ''); +print $formaccounting->select_account($search_accountancy_code_start, 'search_accountancy_code_start', 1, array (), 1, 1, 'maxwidth200'); print '
'; print '
'; print $langs->trans('to'); -print $formaccounting->select_account($search_accountancy_code_end, 'search_accountancy_code_end', 1, array (), 1, 1, ''); +print $formaccounting->select_account($search_accountancy_code_end, 'search_accountancy_code_end', 1, array (), 1, 1, 'maxwidth200'); print '
'; print '
'; diff --git a/htdocs/accountancy/class/bookkeeping.class.php b/htdocs/accountancy/class/bookkeeping.class.php index 9ed4ef29ac1..d607c1dc287 100644 --- a/htdocs/accountancy/class/bookkeeping.class.php +++ b/htdocs/accountancy/class/bookkeeping.class.php @@ -185,7 +185,12 @@ class BookKeeping extends CommonObject else { //$this->errors[]=$langs->trans('ErrorFieldAccountNotDefinedForInvoiceLine', $this->doc_ref, $this->label_compte); - $this->errors[]=$langs->trans('ErrorFieldAccountNotDefinedForLine', $this->label_compte); + $mesg=$this->doc_ref.', '.$langs->trans("AccountAccounting").': '.$this->numero_compte; + if ($this->subledger_account && $this->subledger_account != $this->numero_compte) + { + $mesg.=', '.$langs->trans("SubledgerAccount").': '.$this->subledger_account; + } + $this->errors[]=$langs->trans('ErrorFieldAccountNotDefinedForLine', $mesg); } return -1; diff --git a/htdocs/accountancy/journal/expensereportsjournal.php b/htdocs/accountancy/journal/expensereportsjournal.php index ca9d05e7e93..f73596c5aa4 100644 --- a/htdocs/accountancy/journal/expensereportsjournal.php +++ b/htdocs/accountancy/journal/expensereportsjournal.php @@ -92,15 +92,15 @@ $sql = "SELECT er.rowid, er.ref, er.date_debut as de,"; $sql .= " erd.rowid as erdid, erd.comments, erd.total_ttc, erd.tva_tx, erd.total_ht, erd.total_tva, erd.fk_code_ventilation, erd.vat_src_code, "; $sql .= " u.rowid as uid, u.firstname, u.lastname, u.accountancy_code as user_accountancy_account,"; $sql .= " f.accountancy_code, aa.rowid as fk_compte, aa.account_number as compte, aa.label as label_compte,"; -$sql .= " ct.accountancy_code_buy as account_tva"; +//$sql .= " ct.accountancy_code_buy as account_tva"; $sql .= " FROM " . MAIN_DB_PREFIX . "expensereport_det as erd"; -$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "c_tva as ct ON erd.tva_tx = ct.taux AND ct.fk_pays = '" . $idpays . "'"; +//$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "c_tva as ct ON erd.tva_tx = ct.taux AND ct.fk_pays = '" . $idpays . "'"; $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "c_type_fees as f ON f.id = erd.fk_c_type_fees"; $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON aa.rowid = erd.fk_code_ventilation"; $sql .= " JOIN " . MAIN_DB_PREFIX . "expensereport as er ON er.rowid = erd.fk_expensereport"; $sql .= " JOIN " . MAIN_DB_PREFIX . "user as u ON u.rowid = er.fk_user_author"; -$sql .= " WHERE er.fk_statut > 0 "; -$sql .= " AND erd.fk_code_ventilation > 0 "; +$sql .= " WHERE er.fk_statut > 0"; +$sql .= " AND erd.fk_code_ventilation > 0"; $sql .= " AND er.entity IN (" . getEntity('expensereport', 0) . ")"; // We don't share object for accountancy if ($date_start && $date_end) $sql .= " AND er.date_debut >= '" . $db->idate($date_start) . "' AND er.date_debut <= '" . $db->idate($date_end) . "'"; @@ -129,7 +129,9 @@ if ($result) { // Controls $compta_user = (! empty($obj->user_accountancy_account)) ? $obj->user_accountancy_account : $account_salary; $compta_fees = $obj->compte; - $compta_tva = (! empty($obj->account_tva) ? $obj->account_tva : $account_vat); + + $vatdata = getTaxesFromId($obj->tva_tx.($obj->vat_src_code?' ('.$obj->vat_src_code.')':''), $mysoc, $mysoc, 0); + $compta_tva = (! empty($vatdata['accountancy_code_sell']) ? $vatdata['accountancy_code_sell'] : $account_vat); // Define array to display all VAT rates that use this accounting account $compta_tva if (! empty(price2num($obj->tva_tx)) || ! empty($obj->vat_src_code)) diff --git a/htdocs/accountancy/journal/purchasesjournal.php b/htdocs/accountancy/journal/purchasesjournal.php index b5f763fe2b1..27dfd532981 100644 --- a/htdocs/accountancy/journal/purchasesjournal.php +++ b/htdocs/accountancy/journal/purchasesjournal.php @@ -90,21 +90,21 @@ $idpays = $mysoc->country_id; $sql = "SELECT f.rowid, f.ref, f.type, f.datef as df, f.libelle,f.ref_supplier,"; $sql .= " fd.rowid as fdid, fd.description, fd.total_ttc, fd.tva_tx, fd.total_ht, fd.tva as total_tva, fd.product_type, fd.vat_src_code,"; $sql .= " s.rowid as socid, s.nom as name, s.fournisseur, s.code_client, s.code_fournisseur, s.code_compta, s.code_compta_fournisseur,"; -$sql .= " p.accountancy_code_buy , aa.rowid as fk_compte, aa.account_number as compte, aa.label as label_compte,"; -$sql .= " ct.accountancy_code_buy as account_tva"; +$sql .= " p.accountancy_code_buy , aa.rowid as fk_compte, aa.account_number as compte, aa.label as label_compte"; +//$sql .= " ct.accountancy_code_buy as account_tva"; $sql .= " FROM " . MAIN_DB_PREFIX . "facture_fourn_det as fd"; -$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "c_tva as ct ON fd.tva_tx = ct.taux AND ct.fk_pays = '" . $idpays . "'"; +//$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "c_tva as ct ON fd.tva_tx = ct.taux AND ct.fk_pays = '" . $idpays . "'"; $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product as p ON p.rowid = fd.fk_product"; $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON aa.rowid = fd.fk_code_ventilation"; $sql .= " JOIN " . MAIN_DB_PREFIX . "facture_fourn as f ON f.rowid = fd.fk_facture_fourn"; $sql .= " JOIN " . MAIN_DB_PREFIX . "societe as s ON s.rowid = f.fk_soc"; $sql .= " WHERE f.fk_statut > 0"; // TODO Facture annulée ? -$sql .= " AND fd.fk_code_ventilation > 0 "; +$sql .= " AND fd.fk_code_ventilation > 0"; $sql .= " AND f.entity IN (" . getEntity('facture_fourn', 0) . ")"; // We don't share object for accountancy if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { - $sql .= " AND f.type IN (" . Facture::TYPE_STANDARD . "," . Facture::TYPE_REPLACEMENT . "," . Facture::TYPE_CREDIT_NOTE . "," . Facture::TYPE_SITUATION . ")"; + $sql .= " AND f.type IN (" . FactureFournisseur::TYPE_STANDARD . "," . FactureFournisseur::TYPE_REPLACEMENT . "," . FactureFournisseur::TYPE_CREDIT_NOTE . "," . FactureFournisseur::TYPE_SITUATION . ")"; } else { - $sql .= " AND f.type IN (" . Facture::TYPE_STANDARD . "," . Facture::TYPE_REPLACEMENT . "," . Facture::TYPE_CREDIT_NOTE . "," . Facture::TYPE_DEPOSIT . "," . Facture::TYPE_SITUATION . ")"; + $sql .= " AND f.type IN (" . FactureFournisseur::TYPE_STANDARD . "," . FactureFournisseur::TYPE_REPLACEMENT . "," . FactureFournisseur::TYPE_CREDIT_NOTE . "," . FactureFournisseur::TYPE_DEPOSIT . "," . FactureFournisseur::TYPE_SITUATION . ")"; } if ($date_start && $date_end) $sql .= " AND f.datef >= '" . $db->idate($date_start) . "' AND f.datef <= '" . $db->idate($date_end) . "'"; @@ -130,7 +130,7 @@ if ($result) { while ( $i < $num ) { $obj = $db->fetch_object($result); - // contrôles + // Controls $compta_soc = (! empty($obj->code_compta_fournisseur)) ? $obj->code_compta_fournisseur : $cptfour; $compta_prod = $obj->compte; @@ -536,8 +536,18 @@ if (empty($action) || $action == 'view') { print ''; }*/ + // Button to write into Ledger + if (empty($conf->global->ACCOUNTING_ACCOUNT_SUPPLIER) || $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER == '-1') { + print img_warning().' '.$langs->trans("SomeMandatoryStepsOfSetupWereNotDone"); + print ' : '.$langs->trans("AccountancyAreaDescMisc", 4, ''.$langs->transnoentitiesnoconv("MenuFinancial").'-'.$langs->transnoentitiesnoconv("MenuAccountancy").'-'.$langs->transnoentitiesnoconv("Setup")."-".$langs->transnoentitiesnoconv("MenuDefaultAccounts").''); + } print '
'; - print ''; + if (empty($conf->global->ACCOUNTING_ACCOUNT_CUSTOMER) || $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER == '-1') { + print ''; + } + else { + print ''; + } print '
'; print ' diff --git a/htdocs/accountancy/journal/sellsjournal.php b/htdocs/accountancy/journal/sellsjournal.php index 24f5ae6e7aa..3150b74e9bd 100644 --- a/htdocs/accountancy/journal/sellsjournal.php +++ b/htdocs/accountancy/journal/sellsjournal.php @@ -135,6 +135,7 @@ if ($result) { while ( $i < $num ) { $obj = $db->fetch_object($result); + // Controls $compta_soc = (! empty($obj->code_compta)) ? $obj->code_compta : $cptcli; $compta_prod = $obj->compte; @@ -549,8 +550,19 @@ if (empty($action) || $action == 'view') { } else { print ''; }*/ + + // Button to write into Ledger + if (empty($conf->global->ACCOUNTING_ACCOUNT_CUSTOMER) || $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER == '-1') { + print img_warning().' '.$langs->trans("SomeMandatoryStepsOfSetupWereNotDone"); + print ' : '.$langs->trans("AccountancyAreaDescMisc", 4, ''.$langs->transnoentitiesnoconv("MenuFinancial").'-'.$langs->transnoentitiesnoconv("MenuAccountancy").'-'.$langs->transnoentitiesnoconv("Setup")."-".$langs->transnoentitiesnoconv("MenuDefaultAccounts").''); + } print '
'; - print ''; + if (empty($conf->global->ACCOUNTING_ACCOUNT_CUSTOMER) || $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER == '-1') { + print ''; + } + else { + print ''; + } print '
'; print ' diff --git a/htdocs/core/class/html.formaccounting.class.php b/htdocs/core/class/html.formaccounting.class.php index 7248c4bda3a..8a348dba57a 100644 --- a/htdocs/core/class/html.formaccounting.class.php +++ b/htdocs/core/class/html.formaccounting.class.php @@ -325,14 +325,13 @@ class FormAccounting extends Form /** * Return list of auxilary thirdparty accounts * - * @param string $selectid Preselected pcg_type - * @param string $htmlname Name of field in html form - * @param int $showempty Add an empty field - * @param array $event Event options - * - * @return string String with HTML select + * @param string $selectid Preselected pcg_type + * @param string $htmlname Name of field in html form + * @param int $showempty Add an empty field + * @param string $morecss More css + * @return string String with HTML select */ - function select_auxaccount($selectid, $htmlname = 'account_num_aux', $showempty = 0, $event = array()) { + function select_auxaccount($selectid, $htmlname='account_num_aux', $showempty=0, $morecss='maxwidth200') { $aux_account = array(); @@ -377,8 +376,7 @@ class FormAccounting extends Form $this->db->free($resql); // Build select - $out = ajax_combobox($htmlname, $event); - $out .= Form::selectarray($htmlname, $aux_account, $selectid, $showempty, 0, 0, '', 0, 0, 0, '', 'maxwidth300'); + $out .= Form::selectarray($htmlname, $aux_account, $selectid, $showempty, 0, 0, '', 0, 0, 0, '', $morecss, 1); return $out; } diff --git a/htdocs/langs/en_US/accountancy.lang b/htdocs/langs/en_US/accountancy.lang index 8ff65371fa5..64744eedf4a 100644 --- a/htdocs/langs/en_US/accountancy.lang +++ b/htdocs/langs/en_US/accountancy.lang @@ -256,6 +256,7 @@ Calculated=Calculated Formula=Formula ## Error +SomeMandatoryStepsOfSetupWereNotDone=Some mandatory steps of setup was not done, please complete them ErrorNoAccountingCategoryForThisCountry=No accounting account group available for country %s (See Home - Setup - Dictionaries) ExportNotSupported=The export format setuped is not supported into this page BookeppingLineAlreayExists=Lines already existing into bookeeping From 07b676792a26886170eb657e23410686c0f2236a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 16 Jun 2017 01:02:53 +0200 Subject: [PATCH 020/227] Fix do not show localtax info if not used. --- htdocs/comm/card.php | 12 +++++++----- htdocs/societe/card.php | 3 ++- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/htdocs/comm/card.php b/htdocs/comm/card.php index b8906bd1038..a51ef902eb6 100644 --- a/htdocs/comm/card.php +++ b/htdocs/comm/card.php @@ -175,7 +175,7 @@ if (empty($reshook)) $result=$object->update($object->id, $user); if ($result < 0) setEventMessages($object->error, $object->errors, 'errors'); } - + if ($action == 'update_extras') { $object->fetch($id); @@ -262,21 +262,23 @@ if ($id > 0) print '
'.$langs->trans('VATIsUsed').''; + print ''.$langs->trans('VATIsUsed').''; print yn($object->tva_assuj); print '
'.$langs->transcountry("LocalTax1IsUsed", $mysoc->country_code).''; print yn($object->localtax1_assuj); print '
'.$langs->transcountry("LocalTax2IsUsed", $mysoc->country_code).''; print yn($object->localtax2_assuj); diff --git a/htdocs/societe/card.php b/htdocs/societe/card.php index b5afba996b8..46e6366bba1 100644 --- a/htdocs/societe/card.php +++ b/htdocs/societe/card.php @@ -1766,8 +1766,9 @@ else $formcompany->select_localtax(1,$object->localtax1_value, "lt1"); print ''; } + print ''.fieldLabel($langs->transcountry("LocalTax2IsUsed",$mysoc->country_code),'localtax2assuj_value').''; + print ''.fieldLabel($langs->transcountry("LocalTax2IsUsed",$mysoc->country_code),'localtax2assuj_value').''; print $form->selectyesno('localtax2assuj_value',$object->localtax2_assuj,1); if (! isOnlyOneLocalTax(2)) { From b1945daf6c7eaa1d57d5bd1bf52f2c973d7b4d57 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 16 Jun 2017 01:07:44 +0200 Subject: [PATCH 021/227] Fix alignement --- htdocs/societe/consumption.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/societe/consumption.php b/htdocs/societe/consumption.php index 1fcd73f0ddc..834131a86a8 100644 --- a/htdocs/societe/consumption.php +++ b/htdocs/societe/consumption.php @@ -365,7 +365,7 @@ if ($sql_select) print ''; print ''; print ''; // date + print ''; // date print $formother->select_month($month?$month:-1,'month',1); $formother->select_year($year?$year:-1,'year',1, 20, 1); print '
'; -print $langs->trans("EntityKey").''; - +print $langs->trans("CompanyInitialKey").''; print $block_static->getSignature(); - print '
'; print ''; -print ''; -print ''; +print ''; +print ''; +print ''; print ''; +print ''; print ''; print ''; -print ''; +print ''; print ''; print ''; - + print ''; foreach($blocks as &$block) { $checksignature = $block->checkSignature(); $object_link = $block->getObjectLink(); - + if(!$showonlyerrors || $block->error>0) { - + print ''; + print ''; print ''; - print ''; - print ''; - print ''; - print ''; print ''; - print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + + print ''; + print ''; - + } } print '
'.$langs->trans('Date').''.$langs->trans('Ref').''.$langs->trans('#').''.$langs->trans('Date').''.$langs->trans('Author').''.$langs->trans('Action').''.$langs->trans('Ref').''.$langs->trans('Element').''.$langs->trans('Amount').''.$langs->trans('Author').''.$langs->trans('DataOfArchivedEvent').''.$langs->trans('Fingerprint').'
'.$block->id.''.dol_print_date($block->tms,'dayhour').''.$block->ref_object.''.$langs->trans('log'.$block->action).''.$object_link.''.img_info($langs->trans('ShowDetails')).''.price($block->amounts).''.$block->getUser().''.$block->signature.''.$langs->trans('log'.$block->action).''.$block->ref_object.''.$object_link.''.price($block->amounts).''.img_info($langs->trans('ShowDetails')).''; - - print $block->error == 0 ? img_picto($langs->trans('OkCheckFingerprintValidity'), 'on') : img_picto($langs->trans('KoCheckFingerprintValidity'), 'off'); + print $form->textwithpicto(dol_trunc($block->signature, '12'), $block->signature); + print ''; + print $block->error == 0 ? img_picto($langs->trans('OkCheckFingerprintValidity'), 'tick') : img_picto($langs->trans('KoCheckFingerprintValidity'), 'statut8'); + if(!empty($conf->global->BLOCKEDLOG_USE_REMOTE_AUTHORITY) && !empty($conf->global->BLOCKEDLOG_AUTHORITY_URL)) { print ' '.($block->certified ? img_picto($langs->trans('AddedByAuthority'), 'info') : img_picto($langs->trans('NotAddedByAuthorityYet'), 'info_black') ); } print '
'; + + ?> -global->BLOCKEDLOG_USE_REMOTE_AUTHORITY) && !empty($conf->global->BLOCKEDLOG_AUTHORITY_URL)) { ?> - + + * Copyright (C) 2017 ATM Consulting + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ - $user=new User($db); - $user->fetch(1); //TODO conf user authority - - $auth = new BlockedLogAuthority($db); - - $signature = GETPOST('s'); - $newblock = GETPOST('b'); - $hash = GETPOST('h'); - - if($auth->fetch(0, $signature)<=0) { - $auth->signature = $signature; - $auth->create($user); - } - - - if(!empty($hash)) { - - echo $auth->checkBlockchain($hash) ? 'hashisok' : 'hashisjunk'; - - } - elseif(!empty($newblock)){ - if($auth->checkBlock($newblock)) { - $auth->addBlock($newblock); - $auth->update($user); - - echo 'blockadded'; - } - else{ - - echo 'blockalreadyadded'; - - } +/** + * \file htdocs/blockedlog/ajax/authority.php + * \ingroup blockedlog + * \brief authority + */ + + +// This script is called with a POST method. +// Directory to scan (full path) is inside POST['dir']. + +if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL',1); // Disables token renewal +//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); +if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); +if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); +//if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); + +$res=require '../../master.inc.php'; + +require_once DOL_DOCUMENT_ROOT.'/blockedlog/class/blockedlog.class.php'; +require_once DOL_DOCUMENT_ROOT.'/blockedlog/class/authority.class.php'; + +$user=new User($db); +$user->fetch(1); //TODO conf user authority + +$auth = new BlockedLogAuthority($db); + +$signature = GETPOST('s'); +$newblock = GETPOST('b'); +$hash = GETPOST('h'); + +if($auth->fetch(0, $signature)<=0) { + $auth->signature = $signature; + $auth->create($user); +} + + +if(!empty($hash)) { + + echo $auth->checkBlockchain($hash) ? 'hashisok' : 'hashisjunk'; + +} +elseif(!empty($newblock)){ + if($auth->checkBlock($newblock)) { + $auth->addBlock($newblock); + $auth->update($user); + + echo 'blockadded'; } else{ - echo 'idontunderstandwhatihavetodo'; + + echo 'blockalreadyadded'; + } - - +} +else{ + echo 'idontunderstandwhatihavetodo'; +} + + diff --git a/htdocs/blockedlog/ajax/block-add.php b/htdocs/blockedlog/ajax/block-add.php index 247b01186fe..c82eac81e7b 100644 --- a/htdocs/blockedlog/ajax/block-add.php +++ b/htdocs/blockedlog/ajax/block-add.php @@ -1,19 +1,49 @@ - + * Copyright (C) 2017 ATM Consulting + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ - require '../../main.inc.php'; - require_once DOL_DOCUMENT_ROOT.'/blockedlog/class/blockedlog.class.php'; - - $id = GETPOST('id','int'); - $element = GETPOST('element','alpha'); - $action = GETPOST('action','alpha'); - - if($element === 'facture') { - dol_include_once('/compta/facture/class/facture.class.php'); - - $facture = new Facture($db); - if($facture->fetch($id)>0) { - $facture->call_trigger($action, $user); - } - +/** + * \file htdocs/blockedlog/ajax/block-add.php + * \ingroup blockedlog + * \brief Block-add + */ + + +// This script is called with a POST method. +// Directory to scan (full path) is inside POST['dir']. + +if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL',1); // Disables token renewal +//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); +if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); +if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); +//if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); + +$res=require '../../main.inc.php'; + +$id = GETPOST('id','int'); +$element = GETPOST('element','alpha'); +$action = GETPOST('action','alpha'); + +if ($element === 'facture') { + require_once DOL_DOCUMENT_ROOT.'/blockedlog/class/blockedlog.class.php'; + require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; + + $facture = new Facture($db); + if($facture->fetch($id)>0) { + $facture->call_trigger($action, $user); } - \ No newline at end of file +} diff --git a/htdocs/blockedlog/ajax/block-info.php b/htdocs/blockedlog/ajax/block-info.php index 7a5f531e8f1..83317f33d57 100644 --- a/htdocs/blockedlog/ajax/block-info.php +++ b/htdocs/blockedlog/ajax/block-info.php @@ -1,15 +1,47 @@ + * Copyright (C) 2017 ATM Consulting + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ - require '../../main.inc.php'; - require_once DOL_DOCUMENT_ROOT.'/blockedlog/class/blockedlog.class.php'; - - $id = GETPOST('id'); - - $block = new BlockedLog($db); - if($block->fetch($id)>0) { - echo json_encode($block->object_data); - } - else { - echo json_encode(false); - } - \ No newline at end of file +/** + * \file htdocs/blockedlog/ajax/block-info.php + * \ingroup blockedlog + * \brief block-info + */ + + +// This script is called with a POST method. +// Directory to scan (full path) is inside POST['dir']. + +if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL',1); // Disables token renewal +//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); +if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); +if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); +//if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); + + +require '../../main.inc.php'; +require_once DOL_DOCUMENT_ROOT.'/blockedlog/class/blockedlog.class.php'; + +$id = GETPOST('id'); + +$block = new BlockedLog($db); +if($block->fetch($id)>0) { + echo json_encode($block->object_data); +} +else { + echo json_encode(false); +} diff --git a/htdocs/blockedlog/ajax/check_signature.php b/htdocs/blockedlog/ajax/check_signature.php index bb018508a31..170693a2ece 100644 --- a/htdocs/blockedlog/ajax/check_signature.php +++ b/htdocs/blockedlog/ajax/check_signature.php @@ -1,30 +1,63 @@ + * Copyright (C) 2017 ATM Consulting + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ - require '../../main.inc.php'; +/** + * \file htdocs/blockedlog/ajax/block-info.php + * \ingroup blockedlog + * \brief block-info + */ - if(empty($conf->global->BLOCKEDLOG_AUTHORITY_URL)) exit('BLOCKEDLOG_AUTHORITY_URL not set'); - - require_once DOL_DOCUMENT_ROOT.'/blockedlog/class/blockedlog.class.php'; - require_once DOL_DOCUMENT_ROOT.'/blockedlog/class/authority.class.php'; - - $auth=new BlockedLogAuthority($db); - $auth->syncSignatureWithAuthority(); - - $block_static = new BlockedLog($db); - - $blocks = $block_static->getLog('just_certified', 0, 0, 1) ; - $auth->signature = $block_static->getSignature(); - - foreach($blocks as &$b) { - $auth->blockchain.=$b->signature; - - } - - $hash = $auth->getBlockchainHash(); - - $url = $conf->global->BLOCKEDLOG_AUTHORITY_URL.'/blockedlog/ajax/authority.php?s='.$auth->signature.'&h='.$hash; +// This script is called with a POST method. +// Directory to scan (full path) is inside POST['dir']. - $res = file_get_contents($url); - //echo $url; - echo $res; \ No newline at end of file +if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL',1); // Disables token renewal +//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); +if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); +if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); +//if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); + + +require '../../main.inc.php'; + +if(empty($conf->global->BLOCKEDLOG_AUTHORITY_URL)) exit('BLOCKEDLOG_AUTHORITY_URL not set'); + +require_once DOL_DOCUMENT_ROOT.'/blockedlog/class/blockedlog.class.php'; +require_once DOL_DOCUMENT_ROOT.'/blockedlog/class/authority.class.php'; + +$auth=new BlockedLogAuthority($db); +$auth->syncSignatureWithAuthority(); + +$block_static = new BlockedLog($db); + +$blocks = $block_static->getLog('just_certified', 0, 0, 1) ; + +$auth->signature = $block_static->getSignature(); + +foreach($blocks as &$b) { + $auth->blockchain.=$b->signature; + +} + +$hash = $auth->getBlockchainHash(); + +$url = $conf->global->BLOCKEDLOG_AUTHORITY_URL.'/blockedlog/ajax/authority.php?s='.$auth->signature.'&h='.$hash; + +$res = file_get_contents($url); +//echo $url; +echo $res; \ No newline at end of file diff --git a/htdocs/blockedlog/class/blockedlog.class.php b/htdocs/blockedlog/class/blockedlog.class.php index b0cddd66f75..8a1508b7a04 100644 --- a/htdocs/blockedlog/class/blockedlog.class.php +++ b/htdocs/blockedlog/class/blockedlog.class.php @@ -21,65 +21,65 @@ class BlockedLog { - + /** * Id of the log * @var int */ public $id; - + /** * Unique fingerprint of the log * @var string */ public $signature = ''; - + /** * Unique fingerprint of the line log content * @var string */ public $signature_line = ''; - + public $amounts = null; - + /** * trigger action * @var string */ public $action = ''; - + /** * Object element * @var string */ public $element = ''; - + /** * Object id * @var int */ public $fk_object = 0; - + /** * Log certified by remote authority or not * @var boolean */ public $certified = false; - + /** * Author * @var int */ public $fk_user = 0; - + public $date_object = 0; - + public $ref_object = ''; - + public $object_data = null; - + public $error = 0; - + /** * Constructor * @@ -88,7 +88,7 @@ class BlockedLog public function __construct(DoliDB $db) { $this->db = $db; - + } /** @@ -96,10 +96,10 @@ class BlockedLog */ public function getObjectLink() { global $langs; - + if($this->element === 'facture') { require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; - + $object = new Facture($this->db); if($object->fetch($this->fk_object)>0) { return $object->getNomUrl(1); @@ -110,7 +110,7 @@ class BlockedLog } else if($this->element === 'payment') { require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php'; - + $object = new Paiement($this->db); if($object->fetch($this->fk_object)>0) { return $object->getNomUrl(1); @@ -119,61 +119,61 @@ class BlockedLog $this->error++; } } - + return $langs->trans('ImpossibleToReloadObject', $this->element, $this->fk_object); - + } - + /** * try to retrieve user author */ public function getUser() { global $langs, $cachedUser; - + if(empty($cachedUser))$cachedUser=array(); - + if(empty($cachedUser[$this->fk_user])) { $u=new User($this->db); if($u->fetch($this->fk_user)>0) { $cachedUser[$this->fk_user] = $u; } } - + if(!empty($cachedUser[$this->fk_user])) { return $cachedUser[$this->fk_user]->getNomUrl(1); } - + return $langs->trans('ImpossibleToRetrieveUser', $this->fk_user); } - + /** * populate log by object * * @param payment|facture $object object to store */ public function setObjectData(&$object) { - + if($object->element=='payment') { $this->date_object = $object->datepaye; } else{ $this->date_object = $object->date; } - + $this->ref_object = $object->ref; $this->element = $object->element; $this->fk_object = $object->id; - + $this->object_data=new stdClass(); - + if($this->element === 'facture') { if(empty($object->thirdparty))$object->fetch_thirdparty(); $this->object_data->thirdparty = new stdClass(); - + foreach($object->thirdparty as $key=>$value) { if(!is_object($value)) $this->object_data->thirdparty->{$key} = $value; } - + $this->object_data->total_ht = (double) $object->total_ht; $this->object_data->total_tva = (double) $object->total_tva; $this->object_data->total_ttc = (double) $object->total_ttc; @@ -181,17 +181,17 @@ class BlockedLog $this->object_data->total_localtax2= (double) $object->total_localtax2; $this->object_data->note_public = (double) $object->note_public; $this->object_data->note_private= (double) $object->note_private; - + } elseif($this->element==='payment'){ - + $this->object_data->amounts = $object->amounts; - + } - - + + } - + /** * Get object from database * @@ -199,50 +199,50 @@ class BlockedLog * @return int >0 if OK, <0 if KO, 0 if not found */ public function fetch($id) { - + global $langs; - + dol_syslog(get_class($this)."::fetch id=".$id, LOG_DEBUG); - + if (empty($id)) { $this->error='BadParameter'; return -1; } - + $langs->load("blockedlog"); - + $sql = "SELECT b.rowid, b.signature, b.amounts, b.action, b.element, b.fk_object, b.certified, b.tms, b.fk_user, b.date_object, b.ref_object, b.object_data"; $sql.= " FROM ".MAIN_DB_PREFIX."blockedlog as b"; if ($id) $sql.= " WHERE b.rowid = ". $id; - + $resql=$this->db->query($sql); if ($resql) { if ($this->db->num_rows($resql)) { $obj = $this->db->fetch_object($resql); - + $this->id = $obj->rowid; $this->ref = $obj->rowid; - + $this->signature = $obj->signature; $this->amounts = (double) $obj->amounts; $this->action = $obj->action; $this->element = $obj->element; - + $this->fk_object = trim($obj->fk_object); $this->date_object = $this->db->jdate($obj->date_object); $this->ref_object = $obj->ref_object; - + $this->certified = ($obj->certified == 1); - + $this->fk_user = $obj->fk_user; - + $this->tms = $this->db->jdate($obj->tms); - + $this->object_data = unserialize($obj->object_data); - + return 1; } else @@ -256,24 +256,24 @@ class BlockedLog $this->error=$this->db->error(); return -1; } - + } - + /** * Set block certified by authority * * @return boolean */ public function setCertified() { - + $res = $this->db->query("UPDATE ".MAIN_DB_PREFIX."blockedlog SET certified=1 WHERE rowid=".$this->id); if($res===false) return false; - + return true; - - + + } - + /** * Create blocked log in database. * @@ -281,31 +281,31 @@ class BlockedLog * @return int <0 if KO, >0 if OK */ public function create($user) { - + global $conf,$langs,$hookmanager; - + $langs->load('blockedlog'); - + $error=0; - + dol_syslog(get_class($this).'::create', LOG_DEBUG); - + $this->getSignatureRecursive(); - - + + if (is_null($this->amounts)) { $this->error=$langs->trans("BlockLogNeedAmountsValue"); dol_syslog($this->error, LOG_WARNING); return -1; } - + if(empty($this->element)) { $this->error=$langs->trans("BlockLogNeedElement"); dol_syslog($this->error, LOG_WARNING); return -2; } - + if(empty($this->action)) { $this->error=$langs->trans("BlockLogNeedAction"); dol_syslog($this->error, LOG_WARNING); @@ -313,9 +313,9 @@ class BlockedLog } $this->fk_user = $user->id; - + $this->db->begin(); - + $sql = "INSERT INTO ".MAIN_DB_PREFIX."blockedlog ("; $sql.= "action,"; $sql.= " amounts,"; @@ -343,18 +343,18 @@ class BlockedLog $sql.= "".$user->id.","; $sql.= $conf->entity; $sql.= ")"; - + $res = $this->db->query($sql); if ($res) { $id = $this->db->last_insert_id(MAIN_DB_PREFIX."blockedlog"); - + if ($id > 0) { $this->id = $id; - + $this->db->commit(); - + return $this->id; } else @@ -369,9 +369,9 @@ class BlockedLog $this->db->rollback(); return -1; } - + } - + /** * return crypted value. * @@ -379,56 +379,56 @@ class BlockedLog * @return string crypted string */ private function crypt($value) { - + return hash('sha256',$value); - + } - + /** * check if current signature still correct compare to the chain * - * @return boolean + * @return boolean */ public function checkSignature() { - + $signature_to_test = $this->signature; - + $this->getSignatureRecursive(); - + $res = ($signature_to_test === $this->signature); - + if(!$res) { $this->error++; } - + return $res; } - + /** - * set current signatures + * set current signatures */ private function getSignatureRecursive(){ - + $this->signature_line = $this->crypt( $this->action . $this->getSignature() . $this->amounts . print_r($this->object_data, true) ); /*if($this->signature=='d6320580a02c1ab67fcc0a6d49d453c7d96dda0148901736f7f55725bfe1b900' || $this->signature=='ea65d435ff12ca929936a406aa9d707d99fb334c127878d256b602a5541bbbc9') { var_dump($this->signature_line,$this->action ,$this->getSignature() , $this->amounts , $this->object_data); }*/ $this->signature = $this->signature_line; - + $logs = $this->getLog('all', 0, 0, 1) ; if($logs!==false) { foreach($logs as &$b) { - + if($this->id>0 && $b->id == $this->id) break; // on arrête sur un enregistrement précis pour recalculer une signature - + $b->getCurrentValue(); // on récupère la valeur actuelle en base de l'élément enregistré - + $this->signature = $this->crypt($this->signature. $this->action . $b->signature . $b->amounts); } } - + } - + /** * return log object for a element. * @@ -439,110 +439,110 @@ class BlockedLog * @return array array of object log */ public function getLog($element, $fk_object, $limit = 0, $order = -1) { - global $conf,$cachedlogs ; - + global $conf,$cachedlogs ; + /* $cachedlogs allow fastest search */ if(empty($cachedlogs)) $cachedlogs=array(); - - + + if($element=='all') { - + $sql="SELECT rowid FROM ".MAIN_DB_PREFIX."blockedlog WHERE entity=".$conf->entity; - + } else if($element=='not_certified') { $sql="SELECT rowid FROM ".MAIN_DB_PREFIX."blockedlog WHERE entity=".$conf->entity." AND certified = 0"; - + } else if($element=='just_certified') { $sql="SELECT rowid FROM ".MAIN_DB_PREFIX."blockedlog WHERE entity=".$conf->entity." AND certified = 1"; - + } else{ $sql="SELECT rowid FROM ".MAIN_DB_PREFIX."blockedlog WHERE element='".$element."' AND fk_object=".(int) $fk_object; - + } - + $sql.=($order<0 ? ' ORDER BY rowid DESC ' : ' ORDER BY rowid ASC '); - + if($limit > 0 )$sql.=' LIMIT '.$limit; - + $res = $this->db->query($sql); - + if($res) { - + $results=array(); - + while($obj = $this->db->fetch_object($res)) { - + if(!isset($cachedlogs[$obj->rowid])) { $b=new BlockedLog($this->db); $b->fetch($obj->rowid); - + $cachedlogs[$obj->rowid] = $b; } - + $results[] = $cachedlogs[$obj->rowid]; - + } - + return $results; } else{ return false; } } - + /** * set amounts of log from current element value in order to compare signature. */ private function getCurrentValue() { - + if($this->element === 'payment') { $sql="SELECT amount FROM ".MAIN_DB_PREFIX."paiement WHERE rowid=".$this->fk_object; - + $res = $this->db->query($sql); - + if($res && $obj = $this->db->fetch_object($res)) { $this->amounts = (double) $obj->amount; } } elseif($this->element === 'facture') { $sql="SELECT total_ttc FROM ".MAIN_DB_PREFIX."facture WHERE rowid=".$this->fk_object; - + $res = $this->db->query($sql); if($res && $obj = $this->db->fetch_object($res)) { $this->amounts = (double) $obj->total_ttc; } } - + } - + /** - * return and set the entity signature included into line signature + * Return and set the entity signature included into line signature * * @return string current entity signature */ public function getSignature() { global $db,$conf,$mysoc; - - if(empty($conf->global->BLOCKEDLOG_ENTITY_FINGERPRINT)) { // creation of a unique fingerprint - + + if (empty($conf->global->BLOCKEDLOG_ENTITY_FINGERPRINT)) { // creation of a unique fingerprint + require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; - + $fingerprint = $this->crypt(print_r($mysoc,true).time().rand(0,1000)); - + dolibarr_set_const($db, 'BLOCKEDLOG_ENTITY_FINGERPRINT', $fingerprint, 'chaine',0,'Numeric Unique Fingerprint', $conf->entity); - - $conf->global->BLOCKEDLOG_ENTITY_FINGERPRINT= $fingerprint; + + $conf->global->BLOCKEDLOG_ENTITY_FINGERPRINT=$fingerprint; } - + return $conf->global->BLOCKEDLOG_ENTITY_FINGERPRINT; } - + } diff --git a/htdocs/blockedlog/lib/blockedlog.lib.php b/htdocs/blockedlog/lib/blockedlog.lib.php index a7fca40d116..cffac7cbff9 100644 --- a/htdocs/blockedlog/lib/blockedlog.lib.php +++ b/htdocs/blockedlog/lib/blockedlog.lib.php @@ -32,17 +32,17 @@ function blockedlogadmin_prepare_head() $h = 0; $head = array(); - + $head[$h][0] = DOL_URL_ROOT."/blockedlog/admin/blockedlog.php"; - $head[$h][1] = $langs->trans("BlockedLog"); + $head[$h][1] = $langs->trans("Setup"); $head[$h][2] = 'blockedlog'; $h++; - + $head[$h][0] = DOL_URL_ROOT."/blockedlog/admin/fingerprints.php"; $head[$h][1] = $langs->trans("Fingerprints"); $head[$h][2] = 'fingerprints'; $h++; - + $object=new stdClass(); // Show more tabs from modules diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index ce16d6b9931..223acb91fb3 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -4247,37 +4247,6 @@ else if ($id > 0 || ! empty($ref)) $delallowed = $user->rights->facture->supprimer; print $formfile->showdocuments('facture', $filename, $filedir, $urlsource, $genallowed, $delallowed, $object->modelpdf, 1, 0, 0, 28, 0, '', '', '', $soc->default_lang); - - if(!empty($conf->blockedlog->enabled) && $object->statut>0) { - ?> - - numoffiles; // Show links to link elements diff --git a/htdocs/core/modules/modBlockedLog.class.php b/htdocs/core/modules/modBlockedLog.class.php index b149471cd20..f3f3be971b5 100644 --- a/htdocs/core/modules/modBlockedLog.class.php +++ b/htdocs/core/modules/modBlockedLog.class.php @@ -43,15 +43,15 @@ class modBlockedLog extends DolibarrModules // Family can be 'crm','financial','hr','projects','products','ecm','technic','other' // It is used to group modules in module setup page - $this->family = "technic"; + $this->family = "base"; // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) $this->name = preg_replace('/^mod/i','',get_class($this)); - $this->description = "Enable a log on some business events into a reserved log. This module may be mandatory for some countries."; + $this->description = "Enable a log on some business events into a non reversible log. This module may be mandatory for some countries."; $this->version = 'development'; // 'development', 'experimental' or 'dolibarr' or version // Key used in llx_const table to save module status enabled/disabled (where MYMODULE is value of property name of module in uppercase) $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); // Where to store the module in setup page (0=common,1=interface,2=others,3=very specific) - $this->special = 1; + $this->special = 2; // Name of image file used for this module. $this->picto='technic'; diff --git a/htdocs/core/triggers/interface_50_modBlockedlog_ActionsBlockedLog.class.php b/htdocs/core/triggers/interface_50_modBlockedlog_ActionsBlockedLog.class.php index 004c4eecd78..6759d18ba5d 100644 --- a/htdocs/core/triggers/interface_50_modBlockedlog_ActionsBlockedLog.class.php +++ b/htdocs/core/triggers/interface_50_modBlockedlog_ActionsBlockedLog.class.php @@ -50,9 +50,9 @@ class InterfaceActionsBlockedLog extends DolibarrTriggers if (empty($conf->blockedlog->enabled)) { return 0; } - - if($action==='BILL_VALIDATE' || $action === 'BILL_PAYED' || $action==='BILL_UNPAYED' - || $action === 'BILL_SENTBYMAIL' || $action === 'DOWNLOAD_BILL' || $action === 'PREVIEW_BILL') { + + if($action==='BILL_VALIDATE' || $action === 'BILL_PAYED' || $action==='BILL_UNPAYED' + || $action === 'BILL_SENTBYMAIL' || $action === 'DOC_DOWNLOAD' || $action === 'DOC_PREVIEW') { $amounts= (double) $object->total_ttc; } else if($action === 'PAYMENT_CUSTOMER_CREATE' || $action === 'PAYMENT_ADD_TO_BANK') { @@ -62,8 +62,8 @@ class InterfaceActionsBlockedLog extends DolibarrTriggers $amounts+= price2num($amount); } } - - + + } else if(strpos($action,'PAYMENT')!==false) { $amounts= (double) $object->amount; @@ -71,25 +71,25 @@ class InterfaceActionsBlockedLog extends DolibarrTriggers else { return 0; // not implemented action log } - + $b=new BlockedLog($this->db); $b->action = $action; $b->amounts= $amounts; $b->setObjectData($object); - + $res = $b->create($user); - + if($res<0) { setEventMessage($b->error,'errors'); - + return -1; } else { - + return 1; } - - + + } } diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 695373e22b5..1aa79c2dced 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -467,7 +467,7 @@ Module30Desc=Invoice and credit note management for customers. Invoice managemen Module40Name=Suppliers Module40Desc=Supplier management and buying (orders and invoices) Module42Name=Logs -Module42Desc=Logging facilities (file, syslog, ...) +Module42Desc=Logging facilities (file, syslog, ...). Such logs are for technical/debug purposes. For legal purpose, see instead module 'Non Reversible Logs'. Module49Name=Editors Module49Desc=Editor management Module50Name=Products @@ -565,6 +565,8 @@ Module2900Name=GeoIPMaxmind Module2900Desc=GeoIP Maxmind conversions capabilities Module3100Name=Skype Module3100Desc=Add a Skype button into users / third parties / contacts / members cards +Module3200Name=Non Reversible Logs +Module3200Desc=Activate log of some business events into a non reversible log. Events are archived in real-time. The log is a table that can be then exported. This module may be mandatory for some countries. Module4000Name=HRM Module4000Desc=Human resources management (mangement of department, employee contracts and feelings) Module5000Name=Multi-company diff --git a/htdocs/langs/en_US/blockedlog.lang b/htdocs/langs/en_US/blockedlog.lang index fcad52508bd..7129b65257d 100644 --- a/htdocs/langs/en_US/blockedlog.lang +++ b/htdocs/langs/en_US/blockedlog.lang @@ -1,12 +1,14 @@ +BlockedLog=Non Reversible Logs Field=Field -BlockedLogDesc=This module store event for invoice and payments as block chain -FingerprintsDesc=All fingerprints stored -EntityKey=Entity Key -ShowAllFingerPrintsMightBeTooLong=Show all fingerprints (might be long) -ShowAllFingerPrintsErrorsMightBeTooLong=Show all fingerprints with error (might be long) +BlockedLogDesc=This module store event for invoice and payments into a block chain +Fingerprints=Archived events and fingerprints +FingerprintsDesc=Archived business events and fingerprints +CompanyInitialKey=Company initial key +ShowAllFingerPrintsMightBeTooLong=Show all archived logs (might be long) +ShowAllFingerPrintsErrorsMightBeTooLong=Show all archive logs with error (might be long) DownloadBlockChain=Download fingerprints -KoCheckFingerprintValidity=Fingerprint is not valid -OkCheckFingerprintValidity=Fingerprint is valid +KoCheckFingerprintValidity=Archived log is not valid. It means someone (a hacker ?) has modified some datas of this archived log after it was recorded, or has erased the previous archived record (check that line with previous # exists). +OkCheckFingerprintValidity=Archived log is valid. It means all data on this line were not modified and record follow the previous one. AddedByAuthority=Stored into remote authority NotAddedByAuthorityYet=Not yet stored into remote authority ShowDetails=Show stored details @@ -18,6 +20,7 @@ logBILL_VALIDATE=Customer bill set valid from draft logBILL_SENTBYMAIL=Customer bill send by mail BlockedlogInfoDialog=Log Details Fingerprint=Fingerprint -DownloadLogCSV=Download fingerprints CSV -logPREVIEW_BILL=Preview of a validated customer bill in order to print or download -logDOWNLOAD_BILL=Download of a validated customer bill in order to print or send \ No newline at end of file +DownloadLogCSV=Download archive logs (CSV) +logDOC_PREVIEW=Preview of a validated document in order to print or download +logDOC_DOWNLOAD=Download of a validated document in order to print or send +DataOfArchivedEvent=Full datas of archived event \ No newline at end of file diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index 6b75b957590..33b155bb64c 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -1891,7 +1891,7 @@ if (! function_exists("llxFooter")) */ function llxFooter($comment='',$zone='private') { - global $conf, $langs, $user; + global $conf, $langs, $user, $object; global $delayedhtmlcontent; // Global html output events ($mesgs, $errors, $warnings) @@ -2026,6 +2026,40 @@ if (! function_exists("llxFooter")) '; } + // Wrapper to add log when clicking on download or preview + if (! empty($conf->blockedlog->enabled) && is_object($object) && $object->id > 0 && $object->statut > 0) + { + if (in_array($object->element, array('facture'))) // Restrict for the moment to element 'facture' + { + print "\n\n"; + ?> + + \n"; print ''."\n"; From e813fd2dfa69d3ce67ab5aec2af6df34970e3c16 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 16 Jun 2017 12:57:30 +0200 Subject: [PATCH 026/227] Fix missing key import_key and extraparams --- htdocs/adherents/class/api_memberstypes.class.php | 1 - htdocs/comm/action/class/api_agendaevents.class.php | 1 - htdocs/install/mysql/migration/5.0.0-6.0.0.sql | 7 +++++-- htdocs/install/mysql/tables/llx_actioncomm.sql | 4 +++- 4 files changed, 8 insertions(+), 5 deletions(-) diff --git a/htdocs/adherents/class/api_memberstypes.class.php b/htdocs/adherents/class/api_memberstypes.class.php index 9457b910c5d..ff8064d80fb 100644 --- a/htdocs/adherents/class/api_memberstypes.class.php +++ b/htdocs/adherents/class/api_memberstypes.class.php @@ -274,7 +274,6 @@ class MembersTypes extends DolibarrApi unset($object->cotisation); unset($object->libelle); - unset($object->import_key); unset($object->array_options); unset($object->linkedObjectsIds); unset($object->context); diff --git a/htdocs/comm/action/class/api_agendaevents.class.php b/htdocs/comm/action/class/api_agendaevents.class.php index a607998cfa8..4edd656da53 100644 --- a/htdocs/comm/action/class/api_agendaevents.class.php +++ b/htdocs/comm/action/class/api_agendaevents.class.php @@ -318,7 +318,6 @@ class AgendaEvents extends DolibarrApi unset($object->usermod); unset($object->libelle); - unset($object->import_key); unset($object->array_options); unset($object->context); unset($object->canvas); diff --git a/htdocs/install/mysql/migration/5.0.0-6.0.0.sql b/htdocs/install/mysql/migration/5.0.0-6.0.0.sql index a66ef47fba6..5e46393768a 100644 --- a/htdocs/install/mysql/migration/5.0.0-6.0.0.sql +++ b/htdocs/install/mysql/migration/5.0.0-6.0.0.sql @@ -82,14 +82,17 @@ ALTER TABLE llx_ecm_files ADD UNIQUE INDEX uk_ecm_files (filepath, filename, ent ALTER TABLE llx_ecm_files ADD INDEX idx_ecm_files_label (label); +ALTER TABLE llx_expedition ADD COLUMN fk_projet integer DEFAULT NULL after fk_soc; + + ALTER TABLE llx_holiday ADD COLUMN import_key varchar(14); ALTER TABLE llx_holiday ADD COLUMN extraparams varchar(255); -ALTER TABLE llx_expedition ADD COLUMN fk_projet integer DEFAULT NULL after fk_soc; - ALTER TABLE llx_expensereport ADD COLUMN import_key varchar(14); ALTER TABLE llx_expensereport ADD COLUMN extraparams varchar(255); +ALTER TABLE llx_actioncomm ADD COLUMN import_key varchar(14); +ALTER TABLE llx_actioncomm ADD COLUMN extraparams varchar(255); ALTER TABLE llx_bank_account ADD COLUMN extraparams varchar(255); diff --git a/htdocs/install/mysql/tables/llx_actioncomm.sql b/htdocs/install/mysql/tables/llx_actioncomm.sql index 4849aacb690..48b73bcaa65 100644 --- a/htdocs/install/mysql/tables/llx_actioncomm.sql +++ b/htdocs/install/mysql/tables/llx_actioncomm.sql @@ -69,8 +69,10 @@ create table llx_actioncomm recurdateend datetime, -- no more recurring event after this date fk_element integer DEFAULT NULL, -- For link to an element (proposal, invoice, order, ...) - elementtype varchar(255) DEFAULT NULL -- For link to an element (proposal, invoice, order, ...) + elementtype varchar(255) DEFAULT NULL, -- For link to an element (proposal, invoice, order, ...) + import_key varchar(14), + extraparams varchar(255) -- for other parameters with json format )ENGINE=innodb; From 81f1a341120a85e97c718571ca5bf447a74c08c8 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 16 Jun 2017 13:06:35 +0200 Subject: [PATCH 027/227] Revert "Fix SPEC #7013 : use database type "numeric" to store monetary values" --- .../install/mysql/migration/6.0.0-7.0.0.sql | 64 ------------------- .../tables/llx_accounting_bookkeeping.sql | 10 +-- .../install/mysql/tables/llx_blockedlog.sql | 2 +- .../mysql/tables/llx_chargesociales.sql | 2 +- htdocs/install/mysql/tables/llx_commande.sql | 2 +- .../mysql/tables/llx_commande_fournisseur.sql | 2 +- htdocs/install/mysql/tables/llx_don.sql | 2 +- .../mysql/tables/llx_loan_schedule.sql | 6 +- .../mysql/tables/llx_paiementcharge.sql | 2 +- .../mysql/tables/llx_paiementfourn.sql | 2 +- .../mysql/tables/llx_payment_donation.sql | 2 +- .../tables/llx_payment_expensereport.sql | 2 +- .../install/mysql/tables/llx_payment_loan.sql | 6 +- .../mysql/tables/llx_payment_salary.sql | 4 +- .../mysql/tables/llx_prelevement_bons.sql | 2 +- .../llx_prelevement_facture_demande.sql | 2 +- .../mysql/tables/llx_prelevement_lignes.sql | 2 +- htdocs/install/mysql/tables/llx_societe.sql | 2 +- htdocs/install/mysql/tables/llx_tva.sql | 4 +- 19 files changed, 28 insertions(+), 92 deletions(-) delete mode 100644 htdocs/install/mysql/migration/6.0.0-7.0.0.sql diff --git a/htdocs/install/mysql/migration/6.0.0-7.0.0.sql b/htdocs/install/mysql/migration/6.0.0-7.0.0.sql deleted file mode 100644 index 545b52ea4a7..00000000000 --- a/htdocs/install/mysql/migration/6.0.0-7.0.0.sql +++ /dev/null @@ -1,64 +0,0 @@ --- --- Be carefull to requests order. --- This file must be loaded by calling /install/index.php page --- when current version is 6.0.0 or higher. --- --- To rename a table: ALTER TABLE llx_table RENAME TO llx_table_new; --- To add a column: ALTER TABLE llx_table ADD COLUMN newcol varchar(60) NOT NULL DEFAULT '0' AFTER existingcol; --- To rename a column: ALTER TABLE llx_table CHANGE COLUMN oldname newname varchar(60); --- To drop a column: ALTER TABLE llx_table DROP COLUMN oldname; --- To change type of field: ALTER TABLE llx_table MODIFY COLUMN name varchar(60); --- To drop a foreign key: ALTER TABLE llx_table DROP FOREIGN KEY fk_name; --- To drop an index: -- VMYSQL4.0 DROP INDEX nomindex on llx_table --- To drop an index: -- VPGSQL8.0 DROP INDEX nomindex --- To restrict request to Mysql version x.y minimum use -- VMYSQLx.y --- To restrict request to Pgsql version x.y minimum use -- VPGSQLx.y --- To make pk to be auto increment (mysql): -- VMYSQL4.3 ALTER TABLE llx_c_shipment_mode CHANGE COLUMN rowid rowid INTEGER NOT NULL AUTO_INCREMENT; --- To make pk to be auto increment (postgres): -- VPGSQL8.2 NOT POSSIBLE. MUST DELETE/CREATE TABLE --- To set a field as NULL: -- VMYSQL4.3 ALTER TABLE llx_table MODIFY COLUMN name varchar(60) NULL; --- To set a field as NULL: -- VPGSQL8.2 ALTER TABLE llx_table ALTER COLUMN name DROP NOT NULL; --- To set a field as NOT NULL: -- VMYSQL4.3 ALTER TABLE llx_table MODIFY COLUMN name varchar(60) NOT NULL; --- To set a field as NOT NULL: -- VPGSQL8.2 ALTER TABLE llx_table ALTER COLUMN name SET NOT NULL; --- To set a field as default NULL: -- VPGSQL8.2 ALTER TABLE llx_table ALTER COLUMN name SET DEFAULT NULL; --- Note: fields with type BLOB/TEXT can't have default value. --- -- VPGSQL8.2 DELETE FROM llx_usergroup_user WHERE fk_user NOT IN (SELECT rowid from llx_user); --- -- VMYSQL4.1 DELETE FROM llx_usergroup_user WHERE fk_usergroup NOT IN (SELECT rowid from llx_usergroup); - - --- Clean corrupted values for tms --- VMYSQL4.1 SET sql_mode = 'ALLOW_INVALID_DATES'; --- VMYSQL4.1 update llx_opensurvey_sondage set tms = date_fin where DATE(STR_TO_DATE(tms, '%Y-%m-%d')) IS NULL; --- VMYSQL4.1 SET sql_mode = 'NO_ZERO_DATE'; --- VMYSQL4.1 update llx_opensurvey_sondage set tms = date_fin where DATE(STR_TO_DATE(tms, '%Y-%m-%d')) IS NULL; --- Remove default not null on date_fin --- VMYSQL4.3 ALTER TABLE llx_opensurvey_sondage MODIFY COLUMN date_fin DATETIME NULL DEFAULT NULL; --- VPGSQL8.2 ALTER TABLE llx_opensurvey_sondage ALTER COLUMN date_fin DROP NOT NULL; - --- Move real to numeric for more precision for storing monetary amounts (no rouding) --- https://wiki.dolibarr.org/index.php/Langages_et_normes#Structure_des_tables_et_champs -ALTER TABLE llx_accounting_bookkeeping MODIFY COLUMN debit numeric(24,8); -ALTER TABLE llx_accounting_bookkeeping MODIFY COLUMN credit numeric(24,8); -ALTER TABLE llx_accounting_bookkeeping MODIFY COLUMN montant numeric(24,8); -ALTER TABLE llx_accounting_bookkeeping MODIFY COLUMN multicurrency_amount numeric(24,8); -ALTER TABLE llx_blockedlog MODIFY COLUMN amounts numeric(24,8); -ALTER TABLE llx_chargessociales MODIFY COLUMN amount numeric(24,8); -ALTER TABLE llx_commande MODIFY COLUMN amount_ht numeric(24,8); -ALTER TABLE llx_commande_fournisseur MODIFY COLUMN amount_ht numeric(24,8); -ALTER TABLE llx_don MODIFY COLUMN amount numeric(24,8); -ALTER TABLE llx_loan_schedule MODIFY COLUMN amount_capital numeric(24,8); -ALTER TABLE llx_loan_schedule MODIFY COLUMN amount_insurance numeric(24,8); -ALTER TABLE llx_loan_schedule MODIFY COLUMN amount_interest numeric(24,8); -ALTER TABLE llx_paiementcharge MODIFY COLUMN amount numeric(24,8); -ALTER TABLE llx_paiementfourn MODIFY COLUMN amount numeric(24,8); -ALTER TABLE llx_payment_donation MODIFY COLUMN amount numeric(24,8); -ALTER TABLE llx_payment_expensereport MODIFY COLUMN amount numeric(24,8); -ALTER TABLE llx_payment_loan MODIFY COLUMN amount_capital numeric(24,8); -ALTER TABLE llx_payment_loan MODIFY COLUMN amount_insurance numeric(24,8); -ALTER TABLE llx_payment_loan MODIFY COLUMN amount_interest numeric(24,8); -ALTER TABLE llx_payment_salary MODIFY COLUMN salary numeric(24,8); -ALTER TABLE llx_payment_salary MODIFY COLUMN amount numeric(24,8); -ALTER TABLE llx_prelevement_bons MODIFY COLUMN amount numeric(24,8); -ALTER TABLE llx_prelevement_facture_demande MODIFY COLUMN amount numeric(24,8); -ALTER TABLE llx_prelevement_lignes MODIFY COLUMN amount numeric(24,8); -ALTER TABLE llx_societe MODIFY COLUMN capital numeric(24,8); -ALTER TABLE llx_tva MODIFY COLUMN amount numeric(24,8); diff --git a/htdocs/install/mysql/tables/llx_accounting_bookkeeping.sql b/htdocs/install/mysql/tables/llx_accounting_bookkeeping.sql index 01ced5b07f4..ad1160c356d 100644 --- a/htdocs/install/mysql/tables/llx_accounting_bookkeeping.sql +++ b/htdocs/install/mysql/tables/llx_accounting_bookkeeping.sql @@ -26,17 +26,17 @@ CREATE TABLE llx_accounting_bookkeeping doc_ref varchar(300) NOT NULL, -- | facture_client/reglement_client/... reference number fk_doc integer NOT NULL, -- | facture_client/reglement_client/... rowid fk_docdet integer NOT NULL, -- | facture_client/reglement_client/... line rowid - thirdparty_code varchar(32), -- Third party code (customer or supplier) when record is saved (may help debug) + thirdparty_code varchar(32), -- Third party code (customer or supplier) when record is saved (may help debug) subledger_account varchar(32), -- FEC:CompAuxNum | account number of subledger account subledger_label varchar(255), -- FEC:CompAuxLib | label of subledger account numero_compte varchar(32) NOT NULL, -- FEC:CompteNum | account number label_compte varchar(255) NOT NULL, -- FEC:CompteLib | label of account label_operation varchar(255), -- FEC:EcritureLib | label of the operation - debit numeric(24,8) NOT NULL, -- FEC:Debit - credit numeric(24,8) NOT NULL, -- FEC:Credit - montant numeric(24,8) NOT NULL, -- FEC:Montant (Not necessary) + debit double NOT NULL, -- FEC:Debit + credit double NOT NULL, -- FEC:Credit + montant double NOT NULL, -- FEC:Montant (Not necessary) sens varchar(1) DEFAULT NULL, -- FEC:Sens (Not necessary) - multicurrency_amount numeric(24,8), -- FEC:Montantdevise + multicurrency_amount double, -- FEC:Montantdevise multicurrency_code varchar(255), -- FEC:Idevise lettering_code varchar(255), -- FEC:EcritureLet date_lettering datetime, -- FEC:DateLet diff --git a/htdocs/install/mysql/tables/llx_blockedlog.sql b/htdocs/install/mysql/tables/llx_blockedlog.sql index 59c8e262817..ae696a0d6d1 100644 --- a/htdocs/install/mysql/tables/llx_blockedlog.sql +++ b/htdocs/install/mysql/tables/llx_blockedlog.sql @@ -4,7 +4,7 @@ CREATE TABLE llx_blockedlog rowid integer AUTO_INCREMENT PRIMARY KEY, tms timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, action varchar(50), - amounts numeric(24,8) NOT NULL, + amounts real NOT NULL, signature varchar(100) NOT NULL, signature_line varchar(100) NOT NULL, element varchar(50), diff --git a/htdocs/install/mysql/tables/llx_chargesociales.sql b/htdocs/install/mysql/tables/llx_chargesociales.sql index 093b635a964..519ceacc9e5 100644 --- a/htdocs/install/mysql/tables/llx_chargesociales.sql +++ b/htdocs/install/mysql/tables/llx_chargesociales.sql @@ -34,7 +34,7 @@ create table llx_chargesociales fk_type integer NOT NULL, fk_account integer, -- bank account fk_mode_reglement integer, -- mode de reglement - amount numeric(24,8) default 0 NOT NULL, + amount real default 0 NOT NULL, paye smallint default 0 NOT NULL, periode date, fk_projet integer DEFAULT NULL, diff --git a/htdocs/install/mysql/tables/llx_commande.sql b/htdocs/install/mysql/tables/llx_commande.sql index 6964abdcd57..98740c232ac 100644 --- a/htdocs/install/mysql/tables/llx_commande.sql +++ b/htdocs/install/mysql/tables/llx_commande.sql @@ -42,7 +42,7 @@ create table llx_commande fk_user_cloture integer, -- user closing source smallint, -- not used, except by setting this to 42 for orders coming for replenishment and 0 in other case ? fk_statut smallint default 0, - amount_ht numeric(24,8) default 0, + amount_ht real default 0, remise_percent real default 0, remise_absolue real default 0, remise real default 0, diff --git a/htdocs/install/mysql/tables/llx_commande_fournisseur.sql b/htdocs/install/mysql/tables/llx_commande_fournisseur.sql index 24158903eb1..6d291dcfa00 100644 --- a/htdocs/install/mysql/tables/llx_commande_fournisseur.sql +++ b/htdocs/install/mysql/tables/llx_commande_fournisseur.sql @@ -46,7 +46,7 @@ create table llx_commande_fournisseur source smallint NOT NULL, -- not used, except by setting this to 42 for orders coming for replenishment and 0 in other case ? fk_statut smallint default 0, billed smallint default 0, - amount_ht numeric(24,8) default 0, + amount_ht real default 0, remise_percent real default 0, remise real default 0, tva double(24,8) default 0, diff --git a/htdocs/install/mysql/tables/llx_don.sql b/htdocs/install/mysql/tables/llx_don.sql index 63b2cd111ea..b7b7c89f9cd 100644 --- a/htdocs/install/mysql/tables/llx_don.sql +++ b/htdocs/install/mysql/tables/llx_don.sql @@ -28,7 +28,7 @@ create table llx_don tms timestamp, fk_statut smallint NOT NULL DEFAULT 0, -- Status of donation promise or validate datedon datetime, -- Date of the donation/promise - amount numeric(24,8) DEFAULT 0, + amount real DEFAULT 0, fk_payment integer, paid smallint default 0 NOT NULL, firstname varchar(50), diff --git a/htdocs/install/mysql/tables/llx_loan_schedule.sql b/htdocs/install/mysql/tables/llx_loan_schedule.sql index eb43238255a..c682b22f276 100644 --- a/htdocs/install/mysql/tables/llx_loan_schedule.sql +++ b/htdocs/install/mysql/tables/llx_loan_schedule.sql @@ -24,9 +24,9 @@ create table llx_loan_schedule datec datetime, -- creation date tms timestamp, datep datetime, -- payment date - amount_capital numeric(24,8) DEFAULT 0, - amount_insurance numeric(24,8) DEFAULT 0, - amount_interest numeric(24,8) DEFAULT 0, + amount_capital real DEFAULT 0, + amount_insurance real DEFAULT 0, + amount_interest real DEFAULT 0, fk_typepayment integer NOT NULL, num_payment varchar(50), note_private text, diff --git a/htdocs/install/mysql/tables/llx_paiementcharge.sql b/htdocs/install/mysql/tables/llx_paiementcharge.sql index 086bafae0fa..2efca933dba 100644 --- a/htdocs/install/mysql/tables/llx_paiementcharge.sql +++ b/htdocs/install/mysql/tables/llx_paiementcharge.sql @@ -23,7 +23,7 @@ create table llx_paiementcharge datec datetime, -- date de creation tms timestamp, datep datetime, -- payment date - amount numeric(24,8) DEFAULT 0, + amount real DEFAULT 0, fk_typepaiement integer NOT NULL, num_paiement varchar(50), note text, diff --git a/htdocs/install/mysql/tables/llx_paiementfourn.sql b/htdocs/install/mysql/tables/llx_paiementfourn.sql index 16d63a32076..0e9b1885c97 100644 --- a/htdocs/install/mysql/tables/llx_paiementfourn.sql +++ b/htdocs/install/mysql/tables/llx_paiementfourn.sql @@ -25,7 +25,7 @@ create table llx_paiementfourn tms timestamp, datec datetime, -- date de creation de l'enregistrement datep datetime, -- date de paiement - amount numeric(24,8) DEFAULT 0, -- montant + amount real DEFAULT 0, -- montant multicurrency_amount double(24,8) DEFAULT 0, -- multicurrency amount fk_user_author integer, -- auteur fk_paiement integer NOT NULL, -- moyen de paiement diff --git a/htdocs/install/mysql/tables/llx_payment_donation.sql b/htdocs/install/mysql/tables/llx_payment_donation.sql index 1859c7aa796..afa5075cd4e 100644 --- a/htdocs/install/mysql/tables/llx_payment_donation.sql +++ b/htdocs/install/mysql/tables/llx_payment_donation.sql @@ -23,7 +23,7 @@ create table llx_payment_donation datec datetime, -- date de creation tms timestamp, datep datetime, -- payment date - amount numeric(24,8) DEFAULT 0, + amount real DEFAULT 0, fk_typepayment integer NOT NULL, num_payment varchar(50), note text, diff --git a/htdocs/install/mysql/tables/llx_payment_expensereport.sql b/htdocs/install/mysql/tables/llx_payment_expensereport.sql index 1857246e22e..40e39771978 100644 --- a/htdocs/install/mysql/tables/llx_payment_expensereport.sql +++ b/htdocs/install/mysql/tables/llx_payment_expensereport.sql @@ -23,7 +23,7 @@ create table llx_payment_expensereport datec datetime, -- date de creation tms timestamp, datep datetime, -- payment date - amount numeric(24,8) DEFAULT 0, + amount real DEFAULT 0, fk_typepayment integer NOT NULL, num_payment varchar(50), note text, diff --git a/htdocs/install/mysql/tables/llx_payment_loan.sql b/htdocs/install/mysql/tables/llx_payment_loan.sql index 3b6111a7b2f..d023c039391 100644 --- a/htdocs/install/mysql/tables/llx_payment_loan.sql +++ b/htdocs/install/mysql/tables/llx_payment_loan.sql @@ -24,9 +24,9 @@ create table llx_payment_loan datec datetime, -- creation date tms timestamp, datep datetime, -- payment date - amount_capital numeric(24,8) DEFAULT 0, - amount_insurance numeric(24,8) DEFAULT 0, - amount_interest numeric(24,8) DEFAULT 0, + amount_capital real DEFAULT 0, + amount_insurance real DEFAULT 0, + amount_interest real DEFAULT 0, fk_typepayment integer NOT NULL, num_payment varchar(50), note_private text, diff --git a/htdocs/install/mysql/tables/llx_payment_salary.sql b/htdocs/install/mysql/tables/llx_payment_salary.sql index 3b6da16b9cb..38364c6812e 100644 --- a/htdocs/install/mysql/tables/llx_payment_salary.sql +++ b/htdocs/install/mysql/tables/llx_payment_salary.sql @@ -24,8 +24,8 @@ create table llx_payment_salary fk_user integer NOT NULL, datep date, -- date de paiement datev date, -- date de valeur (this field should not be here, only into bank tables) - salary numeric(24,8), -- salary of user when payment was done - amount numeric(24,8) NOT NULL DEFAULT 0, + salary real, -- salary of user when payment was done + amount real NOT NULL DEFAULT 0, fk_typepayment integer NOT NULL, num_payment varchar(50), -- ref label varchar(255), diff --git a/htdocs/install/mysql/tables/llx_prelevement_bons.sql b/htdocs/install/mysql/tables/llx_prelevement_bons.sql index 40fff2e842d..e92342eb001 100644 --- a/htdocs/install/mysql/tables/llx_prelevement_bons.sql +++ b/htdocs/install/mysql/tables/llx_prelevement_bons.sql @@ -29,7 +29,7 @@ create table llx_prelevement_bons ref varchar(12), -- reference entity integer DEFAULT 1 NOT NULL, -- multi company id datec datetime, -- date de creation - amount numeric(24,8) DEFAULT 0, -- montant total du prelevement + amount real DEFAULT 0, -- montant total du prelevement statut smallint DEFAULT 0, -- statut credite smallint DEFAULT 0, -- indique si le prelevement a ete credite note text, diff --git a/htdocs/install/mysql/tables/llx_prelevement_facture_demande.sql b/htdocs/install/mysql/tables/llx_prelevement_facture_demande.sql index 1d1b59bf3f5..3bdc0e2ed81 100644 --- a/htdocs/install/mysql/tables/llx_prelevement_facture_demande.sql +++ b/htdocs/install/mysql/tables/llx_prelevement_facture_demande.sql @@ -21,7 +21,7 @@ create table llx_prelevement_facture_demande ( rowid integer AUTO_INCREMENT PRIMARY KEY, fk_facture integer NOT NULL, - amount numeric(24,8) NOT NULL, + amount real NOT NULL, date_demande datetime NOT NULL, traite smallint DEFAULT 0, date_traite datetime, diff --git a/htdocs/install/mysql/tables/llx_prelevement_lignes.sql b/htdocs/install/mysql/tables/llx_prelevement_lignes.sql index 448b3846d71..04b6e1ebf5e 100644 --- a/htdocs/install/mysql/tables/llx_prelevement_lignes.sql +++ b/htdocs/install/mysql/tables/llx_prelevement_lignes.sql @@ -24,7 +24,7 @@ create table llx_prelevement_lignes statut smallint DEFAULT 0, client_nom varchar(255), - amount numeric(24,8) DEFAULT 0, + amount real DEFAULT 0, code_banque varchar(128), code_guichet varchar(6), number varchar(255), diff --git a/htdocs/install/mysql/tables/llx_societe.sql b/htdocs/install/mysql/tables/llx_societe.sql index 7c88a74de07..20440b692d7 100644 --- a/htdocs/install/mysql/tables/llx_societe.sql +++ b/htdocs/install/mysql/tables/llx_societe.sql @@ -64,7 +64,7 @@ create table llx_societe idprof5 varchar(128), -- IDProf5: nu for france idprof6 varchar(128), -- IDProf6: nu for france tva_intra varchar(20), -- tva - capital numeric(24,8), -- capital de la societe + capital real, -- capital de la societe fk_stcomm integer DEFAULT 0 NOT NULL, -- commercial statut note_private text, -- note_public text, -- diff --git a/htdocs/install/mysql/tables/llx_tva.sql b/htdocs/install/mysql/tables/llx_tva.sql index d2a7b67c835..9abf63d6ad9 100644 --- a/htdocs/install/mysql/tables/llx_tva.sql +++ b/htdocs/install/mysql/tables/llx_tva.sql @@ -24,11 +24,11 @@ create table llx_tva datec datetime, -- Create date datep date, -- date de paiement datev date, -- date de valeur - amount numeric(24,8) NOT NULL DEFAULT 0, + amount real NOT NULL DEFAULT 0, fk_typepayment integer NULL, num_payment varchar(50), label varchar(255), - entity integer DEFAULT 1 NOT NULL, -- multi company id + entity integer DEFAULT 1 NOT NULL, -- multi company id note text, fk_bank integer, fk_user_creat integer, -- utilisateur who create record From b228fe6a2ae6aa5ac265fcb1aca90c5247c2d4d4 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 16 Jun 2017 16:06:20 +0200 Subject: [PATCH 028/227] Fix auto focus on module page --- htdocs/admin/modules.php | 4 +++- htdocs/core/lib/functions.lib.php | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/htdocs/admin/modules.php b/htdocs/admin/modules.php index 8bea1c6dcb7..5d5886b5415 100644 --- a/htdocs/admin/modules.php +++ b/htdocs/admin/modules.php @@ -430,6 +430,8 @@ print "
\n"; if ($mode == 'common') { + dol_set_focus('#search_keyword'); + print '
'; if ($optioncss != '') print ''; print ''; @@ -441,7 +443,7 @@ if ($mode == 'common') $moreforfilter = ''; $moreforfilter.='
'; - $moreforfilter.= $langs->trans('Keyword') . ': '; + $moreforfilter.= $langs->trans('Keyword') . ': '; $moreforfilter.= '
'; $moreforfilter.='
'; $moreforfilter.= $langs->trans('Origin') . ': '.$form->selectarray('search_nature', $arrayofnatures, dol_escape_htmltag($search_nature), 1); diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index a582263185b..fd3b0012165 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -6089,12 +6089,12 @@ function dolExplodeIntoArray($string, $delimiter = ';', $kv = '=') /** * Set focus onto field with selector * - * @param string $selector Selector ('#id') + * @param string $selector Selector ('#id') to use to find the HTML input field that must get the autofocus. You must use a CSS selector, so unique id preceding with the '#' char. * @return string HTML code to set focus */ function dol_set_focus($selector) { - print ''."\n"; + print "\n".''."\n"; print ''."\n"; } From f0e234eef2e2fbc9c2425bdc7311d64f0768a1f0 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Fri, 16 Jun 2017 17:01:43 +0200 Subject: [PATCH 029/227] Fix: missing hookmanager init --- htdocs/admin/defaultvalues.php | 6 +++++- htdocs/admin/modules.php | 36 ++++++++++++++++++++++------------ htdocs/admin/translation.php | 7 +++++-- htdocs/user/group/index.php | 2 +- htdocs/user/perms.php | 12 ++++++------ 5 files changed, 40 insertions(+), 23 deletions(-) diff --git a/htdocs/admin/defaultvalues.php b/htdocs/admin/defaultvalues.php index 94682cd502f..53c22353b92 100644 --- a/htdocs/admin/defaultvalues.php +++ b/htdocs/admin/defaultvalues.php @@ -1,5 +1,6 @@ +/* Copyright (C) 2017 Laurent Destailleur + * Copyright (C) 2017 Regis Houssin * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -60,6 +61,9 @@ $urlpage = GETPOST('urlpage'); $key = GETPOST('key'); $value = GETPOST('value'); +// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context +$hookmanager->initHooks(array('admindefaultvalues','globaladmin')); + /* * Actions diff --git a/htdocs/admin/modules.php b/htdocs/admin/modules.php index 8bea1c6dcb7..1aebae10947 100644 --- a/htdocs/admin/modules.php +++ b/htdocs/admin/modules.php @@ -1,12 +1,12 @@ - * Copyright (C) 2003 Jean-Louis Bergamo - * Copyright (C) 2004-2017 Laurent Destailleur - * Copyright (C) 2004 Eric Seigne - * Copyright (C) 2005-2012 Regis Houssin - * Copyright (C) 2011 Juanjo Menent - * Copyright (C) 2015 Jean-François Ferry - * Copyright (C) 2015 Raphaël Doursenaud +/* Copyright (C) 2003-2007 Rodolphe Quiedeville + * Copyright (C) 2003 Jean-Louis Bergamo + * Copyright (C) 2004-2017 Laurent Destailleur + * Copyright (C) 2004 Eric Seigne + * Copyright (C) 2005-2017 Regis Houssin + * Copyright (C) 2011 Juanjo Menent + * Copyright (C) 2015 Jean-François Ferry + * Copyright (C) 2015 Raphaël Doursenaud * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -75,11 +75,18 @@ if ($search_version) $param.='&search_version='.urlencode($search_version); $dirins=DOL_DOCUMENT_ROOT.'/custom'; $urldolibarrmodules='https://www.dolistore.com/'; +// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context +$hookmanager->initHooks(array('adminmodules','globaladmin')); + /* * Actions */ +$parameters=array(); +$reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks +if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + if (GETPOST('buttonreset')) { $search_keyword=''; @@ -204,7 +211,7 @@ if ($action == 'set' && $user->admin) setEventMessages($msg, null, 'warnings'); } } - header("Location: modules.php?mode=".$mode.$param.($page_y?'&page_y='.$page_y:'')); + header("Location: ".$_SERVER["PHP_SELF"]."?mode=".$mode.$param.($page_y?'&page_y='.$page_y:'')); exit; } @@ -212,7 +219,7 @@ if ($action == 'reset' && $user->admin) { $result=unActivateModule($value); if ($result) setEventMessages($result, null, 'errors'); - header("Location: modules.php?mode=".$mode.$param.($page_y?'&page_y='.$page_y:'')); + header("Location: ".$_SERVER["PHP_SELF"]."?mode=".$mode.$param.($page_y?'&page_y='.$page_y:'')); exit; } @@ -474,10 +481,13 @@ if ($mode == 'common') print $hookmanager->resPrint; } + $moreforfilter=''; print '

'; - $moreforfilter=''; + $parameters=array(); + $reshook=$hookmanager->executeHooks('insertExtraHeader',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks + if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); // Show list of modules @@ -657,7 +667,7 @@ if ($mode == 'common') } else { - print ''; + print ''; print img_picto($langs->trans("Activated"),'switch_on'); print ''; } @@ -749,7 +759,7 @@ if ($mode == 'common') } } print ''."\n"; - print ''; print img_picto($langs->trans("Disabled"),'switch_off'); diff --git a/htdocs/admin/translation.php b/htdocs/admin/translation.php index 8a6c38ffe46..be48bd0c8f4 100644 --- a/htdocs/admin/translation.php +++ b/htdocs/admin/translation.php @@ -1,6 +1,6 @@ - * Copyright (C) 2009 Regis Houssin +/* Copyright (C) 2007-2016 Laurent Destailleur + * Copyright (C) 2009-2017 Regis Houssin * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -56,6 +56,9 @@ $pagenext = $page + 1; if (! $sortfield) $sortfield='lang,transkey'; if (! $sortorder) $sortorder='ASC'; +// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context +$hookmanager->initHooks(array('admintranslation','globaladmin')); + /* * Actions diff --git a/htdocs/user/group/index.php b/htdocs/user/group/index.php index 06e11caced9..e8d37801998 100644 --- a/htdocs/user/group/index.php +++ b/htdocs/user/group/index.php @@ -203,7 +203,7 @@ if ($resql) print '
'; print "\n"; - $db->free(); + $db->free($resql); } else { diff --git a/htdocs/user/perms.php b/htdocs/user/perms.php index 5d87232c928..6f89e49af5e 100644 --- a/htdocs/user/perms.php +++ b/htdocs/user/perms.php @@ -1,10 +1,10 @@ - * Copyright (C) 2002-2003 Jean-Louis Bergamo - * Copyright (C) 2004-2015 Laurent Destailleur - * Copyright (C) 2004 Eric Seigne - * Copyright (C) 2005-2017 Regis Houssin - * Copyright (C) 2012 Juanjo Menent +/* Copyright (C) 2002-2005 Rodolphe Quiedeville + * Copyright (C) 2002-2003 Jean-Louis Bergamo + * Copyright (C) 2004-2015 Laurent Destailleur + * Copyright (C) 2004 Eric Seigne + * Copyright (C) 2005-2017 Regis Houssin + * Copyright (C) 2012 Juanjo Menent * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by From 1d91ce90d33b3909c6a5e968ad0152c2b6b05735 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 17 Jun 2017 00:13:09 +0200 Subject: [PATCH 030/227] FIX image from medias directory into PDF free text --- htdocs/admin/chequereceipts.php | 2 +- htdocs/admin/commande.php | 2 +- htdocs/admin/contract.php | 2 +- htdocs/admin/expedition.php | 2 +- htdocs/admin/expensereport.php | 2 +- htdocs/admin/facture.php | 2 +- htdocs/admin/fichinter.php | 2 +- htdocs/admin/livraison.php | 2 +- htdocs/admin/propal.php | 2 +- htdocs/admin/supplier_invoice.php | 2 +- htdocs/admin/supplier_order.php | 2 +- htdocs/admin/supplier_proposal.php | 2 +- htdocs/core/lib/pdf.lib.php | 7 +++++++ 13 files changed, 19 insertions(+), 12 deletions(-) diff --git a/htdocs/admin/chequereceipts.php b/htdocs/admin/chequereceipts.php index f88dfc6f5a6..3d3db2451d2 100644 --- a/htdocs/admin/chequereceipts.php +++ b/htdocs/admin/chequereceipts.php @@ -274,7 +274,7 @@ if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) else { include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $doleditor=new DolEditor($variablename, $conf->global->$variablename,'',80,'dolibarr_details'); + $doleditor=new DolEditor($variablename, $conf->global->$variablename,'',80,'dolibarr_notes'); print $doleditor->Create(); } print ''; diff --git a/htdocs/admin/commande.php b/htdocs/admin/commande.php index f4104e2007f..e9ad5ab6ed6 100644 --- a/htdocs/admin/commande.php +++ b/htdocs/admin/commande.php @@ -559,7 +559,7 @@ if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) else { include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $doleditor=new DolEditor($variablename, $conf->global->$variablename,'',80,'dolibarr_details'); + $doleditor=new DolEditor($variablename, $conf->global->$variablename,'',80,'dolibarr_notes'); print $doleditor->Create(); } print ''; diff --git a/htdocs/admin/contract.php b/htdocs/admin/contract.php index e2f865f61f6..427b3a531c4 100644 --- a/htdocs/admin/contract.php +++ b/htdocs/admin/contract.php @@ -493,7 +493,7 @@ if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) else { include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $doleditor=new DolEditor($variablename, $conf->global->$variablename,'',80,'dolibarr_details'); + $doleditor=new DolEditor($variablename, $conf->global->$variablename,'',80,'dolibarr_notes'); print $doleditor->Create(); } print ''."\n"; diff --git a/htdocs/admin/expedition.php b/htdocs/admin/expedition.php index 12d0b7951d5..af932b94b45 100644 --- a/htdocs/admin/expedition.php +++ b/htdocs/admin/expedition.php @@ -493,7 +493,7 @@ if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) else { include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $doleditor=new DolEditor($variablename, $conf->global->$variablename,'',80,'dolibarr_details'); + $doleditor=new DolEditor($variablename, $conf->global->$variablename,'',80,'dolibarr_notes'); print $doleditor->Create(); } print "\n"; diff --git a/htdocs/admin/expensereport.php b/htdocs/admin/expensereport.php index 24aaeede5b4..cd14d472057 100644 --- a/htdocs/admin/expensereport.php +++ b/htdocs/admin/expensereport.php @@ -497,7 +497,7 @@ if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) else { include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $doleditor=new DolEditor($variablename, $conf->global->$variablename,'',80,'dolibarr_details'); + $doleditor=new DolEditor($variablename, $conf->global->$variablename,'',80,'dolibarr_notes'); print $doleditor->Create(); } print ''."\n"; diff --git a/htdocs/admin/facture.php b/htdocs/admin/facture.php index 57ff2321a12..85ee8c09934 100644 --- a/htdocs/admin/facture.php +++ b/htdocs/admin/facture.php @@ -731,7 +731,7 @@ if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) else { include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $doleditor=new DolEditor($variablename, $conf->global->$variablename,'',80,'dolibarr_details'); + $doleditor=new DolEditor($variablename, $conf->global->$variablename,'',80,'dolibarr_notes'); print $doleditor->Create(); } print ''; diff --git a/htdocs/admin/fichinter.php b/htdocs/admin/fichinter.php index 68d2d87800a..926a3651362 100644 --- a/htdocs/admin/fichinter.php +++ b/htdocs/admin/fichinter.php @@ -525,7 +525,7 @@ if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) else { include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $doleditor=new DolEditor($variablename, $conf->global->$variablename,'',80,'dolibarr_details'); + $doleditor=new DolEditor($variablename, $conf->global->$variablename,'',80,'dolibarr_notes'); print $doleditor->Create(); } print ''; diff --git a/htdocs/admin/livraison.php b/htdocs/admin/livraison.php index 0136f6cc9d9..fe41afabfb8 100644 --- a/htdocs/admin/livraison.php +++ b/htdocs/admin/livraison.php @@ -474,7 +474,7 @@ if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) else { include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $doleditor=new DolEditor($variablename, $conf->global->$variablename,'',80,'dolibarr_details'); + $doleditor=new DolEditor($variablename, $conf->global->$variablename,'',80,'dolibarr_notes'); print $doleditor->Create(); } print ''; diff --git a/htdocs/admin/propal.php b/htdocs/admin/propal.php index 8acbf19f939..2f90145f3cc 100644 --- a/htdocs/admin/propal.php +++ b/htdocs/admin/propal.php @@ -564,7 +564,7 @@ if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) else { include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $doleditor=new DolEditor($variablename, $conf->global->$variablename,'',80,'dolibarr_details'); + $doleditor=new DolEditor($variablename, $conf->global->$variablename,'',80,'dolibarr_notes'); print $doleditor->Create(); } print ''; diff --git a/htdocs/admin/supplier_invoice.php b/htdocs/admin/supplier_invoice.php index 17501cdb4f9..6d65af336b9 100644 --- a/htdocs/admin/supplier_invoice.php +++ b/htdocs/admin/supplier_invoice.php @@ -487,7 +487,7 @@ if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) else { include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $doleditor=new DolEditor($variablename, $conf->global->$variablename,'',80,'dolibarr_details'); + $doleditor=new DolEditor($variablename, $conf->global->$variablename,'',80,'dolibarr_notes'); print $doleditor->Create(); } print ''; diff --git a/htdocs/admin/supplier_order.php b/htdocs/admin/supplier_order.php index 13499af551a..21b3de68835 100644 --- a/htdocs/admin/supplier_order.php +++ b/htdocs/admin/supplier_order.php @@ -553,7 +553,7 @@ if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) else { include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $doleditor=new DolEditor($variablename, $conf->global->$variablename,'',80,'dolibarr_details'); + $doleditor=new DolEditor($variablename, $conf->global->$variablename,'',80,'dolibarr_notes'); print $doleditor->Create(); } print ''; diff --git a/htdocs/admin/supplier_proposal.php b/htdocs/admin/supplier_proposal.php index 8c52ee83dda..4e7efa4d922 100644 --- a/htdocs/admin/supplier_proposal.php +++ b/htdocs/admin/supplier_proposal.php @@ -520,7 +520,7 @@ if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) else { include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $doleditor=new DolEditor($variablename, $conf->global->$variablename,'',80,'dolibarr_details'); + $doleditor=new DolEditor($variablename, $conf->global->$variablename,'',80,'dolibarr_notes'); print $doleditor->Create(); } print ''; diff --git a/htdocs/core/lib/pdf.lib.php b/htdocs/core/lib/pdf.lib.php index 9220725dc8e..a9fb8e52734 100644 --- a/htdocs/core/lib/pdf.lib.php +++ b/htdocs/core/lib/pdf.lib.php @@ -861,6 +861,13 @@ function pdf_pagefoot(&$pdf,$outputlangs,$paramfreetext,$fromcompany,$marge_bass $substitutionarray['__FROM_EMAIL__']=$fromcompany->email; complete_substitutions_array($substitutionarray, $outputlangs, $object); $newfreetext=make_substitutions($conf->global->$paramfreetext, $substitutionarray, $outputlangs); + + // Make a change into HTML code to allow to include images from medias directory. + // + // become + // + $newfreetext=preg_replace('/()/', '\1'.DOL_DATA_ROOT.'/medias/\2\3', $newfreetext); + $line.=$outputlangs->convToOutputCharset($newfreetext); } From b240f536b5e121ac8a54bbf16ddf579ca593b3fe Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Sat, 17 Jun 2017 07:54:35 +0200 Subject: [PATCH 031/227] Fix : Accountancy - Debug and add information in database --- htdocs/accountancy/admin/accountmodel.php | 2 +- htdocs/accountancy/admin/card.php | 2 +- htdocs/accountancy/admin/categories_list.php | 2 +- htdocs/accountancy/admin/export.php | 2 +- htdocs/accountancy/admin/fiscalyear_info.php | 2 +- htdocs/accountancy/admin/importaccounts.php | 2 +- htdocs/accountancy/admin/productaccount.php | 2 +- htdocs/accountancy/bookkeeping/balance.php | 273 +++++++++--------- .../bookkeeping/balancebymonth.php | 6 +- htdocs/accountancy/bookkeeping/card.php | 18 +- htdocs/accountancy/bookkeeping/list.php | 6 +- .../accountancy/bookkeeping/listbyaccount.php | 15 +- htdocs/accountancy/bookkeeping/listbyyear.php | 18 +- .../class/accountancycategory.class.php | 4 +- .../class/accountancyexport.class.php | 20 +- .../class/accountancysystem.class.php | 2 +- .../class/accountingaccount.class.php | 2 +- .../accountancy/class/bookkeeping.class.php | 43 ++- htdocs/accountancy/customer/card.php | 2 +- htdocs/accountancy/customer/index.php | 2 +- htdocs/accountancy/customer/lines.php | 2 +- htdocs/accountancy/customer/list.php | 2 +- htdocs/accountancy/journal/bankjournal.php | 77 ++++- .../journal/expensereportsjournal.php | 15 +- .../accountancy/journal/purchasesjournal.php | 10 +- htdocs/accountancy/journal/sellsjournal.php | 14 +- htdocs/accountancy/report/result.php | 2 +- htdocs/accountancy/supplier/card.php | 2 +- htdocs/accountancy/supplier/index.php | 2 +- htdocs/accountancy/supplier/lines.php | 2 +- htdocs/accountancy/supplier/list.php | 2 +- htdocs/accountancy/tpl/export_journal.tpl.php | 2 +- .../bank/class/paymentvarious.class.php | 25 +- htdocs/compta/bank/ligne.php | 2 +- 34 files changed, 326 insertions(+), 258 deletions(-) diff --git a/htdocs/accountancy/admin/accountmodel.php b/htdocs/accountancy/admin/accountmodel.php index e22e993796f..aa6c4a71551 100644 --- a/htdocs/accountancy/admin/accountmodel.php +++ b/htdocs/accountancy/admin/accountmodel.php @@ -8,7 +8,7 @@ * Copyright (C) 2011 Remy Younes * Copyright (C) 2012-2015 Marcos García * Copyright (C) 2012 Christophe Battarel - * Copyright (C) 2011-2016 Alexandre Spangaro + * Copyright (C) 2011-2016 Alexandre Spangaro * Copyright (C) 2015 Ferran Marcet * Copyright (C) 2016 Raphaël Doursenaud * diff --git a/htdocs/accountancy/admin/card.php b/htdocs/accountancy/admin/card.php index 73e3fdf6dd9..fa3adf1301b 100644 --- a/htdocs/accountancy/admin/card.php +++ b/htdocs/accountancy/admin/card.php @@ -1,6 +1,6 @@ - * Copyright (C) 2013-2017 Alexandre Spangaro + * Copyright (C) 2013-2017 Alexandre Spangaro * Copyright (C) 2014 Florian Henry * * This program is free software; you can redistribute it and/or modify diff --git a/htdocs/accountancy/admin/categories_list.php b/htdocs/accountancy/admin/categories_list.php index b10015baa6c..7c658d2661c 100644 --- a/htdocs/accountancy/admin/categories_list.php +++ b/htdocs/accountancy/admin/categories_list.php @@ -8,7 +8,7 @@ * Copyright (C) 2011 Remy Younes * Copyright (C) 2012-2015 Marcos García * Copyright (C) 2012 Christophe Battarel - * Copyright (C) 2011-2016 Alexandre Spangaro + * Copyright (C) 2011-2016 Alexandre Spangaro * Copyright (C) 2015 Ferran Marcet * Copyright (C) 2016 Raphaël Doursenaud * diff --git a/htdocs/accountancy/admin/export.php b/htdocs/accountancy/admin/export.php index eaf69f34f1f..cdec35415fd 100644 --- a/htdocs/accountancy/admin/export.php +++ b/htdocs/accountancy/admin/export.php @@ -1,6 +1,6 @@ - * Copyright (C) 2013-2015 Alexandre Spangaro + * Copyright (C) 2013-2015 Alexandre Spangaro * Copyright (C) 2014 Florian Henry * Copyright (C) 2014 Marcos García * Copyright (C) 2014 Juanjo Menent diff --git a/htdocs/accountancy/admin/fiscalyear_info.php b/htdocs/accountancy/admin/fiscalyear_info.php index 3596d73d751..baadbdc0828 100644 --- a/htdocs/accountancy/admin/fiscalyear_info.php +++ b/htdocs/accountancy/admin/fiscalyear_info.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2014-2016 Alexandre Spangaro * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/htdocs/accountancy/admin/importaccounts.php b/htdocs/accountancy/admin/importaccounts.php index 6ae94dc8ce2..93d41b3cbc6 100644 --- a/htdocs/accountancy/admin/importaccounts.php +++ b/htdocs/accountancy/admin/importaccounts.php @@ -1,6 +1,6 @@ - * Copyright (C) 2013-2017 Alexandre Spangaro + * Copyright (C) 2013-2017 Alexandre Spangaro * Copyright (C) 2014 Florian Henry * * This program is free software; you can redistribute it and/or modify diff --git a/htdocs/accountancy/admin/productaccount.php b/htdocs/accountancy/admin/productaccount.php index 33bf067fa9e..5b614061dbc 100644 --- a/htdocs/accountancy/admin/productaccount.php +++ b/htdocs/accountancy/admin/productaccount.php @@ -1,6 +1,6 @@ - * Copyright (C) 2013-2016 Alexandre Spangaro + * Copyright (C) 2013-2016 Alexandre Spangaro * Copyright (C) 2014 Florian Henry * Copyright (C) 2014 Juanjo Menent * Copyright (C) 2015 Ari Elbaz (elarifr) diff --git a/htdocs/accountancy/bookkeeping/balance.php b/htdocs/accountancy/bookkeeping/balance.php index 3f2c472cc58..a32b739752a 100644 --- a/htdocs/accountancy/bookkeeping/balance.php +++ b/htdocs/accountancy/bookkeeping/balance.php @@ -1,7 +1,7 @@ - * Copyright (C) 2016 Florian Henry - * Copyright (C) 2016 Alexandre Spangaro +/* Copyright (C) 2016 Olivier Geffroy + * Copyright (C) 2016 Florian Henry + * Copyright (C) 2016 Alexandre Spangaro * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -100,10 +100,10 @@ if (! empty($search_accountancy_code_end)) { if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // All tests are required to be compatible with all browsers { - $search_accountancy_code_start = ''; - $search_accountancy_code_end = ''; - $search_date_start = ''; - $search_date_end = ''; + $search_accountancy_code_start = ''; + $search_accountancy_code_end = ''; + $search_date_start = ''; + $search_date_end = ''; } @@ -137,140 +137,137 @@ if ($action == 'export_csv') { } else { - $title_page = $langs->trans("AccountBalance") . (($search_date_start || $search_date_end) ? ' ' . dol_print_date($search_date_start) . '-' . dol_print_date($search_date_end) : ''); - - llxHeader('', $title_page); - - // List + $title_page = $langs->trans("AccountBalance") . (($search_date_start || $search_date_end) ? ' ' . dol_print_date($search_date_start) . '-' . dol_print_date($search_date_end) : ''); - $nbtotalofrecords = ''; - if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { - $nbtotalofrecords = $object->fetchAllBalance($sortorder, $sortfield, 0, 0, $filter); - if ($nbtotalofrecords < 0) { - setEventMessages($object->error, $object->errors, 'errors'); - } - } - - $result = $object->fetchAllBalance($sortorder, $sortfield, $limit, $offset, $filter); - if ($result < 0) { - setEventMessages($object->error, $object->errors, 'errors'); - } - - - print '
'; - - $button = ''; - print_barre_liste($title_page, $page, $_SERVER["PHP_SELF"], $options, $sortfield, $sortorder, '', $result, $result, 'title_accountancy', 0, $button); - - - $moreforfilter = ''; - - $moreforfilter .= '
'; - $moreforfilter .= $langs->trans('DateStart') . ': '; - $moreforfilter .= $form->select_date($search_date_start, 'date_start', 0, 0, 1, '', 1, 0, 1); - $moreforfilter .= $langs->trans('DateEnd') . ': '; - $moreforfilter .= $form->select_date($search_date_end, 'date_end', 0, 0, 1, '', 1, 0, 1); - $moreforfilter .= '
'; - - if (! empty($moreforfilter)) { - print '
'; - print $moreforfilter; - $parameters = array(); - $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook - print $hookmanager->resPrint; - print '
'; - } - - print ''; + llxHeader('', $title_page); - print ''; - print ''; - print ''; + + print ''; + + print ''; + print_liste_field_titre($langs->trans("AccountAccounting"), $_SERVER['PHP_SELF'], "t.numero_compte", "", $options, "", $sortfield, $sortorder); + print_liste_field_titre($langs->trans("Label"), $_SERVER['PHP_SELF'], "t.label_operation", "", $options, "", $sortfield, $sortorder); + print_liste_field_titre($langs->trans("Debit"), $_SERVER['PHP_SELF'], "t.debit", "", $options, 'align="right"', $sortfield, $sortorder); + print_liste_field_titre($langs->trans("Credit"), $_SERVER['PHP_SELF'], "t.credit", "", $options, 'align="right"', $sortfield, $sortorder); + print_liste_field_titre($langs->trans("Solde"), $_SERVER["PHP_SELF"], "", $options, "", 'align="right"', $sortfield, $sortorder); + print_liste_field_titre('', $_SERVER["PHP_SELF"], "", $options, "", 'width="60" align="center"', $sortfield, $sortorder); + print "\n"; + + $total_debit = 0; + $total_credit = 0; + $sous_total_debit = 0; + $sous_total_credit = 0; + $displayed_account = ""; + + foreach ($object->lines as $line) { + $link = ''; + $total_debit += $line->debit; + $total_credit += $line->credit; + $description = $object->get_compte_desc($line->numero_compte); // Search description of the account + $root_account_description = $object->get_compte_racine($line->numero_compte); + if (empty($description)) { + $link = '' . img_edit_add() . ''; + } + print ''; + + // Permet d'afficher le compte comptable + if ($root_account_description != $displayed_account) { + + // Affiche un Sous-Total par compte comptable + if ($displayed_account != "") { + print ''; + print "\n"; + print ''; + } + + // Affiche le compte comptable en d�but de ligne + print ""; + print ''; + print ''; + + $displayed_account = $root_account_description; + $sous_total_debit = 0; + $sous_total_credit = 0; + } + + // $object->get_compte_racine($line->numero_compte); + + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print "\n"; + + // Comptabilise le sous-total + $sous_total_debit += $line->debit; + $sous_total_credit += $line->credit; + } + + print ''; + print "\n"; + print ''; + + print ''; + print "\n"; + print ''; + + print "
'; - print $langs->trans('From'); - print $formaccounting->select_account($search_accountancy_code_start, 'search_accountancy_code_start', 1, array(), 1, 1, ''); - print ' '; - print $langs->trans('to'); - print $formaccounting->select_account($search_accountancy_code_end, 'search_accountancy_code_end', 1, array(), 1, 1, ''); - print ''; + // List + $nbtotalofrecords = ''; + if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { + $nbtotalofrecords = $object->fetchAllBalance($sortorder, $sortfield, 0, 0, $filter); + if ($nbtotalofrecords < 0) { + setEventMessages($object->error, $object->errors, 'errors'); + } + } + + $result = $object->fetchAllBalance($sortorder, $sortfield, $limit, $offset, $filter); + if ($result < 0) { + setEventMessages($object->error, $object->errors, 'errors'); + } + + print ''; + + $button = ''; + print_barre_liste($title_page, $page, $_SERVER["PHP_SELF"], $options, $sortfield, $sortorder, '', $result, $result, 'title_accountancy', 0, $button); + + $moreforfilter = ''; + + $moreforfilter .= '
'; + $moreforfilter .= $langs->trans('DateStart') . ': '; + $moreforfilter .= $form->select_date($search_date_start, 'date_start', 0, 0, 1, '', 1, 0, 1); + $moreforfilter .= $langs->trans('DateEnd') . ': '; + $moreforfilter .= $form->select_date($search_date_end, 'date_end', 0, 0, 1, '', 1, 0, 1); + $moreforfilter .= '
'; + + if (! empty($moreforfilter)) { + print '
'; + print $moreforfilter; + $parameters = array(); + $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; + print '
'; + } + + print ''; + + print ''; + print ''; + print ''; - - print ''; - - print ''; - print_liste_field_titre($langs->trans("AccountAccounting"), $_SERVER['PHP_SELF'], "t.numero_compte", "", $options, "", $sortfield, $sortorder); - print_liste_field_titre($langs->trans("Label"), $_SERVER['PHP_SELF'], "t.label_compte", "", $options, "", $sortfield, $sortorder); - print_liste_field_titre($langs->trans("Debit"), $_SERVER['PHP_SELF'], "t.debit", "", $options, 'align="right"', $sortfield, $sortorder); - print_liste_field_titre($langs->trans("Credit"), $_SERVER['PHP_SELF'], "t.credit", "", $options, 'align="right"', $sortfield, $sortorder); - print_liste_field_titre($langs->trans("Solde"), $_SERVER["PHP_SELF"], "", $options, "", 'align="right"', $sortfield, $sortorder); - print_liste_field_titre('', $_SERVER["PHP_SELF"], "", $options, "", 'width="60" align="center"', $sortfield, $sortorder); - print "\n"; - - $total_debit = 0; - $total_credit = 0; - $sous_total_debit = 0; - $sous_total_credit = 0; - $displayed_account = ""; - - foreach ($object->lines as $line) { - $link = ''; - $total_debit += $line->debit; - $total_credit += $line->credit; - $description = $object->get_compte_desc($line->numero_compte); // Search description of the account - $root_account_description = $object->get_compte_racine($line->numero_compte); - if (empty($description)) { - $link = '' . img_edit_add() . ''; - } - print ''; - - // Permet d'afficher le compte comptable - if ($root_account_description != $displayed_account) { - - // Affiche un Sous-Total par compte comptable - if ($displayed_account != "") { - print ''; - print "\n"; - print ''; - } - - // Affiche le compte comptable en d�but de ligne - print ""; - print ''; - print ''; - - $displayed_account = $root_account_description; - $sous_total_debit = 0; - $sous_total_credit = 0; - } - - // $object->get_compte_racine($line->numero_compte); - - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print "\n"; - - // Comptabilise le sous-total - $sous_total_debit += $line->debit; - $sous_total_credit += $line->credit; - } - - print ''; - print "\n"; - print ''; - - print ''; - print "\n"; - print ''; - - print "
'; + print $langs->trans('From'); + print $formaccounting->select_account($search_accountancy_code_start, 'search_accountancy_code_start', 1, array(), 1, 1, ''); + print ' '; + print $langs->trans('to'); + print $formaccounting->select_account($search_accountancy_code_end, 'search_accountancy_code_end', 1, array(), 1, 1, ''); + print ''; $searchpicto=$form->showFilterAndCheckAddButtons(0); print $searchpicto; - print '
' . $langs->trans("SubTotal") . ':' . price($sous_total_debit) . '' . price($sous_total_credit) . '' . price($sous_total_credit - $sous_total_debit) . ' 
' . $root_account_description . '
' . length_accountg($line->numero_compte) . '' . $description . '' . price($line->debit) . '' . price($line->credit) . '' . price($line->credit - $line->debit) . '' . $link; - print '
' . $langs->trans("SubTotal") . ':' . price($sous_total_debit) . '' . price($sous_total_credit) . '' . price($sous_total_credit - $sous_total_debit) . ' 
' . $langs->trans("AccountBalance") . ':' . price($total_debit) . '' . price($total_credit) . '' . price($total_credit - $total_debit) . ' 
"; - print ''; - - llxFooter(); + print '
' . $langs->trans("SubTotal") . ':' . price($sous_total_debit) . '' . price($sous_total_credit) . '' . price($sous_total_credit - $sous_total_debit) . ' 
' . $root_account_description . '
' . length_accountg($line->numero_compte) . '' . $description . '' . price($line->debit) . '' . price($line->credit) . '' . price($line->credit - $line->debit) . '' . $link; + print '
' . $langs->trans("SubTotal") . ':' . price($sous_total_debit) . '' . price($sous_total_credit) . '' . price($sous_total_credit - $sous_total_debit) . ' 
' . $langs->trans("AccountBalance") . ':' . price($total_debit) . '' . price($total_credit) . '' . price($total_credit - $total_debit) . ' 
"; + print ''; + + llxFooter(); } $db->close(); \ No newline at end of file diff --git a/htdocs/accountancy/bookkeeping/balancebymonth.php b/htdocs/accountancy/bookkeeping/balancebymonth.php index 83908f72172..1d746b4d4df 100644 --- a/htdocs/accountancy/bookkeeping/balancebymonth.php +++ b/htdocs/accountancy/bookkeeping/balancebymonth.php @@ -1,8 +1,8 @@ - * Copyright (C) 2013-2014 Alexandre Spangaro - * Copyright (C) 2014 Florian Henry - * Copyright (C) 2015 Jean-François Ferry + * Copyright (C) 2013-2014 Alexandre Spangaro + * Copyright (C) 2014 Florian Henry + * Copyright (C) 2015 Jean-François Ferry * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/htdocs/accountancy/bookkeeping/card.php b/htdocs/accountancy/bookkeeping/card.php index 5c558ca0a90..660248a46a3 100644 --- a/htdocs/accountancy/bookkeeping/card.php +++ b/htdocs/accountancy/bookkeeping/card.php @@ -52,7 +52,7 @@ $subledger_account = GETPOST('subledger_account'); if ($subledger_account == - 1) { $subledger_account = null; } -$label_compte = GETPOST('label_compte'); +$label_operation = GETPOST('label_operation'); $debit = price2num(GETPOST('debit')); $credit = price2num(GETPOST('credit')); @@ -83,7 +83,7 @@ if ($action == "confirm_update") { } else { $book->numero_compte = $account_number; $book->subledger_account = $subledger_account; - $book->label_compte = $label_compte; + $book->label_operation = $label_operation; $book->debit = $debit; $book->credit = $credit; @@ -120,7 +120,7 @@ else if ($action == "add") { $book->numero_compte = $account_number; $book->subledger_account = $subledger_account; - $book->label_compte = $label_compte; + $book->label_operation = $label_operation; $book->debit = $debit; $book->credit = $credit; $book->doc_date = GETPOST('doc_date'); @@ -182,7 +182,7 @@ else if ($action == "confirm_create") { if (! $error) { - $book->label_compte = ''; + $book->label_operation = ''; $book->debit = 0; $book->credit = 0; $book->doc_date = $date_start = dol_mktime(0, 0, 0, GETPOST('doc_datemonth'), GETPOST('doc_dateday'), GETPOST('doc_dateyear')); @@ -392,7 +392,7 @@ if ($action == 'create') { print ''; print $formaccounting->select_auxaccount($line->subledger_account, 'subledger_account', 1, 'maxwidth300'); print ''; - print ''; + print ''; print ''; print ''; print '' . price($line->montant) . ''; @@ -404,17 +404,17 @@ if ($action == 'create') { } else { print '' . length_accountg($line->numero_compte) . ''; print '' . length_accounta($line->subledger_account) . ''; - print '' . $line->label_compte . ''; + print '' . $line->label_operation . ''; print '' . price($line->debit) . ''; print '' . price($line->credit) . ''; print '' . price($line->montant) . ''; print '' . $line->sens . ''; print ''; - print ''; + print ''; print img_edit(); print ' '; - print ''; + print ''; print img_delete(); print ''; @@ -436,7 +436,7 @@ if ($action == 'create') { print ''; print $formaccounting->select_auxaccount($subledger_account, 'subledger_account', 1, 'maxwidth300'); print ''; - print ''; + print ''; print ''; print ''; print ''; diff --git a/htdocs/accountancy/bookkeeping/list.php b/htdocs/accountancy/bookkeeping/list.php index 4a7bca5e1b7..65e615cecaf 100644 --- a/htdocs/accountancy/bookkeeping/list.php +++ b/htdocs/accountancy/bookkeeping/list.php @@ -183,7 +183,7 @@ if (! empty($search_accountancy_aux_code_end)) { $param .= '&search_accountancy_aux_code_end=' . $search_accountancy_aux_code_end; } if (! empty($search_mvt_label)) { - $filter['t.label_compte'] = $search_mvt_label; + $filter['t.label_operation'] = $search_mvt_label; $param .= '&search_mvt_label=' . $search_mvt_label; } if (! empty($search_direction)) { @@ -424,7 +424,7 @@ print_liste_field_titre($langs->trans("Docdate"), $_SERVER['PHP_SELF'], "t.doc_d print_liste_field_titre($langs->trans("Docref"), $_SERVER['PHP_SELF'], "t.doc_ref", "", $param, "", $sortfield, $sortorder); print_liste_field_titre($langs->trans("AccountAccountingShort"), $_SERVER['PHP_SELF'], "t.numero_compte", "", $param, "", $sortfield, $sortorder); print_liste_field_titre($langs->trans("SubledgerAccount"), $_SERVER['PHP_SELF'], "t.subledger_account", "", $param, "", $sortfield, $sortorder); -print_liste_field_titre($langs->trans("Label"), $_SERVER['PHP_SELF'], "t.label_compte", "", $param, "", $sortfield, $sortorder); +print_liste_field_titre($langs->trans("Label"), $_SERVER['PHP_SELF'], "t.label_operation", "", $param, "", $sortfield, $sortorder); print_liste_field_titre($langs->trans("Debit"), $_SERVER['PHP_SELF'], "t.debit", "", $param, 'align="right"', $sortfield, $sortorder); print_liste_field_titre($langs->trans("Credit"), $_SERVER['PHP_SELF'], "t.credit", "", $param, 'align="right"', $sortfield, $sortorder); print_liste_field_titre($langs->trans("Codejournal"), $_SERVER['PHP_SELF'], "t.code_journal", "", $param, 'align="center"', $sortfield, $sortorder); @@ -450,7 +450,7 @@ foreach ($object->lines as $line ) { print '' . $line->doc_ref . ''; print '' . length_accountg($line->numero_compte) . ''; print '' . length_accounta($line->subledger_account) . ''; - print '' . $line->label_compte . ''; + print '' . $line->label_operation . ''; print '' . ($line->debit ? price($line->debit) : ''). ''; print '' . ($line->credit ? price($line->credit) : '') . ''; diff --git a/htdocs/accountancy/bookkeeping/listbyaccount.php b/htdocs/accountancy/bookkeeping/listbyaccount.php index 7d0ba2280ea..a1398df6fb2 100644 --- a/htdocs/accountancy/bookkeeping/listbyaccount.php +++ b/htdocs/accountancy/bookkeeping/listbyaccount.php @@ -1,9 +1,8 @@ largely based on the great work of : - * - Copyright (C) 2013-2016 Olivier Geffroy - * - Copyright (C) 2013-2016 Florian Henry - * - Copyright (C) 2013-2016 Alexandre Spangaro +/* Copyright (C) 2016 Neil Orley + * Copyright (C) 2013-2016 Olivier Geffroy + * Copyright (C) 2013-2016 Florian Henry + * Copyright (C) 2013-2017 Alexandre Spangaro * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -100,11 +99,11 @@ if (!GETPOST("button_removefilter_x") && !GETPOST("button_removefilter")) // Bot $options .= '&search_accountancy_code_start=' . $search_accountancy_code_start; } if (! empty($search_label_account)) { - $filter['t.label_compte'] = $search_label_account; + $filter['t.label_operation'] = $search_label_account; $options .= '&search_label_account=' . $search_label_account; } if (! empty($search_mvt_label)) { - $filter['t.label_compte'] = $search_mvt_label; + $filter['t.label_operation'] = $search_mvt_label; $options .= '&search_mvt_label=' . $search_mvt_label; } if (! empty($search_direction)) { @@ -312,7 +311,7 @@ foreach ( $object->lines as $line ) { // Affiche un lien vers la facture client/fournisseur $doc_ref = preg_replace('/\(.*\)/', '', $line->doc_ref); - print strlen(length_accounta($line->subledger_account)) == 0 ? '' . $line->label_compte . '' : '' . $line->label_compte . '
(' . length_accounta($line->subledger_account) . ')'; + print strlen(length_accounta($line->subledger_account)) == 0 ? '' . $line->label_operation . '' : '' . $line->label_operation . '
(' . length_accounta($line->subledger_account) . ')'; print '' . ($line->debit ? price($line->debit) :''). ''; diff --git a/htdocs/accountancy/bookkeeping/listbyyear.php b/htdocs/accountancy/bookkeeping/listbyyear.php index e7e51ae67e0..becb700761a 100644 --- a/htdocs/accountancy/bookkeeping/listbyyear.php +++ b/htdocs/accountancy/bookkeeping/listbyyear.php @@ -1,6 +1,6 @@ - * Copyright (C) 2013-2016 Alexandre Spangaro + * Copyright (C) 2013-2017 Alexandre Spangaro * Copyright (C) 2013-2016 Florian Henry * * This program is free software; you can redistribute it and/or modify @@ -61,7 +61,7 @@ $search_subledger_account_end = GETPOST('search_subledger_account_end', 'alpha') if ($search_subledger_account_end == - 1) { $search_subledger_account_end = ''; } -$search_label_compte = GETPOST('search_label_compte', 'alpha'); +$search_label_operation = GETPOST('search_label_operation', 'alpha'); $search_sens = GETPOST('search_sens', 'alpha'); $search_code_journal = GETPOST('search_code_journal', 'alpha'); @@ -93,7 +93,7 @@ if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETP $search_doc_ref = ""; $search_numero_compte = ""; $search_subledger_account = ""; - $search_label_compte = ""; + $search_label_operation = ""; $search_sens = ""; $search_code_journal = ""; } @@ -144,9 +144,9 @@ if (! empty($search_subledger_account_end)) { $filter['t.subledger_account<='] = $search_subledger_account_end; $options .= '&search_subledger_account_end=' . $search_subledger_account_end; } -if (! empty($search_label_compte)) { - $filter['t.label_compte'] = $search_label_compte; - $options .= '&search_label_compte=' . $search_label_compte; +if (! empty($search_label_operation)) { + $filter['t.label_operation'] = $search_label_operation; + $options .= '&search_label_operation=' . $search_label_operation; } if (! empty($search_sens)) { $filter['t.sens'] = $search_sens; @@ -207,7 +207,7 @@ print_liste_field_titre($langs->trans("Date"), $_SERVER['PHP_SELF'], "t.doc_date print_liste_field_titre($langs->trans("Docref"), $_SERVER['PHP_SELF'], "t.doc_ref", "", $options, "", $sortfield, $sortorder); print_liste_field_titre($langs->trans("AccountAccounting"), $_SERVER['PHP_SELF'], "t.numero_compte", "", $options, "", $sortfield, $sortorder); print_liste_field_titre($langs->trans("ThirdPartyAccount"), $_SERVER['PHP_SELF'], "t.subledger_account", "", $options, "", $sortfield, $sortorder); -print_liste_field_titre($langs->trans("Label"), $_SERVER['PHP_SELF'], "t.label_compte", "", $options, "", $sortfield, $sortorder); +print_liste_field_titre($langs->trans("Label"), $_SERVER['PHP_SELF'], "t.label_operation", "", $options, "", $sortfield, $sortorder); print_liste_field_titre($langs->trans("Debit"), $_SERVER['PHP_SELF'], "t.debit", "", $options, "", $sortfield, $sortorder); print_liste_field_titre($langs->trans("Credit"), $_SERVER['PHP_SELF'], "t.credit", "", $options, 'align="center"', $sortfield, $sortorder); print_liste_field_titre($langs->trans("Amount"), $_SERVER['PHP_SELF'], "t.montant", "", $options, 'align="center"', $sortfield, $sortorder); @@ -242,7 +242,7 @@ print ''; print ''; -print ''; +print ''; print ''; print ''; @@ -279,7 +279,7 @@ foreach ( $object->lines as $line ) { print '' . $line->doc_ref . ''; print '' . length_accountg($line->numero_compte) . ''; print '' . length_accounta($line->subledger_account) . ''; - print '' . $line->label_compte . ''; + print '' . $line->label_operation . ''; print '' . price($line->debit) . ''; print '' . price($line->credit) . ''; print '' . price($line->montant) . ''; diff --git a/htdocs/accountancy/class/accountancycategory.class.php b/htdocs/accountancy/class/accountancycategory.class.php index e4e3017ab15..db75947771e 100644 --- a/htdocs/accountancy/class/accountancycategory.class.php +++ b/htdocs/accountancy/class/accountancycategory.class.php @@ -92,7 +92,7 @@ class AccountancyCategory public function getCptBK($id) { global $conf; - $sql = "SELECT t.numero_compte, t.label_compte, t.doc_ref"; + $sql = "SELECT t.numero_compte, t.label_operation, t.doc_ref"; $sql .= " FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping as t"; $sql .= " WHERE t.numero_compte NOT IN ("; $sql .= " SELECT t.account_number"; @@ -104,7 +104,7 @@ class AccountancyCategory $sql .= " INNER JOIN " . MAIN_DB_PREFIX . "accounting_system as asy ON aa.fk_pcg_version = asy.pcg_version"; $sql .= " AND asy.rowid = " . $conf->global->CHARTOFACCOUNTS; $sql .= " AND aa.active = 1)"; - $sql .= " GROUP BY t.numero_compte, t.label_compte, t.doc_ref"; + $sql .= " GROUP BY t.numero_compte, t.label_operation, t.doc_ref"; $sql .= " ORDER BY t.numero_compte"; $this->lines_CptBk = array (); diff --git a/htdocs/accountancy/class/accountancyexport.class.php b/htdocs/accountancy/class/accountancyexport.class.php index dc2b3195ee3..a3358337889 100644 --- a/htdocs/accountancy/class/accountancyexport.class.php +++ b/htdocs/accountancy/class/accountancyexport.class.php @@ -5,7 +5,7 @@ * Copyright (C) 2015 Florian Henry * Copyright (C) 2015 Raphaël Doursenaud * Copyright (C) 2016 Pierre-Henry Favre - * Copyright (C) 2016 Alexandre Spangaro + * Copyright (C) 2016-2017 Alexandre Spangaro * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -198,7 +198,7 @@ class AccountancyExport print length_accounta($line->subledger_account) . $separator; print $line->sens . $separator; print price($line->montant) . $separator; - print $line->label_compte . $separator; + print $line->label_operation . $separator; print $line->doc_ref; print $this->end_line; } @@ -220,7 +220,7 @@ class AccountancyExport print $line->piece_num . $this->separator; print length_accountg($line->numero_compte) . $this->separator; print '' . $this->separator; - print $line->label_compte . $this->separator; + print $line->label_operation . $this->separator; print $date . $this->separator; if ($line->sens=='D') { print price($line->montant) . $this->separator; @@ -230,7 +230,7 @@ class AccountancyExport print price($line->montant) . $this->separator; } print $line->doc_ref . $this->separator; - print $line->label_compte . $this->separator; + print $line->label_operation . $this->separator; print $this->end_line; } } @@ -289,7 +289,7 @@ class AccountancyExport print price($line->debit) . $this->separator; print price($line->credit) . $this->separator; - print dol_trunc($line->label_compte, 32) . $this->separator; + print dol_trunc($line->label_operation, 32) . $this->separator; print $this->end_line; } } @@ -320,11 +320,11 @@ class AccountancyExport $Tab['date_ope'] = dol_print_date($data->doc_date, $conf->global->ACCOUNTING_EXPORT_DATE); $Tab['num_piece'] = str_pad(self::trunc($data->piece_num, 12), 12); $Tab['num_compte'] = str_pad(self::trunc($code_compta, 11), 11); - $Tab['libelle_ecriture'] = str_pad(self::trunc($data->doc_ref . $data->label_compte, 25), 25); + $Tab['libelle_ecriture'] = str_pad(self::trunc($data->doc_ref . $data->label_operation, 25), 25); $Tab['montant'] = str_pad(abs($data->montant), 13, ' ', STR_PAD_LEFT); $Tab['type_montant'] = str_pad($data->sens, 1); $Tab['vide'] = str_repeat(' ', 18); - $Tab['intitule_compte'] = str_pad(self::trunc($data->label_compte, 34), 34); + $Tab['intitule_compte'] = str_pad(self::trunc($data->label_operation, 34), 34); $Tab['end'] = 'O2003'; $Tab['end_line'] = $this->end_line; @@ -359,7 +359,7 @@ class AccountancyExport $Tab['folio'] = '000'; $Tab['date_ecriture'] = $date_ecriture; $Tab['filler'] = ' '; - $Tab['libelle_ecriture'] = str_pad(self::trunc($data->doc_ref . ' ' . $data->label_compte, 20), 20); + $Tab['libelle_ecriture'] = str_pad(self::trunc($data->doc_ref . ' ' . $data->label_operation, 20), 20); $Tab['sens'] = $data->sens; // C or D $Tab['signe_montant'] = '+'; $Tab['montant'] = str_pad(abs($data->montant), 12, '0', STR_PAD_LEFT); // TODO manage negative amount @@ -375,7 +375,7 @@ class AccountancyExport $Tab['devis'] = str_pad($conf->currency, 3); $Tab['code_journal2'] = str_pad(self::trunc($data->code_journal, 3), 3); $Tab['filler3'] = str_repeat(' ', 3); - $Tab['libelle_ecriture2'] = str_pad(self::trunc($data->doc_ref . ' ' . $data->label_compte, 32), 32); + $Tab['libelle_ecriture2'] = str_pad(self::trunc($data->doc_ref . ' ' . $data->label_operation, 32), 32); $Tab['num_piece3'] = str_pad(self::trunc($data->piece_num, 10), 10); $Tab['filler4'] = str_repeat(' ', 73); @@ -406,7 +406,7 @@ class AccountancyExport print $line->code_journal . $this->separator; print length_accountg($line->numero_compte) . $this->separator; print substr(length_accountg($line->numero_compte),0,2) . $this->separator; - print '"'.dol_trunc($line->label_compte,40,'right','UTF-8',1).'"' . $this->separator; + print '"'.dol_trunc($line->label_operation,40,'right','UTF-8',1).'"' . $this->separator; print '"'.dol_trunc($line->piece_num,15,'right','UTF-8',1).'"'.$this->separator; print price2num($line->montant).$this->separator; print $line->sens.$this->separator; diff --git a/htdocs/accountancy/class/accountancysystem.class.php b/htdocs/accountancy/class/accountancysystem.class.php index a1c90a97b5b..87d1ccd663c 100644 --- a/htdocs/accountancy/class/accountancysystem.class.php +++ b/htdocs/accountancy/class/accountancysystem.class.php @@ -1,6 +1,6 @@ - * Copyright (C) 2013-2014 Alexandre Spangaro + * Copyright (C) 2013-2014 Alexandre Spangaro * Copyright (C) 2013-2014 Florian Henry * * This program is free software; you can redistribute it and/or modify diff --git a/htdocs/accountancy/class/accountingaccount.class.php b/htdocs/accountancy/class/accountingaccount.class.php index a526f9171a6..1dad83512e3 100644 --- a/htdocs/accountancy/class/accountingaccount.class.php +++ b/htdocs/accountancy/class/accountingaccount.class.php @@ -1,6 +1,6 @@ - * Copyright (C) 2013-2016 Alexandre Spangaro + * Copyright (C) 2013-2016 Alexandre Spangaro * Copyright (C) 2013-2014 Florian Henry * Copyright (C) 2014 Juanjo Menent * Copyright (C) 2015 Ari Elbaz (elarifr) diff --git a/htdocs/accountancy/class/bookkeeping.class.php b/htdocs/accountancy/class/bookkeeping.class.php index d607c1dc287..2e826b55e08 100644 --- a/htdocs/accountancy/class/bookkeeping.class.php +++ b/htdocs/accountancy/class/bookkeeping.class.php @@ -1,6 +1,6 @@ - * Copyright (C) 2015-2016 Alexandre Spangaro +/* Copyright (C) 2014-2016 Olivier Geffroy + * Copyright (C) 2015-2017 Alexandre Spangaro * Copyright (C) 2015-2016 Florian Henry * * This program is free software; you can redistribute it and/or modify @@ -80,6 +80,7 @@ class BookKeeping extends CommonObject public $subledger_label; public $numero_compte; public $label_compte; + public $label_operation; public $debit; public $credit; public $montant; @@ -144,6 +145,9 @@ class BookKeeping extends CommonObject if (isset($this->label_compte)) { $this->label_compte = trim($this->label_compte); } + if (isset($this->label_operation)) { + $this->label_operation = trim($this->label_operation); + } if (isset($this->debit)) { $this->debit = trim($this->debit); } @@ -263,6 +267,7 @@ class BookKeeping extends CommonObject $sql .= ", subledger_label"; $sql .= ", numero_compte"; $sql .= ", label_compte"; + $sql .= ", label_operation"; $sql .= ", debit"; $sql .= ", credit"; $sql .= ", montant"; @@ -284,6 +289,7 @@ class BookKeeping extends CommonObject $sql .= ",'" . $this->db->escape($this->subledger_label) . "'"; $sql .= ",'" . $this->db->escape($this->numero_compte) . "'"; $sql .= ",'" . $this->db->escape($this->label_compte) . "'"; + $sql .= ",'" . $this->db->escape($this->label_operation) . "'"; $sql .= "," . $this->debit; $sql .= "," . $this->credit; $sql .= "," . $this->montant; @@ -393,6 +399,9 @@ class BookKeeping extends CommonObject if (isset($this->label_compte)) { $this->label_compte = trim($this->label_compte); } + if (isset($this->label_operation)) { + $this->label_operation = trim($this->label_operation); + } if (isset($this->debit)) { $this->debit = trim($this->debit); } @@ -438,6 +447,7 @@ class BookKeeping extends CommonObject $sql .= 'subledger_label,'; $sql .= 'numero_compte,'; $sql .= 'label_compte,'; + $sql .= 'label_operation,'; $sql .= 'debit,'; $sql .= 'credit,'; $sql .= 'montant,'; @@ -459,6 +469,7 @@ class BookKeeping extends CommonObject $sql .= ' ' . (! isset($this->subledger_label) ? 'NULL' : "'" . $this->db->escape($this->subledger_label) . "'") . ','; $sql .= ' ' . (! isset($this->numero_compte) ? "NULL" : "'" . $this->db->escape($this->numero_compte) . "'") . ','; $sql .= ' ' . (! isset($this->label_compte) ? 'NULL' : "'" . $this->db->escape($this->label_compte) . "'") . ','; + $sql .= ' ' . (! isset($this->label_operation) ? 'NULL' : "'" . $this->db->escape($this->label_operation) . "'") . ','; $sql .= ' ' . (! isset($this->debit) ? 'NULL' : $this->debit ). ','; $sql .= ' ' . (! isset($this->credit) ? 'NULL' : $this->credit ). ','; $sql .= ' ' . (! isset($this->montant) ? 'NULL' : $this->montant ). ','; @@ -531,6 +542,7 @@ class BookKeeping extends CommonObject $sql .= " t.subledger_label,"; $sql .= " t.numero_compte,"; $sql .= " t.label_compte,"; + $sql .= " t.label_operation,"; $sql .= " t.debit,"; $sql .= " t.credit,"; $sql .= " t.montant,"; @@ -567,6 +579,7 @@ class BookKeeping extends CommonObject $this->subledger_label = $obj->subledger_label; $this->numero_compte = $obj->numero_compte; $this->label_compte = $obj->label_compte; + $this->label_operation = $obj->label_operation; $this->debit = $obj->debit; $this->credit = $obj->credit; $this->montant = $obj->montant; @@ -621,6 +634,7 @@ class BookKeeping extends CommonObject $sql .= " t.subledger_label,"; $sql .= " t.numero_compte,"; $sql .= " t.label_compte,"; + $sql .= " t.label_operation,"; $sql .= " t.debit,"; $sql .= " t.credit,"; $sql .= " t.montant,"; @@ -644,9 +658,9 @@ class BookKeeping extends CommonObject $sqlwhere[] = $key . '=' . $value; } elseif ($key == 't.subledger_account' || $key == 't.numero_compte') { $sqlwhere[] = $key . ' LIKE \'' . $this->db->escape($value) . '%\''; - } elseif ($key == 't.label_compte') { + } elseif ($key == 't.label_operation') { $sqlwhere[] = $key . ' LIKE \'' . $this->db->escape($value) . '%\''; - }else { + } else { $sqlwhere[] = $key . ' LIKE \'%' . $this->db->escape($value) . '%\''; } } @@ -686,6 +700,7 @@ class BookKeeping extends CommonObject $line->subledger_label = $obj->subledger_label; $line->numero_compte = $obj->numero_compte; $line->label_compte = $obj->label_compte; + $line->label_operation = $obj->label_operation; $line->debit = $obj->debit; $line->credit = $obj->credit; $line->montant = $obj->montant; @@ -725,7 +740,7 @@ class BookKeeping extends CommonObject public function fetchAll($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, array $filter = array(), $filtermode = 'AND') { global $conf; - dol_syslog(__METHOD__, LOG_DEBUG); + dol_syslog(__METHOD__, LOG_DEBUG); $sql = 'SELECT'; $sql .= ' t.rowid,'; @@ -739,6 +754,7 @@ class BookKeeping extends CommonObject $sql .= " t.subledger_label,"; $sql .= " t.numero_compte,"; $sql .= " t.label_compte,"; + $sql .= " t.label_operation,"; $sql .= " t.debit,"; $sql .= " t.credit,"; $sql .= " t.montant,"; @@ -801,6 +817,7 @@ class BookKeeping extends CommonObject $line->subledger_label = $obj->subledger_label; $line->numero_compte = $obj->numero_compte; $line->label_compte = $obj->label_compte; + $line->label_operation = $obj->label_operation; $line->debit = $obj->debit; $line->credit = $obj->credit; $line->montant = $obj->montant; @@ -945,6 +962,9 @@ class BookKeeping extends CommonObject if (isset($this->label_compte)) { $this->label_compte = trim($this->label_compte); } + if (isset($this->label_operation)) { + $this->label_operation = trim($this->label_operation); + } if (isset($this->debit)) { $this->debit = trim($this->debit); } @@ -988,6 +1008,7 @@ class BookKeeping extends CommonObject $sql .= ' subledger_label = ' . (isset($this->subledger_label) ? "'" . $this->db->escape($this->subledger_label) . "'" : "null") . ','; $sql .= ' numero_compte = ' . (isset($this->numero_compte) ? "'" . $this->db->escape($this->numero_compte) . "'" : "null") . ','; $sql .= ' label_compte = ' . (isset($this->label_compte) ? "'" . $this->db->escape($this->label_compte) . "'" : "null") . ','; + $sql .= ' label_operation = ' . (isset($this->label_operation) ? "'" . $this->db->escape($this->label_operation) . "'" : "null") . ','; $sql .= ' debit = ' . (isset($this->debit) ? $this->debit : "null") . ','; $sql .= ' credit = ' . (isset($this->credit) ? $this->credit : "null") . ','; $sql .= ' montant = ' . (isset($this->montant) ? $this->montant : "null") . ','; @@ -1245,14 +1266,15 @@ class BookKeeping extends CommonObject $this->fk_doc = ''; $this->fk_docdet = ''; $this->thirdparty_code = 'CU001'; - $this->subledger_account = '410CU001'; + $this->subledger_account = '41100001'; $this->subledger_label = 'My customer company'; - $this->numero_compte = '410'; - $this->label_compte = ''; + $this->numero_compte = '411'; + $this->label_compte = 'Customer'; + $this->label_operation = 'Sales of pea'; $this->debit = 99.9; $this->credit = ''; $this->montant = ''; - $this->sens = ''; + $this->sens = 'D'; $this->fk_user_author = $user->id; $this->import_key = ''; $this->code_journal = 'VT'; @@ -1358,6 +1380,7 @@ class BookKeeping extends CommonObject $line->subledger_label = $obj->subledger_label; $line->numero_compte = $obj->numero_compte; $line->label_compte = $obj->label_compte; + $line->label_operation = $obj->label_operation; $line->debit = $obj->debit; $line->credit = $obj->credit; $line->montant = $obj->montant; @@ -1416,6 +1439,7 @@ class BookKeeping extends CommonObject $line->subledger_label = $obj->subledger_label; $line->numero_compte = $obj->numero_compte; $line->label_compte = $obj->label_compte; + $line->label_operation = $obj->label_operation; $line->debit = $obj->debit; $line->credit = $obj->credit; $line->montant = $obj->montant; @@ -1606,6 +1630,7 @@ class BookKeepingLine public $subledger_label; public $numero_compte; public $label_compte; + public $label_operation; public $debit; public $credit; public $montant; diff --git a/htdocs/accountancy/customer/card.php b/htdocs/accountancy/customer/card.php index c436fdfd088..a10cd24adc4 100644 --- a/htdocs/accountancy/customer/card.php +++ b/htdocs/accountancy/customer/card.php @@ -1,7 +1,7 @@ * Copyright (C) 2013-2014 Florian Henry - * Copyright (C) 2013-2017 Alexandre Spangaro + * Copyright (C) 2013-2017 Alexandre Spangaro * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/htdocs/accountancy/customer/index.php b/htdocs/accountancy/customer/index.php index deca83b6f12..24e066917bc 100644 --- a/htdocs/accountancy/customer/index.php +++ b/htdocs/accountancy/customer/index.php @@ -1,7 +1,7 @@ * Copyright (C) 2013-2014 Florian Henry - * Copyright (C) 2013-2016 Alexandre Spangaro + * Copyright (C) 2013-2016 Alexandre Spangaro * Copyright (C) 2014 Juanjo Menent * Copyright (C) 2015 Jean-François Ferry * diff --git a/htdocs/accountancy/customer/lines.php b/htdocs/accountancy/customer/lines.php index a5dfa3941d1..b5778ce86f2 100644 --- a/htdocs/accountancy/customer/lines.php +++ b/htdocs/accountancy/customer/lines.php @@ -1,6 +1,6 @@ - * Copyright (C) 2013-2016 Alexandre Spangaro + * Copyright (C) 2013-2016 Alexandre Spangaro * Copyright (C) 2014-2015 Ari Elbaz (elarifr) * Copyright (C) 2014-2016 Florian Henry * Copyright (C) 2014 Juanjo Menent diff --git a/htdocs/accountancy/customer/list.php b/htdocs/accountancy/customer/list.php index 56765e1ba4f..85a97fb3a1e 100644 --- a/htdocs/accountancy/customer/list.php +++ b/htdocs/accountancy/customer/list.php @@ -1,6 +1,6 @@ - * Copyright (C) 2013-2016 Alexandre Spangaro + * Copyright (C) 2013-2016 Alexandre Spangaro * Copyright (C) 2014-2015 Ari Elbaz (elarifr) * Copyright (C) 2013-2014 Florian Henry * Copyright (C) 2014 Juanjo Menent diff --git a/htdocs/accountancy/journal/bankjournal.php b/htdocs/accountancy/journal/bankjournal.php index 568edf051ff..bc27ebfa24f 100644 --- a/htdocs/accountancy/journal/bankjournal.php +++ b/htdocs/accountancy/journal/bankjournal.php @@ -50,6 +50,7 @@ require_once DOL_DOCUMENT_ROOT . '/accountancy/class/bookkeeping.class.php'; require_once DOL_DOCUMENT_ROOT . '/societe/class/client.class.php'; require_once DOL_DOCUMENT_ROOT . '/expensereport/class/expensereport.class.php'; require_once DOL_DOCUMENT_ROOT . '/expensereport/class/paymentexpensereport.class.php'; +require_once DOL_DOCUMENT_ROOT . '/compta/bank/class/paymentvarious.class.php'; $langs->load("companies"); $langs->load("other"); @@ -60,6 +61,7 @@ $langs->load('donations'); $langs->load("accountancy"); $langs->load("trips"); $langs->load("salaries"); +$langs->load("hrm"); // Multi journal $id_journal = GETPOST('id_journal', 'int'); @@ -131,6 +133,7 @@ $paymentdonstatic = new PaymentDonation($db); $paymentvatstatic = new TVA($db); $paymentsalstatic = new PaymentSalary($db); $paymentexpensereportstatic = new PaymentExpenseReport($db); +$paymentvariousstatic = new PaymentVarious($db); // Get code of finance journal $accountingjournalstatic = new AccountingJournal($db); @@ -208,7 +211,7 @@ if ($result) { // Now loop on each link of record in bank. foreach ( $links as $key => $val ) { - if (in_array($links[$key]['type'], array('sc', 'payment_sc', 'payment', 'payment_supplier', 'payment_vat', 'payment_expensereport', 'banktransfert', 'payment_donation', 'payment_salary'))) // So we excluded 'company' here + if (in_array($links[$key]['type'], array('sc', 'payment_sc', 'payment', 'payment_supplier', 'payment_vat', 'payment_expensereport', 'banktransfert', 'payment_donation', 'payment_salary', 'payment_various'))) // So we excluded 'company' here { // We save tabtype for a future use, to remember what kind of payment it is $tabtype[$obj->rowid] = $links[$key]['type']; @@ -250,9 +253,9 @@ if ($result) { $sqlmid = 'SELECT cchgsoc.accountancy_code'; $sqlmid .= " FROM " . MAIN_DB_PREFIX . "c_chargesociales cchgsoc "; - $sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "chargesociales as chgsoc ON chgsoc.fk_type=cchgsoc.id"; - $sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "paiementcharge as paycharg ON paycharg.fk_charge=chgsoc.rowid"; - $sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "bank_url as bkurl ON bkurl.url_id=paycharg.rowid"; + $sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "chargesociales as chgsoc ON chgsoc.fk_type=cchgsoc.id"; + $sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "paiementcharge as paycharg ON paycharg.fk_charge=chgsoc.rowid"; + $sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "bank_url as bkurl ON bkurl.url_id=paycharg.rowid"; $sqlmid .= " WHERE bkurl.fk_bank=" . $obj->rowid; dol_syslog("accountancy/journal/bankjournal.php:: sqlmid=" . $sqlmid, LOG_DEBUG); @@ -285,6 +288,15 @@ if ($result) { $paymentexpensereportstatic->fk_expensereport = $links[$key]['url_id']; $tabpay[$obj->rowid]["lib"] .= ' ' . $paymentexpensereportstatic->getNomUrl(2); $tabpay[$obj->rowid]["fk_expensereport"] = $paymentexpensereportstatic->id; + } else if ($links[$key]['type'] == 'payment_various') { + $paymentvariousstatic->id = $links[$key]['url_id']; + $paymentvariousstatic->ref = $links[$key]['url_id']; + $paymentvariousstatic->label = $links[$key]['label']; + $tabpay[$obj->rowid]["lib"] .= ' ' . $paymentvariousstatic->getNomUrl(2); + $tabpay[$obj->rowid]["paymentvariousid"] = $paymentvariousstatic->id; + $paymentvariousstatic->fetch($paymentvariousstatic->id); + $account_various = (! empty($paymentvariousstatic->accountancy_code) ? $paymentvariousstatic->accountancy_code : $langs->trans("CodeNotDef")); + $tabtp[$obj->rowid][$account_various] += $obj->amount; } else if ($links[$key]['type'] == 'banktransfert') { $tabpay[$obj->rowid]["lib"] .= ' ' . $langs->trans("BankTransfer"); $tabtp[$obj->rowid][$account_transfer] += $obj->amount; @@ -353,7 +365,7 @@ if (! $error && $action == 'writebookkeeping') { $bookkeeping->fk_doc = $key; $bookkeeping->fk_docdet = $val["fk_bank"]; $bookkeeping->numero_compte = $k; - $bookkeeping->label_compte = $compte->label; + $bookkeeping->label_operation = $val["label"]; $bookkeeping->montant = ($mt < 0 ? - $mt : $mt); $bookkeeping->sens = ($mt >= 0) ? 'D' : 'C'; $bookkeeping->debit = ($mt >= 0 ? $mt : 0); @@ -412,8 +424,11 @@ if (! $error && $action == 'writebookkeeping') { $bookkeeping->doc_ref = $langs->trans("Donation") . ' (' . $val["paymentdonationid"] . ')'; // Rowid of donation } else if ($tabtype[$key] == 'payment_salary') { $bookkeeping->subledger_account = ''; - $bookkeeping->label_compte = $tabuser[$key]['name']; + $bookkeeping->label_operation = $tabuser[$key]['name']; $bookkeeping->doc_ref = $langs->trans("SalaryPayment") . ' (' . $val["paymentsalid"] . ')'; // Ref of salary payment + } else if ($tabtype[$key] == 'payment_various') { + $bookkeeping->subledger_account = ''; + $bookkeeping->doc_ref = $langs->trans("VariousPayment") . ' (' . $val["paymentvariousid"] . ')'; // Ref of various payment } $result = $bookkeeping->create($user); @@ -447,7 +462,7 @@ if (! $error && $action == 'writebookkeeping') { $bookkeeping->doc_type = 'bank'; $bookkeeping->fk_doc = $key; $bookkeeping->fk_docdet = $val["fk_bank"]; - $bookkeeping->label_compte = $tabcompany[$key]['name']; + $bookkeeping->label_operation = $tabcompany[$key]['name']; $bookkeeping->montant = ($mt < 0 ? - $mt : $mt); $bookkeeping->sens = ($mt < 0) ? 'D' : 'C'; $bookkeeping->debit = ($mt < 0 ? - $mt : 0); @@ -473,7 +488,8 @@ if (! $error && $action == 'writebookkeeping') { $bookkeeping->doc_ref = $objmid->facnumber; } $bookkeeping->subledger_account = $tabcompany[$key]['code_compta']; - $bookkeeping->numero_compte = $k; + $bookkeeping->subledger_label = $tabcompany[$key]['name']; + $bookkeeping->numero_compte = $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER; } else if ($tabtype[$key] == 'payment_supplier') { // If payment is payment of supplier invoice, we get ref of invoice $sqlmid = 'SELECT facf.ref_supplier,facf.ref'; $sqlmid .= " FROM " . MAIN_DB_PREFIX . "facture_fourn facf "; @@ -487,7 +503,23 @@ if (! $error && $action == 'writebookkeeping') { $bookkeeping->doc_ref = $objmid->ref_supplier . ' (' . $objmid->ref . ')'; } $bookkeeping->subledger_account = $tabcompany[$key]['code_compta']; - $bookkeeping->numero_compte = $k; + $bookkeeping->subledger_label = $tabcompany[$key]['name']; + $bookkeeping->numero_compte = $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER; + } else if ($tabtype[$key] == 'payment_expensereport') { + $bookkeeping->subledger_account = $tabuser[$key]['accountancy_code']; + $bookkeeping->subledger_label = $tabuser[$key]['name']; + $bookkeeping->numero_compte = $conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT; + $bookkeeping->label_operation = $tabuser[$key]['name']; + $sqlmid = 'SELECT e.ref'; + $sqlmid .= " FROM " . MAIN_DB_PREFIX . "expensereport as e"; + $sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "payment_expensereport as payer ON payer.fk_expensereport=e.rowid"; + $sqlmid .= " WHERE payer.fk_expensereport=" . $val["fk_expensereport"]; + dol_syslog("accountancy/journal/bankjournal.php:: sqlmid=" . $sqlmid, LOG_DEBUG); + $resultmid = $db->query($sqlmid); + if ($resultmid) { + $objmid = $db->fetch_object($resultmid); + $bookkeeping->doc_ref = $objmid->ref; // Ref of expensereport + } } else if ($tabtype[$key] == 'payment_vat') { $bookkeeping->subledger_account = ''; $bookkeeping->numero_compte = $k; @@ -499,16 +531,19 @@ if (! $error && $action == 'writebookkeeping') { } else if ($tabtype[$key] == 'payment_salary') { $bookkeeping->subledger_account = $tabuser[$key]['accountancy_code']; $bookkeeping->numero_compte = $conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT; - $bookkeeping->label_compte = $tabuser[$key]['name']; + $bookkeeping->label_operation = $tabuser[$key]['name']; $bookkeeping->doc_ref = $langs->trans("SalaryPayment") . ' (' . $val["paymentsalid"] . ')'; // Rowid of salary payment + } else if ($tabtype[$key] == 'payment_various') { + $bookkeeping->subledger_account = ''; + $bookkeeping->numero_compte = $k; + $bookkeeping->doc_ref = $langs->trans("VariousPayment") . ' (' . $val["paymentvariousid"] . ')'; // Rowid of various payment } else if ($tabtype[$key] == 'banktransfert') { $bookkeeping->subledger_account = ''; $bookkeeping->numero_compte = $k; } else { - // FIXME Should be a temporary account ??? + // Temporary account $bookkeeping->doc_ref = $k; - //$bookkeeping->numero_compte = $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER; - $bookkeeping->numero_compte = 'CodeNotDef'; + $bookkeeping->numero_compte = $conf->global->ACCOUNTING_ACCOUNT_SUSPENSE; } $result = $bookkeeping->create($user); @@ -745,6 +780,7 @@ if (empty($action) || $action == 'view') { $vatstatic = new Tva($db); $donationstatic = new Don($db); $salarystatic = new PaymentSalary($db); + $variousstatic = new PaymentVarious($db); llxHeader('', $langs->trans("FinanceJournal")); @@ -913,7 +949,20 @@ if (empty($action) || $action == 'view') { } else dol_print_error($db); } - + elseif ($tabtype[$key] == 'payment_various') + { + $sqlmid = 'SELECT v.rowid as id'; + $sqlmid .= " FROM " . MAIN_DB_PREFIX . "payment_various as v"; + $sqlmid .= " WHERE v.rowid=" . $val["paymentvariousid"]; + dol_syslog("accountancy/journal/bankjournal.php::sqlmid=" . $sqlmid, LOG_DEBUG); + $resultmid = $db->query($sqlmid); + if ($resultmid) { + $objmid = $db->fetch_object($resultmid); + $variousstatic->fetch($objmid->id); + $ref=$variousstatic->getNomUrl(1); + } + else dol_print_error($db); + } /*$invoicestatic->id = $key; $invoicestatic->ref = $val["ref"]; diff --git a/htdocs/accountancy/journal/expensereportsjournal.php b/htdocs/accountancy/journal/expensereportsjournal.php index 3da9e09aeda..6dba1443ae1 100644 --- a/htdocs/accountancy/journal/expensereportsjournal.php +++ b/htdocs/accountancy/journal/expensereportsjournal.php @@ -136,7 +136,7 @@ if ($result) { // Define array to display all VAT rates that use this accounting account $compta_tva if ((! price2num($obj->tva_tx)) || ! empty($obj->vat_src_code)) { - $def_tva[$obj->rowid][$compta_tva][vatrate($obj->tva_tx).($obj->vat_src_code?' ('.$obj->vat_src_code.')':'')]=(vatrate($obj->tva_tx).($obj->vat_src_code?' ('.$obj->vat_src_code.')':'')); + $def_tva[$obj->rowid][$compta_tva][vatrate($obj->tva_tx).($obj->vat_src_code?' ('.$obj->vat_src_code.')':'')]=(vatrate($obj->tva_tx).($obj->vat_src_code?' ('.$obj->vat_src_code.')':'')); } $taber[$obj->rowid]["date"] = $db->jdate($obj->de); @@ -148,7 +148,7 @@ if ($result) { $tabtva[$obj->rowid][$compta_tva] += $obj->total_tva; $tabuser[$obj->rowid] = array ( 'id' => $obj->uid, - 'name' => $obj->firstname.' '.$obj->lastname, + 'name' => dolGetFirstLastname($obj->firstname, $obj->lastname), 'user_accountancy_code' => $obj->user_accountancy_account ); @@ -169,6 +169,7 @@ if ($action == 'writebookkeeping') { $db->begin(); + // Thirdparty if (! $errorforline) { foreach ( $tabttc[$key] as $k => $mt ) { @@ -183,7 +184,7 @@ if ($action == 'writebookkeeping') { $bookkeeping->fk_docdet = $val["fk_expensereportdet"]; $bookkeeping->subledger_account = $tabuser[$key]['user_accountancy_code']; $bookkeeping->subledger_label = $tabuser[$key]['user_accountancy_code']; - $bookkeeping->label_compte = $tabuser[$key]['name']; + $bookkeeping->label_operation = $tabuser[$key]['name']; $bookkeeping->numero_compte = $conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT; $bookkeeping->montant = $mt; $bookkeeping->sens = ($mt >= 0) ? 'C' : 'D'; @@ -212,9 +213,9 @@ if ($action == 'writebookkeeping') { } } + // Fees if (! $errorforline) { - // Fees foreach ( $tabht[$key] as $k => $mt ) { $accountingaccount = new AccountingAccount($db); $accountingaccount->fetch(null, $k, true); @@ -231,7 +232,7 @@ if ($action == 'writebookkeeping') { $bookkeeping->fk_docdet = $val["fk_expensereportdet"]; $bookkeeping->subledger_account = ''; $bookkeeping->subledger_label = ''; - $bookkeeping->label_compte = $accountingaccount->label; + $bookkeeping->label_operation = $accountingaccount->label; $bookkeeping->numero_compte = $k; $bookkeeping->montant = $mt; $bookkeeping->sens = ($mt < 0) ? 'C' : 'D'; @@ -261,9 +262,9 @@ if ($action == 'writebookkeeping') { } } + // VAT if (! $errorforline) { - // VAT // var_dump($tabtva); foreach ( $tabtva[$key] as $k => $mt ) { if ($mt) { @@ -277,7 +278,7 @@ if ($action == 'writebookkeeping') { $bookkeeping->fk_docdet = $val["fk_expensereportdet"]; $bookkeeping->subledger_account = ''; $bookkeeping->subledger_label = ''; - $bookkeeping->label_compte = $langs->trans("VAT"). ' '.join(', ',$def_tva[$key][$k]); + $bookkeeping->label_operation = $langs->trans("VAT"). ' '.join(', ',$def_tva[$key][$k]); $bookkeeping->numero_compte = $k; $bookkeeping->montant = $mt; $bookkeeping->sens = ($mt < 0) ? 'C' : 'D'; diff --git a/htdocs/accountancy/journal/purchasesjournal.php b/htdocs/accountancy/journal/purchasesjournal.php index 9ef1afdac38..e80ae3ba059 100644 --- a/htdocs/accountancy/journal/purchasesjournal.php +++ b/htdocs/accountancy/journal/purchasesjournal.php @@ -3,7 +3,7 @@ * Copyright (C) 2007-2010 Jean Heimburger * Copyright (C) 2011 Juanjo Menent * Copyright (C) 2012 Regis Houssin - * Copyright (C) 2013-2015 Alexandre Spangaro + * Copyright (C) 2013-2017 Alexandre Spangaro * Copyright (C) 2013-2016 Olivier Geffroy * Copyright (C) 2013-2016 Florian Henry * @@ -208,10 +208,10 @@ if ($action == 'writebookkeeping') { $companystatic->code_fournisseur = $tabcompany[$key]['code_fournisseur']; $companystatic->client = $tabcompany[$key]['code_client']; + // Thirdparty if (! $errorforline) { foreach ( $tabttc[$key] as $k => $mt ) { - // get compte id and label if ($mt) { $bookkeeping = new BookKeeping($db); $bookkeeping->doc_date = $val["date"]; @@ -223,7 +223,7 @@ if ($action == 'writebookkeeping') { $bookkeeping->thirdparty_code = $companystatic->code_fournisseur; $bookkeeping->subledger_account = $tabcompany[$key]['code_compta_fournisseur']; $bookkeeping->subledger_label = ''; // TODO To complete - $bookkeeping->label_compte = dol_trunc($companystatic->name, 16) . ' - ' . $invoicestatic->refsupplier . ' - ' . $langs->trans("subledger_account"); + $bookkeeping->label_operation = dol_trunc($companystatic->name, 16) . ' - ' . $invoicestatic->refsupplier . ' - ' . $langs->trans("subledger_account"); $bookkeeping->numero_compte = $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER; $bookkeeping->montant = $mt; $bookkeeping->sens = ($mt >= 0) ? 'C' : 'D'; @@ -272,7 +272,7 @@ if ($action == 'writebookkeeping') { $bookkeeping->thirdparty_code = $companystatic->code_fournisseur; $bookkeeping->subledger_account = ''; $bookkeeping->subledger_label = ''; - $bookkeeping->label_compte = dol_trunc($companystatic->name, 16) . ' - ' . $invoicestatic->refsupplier . ' - ' . $accountingaccount->label; + $bookkeeping->label_operation = dol_trunc($companystatic->name, 16) . ' - ' . $invoicestatic->refsupplier . ' - ' . $accountingaccount->label; $bookkeeping->numero_compte = $k; $bookkeeping->montant = $mt; $bookkeeping->sens = ($mt < 0) ? 'C' : 'D'; @@ -319,7 +319,7 @@ if ($action == 'writebookkeeping') { $bookkeeping->thirdparty_code = $companystatic->code_fournisseur; $bookkeeping->subledger_account = ''; $bookkeeping->subledger_label = ''; - $bookkeeping->label_compte = dol_trunc($companystatic->name, 16) . ' - ' . $invoicestatic->refsupplier . ' - ' . $langs->trans("VAT"). ' '.join(', ',$def_tva[$key][$k]); + $bookkeeping->label_operation = dol_trunc($companystatic->name, 16) . ' - ' . $invoicestatic->refsupplier . ' - ' . $langs->trans("VAT"). ' '.join(', ',$def_tva[$key][$k]); $bookkeeping->numero_compte = $k; $bookkeeping->montant = $mt; $bookkeeping->sens = ($mt < 0) ? 'C' : 'D'; diff --git a/htdocs/accountancy/journal/sellsjournal.php b/htdocs/accountancy/journal/sellsjournal.php index 4eb4dc72171..a50f8be7fb9 100644 --- a/htdocs/accountancy/journal/sellsjournal.php +++ b/htdocs/accountancy/journal/sellsjournal.php @@ -1,13 +1,13 @@ * Copyright (C) 2007-2010 Jean Heimburger - * Copyright (C) 2011 Juanjo Menent - * Copyright (C) 2012 Regis Houssin - * Copyright (C) 2013 Christophe Battarel + * Copyright (C) 2011 Juanjo Menent + * Copyright (C) 2012 Regis Houssin + * Copyright (C) 2013 Christophe Battarel * Copyright (C) 2013-2017 Alexandre Spangaro * Copyright (C) 2013-2016 Florian Henry * Copyright (C) 2013-2016 Olivier Geffroy - * Copyright (C) 2014 Raphaël Doursenaud + * Copyright (C) 2014 Raphaël Doursenaud * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -239,7 +239,7 @@ if ($action == 'writebookkeeping') { $bookkeeping->subledger_account = $tabcompany[$key]['code_compta']; $bookkeeping->subledger_label = ''; // TODO To complete $bookkeeping->numero_compte = $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER; - $bookkeeping->label_compte = dol_trunc($companystatic->name, 16) . ' - ' . $invoicestatic->ref . ' - ' . $langs->trans("subledger_account"); + $bookkeeping->label_operation = dol_trunc($companystatic->name, 16) . ' - ' . $invoicestatic->ref . ' - ' . $langs->trans("subledger_account"); $bookkeeping->montant = $mt; $bookkeeping->sens = ($mt >= 0) ? 'D' : 'C'; $bookkeeping->debit = ($mt >= 0) ? $mt : 0; @@ -286,7 +286,7 @@ if ($action == 'writebookkeeping') { $bookkeeping->subledger_account = ''; $bookkeeping->subledger_label = ''; $bookkeeping->numero_compte = $k; - $bookkeeping->label_compte = dol_trunc($companystatic->name, 16) . ' - ' . $invoicestatic->ref . ' - ' . $accountingaccount->label; + $bookkeeping->label_operation = dol_trunc($companystatic->name, 16) . ' - ' . $invoicestatic->ref . ' - ' . $accountingaccount->label; $bookkeeping->montant = $mt; $bookkeeping->sens = ($mt < 0) ? 'D' : 'C'; $bookkeeping->debit = ($mt < 0) ? $mt : 0; @@ -332,7 +332,7 @@ if ($action == 'writebookkeeping') { $bookkeeping->subledger_account = ''; $bookkeeping->subledger_label = ''; $bookkeeping->numero_compte = $k; - $bookkeeping->label_compte = dol_trunc($companystatic->name, 16) . ' - ' . $invoicestatic->ref . ' - ' . $langs->trans("VAT").' '.join(', ',$def_tva[$key][$k]); + $bookkeeping->label_operation = dol_trunc($companystatic->name, 16) . ' - ' . $invoicestatic->ref . ' - ' . $langs->trans("VAT").' '.join(', ',$def_tva[$key][$k]); $bookkeeping->montant = $mt; $bookkeeping->sens = ($mt < 0) ? 'D' : 'C'; $bookkeeping->debit = ($mt < 0) ? $mt : 0; diff --git a/htdocs/accountancy/report/result.php b/htdocs/accountancy/report/result.php index aa31185604a..801ba0a2007 100644 --- a/htdocs/accountancy/report/result.php +++ b/htdocs/accountancy/report/result.php @@ -1,6 +1,6 @@ - * Copyright (C) 2016 Alexandre Spangaro + * Copyright (C) 2016 Alexandre Spangaro * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/htdocs/accountancy/supplier/card.php b/htdocs/accountancy/supplier/card.php index 69a7855dfd2..b73c40ced74 100644 --- a/htdocs/accountancy/supplier/card.php +++ b/htdocs/accountancy/supplier/card.php @@ -1,7 +1,7 @@ * Copyright (C) 2005 Simon TOSSER - * Copyright (C) 2013-2017 Alexandre Spangaro + * Copyright (C) 2013-2017 Alexandre Spangaro * Copyright (C) 2013-2014 Olivier Geffroy * Copyright (C) 2013-2014 Florian Henry * Copyright (C) 2014 Juanjo Menent diff --git a/htdocs/accountancy/supplier/index.php b/htdocs/accountancy/supplier/index.php index 805c5e40420..3aa8e501bb9 100644 --- a/htdocs/accountancy/supplier/index.php +++ b/htdocs/accountancy/supplier/index.php @@ -1,7 +1,7 @@ * Copyright (C) 2013-2014 Florian Henry - * Copyright (C) 2013-2015 Alexandre Spangaro + * Copyright (C) 2013-2015 Alexandre Spangaro * Copyright (C) 2014 Juanjo Menent * * This program is free software; you can redistribute it and/or modify diff --git a/htdocs/accountancy/supplier/lines.php b/htdocs/accountancy/supplier/lines.php index 164525d5214..dc6b5e7ec20 100644 --- a/htdocs/accountancy/supplier/lines.php +++ b/htdocs/accountancy/supplier/lines.php @@ -1,6 +1,6 @@ - * Copyright (C) 2013-2017 Alexandre Spangaro + * Copyright (C) 2013-2017 Alexandre Spangaro * Copyright (C) 2014-2015 Ari Elbaz (elarifr) * Copyright (C) 2013-2016 Florian Henry * Copyright (C) 2014 Juanjo Menent diff --git a/htdocs/accountancy/supplier/list.php b/htdocs/accountancy/supplier/list.php index 26000c3fb66..93aeb1746f5 100644 --- a/htdocs/accountancy/supplier/list.php +++ b/htdocs/accountancy/supplier/list.php @@ -1,6 +1,6 @@ - * Copyright (C) 2013-2017 Alexandre Spangaro + * Copyright (C) 2013-2017 Alexandre Spangaro * Copyright (C) 2014-2015 Ari Elbaz (elarifr) * Copyright (C) 2013-2014 Florian Henry * Copyright (C) 2014 Juanjo Menent s diff --git a/htdocs/accountancy/tpl/export_journal.tpl.php b/htdocs/accountancy/tpl/export_journal.tpl.php index f69b47a8017..b5b6920e853 100644 --- a/htdocs/accountancy/tpl/export_journal.tpl.php +++ b/htdocs/accountancy/tpl/export_journal.tpl.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2015 Alexandre Spangaro * Copyright (C) 2016 Charlie Benke * * This program is free software; you can redistribute it and/or modify diff --git a/htdocs/compta/bank/class/paymentvarious.class.php b/htdocs/compta/bank/class/paymentvarious.class.php index d0c0d61a954..939872ce7fd 100644 --- a/htdocs/compta/bank/class/paymentvarious.class.php +++ b/htdocs/compta/bank/class/paymentvarious.class.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2017 Alexandre Spangaro * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -16,9 +16,9 @@ */ /** - * \file htdocs/compta/bank/class/paymentvarious.class.php - * \ingroup salaries - * \brief Class for salaries module payment + * \file htdocs/compta/bank/class/paymentvarious.class.php + * \ingroup bank + * \brief Class for various payment */ // Put here all includes required by your class file @@ -30,7 +30,7 @@ require_once DOL_DOCUMENT_ROOT .'/core/class/commonobject.class.php'; */ class PaymentVarious extends CommonObject { - //public $element='payment_various'; //!< Id that identify managed objects + //public $element='payment_various'; //!< Id that identify managed objects //public $table_element='payment_various'; //!< Name of table without prefix where object is stored var $tms; @@ -74,7 +74,6 @@ class PaymentVarious extends CommonObject $error=0; // Clean parameters - $this->fk_user=trim($this->fk_user); $this->amount=trim($this->amount); $this->label=trim($this->label); $this->note=trim($this->note); @@ -85,10 +84,9 @@ class PaymentVarious extends CommonObject $this->db->begin(); // Update request - $sql = "UPDATE ".MAIN_DB_PREFIX."payment_salary SET"; + $sql = "UPDATE ".MAIN_DB_PREFIX."payment_various SET"; $sql.= " tms=".$this->db->idate($this->tms).","; - $sql.= " fk_user=".$this->fk_user.","; $sql.= " datep=".$this->db->idate($this->datep).","; $sql.= " datev=".$this->db->idate($this->datev).","; $sql.= " sens=".$this->sens.","; @@ -114,10 +112,10 @@ class PaymentVarious extends CommonObject if (! $notrigger) { - // Call trigger - $result=$this->call_trigger('PAYMENT_SALARY_MODIFY',$user); - if ($result < 0) $error++; - // End call triggers + // Call trigger + $result=$this->call_trigger('PAYMENT_VARIOUS_MODIFY',$user); + if ($result < 0) $error++; + // End call triggers } if (! $error) @@ -178,7 +176,6 @@ class PaymentVarious extends CommonObject $this->id = $obj->rowid; $this->ref = $obj->rowid; $this->tms = $this->db->jdate($obj->tms); - $this->fk_user = $obj->fk_user; $this->datep = $this->db->jdate($obj->datep); $this->datev = $this->db->jdate($obj->datev); $this->sens = $obj->sens; @@ -252,12 +249,12 @@ class PaymentVarious extends CommonObject $this->id=0; $this->tms=''; - $this->fk_user=''; $this->datep=''; $this->datev=''; $this->sens=''; $this->amount=''; $this->label=''; + $this->accountancy_code=''; $this->note=''; $this->fk_bank=''; $this->fk_user_author=''; diff --git a/htdocs/compta/bank/ligne.php b/htdocs/compta/bank/ligne.php index b50bf07d31a..99362167a07 100644 --- a/htdocs/compta/bank/ligne.php +++ b/htdocs/compta/bank/ligne.php @@ -49,7 +49,7 @@ $confirm=GETPOST('confirm','alpha'); $rowid=GETPOST("rowid",'int'); $orig_account=GETPOST("orig_account"); $backtopage=GETPOST('backtopage'); -$cancel=GETPOSt('cancel'); +$cancel=GETPOST('cancel'); // Security check $fieldvalue = (! empty($id) ? $id : (! empty($ref) ? $ref :'')); From 5320ebc0515e865553004f2febe718b3a46b9620 Mon Sep 17 00:00:00 2001 From: BENKE Charlene Date: Sat, 17 Jun 2017 10:16:52 +0200 Subject: [PATCH 032/227] getTotalWeightVolume : add conversion Lb & oz to KG New conversion value : Oz once Little az a wizzard... --- htdocs/core/class/commonobject.class.php | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 3ac7cb6ffb3..bd5d8a6b831 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -3097,9 +3097,18 @@ abstract class CommonObject $trueWeightUnit=pow(10, $weightUnit); $totalWeight += $weight * $qty * $trueWeightUnit; } - else - { - $totalWeight += $weight * $qty; // This may be wrong if we mix different units + else { + if ($weight_units == 99) { + // conversion 1 Livre = 0.45359237 KG + $trueWeightUnit = 0.45359237; + $totalWeight += $weight * $qty * $trueWeightUnit; + } elseif ($weight_units == 98) { + // conversion 1 once = 0.0283495 KG + $trueWeightUnit = 0.0283495; + $totalWeight += $weight * $qty * $trueWeightUnit; + } + else + $totalWeight += $weight * $qty; // This may be wrong if we mix different units } if ($volume_units < 50) // >50 means a standard unit (power of 10 of official unit), > 50 means an exotic unit (like inch) { From 5b7a8e9c90f82b4abe7c0a4dff84603b16f5884f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 17 Jun 2017 10:17:36 +0200 Subject: [PATCH 033/227] Fix missing signature when sending email from user card --- htdocs/commande/card.php | 25 ++++++++----- htdocs/core/class/html.formmail.class.php | 6 ++-- htdocs/langs/en_US/other.lang | 1 + htdocs/user/card.php | 43 ++++------------------- 4 files changed, 28 insertions(+), 47 deletions(-) diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index 83135a8c0f5..f837119730c 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -2621,6 +2621,19 @@ if ($action == 'create' && $user->rights->commande->creer) $outputlangs->load('commercial'); } + // Show email form + + // By default if $action=='presend' + $titreform='SendOrderByMail'; + $topicmail=''; + if (empty($object->ref_client)) { + $topicmail = $outputlangs->trans('SendOrderRef', '__ORDERREF__'); + } else if (! empty($object->ref_client)) { + $topicmail = $outputlangs->trans('SendOrderRef', '__ORDERREF__ (__REFCLIENT__)'); + } + $action='send'; + $modelmail='order_send'; + // Build document if it not exists if (! $file || ! is_readable($file)) { $result = $object->generateDocument(GETPOST('model') ? GETPOST('model') : $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); @@ -2635,7 +2648,7 @@ if ($action == 'create' && $user->rights->commande->creer) print '
'; print '
'; print '
'; - print load_fiche_titre($langs->trans('SendOrderByMail')); + print load_fiche_titre($langs->trans($titreform)); dol_fiche_head(''); @@ -2662,11 +2675,7 @@ if ($action == 'create' && $user->rights->commande->creer) $formmail->withto = GETPOST('sendto') ? GETPOST('sendto') : $liste; $formmail->withtocc = $liste; $formmail->withtoccc = $conf->global->MAIN_EMAIL_USECCC; - if (empty($object->ref_client)) { - $formmail->withtopic = $outputlangs->trans('SendOrderRef', '__ORDERREF__'); - } else if (! empty($object->ref_client)) { - $formmail->withtopic = $outputlangs->trans('SendOrderRef', '__ORDERREF__ (__REFCLIENT__)'); - } + $formmail->withtopic = $topicmail; $formmail->withfile = 2; $formmail->withbody = 1; $formmail->withdeliveryreceipt = 1; @@ -2696,8 +2705,8 @@ if ($action == 'create' && $user->rights->commande->creer) } // Tableau des parametres complementaires - $formmail->param['action'] = 'send'; - $formmail->param['models'] = 'order_send'; + $formmail->param['action'] = $action; + $formmail->param['models'] = $modelmail; $formmail->param['models_id']=GETPOST('modelmailselected','int'); $formmail->param['orderid'] = $object->id; $formmail->param['returnurl'] = $_SERVER["PHP_SELF"] . '?id=' . $object->id; diff --git a/htdocs/core/class/html.formmail.class.php b/htdocs/core/class/html.formmail.class.php index 860d3fcfb1c..d59ac6c25af 100644 --- a/htdocs/core/class/html.formmail.class.php +++ b/htdocs/core/class/html.formmail.class.php @@ -288,14 +288,15 @@ class FormMail extends Form $outputlangs->load('other'); } - // Get message template + // Get message template for $this->param["models"] into c_email_templates $model_id=0; if (array_key_exists('models_id',$this->param)) { $model_id=$this->param["models_id"]; } $arraydefaultmessage=$this->getEMailTemplate($this->db, $this->param["models"], $user, $outputlangs, $model_id); - //var_dump($arraydefaultmessage); + //var_dump($this->param["models"]); + //var_dump($arraydefaultmessage); $out.= "\n".'
'."\n"; if ($this->withform == 1) @@ -876,6 +877,7 @@ class FormMail extends Form elseif ($type_template=='shipping_send') { $defaultmessage=$outputlangs->transnoentities("PredefinedMailContentSendShipping"); } elseif ($type_template=='fichinter_send') { $defaultmessage=$outputlangs->transnoentities("PredefinedMailContentSendFichInter"); } elseif ($type_template=='thirdparty') { $defaultmessage=$outputlangs->transnoentities("PredefinedMailContentThirdparty"); } + elseif ($type_template=='user') { $defaultmessage=$outputlangs->transnoentities("PredefinedMailContentUser"); } $ret['label']='default'; $ret['topic']=''; diff --git a/htdocs/langs/en_US/other.lang b/htdocs/langs/en_US/other.lang index a14bfffffb6..b151614ce3c 100644 --- a/htdocs/langs/en_US/other.lang +++ b/htdocs/langs/en_US/other.lang @@ -81,6 +81,7 @@ PredefinedMailContentSendSupplierInvoice=__CONTACTCIVNAME__\n\nYou will find her PredefinedMailContentSendShipping=__CONTACTCIVNAME__\n\nYou will find here the shipping __SHIPPINGREF__\n\n__PERSONALIZED__Sincerely\n\n__SIGNATURE__ PredefinedMailContentSendFichInter=__CONTACTCIVNAME__\n\nYou will find here the intervention __FICHINTERREF__\n\n__PERSONALIZED__Sincerely\n\n__SIGNATURE__ PredefinedMailContentThirdparty=__CONTACTCIVNAME__\n\n__PERSONALIZED__\n\n__SIGNATURE__ +PredefinedMailContentUser=aa__PERSONALIZED__\n\n__SIGNATURE__ DemoDesc=Dolibarr is a compact ERP/CRM supporting several business modules. A demo showcasing all modules makes no sense as this scenario never occurs (several hundred available). So, several demo profiles are available. ChooseYourDemoProfil=Choose the demo profile that best suits your needs... ChooseYourDemoProfilMore=...or build your own profile
(manual module selection) diff --git a/htdocs/user/card.php b/htdocs/user/card.php index 089820da442..a2938a89712 100644 --- a/htdocs/user/card.php +++ b/htdocs/user/card.php @@ -1659,13 +1659,11 @@ else } if ($action == 'presend') { - /* - * Affiche formulaire mail - */ + // Show email form // By default if $action=='presend' $titreform='SendMail'; - $topicmail=''; + $topicmail=1; $action='send'; $modelmail='user'; @@ -1680,9 +1678,8 @@ else $newlang = ''; if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST['lang_id'])) $newlang = $_REQUEST['lang_id']; - - if ($conf->global->MAIN_MULTILANGS && empty($newlang)) - $newlang = $object->default_lang; + //if ($conf->global->MAIN_MULTILANGS && empty($newlang)) + // $newlang = $object->thirdparty->default_lang; // Cree l'objet formulaire mail include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php'; @@ -1701,7 +1698,7 @@ else $formmail->frommail=dolAddEmailTrackId($formmail->frommail, 'thi'.$object->id); } $formmail->withfrom=1; - $formmail->withtopic=1; + $formmail->withtopic=$topicmail; $formmail->withto=GETPOST('sendto')?GETPOST('sendto'):$object->email; $formmail->withtofree=1; $formmail->withtocc=1; @@ -1711,37 +1708,9 @@ else $formmail->withdeliveryreceipt=1; $formmail->withcancel=1; // Tableau des substitutions - //$formmail->setSubstitFromObject($object); + $formmail->setSubstitFromObject($object); $formmail->substit['__LASTNAME__']=$object->lastname; $formmail->substit['__FIRSTNAME__']=$object->firstname; - $formmail->substit['__SIGNATURE__']=$user->signature; - $formmail->substit['__PERSONALIZED__']=''; - - //Find the good contact adress - /* - $custcontact=''; - $contactarr=array(); - $contactarr=$object->liste_contact(-1,'external'); - - if (is_array($contactarr) && count($contactarr)>0) - { - foreach($contactarr as $contact) - { - if ($contact['libelle']==$langs->trans('TypeContact_facture_external_BILLING')) { - - require_once DOL_DOCUMENT_ROOT . '/contact/class/contact.class.php'; - - $contactstatic=new Contact($db); - $contactstatic->fetch($contact['id']); - $custcontact=$contactstatic->getFullName($langs,1); - } - } - - if (!empty($custcontact)) { - $formmail->substit['__CONTACTCIVNAME__']=$custcontact; - } - }*/ - // Tableau des parametres complementaires du post $formmail->param['action']=$action; From e98bc90489b8c9085904ffc7762cd0b63e48ada8 Mon Sep 17 00:00:00 2001 From: BENKE Charlene Date: Sat, 17 Jun 2017 10:18:59 +0200 Subject: [PATCH 034/227] introduce OZ : once weight --- htdocs/product/class/html.formproduct.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/product/class/html.formproduct.class.php b/htdocs/product/class/html.formproduct.class.php index 01064c8ffa3..1dbfbc7662f 100644 --- a/htdocs/product/class/html.formproduct.class.php +++ b/htdocs/product/class/html.formproduct.class.php @@ -307,7 +307,7 @@ class FormProduct $return=''; $measuring_units=array(); - if ($measuring_style == 'weight') $measuring_units=array(-6=>1,-3=>1,0=>1,3=>1,99=>1); + if ($measuring_style == 'weight') $measuring_units=array(-6=>1,-3=>1,0=>1,3=>1,98=>1,99=>1); else if ($measuring_style == 'size') $measuring_units=array(-3=>1,-2=>1,-1=>1,0=>1,98=>1,99=>1); else if ($measuring_style == 'surface') $measuring_units=array(-6=>1,-4=>1,-2=>1,0=>1,98=>1,99=>1); else if ($measuring_style == 'volume') $measuring_units=array(-9=>1,-6=>1,-3=>1,0=>1,88=>1,89=>1,97=>1,99=>1,/* 98=>1 */); // Liter is not used as already available with dm3 From 17247c64f0fbe50c0720e5c13c70965892ae18e9 Mon Sep 17 00:00:00 2001 From: BENKE Charlene Date: Sat, 17 Jun 2017 10:26:01 +0200 Subject: [PATCH 035/227] add WeightUnitonce --- htdocs/core/lib/product.lib.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/core/lib/product.lib.php b/htdocs/core/lib/product.lib.php index 5aec64f3ce0..16bedc4d346 100644 --- a/htdocs/core/lib/product.lib.php +++ b/htdocs/core/lib/product.lib.php @@ -441,7 +441,8 @@ function measuring_units_string($unit,$measuring_style='') $measuring_units[0] = $langs->transnoentitiesnoconv("WeightUnitkg"); $measuring_units[-3] = $langs->transnoentitiesnoconv("WeightUnitg"); $measuring_units[-6] = $langs->transnoentitiesnoconv("WeightUnitmg"); - $measuring_units[99] = $langs->transnoentitiesnoconv("WeightUnitpound"); + $measuring_units[98] = $langs->transnoentitiesnoconv("WeightUnitonce"); + $measuring_units[99] = $langs->transnoentitiesnoconv("WeightUnitpound"); } else if ($measuring_style == 'size') { From f0bc72cda4aa3864dcfaba252537a3005027bad8 Mon Sep 17 00:00:00 2001 From: BENKE Charlene Date: Sat, 17 Jun 2017 10:27:00 +0200 Subject: [PATCH 036/227] WeightUnitonce translation --- htdocs/langs/en_US/other.lang | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/langs/en_US/other.lang b/htdocs/langs/en_US/other.lang index a14bfffffb6..120b1dcd790 100644 --- a/htdocs/langs/en_US/other.lang +++ b/htdocs/langs/en_US/other.lang @@ -123,6 +123,7 @@ WeightUnitkg=kg WeightUnitg=g WeightUnitmg=mg WeightUnitpound=pound +WeightUnitonce=once Length=Length LengthUnitm=m LengthUnitdm=dm From bebe7baa80990fa25f37b25c5ac8620cbf90ea6c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 17 Jun 2017 10:44:08 +0200 Subject: [PATCH 037/227] Fix images into medias not reabable into send emails --- htdocs/core/actions_sendmails.inc.php | 31 ++++++++++++++++++--------- htdocs/core/lib/pdf.lib.php | 2 +- htdocs/langs/en_US/errors.lang | 1 + 3 files changed, 23 insertions(+), 11 deletions(-) diff --git a/htdocs/core/actions_sendmails.inc.php b/htdocs/core/actions_sendmails.inc.php index dded23e6cbf..7bb3e8aec49 100644 --- a/htdocs/core/actions_sendmails.inc.php +++ b/htdocs/core/actions_sendmails.inc.php @@ -31,7 +31,7 @@ /* * Add file in email form -*/ + */ if (GETPOST('addfile')) { $trackid = GETPOST('trackid','aZ09'); @@ -137,7 +137,7 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO { $sendtosocid=$possibleaccounts[1]['id']; $result=$object->fetch($sendtosocid); - + setEventMessages($langs->trans('ErrorFoundMoreThanOneRecordWithEmail',$_POST['sendto'],$object->name), null, 'mesgs'); } else @@ -229,7 +229,12 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO if (dol_strlen($sendto)) { - require_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php'; + // Define $urlwithroot + $urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT,'/').'$/i','',trim($dolibarr_main_url_root)); + $urlwithroot=$urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file + //$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current + + require_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php'; $langs->load("commercial"); @@ -254,11 +259,17 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO $replyto = $_POST['replytoname']. ' <' . $_POST['replytomail'].'>'; $message = $_POST['message']; - + + // Make a change into HTML code to allow to include images from medias directory with an external reabable URL. + // + // become + // + $message=preg_replace('/()/', '\1'.$urlwithroot.'/viewimage.php\2modulepart=medias\3file=\4\5', $message); + $sendtobcc= GETPOST('sendtoccc'); - if ($mode == 'emailfromproposal') $sendtobcc .= (empty($conf->global->MAIN_MAIL_AUTOCOPY_PROPOSAL_TO) ? '' : (($sendtobcc?", ":"").$conf->global->MAIN_MAIL_AUTOCOPY_PROPOSAL_TO)); - if ($mode == 'emailfromorder') $sendtobcc .= (empty($conf->global->MAIN_MAIL_AUTOCOPY_ORDER_TO) ? '' : (($sendtobcc?", ":"").$conf->global->MAIN_MAIL_AUTOCOPY_ORDER_TO)); - if ($mode == 'emailfrominvoice') $sendtobcc .= (empty($conf->global->MAIN_MAIL_AUTOCOPY_INVOICE_TO) ? '' : (($sendtobcc?", ":"").$conf->global->MAIN_MAIL_AUTOCOPY_INVOICE_TO)); + if ($mode == 'emailfromproposal') $sendtobcc .= (empty($conf->global->MAIN_MAIL_AUTOCOPY_PROPOSAL_TO) ? '' : (($sendtobcc?", ":"").$conf->global->MAIN_MAIL_AUTOCOPY_PROPOSAL_TO)); + if ($mode == 'emailfromorder') $sendtobcc .= (empty($conf->global->MAIN_MAIL_AUTOCOPY_ORDER_TO) ? '' : (($sendtobcc?", ":"").$conf->global->MAIN_MAIL_AUTOCOPY_ORDER_TO)); + if ($mode == 'emailfrominvoice') $sendtobcc .= (empty($conf->global->MAIN_MAIL_AUTOCOPY_INVOICE_TO) ? '' : (($sendtobcc?", ":"").$conf->global->MAIN_MAIL_AUTOCOPY_INVOICE_TO)); if ($mode == 'emailfromsupplierproposal') $sendtobcc .= (empty($conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_PROPOSAL_TO) ? '' : (($sendtobcc?", ":"").$conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_PROPOSAL_TO)); if ($mode == 'emailfromsupplierorder') $sendtobcc .= (empty($conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_ORDER_TO) ? '' : (($sendtobcc?", ":"").$conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_ORDER_TO)); if ($mode == 'emailfromsupplierinvoice') $sendtobcc .= (empty($conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_INVOICE_TO) ? '' : (($sendtobcc?", ":"").$conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_INVOICE_TO)); @@ -371,7 +382,7 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO if (is_object($object)) { if (empty($actiontypecode)) $actiontypecode='AC_OTH_AUTO'; // Event insert into agenda automatically - + $object->socid = $sendtosocid; // To link to a company $object->sendtoid = $sendtoid; // To link to contacts/addresses. This is an array. $object->actiontypecode = $actiontypecode; // Type of event ('AC_OTH', 'AC_OTH_AUTO', 'AC_XXX'...) @@ -392,7 +403,7 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO } } } - + if ($error) { dol_print_error($db); @@ -403,7 +414,7 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO // This avoid sending mail twice if going out and then back to page $mesg=$langs->trans('MailSuccessfulySent',$mailfile->getValidAddress($from,2),$mailfile->getValidAddress($sendto,2)); setEventMessages($mesg, null, 'mesgs'); - if ($conf->dolimail->enabled) + if ($conf->dolimail->enabled) { header('Location: '.$_SERVER["PHP_SELF"].'?'.($paramname?$paramname:'id').'='.(is_object($object)?$object->id:'').'&'.($paramname2?$paramname2:'mid').'='.$parm2val); exit; diff --git a/htdocs/core/lib/pdf.lib.php b/htdocs/core/lib/pdf.lib.php index a9fb8e52734..3c771220c70 100644 --- a/htdocs/core/lib/pdf.lib.php +++ b/htdocs/core/lib/pdf.lib.php @@ -865,7 +865,7 @@ function pdf_pagefoot(&$pdf,$outputlangs,$paramfreetext,$fromcompany,$marge_bass // Make a change into HTML code to allow to include images from medias directory. // // become - // + // $newfreetext=preg_replace('/()/', '\1'.DOL_DATA_ROOT.'/medias/\2\3', $newfreetext); $line.=$outputlangs->convToOutputCharset($newfreetext); diff --git a/htdocs/langs/en_US/errors.lang b/htdocs/langs/en_US/errors.lang index 0f57a23d23c..ac982973ef3 100644 --- a/htdocs/langs/en_US/errors.lang +++ b/htdocs/langs/en_US/errors.lang @@ -44,6 +44,7 @@ ErrorFailedToWriteInDir=Failed to write in directory %s ErrorFoundBadEmailInFile=Found incorrect email syntax for %s lines in file (example line %s with email=%s) ErrorUserCannotBeDelete=User cannot be deleted. May be it is associated to Dolibarr entities. ErrorFieldsRequired=Some required fields were not filled. +ErrorSubjectIsRequired=The email topic is required ErrorFailedToCreateDir=Failed to create a directory. Check that Web server user has permissions to write into Dolibarr documents directory. If parameter safe_mode is enabled on this PHP, check that Dolibarr php files owns to web server user (or group). ErrorNoMailDefinedForThisUser=No mail defined for this user ErrorFeatureNeedJavascript=This feature need javascript to be activated to work. Change this in setup - display. From 7c41c9a3e4aedb97742ab505afe957281e9527e2 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 17 Jun 2017 11:43:00 +0200 Subject: [PATCH 038/227] Fix activation of dependency for a dedicated country. BlockedLog depends now on CashDesk only. --- htdocs/admin/modules.php | 8 +++-- htdocs/core/lib/admin.lib.php | 20 ++++++------ htdocs/core/modules/modBlockedLog.class.php | 6 ++-- htdocs/core/modules/modCashDesk.class.php | 6 ++-- htdocs/core/modules/modFacture.class.php | 31 +++++++++---------- htdocs/langs/en_US/admin.lang | 6 ++-- htdocs/langs/en_US/main.lang | 3 +- .../core/modules/modMyModule.class.php | 2 ++ htdocs/theme/md/style.css.php | 1 - 9 files changed, 45 insertions(+), 38 deletions(-) diff --git a/htdocs/admin/modules.php b/htdocs/admin/modules.php index 5d5886b5415..d3221f40505 100644 --- a/htdocs/admin/modules.php +++ b/htdocs/admin/modules.php @@ -80,7 +80,7 @@ $urldolibarrmodules='https://www.dolistore.com/'; * Actions */ -if (GETPOST('buttonreset')) +if (GETPOST('buttonreset','alpha')) { $search_keyword=''; $search_status=''; @@ -738,13 +738,17 @@ if ($mode == 'common') print ''."\n"; foreach ($arrayofwarningsext as $keymodule => $arrayofwarningsextbycountry) { - if (! empty($modules[$keymodule]->const_name)) // If module that request warning is on + $keymodulelowercase=strtolower(preg_replace('/^mod/','',$keymodule)); + if (in_array($keymodulelowercase, $conf->modules)) // If module that request warning is on { foreach ($arrayofwarningsextbycountry as $keycountry => $cursorwarningmessage) { if ($keycountry == 'always' || $keycountry == $mysoc->country_code) { $warningmessage .= ($warningmessage?"\n":"").$langs->trans($cursorwarningmessage, $objMod->getName(), $mysoc->country_code, $modules[$keymodule]->getName()); + $warningmessage .= ($warningmessage?"\n":"").($warningmessage?"\n":"").$langs->trans("Module").' : '.$objMod->getName(); + if (! empty($objMod->editor_name)) $warningmessage .= ($warningmessage?"\n":"").$langs->trans("Publisher").' : '.$objMod->editor_name; + if (! empty($objMod->editor_name)) $warningmessage .= ($warningmessage?"\n":"").$langs->trans("ModuleTriggeringThisWarning").' : '.$modules[$keymodule]->getName(); } } } diff --git a/htdocs/core/lib/admin.lib.php b/htdocs/core/lib/admin.lib.php index ba5f099365c..e90f006ac7e 100644 --- a/htdocs/core/lib/admin.lib.php +++ b/htdocs/core/lib/admin.lib.php @@ -756,7 +756,7 @@ function purgeSessions($mysessionid) */ function activateModule($value,$withdeps=1) { - global $db, $modules, $langs, $conf; + global $db, $modules, $langs, $conf, $mysoc; // Check parameters if (empty($value)) { @@ -813,7 +813,7 @@ function activateModule($value,$withdeps=1) } $result=$objMod->init(); // Enable module - if ($result <= 0) + if ($result <= 0) { $ret['errors'][]=$objMod->error; } @@ -848,19 +848,19 @@ function activateModule($value,$withdeps=1) break; } } - + if ($activate) { $ret['nbmodules']+=$resarray['nbmodules']; $ret['nbperms']+=$resarray['nbperms']; } - else + else { $ret['errors'][] = $langs->trans('activateModuleDependNotSatisfied', $objMod->name, $modulestring); } } } - + if (isset($objMod->conflictwith) && is_array($objMod->conflictwith) && ! empty($objMod->conflictwith)) { // Desactivation des modules qui entrent en conflit @@ -879,12 +879,12 @@ function activateModule($value,$withdeps=1) } } - if (! count($ret['errors'])) + if (! count($ret['errors'])) { $ret['nbmodules']++; $ret['nbperms']+=count($objMod->rights); } - + return $ret; } @@ -1221,7 +1221,7 @@ function form_constantes($tableau, $strictw3c=0, $helptext='') if ($result) { $obj = $db->fetch_object($result); // Take first result of select - + // For avoid warning in strict mode if (empty($obj)) { @@ -1360,7 +1360,7 @@ function showModulesExludedForExternal($modules) //if (empty($conf->global->$moduleconst)) continue; if (! in_array($modulename,$listofmodules)) continue; //var_dump($modulename.'eee'.$langs->trans('Module'.$module->numero.'Name')); - + if ($i > 0) $text.=', '; else $text.=' '; $i++; @@ -1391,7 +1391,7 @@ function addDocumentModel($name, $type, $label='', $description='') $sql.= ($label?"'".$db->escape($label)."'":'null').", "; $sql.= (! empty($description)?"'".$db->escape($description)."'":"null"); $sql.= ")"; - + dol_syslog("admin.lib::addDocumentModel", LOG_DEBUG); $resql=$db->query($sql); if ($resql) diff --git a/htdocs/core/modules/modBlockedLog.class.php b/htdocs/core/modules/modBlockedLog.class.php index f3f3be971b5..3125627c007 100644 --- a/htdocs/core/modules/modBlockedLog.class.php +++ b/htdocs/core/modules/modBlockedLog.class.php @@ -65,9 +65,9 @@ class modBlockedLog extends DolibarrModules // Dependancies //------------- $this->hidden = false; // A condition to disable module - $this->depends = array('modFacture'); // List of modules id that must be enabled if this module is enabled - $this->requiredby = array(); // List of modules id to disable if this one is disabled - $this->conflictwith = array(); // List of modules id this module is in conflict with + $this->depends = array('always'=>'modFacture'); // List of modules id that must be enabled if this module is enabled + $this->requiredby = array(); // List of modules id to disable if this one is disabled + $this->conflictwith = array(); // List of modules id this module is in conflict with $this->langfiles = array(); // Constants diff --git a/htdocs/core/modules/modCashDesk.class.php b/htdocs/core/modules/modCashDesk.class.php index ec8764c9017..e5ba473c1c7 100644 --- a/htdocs/core/modules/modCashDesk.class.php +++ b/htdocs/core/modules/modCashDesk.class.php @@ -65,11 +65,13 @@ class modCashDesk extends DolibarrModules $this->config_page_url = array("cashdesk.php@cashdesk"); // Dependencies - $this->depends = array("modBanque","modFacture","modProduct"); // List of modules id that must be enabled if this module is enabled - $this->requiredby = array(); // List of modules id to disable if this one is disabled + $this->depends = array('always'=>"modBanque", 'always'=>"modFacture", 'always'=>"modProduct", 'FR'=>'modBlockedLog'); // List of modules id that must be enabled if this module is enabled + $this->requiredby = array(); // List of modules id to disable if this one is disabled $this->phpmin = array(4,1); // Minimum version of PHP required by module $this->need_dolibarr_version = array(2,4); // Minimum version of Dolibarr required by module $this->langfiles = array("cashdesk"); + $this->warnings_activation = array('FR'=>'WarningNoteModulePOSForFrenchLaw'); // Warning to show when we activate module. array('always'='text') or array('FR'='text') + $this->warnings_activation_ext = array('FR'=>'WarningInstallationMayBecomeNotCompliantWithLaw'); // Warning to show when we activate an external module. array('always'='text') or array('FR'='text') // Constants $this->const = array(); diff --git a/htdocs/core/modules/modFacture.class.php b/htdocs/core/modules/modFacture.class.php index 3af85a1944d..40e2a03d161 100644 --- a/htdocs/core/modules/modFacture.class.php +++ b/htdocs/core/modules/modFacture.class.php @@ -64,14 +64,13 @@ class modFacture extends DolibarrModules $this->dirs = array("/facture/temp"); // Dependencies - $this->depends = array('always'=>"modSociete", 'FR'=>'modBlockedLog'); + $this->depends = array('always'=>"modSociete"); $this->requiredby = array("modComptabilite","modAccounting"); $this->conflictwith = array(); $this->langfiles = array("bills","companies","compta","products"); - $this->warnings_activation = array('FR'=>'WarningNoteModuleInvoiceForFrenchLaw'); // Warning to show when we activate module. array('always'='text') or array('FR'='text') - $this->warnings_activation = array(); - $this->warnings_activation_ext = array('FR'=>'WarningInstallationMayBecomeNotCompliantWithLaw'); // Warning to show when we activate an external module. array('always'='text') or array('FR'='text') - + $this->warnings_activation = array(); // Warning to show when we activate module. array('always'='text') or array('FR'='text') + $this->warnings_activation_ext = array(); // Warning to show when we activate an external module. array('always'='text') or array('FR'='text') + // Config pages $this->config_page_url = array("facture.php"); @@ -99,7 +98,7 @@ class modFacture extends DolibarrModules $this->const[$r][3] = ""; $this->const[$r][4] = 0; $r++; - + /*$this->const[$r][0] = "FACTURE_DRAFT_WATERMARK"; $this->const[$r][1] = "chaine"; $this->const[$r][2] = "__(Draft)__"; @@ -107,7 +106,7 @@ class modFacture extends DolibarrModules $this->const[$r][4] = 0; $r++;*/ - + // Boxes //$this->boxes = array(0=>array(1=>'box_factures_imp.php'),1=>array(1=>'box_factures.php')); $this->boxes = array( @@ -116,16 +115,16 @@ class modFacture extends DolibarrModules 2=>array('file'=>'box_graph_invoices_permonth.php','enabledbydefaulton'=>'Home') ); - // Cronjobs + // Cronjobs $this->cronjobs = array( - 0=>array('label'=>'RecurringInvoices', 'jobtype'=>'method', 'class'=>'compta/facture/class/facture-rec.class.php', 'objectname'=>'FactureRec', 'method'=>'createRecurringInvoices', 'parameters'=>'', 'comment'=>'Generate recurring invoices', 'frequency'=>1, 'unitfrequency'=>3600*24), + 0=>array('label'=>'RecurringInvoices', 'jobtype'=>'method', 'class'=>'compta/facture/class/facture-rec.class.php', 'objectname'=>'FactureRec', 'method'=>'createRecurringInvoices', 'parameters'=>'', 'comment'=>'Generate recurring invoices', 'frequency'=>1, 'unitfrequency'=>3600*24), // 1=>array('label'=>'My label', 'jobtype'=>'command', 'command'=>'', 'parameters'=>'', 'comment'=>'Comment', 'frequency'=>3600, 'unitfrequency'=>3600) - ); - // List of cron jobs entries to add - // Example: + ); + // List of cron jobs entries to add + // Example: // $this->cronjobs=array( - // 0=>array('label'=>'My label', 'jobtype'=>'method', 'class'=>'MyClass', 'method'=>'myMethod', 'parameters'=>'', 'comment'=>'Comment', 'frequency'=>1, 'unitfrequency'=>3600), - // 1=>array('label'=>'My label', 'jobtype'=>'command', 'command'=>'', 'parameters'=>'', 'comment'=>'Comment', 'frequency'=>1, 'unitfrequency'=>3600) + // 0=>array('label'=>'My label', 'jobtype'=>'method', 'class'=>'MyClass', 'method'=>'myMethod', 'parameters'=>'', 'comment'=>'Comment', 'frequency'=>1, 'unitfrequency'=>3600), + // 1=>array('label'=>'My label', 'jobtype'=>'command', 'command'=>'', 'parameters'=>'', 'comment'=>'Comment', 'frequency'=>1, 'unitfrequency'=>3600) // ); // Permissions @@ -206,8 +205,8 @@ class modFacture extends DolibarrModules // Menus //------- $this->menu = 1; // This module add menu entries. They are coded into menu manager. - - + + // Exports //-------- $r=1; diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 1aa79c2dced..0ba5ab270bc 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -104,7 +104,7 @@ MenuIdParent=Parent menu ID DetailMenuIdParent=ID of parent menu (empty for a top menu) DetailPosition=Sort number to define menu position AllMenus=All -NotConfigured=Module not configured +NotConfigured=Module/Application not configured Active=Active SetupShort=Setup OtherOptions=Other options @@ -114,7 +114,6 @@ CurrentValueSeparatorThousand=Thousand separator Destination=Destination IdModule=Module ID IdPermissions=Permissions ID -Modules=Modules LanguageBrowserParameter=Parameter %s LocalisationDolibarrParameters=Localisation parameters ClientTZ=Client Time Zone (user) @@ -1700,7 +1699,8 @@ UserHasNoPermissions=This user has no permission defined TypeCdr=Use "None" if the date of payment term is date of invoice plus a delta in days (delta is field "Nb of days")
Use "At end of month", if, after delta, the date must be increased to reach the end of month (+ an optional "Offset" in days)
Use "Current/Next" to have payment term date being the first Nth of the month (N is stored into field "Nb of days") BaseCurrency=Reference currency of the company (go into setup of company to change this) WarningNoteModuleInvoiceForFrenchLaw=This module %s is compliant with french laws (Loi Finance 2016). -WarningInstallationMayBecomeNotCompliantWithLaw=You try to install the module %s that is an external module. Activating an external module means you trust the editor of the module and you are sure that this module does not alterate negatively the behavior of your application and is compliant with laws of your country (%s). If the module bring a non legal feature, you become responsible for the use of a non legal software. +WarningNoteModulePOSForFrenchLaw=This module %s is compliant with french laws (Loi Finance 2016) because module Non Reversible Logs is automatically activated. +WarningInstallationMayBecomeNotCompliantWithLaw=You try to install the module %s that is an external module. Activating an external module means you trust the publisher of the module and you are sure that this module does not alterate negatively the behavior of your application and is compliant with laws of your country (%s). If the module bring a non legal feature, you become responsible for the use of a non legal software. ##### Resource #### ResourceSetup=Configuration du module Resource UseSearchToSelectResource=Use a search form to choose a resource (rather than a drop-down list). diff --git a/htdocs/langs/en_US/main.lang b/htdocs/langs/en_US/main.lang index 8ea14fdb305..a35342f2af9 100644 --- a/htdocs/langs/en_US/main.lang +++ b/htdocs/langs/en_US/main.lang @@ -366,7 +366,8 @@ VATRate=Tax Rate Average=Average Sum=Sum Delta=Delta -Module=Module +Module=Module/Application +Modules=Modules/Applications Option=Option List=List FullList=Full list diff --git a/htdocs/modulebuilder/template/core/modules/modMyModule.class.php b/htdocs/modulebuilder/template/core/modules/modMyModule.class.php index dc98c327cb3..60889bdf279 100644 --- a/htdocs/modulebuilder/template/core/modules/modMyModule.class.php +++ b/htdocs/modulebuilder/template/core/modules/modMyModule.class.php @@ -114,6 +114,8 @@ class modMyModule extends DolibarrModules $this->phpmin = array(5,0); // Minimum version of PHP required by module $this->need_dolibarr_version = array(3,0); // Minimum version of Dolibarr required by module $this->langfiles = array("mymodule@mymodule"); + $this->warnings_activation = array(); // Warning to show when we activate module. array('always'='text') or array('FR'='textfr','ES'='textes'...) + $this->warnings_activation_ext = array(); // Warning to show when we activate an external module. array('always'='text') or array('FR'='textfr','ES'='textes'...) // Constants // List of particular constants to add when module is enabled (key, 'chaine', value, desc, visible, 'current' or 'allentities', deleteonunactive) diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php index 5fbd8455919..e96fa032538 100644 --- a/htdocs/theme/md/style.css.php +++ b/htdocs/theme/md/style.css.php @@ -2528,7 +2528,6 @@ div.pagination li.noborder a:hover { div.pagination li a, div.pagination li span { background-color: #fff; - border: 1px solid #ddd; } div.pagination li:first-child a, div.pagination li:first-child span { From a4f34539ea92cf634c49a98904c6aa92eb0015b1 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 17 Jun 2017 11:46:45 +0200 Subject: [PATCH 039/227] Fix translation --- htdocs/langs/en_US/admin.lang | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 0ba5ab270bc..e2b5825f14f 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -466,7 +466,7 @@ Module30Desc=Invoice and credit note management for customers. Invoice managemen Module40Name=Suppliers Module40Desc=Supplier management and buying (orders and invoices) Module42Name=Logs -Module42Desc=Logging facilities (file, syslog, ...). Such logs are for technical/debug purposes. For legal purpose, see instead module 'Non Reversible Logs'. +Module42Desc=Logging facilities (file, syslog, ...). Such logs are for technical/debug purposes. Module49Name=Editors Module49Desc=Editor management Module50Name=Products @@ -565,7 +565,7 @@ Module2900Desc=GeoIP Maxmind conversions capabilities Module3100Name=Skype Module3100Desc=Add a Skype button into users / third parties / contacts / members cards Module3200Name=Non Reversible Logs -Module3200Desc=Activate log of some business events into a non reversible log. Events are archived in real-time. The log is a table that can be then exported. This module may be mandatory for some countries. +Module3200Desc=Activate log of some business events into a non reversible log. Events are archived in real-time. The log is a table of chained event that can be then read and exported. This module may be mandatory for some countries. Module4000Name=HRM Module4000Desc=Human resources management (mangement of department, employee contracts and feelings) Module5000Name=Multi-company From 8a1de52f3c5b80c10c290c6028e0cc61cdf003f0 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 17 Jun 2017 12:00:33 +0200 Subject: [PATCH 040/227] Fix translation --- htdocs/admin/index.php | 6 +++--- htdocs/langs/en_US/admin.lang | 12 ++++++------ 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/htdocs/admin/index.php b/htdocs/admin/index.php index a1ac45244e1..9ac33f1cc3d 100644 --- a/htdocs/admin/index.php +++ b/htdocs/admin/index.php @@ -70,13 +70,13 @@ if (! empty($conf->global->MAIN_MOTD_SETUPPAGE)) print $langs->trans("SetupDescription1").' '; print $langs->trans("AreaForAdminOnly").' '; -print $langs->trans("SetupDescription2")."

"; +print $langs->trans("SetupDescription2", $langs->trans("MenuCompanySetup"), $langs->trans("Modules"))."

"; print '
'; // Show info setup company if (empty($conf->global->MAIN_INFO_SOCIETE_NOM) || empty($conf->global->MAIN_INFO_SOCIETE_COUNTRY)) $setupcompanynotcomplete=1; -print img_picto('','puce').' '.$langs->trans("SetupDescription3",DOL_URL_ROOT.'/admin/company.php?mainmenu=home'.(empty($setupcompanynotcomplete)?'':'&action=edit')); +print img_picto('','puce').' '.$langs->trans("SetupDescription3", DOL_URL_ROOT.'/admin/company.php?mainmenu=home'.(empty($setupcompanynotcomplete)?'':'&action=edit'), $langs->trans("Setup"), $langs->trans("MenuCompanySetup")); if (! empty($setupcompanynotcomplete)) { $langs->load("errors"); @@ -88,7 +88,7 @@ print '
'; print '
'; // Show info setup module -print img_picto('','puce').' '.$langs->trans("SetupDescription4",DOL_URL_ROOT.'/admin/modules.php?mainmenu=home'); +print img_picto('','puce').' '.$langs->trans("SetupDescription4", DOL_URL_ROOT.'/admin/modules.php?mainmenu=home', $langs->trans("Setup"), $langs->trans("Modules")); if (count($conf->modules) <= (empty($conf->global->MAIN_MIN_NB_ENABLED_MODULE_FOR_WARNING)?1:$conf->global->MAIN_MIN_NB_ENABLED_MODULE_FOR_WARNING)) // If only user module enabled { $langs->load("errors"); diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index e2b5825f14f..23b207b4fea 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -190,7 +190,7 @@ FeatureAvailableOnlyOnStable=Feature only available on official stable versions Rights=Permissions BoxesDesc=Widgets are components showing some information that you can add to personalize some pages. You can choose between showing the widget or not by selecting target page and clicking 'Activate', or by clicking the dustbin to disable it. OnlyActiveElementsAreShown=Only elements from enabled modules are shown. -ModulesDesc=Dolibarr modules define which application/feature is enabled in software. Some application/modules require permissions you must grant to users, after enabling module. Click on button on/off to enable an application/module. +ModulesDesc=Dolibarr modules define which application/feature is enabled in software. Some application/modules require permissions you must grant to users, after activating it. Click on button on/off to enable a module/application. ModulesMarketPlaceDesc=You can find more modules to download on external websites on the Internet... ModulesDeployDesc=If permissions on your file system allows it, you can use this tool to deploy an external module. The module wil then be visible on the tab %s. ModulesMarketPlaces=Find external modules... @@ -270,7 +270,7 @@ FeatureNotAvailableOnLinux=Feature not available on Unix like systems. Test your SubmitTranslation=If translation for this language is not complete or you find errors, you can correct this by editing files into directory langs/%s and submit your change to www.transifex.com/dolibarr-association/dolibarr/ SubmitTranslationENUS=If translation for this language is not complete or you find errors, you can correct this by editing files into directory langs/%s and submit modified files on dolibarr.org/forum or for developers on github.com/Dolibarr/dolibarr. ModuleSetup=Module setup -ModulesSetup=Modules setup +ModulesSetup=Modules/Application setup ModuleFamilyBase=System ModuleFamilyCrm=Customer Relation Management (CRM) ModuleFamilySrm=Supplier Relation Management (SRM) @@ -997,9 +997,9 @@ Delays_MAIN_DELAY_MEMBERS=Tolerance delay (in days) before alert on delayed memb Delays_MAIN_DELAY_CHEQUES_TO_DEPOSIT=Tolerance delay (in days) before alert for cheques deposit to do Delays_MAIN_DELAY_EXPENSEREPORTS=Tolerance delay (in days) before alert for expense reports to approve SetupDescription1=The setup area is for initial setup parameters before starting to use Dolibarr. -SetupDescription2=The two most important setup steps are the first two in the setup menu on the left: Company/Organisation setup page and Modules setup page: -SetupDescription3=Parameters in menu Setup -> Company/Organisation are required because submitted data are used on Dolibarr displays and to customize the default behaviour of the software (for country-related features for example). -SetupDescription4=Parameters in menu Setup -> Modules are required because Dolibarr is not a monolithic ERP/CRM but a collection of several modules, all more or less independent. New features will be added to menus for every module you'll enable. +SetupDescription2=The two mandatory setup steps are the first two in the setup menu on the left: %s setup page and %s setup page : +SetupDescription3=Parameters in menu %s -> %s are required because defined data are used on Dolibarr screens and to customize the default behavior of the software (for country-related features for example). +SetupDescription4=Parameters in menu %s -> %s are required because Dolibarr ERP/CRM is a collection of several modules/applications, all more or less independent. New features will be added to menus for every module you will activate. SetupDescription5=Other menu entries manage optional parameters. LogEvents=Security audit events Audit=Audit @@ -1015,7 +1015,7 @@ BrowserOS=Browser OS ListOfSecurityEvents=List of Dolibarr security events SecurityEventsPurged=Security events purged LogEventDesc=You can enable here the logging for Dolibarr security events. Administrators can then see its content via menu System tools - Audit. Warning, this feature can consume a large amount of data in database. -AreaForAdminOnly=Those features can be used by administrator users only. +AreaForAdminOnly=Setup parameters can be set by administrator users only. SystemInfoDesc=System information is miscellaneous technical information you get in read only mode and visible for administrators only. SystemAreaForAdminOnly=This area is available for administrator users only. None of the Dolibarr permissions can reduce this limit. CompanyFundationDesc=Edit on this page all known information of the company or foundation you need to manage (For this, click on "Modify" or "Save" button at bottom of page) From 240e9637fa03e1bf03add7712f050b26d2d20e7e Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Sat, 17 Jun 2017 14:43:15 +0200 Subject: [PATCH 041/227] New: add extrafields API REST --- .../class/api_dictionaryextrafields.class.php | 112 ++++++++++++++++++ 1 file changed, 112 insertions(+) create mode 100644 htdocs/api/class/api_dictionaryextrafields.class.php diff --git a/htdocs/api/class/api_dictionaryextrafields.class.php b/htdocs/api/class/api_dictionaryextrafields.class.php new file mode 100644 index 00000000000..69f574797c7 --- /dev/null +++ b/htdocs/api/class/api_dictionaryextrafields.class.php @@ -0,0 +1,112 @@ + + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +use Luracast\Restler\RestException; + +//require_once DOL_DOCUMENT_ROOT . '/core/class/extrafields.class.php'; + +/** + * API class for extra fields (content of the extrafields) + * + * @access protected + * @class DolibarrApiAccess {@requires user,external} + */ +class DictionaryExtraFields extends DolibarrApi +{ + /** + * Constructor + */ + function __construct() + { + global $db; + $this->db = $db; + } + + /** + * Get the list of extra fields. + * + * @param string $sortfield Sort field + * @param string $sortorder Sort order + * @param string $type Type of element ('adherent', 'commande', 'thirdparty', 'facture', 'propal', 'product', ...) + * @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.label:like:'SO-%')" + * @return List of events types + * + * @throws RestException + */ + function index($sortfield = "t.pos", $sortorder = 'ASC', $type = '', $sqlfilters = '') + { + $list = array(); + + if ($type == 'thirdparty') $type='societe'; + if ($type == 'contact') $type='socpeople'; + + $sql = "SELECT t.rowid, t.name, t.label, t.type, t.size, t.elementtype, t.fieldunique, t.fieldrequired, t.param, t.pos, t.alwayseditable, t.perms, t.list, t.ishidden, t.fielddefault, t.fieldcomputed"; + $sql.= " FROM ".MAIN_DB_PREFIX."extrafields as t"; + $sql.= " WHERE t.entity IN (".getEntity('extrafields').")"; + if (! empty($type)) $sql.= " AND t.elementtype = '".$this->db->escape($type)."'"; + // Add sql filters + if ($sqlfilters) + { + if (! DolibarrApi::_checkFilters($sqlfilters)) + { + throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); + } + $regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; + $sql.=" AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; + } + + $sql.= $this->db->order($sortfield, $sortorder); + + $resql=$this->db->query($sql); + if ($resql) + { + if ($this->db->num_rows($resql)) + { + while ($tab = $this->db->fetch_object($resql)) + { + // New usage + $list[$tab->elementtype][$tab->name]['type']=$tab->type; + $list[$tab->elementtype][$tab->name]['label']=$tab->label; + $list[$tab->elementtype][$tab->name]['size']=$tab->size; + $list[$tab->elementtype][$tab->name]['elementtype']=$tab->elementtype; + $list[$tab->elementtype][$tab->name]['default']=$tab->fielddefault; + $list[$tab->elementtype][$tab->name]['computed']=$tab->fieldcomputed; + $list[$tab->elementtype][$tab->name]['unique']=$tab->fieldunique; + $list[$tab->elementtype][$tab->name]['required']=$tab->fieldrequired; + $list[$tab->elementtype][$tab->name]['param']=($tab->param ? unserialize($tab->param) : ''); + $list[$tab->elementtype][$tab->name]['pos']=$tab->pos; + $list[$tab->elementtype][$tab->name]['alwayseditable']=$tab->alwayseditable; + $list[$tab->elementtype][$tab->name]['perms']=$tab->perms; + $list[$tab->elementtype][$tab->name]['list']=$tab->list; + $list[$tab->elementtype][$tab->name]['ishidden']=$tab->ishidden; + } + } + } + else + { + throw new RestException(503, 'Error when retrieving list of extra fields : '.$this->db->lasterror()); + } + + if (! count($list)) + { + throw new RestException(404, 'No extrafield found'); + } + + return $list; + } + +} From 48866f07325c1374c1f8112382674f1160b3a74c Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Sat, 17 Jun 2017 14:43:31 +0200 Subject: [PATCH 042/227] Fix: wrong array format --- htdocs/core/class/extrafields.class.php | 46 ++++++++++++------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php index 4b5f151ec72..24be010ff4c 100644 --- a/htdocs/core/class/extrafields.class.php +++ b/htdocs/core/class/extrafields.class.php @@ -1,13 +1,13 @@ - * Copyright (C) 2002-2003 Jean-Louis Bergamo - * Copyright (C) 2004 Sebastien Di Cintio - * Copyright (C) 2004 Benoit Mortier - * Copyright (C) 2009-2012 Laurent Destailleur - * Copyright (C) 2009-2012 Regis Houssin - * Copyright (C) 2013 Florian Henry - * Copyright (C) 2015 Charles-Fr BENKE - * Copyright (C) 2016 Raphaël Doursenaud +/* Copyright (C) 2002-2003 Rodolphe Quiedeville + * Copyright (C) 2002-2003 Jean-Louis Bergamo + * Copyright (C) 2004 Sebastien Di Cintio + * Copyright (C) 2004 Benoit Mortier + * Copyright (C) 2009-2012 Laurent Destailleur + * Copyright (C) 2009-2017 Regis Houssin + * Copyright (C) 2013 Florian Henry + * Copyright (C) 2015 Charles-Fr BENKE + * Copyright (C) 2016 Raphaël Doursenaud * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -702,20 +702,20 @@ class ExtraFields $this->attribute_hidden[$tab->name]=$tab->ishidden; // New usage - $this->attributes[$tab->elementtype]['type'][$tab->name]=$tab->type; - $this->attributes[$tab->elementtype]['label'][$tab->name]=$tab->label; - $this->attributes[$tab->elementtype]['size'][$tab->name]=$tab->size; - $this->attributes[$tab->elementtype]['elementtype'][$tab->name]=$tab->elementtype; - $this->attributes[$tab->elementtype]['default'][$tab->name]=$tab->fielddefault; - $this->attributes[$tab->elementtype]['computed'][$tab->name]=$tab->fieldcomputed; - $this->attributes[$tab->elementtype]['unique'][$tab->name]=$tab->fieldunique; - $this->attributes[$tab->elementtype]['required'][$tab->name]=$tab->fieldrequired; - $this->attributes[$tab->elementtype]['param'][$tab->name]=($tab->param ? unserialize($tab->param) : ''); - $this->attributes[$tab->elementtype]['pos'][$tab->name]=$tab->pos; - $this->attributes[$tab->elementtype]['alwayseditable'][$tab->name]=$tab->alwayseditable; - $this->attributes[$tab->elementtype]['perms'][$tab->name]=$tab->perms; - $this->attributes[$tab->elementtype]['list'][$tab->name]=$tab->list; - $this->attributes[$tab->elementtype]['ishidden'][$tab->name]=$tab->ishidden; + $this->attributes[$tab->elementtype][$tab->name]['type']=$tab->type; + $this->attributes[$tab->elementtype][$tab->name]['label']=$tab->label; + $this->attributes[$tab->elementtype][$tab->name]['size']=$tab->size; + $this->attributes[$tab->elementtype][$tab->name]['elementtype']=$tab->elementtype; + $this->attributes[$tab->elementtype][$tab->name]['default']=$tab->fielddefault; + $this->attributes[$tab->elementtype][$tab->name]['computed']=$tab->fieldcomputed; + $this->attributes[$tab->elementtype][$tab->name]['unique']=$tab->fieldunique; + $this->attributes[$tab->elementtype][$tab->name]['required']=$tab->fieldrequired; + $this->attributes[$tab->elementtype][$tab->name]['param']=($tab->param ? unserialize($tab->param) : ''); + $this->attributes[$tab->elementtype][$tab->name]['pos']=$tab->pos; + $this->attributes[$tab->elementtype][$tab->name]['alwayseditable']=$tab->alwayseditable; + $this->attributes[$tab->elementtype][$tab->name]['perms']=$tab->perms; + $this->attributes[$tab->elementtype][$tab->name]['list']=$tab->list; + $this->attributes[$tab->elementtype][$tab->name]['ishidden']=$tab->ishidden; } } if ($elementtype) $this->attributes[$elementtype]['loaded']=1; From 12cab2dfe08695f75199afb84779c84b897101e9 Mon Sep 17 00:00:00 2001 From: BENKE Charlene Date: Sat, 17 Jun 2017 16:30:03 +0200 Subject: [PATCH 043/227] Once to Ounce --- htdocs/core/lib/product.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/product.lib.php b/htdocs/core/lib/product.lib.php index 16bedc4d346..7048b8570c6 100644 --- a/htdocs/core/lib/product.lib.php +++ b/htdocs/core/lib/product.lib.php @@ -441,7 +441,7 @@ function measuring_units_string($unit,$measuring_style='') $measuring_units[0] = $langs->transnoentitiesnoconv("WeightUnitkg"); $measuring_units[-3] = $langs->transnoentitiesnoconv("WeightUnitg"); $measuring_units[-6] = $langs->transnoentitiesnoconv("WeightUnitmg"); - $measuring_units[98] = $langs->transnoentitiesnoconv("WeightUnitonce"); + $measuring_units[98] = $langs->transnoentitiesnoconv("WeightUnitounce"); $measuring_units[99] = $langs->transnoentitiesnoconv("WeightUnitpound"); } else if ($measuring_style == 'size') From db173632674e7fd6ae22c0965ae8e9361b607502 Mon Sep 17 00:00:00 2001 From: BENKE Charlene Date: Sat, 17 Jun 2017 16:30:37 +0200 Subject: [PATCH 044/227] Update other.lang --- htdocs/langs/en_US/other.lang | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/langs/en_US/other.lang b/htdocs/langs/en_US/other.lang index 120b1dcd790..bf01ba734f3 100644 --- a/htdocs/langs/en_US/other.lang +++ b/htdocs/langs/en_US/other.lang @@ -123,7 +123,7 @@ WeightUnitkg=kg WeightUnitg=g WeightUnitmg=mg WeightUnitpound=pound -WeightUnitonce=once +WeightUnitounce=ounce Length=Length LengthUnitm=m LengthUnitdm=dm From fcdf68db6a1175f2faa5e9a95afef05398c29fb5 Mon Sep 17 00:00:00 2001 From: BENKE Charlene Date: Sat, 17 Jun 2017 16:31:54 +0200 Subject: [PATCH 045/227] Update commonobject.class.php --- htdocs/core/class/commonobject.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index bd5d8a6b831..b87b3d28ea8 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -3099,11 +3099,11 @@ abstract class CommonObject } else { if ($weight_units == 99) { - // conversion 1 Livre = 0.45359237 KG + // conversion 1 Pound = 0.45359237 KG $trueWeightUnit = 0.45359237; $totalWeight += $weight * $qty * $trueWeightUnit; } elseif ($weight_units == 98) { - // conversion 1 once = 0.0283495 KG + // conversion 1 Ounce = 0.0283495 KG $trueWeightUnit = 0.0283495; $totalWeight += $weight * $qty * $trueWeightUnit; } From 04821376200381ef232947147b8063bf189c2f9b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 17 Jun 2017 18:03:53 +0200 Subject: [PATCH 046/227] Fix warning --- htdocs/install/inc.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/install/inc.php b/htdocs/install/inc.php index dc7e29b19f5..b9efc4eb8a4 100644 --- a/htdocs/install/inc.php +++ b/htdocs/install/inc.php @@ -385,12 +385,12 @@ function pHeader($subtitle,$next,$action='set',$param='',$forcejqueryurl='',$css // We force the content charset header("Content-type: text/html; charset=".$conf->file->character_set_client); header("X-Content-Type-Options: nosniff"); - + print ''."\n"; print ''."\n"; print ''."\n"; print ''."\n"; - print ''."\n"; + print ''."\n"; print ''."\n"; print ''."\n"; @@ -453,7 +453,7 @@ function pFooter($nonext=0,$setuplang='',$jscheckfunction='', $withpleasewait=0) print '
'; if ($nonext == '2') { - print $langs->trans("ErrorFoundDuringMigration", $_SERVER["REQUEST_URI"].'&ignoreerrors=1').'

'; + print $langs->trans("ErrorFoundDuringMigration", isset($_SERVER["REQUEST_URI"])?$_SERVER["REQUEST_URI"].'&ignoreerrors=1':'').'

'; } print '"'; From 285b5563d66cb0cde3f20ad86e23641a0f4bf4dd Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 17 Jun 2017 18:23:26 +0200 Subject: [PATCH 047/227] Update changelog --- ChangeLog | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/ChangeLog b/ChangeLog index 78793b9d419..c43fd92f676 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2,6 +2,22 @@ English Dolibarr ChangeLog -------------------------------------------------------------- +***** ChangeLog for 5.0.4 compared to 5.0.3 ***** +FIX: #6880 +FIX: #6925 +FIX: #6926 +FIX: Can set supplier invoice to billed. +FIX: Can't create invoice if PO disapproved +FIX: contratligne update +FIX: CVE-2017-7886 +FIX: default param +FIX: Line of invoices not inserted when using POS module and VAT NPR. +FIX: origin & originid on supplierproposal +FIX: Redirect to payment page from member subscription page failed if a unique security key was defined. +FIX: REST api to get project when user has permission to read all. +FIX: situation_progress param default value must be 100 and not 0 +FIX: SQL injection on user/index.php parameter search_statut. +FIX: Warnings ***** ChangeLog for 5.0.3 compared to 5.0.2 ***** FIX: #6677 Expired contracts dashboard box does not show the name of the thirdparty From fd9c30fd11ca2faa2b838977fd81219273d4d362 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Sat, 17 Jun 2017 18:30:11 +0200 Subject: [PATCH 048/227] Revert "Fix: wrong array format" This reverts commit 48866f07325c1374c1f8112382674f1160b3a74c. --- htdocs/core/class/extrafields.class.php | 46 ++++++++++++------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php index 24be010ff4c..4b5f151ec72 100644 --- a/htdocs/core/class/extrafields.class.php +++ b/htdocs/core/class/extrafields.class.php @@ -1,13 +1,13 @@ - * Copyright (C) 2002-2003 Jean-Louis Bergamo - * Copyright (C) 2004 Sebastien Di Cintio - * Copyright (C) 2004 Benoit Mortier - * Copyright (C) 2009-2012 Laurent Destailleur - * Copyright (C) 2009-2017 Regis Houssin - * Copyright (C) 2013 Florian Henry - * Copyright (C) 2015 Charles-Fr BENKE - * Copyright (C) 2016 Raphaël Doursenaud +/* Copyright (C) 2002-2003 Rodolphe Quiedeville + * Copyright (C) 2002-2003 Jean-Louis Bergamo + * Copyright (C) 2004 Sebastien Di Cintio + * Copyright (C) 2004 Benoit Mortier + * Copyright (C) 2009-2012 Laurent Destailleur + * Copyright (C) 2009-2012 Regis Houssin + * Copyright (C) 2013 Florian Henry + * Copyright (C) 2015 Charles-Fr BENKE + * Copyright (C) 2016 Raphaël Doursenaud * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -702,20 +702,20 @@ class ExtraFields $this->attribute_hidden[$tab->name]=$tab->ishidden; // New usage - $this->attributes[$tab->elementtype][$tab->name]['type']=$tab->type; - $this->attributes[$tab->elementtype][$tab->name]['label']=$tab->label; - $this->attributes[$tab->elementtype][$tab->name]['size']=$tab->size; - $this->attributes[$tab->elementtype][$tab->name]['elementtype']=$tab->elementtype; - $this->attributes[$tab->elementtype][$tab->name]['default']=$tab->fielddefault; - $this->attributes[$tab->elementtype][$tab->name]['computed']=$tab->fieldcomputed; - $this->attributes[$tab->elementtype][$tab->name]['unique']=$tab->fieldunique; - $this->attributes[$tab->elementtype][$tab->name]['required']=$tab->fieldrequired; - $this->attributes[$tab->elementtype][$tab->name]['param']=($tab->param ? unserialize($tab->param) : ''); - $this->attributes[$tab->elementtype][$tab->name]['pos']=$tab->pos; - $this->attributes[$tab->elementtype][$tab->name]['alwayseditable']=$tab->alwayseditable; - $this->attributes[$tab->elementtype][$tab->name]['perms']=$tab->perms; - $this->attributes[$tab->elementtype][$tab->name]['list']=$tab->list; - $this->attributes[$tab->elementtype][$tab->name]['ishidden']=$tab->ishidden; + $this->attributes[$tab->elementtype]['type'][$tab->name]=$tab->type; + $this->attributes[$tab->elementtype]['label'][$tab->name]=$tab->label; + $this->attributes[$tab->elementtype]['size'][$tab->name]=$tab->size; + $this->attributes[$tab->elementtype]['elementtype'][$tab->name]=$tab->elementtype; + $this->attributes[$tab->elementtype]['default'][$tab->name]=$tab->fielddefault; + $this->attributes[$tab->elementtype]['computed'][$tab->name]=$tab->fieldcomputed; + $this->attributes[$tab->elementtype]['unique'][$tab->name]=$tab->fieldunique; + $this->attributes[$tab->elementtype]['required'][$tab->name]=$tab->fieldrequired; + $this->attributes[$tab->elementtype]['param'][$tab->name]=($tab->param ? unserialize($tab->param) : ''); + $this->attributes[$tab->elementtype]['pos'][$tab->name]=$tab->pos; + $this->attributes[$tab->elementtype]['alwayseditable'][$tab->name]=$tab->alwayseditable; + $this->attributes[$tab->elementtype]['perms'][$tab->name]=$tab->perms; + $this->attributes[$tab->elementtype]['list'][$tab->name]=$tab->list; + $this->attributes[$tab->elementtype]['ishidden'][$tab->name]=$tab->ishidden; } } if ($elementtype) $this->attributes[$elementtype]['loaded']=1; From a6b4b15e07a29934b483c93b8487eb6b7dee0218 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 17 Jun 2017 19:40:48 +0200 Subject: [PATCH 049/227] Work on modulebuilder --- htdocs/langs/en_US/modulebuilder.lang | 6 +- htdocs/modulebuilder/index.php | 142 +++++++++++++++++- .../modulebuilder/template/class/MyObject.txt | 1 + ...class.class.php => api_myobject.class.php} | 0 .../template/class/myobject.class.php | 4 +- ...bject_mymodule.png => object_myobject.png} | Bin 6 files changed, 148 insertions(+), 5 deletions(-) create mode 100644 htdocs/modulebuilder/template/class/MyObject.txt rename htdocs/modulebuilder/template/class/{myobject_api_class.class.php => api_myobject.class.php} (100%) rename htdocs/modulebuilder/template/img/{myobject_mymodule.png => object_myobject.png} (100%) diff --git a/htdocs/langs/en_US/modulebuilder.lang b/htdocs/langs/en_US/modulebuilder.lang index adce0950b88..b8300182b05 100644 --- a/htdocs/langs/en_US/modulebuilder.lang +++ b/htdocs/langs/en_US/modulebuilder.lang @@ -1,11 +1,15 @@ # Dolibarr language file - Source file is en_US - loan ModuleBuilderDesc=This tools give you utilites to build or edit your own module. -EnterNameOfModuleDesc=Enter name of the module to create with no spaces. Use uppercase to separate words (For example: MyModule, EcommerceForShop, SyncWithMySystem...) +EnterNameOfModuleDesc=Enter name of the module/application to create with no spaces. Use uppercase to separate words (For example: MyModule, EcommerceForShop, SyncWithMySystem...) +EnterNameOfObjectDesc=Enter name of the object to create with no spaces. Use uppercase to separate words (For example: MyObject, Student, Teacher...) ModuleBuilderDesc2=Path were modules are generated/edited (first alternative directory defined into %s): %s ModuleBuilderDesc3=Generated/editable modules found: %s (they are detected as editable when the file %s exists in root of module directory). NewModule=New module +NewObject=New object ModuleKey=Key for new module +ObjectKey=Key for new object ModuleInitialized=Module initialized +FilesForObjectInitialized=Files for new object initialized ModuleBuilderDescdescription=Enter here all general information that describe your module ModuleBuilderDescobjects=Define here the new objects you want to manage with your module. A page to list them and a page to create/edit/view a card will be generated. ModuleBuilderDescmenus=This tab is dedicated to define menu entries provided by your module. diff --git a/htdocs/modulebuilder/index.php b/htdocs/modulebuilder/index.php index 8cabec1bdfb..0f60d76ca4f 100644 --- a/htdocs/modulebuilder/index.php +++ b/htdocs/modulebuilder/index.php @@ -33,11 +33,13 @@ $action=GETPOST('action','aZ09'); $confirm=GETPOST('confirm','alpha'); $module=GETPOST('module','alpha'); $tab=GETPOST('tab','aZ09'); +$tabobj=GETPOST('tabobj','alpha'); if (empty($module)) $module='initmodule'; if (empty($tab)) $tab='description'; +if (empty($tabobj)) $tabobj='newobject'; $modulename=dol_sanitizeFileName(GETPOST('modulename','alpha')); - +$objectname=dol_sanitizeFileName(GETPOST('objectname','alpha')); // Security check if (! $user->admin && empty($conf->global->MODULEBUILDER_FOREVERYONE)) accessforbidden('ModuleBuilderNotAllowed'); @@ -80,6 +82,18 @@ if ($dirins && $action == 'initmodule' && $modulename) } } + // Delete some files + dol_delete_file($destdir.'/myobject_card.php'); + dol_delete_file($destdir.'/myobject_list.php'); + dol_delete_file($destdir.'/test/phpunit/MyObjectTest.php'); + dol_delete_file($destdir.'/sql/llx_myobject.key.sql'); + dol_delete_file($destdir.'/sql/llx_myobject.sql'); + dol_delete_file($destdir.'/scripts/myobject.php'); + dol_delete_file($destdir.'/img/object_myobject.png'); + dol_delete_file($destdir.'/class/myobject.class.php'); + dol_delete_file($destdir.'/class/api_myobject.class.php'); + dol_delete_file($destdir.'/class/MyObject.txt'); + // Edit PHP files if (! $error) { @@ -113,6 +127,86 @@ if ($dirins && $action == 'initmodule' && $modulename) } } +if ($dirins && $action == 'initobject' && $module && $objectname) +{ + $srcdir = DOL_DOCUMENT_ROOT.'/modulebuilder/template'; + $destdir = $dirins.'/'.strtolower($module); + + $arrayreplacement=array( + 'mymodule'=>strtolower($module), + 'MyModule'=>$module, + 'myobject'=>strtolower($objectname), + 'MyObject'=>$objectname + ); + + + // Delete some files + $filetogenerate = array( + 'myobject_card.php'=>strtolower($objectname).'_card.php', + 'myobject_list.php'=>strtolower($objectname).'_list.php', + 'test/phpunit/MyObjectTest.php'=>'test/phpunit/'.$objectname.'Test.php', + 'sql/llx_myobject.key.sql'=>'sql/llx_'.strtolower($objectname).'.key.sql', + 'sql/llx_myobject.sql'=>'sql/llx_'.strtolower($objectname).'.sql', + 'scripts/myobject.php'=>'scripts/'.strtolower($objectname).'.php', + 'img/object_myobject.png'=>'img/object_'.strtolower($objectname).'.png', + 'class/myobject.class.php'=>'class/'.strtolower($objectname).'.class.php', + 'class/api_myobject.class.php'=>'class/api_'.strtolower($objectname).'.class.php', + 'class/MyObject.txt'=>'class/'.$objectname.'.txt' + ); + + foreach($filetogenerate as $srcfile => $destfile) + { + $result = dol_copy($srcdir.'/'.$srcfile, $destdir.'/'.$destfile); + if ($result <= 0) + { + if ($result < 0) + { + $error++; + $langs->load("errors"); + setEventMessages($langs->trans("ErrorFailToCopyFile", $srcdir.'/'.$srcfile, $destdir.'/'.$destfile), null, 'errors'); + } + else // $result == 0 + { + setEventMessages($langs->trans("FileAlreadyExists", $srcdir.'/'.$srcfile, $destdir.'/'.$destfile), null, 'warnings'); + } + } + else + { + // Copy is ok + } + } + + // Edit PHP files + foreach($filetogenerate as $destfile) + { + $phpfileval['fullname'] = $destdir.'/'.$destfile; + + //var_dump($phpfileval['fullname']); + $arrayreplacement=array( + 'mymodule'=>strtolower($modulename), + 'MyModule'=>$modulename, + 'MYMODULE'=>strtoupper($modulename), + 'My module'=>$modulename, + 'htdocs/modulebuilder/template/'=>'', + 'myobject'=>strtolower($objectname), + 'MyObject'=>$objectname + ); + + $result=dolReplaceInFile($phpfileval['fullname'], $arrayreplacement); + //var_dump($result); + if ($result < 0) + { + setEventMessages($langs->trans("ErrorFailToMakeReplacementInto", $phpfileval['fullname']), null, 'errors'); + } + } + + if (! $error) + { + setEventMessages('FilesForObjectInitialized', null); + } +} + + if ($dirins && $action == 'confirm_delete') { $modulelowercase=strtolower($module); @@ -485,9 +579,53 @@ elseif (! empty($module)) if ($tab == 'objects') { - print $langs->trans("FeatureNotYetAvailable"); + $head3 = array(); + $h=0; + $modulelowercase=strtolower($module); + + // Dir for module + $dir = $dirins.'/'.$modulelowercase.'/class'; + + $head3[$h][0] = $_SERVER["PHP_SELF"].'?tab=objects&module='.$module.'&tabobj=newobject'; + $head3[$h][1] = $langs->trans("NewObject"); + $head3[$h][2] = 'newobject'; + $h++; + + $listofobject = dol_dir_list($dir , 'files', 0, '\.txt$'); + foreach($listofobject as $fileobj) + { + $objectname = preg_replace('/\.txt$/', '', $fileobj['name']); + + $head3[$h][0] = $_SERVER["PHP_SELF"].'?tab=objects&module='.$module.'&tabobj='.$objectname; + $head3[$h][1] = $objectname; + $head3[$h][2] = $objectname; + $h++; + } + + dol_fiche_head($head3, $tabobj, '', -1, ''); + + if ($tabobj == 'newobject') + { + // New module + print '
'; + print ''; + print ''; + print ''; + print ''; + + print $langs->trans("EnterNameOfObjectDesc").'

'; + + print ''; + print ''; + print '
'; + } + + if ($tabobj == 'fields') + { + print $langs->trans("FeatureNotYetAvailable").'

'; + } } if ($tab == 'menus') diff --git a/htdocs/modulebuilder/template/class/MyObject.txt b/htdocs/modulebuilder/template/class/MyObject.txt new file mode 100644 index 00000000000..37ccaca81ed --- /dev/null +++ b/htdocs/modulebuilder/template/class/MyObject.txt @@ -0,0 +1 @@ +# If this file exists, it means the class and file for object MyOjbect was generated by ModuleBuilder. \ No newline at end of file diff --git a/htdocs/modulebuilder/template/class/myobject_api_class.class.php b/htdocs/modulebuilder/template/class/api_myobject.class.php similarity index 100% rename from htdocs/modulebuilder/template/class/myobject_api_class.class.php rename to htdocs/modulebuilder/template/class/api_myobject.class.php diff --git a/htdocs/modulebuilder/template/class/myobject.class.php b/htdocs/modulebuilder/template/class/myobject.class.php index f2d4daee8d4..9e66b9410f6 100644 --- a/htdocs/modulebuilder/template/class/myobject.class.php +++ b/htdocs/modulebuilder/template/class/myobject.class.php @@ -31,11 +31,11 @@ require_once DOL_DOCUMENT_ROOT . '/core/class/commonobject.class.php'; //require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php'; /** - * Class MyModuleObject + * Class MyObject * * Put here description of your class. */ -class MyModuleObject extends CommonObject +class MyObject extends CommonObject { /** * @var string Id to identify managed object diff --git a/htdocs/modulebuilder/template/img/myobject_mymodule.png b/htdocs/modulebuilder/template/img/object_myobject.png similarity index 100% rename from htdocs/modulebuilder/template/img/myobject_mymodule.png rename to htdocs/modulebuilder/template/img/object_myobject.png From 69b26dcb4ebea5a36cd6dcfb9fbf4ced48a910de Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 17 Jun 2017 21:23:52 +0200 Subject: [PATCH 050/227] Work on modulebuilder --- htdocs/langs/en_US/modulebuilder.lang | 10 +- htdocs/modulebuilder/index.php | 152 ++++++++++++++++-- .../template/class/myobject.class.php | 22 ++- 3 files changed, 159 insertions(+), 25 deletions(-) diff --git a/htdocs/langs/en_US/modulebuilder.lang b/htdocs/langs/en_US/modulebuilder.lang index b8300182b05..8d9a31cfdf7 100644 --- a/htdocs/langs/en_US/modulebuilder.lang +++ b/htdocs/langs/en_US/modulebuilder.lang @@ -17,7 +17,7 @@ ModuleBuilderDescpermissions=This tab is dedicated to define the new permissions ModuleBuilderDesctriggers=This is the view of triggers provided by your module. To include code executed when a triggered business event is launched, just edit this file with your IDE. ModuleBuilderDeschooks=This tab is dedicated to hooks. ModuleBuilderDescwidgets=This tab is dedicated to manage/build widgets. -ModuleBuilderDescbuildpackage=You can generate here a "ready to distribute" package file (a normalized .zip file) of your module. Just click on button to get your module package file. +ModuleBuilderDescbuildpackage=You can generate here a "ready to distribute" package file (a normalized .zip file) of your module. Just click on button to build the module package file. ModuleBuilderDescdangerzone=You can delete your module. WARNING: All files of module will be definetly lost ! DangerZone=Danger zone BuildPackage=Build package @@ -25,4 +25,10 @@ ModuleIsNotActive=This module was not activated yet (go into Home-Setup-Module t ModuleIsLive=This module has been activated. Any change on it may break a current active feature. DescriptionLong=Long description EditorName=Name of editor -EditorUrl=URL of editor \ No newline at end of file +EditorUrl=URL of editor +DescriptorFile=Descriptor file of module +ClassFile=File for PHP class +ApiClassFile=File for PHP API class +PageForList=PHP page for list of record +PageForCreateEditView=PHP page to create/edit/view a record +PathToModulePackage=Path to zip of module/application package \ No newline at end of file diff --git a/htdocs/modulebuilder/index.php b/htdocs/modulebuilder/index.php index 0f60d76ca4f..d9ae491b654 100644 --- a/htdocs/modulebuilder/index.php +++ b/htdocs/modulebuilder/index.php @@ -454,7 +454,9 @@ elseif (! empty($module)) $head2 = array(); $h=0; - $modulestatusinfo=img_info('').' '.$langs->trans("ModuleIsNotActive"); + $modulelowercase=strtolower($module); + + $modulestatusinfo=img_info('').' '.$langs->trans("ModuleIsNotActive"); if (! empty($conf->$module->enabled)) { $modulestatusinfo=img_warning().' '.$langs->trans("ModuleIsLive"); @@ -513,7 +515,12 @@ elseif (! empty($module)) if ($tab == 'description') { - print '
'; + $pathtofile = $modulelowercase.'/core/modules/mod'.$module.'.class.php'; + + print ' '.$langs->trans("DescriptorFile").' : '.$pathtofile.'
'; + print '
'; + + print '
'; print '
'; print ''; @@ -579,12 +586,9 @@ elseif (! empty($module)) if ($tab == 'objects') { - $head3 = array(); $h=0; - $modulelowercase=strtolower($module); - // Dir for module $dir = $dirins.'/'.$modulelowercase.'/class'; @@ -621,10 +625,92 @@ elseif (! empty($module)) print ''; print ''; } - - if ($tabobj == 'fields') + else { - print $langs->trans("FeatureNotYetAvailable").'

'; + try { + $pathtoclass = strtolower($module).'/class/'.strtolower($tabobj).'.class.php'; + $pathtoapi = strtolower($module).'/class/api_'.strtolower($tabobj).'.class.php'; + $pathtolist = strtolower($module).'/'.strtolower($tabobj).'_list.class.php'; + $pathtocard = strtolower($module).'/'.strtolower($tabobj).'_card.class.php'; + print ' '.$langs->trans("ClassFile").' : '.$pathtoclass.'
'; + print ' '.$langs->trans("ApiClassFile").' : '.$pathtoapi.'
'; + print ' '.$langs->trans("PageForList").' : '.$pathtolist.'
'; + print ' '.$langs->trans("PageForCreateEditView").' : '.$pathtocard.'
'; + + $result = dol_include_once($pathtoclass); + $tmpobjet = new $tabobj($db); + + $reflector = new ReflectionClass($tabobj); + $properties = $reflector->getProperties(); + $propdefault = $reflector->getDefaultProperties(); + + print load_fiche_titre($langs->trans("Properties"), '', ''); + + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + + print '
'; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + foreach($properties as $propkey => $propval) + { + if ($propval->class == $tabobj) + { + $propname=$propval->getName(); + + // Discard generic properties + if (in_array($propname, array('element', 'table_element', 'table_element_line', 'class_element_line', 'ismultientitymanaged'))) continue; + + // Keep or not lines + if (in_array($propname, array('fk_element', 'lines'))) continue; + + + print ''; + print ''; + + print ''; + + print ''; + + print ''; + print ''; + } + } + print '
'.$langs->trans("Property").''.$langs->trans("Description").''.$langs->trans("Type").''.$langs->trans("DefaultValue").'
'; + print ''; + print '
'; + print $propname; + print ''; + + print ''; + + print ''; + print $propdefault[$propname]; + print ''; + + print '
'; + + print ''; + } + catch(Exception $e) + { + print $e->getMessage(); + } } } @@ -666,10 +752,9 @@ elseif (! empty($module)) $var=True; foreach ($triggers as $trigger) { - print ''; print ''.$trigger['picto'].''; - print ''.$trigger['file'].''; + print ''.$trigger['relpath'].''; print ''.$trigger['status'].''; print ''; $text=$trigger['info']; @@ -698,11 +783,56 @@ elseif (! empty($module)) print '
'; } + $modulelowercase=strtolower($module); + + // Zip file to build + $FILENAMEZIP=''; + + // Load module + dol_include_once($modulelowercase.'/core/modules/mod'.$module.'.class.php'); + $class='mod'.$module; + + if (class_exists($class)) + { + try { + $moduleobj = new $class($db); + } + catch(Exception $e) + { + $error++; + dol_print_error($e->getMessage()); + } + } + else + { + $error++; + $langs->load("errors"); + dol_print_error($langs->trans("ErrorFailedToLoadModuleDescriptorForXXX", $module)); + exit; + } + + $arrayversion=explode('.',$moduleobj->version,3); + if (count($arrayversion)) + { + $FILENAMEZIP="module_".$modulelowercase.'-'.$arrayversion[0].'.'.$arrayversion[1].($arrayversion[2]?".".$arrayversion[2]:"").".zip"; + $outputfile = $conf->admin->dir_temp.'/'.$FILENAMEZIP; + } + + print ' '. $langs->trans("PathToModulePackage") . ' : '; + if (! dol_is_file($outputfile)) print ''.$langs->trans("PackageFileNotYetGenerated").''; + else { + print ''.$outputfile.''; + print ' ('.$langs->trans("GeneratedOn").' '.dol_print_date(dol_filemtime($outputfile), 'dayhour').')'; + } + print '
'; + + print '

'; + print '
'; print ''; print ''; print ''; - print ''; + print ''; print '
'; } diff --git a/htdocs/modulebuilder/template/class/myobject.class.php b/htdocs/modulebuilder/template/class/myobject.class.php index 9e66b9410f6..4993f60f83c 100644 --- a/htdocs/modulebuilder/template/class/myobject.class.php +++ b/htdocs/modulebuilder/template/class/myobject.class.php @@ -21,8 +21,8 @@ /** * \file htdocs/modulebuilder/template/class/myobject.class.php - * \ingroup mymodule othermodule1 othermodule2 - * \brief This file is an example for a CRUD class file (Create/Read/Update/Delete) + * \ingroup mymodule + * \brief This file is a CRUD class file for MyObject (Create/Read/Update/Delete) */ // Put here all includes required by your class file @@ -31,24 +31,22 @@ require_once DOL_DOCUMENT_ROOT . '/core/class/commonobject.class.php'; //require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php'; /** - * Class MyObject - * - * Put here description of your class. + * Class for MyObject */ class MyObject extends CommonObject { /** * @var string Id to identify managed object */ - public $element = 'mymoduleobject'; + public $element = 'myobject'; /** * @var string Name of table without prefix where object is stored */ - public $table_element = 'mymoduleobject'; + public $table_element = 'myobject'; /** * @var array Array with all fields and their property */ - public $picto = 'generic'; + public $picto = 'myobject'; /** * @var array Array with all fields and their property */ @@ -67,12 +65,12 @@ class MyObject extends CommonObject protected $ismultientitymanaged = 1; // 0=No test on entity, 1=Test with field entity, 2=Test with link by societe - public $table_element_line = 'mymoduleobjectdet'; - public $class_element_line = 'MyModuleObjectline'; - public $fk_element = 'fk_mymoduleobject'; + public $table_element_line = 'myobjectdet'; + public $class_element_line = 'MyObjectline'; + public $fk_element = 'fk_myobject'; /** - * @var MyModuleObjectLine[] Lines + * @var MyObjectLine[] Lines */ public $lines = array(); From 862b12abfd4bef2915abf492dd6fb7790657d234 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 17 Jun 2017 21:28:29 +0200 Subject: [PATCH 051/227] Fix responsive --- htdocs/opensurvey/card.php | 42 +++++++++++++++++++------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/htdocs/opensurvey/card.php b/htdocs/opensurvey/card.php index 18326321a4b..c634ca1ceaa 100644 --- a/htdocs/opensurvey/card.php +++ b/htdocs/opensurvey/card.php @@ -67,48 +67,48 @@ if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'e if (empty($reshook)) { if ($cancel) $action=''; - + // Delete if ($action == 'delete_confirm') { // Security check if (!$user->rights->opensurvey->write) accessforbidden(); - + $result=$object->delete($user,'',$numsondage); - + header('Location: '.dol_buildpath('/opensurvey/list.php',1)); exit(); } - + // Close if ($action == 'close') { $object->status = Opensurveysondage::STATUS_CLOSED; $object->update($user); } - + // Reopend if ($action == 'reopen') { $object->status = Opensurveysondage::STATUS_VALIDATED; $object->update($user); } - + // Update if ($action == 'update') { // Security check if (!$user->rights->opensurvey->write) accessforbidden(); - + $error=0; - + if (! GETPOST('nouveautitre')) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Title")), null, 'errors'); $error++; $action = 'edit'; } - + if (! $error) { $object->titre = GETPOST('nouveautitre'); @@ -118,7 +118,7 @@ if (empty($reshook)) $object->allow_comments = GETPOST('cancomment') == 'on' ? true : false; $object->allow_spy = GETPOST('canseeothersvote') == 'on' ? true : false; $object->mailsonde = GETPOST('mailsonde') == 'on' ? true : false; - + $res=$object->update($user); if ($res < 0) { @@ -132,7 +132,7 @@ if (empty($reshook)) if (GETPOST('ajoutcomment')) { $error=0; - + if (! GETPOST('comment')) { $error++; @@ -143,33 +143,33 @@ if (empty($reshook)) $error++; setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("User")), null, 'errors'); } - + if (! $error) { $comment = GETPOST("comment"); $comment_user = GETPOST('commentuser'); - + $resql = $object->addComment($comment, $comment_user); - + if (! $resql) { setEventMessages($langs->trans('ErrorInsertingComment'), null, 'errors'); } } } - + // Delete comment $idcomment=GETPOST('deletecomment','int'); if ($idcomment) { // Security check if (!$user->rights->opensurvey->write) accessforbidden(); - + $resql = $object->deleteComment($idcomment); } - + if ($action == 'edit') { - + // Security check if (!$user->rights->opensurvey->write) accessforbidden(); } @@ -307,7 +307,7 @@ print ''; // Expire date print ''.$langs->trans('ExpireDate').''; if ($action == 'edit') print $form->select_date($expiredate?$expiredate:$object->date_fin,'expire',0,0,0,'',1,0,1); -else +else { print dol_print_date($object->date_fin,'day'); if ($object->date_fin && $object->date_fin < dol_now()) print img_warning($langs->trans("Expired")); @@ -377,7 +377,7 @@ if ($action != 'edit' && $user->rights->opensurvey->write) { //Opened button print ''.$langs->trans("ReOpen") . ''; } - + //Delete button print ''.$langs->trans('Delete').''; } @@ -420,7 +420,7 @@ print '
'; // Add comment if ($object->allow_comments) { print $langs->trans("AddACommentForPoll") . '
'; - print '
'."\n"; + print '
'."\n"; print $langs->trans("Name") .':
'."\n"; print '
'."\n"; if (isset($erreur_commentaire_vide) && $erreur_commentaire_vide=="yes") { From 787d6946b220453e6337d56e1b6859ac266dcee9 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 18 Jun 2017 12:30:18 +0200 Subject: [PATCH 052/227] Continue work started on module builder --- htdocs/langs/en_US/modulebuilder.lang | 14 +- htdocs/modulebuilder/index.php | 361 ++++++++++++------ .../modulebuilder/template/class/MyObject.txt | 3 +- .../template/class/myobject.class.php | 62 ++- .../modulebuilder/template/modulebuilder.txt | 5 +- 5 files changed, 294 insertions(+), 151 deletions(-) diff --git a/htdocs/langs/en_US/modulebuilder.lang b/htdocs/langs/en_US/modulebuilder.lang index 8d9a31cfdf7..fe636fd4f2d 100644 --- a/htdocs/langs/en_US/modulebuilder.lang +++ b/htdocs/langs/en_US/modulebuilder.lang @@ -1,24 +1,25 @@ # Dolibarr language file - Source file is en_US - loan -ModuleBuilderDesc=This tools give you utilites to build or edit your own module. +ModuleBuilderDesc=This tools give you utilites to build or edit your own module (More information here). EnterNameOfModuleDesc=Enter name of the module/application to create with no spaces. Use uppercase to separate words (For example: MyModule, EcommerceForShop, SyncWithMySystem...) EnterNameOfObjectDesc=Enter name of the object to create with no spaces. Use uppercase to separate words (For example: MyObject, Student, Teacher...) ModuleBuilderDesc2=Path were modules are generated/edited (first alternative directory defined into %s): %s ModuleBuilderDesc3=Generated/editable modules found: %s (they are detected as editable when the file %s exists in root of module directory). NewModule=New module NewObject=New object -ModuleKey=Key for new module -ObjectKey=Key for new object +ModuleKey=Module key +ObjectKey=Object key ModuleInitialized=Module initialized FilesForObjectInitialized=Files for new object initialized ModuleBuilderDescdescription=Enter here all general information that describe your module -ModuleBuilderDescobjects=Define here the new objects you want to manage with your module. A page to list them and a page to create/edit/view a card will be generated. +ModuleBuilderDescobjects=Define here the objects you want to manage with your module. A sql file, a page to list them, to create/edit/view a card and an API will be generated. ModuleBuilderDescmenus=This tab is dedicated to define menu entries provided by your module. ModuleBuilderDescpermissions=This tab is dedicated to define the new permissions you want to provide with your module. ModuleBuilderDesctriggers=This is the view of triggers provided by your module. To include code executed when a triggered business event is launched, just edit this file with your IDE. ModuleBuilderDeschooks=This tab is dedicated to hooks. ModuleBuilderDescwidgets=This tab is dedicated to manage/build widgets. ModuleBuilderDescbuildpackage=You can generate here a "ready to distribute" package file (a normalized .zip file) of your module. Just click on button to build the module package file. -ModuleBuilderDescdangerzone=You can delete your module. WARNING: All files of module will be definetly lost ! +EnterNameOfModuleToDeleteDesc=You can delete your module. WARNING: All files of module will be definitly lost ! +EnterNameOfObjectToDeleteDesc=You can delete an object. WARNING: All files related to object will be definitly lost ! DangerZone=Danger zone BuildPackage=Build package ModuleIsNotActive=This module was not activated yet (go into Home-Setup-Module to make it live) @@ -31,4 +32,5 @@ ClassFile=File for PHP class ApiClassFile=File for PHP API class PageForList=PHP page for list of record PageForCreateEditView=PHP page to create/edit/view a record -PathToModulePackage=Path to zip of module/application package \ No newline at end of file +PathToModulePackage=Path to zip of module/application package +SpaceOrSpecialCharAreNotAllowed=Spaces or special characters are not allowed. \ No newline at end of file diff --git a/htdocs/modulebuilder/index.php b/htdocs/modulebuilder/index.php index d9ae491b654..7aa3440b8a8 100644 --- a/htdocs/modulebuilder/index.php +++ b/htdocs/modulebuilder/index.php @@ -58,41 +58,50 @@ $FILEFLAG='modulebuilder.txt'; if ($dirins && $action == 'initmodule' && $modulename) { - $srcdir = DOL_DOCUMENT_ROOT.'/modulebuilder/template'; - $destdir = $dirins.'/'.strtolower($modulename); - - $arrayreplacement=array( - 'mymodule'=>strtolower($modulename), - 'MyModule'=>$modulename - ); - - $result = dolCopyDir($srcdir, $destdir, 0, 0, $arrayreplacement); - //dol_mkdir($destfile); - if ($result <= 0) + if (preg_match('/\s/', $modulename)) { - if ($result < 0) - { - $error++; - $langs->load("errors"); - setEventMessages($langs->trans("ErrorFailToCopyDir", $srcdir, $destdir), null, 'errors'); - } - else // $result == 0 - { - setEventMessages($langs->trans("AllFilesDidAlreadyExist", $srcdir, $destdir), null, 'warnings'); - } + $error++; + setEventMessages($langs->trans("SpaceOrSpecialCharAreNotAllowed"), null, 'errors'); } - // Delete some files - dol_delete_file($destdir.'/myobject_card.php'); - dol_delete_file($destdir.'/myobject_list.php'); - dol_delete_file($destdir.'/test/phpunit/MyObjectTest.php'); - dol_delete_file($destdir.'/sql/llx_myobject.key.sql'); - dol_delete_file($destdir.'/sql/llx_myobject.sql'); - dol_delete_file($destdir.'/scripts/myobject.php'); - dol_delete_file($destdir.'/img/object_myobject.png'); - dol_delete_file($destdir.'/class/myobject.class.php'); - dol_delete_file($destdir.'/class/api_myobject.class.php'); - dol_delete_file($destdir.'/class/MyObject.txt'); + if (! $error) + { + $srcdir = DOL_DOCUMENT_ROOT.'/modulebuilder/template'; + $destdir = $dirins.'/'.strtolower($modulename); + + $arrayreplacement=array( + 'mymodule'=>strtolower($modulename), + 'MyModule'=>$modulename + ); + + $result = dolCopyDir($srcdir, $destdir, 0, 0, $arrayreplacement); + //dol_mkdir($destfile); + if ($result <= 0) + { + if ($result < 0) + { + $error++; + $langs->load("errors"); + setEventMessages($langs->trans("ErrorFailToCopyDir", $srcdir, $destdir), null, 'errors'); + } + else // $result == 0 + { + setEventMessages($langs->trans("AllFilesDidAlreadyExist", $srcdir, $destdir), null, 'warnings'); + } + } + + // Delete some files + dol_delete_file($destdir.'/myobject_card.php'); + dol_delete_file($destdir.'/myobject_list.php'); + dol_delete_file($destdir.'/test/phpunit/MyObjectTest.php'); + dol_delete_file($destdir.'/sql/llx_myobject.key.sql'); + dol_delete_file($destdir.'/sql/llx_myobject.sql'); + dol_delete_file($destdir.'/scripts/myobject.php'); + dol_delete_file($destdir.'/img/object_myobject.png'); + dol_delete_file($destdir.'/class/myobject.class.php'); + dol_delete_file($destdir.'/class/api_myobject.class.php'); + dol_delete_file($destdir.'/class/MyObject.txt'); + } // Edit PHP files if (! $error) @@ -129,74 +138,86 @@ if ($dirins && $action == 'initmodule' && $modulename) if ($dirins && $action == 'initobject' && $module && $objectname) { - $srcdir = DOL_DOCUMENT_ROOT.'/modulebuilder/template'; - $destdir = $dirins.'/'.strtolower($module); - - $arrayreplacement=array( - 'mymodule'=>strtolower($module), - 'MyModule'=>$module, - 'myobject'=>strtolower($objectname), - 'MyObject'=>$objectname - ); - - - // Delete some files - $filetogenerate = array( - 'myobject_card.php'=>strtolower($objectname).'_card.php', - 'myobject_list.php'=>strtolower($objectname).'_list.php', - 'test/phpunit/MyObjectTest.php'=>'test/phpunit/'.$objectname.'Test.php', - 'sql/llx_myobject.key.sql'=>'sql/llx_'.strtolower($objectname).'.key.sql', - 'sql/llx_myobject.sql'=>'sql/llx_'.strtolower($objectname).'.sql', - 'scripts/myobject.php'=>'scripts/'.strtolower($objectname).'.php', - 'img/object_myobject.png'=>'img/object_'.strtolower($objectname).'.png', - 'class/myobject.class.php'=>'class/'.strtolower($objectname).'.class.php', - 'class/api_myobject.class.php'=>'class/api_'.strtolower($objectname).'.class.php', - 'class/MyObject.txt'=>'class/'.$objectname.'.txt' - ); - - foreach($filetogenerate as $srcfile => $destfile) + if (preg_match('/\s/', $objectname)) { - $result = dol_copy($srcdir.'/'.$srcfile, $destdir.'/'.$destfile); - if ($result <= 0) - { - if ($result < 0) - { - $error++; - $langs->load("errors"); - setEventMessages($langs->trans("ErrorFailToCopyFile", $srcdir.'/'.$srcfile, $destdir.'/'.$destfile), null, 'errors'); - } - else // $result == 0 - { - setEventMessages($langs->trans("FileAlreadyExists", $srcdir.'/'.$srcfile, $destdir.'/'.$destfile), null, 'warnings'); - } - } - else - { - // Copy is ok - } + $error++; + setEventMessages($langs->trans("SpaceOrSpecialCharAreNotAllowed"), null, 'errors'); } - // Edit PHP files - foreach($filetogenerate as $destfile) + if (! $error) { - $phpfileval['fullname'] = $destdir.'/'.$destfile; + $srcdir = DOL_DOCUMENT_ROOT.'/modulebuilder/template'; + $destdir = $dirins.'/'.strtolower($module); - //var_dump($phpfileval['fullname']); $arrayreplacement=array( - 'mymodule'=>strtolower($modulename), - 'MyModule'=>$modulename, - 'MYMODULE'=>strtoupper($modulename), - 'My module'=>$modulename, - 'htdocs/modulebuilder/template/'=>'', + 'mymodule'=>strtolower($module), + 'MyModule'=>$module, 'myobject'=>strtolower($objectname), 'MyObject'=>$objectname ); - $result=dolReplaceInFile($phpfileval['fullname'], $arrayreplacement); - //var_dump($result); - if ($result < 0) + + // Delete some files + $filetogenerate = array( + 'myobject_card.php'=>strtolower($objectname).'_card.php', + 'myobject_list.php'=>strtolower($objectname).'_list.php', + 'test/phpunit/MyObjectTest.php'=>'test/phpunit/'.$objectname.'Test.php', + 'sql/llx_myobject.key.sql'=>'sql/llx_'.strtolower($objectname).'.key.sql', + 'sql/llx_myobject.sql'=>'sql/llx_'.strtolower($objectname).'.sql', + 'scripts/myobject.php'=>'scripts/'.strtolower($objectname).'.php', + 'img/object_myobject.png'=>'img/object_'.strtolower($objectname).'.png', + 'class/myobject.class.php'=>'class/'.strtolower($objectname).'.class.php', + 'class/api_myobject.class.php'=>'class/api_'.strtolower($objectname).'.class.php', + 'class/MyObject.txt'=>'class/'.$objectname.'.txt' + ); + + foreach($filetogenerate as $srcfile => $destfile) { - setEventMessages($langs->trans("ErrorFailToMakeReplacementInto", $phpfileval['fullname']), null, 'errors'); + $result = dol_copy($srcdir.'/'.$srcfile, $destdir.'/'.$destfile); + if ($result <= 0) + { + if ($result < 0) + { + $error++; + $langs->load("errors"); + setEventMessages($langs->trans("ErrorFailToCopyFile", $srcdir.'/'.$srcfile, $destdir.'/'.$destfile), null, 'errors'); + } + else // $result == 0 + { + setEventMessages($langs->trans("FileAlreadyExists", $srcdir.'/'.$srcfile, $destdir.'/'.$destfile), null, 'warnings'); + } + } + else + { + // Copy is ok + } + } + } + + if (! $error) + { + // Edit PHP files + foreach($filetogenerate as $destfile) + { + $phpfileval['fullname'] = $destdir.'/'.$destfile; + + //var_dump($phpfileval['fullname']); + $arrayreplacement=array( + 'mymodule'=>strtolower($modulename), + 'MyModule'=>$modulename, + 'MYMODULE'=>strtoupper($modulename), + 'My module'=>$modulename, + 'htdocs/modulebuilder/template/'=>'', + 'myobject'=>strtolower($objectname), + 'MyObject'=>$objectname + ); + + $result=dolReplaceInFile($phpfileval['fullname'], $arrayreplacement); + //var_dump($result); + if ($result < 0) + { + setEventMessages($langs->trans("ErrorFailToMakeReplacementInto", $phpfileval['fullname']), null, 'errors'); + } } } @@ -206,18 +227,90 @@ if ($dirins && $action == 'initobject' && $module && $objectname) } } - if ($dirins && $action == 'confirm_delete') { - $modulelowercase=strtolower($module); + if (preg_match('/\s/', $module)) + { + $error++; + setEventMessages($langs->trans("SpaceOrSpecialCharAreNotAllowed"), null, 'errors'); + } - // Dir for module - $dir = $dirins.'/'.$modulelowercase; + if (! $error) + { + $modulelowercase=strtolower($module); - dol_delete_dir_recursive($dir); + // Dir for module + $dir = $dirins.'/'.$modulelowercase; - header("Location: ".DOL_URL_ROOT.'/modulebuilder/index.php?module=initmodule'); - exit; + $result = dol_delete_dir_recursive($dir); + + if ($result > 0) + { + setEventMessages($langs->trans("DirDeleted"), null); + } + else + { + setEventMessages($langs->trans("NothingDeleted"), null, 'warnings'); + } + } + + //header("Location: ".DOL_URL_ROOT.'/modulebuilder/index.php?module=initmodule'); + //exit; + $action = ''; + $module = 'deletemodule'; +} + +if ($dirins && $action == 'confirm_deleteobject' && $objectname) +{ + if (preg_match('/\s/', $objectname)) + { + $error++; + setEventMessages($langs->trans("SpaceOrSpecialCharAreNotAllowed"), null, 'errors'); + } + + if (! $error) + { + $modulelowercase=strtolower($module); + $objectlowercase=strtolower($objectname); + + // Dir for module + $dir = $dirins.'/'.$modulelowercase; + + // Delete some files + $filetogenerate = array( + 'myobject_card.php'=>strtolower($objectname).'_card.php', + 'myobject_list.php'=>strtolower($objectname).'_list.php', + 'test/phpunit/MyObjectTest.php'=>'test/phpunit/'.$objectname.'Test.php', + 'sql/llx_myobject.key.sql'=>'sql/llx_'.strtolower($objectname).'.key.sql', + 'sql/llx_myobject.sql'=>'sql/llx_'.strtolower($objectname).'.sql', + 'scripts/myobject.php'=>'scripts/'.strtolower($objectname).'.php', + 'img/object_myobject.png'=>'img/object_'.strtolower($objectname).'.png', + 'class/myobject.class.php'=>'class/'.strtolower($objectname).'.class.php', + 'class/api_myobject.class.php'=>'class/api_'.strtolower($objectname).'.class.php', + 'class/MyObject.txt'=>'class/'.$objectname.'.txt' + ); + + $resultko = 0; + foreach($filetogenerate as $filetodelete) + { + $resulttmp = dol_delete_file($dir.'/'.$filetodelete, 0, 0, 1); + if (! $resulttmp) $resultko++; + } + + if ($resultko == 0) + { + setEventMessages($langs->trans("FilesDeleted"), null); + } + else + { + setEventMessages($langs->trans("ErrorSomeFilesCouldNotBeDeleted"), null, 'warnings'); + } + } + + //header("Location: ".DOL_URL_ROOT.'/modulebuilder/index.php?module=initmodule'); + //exit; + $action = ''; + $tabobj = 'deleteobject'; } if ($dirins && $action == 'generatepackage') @@ -341,7 +434,7 @@ if (!empty($conf->modulebuilder->enabled) && $mainmenu == 'modulebuilder') // En // Show description of content $newdircustom=$dirins; if (empty($newdircustom)) $newdircustom=img_warning(); -print $langs->trans("ModuleBuilderDesc").'
'; +print $langs->trans("ModuleBuilderDesc", 'https://wiki.dolibarr.org/index.php/Module_development#Create_your_module').'
'; print $langs->trans("ModuleBuilderDesc2", 'conf/conf.php', $newdircustom).'
'; $message=''; @@ -381,7 +474,7 @@ print $langs->trans("ModuleBuilderDesc3", count($listofmodules), $FILEFLAG).'
$tmpmodulewithcase) $h++; } +$head[$h][0] = $_SERVER["PHP_SELF"].'?module=deletemodule'; +$head[$h][1] = $langs->trans("DangerZone"); +$head[$h][2] = 'deletemodule'; +$h++; dol_fiche_head($head, $module, $langs->trans("Modules"), -1, 'generic'); @@ -446,6 +543,19 @@ if ($module == 'initmodule') print ''; print ''; } +elseif ($module == 'deletemodule') +{ + print '
'; + print ''; + print ''; + print ''; + + print $langs->trans("EnterNameOfModuleToDeleteDesc").'

'; + + print ''; + print ''; + print '
'; +} elseif (! empty($module)) { // Tabs for module @@ -502,11 +612,6 @@ elseif (! empty($module)) $head2[$h][2] = 'buildpackage'; $h++; - $head2[$h][0] = $_SERVER["PHP_SELF"].'?tab=dangerzone&module='.$module; - $head2[$h][1] = $langs->trans("DangerZone"); - $head2[$h][2] = 'dangerzone'; - $h++; - print $modulestatusinfo.'

'; dol_fiche_head($head2, $tab, '', -1, ''); @@ -532,6 +637,7 @@ elseif (! empty($module)) print ''; print $langs->trans("Numero"); + print ' ('.$langs->trans("SeeHere").')'; print ''; print $moduleobj->numero; print ''; @@ -608,6 +714,12 @@ elseif (! empty($module)) $h++; } + $head3[$h][0] = $_SERVER["PHP_SELF"].'?tab=objects&module='.$module.'&tabobj=deleteobject'; + $head3[$h][1] = $langs->trans("DangerZone"); + $head3[$h][2] = 'deleteobject'; + $h++; + + dol_fiche_head($head3, $tabobj, '', -1, ''); if ($tabobj == 'newobject') @@ -625,6 +737,21 @@ elseif (! empty($module)) print ''; print ''; } + elseif ($tabobj == 'deleteobject') + { + // New module + print '
'; + print ''; + print ''; + print ''; + print ''; + + print $langs->trans("EnterNameOfObjectToDeleteDesc").'

'; + + print ''; + print ''; + print '
'; + } else { try { @@ -641,8 +768,9 @@ elseif (! empty($module)) $tmpobjet = new $tabobj($db); $reflector = new ReflectionClass($tabobj); - $properties = $reflector->getProperties(); - $propdefault = $reflector->getDefaultProperties(); + $properties = $reflector->getProperties(); // Can also use get_object_vars + $propdefault = $reflector->getDefaultProperties(); // Can also use get_object_vars + //$propstat = $reflector->getStaticProperties(); print load_fiche_titre($langs->trans("Properties"), '', ''); @@ -655,8 +783,10 @@ elseif (! empty($module)) print ''; print ''; - print ''; - print ''; + print ''; + print ''; print ''; print ''; print ''; @@ -676,7 +806,7 @@ elseif (! empty($module)) $propname=$propval->getName(); // Discard generic properties - if (in_array($propname, array('element', 'table_element', 'table_element_line', 'class_element_line', 'ismultientitymanaged'))) continue; + if (in_array($propname, array('element', 'childtables', 'table_element', 'table_element_line', 'class_element_line', 'isnolinkedbythird', 'ismultientitymanaged'))) continue; // Keep or not lines if (in_array($propname, array('fk_element', 'lines'))) continue; @@ -686,11 +816,10 @@ elseif (! empty($module)) print $propname; print ''; print ''; - print ''; print ' diff --git a/htdocs/core/tpl/passwordforgotten.tpl.php b/htdocs/core/tpl/passwordforgotten.tpl.php index b641627b789..c05916d55a7 100644 --- a/htdocs/core/tpl/passwordforgotten.tpl.php +++ b/htdocs/core/tpl/passwordforgotten.tpl.php @@ -28,6 +28,9 @@ if (GETPOST('dol_use_jmobile')) $conf->dol_use_jmobile=1; // If we force to use jmobile, then we reenable javascript if (! empty($conf->dol_use_jmobile)) $conf->use_javascript_ajax=1; +$php_self = dol_escape_htmltag($_SERVER['PHP_SELF']); +$php_self.= dol_escape_htmltag($_SERVER["QUERY_STRING"])?'?'.dol_escape_htmltag($_SERVER["QUERY_STRING"]):''; + print top_htmlhead('',$langs->trans('SendNewPassword')); ?> @@ -94,7 +97,7 @@ if (! empty($hookmanager->resArray['options'])) { } ?> -resArray['options'])) {
-
class="button" name="password" value="trans('SendNewPassword'); ?>" tabindex="4" /> +
class="button" name="password" value="trans('SendNewPassword'); ?>" tabindex="4" />
diff --git a/htdocs/ecm/ajax/ecmdatabase.php b/htdocs/ecm/ajax/ecmdatabase.php index ac3a45d5683..6753a4299b0 100644 --- a/htdocs/ecm/ajax/ecmdatabase.php +++ b/htdocs/ecm/ajax/ecmdatabase.php @@ -39,7 +39,7 @@ $element = GETPOST('element', 'alpha'); top_httphead(); -//print ''."\n"; +//print ''."\n"; // Load original field value if (isset($action) && ! empty($action)) diff --git a/htdocs/expensereport/ajax/ajaxprojet.php b/htdocs/expensereport/ajax/ajaxprojet.php index 6b9dd7e062f..423677c5da5 100644 --- a/htdocs/expensereport/ajax/ajaxprojet.php +++ b/htdocs/expensereport/ajax/ajaxprojet.php @@ -46,7 +46,7 @@ require '../../main.inc.php'; //top_htmlhead("", "", 1); // Replaced with top_httphead. An ajax page does not need html header. top_httphead(); -//print ''."\n"; +//print ''."\n"; dol_syslog(join(',',$_GET)); diff --git a/htdocs/externalsite/frames.php b/htdocs/externalsite/frames.php index adf9d547073..6005b8e55b6 100644 --- a/htdocs/externalsite/frames.php +++ b/htdocs/externalsite/frames.php @@ -34,8 +34,8 @@ if (empty($conf->global->EXTERNALSITE_URL)) llxFooter(); } -$mainmenu=GETPOST('mainmenu', 'alpha'); -$leftmenu=GETPOST('leftmenu', 'alpha'); +$mainmenu=GETPOST('mainmenu', "aZ09"); +$leftmenu=GETPOST('leftmenu', "aZ09"); $idmenu=GETPOST('idmenu', 'int'); $theme=GETPOST('theme', 'alpha'); $codelang=GETPOST('lang', 'aZ09'); diff --git a/htdocs/fourn/ajax/getSupplierPrices.php b/htdocs/fourn/ajax/getSupplierPrices.php index af3d728dc78..9a8c24c4eba 100644 --- a/htdocs/fourn/ajax/getSupplierPrices.php +++ b/htdocs/fourn/ajax/getSupplierPrices.php @@ -46,7 +46,7 @@ $langs->load('margins'); top_httphead(); -//print ''."\n"; +//print ''."\n"; if ($idprod > 0) { @@ -55,7 +55,7 @@ if ($idprod > 0) $sorttouse = 's.nom, pfp.quantity, pfp.price'; if (GETPOST('bestpricefirst')) $sorttouse = 'pfp.unitprice, s.nom, pfp.quantity, pfp.price'; - + $productSupplierArray = $producttmp->list_product_fournisseur_price($idprod, $sorttouse); // We list all price per supplier, and then firstly with the lower quantity. So we can choose first one with enough quantity into list. if ( is_array($productSupplierArray)) { @@ -63,15 +63,15 @@ if ($idprod > 0) { $price = $productSupplier->fourn_price * (1 - $productSupplier->fourn_remise_percent / 100); $unitprice = $productSupplier->fourn_unitprice * (1 - $productSupplier->fourn_remise_percent / 100); - + $title = $productSupplier->fourn_name.' - '.$productSupplier->fourn_ref.' - '; - + if ($productSupplier->fourn_qty == 1) { $title.= price($price,0,$langs,0,0,-1,$conf->currency)."/"; } $title.= $productSupplier->fourn_qty.' '.($productSupplier->fourn_qty == 1 ? $langs->trans("Unit") : $langs->trans("Units")); - + if ($productSupplier->fourn_qty > 1) { $title.=" - "; @@ -84,19 +84,19 @@ if ($idprod > 0) $title.= price($productSupplier->fourn_unitcharges,0,$langs,0,0,-1,$conf->currency); $price += $productSupplier->fourn_unitcharges; } - + $label = price($price,0,$langs,0,0,-1,$conf->currency)."/".$langs->trans("Unit"); if ($productSupplier->fourn_ref) $label.=' ('.$productSupplier->fourn_ref.')'; - + $prices[] = array("id" => $productSupplier->product_fourn_price_id, "price" => price2num($price,0,'',0), "label" => $label, "title" => $title); // For price field, we must use price2num(), for label or title, price() } } - + // Add price for costprice $price=$producttmp->cost_price; $prices[] = array("id" => 'costprice', "price" => price2num($price), "label" => $langs->trans("CostPrice").': '.price($price,0,$langs,0,0,-1,$conf->currency), "title" => $langs->trans("PMPValueShort").': '.price($price,0,$langs,0,0,-1,$conf->currency)); // For price field, we must use price2num(), for label or title, price() - if(!empty($conf->stock->enabled)) + if(!empty($conf->stock->enabled)) { // Add price for pmp $price=$producttmp->pmp; diff --git a/htdocs/holiday/list.php b/htdocs/holiday/list.php index 1ab8fbd785f..9523d489256 100644 --- a/htdocs/holiday/list.php +++ b/htdocs/holiday/list.php @@ -66,7 +66,7 @@ $year_end = GETPOST('year_end'); $search_employe = GETPOST('search_employe'); $search_valideur = GETPOST('search_valideur'); $search_statut = GETPOST('select_statut'); -$type = GETPOST('type','int'); +$type = GETPOST('type','int'); // List of fields to search into when doing a "search in all" $fieldstosearchall = array( @@ -82,7 +82,7 @@ $fieldstosearchall = array( * Actions */ -if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // Both test are required to be compatible with all browsers +if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // All tests are required to be compatible with all browsers { $search_ref=""; $month_create=""; @@ -168,7 +168,7 @@ if($year_create > 0) { } } else { if($month_create > 0) { - $filter.= " AND date_format(cp.date_create, '%m') = '$month_create'"; + $filter.= " AND date_format(cp.date_create, '%m') = '".$db->escape($month_create)."'"; } } @@ -313,7 +313,7 @@ print ''; // DATE CREATE print '
'; @@ -409,7 +409,7 @@ if (! empty($holiday->holiday)) $userstatic->login=$infos_CP['user_login']; $userstatic->statut=$infos_CP['user_statut']; $userstatic->photo=$infos_CP['user_photo']; - + // Valideur $approbatorstatic->id=$infos_CP['fk_validator']; $approbatorstatic->lastname=$infos_CP['validator_lastname']; @@ -417,7 +417,7 @@ if (! empty($holiday->holiday)) $approbatorstatic->login=$infos_CP['validator_login']; $approbatorstatic->statut=$infos_CP['validator_statut']; $approbatorstatic->photo=$infos_CP['validator_photo']; - + $date = $infos_CP['date_create']; print ''; diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index 7e52b454f97..2806f2d06a0 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -97,8 +97,9 @@ function test_sql_and_script_inject($val, $type) $sql_inj += preg_match('/'; - } - + } + $titletoshow=$langs->trans("Documents"); if (! empty($title)) $titletoshow=$title; @@ -556,7 +556,7 @@ class FormFile if (empty($noform)) $out.= ''; $out.= ''; $out.= ''; - + $out.= load_fiche_titre($titletoshow, '', ''); $out.= '
'.$langs->trans("Property").''.$langs->trans("Description").''.$langs->trans("Property"); + print ' ('.$langs->trans("Example").')'; + print ''.$langs->trans("Comment").''.$langs->trans("Type").''.$langs->trans("DefaultValue").''; - + print $propval->getDocComment(); print ''; - + print gettype($tmpobjet->$propname); print ''; @@ -836,16 +965,6 @@ elseif (! empty($module)) print ''; } - if ($tab == 'dangerzone') - { - print '
'; - print ''; - print ''; - print ''; - print ''; - print '
'; - } - dol_fiche_end(); } } diff --git a/htdocs/modulebuilder/template/class/MyObject.txt b/htdocs/modulebuilder/template/class/MyObject.txt index 37ccaca81ed..e86e7cdf5c6 100644 --- a/htdocs/modulebuilder/template/class/MyObject.txt +++ b/htdocs/modulebuilder/template/class/MyObject.txt @@ -1 +1,2 @@ -# If this file exists, it means the class and file for object MyOjbect was generated by ModuleBuilder. \ No newline at end of file +# DO NOT DELETE THIS FILE MANUALLY +# If this file exists, it means the class and file for object MyOjbect was generated by ModuleBuilder. Use ModuleBuilder if you want to delete object. \ No newline at end of file diff --git a/htdocs/modulebuilder/template/class/myobject.class.php b/htdocs/modulebuilder/template/class/myobject.class.php index 4993f60f83c..c66110fddf6 100644 --- a/htdocs/modulebuilder/template/class/myobject.class.php +++ b/htdocs/modulebuilder/template/class/myobject.class.php @@ -36,43 +36,63 @@ require_once DOL_DOCUMENT_ROOT . '/core/class/commonobject.class.php'; class MyObject extends CommonObject { /** - * @var string Id to identify managed object + * @var string ID to identify managed object */ public $element = 'myobject'; /** * @var string Name of table without prefix where object is stored */ public $table_element = 'myobject'; - /** - * @var array Array with all fields and their property + + /** + * @var array Does this field is linked to a thirdparty ? + */ + protected $isnolinkedbythird=1; + /** + * @var array Does myobject support multicompany module ? 0=No test on entity, 1=Test with field entity, 2=Test with link by societe + */ + protected $ismultientitymanaged = 1; + + + /** + * @var string String with name of icon for myobject */ public $picto = 'myobject'; - /** - * @var array Array with all fields and their property + + /** + * @var int Entity Id + */ + public $entity; + + /** + * @var array Array with all fields and their property */ public $fields; + + + // If this object has a subtable with lines + /** - * @var mixed Sample property 1 + * @var int Name of subtable line */ - public $prop1; + //public $table_element_line = 'myobjectdet'; /** - * @var mixed Sample property 2 + * @var int Field with ID of parent key if this field has a parent */ - public $prop2; - - //... - - protected $ismultientitymanaged = 1; // 0=No test on entity, 1=Test with field entity, 2=Test with link by societe - - public $table_element_line = 'myobjectdet'; - public $class_element_line = 'MyObjectline'; - public $fk_element = 'fk_myobject'; - - /** - * @var MyObjectLine[] Lines + //public $fk_element = 'fk_myobject'; + /** + * @var int Name of subtable class that manage subtable lines */ - public $lines = array(); + //public $class_element_line = 'MyObjectline'; + /** + * @var array Array of child tables (child tables to delete before deleting a record) + */ + //protected $childtables=array('myobjectdet'); + /** + * @var MyObjectLine[] Array of subtable lines + */ + //public $lines = array(); diff --git a/htdocs/modulebuilder/template/modulebuilder.txt b/htdocs/modulebuilder/template/modulebuilder.txt index 5cdb6c6e6e8..24ea0d6eac5 100644 --- a/htdocs/modulebuilder/template/modulebuilder.txt +++ b/htdocs/modulebuilder/template/modulebuilder.txt @@ -1,2 +1,3 @@ -File to flag module built using official module template. -When this file is present into a module directory, you can edit it with the module builder tool. \ No newline at end of file +# DO NOT DELETE THIS FILE MANUALLY +# File to flag module built using official module template. +# When this file is present into a module directory, you can edit it with the module builder tool. Use ModuleBuilder if you want to delete module. \ No newline at end of file From cde0da6e1286febe81523590c3cbb693187ee1af Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 18 Jun 2017 12:48:58 +0200 Subject: [PATCH 053/227] Fix responsive --- htdocs/public/demo/index.php | 2 +- htdocs/public/opensurvey/studs.php | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/public/demo/index.php b/htdocs/public/demo/index.php index f9bb4db7ecf..60559eb7aed 100644 --- a/htdocs/public/demo/index.php +++ b/htdocs/public/demo/index.php @@ -291,7 +291,7 @@ print ''; print '
'; print '
'; print '
'.$langs->trans("DemoDesc").'

'; -print ''.$langs->trans("ChooseYourDemoProfil").''; +print '
'.$langs->trans("ChooseYourDemoProfil").'
'; print '
'; print '
'; diff --git a/htdocs/public/opensurvey/studs.php b/htdocs/public/opensurvey/studs.php index 8e769452ec1..5f4c7a1fb03 100644 --- a/htdocs/public/opensurvey/studs.php +++ b/htdocs/public/opensurvey/studs.php @@ -113,14 +113,14 @@ if (GETPOST("boutonp") || GETPOST("boutonp.x") || GETPOST("boutonp_x")) // bout } $nom=substr(GETPOST("nom"),0,64); - + // Check if vote already exists $sql = 'SELECT id_users, nom as name'; $sql.= ' FROM '.MAIN_DB_PREFIX.'opensurvey_user_studs'; $sql.= " WHERE id_sondage='".$db->escape($numsondage)."' AND nom = '".$db->escape($nom)."' ORDER BY id_users"; $resql = $db->query($sql); if (! $resql) dol_print_error($db); - + $num_rows = $db->num_rows($resql); if ($num_rows > 0) { @@ -739,7 +739,7 @@ if ($comments) if ($object->allow_comments) { print '
' .$langs->trans("AddACommentForPoll") . "
\n"; - print '
'."\n"; + print '
'."\n"; print $langs->trans("Name") .': '; print '   '."\n"; print '
'."\n"; From abe736c6a6080589fe03d6f7026af0a5b1c7561a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 18 Jun 2017 19:42:59 +0200 Subject: [PATCH 054/227] Escape hml tags --- htdocs/admin/tools/index.php | 2 +- htdocs/bookmarks/bookmarks.lib.php | 2 +- htdocs/core/ajax/ajaxdirpreview.php | 2 +- htdocs/core/ajax/bankconciliate.php | 2 +- htdocs/core/ajax/box.php | 2 +- htdocs/core/ajax/constantonoff.php | 2 +- htdocs/core/ajax/contacts.php | 8 ++++---- htdocs/core/ajax/extraparams.php | 18 +++++++++--------- htdocs/core/ajax/loadinplace.php | 2 +- htdocs/core/ajax/objectonoff.php | 2 +- htdocs/core/ajax/price.php | 2 +- htdocs/core/ajax/row.php | 6 +++--- htdocs/core/ajax/saveinplace.php | 2 +- htdocs/core/ajax/security.php | 6 +++--- htdocs/core/ajax/vatrates.php | 2 +- htdocs/core/ajax/ziptown.php | 2 +- htdocs/core/class/html.formother.class.php | 4 ++-- htdocs/core/lib/functions.lib.php | 7 ++----- htdocs/core/lib/security2.lib.php | 6 +----- htdocs/core/tpl/ajax/fileupload_main.tpl.php | 2 +- htdocs/core/tpl/login.tpl.php | 6 +++++- htdocs/core/tpl/passwordforgotten.tpl.php | 7 +++++-- htdocs/ecm/ajax/ecmdatabase.php | 2 +- htdocs/expensereport/ajax/ajaxprojet.php | 2 +- htdocs/externalsite/frames.php | 4 ++-- htdocs/fourn/ajax/getSupplierPrices.php | 18 +++++++++--------- htdocs/holiday/list.php | 12 ++++++------ htdocs/main.inc.php | 11 ++++++----- htdocs/product/ajax/products.php | 2 +- htdocs/product/stats/card.php | 2 +- htdocs/public/paybox/paymentko.php | 2 +- htdocs/public/paybox/paymentok.php | 2 +- htdocs/public/paypal/paymentko.php | 6 +++--- htdocs/public/paypal/paymentok.php | 2 +- htdocs/societe/ajax/company.php | 4 ++-- htdocs/societe/ajaxcompanies.php | 2 +- htdocs/societe/ajaxcountries.php | 2 +- htdocs/user/passwordforgotten.php | 3 --- 38 files changed, 84 insertions(+), 86 deletions(-) diff --git a/htdocs/admin/tools/index.php b/htdocs/admin/tools/index.php index 8da041d05da..b8dfad44e8f 100644 --- a/htdocs/admin/tools/index.php +++ b/htdocs/admin/tools/index.php @@ -38,7 +38,7 @@ if (! $user->admin) $form = new Form($db); $title=$langs->trans("SystemToolsArea"); -if (GETPOST('leftmenu') == 'admintools') $title=$langs->trans("ModulesSystemTools"); +if (GETPOST('leftmenu',"aZ09") == 'admintools') $title=$langs->trans("ModulesSystemTools"); llxHeader('', $title); diff --git a/htdocs/bookmarks/bookmarks.lib.php b/htdocs/bookmarks/bookmarks.lib.php index 3cee534e797..e6d3125abed 100644 --- a/htdocs/bookmarks/bookmarks.lib.php +++ b/htdocs/bookmarks/bookmarks.lib.php @@ -40,7 +40,7 @@ function printBookmarksList($aDb, $aLangs) $langs->load("bookmarks"); - $url= $_SERVER["PHP_SELF"].(! empty($_SERVER["QUERY_STRING"])?'?'.$_SERVER["QUERY_STRING"]:''); + $url= $_SERVER["PHP_SELF"].(dol_escape_htmltag($_SERVER["QUERY_STRING"])?'?'.dol_escape_htmltag($_SERVER["QUERY_STRING"]):''); $ret = ''; // Menu bookmark diff --git a/htdocs/core/ajax/ajaxdirpreview.php b/htdocs/core/ajax/ajaxdirpreview.php index 28f78e22ef4..bbc7647c802 100644 --- a/htdocs/core/ajax/ajaxdirpreview.php +++ b/htdocs/core/ajax/ajaxdirpreview.php @@ -139,7 +139,7 @@ if (! dol_is_dir($upload_dir)) } print ''."\n"; -print ''."\n"; +//print ''."\n"; $param=($sortfield?'&sortfield='.$sortfield:'').($sortorder?'&sortorder='.$sortorder:''); diff --git a/htdocs/core/ajax/bankconciliate.php b/htdocs/core/ajax/bankconciliate.php index 3a8a3e30687..76ab3045f93 100644 --- a/htdocs/core/ajax/bankconciliate.php +++ b/htdocs/core/ajax/bankconciliate.php @@ -45,7 +45,7 @@ $action=GETPOST('action'); //top_htmlhead("", "", 1); // Replaced with top_httphead. An ajax page does not need html header. top_httphead(); -//print ''."\n"; +//print ''."\n"; if (($user->rights->banque->modifier || $user->rights->banque->consolidate) && $action == 'dvnext') { diff --git a/htdocs/core/ajax/box.php b/htdocs/core/ajax/box.php index 63f96a0c513..106822f998b 100644 --- a/htdocs/core/ajax/box.php +++ b/htdocs/core/ajax/box.php @@ -50,7 +50,7 @@ $userid=GETPOST('userid','int'); //top_htmlhead("", "", 1); // Replaced with top_httphead. An ajax page does not need html header. top_httphead(); -print ''."\n"; +print ''."\n"; // Add a box if ($boxid > 0 && $zone !='' && $userid > 0) diff --git a/htdocs/core/ajax/constantonoff.php b/htdocs/core/ajax/constantonoff.php index 331a5e87513..f79753260d7 100644 --- a/htdocs/core/ajax/constantonoff.php +++ b/htdocs/core/ajax/constantonoff.php @@ -45,7 +45,7 @@ $name=GETPOST('name','alpha'); //top_htmlhead("", "", 1); // Replaced with top_httphead. An ajax page does not need html header. top_httphead(); -print ''."\n"; +//print ''."\n"; // Registering the location of boxes if (! empty($action) && ! empty($name)) diff --git a/htdocs/core/ajax/contacts.php b/htdocs/core/ajax/contacts.php index c3788a8baeb..1c7c7a56e4b 100644 --- a/htdocs/core/ajax/contacts.php +++ b/htdocs/core/ajax/contacts.php @@ -41,20 +41,20 @@ $showempty = GETPOST('showempty','int'); top_httphead(); -//print ''."\n"; +//print ''."\n"; // Load original field value if (! empty($id) && ! empty($action) && ! empty($htmlname)) { $form = new Form($db); - + $return=array(); if (empty($showempty)) $showempty=0; - + $return['value'] = $form->selectcontacts($id,'',$htmlname,$showempty,'','',0,'',true); $return['num'] = $form->num; $return['error'] = $form->error; - + echo json_encode($return); } diff --git a/htdocs/core/ajax/extraparams.php b/htdocs/core/ajax/extraparams.php index 510ef8a1cf8..f8a636e52a5 100644 --- a/htdocs/core/ajax/extraparams.php +++ b/htdocs/core/ajax/extraparams.php @@ -40,17 +40,17 @@ $type = GETPOST('type', 'alpha'); top_httphead(); -print ''."\n"; +print ''."\n"; if(! empty($id) && ! empty($element) && ! empty($htmlelement) && ! empty($type)) { $value = GETPOST('value','alpha'); $params=array(); - + dol_syslog("AjaxSetExtraParameters id=".$id." element=".$element." htmlelement=".$htmlelement." type=".$type." value=".$value, LOG_DEBUG); - + $classpath = $subelement = $element; - + // For compatibility if ($element == 'order' || $element == 'commande') { $classpath = $subelement = 'commande'; } else if ($element == 'propal') { $classpath = 'comm/propal'; $subelement = 'propal'; } @@ -60,19 +60,19 @@ if(! empty($id) && ! empty($element) && ! empty($htmlelement) && ! empty($type)) else if ($element == 'deplacement') { $classpath = 'compta/deplacement'; $subelement = 'deplacement'; } else if ($element == 'order_supplier') { $classpath = 'fourn'; $subelement = 'fournisseur.commande'; } else if ($element == 'invoice_supplier') { $classpath = 'fourn'; $subelement = 'fournisseur.facture'; } - + dol_include_once('/'.$classpath.'/class/'.$subelement.'.class.php'); - + if ($element == 'order_supplier') { $classname = 'CommandeFournisseur'; } else if ($element == 'invoice_supplier') { $classname = 'FactureFournisseur'; } else $classname = ucfirst($subelement); - + $object = new $classname($db); $object->fetch($id); - + $params[$htmlelement] = array($type => $value); $object->extraparams = array_merge($object->extraparams, $params); - + $result=$object->setExtraParameters(); } diff --git a/htdocs/core/ajax/loadinplace.php b/htdocs/core/ajax/loadinplace.php index de3a4e57d19..7e9e541c768 100644 --- a/htdocs/core/ajax/loadinplace.php +++ b/htdocs/core/ajax/loadinplace.php @@ -41,7 +41,7 @@ $fk_element = GETPOST('fk_element','alpha'); top_httphead(); -//print ''."\n"; +//print ''."\n"; // Load original field value if (! empty($field) && ! empty($element) && ! empty($table_element) && ! empty($fk_element)) diff --git a/htdocs/core/ajax/objectonoff.php b/htdocs/core/ajax/objectonoff.php index 6ac5abd3bbb..37173ed9943 100644 --- a/htdocs/core/ajax/objectonoff.php +++ b/htdocs/core/ajax/objectonoff.php @@ -42,7 +42,7 @@ $object = new GenericObject($db); top_httphead(); -print ''."\n"; +print ''."\n"; // Registering new values if (($action == 'set') && ! empty($id)) diff --git a/htdocs/core/ajax/price.php b/htdocs/core/ajax/price.php index 5c891df14d5..d4a101fb497 100644 --- a/htdocs/core/ajax/price.php +++ b/htdocs/core/ajax/price.php @@ -39,7 +39,7 @@ $tva_tx = str_replace('*','',GETPOST('tva_tx','alpha')); top_httphead(); -//print ''."\n"; +//print ''."\n"; // Load original field value if (! empty($output) && isset($amount) && isset($tva_tx)) diff --git a/htdocs/core/ajax/row.php b/htdocs/core/ajax/row.php index 41d411f01fd..827ee92d525 100644 --- a/htdocs/core/ajax/row.php +++ b/htdocs/core/ajax/row.php @@ -17,8 +17,8 @@ /** * \file htdocs/core/ajax/row.php - * \brief File to return Ajax response on Row move. - * This ajax page is called when doing an up or down drag and drop. + * \brief File to return Ajax response on Row move. + * This ajax page is called when doing an up or down drag and drop. */ if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); // Disable token renewal @@ -39,7 +39,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/genericobject.class.php'; top_httphead(); -print ''."\n"; +print ''."\n"; // Registering the location of boxes if ((isset($_POST['roworder']) && ! empty($_POST['roworder'])) && (isset($_POST['table_element_line']) && ! empty($_POST['table_element_line'])) diff --git a/htdocs/core/ajax/saveinplace.php b/htdocs/core/ajax/saveinplace.php index 48797dd0432..eb04379a778 100644 --- a/htdocs/core/ajax/saveinplace.php +++ b/htdocs/core/ajax/saveinplace.php @@ -54,7 +54,7 @@ savemethodname: top_httphead(); -//print ''."\n"; +//print ''."\n"; //print_r($_POST); // Load original field value diff --git a/htdocs/core/ajax/security.php b/htdocs/core/ajax/security.php index 28a53a87679..cc7335618d0 100644 --- a/htdocs/core/ajax/security.php +++ b/htdocs/core/ajax/security.php @@ -17,8 +17,8 @@ /** * \file htdocs/core/ajax/security.php - * \brief This ajax component is used to generated has keys for security purposes - * like key to use into URL to protect them. + * \brief This ajax component is used to generated has keys for security purposes + * like key to use into URL to protect them. */ if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); // Disables token renewal @@ -38,7 +38,7 @@ require '../../main.inc.php'; //top_htmlhead("", "", 1); // Replaced with top_httphead. An ajax page does not need html header. top_httphead(); -//print ''."\n"; +//print ''."\n"; // Registering the location of boxes if (isset($_GET['action']) && ! empty($_GET['action'])) diff --git a/htdocs/core/ajax/vatrates.php b/htdocs/core/ajax/vatrates.php index fc30a13afec..ac9691bfa25 100644 --- a/htdocs/core/ajax/vatrates.php +++ b/htdocs/core/ajax/vatrates.php @@ -41,7 +41,7 @@ $productid = (GETPOST('productid','int')?GETPOST('productid','int'):0); top_httphead(); -//print ''."\n"; +//print ''."\n"; // Load original field value if (! empty($id) && ! empty($action) && ! empty($htmlname)) diff --git a/htdocs/core/ajax/ziptown.php b/htdocs/core/ajax/ziptown.php index 30e0211ece1..9fa475039d9 100644 --- a/htdocs/core/ajax/ziptown.php +++ b/htdocs/core/ajax/ziptown.php @@ -45,7 +45,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; //top_htmlhead("", "", 1); // Replaced with top_httphead. An ajax page does not need html header. top_httphead(); -//print ''."\n"; +//print ''."\n"; dol_syslog("GET is ".join(',',$_GET).', MAIN_USE_ZIPTOWN_DICTIONNARY='.(empty($conf->global->MAIN_USE_ZIPTOWN_DICTIONNARY)?'':$conf->global->MAIN_USE_ZIPTOWN_DICTIONNARY)); //var_dump($_GET); diff --git a/htdocs/core/class/html.formother.class.php b/htdocs/core/class/html.formother.class.php index 98720d335b9..1771b6f7a4c 100644 --- a/htdocs/core/class/html.formother.class.php +++ b/htdocs/core/class/html.formother.class.php @@ -1062,7 +1062,7 @@ class FormOther async: false }); // We force reload to be sure to get all boxes into list - window.location.search=\'mainmenu='.GETPOST("mainmenu").'&leftmenu='.GETPOST('leftmenu').'&action=delbox\'; + window.location.search=\'mainmenu='.GETPOST("mainmenu","aZ09").'&leftmenu='.GETPOST('leftmenu',"aZ09").'&action=delbox\'; } else { @@ -1084,7 +1084,7 @@ class FormOther url: \''.DOL_URL_ROOT.'/core/ajax/box.php?boxorder=\'+boxorder+\'&boxid=\'+boxid+\'&zone='.$areacode.'&userid='.$user->id.'\', async: false }); - window.location.search=\'mainmenu='.GETPOST("mainmenu").'&leftmenu='.GETPOST('leftmenu').'&action=addbox&boxid=\'+boxid; + window.location.search=\'mainmenu='.GETPOST("mainmenu","aZ09").'&leftmenu='.GETPOST('leftmenu',"aZ09").'&action=addbox&boxid=\'+boxid; } });'; if (! count($arrayboxtoactivatelabel)) $selectboxlist.='jQuery("#boxcombo").hide();'; diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 97ce3c4f698..f9f9c8557ee 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -289,9 +289,6 @@ function GETPOST($paramname,$check='',$method=0,$filter=NULL,$options=NULL) case 'intcomma': if (preg_match('/[^0-9,]+/i',$out)) $out=''; break; - case 'intcomma': - if (preg_match('/[^0-9,]+/i',$out)) $out=''; - break; case 'alpha': $out=trim($out); // '"' is dangerous because param in url can close the href= or src= and add javascript functions. @@ -2931,8 +2928,8 @@ function dol_print_error($db='',$error='',$errors=null) $out.="".$langs->trans("Referer").": ".(isset($_SERVER["HTTP_REFERER"])?dol_htmlentities($_SERVER["HTTP_REFERER"],ENT_COMPAT,'UTF-8'):'')."
\n"; $out.="".$langs->trans("MenuManager").": ".(isset($conf->standard_menu)?$conf->standard_menu:'')."
\n"; $out.="
\n"; - $syslog.="url=".$_SERVER["REQUEST_URI"]; - $syslog.=", query_string=".$_SERVER["QUERY_STRING"]; + $syslog.="url=".dol_escape_htmltag($_SERVER["REQUEST_URI"]); + $syslog.=", query_string=".dol_escape_htmltag($_SERVER["QUERY_STRING"]); } else // Mode CLI { diff --git a/htdocs/core/lib/security2.lib.php b/htdocs/core/lib/security2.lib.php index fc05e2c9194..8c16ae8309a 100644 --- a/htdocs/core/lib/security2.lib.php +++ b/htdocs/core/lib/security2.lib.php @@ -144,10 +144,6 @@ function dol_loginfunction($langs,$conf,$mysoc) $dol_url_root = DOL_URL_ROOT; - $php_self = $_SERVER['PHP_SELF']; - $php_self.= $_SERVER["QUERY_STRING"]?'?'.$_SERVER["QUERY_STRING"]:''; - if (! preg_match('/mainmenu=/',$php_self)) $php_self.=(preg_match('/\?/',$php_self)?'&':'?').'mainmenu=home'; - // Title $appli=constant('DOL_APPLICATION_TITLE'); $title=$appli.' '.DOL_VERSION; @@ -422,7 +418,7 @@ function encodedecode_dbpassconf($level=0) fflush($fp); fclose($fp); clearstatcache(); - + // It's config file, so we set read permission for creator only. // Should set permission to web user and groups for users used by batch //@chmod($file, octdec('0600')); diff --git a/htdocs/core/tpl/ajax/fileupload_main.tpl.php b/htdocs/core/tpl/ajax/fileupload_main.tpl.php index b7437af4616..034e9ebc3fc 100644 --- a/htdocs/core/tpl/ajax/fileupload_main.tpl.php +++ b/htdocs/core/tpl/ajax/fileupload_main.tpl.php @@ -45,7 +45,7 @@ $(function () { // Events $('#fileupload').fileupload({ stop: function (e, data) { - location.href=''; + location.href=''; }, destroy: function (e, data) { var that = $(this).data('fileupload'); diff --git a/htdocs/core/tpl/login.tpl.php b/htdocs/core/tpl/login.tpl.php index 3772b44c9fc..608e508d717 100644 --- a/htdocs/core/tpl/login.tpl.php +++ b/htdocs/core/tpl/login.tpl.php @@ -31,6 +31,10 @@ if (GETPOST('dol_use_jmobile')) $conf->dol_use_jmobile=1; // If we force to use jmobile, then we reenable javascript if (! empty($conf->dol_use_jmobile)) $conf->use_javascript_ajax=1; +$php_self = dol_escape_htmltag($_SERVER['PHP_SELF']); +$php_self.= dol_escape_htmltag($_SERVER["QUERY_STRING"])?'?'.dol_escape_htmltag($_SERVER["QUERY_STRING"]):''; +if (! preg_match('/mainmenu=/',$php_self)) $php_self.=(preg_match('/\?/',$php_self)?'&':'?').'mainmenu=home'; + // Javascript code on logon page only to detect user tz, dst_observed, dst_first, dst_second $arrayofjs=array( '/includes/jstz/jstz.min.js'.(empty($conf->dol_use_jmobile)?'':'?version='.urlencode(DOL_VERSION)), @@ -80,7 +84,7 @@ $(document).ready(function () {
'; -echo dol_escape_htmltag($title); +echo dol_escape_htmltag($title); if ($disablenofollow) echo ''; ?>
'; -print ''; +print ''; $formother->select_year($year_create,'year_create',1, $min_year, 0); print '
'; @@ -644,9 +644,9 @@ class FormFile $sortfield = $sortorder = null; $res = $link->fetchAll($link_list, $object->element, $object->id, $sortfield, $sortorder); } - + $out.= ''."\n"; - + // Show title of array if not already shown if ((! empty($file_list) || ! empty($link_list) || preg_match('/^massfilesarea/', $modulepart)) && ! $headershown) { @@ -671,7 +671,7 @@ class FormFile $documenturl = DOL_URL_ROOT.'/document.php'; if (isset($conf->global->DOL_URL_ROOT_DOCUMENT_PHP)) $documenturl=$conf->global->DOL_URL_ROOT_DOCUMENT_PHP; - + // Show file name with link to download $out.= ''; @@ -799,7 +799,7 @@ class FormFile $this->infofiles=array('nboffiles'=>0,'extensions'=>array(),'files'=>array()); if (! empty($conf->dol_use_jmobile)) return ''; - + $file_list=dol_dir_list($filedir, 'files', 0, preg_quote(basename($modulesubdir),'/').'[^\-]+', '\.meta$|\.png$'); // Get list of files starting with name of ref (but not followed by "-" to discard uploaded files) // For ajax treatment @@ -919,7 +919,7 @@ class FormFile if ($user->rights->service->creer && $object->type == Product::TYPE_SERVICE) $permtoeditline=1; } } - if (empty($conf->global->MAIN_UPLOAD_DOC)) + if (empty($conf->global->MAIN_UPLOAD_DOC)) { $permtoeditline=0; $permonobject=0; @@ -928,7 +928,7 @@ class FormFile // Show list of existing files if (empty($useinecm)) print load_fiche_titre($title?$title:$langs->trans("AttachedFiles")); if (empty($url)) $url=$_SERVER["PHP_SELF"]; - + print ''."\n"; if (GETPOST('action') == 'editfile' && $permtoeditline) { @@ -938,7 +938,7 @@ class FormFile print ''; } print '
'; $out.= '"; $out.=''; $out.=''; @@ -756,7 +756,7 @@ class FormFile } $this->numoffiles++; } - + if (count($file_list) == 0 && count($link_list) == 0 && $headershown) { $out.='
'.$langs->trans("None").'
'."\n"; - + print ''; print_liste_field_titre($langs->trans("Documents2"),$url,"name","",$param,'align="left"',$sortfield,$sortorder); print_liste_field_titre($langs->trans("Size"),$url,"size","",$param,'align="right"',$sortfield,$sortorder); @@ -971,13 +971,13 @@ class FormFile $relativepath=preg_replace('/^.*\/produit\//','',$file['path']).'/'; } $var=!$var; - + $editline=0; - + print ''."\n"; print ''; print '"; @@ -1103,7 +1103,7 @@ class FormFile { print ''; } - + return $nboffiles; } } @@ -1489,11 +1489,11 @@ class FormFile return $nboflinks; } - - + + /** * Show detail icon with link for preview - * + * * @param array $file File * @param string $modulepart propal, facture, facture_fourn, ... * @param string $relativepath Relative path of docs From 4dda771079d04bb22eb5166ad2aff8042e237184 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 20 Jun 2017 12:54:26 +0200 Subject: [PATCH 115/227] FIX #6973 --- htdocs/admin/mails_templates.php | 404 +++++++++++++++++-------------- 1 file changed, 216 insertions(+), 188 deletions(-) diff --git a/htdocs/admin/mails_templates.php b/htdocs/admin/mails_templates.php index cc35aed19be..123877f7f4e 100644 --- a/htdocs/admin/mails_templates.php +++ b/htdocs/admin/mails_templates.php @@ -50,6 +50,7 @@ $action=GETPOST('action','alpha')?GETPOST('action','alpha'):'view'; $confirm=GETPOST('confirm','alpha'); $id=GETPOST('id','int'); $rowid=GETPOST('rowid','alpha'); +$search_label=GETPOST('search_label','alpha'); $allowed=$user->admin; if (! $allowed) accessforbidden(); @@ -78,10 +79,6 @@ $hookmanager->initHooks(array('emailtemplates')); $tabname=array(); $tabname[25]= MAIN_DB_PREFIX."c_email_templates"; -// Requests to extract data -$tabsql=array(); -$tabsql[25]= "SELECT rowid as rowid, label, type_template, private, position, topic, content_lines, content, active FROM ".MAIN_DB_PREFIX."c_email_templates WHERE entity IN (".getEntity('email_template').")"; - // Criteria to sort dictionaries $tabsqlsort=array(); $tabsqlsort[25]="label ASC"; @@ -173,211 +170,223 @@ $id = 25; * Actions */ -if (GETPOST('button_removefilter') || GETPOST('button_removefilter.x') || GETPOST('button_removefilter_x')) -{ - //$search_country_id = ''; -} +if (GETPOST('cancel')) { $action='list'; $massaction=''; } +if (! GETPOST('confirmmassaction') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction=''; } -// Actions add or modify an entry into a dictionary -if (GETPOST('actionadd') || GETPOST('actionmodify')) -{ - $listfield=explode(',', str_replace(' ', '',$tabfield[$id])); - $listfieldinsert=explode(',',$tabfieldinsert[$id]); - $listfieldmodify=explode(',',$tabfieldinsert[$id]); - $listfieldvalue=explode(',',$tabfieldvalue[$id]); +$parameters=array(); +$reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks +if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); - // Check that all fields are filled - $ok=1; - foreach ($listfield as $f => $value) +if (empty($reshook)) +{ + // Purge search criteria + if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") ||GETPOST("button_removefilter")) // All tests are required to be compatible with all browsers { - if ($value == 'content') continue; - if ($value == 'content_lines') continue; - if ($value == 'content') $value='content-'.$rowid; - if ($value == 'content_lines') $value='content_lines-'.$rowid; - - if (! isset($_POST[$value]) || $_POST[$value]=='') - { - $ok=0; - $fieldnamekey=$listfield[$f]; - // We take translate key of field - if ($fieldnamekey == 'libelle' || ($fieldnamekey == 'label')) $fieldnamekey='Label'; - if ($fieldnamekey == 'libelle_facture') $fieldnamekey = 'LabelOnDocuments'; - if ($fieldnamekey == 'code') $fieldnamekey = 'Code'; - if ($fieldnamekey == 'note') $fieldnamekey = 'Note'; - if ($fieldnamekey == 'type') $fieldnamekey = 'Type'; - - setEventMessages($langs->transnoentities("ErrorFieldRequired", $langs->transnoentities($fieldnamekey)), null, 'errors'); - } + $search_label=''; + $toselect=''; + $search_array_options=array(); } - // Si verif ok et action add, on ajoute la ligne - if ($ok && GETPOST('actionadd')) + // Actions add or modify an entry into a dictionary + if (GETPOST('actionadd') || GETPOST('actionmodify')) { - if ($tabrowid[$id]) + $listfield=explode(',', str_replace(' ', '',$tabfield[$id])); + $listfieldinsert=explode(',',$tabfieldinsert[$id]); + $listfieldmodify=explode(',',$tabfieldinsert[$id]); + $listfieldvalue=explode(',',$tabfieldvalue[$id]); + + // Check that all fields are filled + $ok=1; + foreach ($listfield as $f => $value) { - // Recupere id libre pour insertion - $newid=0; - $sql = "SELECT max(".$tabrowid[$id].") newid from ".$tabname[$id]; - $result = $db->query($sql); - if ($result) + if ($value == 'content') continue; + if ($value == 'content_lines') continue; + if ($value == 'content') $value='content-'.$rowid; + if ($value == 'content_lines') $value='content_lines-'.$rowid; + + if (! isset($_POST[$value]) || $_POST[$value]=='') { - $obj = $db->fetch_object($result); - $newid=($obj->newid + 1); + $ok=0; + $fieldnamekey=$listfield[$f]; + // We take translate key of field + if ($fieldnamekey == 'libelle' || ($fieldnamekey == 'label')) $fieldnamekey='Label'; + if ($fieldnamekey == 'libelle_facture') $fieldnamekey = 'LabelOnDocuments'; + if ($fieldnamekey == 'code') $fieldnamekey = 'Code'; + if ($fieldnamekey == 'note') $fieldnamekey = 'Note'; + if ($fieldnamekey == 'type') $fieldnamekey = 'Type'; - } else { - dol_print_error($db); + setEventMessages($langs->transnoentities("ErrorFieldRequired", $langs->transnoentities($fieldnamekey)), null, 'errors'); } } - // Add new entry - $sql = "INSERT INTO ".$tabname[$id]." ("; - // List of fields - if ($tabrowid[$id] && ! in_array($tabrowid[$id],$listfieldinsert)) - $sql.= $tabrowid[$id].","; - $sql.= $tabfieldinsert[$id]; - $sql.=",active)"; - $sql.= " VALUES("; + // Si verif ok et action add, on ajoute la ligne + if ($ok && GETPOST('actionadd')) + { + if ($tabrowid[$id]) + { + // Recupere id libre pour insertion + $newid=0; + $sql = "SELECT max(".$tabrowid[$id].") newid from ".$tabname[$id]; + $result = $db->query($sql); + if ($result) + { + $obj = $db->fetch_object($result); + $newid=($obj->newid + 1); - // List of values - if ($tabrowid[$id] && ! in_array($tabrowid[$id],$listfieldinsert)) - $sql.= $newid.","; - $i=0; - foreach ($listfieldinsert as $f => $value) - { - //var_dump($i.' - '.$listfieldvalue[$i].' - '.$_POST[$listfieldvalue[$i]].' - '.$value); - if ($value == 'entity') { - $_POST[$listfieldvalue[$i]] = $conf->entity; + } else { + dol_print_error($db); + } } - if ($i) $sql.=","; - if ($value == 'private' && ! is_numeric($_POST[$listfieldvalue[$i]])) $_POST[$listfieldvalue[$i]]='0'; - if ($value == 'position' && ! is_numeric($_POST[$listfieldvalue[$i]])) $_POST[$listfieldvalue[$i]]='1'; - if ($_POST[$listfieldvalue[$i]] == '') $sql.="null"; // For vat, we want/accept code = '' - else $sql.="'".$db->escape($_POST[$listfieldvalue[$i]])."'"; - $i++; - } - $sql.=",1)"; - dol_syslog("actionadd", LOG_DEBUG); - $result = $db->query($sql); - if ($result) // Add is ok - { - setEventMessages($langs->transnoentities("RecordSaved"), null, 'mesgs'); - $_POST=array('id'=>$id); // Clean $_POST array, we keep only - } - else - { - if ($db->errno() == 'DB_ERROR_RECORD_ALREADY_EXISTS') { - setEventMessages($langs->transnoentities("ErrorRecordAlreadyExists"), null, 'errors'); + // Add new entry + $sql = "INSERT INTO ".$tabname[$id]." ("; + // List of fields + if ($tabrowid[$id] && ! in_array($tabrowid[$id],$listfieldinsert)) + $sql.= $tabrowid[$id].","; + $sql.= $tabfieldinsert[$id]; + $sql.=",active)"; + $sql.= " VALUES("; + + // List of values + if ($tabrowid[$id] && ! in_array($tabrowid[$id],$listfieldinsert)) + $sql.= $newid.","; + $i=0; + foreach ($listfieldinsert as $f => $value) + { + //var_dump($i.' - '.$listfieldvalue[$i].' - '.$_POST[$listfieldvalue[$i]].' - '.$value); + if ($value == 'entity') { + $_POST[$listfieldvalue[$i]] = $conf->entity; + } + if ($i) $sql.=","; + if ($value == 'private' && ! is_numeric($_POST[$listfieldvalue[$i]])) $_POST[$listfieldvalue[$i]]='0'; + if ($value == 'position' && ! is_numeric($_POST[$listfieldvalue[$i]])) $_POST[$listfieldvalue[$i]]='1'; + if ($_POST[$listfieldvalue[$i]] == '') $sql.="null"; // For vat, we want/accept code = '' + else $sql.="'".$db->escape($_POST[$listfieldvalue[$i]])."'"; + $i++; } - else { - dol_print_error($db); + $sql.=",1)"; + + dol_syslog("actionadd", LOG_DEBUG); + $result = $db->query($sql); + if ($result) // Add is ok + { + setEventMessages($langs->transnoentities("RecordSaved"), null, 'mesgs'); + $_POST=array('id'=>$id); // Clean $_POST array, we keep only + } + else + { + if ($db->errno() == 'DB_ERROR_RECORD_ALREADY_EXISTS') { + setEventMessages($langs->transnoentities("ErrorRecordAlreadyExists"), null, 'errors'); + } + else { + dol_print_error($db); + } + } + } + + // Si verif ok et action modify, on modifie la ligne + if ($ok && GETPOST('actionmodify')) + { + if ($tabrowid[$id]) { $rowidcol=$tabrowid[$id]; } + else { $rowidcol="rowid"; } + + // Modify entry + $sql = "UPDATE ".$tabname[$id]." SET "; + // Modifie valeur des champs + if ($tabrowid[$id] && ! in_array($tabrowid[$id],$listfieldmodify)) + { + $sql.= $tabrowid[$id]."="; + $sql.= "'".$db->escape($rowid)."', "; + } + $i = 0; + foreach ($listfieldmodify as $field) + { + if ($field == 'content') $_POST['content']=$_POST['content-'.$rowid]; + if ($field == 'content_lines') $_POST['content_lines']=$_POST['content_lines-'.$rowid]; + if ($field == 'entity') { + $_POST[$listfieldvalue[$i]] = $conf->entity; + } + if ($i) $sql.=","; + $sql.= $field."="; + if ($_POST[$listfieldvalue[$i]] == '') $sql.="null"; // For vat, we want/accept code = '' + else $sql.="'".$db->escape($_POST[$listfieldvalue[$i]])."'"; + $i++; + } + $sql.= " WHERE ".$rowidcol." = '".$rowid."'"; + + dol_syslog("actionmodify", LOG_DEBUG); + //print $sql; + $resql = $db->query($sql); + if (! $resql) + { + setEventMessages($db->error(), null, 'errors'); } } } - // Si verif ok et action modify, on modifie la ligne - if ($ok && GETPOST('actionmodify')) + if ($action == 'confirm_delete' && $confirm == 'yes') // delete { if ($tabrowid[$id]) { $rowidcol=$tabrowid[$id]; } else { $rowidcol="rowid"; } - // Modify entry - $sql = "UPDATE ".$tabname[$id]." SET "; - // Modifie valeur des champs - if ($tabrowid[$id] && ! in_array($tabrowid[$id],$listfieldmodify)) - { - $sql.= $tabrowid[$id]."="; - $sql.= "'".$db->escape($rowid)."', "; - } - $i = 0; - foreach ($listfieldmodify as $field) - { - if ($field == 'content') $_POST['content']=$_POST['content-'.$rowid]; - if ($field == 'content_lines') $_POST['content_lines']=$_POST['content_lines-'.$rowid]; - if ($field == 'entity') { - $_POST[$listfieldvalue[$i]] = $conf->entity; - } - if ($i) $sql.=","; - $sql.= $field."="; - if ($_POST[$listfieldvalue[$i]] == '') $sql.="null"; // For vat, we want/accept code = '' - else $sql.="'".$db->escape($_POST[$listfieldvalue[$i]])."'"; - $i++; - } - $sql.= " WHERE ".$rowidcol." = '".$rowid."'"; + $sql = "DELETE from ".$tabname[$id]." WHERE ".$rowidcol."='".$rowid."'"; - dol_syslog("actionmodify", LOG_DEBUG); - //print $sql; - $resql = $db->query($sql); - if (! $resql) + dol_syslog("delete", LOG_DEBUG); + $result = $db->query($sql); + if (! $result) { - setEventMessages($db->error(), null, 'errors'); + if ($db->errno() == 'DB_ERROR_CHILD_EXISTS') + { + setEventMessages($langs->transnoentities("ErrorRecordIsUsedByChild"), null, 'errors'); + } + else + { + dol_print_error($db); + } } } -} -if ($action == 'confirm_delete' && $confirm == 'yes') // delete -{ - if ($tabrowid[$id]) { $rowidcol=$tabrowid[$id]; } - else { $rowidcol="rowid"; } - - $sql = "DELETE from ".$tabname[$id]." WHERE ".$rowidcol."='".$rowid."'"; - - dol_syslog("delete", LOG_DEBUG); - $result = $db->query($sql); - if (! $result) + // activate + if ($action == $acts[0]) { - if ($db->errno() == 'DB_ERROR_CHILD_EXISTS') - { - setEventMessages($langs->transnoentities("ErrorRecordIsUsedByChild"), null, 'errors'); + if ($tabrowid[$id]) { $rowidcol=$tabrowid[$id]; } + else { $rowidcol="rowid"; } + + if ($rowid) { + $sql = "UPDATE ".$tabname[$id]." SET active = 1 WHERE ".$rowidcol."='".$rowid."'"; } - else + elseif ($code) { + $sql = "UPDATE ".$tabname[$id]." SET active = 1 WHERE code='".$code."'"; + } + + $result = $db->query($sql); + if (!$result) + { + dol_print_error($db); + } + } + + // disable + if ($action == $acts[1]) + { + if ($tabrowid[$id]) { $rowidcol=$tabrowid[$id]; } + else { $rowidcol="rowid"; } + + if ($rowid) { + $sql = "UPDATE ".$tabname[$id]." SET active = 0 WHERE ".$rowidcol."='".$rowid."'"; + } + elseif ($code) { + $sql = "UPDATE ".$tabname[$id]." SET active = 0 WHERE code='".$code."'"; + } + + $result = $db->query($sql); + if (!$result) { dol_print_error($db); } } } -// activate -if ($action == $acts[0]) -{ - if ($tabrowid[$id]) { $rowidcol=$tabrowid[$id]; } - else { $rowidcol="rowid"; } - - if ($rowid) { - $sql = "UPDATE ".$tabname[$id]." SET active = 1 WHERE ".$rowidcol."='".$rowid."'"; - } - elseif ($code) { - $sql = "UPDATE ".$tabname[$id]." SET active = 1 WHERE code='".$code."'"; - } - - $result = $db->query($sql); - if (!$result) - { - dol_print_error($db); - } -} - -// disable -if ($action == $acts[1]) -{ - if ($tabrowid[$id]) { $rowidcol=$tabrowid[$id]; } - else { $rowidcol="rowid"; } - - if ($rowid) { - $sql = "UPDATE ".$tabname[$id]." SET active = 0 WHERE ".$rowidcol."='".$rowid."'"; - } - elseif ($code) { - $sql = "UPDATE ".$tabname[$id]." SET active = 0 WHERE code='".$code."'"; - } - - $result = $db->query($sql); - if (!$result) - { - dol_print_error($db); - } -} - - /* * View @@ -416,8 +425,11 @@ if ($action == 'delete') } //var_dump($elementList); -// Complete requete recherche valeurs avec critere de tri -$sql=$tabsql[$id]; + +$sql="SELECT rowid as rowid, label, type_template, private, position, topic, content_lines, content, active"; +$sql.=" FROM ".MAIN_DB_PREFIX."c_email_templates"; +$sql.=" WHERE entity IN (".getEntity('email_template').")"; +if ($search_label) $sql.=natural_search('label', $search_label); if ($search_country_id > 0) { @@ -572,9 +584,19 @@ if ($action != 'edit') $colspan=count($fieldlist)+1; - print ''; // Keep   to have a line with enough height + //print ''; // Keep   to have a line with enough height } +print '
'; - + //print "XX".$file['name']; //$file['name'] must be utf8 print '\n"; @@ -1038,7 +1038,7 @@ class FormFile // Delete or view link // ($param must start with &) print ''; - if ($useinecm) + if ($useinecm) { print ''.img_view('default', 0, 'class="paddingrightonly"').''; } @@ -1046,10 +1046,10 @@ class FormFile { $newmodulepart=$modulepart; if (in_array($modulepart, array('product','produit','service'))) $newmodulepart='produit|service'; - - $disablecrop=1; + + $disablecrop=1; if (in_array($modulepart, array('product','produit','service','holiday','project'))) $disablecrop=0; - + if (! $disablecrop && image_format_supported($file['name']) > 0) { if ($permtoeditline) @@ -1058,7 +1058,7 @@ class FormFile print ''.img_picto($langs->trans("Resize"),DOL_URL_ROOT.'/theme/common/transform-crop-and-resize','class="paddingrightonly"',1).''; } } - + if ($permtoeditline) { print ''.img_edit('default',0,'class="paddingrightonly"').''; @@ -1076,7 +1076,7 @@ class FormFile if (! empty($conf->dol_use_jmobile)) $useajax=0; if (empty($conf->use_javascript_ajax)) $useajax=0; if (! empty($conf->global->MAIN_ECM_DISABLE_JS)) $useajax=0; - + print ''.img_delete().''; } print "
 
 
'; +print ''; + +print '
'; + +print '
'; +print ''; +print ''; + +print ''; // List of available record in database dol_syslog("htdocs/admin/dict", LOG_DEBUG); @@ -599,8 +621,26 @@ if ($resql) print ''; } + + // Title line with search boxes + print ''; + $filterfound=0; + foreach ($fieldlist as $field => $value) + { + if ($value == 'label') print ''; + elseif (! in_array($value, array('content', 'content_lines'))) print ''; + } + if (empty($conf->global->MAIN_EMAIL_TEMPLATES_FOR_OBJECT_LINES)) print ''; + print ''; + // Action column + print ''; + print ''; + // Title of lines - print ''; + print ''; foreach ($fieldlist as $field => $value) { // Determine le nom du champ par rapport aux noms possibles @@ -642,18 +682,6 @@ if ($resql) print getTitleFieldOfList(''); print ''; - // Title line with search boxes - print ''; - $filterfound=0; - foreach ($fieldlist as $field => $value) - { - if (! in_array($field, array('content', 'content_lines'))) print ''; - } - if (empty($conf->global->MAIN_EMAIL_TEMPLATES_FOR_OBJECT_LINES)) print ''; - print ''; - print ''; - print ''; - if ($num) { // Lines with values From efe5d79a862f72b3da7aecbf07e508d7e6d23b65 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 20 Jun 2017 12:58:43 +0200 Subject: [PATCH 116/227] Work on #6958. Only one type of invoice supported for supplier invoices --- .../mod_facture_fournisseur_tulip.php | 33 +++++++++++-------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/htdocs/core/modules/supplier_invoice/mod_facture_fournisseur_tulip.php b/htdocs/core/modules/supplier_invoice/mod_facture_fournisseur_tulip.php index b7a3801a9cd..2e155c04df8 100644 --- a/htdocs/core/modules/supplier_invoice/mod_facture_fournisseur_tulip.php +++ b/htdocs/core/modules/supplier_invoice/mod_facture_fournisseur_tulip.php @@ -72,27 +72,32 @@ class mod_facture_fournisseur_tulip extends ModeleNumRefSuppliersInvoices $tooltip.=$langs->trans("GenericMaskCodes5"); // Parametrage du prefix - $texte.= ''; + $texte.= ''; $texte.= ''; $texte.= ''; $texte.= ''; - // Parametrage du prefix des replacement - $texte.= ''; - $texte.= ''; - $texte.= ''; + if ($conf->global->MAIN_FEATURE_LEVEL >= 2) + { + // Parametrage du prefix des replacement + $texte.= ''; + $texte.= ''; + $texte.= ''; - // Parametrage du prefix des avoirs - $texte.= ''; - $texte.= ''; - $texte.= ''; + // Parametrage du prefix des avoirs + $texte.= ''; + $texte.= ''; + $texte.= ''; - // Parametrage du prefix des acomptes - $texte.= ''; - $texte.= ''; - $texte.= ''; + // Parametrage du prefix des acomptes + $texte.= ''; + $texte.= ''; + $texte.= ''; + } $texte.= '
'; + $searchpicto=$form->showFilterButtons(); + print $searchpicto; + print '
'.$langs->trans("Mask").' ('.$langs->trans("InvoiceStandard").'):
'.$langs->trans("Mask"); + //$texte.= ' ('.$langs->trans("InvoiceStandard").')'; + $texte.= ':'.$form->textwithpicto('',$tooltip,1,1).' 
'.$langs->trans("Mask").' ('.$langs->trans("InvoiceReplacement").'):'.$form->textwithpicto('',$tooltip,1,1).'
'.$langs->trans("Mask").' ('.$langs->trans("InvoiceReplacement").'):'.$form->textwithpicto('',$tooltip,1,1).'
'.$langs->trans("Mask").' ('.$langs->trans("InvoiceAvoir").'):'.$form->textwithpicto('',$tooltip,1,1).'
'.$langs->trans("Mask").' ('.$langs->trans("InvoiceAvoir").'):'.$form->textwithpicto('',$tooltip,1,1).'
'.$langs->trans("Mask").' ('.$langs->trans("InvoiceDeposit").'):'.$form->textwithpicto('',$tooltip,1,1).'
'.$langs->trans("Mask").' ('.$langs->trans("InvoiceDeposit").'):'.$form->textwithpicto('',$tooltip,1,1).'
'; $texte.= '
'; @@ -137,7 +142,7 @@ class mod_facture_fournisseur_tulip extends ModeleNumRefSuppliersInvoices // Get Mask value $mask = ''; - if (is_object($object) && $object->type == 1) + if (is_object($object) && $object->type == 1) { $mask=$conf->global->SUPPLIER_REPLACEMENT_TULIP_MASK; if (! $mask) From f1701469e0a16d80951de4801a4637918ad7493d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 20 Jun 2017 13:28:34 +0200 Subject: [PATCH 117/227] NEW data files are now also parsed by phpunit for sql syntax --- htdocs/core/db/pgsql.class.php | 3 ++- htdocs/install/mysql/data/llx_accounting.sql | 2 +- htdocs/install/mysql/data/llx_const.sql | 8 ++++---- htdocs/install/mysql/migration/3.2.0-3.3.0.sql | 2 +- htdocs/install/mysql/migration/5.0.0-6.0.0.sql | 2 +- .../mysql/tables/llx_blockedlog_authority.sql | 2 +- htdocs/install/pgsql/functions/functions.sql | 3 ++- test/phpunit/CodingSqlTest.php | 13 +++++++++++-- 8 files changed, 23 insertions(+), 12 deletions(-) diff --git a/htdocs/core/db/pgsql.class.php b/htdocs/core/db/pgsql.class.php index 89f2a66bdea..2b8e90d0780 100644 --- a/htdocs/core/db/pgsql.class.php +++ b/htdocs/core/db/pgsql.class.php @@ -169,7 +169,7 @@ class DoliDBPgsql extends DoliDB $line = preg_replace('/ SEPARATOR/i', ',', $line); $line = preg_replace('/STRING_AGG\(([^,\)]+)\)/i', 'STRING_AGG(\\1, \',\')', $line); //print $line."\n"; - + if ($type == 'auto') { if (preg_match('/ALTER TABLE/i',$line)) $type='dml'; @@ -210,6 +210,7 @@ class DoliDBPgsql extends DoliDB // tinytext/mediumtext -> text $line=preg_replace('/tinytext/i','text',$line); $line=preg_replace('/mediumtext/i','text',$line); + $line=preg_replace('/longtext/i','text',$line); $line=preg_replace('/text\([0-9]+\)/i','text',$line); diff --git a/htdocs/install/mysql/data/llx_accounting.sql b/htdocs/install/mysql/data/llx_accounting.sql index ea1fe7a7dd7..6448646bda0 100644 --- a/htdocs/install/mysql/data/llx_accounting.sql +++ b/htdocs/install/mysql/data/llx_accounting.sql @@ -360,7 +360,7 @@ INSERT INTO llx_accounting_account (rowid, fk_pcg_version, pcg_type, pcg_subtype INSERT INTO llx_accounting_account (rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (305,'PCG99-BASE','FINAN', 'XXXXXX', '511', '304', 'Valeurs à l''encaissement', 1); INSERT INTO llx_accounting_account (rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (306,'PCG99-BASE','FINAN', 'BANK', '512', '304', 'Banques', 1); INSERT INTO llx_accounting_account (rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (307,'PCG99-BASE','FINAN', 'XXXXXX', '514', '304', 'Chèques postaux', 1); -INSERT INTO llx_accounting_account (rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (308,'PCG99-BASE','FINAN', 'XXXXXX', '515', '304', '"Caisses" du Trésor et des établissements publics', 1); +INSERT INTO llx_accounting_account (rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (308,'PCG99-BASE','FINAN', 'XXXXXX', '515', '304', 'Caisses du Trésor et des établissements publics', 1); INSERT INTO llx_accounting_account (rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (309,'PCG99-BASE','FINAN', 'XXXXXX', '516', '304', 'Sociétés de bourse', 1); INSERT INTO llx_accounting_account (rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (310,'PCG99-BASE','FINAN', 'XXXXXX', '517', '304', 'Autres organismes financiers', 1); INSERT INTO llx_accounting_account (rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (311,'PCG99-BASE','FINAN', 'XXXXXX', '518', '304', 'Intérêts courus', 1); diff --git a/htdocs/install/mysql/data/llx_const.sql b/htdocs/install/mysql/data/llx_const.sql index bf76d378789..ee6f952e6ae 100644 --- a/htdocs/install/mysql/data/llx_const.sql +++ b/htdocs/install/mysql/data/llx_const.sql @@ -91,7 +91,7 @@ insert into llx_const (name, value, type, note, visible) values ('MAILING_EMAIL_ -- -- ODT Path --- -insert into `llx_const` (`name`, `entity`, `value`, `type`, `visible`) VALUES ('PRODUCT_ADDON_PDF_ODT_PATH', 1, 'DOL_DATA_ROOT/doctemplates/products', 'chaine', 0); -insert into `llx_const` (`name`, `entity`, `value`, `type`, `visible`) VALUES ('CONTRACT_ADDON_PDF_ODT_PATH', 1, 'DOL_DATA_ROOT/doctemplates/contracts', 'chaine', 0); -insert into `llx_const` (`name`, `entity`, `value`, `type`, `visible`) VALUES ('USERGROUP_ADDON_PDF_ODT_PATH', 1, 'DOL_DATA_ROOT/doctemplates/usergroups', 'chaine', 0); -insert into `llx_const` (`name`, `entity`, `value`, `type`, `visible`) VALUES ('USER_ADDON_PDF_ODT_PATH', 1, 'DOL_DATA_ROOT/doctemplates/users', 'chaine', 0); +insert into llx_const (name, entity, value, type, visible) VALUES ('PRODUCT_ADDON_PDF_ODT_PATH', 1, 'DOL_DATA_ROOT/doctemplates/products', 'chaine', 0); +insert into llx_const (name, entity, value, type, visible) VALUES ('CONTRACT_ADDON_PDF_ODT_PATH', 1, 'DOL_DATA_ROOT/doctemplates/contracts', 'chaine', 0); +insert into llx_const (name, entity, value, type, visible) VALUES ('USERGROUP_ADDON_PDF_ODT_PATH', 1, 'DOL_DATA_ROOT/doctemplates/usergroups', 'chaine', 0); +insert into llx_const (name, entity, value, type, visible) VALUES ('USER_ADDON_PDF_ODT_PATH', 1, 'DOL_DATA_ROOT/doctemplates/users', 'chaine', 0); diff --git a/htdocs/install/mysql/migration/3.2.0-3.3.0.sql b/htdocs/install/mysql/migration/3.2.0-3.3.0.sql index 2253eb68787..91c155d3d84 100644 --- a/htdocs/install/mysql/migration/3.2.0-3.3.0.sql +++ b/htdocs/install/mysql/migration/3.2.0-3.3.0.sql @@ -803,7 +803,7 @@ ALTER TABLE llx_user ADD COLUMN job varchar(128) AFTER firstname; -- Use entity 0 for all entities -INSERT INTO llx_const(name, value, visible, entity) SELECT __ENCRYPT('SYSLOG_HANDLERS')__, __ENCRYPT('[\'mod_syslog_file\']')__, 0, 0 FROM llx_const WHERE __DECRYPT('name')__ = 'SYSLOG_FILE_ON' AND __DECRYPT('value')__ = '1'; +INSERT INTO llx_const(name, value, visible, entity) SELECT __ENCRYPT('SYSLOG_HANDLERS')__, __ENCRYPT('["mod_syslog_file"]')__, 0, 0 FROM llx_const WHERE __DECRYPT('name')__ = 'SYSLOG_FILE_ON' AND __DECRYPT('value')__ = '1'; -- New Imports diff --git a/htdocs/install/mysql/migration/5.0.0-6.0.0.sql b/htdocs/install/mysql/migration/5.0.0-6.0.0.sql index 3acf312bae1..637648be3ba 100644 --- a/htdocs/install/mysql/migration/5.0.0-6.0.0.sql +++ b/htdocs/install/mysql/migration/5.0.0-6.0.0.sql @@ -493,7 +493,7 @@ CREATE TABLE llx_blockedlog_authority rowid integer AUTO_INCREMENT PRIMARY KEY, blockchain longtext NOT NULL, signature varchar(100) NOT NULL, - tms timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP + tms timestamp ) ENGINE=innodb; ALTER TABLE llx_blockedlog_authority ADD INDEX signature (signature); diff --git a/htdocs/install/mysql/tables/llx_blockedlog_authority.sql b/htdocs/install/mysql/tables/llx_blockedlog_authority.sql index eb491f93af4..9e7dae8f23c 100644 --- a/htdocs/install/mysql/tables/llx_blockedlog_authority.sql +++ b/htdocs/install/mysql/tables/llx_blockedlog_authority.sql @@ -3,5 +3,5 @@ CREATE TABLE llx_blockedlog_authority rowid integer AUTO_INCREMENT PRIMARY KEY, blockchain longtext NOT NULL, signature varchar(100) NOT NULL, - tms timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP + tms timestamp ) ENGINE=innodb; diff --git a/htdocs/install/pgsql/functions/functions.sql b/htdocs/install/pgsql/functions/functions.sql index 441b20c66ad..1b2d184de0f 100644 --- a/htdocs/install/pgsql/functions/functions.sql +++ b/htdocs/install/pgsql/functions/functions.sql @@ -24,9 +24,10 @@ CREATE OR REPLACE FUNCTION UNIX_TIMESTAMP(TIMESTAMP WITHOUT TIME ZONE) RETURNS B CREATE OR REPLACE FUNCTION UNIX_TIMESTAMP(TIMESTAMP WITH TIME ZONE) RETURNS BIGINT LANGUAGE SQL IMMUTABLE STRICT AS 'SELECT EXTRACT(EPOCH FROM $1)::bigint;'; - +DROP FUNCTION date_format(timestamp without time zone,text); CREATE OR REPLACE FUNCTION date_format(timestamp without time zone, text) RETURNS text AS $$ DECLARE i int := 1; temp text := ''; c text; n text; res text; BEGIN WHILE i <= pg_catalog.length($2) LOOP c := SUBSTRING ($2 FROM i FOR 1); IF c = '%' AND i != pg_catalog.length($2) THEN n := SUBSTRING ($2 FROM (i + 1) FOR 1); SELECT INTO res CASE WHEN n = 'a' THEN pg_catalog.to_char($1, 'Dy') WHEN n = 'b' THEN pg_catalog.to_char($1, 'Mon') WHEN n = 'c' THEN pg_catalog.to_char($1, 'FMMM') WHEN n = 'D' THEN pg_catalog.to_char($1, 'FMDDth') WHEN n = 'd' THEN pg_catalog.to_char($1, 'DD') WHEN n = 'e' THEN pg_catalog.to_char($1, 'FMDD') WHEN n = 'f' THEN pg_catalog.to_char($1, 'US') WHEN n = 'H' THEN pg_catalog.to_char($1, 'HH24') WHEN n = 'h' THEN pg_catalog.to_char($1, 'HH12') WHEN n = 'I' THEN pg_catalog.to_char($1, 'HH12') WHEN n = 'i' THEN pg_catalog.to_char($1, 'MI') WHEN n = 'j' THEN pg_catalog.to_char($1, 'DDD') WHEN n = 'k' THEN pg_catalog.to_char($1, 'FMHH24') WHEN n = 'l' THEN pg_catalog.to_char($1, 'FMHH12') WHEN n = 'M' THEN pg_catalog.to_char($1, 'FMMonth') WHEN n = 'm' THEN pg_catalog.to_char($1, 'MM') WHEN n = 'p' THEN pg_catalog.to_char($1, 'AM') WHEN n = 'r' THEN pg_catalog.to_char($1, 'HH12:MI:SS AM') WHEN n = 'S' THEN pg_catalog.to_char($1, 'SS') WHEN n = 's' THEN pg_catalog.to_char($1, 'SS') WHEN n = 'T' THEN pg_catalog.to_char($1, 'HH24:MI:SS') WHEN n = 'U' THEN pg_catalog.to_char($1, '?') WHEN n = 'u' THEN pg_catalog.to_char($1, '?') WHEN n = 'V' THEN pg_catalog.to_char($1, '?') WHEN n = 'v' THEN pg_catalog.to_char($1, '?') WHEN n = 'W' THEN pg_catalog.to_char($1, 'FMDay') WHEN n = 'w' THEN EXTRACT(DOW FROM $1)::text WHEN n = 'X' THEN pg_catalog.to_char($1, '?') WHEN n = 'x' THEN pg_catalog.to_char($1, '?') WHEN n = 'Y' THEN pg_catalog.to_char($1, 'YYYY') WHEN n = 'y' THEN pg_catalog.to_char($1, 'YY') WHEN n = '%' THEN pg_catalog.to_char($1, '%') ELSE NULL END; temp := temp operator(pg_catalog.||) res; i := i + 2; ELSE temp = temp operator(pg_catalog.||) c; i := i + 1; END IF; END LOOP; RETURN temp; END $$ IMMUTABLE STRICT LANGUAGE plpgsql; +DROP FUNCTION date_format(timestamp with time zone,text); CREATE OR REPLACE FUNCTION date_format(timestamp with time zone, text) RETURNS text AS $$ DECLARE i int := 1; temp text := ''; c text; n text; res text; BEGIN WHILE i <= pg_catalog.length($2) LOOP c := SUBSTRING ($2 FROM i FOR 1); IF c = '%' AND i != pg_catalog.length($2) THEN n := SUBSTRING ($2 FROM (i + 1) FOR 1); SELECT INTO res CASE WHEN n = 'a' THEN pg_catalog.to_char($1, 'Dy') WHEN n = 'b' THEN pg_catalog.to_char($1, 'Mon') WHEN n = 'c' THEN pg_catalog.to_char($1, 'FMMM') WHEN n = 'D' THEN pg_catalog.to_char($1, 'FMDDth') WHEN n = 'd' THEN pg_catalog.to_char($1, 'DD') WHEN n = 'e' THEN pg_catalog.to_char($1, 'FMDD') WHEN n = 'f' THEN pg_catalog.to_char($1, 'US') WHEN n = 'H' THEN pg_catalog.to_char($1, 'HH24') WHEN n = 'h' THEN pg_catalog.to_char($1, 'HH12') WHEN n = 'I' THEN pg_catalog.to_char($1, 'HH12') WHEN n = 'i' THEN pg_catalog.to_char($1, 'MI') WHEN n = 'j' THEN pg_catalog.to_char($1, 'DDD') WHEN n = 'k' THEN pg_catalog.to_char($1, 'FMHH24') WHEN n = 'l' THEN pg_catalog.to_char($1, 'FMHH12') WHEN n = 'M' THEN pg_catalog.to_char($1, 'FMMonth') WHEN n = 'm' THEN pg_catalog.to_char($1, 'MM') WHEN n = 'p' THEN pg_catalog.to_char($1, 'AM') WHEN n = 'r' THEN pg_catalog.to_char($1, 'HH12:MI:SS AM') WHEN n = 'S' THEN pg_catalog.to_char($1, 'SS') WHEN n = 's' THEN pg_catalog.to_char($1, 'SS') WHEN n = 'T' THEN pg_catalog.to_char($1, 'HH24:MI:SS') WHEN n = 'U' THEN pg_catalog.to_char($1, '?') WHEN n = 'u' THEN pg_catalog.to_char($1, '?') WHEN n = 'V' THEN pg_catalog.to_char($1, '?') WHEN n = 'v' THEN pg_catalog.to_char($1, '?') WHEN n = 'W' THEN pg_catalog.to_char($1, 'FMDay') WHEN n = 'w' THEN EXTRACT(DOW FROM $1)::text WHEN n = 'X' THEN pg_catalog.to_char($1, '?') WHEN n = 'x' THEN pg_catalog.to_char($1, '?') WHEN n = 'Y' THEN pg_catalog.to_char($1, 'YYYY') WHEN n = 'y' THEN pg_catalog.to_char($1, 'YY') WHEN n = '%' THEN pg_catalog.to_char($1, '%') ELSE NULL END; temp := temp operator(pg_catalog.||) res; i := i + 2; ELSE temp = temp operator(pg_catalog.||) c; i := i + 1; END IF; END LOOP; RETURN temp; END $$ IMMUTABLE STRICT LANGUAGE plpgsql; diff --git a/test/phpunit/CodingSqlTest.php b/test/phpunit/CodingSqlTest.php index 348043d4a4e..d158b71fc2e 100644 --- a/test/phpunit/CodingSqlTest.php +++ b/test/phpunit/CodingSqlTest.php @@ -141,7 +141,7 @@ class CodingSqlTest extends PHPUnit_Framework_TestCase $langs=$this->savlangs; $db=$this->savdb; - $listofsqldir = array(DOL_DOCUMENT_ROOT.'/install/mysql/tables', DOL_DOCUMENT_ROOT.'/install/mysql/migration'); + $listofsqldir = array(DOL_DOCUMENT_ROOT.'/install/mysql/data', DOL_DOCUMENT_ROOT.'/install/mysql/tables', DOL_DOCUMENT_ROOT.'/install/mysql/migration'); foreach ($listofsqldir as $dir) { @@ -161,8 +161,12 @@ class CodingSqlTest extends PHPUnit_Framework_TestCase $this->assertTrue($result===false, 'Found back quote into '.$file.'. Bad.'); $result=strpos($filecontent,'"'); + if ($result) + { + $result=! strpos($filecontent,'["'); + } print __METHOD__." Result for checking we don't have double quote = ".$result."\n"; - $this->assertTrue($result===false, 'Found double quote into '.$file.'. Bad.'); + $this->assertTrue($result===false, 'Found double quote that is not [" (used for json content) into '.$file.'. Bad.'); $result=strpos($filecontent,'int('); print __METHOD__." Result for checking we don't have 'int(' instead of 'integer' = ".$result."\n"; @@ -176,6 +180,11 @@ class CodingSqlTest extends PHPUnit_Framework_TestCase { // Test for migration files only + } + elseif ($dir == DOL_DOCUMENT_ROOT.'/install/mysql/data') + { + // Test for data files only + } else { From 302e086f991c60dad5abd3a7b3ea214dbf3b5106 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 20 Jun 2017 13:33:26 +0200 Subject: [PATCH 118/227] Fix pgsql compatibility --- .../class/supplier_proposal.class.php | 86 +++++++++---------- 1 file changed, 43 insertions(+), 43 deletions(-) diff --git a/htdocs/supplier_proposal/class/supplier_proposal.class.php b/htdocs/supplier_proposal/class/supplier_proposal.class.php index e3f873476ba..b14e4a40ff9 100644 --- a/htdocs/supplier_proposal/class/supplier_proposal.class.php +++ b/htdocs/supplier_proposal/class/supplier_proposal.class.php @@ -50,7 +50,7 @@ class SupplierProposal extends CommonObject public $fk_element='fk_supplier_proposal'; protected $ismultientitymanaged = 1; // 0=No test on entity, 1=Test with field entity, 2=Test with link by societe public $picto='propal'; - + /** * {@inheritdoc} */ @@ -140,7 +140,7 @@ class SupplierProposal extends CommonObject var $multicurrency_total_ht; var $multicurrency_total_tva; var $multicurrency_total_ttc; - + /** * Draft status */ @@ -160,10 +160,10 @@ class SupplierProposal extends CommonObject /** * Billed or closed/processed quote */ - const STATUS_CLOSE = 4; - - - + const STATUS_CLOSE = 4; + + + /** * Constructor * @@ -407,7 +407,7 @@ class SupplierProposal extends CommonObject $localtaxes_type=getLocalTaxesFromRate($txtva,0,$this->thirdparty,$mysoc); $txtva = preg_replace('/\s*\(.*\)/','',$txtva); // Remove code into vatrate. - + $tabprice=calcul_price_total($qty, $pu, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, 0, $price_base_type, $info_bits, $type, $this->thirdparty, $localtaxes_type, 100, $this->multicurrency_tx); $total_ht = $tabprice[0]; $total_tva = $tabprice[1]; @@ -419,7 +419,7 @@ class SupplierProposal extends CommonObject $multicurrency_total_ht = $tabprice[16]; $multicurrency_total_tva = $tabprice[17]; $multicurrency_total_ttc = $tabprice[18]; - + // Rang to use $rangtouse = $rang; if ($rangtouse == -1) @@ -487,7 +487,7 @@ class SupplierProposal extends CommonObject $this->line->multicurrency_total_ht = $multicurrency_total_ht; $this->line->multicurrency_total_tva = $multicurrency_total_tva; $this->line->multicurrency_total_ttc = $multicurrency_total_ttc; - + // Mise en option de la ligne if (empty($qty) && empty($special_code)) $this->line->special_code=3; @@ -583,7 +583,7 @@ class SupplierProposal extends CommonObject $localtaxes_type=getLocalTaxesFromRate($txtva,0,$this->thirdparty,$mysoc); $txtva = preg_replace('/\s*\(.*\)/','',$txtva); // Remove code into vatrate. - + $tabprice=calcul_price_total($qty, $pu, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, 0, $price_base_type, $info_bits, $type, $this->thirdparty, $localtaxes_type, 100, $this->multicurrency_tx); $total_ht = $tabprice[0]; $total_tva = $tabprice[1]; @@ -595,7 +595,7 @@ class SupplierProposal extends CommonObject $multicurrency_total_ht = $tabprice[16]; $multicurrency_total_tva = $tabprice[17]; $multicurrency_total_ttc = $tabprice[18]; - + // Anciens indicateurs: $price, $remise (a ne plus utiliser) $price = $pu; if ($remise_percent > 0) @@ -662,7 +662,7 @@ class SupplierProposal extends CommonObject if (is_array($array_option) && count($array_option)>0) { $this->line->array_options=$array_option; } - + // Multicurrency $this->line->multicurrency_subprice = price2num($pu * $this->multicurrency_tx); $this->line->multicurrency_total_ht = $multicurrency_total_ht; @@ -1180,7 +1180,7 @@ class SupplierProposal extends CommonObject $this->multicurrency_total_ht = $obj->multicurrency_total_ht; $this->multicurrency_total_tva = $obj->multicurrency_total_tva; $this->multicurrency_total_ttc = $obj->multicurrency_total_ttc; - + if ($obj->fk_statut == 0) { $this->brouillon = 1; @@ -1271,7 +1271,7 @@ class SupplierProposal extends CommonObject $line->multicurrency_total_tva = $objp->multicurrency_total_tva; $line->multicurrency_total_ttc = $objp->multicurrency_total_ttc; $line->fk_unit = $objp->fk_unit; - + $this->lines[$i] = $line; $i++; @@ -1653,7 +1653,7 @@ class SupplierProposal extends CommonObject { $trigger_name='SUPPLIER_PROPOSAL_CLASSIFY_BILLED'; } - + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { // Define output language @@ -1704,7 +1704,7 @@ class SupplierProposal extends CommonObject $productsupplier = new ProductFournisseur($this->db); dol_syslog(get_class($this)."::updateOrCreatePriceFournisseur", LOG_DEBUG); - foreach ($this->lines as $product) + foreach ($this->lines as $product) { if ($product->subprice <= 0) continue; @@ -1721,7 +1721,7 @@ class SupplierProposal extends CommonObject $this->createPriceFournisseur($product, $user); } } - + return 1; } @@ -2149,7 +2149,7 @@ class SupplierProposal extends CommonObject $response->label = $label; $response->url = DOL_URL_ROOT.'/supplier_proposal/list.php?viewstatut='.$statut; $response->img = img_object('',"propal"); - + // This assignment in condition is not a bug. It allows walking the results. while ($obj=$this->db->fetch_object($resql)) { @@ -2187,7 +2187,7 @@ class SupplierProposal extends CommonObject global $user,$langs,$conf; // Load array of products prodids - $num_prods = 0; + $num_prods = 0; $prodids = array(); $sql = "SELECT rowid"; $sql.= " FROM ".MAIN_DB_PREFIX."product"; @@ -2250,7 +2250,7 @@ class SupplierProposal extends CommonObject $prodid = mt_rand(1, $num_prods); $line->fk_product=$prodids[$prodid]; } - + $this->lines[$xnbp]=$line; $this->total_ht += $line->total_ht; @@ -2375,10 +2375,10 @@ class SupplierProposal extends CommonObject global $langs, $conf, $user; if (! empty($conf->dol_no_mouse_hover)) $notooltip=1; // Force disable tooltips - + $url=''; $result=''; - + $label=''.$langs->trans("ShowSupplierProposal").''; if (! empty($this->ref)) $label.= '
'.$langs->trans('Ref').': '.$this->ref; @@ -2396,7 +2396,7 @@ class SupplierProposal extends CommonObject if ($option == 'document') { $url = DOL_URL_ROOT.'/supplier_proposal/document.php?id='.$this->id. $get_params; } - + $linkclose=''; if (empty($notooltip) && $user->rights->propal->lire) { @@ -2408,7 +2408,7 @@ class SupplierProposal extends CommonObject $linkclose.= ' title="'.dol_escape_htmltag($label, 1).'"'; $linkclose.=' class="classfortooltip"'; } - + $linkstart = ''; $linkend=''; @@ -2432,14 +2432,14 @@ class SupplierProposal extends CommonObject function getLinesArray() { // For other object, here we call fetch_lines. But fetch_lines does not exists on supplier proposal - + $sql = 'SELECT pt.rowid, pt.label as custom_label, pt.description, pt.fk_product, pt.fk_remise_except,'; $sql.= ' pt.qty, pt.tva_tx, pt.remise_percent, pt.subprice, pt.info_bits,'; $sql.= ' pt.total_ht, pt.total_tva, pt.total_ttc, pt.fk_product_fournisseur_price as fk_fournprice, pt.buy_price_ht as pa_ht, pt.special_code, pt.localtax1_tx, pt.localtax2_tx,'; $sql.= ' pt.product_type, pt.rang, pt.fk_parent_line,'; $sql.= ' p.label as product_label, p.ref, p.fk_product_type, p.rowid as prodid,'; - $sql.= ' p.description as product_desc, pt.ref_fourn as ref_produit_fourn'; - $sql.= ' ,pt.fk_multicurrency, pt.multicurrency_code, pt.multicurrency_subprice, pt.multicurrency_total_ht, pt.multicurrency_total_tva, pt.multicurrency_total_ttc, pt.fk_unit'; + $sql.= ' p.description as product_desc, pt.ref_fourn as ref_produit_fourn,'; + $sql.= ' pt.fk_multicurrency, pt.multicurrency_code, pt.multicurrency_subprice, pt.multicurrency_total_ht, pt.multicurrency_total_tva, pt.multicurrency_total_ttc, pt.fk_unit'; $sql.= ' FROM '.MAIN_DB_PREFIX.'supplier_proposaldet as pt'; $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON pt.fk_product=p.rowid'; $sql.= ' WHERE pt.fk_supplier_proposal = '.$this->id; @@ -2486,7 +2486,7 @@ class SupplierProposal extends CommonObject $this->lines[$i]->rang = $obj->rang; $this->lines[$i]->ref_fourn = $obj->ref_produit_fourn; - + // Multicurrency $this->lines[$i]->fk_multicurrency = $obj->fk_multicurrency; $this->lines[$i]->multicurrency_code = $obj->multicurrency_code; @@ -2541,7 +2541,7 @@ class SupplierProposal extends CommonObject return $this->commonGenerateDocument($modelpath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref); } - + /** * Function used to replace a thirdparty id with another one. * @@ -2555,10 +2555,10 @@ class SupplierProposal extends CommonObject $tables = array( 'supplier_proposal' ); - + return CommonObject::commonReplaceThirdparty($db, $origin_id, $dest_id, $tables); } - + } @@ -2669,7 +2669,7 @@ class SupplierProposalLine extends CommonObjectLine var $skip_update_total; // Skip update price total for special lines var $ref_fourn; - + // Multicurrency var $fk_multicurrency; var $multicurrency_code; @@ -2750,7 +2750,7 @@ class SupplierProposalLine extends CommonObjectLine $this->product_desc = $objp->product_desc; $this->ref_fourn = $objp->ref_produit_forun; - + // Multicurrency $this->fk_multicurrency = $objp->fk_multicurrency; $this->multicurrency_code = $objp->multicurrency_code; @@ -2798,11 +2798,11 @@ class SupplierProposalLine extends CommonObjectLine if (empty($this->fk_parent_line)) $this->fk_parent_line=0; if (empty($this->fk_fournprice)) $this->fk_fournprice=0; if (empty($this->fk_unit)) $this->fk_unit=0; - + if (empty($this->pa_ht)) $this->pa_ht=0; // if buy price not defined, define buyprice as configured in margin admin - if ($this->pa_ht == 0) + if ($this->pa_ht == 0) { if (($result = $this->defineBuyPrice($this->subprice, $this->remise_percent, $this->fk_product)) < 0) { @@ -2826,8 +2826,8 @@ class SupplierProposalLine extends CommonObjectLine $sql.= ' subprice, remise_percent, '; $sql.= ' info_bits, '; $sql.= ' total_ht, total_tva, total_localtax1, total_localtax2, total_ttc, fk_product_fournisseur_price, buy_price_ht, special_code, rang,'; - $sql.= ' ref_fourn'; - $sql.= ', fk_multicurrency, multicurrency_code, multicurrency_subprice, multicurrency_total_ht, multicurrency_total_tva, multicurrency_total_ttc, fk_unit)'; + $sql.= ' ref_fourn,'; + $sql.= ' fk_multicurrency, multicurrency_code, multicurrency_subprice, multicurrency_total_ht, multicurrency_total_tva, multicurrency_total_ttc, fk_unit)'; $sql.= " VALUES (".$this->fk_supplier_proposal.","; $sql.= " ".($this->fk_parent_line>0?"'".$this->fk_parent_line."'":"null").","; $sql.= " ".(! empty($this->label)?"'".$this->db->escape($this->label)."'":"null").","; @@ -2860,7 +2860,7 @@ class SupplierProposalLine extends CommonObjectLine $sql.= ", ".$this->multicurrency_total_ht; $sql.= ", ".$this->multicurrency_total_tva; $sql.= ", ".$this->multicurrency_total_ttc; - $sql.= ", fk_unit=".($this->fk_unit?$this->fk_unit:'null'); + $sql.= ", ".($this->fk_unit?$this->fk_unit:'null'); $sql.= ')'; dol_syslog(get_class($this).'::insert', LOG_DEBUG); @@ -2869,7 +2869,7 @@ class SupplierProposalLine extends CommonObjectLine { $this->rowid=$this->db->last_insert_id(MAIN_DB_PREFIX.'supplier_proposaldet'); $this->id=$this->rowid; - + if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used { $result=$this->insertExtraFields(); @@ -2982,11 +2982,11 @@ class SupplierProposalLine extends CommonObjectLine if (empty($this->fk_parent_line)) $this->fk_parent_line=0; if (empty($this->fk_fournprice)) $this->fk_fournprice=0; if (empty($this->fk_unit)) $this->fk_unit=0; - + if (empty($this->pa_ht)) $this->pa_ht=0; // if buy price not defined, define buyprice as configured in margin admin - if ($this->pa_ht == 0) + if ($this->pa_ht == 0) { if (($result = $this->defineBuyPrice($this->subprice, $this->remise_percent, $this->fk_product)) < 0) { @@ -3031,13 +3031,13 @@ class SupplierProposalLine extends CommonObjectLine if (! empty($this->rang)) $sql.= ", rang=".$this->rang; $sql.= " , ref_fourn=".(! empty($this->ref_fourn)?"'".$this->db->escape($this->ref_fourn)."'":"null"); $sql.= " , fk_unit=".($this->fk_unit?$this->fk_unit:'null'); - + // Multicurrency $sql.= " , multicurrency_subprice=".price2num($this->multicurrency_subprice).""; $sql.= " , multicurrency_total_ht=".price2num($this->multicurrency_total_ht).""; $sql.= " , multicurrency_total_tva=".price2num($this->multicurrency_total_tva).""; $sql.= " , multicurrency_total_ttc=".price2num($this->multicurrency_total_ttc).""; - + $sql.= " WHERE rowid = ".$this->rowid; dol_syslog(get_class($this)."::update", LOG_DEBUG); From 3873bc74333657921b2c01cc67a3153284674146 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 20 Jun 2017 15:06:24 +0200 Subject: [PATCH 119/227] Fix bette compatibility with pgsql --- htdocs/core/db/pgsql.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/db/pgsql.class.php b/htdocs/core/db/pgsql.class.php index 2b8e90d0780..4aa56b367f3 100644 --- a/htdocs/core/db/pgsql.class.php +++ b/htdocs/core/db/pgsql.class.php @@ -185,8 +185,8 @@ class DoliDBPgsql extends DoliDB // we are inside create table statement so lets process datatypes if (preg_match('/(ISAM|innodb)/i',$line)) { // end of create table sequence - $line=preg_replace('/\)[\s\t]*type[\s\t]*=[\s\t]*(MyISAM|innodb);/i',');',$line); - $line=preg_replace('/\)[\s\t]*engine[\s\t]*=[\s\t]*(MyISAM|innodb);/i',');',$line); + $line=preg_replace('/\)[\s\t]*type[\s\t]*=[\s\t]*(MyISAM|innodb).*;/i',');',$line); + $line=preg_replace('/\)[\s\t]*engine[\s\t]*=[\s\t]*(MyISAM|innodb).*;/i',');',$line); $line=preg_replace('/,$/','',$line); } From ec9bbe2b52214008f6d6c55bf3dafbb8b8080778 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 20 Jun 2017 16:54:37 +0200 Subject: [PATCH 120/227] Help/Need debug of some online instances with the log view --- htdocs/admin/syslog.php | 14 +++++++++++--- htdocs/admin/tools/purge.php | 10 +++++++++- htdocs/core/lib/files.lib.php | 21 +++++++++++++-------- htdocs/document.php | 5 +++-- 4 files changed, 36 insertions(+), 14 deletions(-) diff --git a/htdocs/admin/syslog.php b/htdocs/admin/syslog.php index 65933c25639..75de985728c 100644 --- a/htdocs/admin/syslog.php +++ b/htdocs/admin/syslog.php @@ -88,7 +88,7 @@ if ($action == 'set') $newActiveModules = array(); $selectedModules = (isset($_POST['SYSLOG_HANDLERS']) ? $_POST['SYSLOG_HANDLERS'] : array()); - + // Save options of handler foreach ($syslogModules as $syslogHandler) { @@ -111,7 +111,7 @@ if ($action == 'set') $activeModules = $newActiveModules; - dolibarr_del_const($db, 'SYSLOG_HANDLERS', -1); // To be sure ther is not a setup into another entity + dolibarr_del_const($db, 'SYSLOG_HANDLERS', -1); // To be sure ther is not a setup into another entity dolibarr_set_const($db, 'SYSLOG_HANDLERS', json_encode($activeModules), 'chaine',0,'',0); // Check configuration @@ -206,7 +206,7 @@ foreach ($syslogModules as $moduleName) //print $moduleName." = ".$moduleactive." - ".$module->getName()." ".($moduleactive == -1)."
\n"; if (($moduleactive == -1) && empty($conf->global->MAIN_FEATURES_LEVEL)) continue; // Some modules are hidden if not activable and not into debug mode (end user must not see them) - + print ''; print ''; print ' '; @@ -229,6 +229,14 @@ foreach ($syslogModules as $moduleName) print $option['name'].': '; if (! empty($option['example'])) print '
'.$langs->trans("Example").': '.$option['example']; + + if ($option['constant'] == 'SYSLOG_FILE' && preg_match('/^DOL_DATA_ROOT\/[^\/]*$/',$value)) + { + $filelogparam =' ('; + $filelogparam.=$langs->trans('Download'); + $filelogparam.=$filelog.')'; + print $filelogparam; + } } } print ''; diff --git a/htdocs/admin/tools/purge.php b/htdocs/admin/tools/purge.php index e913d59a4a7..7a5cb30ae75 100644 --- a/htdocs/admin/tools/purge.php +++ b/htdocs/admin/tools/purge.php @@ -83,7 +83,15 @@ if (! empty($conf->syslog->enabled)) { print ' '.$langs->trans("PurgeDeleteLogFile",$filelog).'

'; + $filelogparam=$filelog; + if ($user->admin && preg_match('/^dolibarr.*\.log$/', basename($filelog))) + { + $filelogparam =''.$filelog.''; + } + print '> '.$langs->trans("PurgeDeleteLogFile", $filelogparam); + print '

'; } print 'admin && basename($original_file) == $original_file && preg_match('/^dolibarr.*\.log$/', basename($original_file))); + $original_file=$dolibarr_main_data_root.'/'.$original_file; + } // Wrapping for some images - if (($modulepart == 'mycompany' || $modulepart == 'companylogo') && !empty($conf->mycompany->dir_output)) + elseif (($modulepart == 'mycompany' || $modulepart == 'companylogo') && !empty($conf->mycompany->dir_output)) { $accessallowed=1; $original_file=$conf->mycompany->dir_output.'/logos/'.$original_file; @@ -2369,13 +2381,6 @@ function dol_check_secure_access_document($modulepart, $original_file, $entity, $original_file=$conf->fckeditor->dir_output.'/'.$original_file; } - // Wrapping for miscellaneous medias files - elseif ($modulepart == 'medias' && !empty($dolibarr_main_data_root)) - { - $accessallowed=1; - $original_file=$dolibarr_main_data_root.'/medias/'.$original_file; - } - // Wrapping for backups else if ($modulepart == 'systemtools' && !empty($conf->admin->dir_output)) { diff --git a/htdocs/document.php b/htdocs/document.php index 46e27d57a67..206ea69688a 100644 --- a/htdocs/document.php +++ b/htdocs/document.php @@ -26,6 +26,7 @@ * \brief Wrapper to download data files * \remarks Call of this wrapper is made with URL: * document.php?modulepart=repfichierconcerne&file=pathrelatifdufichier + * document.php?modulepart=logs&file=dolibarr.log */ define('NOTOKENRENEWAL',1); // Disables token renewal @@ -106,7 +107,7 @@ $refname=basename(dirname($original_file)."/"); // Security check if (empty($modulepart)) accessforbidden('Bad value for parameter modulepart'); -$check_access = dol_check_secure_access_document($modulepart,$original_file,$entity,$refname); +$check_access = dol_check_secure_access_document($modulepart, $original_file, $entity, $refname); $accessallowed = $check_access['accessallowed']; $sqlprotectagainstexternals = $check_access['sqlprotectagainstexternals']; $original_file = $check_access['original_file']; // original_file is now a full path name @@ -183,7 +184,7 @@ header('Pragma: public'); //ob_clean(); //flush(); - + readfile($original_file_osencoded); if (is_object($db)) $db->close(); From ce8a024d4484c5f42d141e5889f6d62b0eebf51e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 21 Jun 2017 00:34:56 +0200 Subject: [PATCH 121/227] Fix limit on margin pages --- htdocs/margin/agentMargins.php | 22 ++++++++++++---------- htdocs/margin/customerMargins.php | 18 ++++++++++++------ htdocs/margin/productMargins.php | 28 ++++++++++++++-------------- 3 files changed, 38 insertions(+), 30 deletions(-) diff --git a/htdocs/margin/agentMargins.php b/htdocs/margin/agentMargins.php index f474b7af340..e00eb4ae18b 100644 --- a/htdocs/margin/agentMargins.php +++ b/htdocs/margin/agentMargins.php @@ -44,8 +44,15 @@ if ($user->rights->margins->read->all) { $mesg = ''; -$sortfield = GETPOST("sortfield",'alpha'); -$sortorder = GETPOST("sortorder",'alpha'); +// Load variable for pagination +$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit; +$sortfield = GETPOST('sortfield','alpha'); +$sortorder = GETPOST('sortorder','alpha'); +$page = GETPOST('page','int'); +if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 +$offset = $limit * $page; +$pageprev = $page - 1; +$pagenext = $page + 1; if (! $sortorder) $sortorder="ASC"; if (! $sortfield) { @@ -54,11 +61,6 @@ if (! $sortfield) else $sortfield="u.lastname"; } -$page = GETPOST("page",'int'); -if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 -$offset = $conf->liste_limit * $page; -$pageprev = $page - 1; -$pagenext = $page + 1; $startdate=$enddate=''; @@ -170,13 +172,13 @@ if ($result) $num = $db->num_rows($result); print '
'; - print_barre_liste($langs->trans("MarginDetails"),$page,$_SERVER["PHP_SELF"],"",$sortfield,$sortorder,'',$num,$num,''); + print_barre_liste($langs->trans("MarginDetails"), $page, $_SERVER["PHP_SELF"], "", $sortfield, $sortorder, '', $num, $num, '', 0, '', '', 0, 1); if ($conf->global->MARGIN_TYPE == "1") $labelcostprice=$langs->trans('BuyingPrice'); else // value is 'costprice' or 'pmp' $labelcostprice=$langs->trans('CostPrice'); - + $i = 0; print ""; @@ -220,7 +222,7 @@ if ($result) $markRate = ($pv != 0)?(100 * $marge / $pv):'' ; } - + print ''; if ($agentid > 0) { diff --git a/htdocs/margin/customerMargins.php b/htdocs/margin/customerMargins.php index 64b0dd82ff2..ed76cde223c 100644 --- a/htdocs/margin/customerMargins.php +++ b/htdocs/margin/customerMargins.php @@ -41,11 +41,17 @@ $result = restrictedArea($user, 'societe','',''); $mesg = ''; -$page = GETPOST("page",'int'); +// Load variable for pagination +$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit; +$sortfield = GETPOST('sortfield','alpha'); +$sortorder = GETPOST('sortorder','alpha'); +$page = GETPOST('page','int'); if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 -$offset = $conf->liste_limit * $page; +$offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; +if (! $sortfield) $sortfield="s.nom"; // Set here default search field +if (! $sortorder) $sortorder="ASC"; $startdate=$enddate=''; @@ -206,13 +212,13 @@ if ($result) $num = $db->num_rows($result); print '
'; - print_barre_liste($langs->trans("MarginDetails"),$page,$_SERVER["PHP_SELF"],"",$sortfield,$sortorder,'',$num,$num,''); + print_barre_liste($langs->trans("MarginDetails"), $page, $_SERVER["PHP_SELF"], "", $sortfield, $sortorder, '', $num, $num, '', 0, '', '', 0, 1); if ($conf->global->MARGIN_TYPE == "1") $labelcostprice=$langs->trans('BuyingPrice'); else // value is 'costprice' or 'pmp' $labelcostprice=$langs->trans('CostPrice'); - + $i = 0; print "
"; @@ -260,7 +266,7 @@ if ($result) $markRate = ($pv != 0)?(100 * $marge / $pv):'' ; } - + print ''; if ($client) { @@ -295,7 +301,7 @@ if ($result) } // affichage totaux marges - + $totalMargin = $cumul_vente - $cumul_achat; /*if ($totalMargin < 0) { diff --git a/htdocs/margin/productMargins.php b/htdocs/margin/productMargins.php index f1ed5afe573..43a9ef0f22e 100644 --- a/htdocs/margin/productMargins.php +++ b/htdocs/margin/productMargins.php @@ -46,9 +46,15 @@ $result=restrictedArea($user,'produit|service',$fieldvalue,'product&product','', $mesg = ''; -$sortfield = GETPOST("sortfield",'alpha'); -$sortorder = GETPOST("sortorder",'alpha'); -if (! $sortorder) $sortorder="ASC"; +// Load variable for pagination +$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit; +$sortfield = GETPOST('sortfield','alpha'); +$sortorder = GETPOST('sortorder','alpha'); +$page = GETPOST('page','int'); +if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 +$offset = $limit * $page; +$pageprev = $page - 1; +$pagenext = $page + 1; if (! $sortfield) { if ($id > 0) @@ -63,12 +69,6 @@ if (! $sortfield) } } -$page = GETPOST("page",'int'); -if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 -$offset = $conf->liste_limit * $page; -$pageprev = $page - 1; -$pagenext = $page + 1; - $startdate=$enddate=''; if (!empty($_POST['startdatemonth'])) @@ -202,16 +202,16 @@ if ($result) $num = $db->num_rows($result); print '
'; - print_barre_liste($langs->trans("MarginDetails"),$page,$_SERVER["PHP_SELF"],"&id=".$id,$sortfield,$sortorder,'',$num,$num,''); + print_barre_liste($langs->trans("MarginDetails"), $page, $_SERVER["PHP_SELF"], "&id=".$id, $sortfield, $sortorder, '', $num, $num, '', 0, '', '', 0, 1); //var_dump($conf->global->MARGIN_TYPE); if ($conf->global->MARGIN_TYPE == "1") $labelcostprice=$langs->trans('BuyingPrice'); else // value is 'costprice' or 'pmp' $labelcostprice=$langs->trans('CostPrice'); - + $moreforfilter=''; - + $i = 0; print '
'; print '
'."\n"; @@ -260,7 +260,7 @@ if ($result) $markRate = ($pv != 0)?(100 * $marge / $pv):'' ; } - + print ''; if ($id > 0) { @@ -308,7 +308,7 @@ if ($result) } // affichage totaux marges - + $totalMargin = $cumul_vente - $cumul_achat; $marginRate = ($cumul_achat != 0)?(100 * $totalMargin / $cumul_achat):''; From 9ec792975396b708dd1e90fd535bcae94df26a9e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 21 Jun 2017 10:57:15 +0200 Subject: [PATCH 122/227] Look and feel v6 --- htdocs/margin/agentMargins.php | 25 +++- htdocs/margin/checkMargins.php | 237 +++++++++++++++--------------- htdocs/margin/customerMargins.php | 1 + htdocs/margin/productMargins.php | 1 + htdocs/theme/eldy/style.css.php | 5 +- htdocs/theme/md/style.css.php | 5 +- 6 files changed, 143 insertions(+), 131 deletions(-) diff --git a/htdocs/margin/agentMargins.php b/htdocs/margin/agentMargins.php index e00eb4ae18b..6c3a246ad0d 100644 --- a/htdocs/margin/agentMargins.php +++ b/htdocs/margin/agentMargins.php @@ -34,14 +34,6 @@ $langs->load("bills"); $langs->load("products"); $langs->load("margins"); -// Security check - -if ($user->rights->margins->read->all) { - $agentid = GETPOST('agentid', 'int'); -} else { - $agentid = $user->id; -} - $mesg = ''; // Load variable for pagination @@ -69,6 +61,23 @@ if (!empty($_POST['startdatemonth'])) if (!empty($_POST['enddatemonth'])) $enddate = dol_mktime(23, 59, 59, $_POST['enddatemonth'], $_POST['enddateday'], $_POST['enddateyear']); +// Security check +if ($user->rights->margins->read->all) { + $agentid = GETPOST('agentid', 'int'); +} else { + $agentid = $user->id; +} +$result=restrictedArea($user,'margins'); + + +/* + * Actions + */ + +// None + + + /* * View */ diff --git a/htdocs/margin/checkMargins.php b/htdocs/margin/checkMargins.php index c576b3ce4a6..ab6394eb74c 100644 --- a/htdocs/margin/checkMargins.php +++ b/htdocs/margin/checkMargins.php @@ -34,72 +34,35 @@ $langs->load("bills"); $langs->load("products"); $langs->load("margins"); -// Security check - -if ($user->rights->margins->creer) { - $agentid = $user->id; -} else { - accessforbidden(); -} - -$sortfield = GETPOST("sortfield", 'alpha'); -$sortorder = GETPOST("sortorder", 'alpha'); -if (! $sortorder) - $sortorder = "DESC"; -if (! $sortfield) { - $sortfield = 'f.facnumber'; -} -$page = GETPOST("page", 'int'); -if ($page == - 1) { - $page = 0; -} -$offset = $conf->liste_limit * $page; +// Load variable for pagination +$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit; +$sortfield = GETPOST('sortfield','alpha'); +$sortorder = GETPOST('sortorder','alpha'); +$page = GETPOST('page','int'); +if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 +$offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; - -// Both test are required to be compatible with all browsers -if (GETPOST("button_search_x") || GETPOST("button_search")) { - $action = 'search'; -} elseif (GETPOST("button_updatemagins_x") || GETPOST("button_updatemagins")) { - $action = 'update'; -} - -if ($action == 'update') { - $datapost = $_POST; - - foreach ( $datapost as $key => $value ) { - if (strpos($key, 'buyingprice_') !== false) { - $tmp_array = explode('_', $key); - if (count($tmp_array) > 0) { - $invoicedet_id = $tmp_array[1]; - if (! empty($invoicedet_id)) { - $sql = 'UPDATE ' . MAIN_DB_PREFIX . 'facturedet'; - $sql .= ' SET buy_price_ht=\'' . price2num($value) . '\''; - $sql .= ' WHERE rowid=' . $invoicedet_id; - $result = $db->query($sql); - if (!$result) { - setEventMessages($db->lasterror, null, 'errors'); - } - } - } - } - } -} +if (! $sortorder) $sortorder = "DESC"; +if (! $sortfield) $sortfield = 'f.facnumber'; $startdate = $enddate = ''; $startdate = dol_mktime(0, 0, 0, GETPOST('startdatemonth', 'int'), GETPOST('startdateday', 'int'), GETPOST('startdateyear', 'int')); $enddate = dol_mktime(23, 59, 59, GETPOST('enddatemonth', 'int'), GETPOST('enddateday', 'int'), GETPOST('enddateyear', 'int')); -if (! empty($startdate)) { - $options .= '&startdatemonth=' . GETPOST('startdatemonth', 'int') . '&startdateday=' . GETPOST('startdateday', 'int') . '&startdateyear=' . GETPOST('startdateyear', 'int'); -} -if (! empty($enddate)) { - $options .= '&enddatemonth=' . GETPOST('enddatemonth', 'int') . '&enddateday=' . GETPOST('enddateday', 'int') . '&enddateyear=' . GETPOST('enddateyear', 'int'); -} - $search_ref = GETPOST('search_ref','alpha'); +// Security check +$result=restrictedArea($user,'margins'); + +// Both test are required to be compatible with all browsers +if (GETPOST("button_search_x") || GETPOST("button_search")) { + $action = 'search'; +} elseif (GETPOST("button_updatemagins_x") || GETPOST("button_updatemagins")) { + $action = 'update'; +} + /* * Actions @@ -117,6 +80,28 @@ if (empty($reshook)) // Selection of new fields include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; + if ($action == 'update') { + $datapost = $_POST; + + foreach ( $datapost as $key => $value ) { + if (strpos($key, 'buyingprice_') !== false) { + $tmp_array = explode('_', $key); + if (count($tmp_array) > 0) { + $invoicedet_id = $tmp_array[1]; + if (! empty($invoicedet_id)) { + $sql = 'UPDATE ' . MAIN_DB_PREFIX . 'facturedet'; + $sql .= ' SET buy_price_ht=\'' . price2num($value) . '\''; + $sql .= ' WHERE rowid=' . $invoicedet_id; + $result = $db->query($sql); + if (!$result) { + setEventMessages($db->lasterror, null, 'errors'); + } + } + } + } + } + } + // Purge search criteria if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // All tests are required to be compatible with all browsers { @@ -155,6 +140,17 @@ llxHeader('', $title); // print_fiche_titre($text); +$param=''; +if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage; +if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit; +if (! empty($startdate)) { + $param .= '&startdatemonth=' . GETPOST('startdatemonth', 'int') . '&startdateday=' . GETPOST('startdateday', 'int') . '&startdateyear=' . GETPOST('startdateyear', 'int'); +} +if (! empty($enddate)) { + $param .= '&enddatemonth=' . GETPOST('enddatemonth', 'int') . '&enddateday=' . GETPOST('enddateday', 'int') . '&enddateyear=' . GETPOST('enddateyear', 'int'); +} +if ($optioncss != '') $param.='&optioncss='.$optioncss; + // Show tabs $head = marges_prepare_head($user); $picto = 'margin'; @@ -202,7 +198,7 @@ $sql .= $db->order($sortfield, $sortorder); $nbtotalofrecords = ''; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { - + dol_syslog(__FILE__, LOG_DEBUG); $result = $db->query($sql); if ($result) { @@ -212,31 +208,30 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { } } -$sql .= $db->plimit($conf->liste_limit + 1, $offset); +$sql .= $db->plimit($limit+1, $offset); -dol_syslog(__FILE__, LOG_DEBUG); $result = $db->query($sql); if ($result) { $num = $db->num_rows($result); - + print '
'; - print_barre_liste($langs->trans("MarginDetails"), $page, $_SERVER["PHP_SELF"], "", $sortfield, $sortorder, '', $num, $nbtotalofrecords, ''); - + print_barre_liste($langs->trans("MarginDetails"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, '', 0, '', '', $limit); + if ($conf->global->MARGIN_TYPE == "1") $labelcostprice=$langs->trans('BuyingPrice'); else // value is 'costprice' or 'pmp' $labelcostprice=$langs->trans('CostPrice'); - + $moreforfilter=''; - + $varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage; //$selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields //if ($massactionbutton) $selectedfields.=$form->showCheckAddButtons('checkforselect', 1); $selectedfields=''; - + print '
'; print '
'."\n"; - + print ''; print ''; print ''; @@ -249,66 +244,66 @@ if ($result) { print $searchpitco; print ''; print "\n"; - + print ''; - print_liste_field_titre($langs->trans("Ref"), $_SERVER["PHP_SELF"], "f.facnumber", "", $options, '', $sortfield, $sortorder); - print_liste_field_titre($langs->trans("Description"), $_SERVER["PHP_SELF"], "", "", $options, 'width=20%', $sortfield, $sortorder); - print_liste_field_titre($langs->trans("UnitPriceHT"), $_SERVER["PHP_SELF"], "d.subprice", "", $options, 'align="right"', $sortfield, $sortorder); - print_liste_field_titre($labelcostprice, $_SERVER["PHP_SELF"], "d.buy_price_ht", "", $options, 'align="right"', $sortfield, $sortorder); - print_liste_field_titre($langs->trans("Qty"), $_SERVER["PHP_SELF"], "d.qty", "", $options, 'align="right"', $sortfield, $sortorder); - print_liste_field_titre($langs->trans("AmountTTC"), $_SERVER["PHP_SELF"], "d.total_ht", "", $options, 'align="right"', $sortfield, $sortorder); - print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"],"",'','','align="center"',$sortfield,$sortorder,'maxwidthsearch '); + print_liste_field_titre($langs->trans("Ref"), $_SERVER["PHP_SELF"], "f.facnumber", "", $param, '', $sortfield, $sortorder); + print_liste_field_titre($langs->trans("Description"), $_SERVER["PHP_SELF"], "", "", $param, 'width=20%', $sortfield, $sortorder); + print_liste_field_titre($langs->trans("UnitPriceHT"), $_SERVER["PHP_SELF"], "d.subprice", "", $param, 'align="right"', $sortfield, $sortorder); + print_liste_field_titre($labelcostprice, $_SERVER["PHP_SELF"], "d.buy_price_ht", "", $param, 'align="right"', $sortfield, $sortorder); + print_liste_field_titre($langs->trans("Qty"), $_SERVER["PHP_SELF"], "d.qty", "", $param, 'align="right"', $sortfield, $sortorder); + print_liste_field_titre($langs->trans("AmountTTC"), $_SERVER["PHP_SELF"], "d.total_ht", "", $param, 'align="right"', $sortfield, $sortorder); + print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"],"",'',$param,'align="center"',$sortfield,$sortorder,'maxwidthsearch '); print "\n"; - - if ($num > 0) { - while ($objp = $db->fetch_object($result)) - { - $var = ! $var; - - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - - print "\n"; - - $i ++; + + $i=0; + while ($i < min($num, $limit)) + { + $objp = $db->fetch_object($result); + + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + + print "\n"; + + $i ++; } + print "
'; - $result_inner = $invoicestatic->fetch($objp->invoiceid); - if ($result_inner < 0) { - setEventMessages($invoicestatic->error, null, 'errors'); - } else { - print $invoicestatic->getNomUrl(1); - } - print ''; - if (! empty($objp->fk_product)) { - $result_inner = $productstatic->fetch($objp->fk_product); - if ($result_inner < 0) { - setEventMessages($productstatic->error, null, 'errors'); - } else { - print $productstatic->getNomUrl(1); - } - } else { - print $objp->label; - print ' '; - print $objp->description; - } - print ''; - print price($objp->subprice); - print ''; - print ''; - print ''; - print $objp->qty; - print ''; - print price($objp->total_ht); - print '
'; + $result_inner = $invoicestatic->fetch($objp->invoiceid); + if ($result_inner < 0) { + setEventMessages($invoicestatic->error, null, 'errors'); + } else { + print $invoicestatic->getNomUrl(1); } + print ''; + if (! empty($objp->fk_product)) { + $result_inner = $productstatic->fetch($objp->fk_product); + if ($result_inner < 0) { + setEventMessages($productstatic->error, null, 'errors'); + } else { + print $productstatic->getNomUrl(1); + } + } else { + print $objp->label; + print ' '; + print $objp->description; + } + print ''; + print price($objp->subprice); + print ''; + print ''; + print ''; + print $objp->qty; + print ''; + print price($objp->total_ht); + print '
"; - + print "
"; } else { dol_print_error($db); diff --git a/htdocs/margin/customerMargins.php b/htdocs/margin/customerMargins.php index ed76cde223c..643fdcb4704 100644 --- a/htdocs/margin/customerMargins.php +++ b/htdocs/margin/customerMargins.php @@ -37,6 +37,7 @@ $langs->load("margins"); $socid = GETPOST('socid','int'); if (! empty($user->societe_id)) $socid=$user->societe_id; $result = restrictedArea($user, 'societe','',''); +$result = restrictedArea($user,'margins'); $mesg = ''; diff --git a/htdocs/margin/productMargins.php b/htdocs/margin/productMargins.php index 43a9ef0f22e..77f7e23c84f 100644 --- a/htdocs/margin/productMargins.php +++ b/htdocs/margin/productMargins.php @@ -43,6 +43,7 @@ $fieldvalue = (! empty($id) ? $id : (! empty($ref) ? $ref : '')); $fieldtype = (! empty($ref) ? 'ref' : 'rowid'); if (! empty($user->societe_id)) $socid=$user->societe_id; $result=restrictedArea($user,'produit|service',$fieldvalue,'product&product','','',$fieldtype); +$result=restrictedArea($user,'margins'); $mesg = ''; diff --git a/htdocs/theme/eldy/style.css.php b/htdocs/theme/eldy/style.css.php index c3bfa8b05cb..3f05f66c82b 100644 --- a/htdocs/theme/eldy/style.css.php +++ b/htdocs/theme/eldy/style.css.php @@ -4043,12 +4043,15 @@ a span.select2-chosen .css-searchselectcombo ul.select2-results { max-height: none; } -.select2-container-multi.select2-container-disabled .select2-choices { +.select2-container.select2-container-disabled .select2-choice, .select2-container-multi.select2-container-disabled .select2-choices { background-color: #FFFFFF; background-image: none; border: none; cursor: default; } +.select2-container-disabled .select2-choice .select2-arrow b { + opacity: 0.5; +} .select2-container-multi .select2-choices .select2-search-choice { margin-bottom: 3px; } diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php index e96fa032538..802eb46f6af 100644 --- a/htdocs/theme/md/style.css.php +++ b/htdocs/theme/md/style.css.php @@ -4128,12 +4128,15 @@ a span.select2-chosen .css-searchselectcombo ul.select2-results { max-height: none; } -.select2-container-multi.select2-container-disabled .select2-choices { +.select2-container.select2-container-disabled .select2-choice, .select2-container-multi.select2-container-disabled .select2-choices { background-color: #FFFFFF; background-image: none; border: none; cursor: default; } +.select2-container-disabled .select2-choice .select2-arrow b { + opacity: 0.5; +} .select2-container-multi .select2-choices .select2-search-choice { margin-bottom: 3px; } From 4102403482156add2e1342d7d8b02f8604678b6e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 21 Jun 2017 11:37:34 +0200 Subject: [PATCH 123/227] Look and feel v6 --- htdocs/categories/card.php | 11 +++++------ htdocs/comm/propal/card.php | 2 +- htdocs/commande/card.php | 2 +- htdocs/core/class/html.form.class.php | 4 ++-- htdocs/core/lib/ajax.lib.php | 20 ++++++++++---------- htdocs/core/lib/functions.lib.php | 4 ++-- htdocs/fichinter/card.php | 2 +- htdocs/fourn/commande/card.php | 2 +- htdocs/fourn/facture/card.php | 2 +- htdocs/product/card.php | 4 +++- htdocs/product/stock/card.php | 4 +++- htdocs/societe/ajax/company.php | 5 +++-- htdocs/supplier_proposal/card.php | 2 +- htdocs/theme/eldy/style.css.php | 2 +- 14 files changed, 35 insertions(+), 31 deletions(-) diff --git a/htdocs/categories/card.php b/htdocs/categories/card.php index 55bf400ea3a..9f49e42f060 100644 --- a/htdocs/categories/card.php +++ b/htdocs/categories/card.php @@ -1,6 +1,6 @@ - * Copyright (C) 2006-2015 Laurent Destailleur + * Copyright (C) 2006-2017 Laurent Destailleur * Copyright (C) 2005-2014 Regis Houssin * Copyright (C) 2007 Patrick Raguin * Copyright (C) 2013 Florian Henry @@ -221,9 +221,7 @@ llxHeader("",$langs->trans("Categories"),$helpurl); if ($user->rights->categorie->creer) { - /* - * Fiche en mode creation - */ + // Create or add if ($action == 'create' || $_POST["addcat"] == 'addcat') { dol_set_focus('#label'); @@ -246,7 +244,7 @@ if ($user->rights->categorie->creer) // Ref print ''; - print ''.$langs->trans("Ref").''; + print ''.$langs->trans("Ref").''; print''; // Description @@ -263,7 +261,8 @@ if ($user->rights->categorie->creer) // Parent category print ''.$langs->trans("AddIn").''; - print $form->select_all_categories($type, $catorigin); + print $form->select_all_categories($type, $catorigin, 'parent'); + print ajax_combobox('parent'); print ''; $parameters=array(); diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php index 67dbca101f8..0c9d97fc299 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -1360,7 +1360,7 @@ if ($action == 'create') } } else { print ''; - print $form->select_company('', 'socid', '(s.client = 1 OR s.client = 2 OR s.client = 3) AND status=1', 'SelectThirdParty'); + print $form->select_company('', 'socid', '(s.client = 1 OR s.client = 2 OR s.client = 3) AND status=1', 'SelectThirdParty', 0, 0, null, 0, 'minwidth300'); // reload page to retrieve customer informations if (!empty($conf->global->RELOAD_PAGE_ON_CUSTOMER_CHANGE)) { diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index f837119730c..a10de641ea1 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -1477,7 +1477,7 @@ if ($action == 'create' && $user->rights->commande->creer) print ''; } else { print ''; - print $form->select_company('', 'socid', 's.client = 1 OR s.client = 3', 'SelectThirdParty'); + print $form->select_company('', 'socid', 's.client = 1 OR s.client = 3', 'SelectThirdParty', 0, 0, null, 0, 'minwidth300'); // reload page to retrieve customer informations if (!empty($conf->global->RELOAD_PAGE_ON_CUSTOMER_CHANGE)) { diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 7c8efcc8328..1a19d0da776 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -995,7 +995,7 @@ class Form unset($societetmp); } // mode 1 - $urloption='htmlname='.$htmlname.'&outjson=1&filter='.$filter; + $urloption='htmlname='.$htmlname.'&outjson=1&filter='.$filter.($showtype?'&showtype='.$showtype:''); $out.= ajax_autocompleter($selected, $htmlname, DOL_URL_ROOT.'/societe/ajax/company.php', $urloption, $conf->global->COMPANY_USE_SEARCH_TO_SELECT, 0, $ajaxoptions); $out.=''."\n";*/ $contentforedit .= $objectpage->content; - + require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; $doleditor=new DolEditor('PAGE_CONTENT',$contentforedit,'',500,'Full','',true,true,true,ROWS_5,'90%'); $doleditor->Create(0, '', false); @@ -1056,23 +1071,23 @@ if ($action == 'preview') $objectpage->fetch($pageid); $out = "\n".''."\n"; - + $out.='
'."\n"; - + $csscontent = @file_get_contents($filecss); - + $out.=''."\n"; - + $out.=$objectpage->content."\n"; - + $out.='
'; - + $out.= "\n".''."\n\n"; - + print $out; - + /*file_put_contents($filetpl, $out); if (! empty($conf->global->MAIN_UMASK)) @chmod($filetpl, octdec($conf->global->MAIN_UMASK)); @@ -1080,17 +1095,17 @@ if ($action == 'preview') // Output file on browser dol_syslog("index.php include $filetpl $filename content-type=$type"); $original_file_osencoded=dol_osencode($filetpl); // New file name encoded in OS encoding charset - + // This test if file exists should be useless. We keep it to find bug more easily if (! file_exists($original_file_osencoded)) { dol_print_error(0,$langs->trans("ErrorFileDoesNotExists",$original_file)); exit; } - + //include_once $original_file_osencoded; */ - + /*print '';*/ } From efecb32ec98459e1810f61772bc72c8578841a59 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 3 Jul 2017 00:11:22 +0200 Subject: [PATCH 215/227] Fix migration --- htdocs/install/mysql/migration/5.0.0-6.0.0.sql | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/htdocs/install/mysql/migration/5.0.0-6.0.0.sql b/htdocs/install/mysql/migration/5.0.0-6.0.0.sql index 5d1948f318f..0b41cf739ef 100644 --- a/htdocs/install/mysql/migration/5.0.0-6.0.0.sql +++ b/htdocs/install/mysql/migration/5.0.0-6.0.0.sql @@ -25,7 +25,22 @@ -- -- VMYSQL4.1 DELETE FROM llx_usergroup_user WHERE fk_usergroup NOT IN (SELECT rowid from llx_usergroup); +ALTER TABLE llx_supplier_proposaldet CHANGE COLUMN fk_askpricesupplier fk_supplier_proposal integer NOT NULL; + +-- VMYSQL4.1 SET sql_mode = 'ALLOW_INVALID_DATES'; +-- VMYSQL4.1 update llx_adherent set datefin = NULL where DATE(STR_TO_DATE(datefin, '%Y-%m-%d')) IS NULL; +-- VMYSQL4.1 SET sql_mode = 'NO_ZERO_DATE'; +-- VMYSQL4.1 update llx_adherent set datefin = NULL where DATE(STR_TO_DATE(datefin, '%Y-%m-%d')) IS NULL; + -- VMYSQL4.1 ALTER TABLE llx_opensurvey_sondage MODIFY COLUMN tms timestamp DEFAULT '2001-01-01 00:00:00'; +-- VMYSQL4.1 ALTER TABLE llx_adherent MODIFY COLUMN datefin datetime NULL; + +-- To remove a default value for date that is not valid when field is not null +-- VMYSQL4.1 ALTER TABLE llx_chargesociales MODIFY COLUMN date_ech datetime DEFAULT NULL; +-- VMYSQL4.1 ALTER TABLE llx_chargesociales MODIFY COLUMN date_ech datetime NOT NULL; + + + -- Clean corrupted values for tms -- VMYSQL4.1 SET sql_mode = 'ALLOW_INVALID_DATES'; From aa1351d48393915c0c5fb992b374e9962151e988 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 3 Jul 2017 01:10:09 +0200 Subject: [PATCH 216/227] Fix to be sure database is not created using utf8mb4 (not yet supported) --- htdocs/core/db/mysqli.class.php | 10 ++++++++-- htdocs/install/mysql/migration/repair.sql | 11 ++++++++--- .../mysql/tables/llx_product_attribute.key.sql | 3 ++- htdocs/install/step1.php | 15 +++++++++++++-- 4 files changed, 31 insertions(+), 8 deletions(-) diff --git a/htdocs/core/db/mysqli.class.php b/htdocs/core/db/mysqli.class.php index 24ed1425f6b..526d43de0ab 100644 --- a/htdocs/core/db/mysqli.class.php +++ b/htdocs/core/db/mysqli.class.php @@ -857,6 +857,7 @@ class DoliDBMysqli extends DoliDB * Return charset used to store data in current database (same result than using SELECT default_character_set_name FROM information_schema.SCHEMATA WHERE schema_name = "databasename";) * * @return string Charset + * @see getDefaultCollationDatabase */ function getDefaultCharacterSetDatabase() { @@ -867,7 +868,9 @@ class DoliDBMysqli extends DoliDB return $this->forcecharset; } $liste=$this->fetch_array($resql); - return $liste['Value']; + $tmpval = $liste['Value']; + + return $tmpval; } /** @@ -900,6 +903,7 @@ class DoliDBMysqli extends DoliDB * Return collation used in current database * * @return string Collation value + * @see getDefaultCharacterSetDatabase */ function getDefaultCollationDatabase() { @@ -910,7 +914,9 @@ class DoliDBMysqli extends DoliDB return $this->forcecollate; } $liste=$this->fetch_array($resql); - return $liste['Value']; + $tmpval = $liste['Value']; + + return $tmpval; } /** diff --git a/htdocs/install/mysql/migration/repair.sql b/htdocs/install/mysql/migration/repair.sql index f9ec23d4f69..95840f73cb8 100755 --- a/htdocs/install/mysql/migration/repair.sql +++ b/htdocs/install/mysql/migration/repair.sql @@ -13,12 +13,17 @@ -- flush privileges; --- Requests to change character set and collation of a varchar column. --- utf8 and utf8_unicode_ci is recommended (or even better utf8mb4 and utf8mb4_unicode_ci with mysql 5.5.3+) +-- Request to change default pagecode + colation of database +-- ALTER DATABASE name_of_database CHARACTER SET utf8 COLLATE utf8_unicode_ci; +-- Request to change default pagecode + colation of table +-- ALTER TABLE name_of_table CONVERT TO CHARACTER SET utf8 COLLATE utf8_unicode_ci; + +-- Request to change character set and collation of a varchar column. +-- utf8 and utf8_unicode_ci is recommended (or even better utf8mb4 and utf8mb4_unicode_ci with mysql 5.5.3+) -- ALTER TABLE llx_accounting_account MODIFY account_number VARCHAR(20) CHARACTER SET utf8; -- ALTER TABLE llx_accounting_account MODIFY account_number VARCHAR(20) COLLATE utf8_unicode_ci; --- You can check with 'show full columns from llx_accounting_account'; +-- You can check with 'show full columns from mytablename'; diff --git a/htdocs/install/mysql/tables/llx_product_attribute.key.sql b/htdocs/install/mysql/tables/llx_product_attribute.key.sql index 28d687dbdda..f107a855e61 100644 --- a/htdocs/install/mysql/tables/llx_product_attribute.key.sql +++ b/htdocs/install/mysql/tables/llx_product_attribute.key.sql @@ -16,4 +16,5 @@ -- -- ============================================================================ -ALTER TABLE llx_product_attribute ADD CONSTRAINT unique_ref UNIQUE (ref); \ No newline at end of file +ALTER TABLE llx_product_attribute ADD UNIQUE INDEX uk_product_attribute_ref (ref); + diff --git a/htdocs/install/step1.php b/htdocs/install/step1.php index 9ad30fe5d7b..a0fdc22a015 100644 --- a/htdocs/install/step1.php +++ b/htdocs/install/step1.php @@ -312,8 +312,11 @@ if (! $error && $db->connected) // Define $defaultCharacterSet and $defaultDBSortingCollation if (! $error && $db->connected) { - if (!empty($db_create_database)) { // If we create database, we force default value - $defaultCharacterSet=$db->forcecharset; + if (!empty($db_create_database)) // If we create database, we force default value + { + // Default values come from the database handler + + $defaultCharacterSet=$db->forcecharset; $defaultDBSortingCollation=$db->forcecollate; } else // If already created, we take current value @@ -322,6 +325,14 @@ if (! $error && $db->connected) $defaultDBSortingCollation=$db->getDefaultCollationDatabase(); } + // Force to avoid utf8mb4 because index on field char 255 reach limit of 767 char for indexes (example with mysql 5.6.34 = mariadb 10.0.29) + // TODO Remove this when utf8mb4 is supported + if ($defaultCharacterSet == 'utf8mb4' || $defaultDBSortingCollation == 'utf8mb4_unicode_ci') + { + $defaultCharacterSet = 'utf8'; + $defaultDBSortingCollation = 'utf8_unicode_ci'; + } + print ''; print ''; $db_character_set=$defaultCharacterSet; From d57fe35efc0327ff4b7b191e40a508b2cd1a65f3 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 3 Jul 2017 01:36:04 +0200 Subject: [PATCH 217/227] Add option to fix corrupted database with bad pagecode --- htdocs/install/repair.php | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/htdocs/install/repair.php b/htdocs/install/repair.php index 895d36d72f1..3cfbbda5d26 100644 --- a/htdocs/install/repair.php +++ b/htdocs/install/repair.php @@ -78,6 +78,7 @@ print 'Option clean_product_stock_batch (0 or \'test\' or \'confirmed\') is '.(G print 'Option set_empty_time_spent_amount (0 or \'test\' or \'confirmed\') is '.(GETPOST('set_empty_time_spent_amount','alpha')?GETPOST('set_empty_time_spent_amount','alpha'):'0').'
'."\n"; print 'Option rebuild_product_thumbs (0 or \'test\' or \'confirmed\') is '.(GETPOST('rebuild_product_thumbs','alpha')?GETPOST('rebuild_product_thumbs','alpha'):'0').'
'."\n"; print 'Option force_disable_of_modules_not_found (0 or \'test\' or \'confirmed\') is '.(GETPOST('force_disable_of_modules_not_found','alpha')?GETPOST('force_disable_of_modules_not_found','alpha'):'0').'
'."\n"; +print 'Option force_utf8_on_tables, for mysql/mariadb only(0 or \'test\' or \'confirmed\') is '.(GETPOST('force_utf8_on_tables','alpha')?GETPOST('force_utf8_on_tables','alpha'):'0').'
'."\n"; print '
'; print ''; @@ -890,6 +891,35 @@ if ($ok && GETPOST('force_disable_of_modules_not_found','alpha')) +// clean_old_module_entries: Clean data into const when files of module were removed without being +// clean_linked_elements: Check and clean linked elements +if ($ok && GETPOST('force_utf8_on_tables','alpha')) +{ + print ''; + + if ($db->type == "mysql") + { + $listoftables = $db->DDLListTables($db->database_name); + + foreach($listoftables as $table) + { + print ''; + } + } + else + { + print ''; + } +} + + print '

*** Force page code and collation with utf8 (for mysql/mariadb only)
'; + print $table; + $sql='ALTER TABLE '.$table.' CONVERT TO CHARACTER SET utf8 COLLATE utf8_unicode_ci'; + if (GETPOST('force_utf8_on_tables','alpha') == 'confirmed') + { + $db->query($sql); + } + print '
Not available with database type '.$db->type.'
'; From 8a96260892ae9b4f76026e8c065291c6ced85901 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 3 Jul 2017 01:57:28 +0200 Subject: [PATCH 218/227] Fix amount not filled into email confirmation --- htdocs/public/stripe/newpayment.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/public/stripe/newpayment.php b/htdocs/public/stripe/newpayment.php index af0c880d3c8..962185b8397 100644 --- a/htdocs/public/stripe/newpayment.php +++ b/htdocs/public/stripe/newpayment.php @@ -297,7 +297,7 @@ if ($action == 'charge') } $_SESSION["onlinetoken"] = $stripeToken; - $_SESSION["FinalPaymentAmt"] = $amount; + $_SESSION["Payment_Amount"] = $amount; $_SESSION["currencyCodeType"] = $currency; $_SESSION["paymentType"] = ''; $_SESSION['ipaddress'] = $_SERVER['REMOTE_ADDR']; // Payer ip From db1d97c9ac8e8d3f39e7c63876dfc6779b335a5c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 3 Jul 2017 02:09:14 +0200 Subject: [PATCH 219/227] Fix bad value for ref of old contracts --- htdocs/install/mysql/migration/5.0.0-6.0.0.sql | 2 ++ 1 file changed, 2 insertions(+) diff --git a/htdocs/install/mysql/migration/5.0.0-6.0.0.sql b/htdocs/install/mysql/migration/5.0.0-6.0.0.sql index 0b41cf739ef..f418a5e6a1f 100644 --- a/htdocs/install/mysql/migration/5.0.0-6.0.0.sql +++ b/htdocs/install/mysql/migration/5.0.0-6.0.0.sql @@ -346,6 +346,8 @@ ALTER TABLE llx_product_fournisseur_price_log ADD COLUMN multicurrency_tx d ALTER TABLE llx_product_fournisseur_price_log ADD COLUMN multicurrency_price double(24,8) DEFAULT NULL; ALTER TABLE llx_product_fournisseur_price_log ADD COLUMN multicurrency_price_ttc double(24,8) DEFAULT NULL; +UPDATE TABLE llx_contrat set ref = rowid where ref is null or ref = ''; + create table llx_payment_various ( rowid integer AUTO_INCREMENT PRIMARY KEY, From 9e26e6b0a3600b1172a01f31a0772e9f5b4bc7bf Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 3 Jul 2017 02:09:14 +0200 Subject: [PATCH 220/227] Fix bad value for ref of old contracts --- htdocs/admin/websites.php | 51 +++++++++++------- htdocs/core/lib/pdf.lib.php | 2 +- htdocs/core/lib/website.lib.php | 33 ++++++++---- htdocs/core/modules/modWebsites.class.php | 6 +-- .../install/mysql/migration/5.0.0-6.0.0.sql | 2 + htdocs/langs/en_US/website.lang | 3 +- htdocs/public/error-404.php | 2 +- htdocs/public/websites/index.php | 52 +++++++++++++++---- htdocs/public/websites/styles.css.php | 21 +++++--- htdocs/websites/index.php | 13 ++++- 10 files changed, 132 insertions(+), 53 deletions(-) diff --git a/htdocs/admin/websites.php b/htdocs/admin/websites.php index 4dbd154096f..0336a2533c0 100644 --- a/htdocs/admin/websites.php +++ b/htdocs/admin/websites.php @@ -25,8 +25,10 @@ require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formadmin.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; +require_once DOL_DOCUMENT_ROOT.'/websites/class/website.class.php'; $langs->load("errors"); $langs->load("admin"); @@ -35,7 +37,6 @@ $langs->load("website"); $action=GETPOST('action','alpha')?GETPOST('action','alpha'):'view'; $confirm=GETPOST('confirm','alpha'); -$id=GETPOST('id','int'); $rowid=GETPOST('rowid','alpha'); $id=1; @@ -135,7 +136,7 @@ if (GETPOST('actionadd') || GETPOST('actionmodify')) setEventMessages($langs->transnoentities("ErrorFieldRequired", $langs->transnoentities($fieldnamekey)), null, 'errors'); } } - + // Si verif ok et action add, on ajoute la ligne if ($ok && GETPOST('actionadd')) { @@ -185,7 +186,7 @@ if (GETPOST('actionadd') || GETPOST('actionmodify')) if ($result) // Add is ok { setEventMessages($langs->transnoentities("RecordSaved"), null, 'mesgs'); - $_POST=array('id'=>$id); // Clean $_POST array, we keep only + unset($_POST); // Clean $_POST array, we keep only } else { @@ -204,6 +205,10 @@ if (GETPOST('actionadd') || GETPOST('actionmodify')) if ($tabrowid[$id]) { $rowidcol=$tabrowid[$id]; } else { $rowidcol="rowid"; } + $website=new Website($db); + $rowid=GETPOST('rowid','int'); + $website->fetch($rowid); + // Modify entry $sql = "UPDATE ".$tabname[$id]." SET "; // Modifie valeur des champs @@ -229,7 +234,17 @@ if (GETPOST('actionadd') || GETPOST('actionmodify')) dol_syslog("actionmodify", LOG_DEBUG); //print $sql; $resql = $db->query($sql); - if (! $resql) + if ($resql) + { + $newname = dol_sanitizeFileName(GETPOST('ref','aZ09')); + if ($newname != $website->ref) + { + $srcfile=DOL_DATA_ROOT.'/websites/'.$website->ref; + $destfile=DOL_DATA_ROOT.'/websites/'.$newname; + @rename($srcfile, $destfile); + } + } + else { setEventMessages($db->error(), null, 'errors'); } @@ -249,7 +264,7 @@ if ($action == 'confirm_delete' && $confirm == 'yes') // delete $sql = "DELETE from ".MAIN_DB_PREFIX."website_pages WHERE fk_website ='".$rowid."'"; $result = $db->query($sql); - + $sql = "DELETE from ".MAIN_DB_PREFIX."website WHERE rowid ='".$rowid."'"; $result = $db->query($sql); if (! $result) @@ -321,7 +336,7 @@ print "
\n"; // Confirmation de la suppression de la ligne if ($action == 'delete') { - print $form->formconfirm($_SERVER["PHP_SELF"].'?'.($page?'page='.$page.'&':'').'sortfield='.$sortfield.'&sortorder='.$sortorder.'&rowid='.$rowid.'&id='.$id, $langs->trans('DeleteWebsite'), $langs->trans('ConfirmDeleteWebsite'), 'confirm_delete','',0,1); + print $form->formconfirm($_SERVER["PHP_SELF"].'?'.($page?'page='.$page.'&':'').'sortfield='.$sortfield.'&sortorder='.$sortorder.'&rowid='.$rowid, $langs->trans('DeleteWebsite'), $langs->trans('ConfirmDeleteWebsite'), 'confirm_delete','',0,1); } //var_dump($elementList); @@ -355,7 +370,7 @@ if ($id) $fieldlist=explode(',',$tabfield[$id]); - print '
'; + print ''; print ''; print ''; @@ -388,9 +403,7 @@ if ($id) if ($fieldlist[$field]=='libelle' || $fieldlist[$field]=='label') $alabelisused=1; } - if ($id == 4) print ''; print ''; print ''; @@ -444,19 +457,19 @@ if ($id) if ($num) { print '
'; - - print ''; + + print ''; print ''; print ''; print ''; - + print '
'; - print ''; print '
'; - + // There is several pages if ($num > $listlimit) { print ''; } @@ -486,11 +499,11 @@ if ($id) // Affiche nom du champ if ($showfield) { - print getTitleFieldOfList($valuetoshow,0,$_SERVER["PHP_SELF"],($sortable?$fieldlist[$field]:''),($page?'page='.$page.'&':'').'&id='.$id,"","align=".$align,$sortfield,$sortorder); + print getTitleFieldOfList($valuetoshow,0,$_SERVER["PHP_SELF"],($sortable?$fieldlist[$field]:''),($page?'page='.$page.'&':''),"","align=".$align,$sortfield,$sortorder); } } - print getTitleFieldOfList($langs->trans("Status"),0,$_SERVER["PHP_SELF"],"status",($page?'page='.$page.'&':'').'&id='.$id,"",'align="center"',$sortfield,$sortorder); + print getTitleFieldOfList($langs->trans("Status"),0,$_SERVER["PHP_SELF"],"status",($page?'page='.$page.'&':''),"",'align="center"',$sortfield,$sortorder); print getTitleFieldOfList(''); print getTitleFieldOfList(''); print ''; @@ -539,7 +552,7 @@ if ($id) // Can an entry be erased or disabled ? $iserasable=1;$isdisable=1; // true by default - $url = $_SERVER["PHP_SELF"].'?'.($page?'page='.$page.'&':'').'sortfield='.$sortfield.'&sortorder='.$sortorder.'&rowid='.(! empty($obj->rowid)?$obj->rowid:(! empty($obj->code)?$obj->code:'')).'&code='.(! empty($obj->code)?urlencode($obj->code):'').'&id='.$id.'&'; + $url = $_SERVER["PHP_SELF"].'?'.($page?'page='.$page.'&':'').'sortfield='.$sortfield.'&sortorder='.$sortorder.'&rowid='.(! empty($obj->rowid)?$obj->rowid:(! empty($obj->code)?$obj->code:'')).'&code='.(! empty($obj->code)?urlencode($obj->code):'').'&'; // Active print '
'; - print_fleche_navigation($page, $_SERVER["PHP_SELF"], '&id='.$id, ($num > $listlimit), ''); + print_fleche_navigation($page, $_SERVER["PHP_SELF"], '', ($num > $listlimit), ''); print '
'; @@ -558,9 +571,9 @@ if ($id) } $i++; } - + print '
'; - + print '
'; } } diff --git a/htdocs/core/lib/pdf.lib.php b/htdocs/core/lib/pdf.lib.php index dedb169dc38..614379a2900 100644 --- a/htdocs/core/lib/pdf.lib.php +++ b/htdocs/core/lib/pdf.lib.php @@ -865,7 +865,7 @@ function pdf_pagefoot(&$pdf,$outputlangs,$paramfreetext,$fromcompany,$marge_bass // Make a change into HTML code to allow to include images from medias directory. // // become - // + // $newfreetext=preg_replace('/()/', '\1'.DOL_DATA_ROOT.'/medias/\2\3', $newfreetext); $line.=$outputlangs->convToOutputCharset($newfreetext); diff --git a/htdocs/core/lib/website.lib.php b/htdocs/core/lib/website.lib.php index ebbd261984e..37f01a0ffe3 100644 --- a/htdocs/core/lib/website.lib.php +++ b/htdocs/core/lib/website.lib.php @@ -31,21 +31,36 @@ function dolWebsiteOutput($content) { global $db, $langs, $conf, $user; + global $dolibarr_main_url_root; dol_syslog("dolWebsiteOutput start"); - + if (! defined('USEDOLIBARRSERVER')) { - // Replace link of Dolibarr medias with direct link for virtual server - - - - - + // Define $urlwithroot + $urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT,'/').'$/i','',trim($dolibarr_main_url_root)); + $urlwithroot=$urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file + //$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current + + $symlinktomediaexists=1; + + // Make a change into HTML code to allow to include images from medias directory correct with direct link for virtual server + // + // become + // + $nbrep=0; + if (! $symlinktomediaexists) + { + $content=preg_replace('/()/', '\1'.$urlwithroot.'/viewimage.php\2modulepart=medias\3file=\4\5', $content, -1, $nbrep); + } + else + { + $content=preg_replace('/()/', '\1medias/\4\5', $content, -1, $nbrep); + } } - + dol_syslog("dolWebsiteOutput end"); - + print $content; } diff --git a/htdocs/core/modules/modWebsites.class.php b/htdocs/core/modules/modWebsites.class.php index 877c78b85eb..57abe371314 100644 --- a/htdocs/core/modules/modWebsites.class.php +++ b/htdocs/core/modules/modWebsites.class.php @@ -42,15 +42,15 @@ class modWebsites extends DolibarrModules $this->db = $db; $this->numero = 10000; - + // Family can be 'crm','financial','hr','projects','products','ecm','technic','other' // It is used to group modules in module setup page $this->family = "portal"; $this->module_position = 50; // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) $this->name = preg_replace('/^mod/i','',get_class($this)); - $this->description = "Enable the public website with CMS features"; - $this->version = 'development'; // 'experimental' or 'dolibarr' or version + $this->description = "Enable to build and serve public websites with CMS features"; + $this->version = 'experimental'; // 'experimental' or 'dolibarr' or version // Key used in llx_const table to save module status enabled/disabled (where MYMODULE is value of property name of module in uppercase) $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); // Where to store the module in setup page (0=common,1=interface,2=others,3=very specific) diff --git a/htdocs/install/mysql/migration/5.0.0-6.0.0.sql b/htdocs/install/mysql/migration/5.0.0-6.0.0.sql index 0b41cf739ef..f418a5e6a1f 100644 --- a/htdocs/install/mysql/migration/5.0.0-6.0.0.sql +++ b/htdocs/install/mysql/migration/5.0.0-6.0.0.sql @@ -346,6 +346,8 @@ ALTER TABLE llx_product_fournisseur_price_log ADD COLUMN multicurrency_tx d ALTER TABLE llx_product_fournisseur_price_log ADD COLUMN multicurrency_price double(24,8) DEFAULT NULL; ALTER TABLE llx_product_fournisseur_price_log ADD COLUMN multicurrency_price_ttc double(24,8) DEFAULT NULL; +UPDATE TABLE llx_contrat set ref = rowid where ref is null or ref = ''; + create table llx_payment_various ( rowid integer AUTO_INCREMENT PRIMARY KEY, diff --git a/htdocs/langs/en_US/website.lang b/htdocs/langs/en_US/website.lang index 4482093b26d..dd6332b11a7 100644 --- a/htdocs/langs/en_US/website.lang +++ b/htdocs/langs/en_US/website.lang @@ -14,8 +14,9 @@ EditPageContent=Edit Content Website=Web site Webpage=Web page AddPage=Add page +HomePage=Home Page PreviewOfSiteNotYetAvailable=Preview of your website %s not yet available. You must first add a page. -RequestedPageHasNoContentYet=Requested page with id %s has not content yet or cache file .tpl.php was removed. Edit content of page to solve this. +RequestedPageHasNoContentYet=Requested page with id %s has no content yet, or cache file .tpl.php was removed. Edit content of the page to solve this. PageDeleted=Page '%s' of website %s deleted PageAdded=Page '%s' added ViewSiteInNewTab=View site in new tab diff --git a/htdocs/public/error-404.php b/htdocs/public/error-404.php index 951f29b7dde..36547d26704 100644 --- a/htdocs/public/error-404.php +++ b/htdocs/public/error-404.php @@ -18,7 +18,7 @@

Error


- You requested a page that does not exists. + You requested a website or a page that does not exists.
diff --git a/htdocs/public/websites/index.php b/htdocs/public/websites/index.php index 4c2eec0edc5..0bc85dce463 100644 --- a/htdocs/public/websites/index.php +++ b/htdocs/public/websites/index.php @@ -67,23 +67,51 @@ if (empty($pageid)) { require_once DOL_DOCUMENT_ROOT.'/websites/class/website.class.php'; require_once DOL_DOCUMENT_ROOT.'/websites/class/websitepage.class.php'; - + $object=new Website($db); $object->fetch(0, $website); - - $objectpage=new WebsitePage($db); - $array=$objectpage->fetchAll($object->id); - - if (count($array) > 0) + if (empty($object->id)) { - $firstrep=reset($array); - $pageid=$firstrep->id; + if (empty($pageid)) + { + // Return header 404 + header($_SERVER["SERVER_PROTOCOL"]." 404 Not Found", true, 404); + + include DOL_DOCUMENT_ROOT.'/public/error-404.php'; + exit; + } + } + + $objectpage=new WebsitePage($db); + + if ($object->fk_default_home > 0) + { + $result=$objectpage->fetch($object->fk_default_home); + if ($result > 0) + { + $pageid = $objectpage->id; + } + } + + if (empty($pageid)) + { + $array=$objectpage->fetchAll($object->id); + if (is_array($array) && count($array) > 0) + { + $firstrep=reset($array); + $pageid=$firstrep->id; + } } } if (empty($pageid)) { + // Return header 404 + header($_SERVER["SERVER_PROTOCOL"]." 404 Not Found", true, 404); + $langs->load("website"); print $langs->trans("PreviewOfSiteNotYetAvailable"); + + include DOL_DOCUMENT_ROOT.'/public/error-404.php'; exit; } @@ -95,7 +123,7 @@ if ($pageid == 'css') // No more used ? header('Content-type: text/css'); // Important: Following code is to avoid page request by browser and PHP CPU at each Dolibarr page access. //if (empty($dolibarr_nocache)) header('Cache-Control: max-age=3600, public, must-revalidate'); - //else + //else header('Cache-Control: no-cache'); $original_file=$dolibarr_main_data_root.'/websites/'.$website.'/styles.css.php'; } @@ -136,9 +164,13 @@ $original_file_osencoded=dol_osencode($original_file); // New file name encoded // This test if file exists should be useless. We keep it to find bug more easily if (! file_exists($original_file_osencoded)) { + // Return header 404 + header($_SERVER["SERVER_PROTOCOL"]." 404 Not Found", true, 404); + $langs->load("website"); print $langs->trans("RequestedPageHasNoContentYet", $pageid); - //dol_print_error(0,$langs->trans("ErrorFileDoesNotExists",$original_file)); + + include DOL_DOCUMENT_ROOT.'/public/error-404.php'; exit; } diff --git a/htdocs/public/websites/styles.css.php b/htdocs/public/websites/styles.css.php index 5a736affc25..14014577cea 100644 --- a/htdocs/public/websites/styles.css.php +++ b/htdocs/public/websites/styles.css.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2016-2017 Laurent Destailleur * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -18,8 +18,7 @@ /** * \file htdocs/public/websites/styles.css.php * \ingroup website - * \brief Page to output style page - * \author Laurent Destailleur + * \brief Page to output style page. Called with */ define('NOTOKENRENEWAL',1); // Disables token renewal @@ -48,6 +47,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; $error=0; $website=GETPOST('website', 'alpha'); +$websiteid=GETPOST('websiteid', 'int'); $pageid=GETPOST('page', 'alpha')?GETPOST('page', 'alpha'):GETPOST('pageid', 'alpha'); $accessallowed = 1; @@ -67,13 +67,20 @@ if (empty($pageid)) { require_once DOL_DOCUMENT_ROOT.'/websites/class/website.class.php'; require_once DOL_DOCUMENT_ROOT.'/websites/class/websitepage.class.php'; - + $object=new Website($db); - $object->fetch(0, $website); - + if ($websiteid) + { + $object->fetch($websiteid); + $website=$object->ref; + } + else + { + $object->fetch(0, $website); + } $objectpage=new WebsitePage($db); $array=$objectpage->fetchAll($object->id); - + if (count($array) > 0) { $firstrep=reset($array); diff --git a/htdocs/websites/index.php b/htdocs/websites/index.php index 183fa45298a..1a11ea2a4e1 100644 --- a/htdocs/websites/index.php +++ b/htdocs/websites/index.php @@ -414,7 +414,7 @@ if ($action == 'updatemeta') $tplcontent.= ''."\n"; $tplcontent.= ''."\n"; $tplcontent.= ''."\n"; - $tplcontent.= ''."\n"; + $tplcontent.= ''."\n"; $tplcontent.= ''.dol_escape_htmltag($objectpage->title).''."\n"; $tplcontent.= ''."\n"; @@ -452,6 +452,15 @@ if ($action == 'updatecontent' || GETPOST('refreshsite') || GETPOST('refreshpage { $object->fetch(0, $website); + // Check symlink to medias and restore it if ko + $pathtomedias=DOL_DATA_ROOT.'/medias'; + $pathtomediasinwebsite=$pathofwebsite.'/medias'; + if (! is_link(dol_osencode($pathtomediasinwebsite))) + { + dol_syslog("Create symlink for ".$pathtomedias." into name ".$pathtomediasinwebsite); + symlink($pathtomedias, $pathtomediasinwebsite); + } + /*if (GETPOST('savevirtualhost') && $object->virtualhost != GETPOST('previewsite')) { $object->virtualhost = GETPOST('previewsite', 'alpha'); @@ -558,7 +567,7 @@ if ($action == 'updatecontent' || GETPOST('refreshsite') || GETPOST('refreshpage $tplcontent.= ''."\n"; $tplcontent.= ''."\n"; $tplcontent.= ''."\n"; - $tplcontent.= ''."\n"; + $tplcontent.= ''."\n"; $tplcontent.= ''.dol_escape_htmltag($objectpage->title).''."\n"; $tplcontent.= ''."\n"; From 8b91f4fb5ee537980ced85843a983ec98ccb4a9a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 3 Jul 2017 12:04:45 +0200 Subject: [PATCH 221/227] Debug module website --- htdocs/collab/index.php | 62 ++++++++++++++++----------------- htdocs/langs/en_US/website.lang | 3 +- htdocs/websites/index.php | 6 ++-- 3 files changed, 36 insertions(+), 35 deletions(-) diff --git a/htdocs/collab/index.php b/htdocs/collab/index.php index ea7abde4151..7f08beff955 100644 --- a/htdocs/collab/index.php +++ b/htdocs/collab/index.php @@ -49,7 +49,7 @@ function llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, top_htmlhead($head, $title, $disablejs, $disablehead, $arrayofjs, $arrayofcss); print ''; - + // top menu and left menu area if (empty($conf->dol_hide_topmenu)) { @@ -108,7 +108,7 @@ if (empty($action)) $action='preview'; */ if (GETPOST('refreshsite')) $pageid=0; // If we change the site, we reset the pageid. -if (GETPOST('refreshpage')) $action='preview'; +if (GETPOST('refreshpage')) $action='preview'; // Add a collab page @@ -146,7 +146,7 @@ if ($action == 'add') { $db->rollback(); } - + $action = 'preview'; $id = $objectpage->id; } @@ -173,7 +173,7 @@ if ($action == 'delete') { $db->commit(); setEventMessages($langs->trans("PageDeleted", $objectpage->pageurl, $website), null, 'mesgs'); - + header("Location: ".$_SERVER["PHP_SELF"].'?website='.$website); exit; } @@ -218,7 +218,7 @@ print '
'; if (count($object->records) > 0) { // ***** Part for web sites - + print '
'; print $langs->trans("Website").': '; print '
'; @@ -252,20 +252,20 @@ if (count($object->records) > 0) $dataroot=DOL_DATA_ROOT.'/websites/'.$website; if (! empty($object->virtualhost)) $virtualurl=$object->virtualhost; } - + if ($website && $action == 'preview') { $disabled=''; if (empty($user->rights->websites->write)) $disabled=' disabled="disabled"'; - + print '   '; - + //print ''; print ''; print ''; print ''; } - + print '
'; // Button for websites @@ -279,7 +279,7 @@ if (count($object->records) > 0) $htmltext=$langs->trans("SetHereVirtualHost", $dataroot); print $form->textwithpicto('', $htmltext); print '
'; - + $urlext=$virtualurl; $urlint=$urlwithroot.'/public/websites/index.php?website='.$website; //if (! empty($object->virtualhost)) @@ -288,7 +288,7 @@ if (count($object->records) > 0) print $form->textwithpicto('', $langs->trans("PreviewSiteServedByWebServer", $langs->transnoentitiesnoconv("Site"), $langs->transnoentitiesnoconv("Site"), $dataroot, $urlext?$urlext:$langs->trans("VirtualHostUrlNotDefined")), 1, 'preview_ext'); print ''; //} - + print 'transnoentitiesnoconv("Site"), $langs->transnoentitiesnoconv("Site"), $urlint)).'">'; print $form->textwithpicto('', $langs->trans("PreviewSiteServedByDolibarr", $langs->transnoentitiesnoconv("Site"), $langs->transnoentitiesnoconv("Site"), $urlint, $dataroot), 1, 'preview'); print ''; @@ -300,12 +300,12 @@ if (count($object->records) > 0) if (preg_match('/^create/',$action)) print ''; if (preg_match('/^edit/',$action)) print ''; } - + print ''; // ***** Part for pages - + if ($website) { print ''; @@ -313,13 +313,13 @@ if (count($object->records) > 0) $array=$objectpage->fetchAll($object->id); if (! is_array($array) && $array < 0) dol_print_error('', $objectpage->error, $objectpage->errors); $atleastonepage=(is_array($array) && count($array) > 0); - + print '
'; print '
'; print $langs->trans("Page").': '; print '
'; print '
'; - + if ($action != 'add') { $out=''; @@ -336,7 +336,7 @@ if (count($object->records) > 0) } $pageid=$homepageid?$homepageid:$firstpageid; // We choose home page and if not defined yet, we take first page } - + foreach($array as $key => $valpage) { $out.='
'; print '
'; print '
'; @@ -389,17 +389,17 @@ if (count($object->records) > 0) { $websitepage = new WebSitePage($db); $websitepage->fetch($pageid); - + $realpage=$urlwithroot.'/public/websites/index.php?website='.$website.'&page='.$pageid; $pagealias = $websitepage->pageurl; - + print '
'; print ''; //print ''; $htmltext=$langs->trans("WEBSITE_PAGENAME", $pagealias); print $form->textwithpicto('', $htmltext); print '
'; - + if (! empty($object->virtualhost)) { $urlext=$virtualurl.'/'.$pagealias.'.php'; @@ -413,12 +413,12 @@ if (count($object->records) > 0) print $form->textwithpicto('', $langs->trans("PreviewSiteServedByWebServer", $langs->transnoentitiesnoconv("Page"), $langs->transnoentitiesnoconv("Page"), $dataroot, $urlext?$urlext:$langs->trans("VirtualHostUrlNotDefined")), 1, 'preview_ext'); print ''; } - + print 'transnoentitiesnoconv("Page"), $langs->transnoentitiesnoconv("Page"), $realpage)).'">'; - print $form->textwithpicto('', $langs->trans("PreviewSiteServedByDolibarr", $langs->transnoentitiesnoconv("Page"), $langs->transnoentitiesnoconv("Page"), $realpage, $dataroot), 1, 'preview'); + print $form->textwithpicto('', $langs->trans("PreviewSiteServedByDolibarr", $langs->transnoentitiesnoconv("Page"), $langs->transnoentitiesnoconv("Page"), $realpage, $dataroot), 1, 'preview'); print ''; // View page in new Tab //print ''; - + // TODO Add js to save alias like we save virtual host name and use dynamic virtual host for url of id=previewpageext } if (! in_array($action, array('editcss','editmenu','create'))) @@ -427,7 +427,7 @@ if (count($object->records) > 0) if (preg_match('/^create/',$action)) print ''; if (preg_match('/^edit/',$action)) print ''; } - + print '
'; if ($action == 'preview') @@ -454,7 +454,7 @@ if (count($object->records) > 0) }, context: document.body }); - + jQuery("#previewsiteext").attr("href",newurl); jQuery("#previewpageext").attr("href",newpage); }); @@ -483,15 +483,15 @@ if ($action == 'editcontent') /* * Editing global variables not related to a specific theme */ - + $csscontent = @file_get_contents($filecss); - + $contentforedit = ''; /*$contentforedit.=''."\n";*/ $contentforedit .= $objectpage->content; - + require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; $doleditor=new DolEditor('PAGE_CONTENT',$contentforedit,'',500,'Full','',true,true,true,ROWS_5,'90%'); $doleditor->Create(0, '', false); diff --git a/htdocs/langs/en_US/website.lang b/htdocs/langs/en_US/website.lang index dd6332b11a7..abb7f7e56d3 100644 --- a/htdocs/langs/en_US/website.lang +++ b/htdocs/langs/en_US/website.lang @@ -6,6 +6,7 @@ ConfirmDeleteWebsite=Are you sure you want to delete this web site. All its page WEBSITE_PAGENAME=Page name/alias WEBSITE_CSS_URL=URL of external CSS file WEBSITE_CSS_INLINE=CSS content +PageNameAliasHelp=Name or alias of the page.
This alias is also used to forge a SEO URL when website is read from a Virtual host of a Web server (like Apacke, Nginx, ...). Use the button "%s" to edit this alias. MediaFiles=Media library EditCss=Edit Style/CSS EditMenu=Edit menu @@ -24,7 +25,7 @@ ViewPageInNewTab=View page in new tab SetAsHomePage=Set as Home page RealURL=Real URL ViewWebsiteInProduction=View web site using home URLs -SetHereVirtualHost=If you can set, on your web server, a dedicated virtual host with a root directory on %s, define here the virtual hostname so the preview can be done also using this direct web server access and not only using Dolibarr server. +SetHereVirtualHost=If you can create, on your web server (Apache, Nginx, ...), a dedicated Virtual Host with PHP enabled and a Root directory on %s
then enter here the virtual hostname you have created, so the preview can be done also using this direct web server access, and not only using Dolibarr server. PreviewSiteServedByWebServer=Preview %s in a new tab.

The %s will be served by an external web server (like Apache, Nginx, IIS). You must install and setup this server before to point to directory:
%s
URL served by external server:
%s PreviewSiteServedByDolibarr=Preview %s in a new tab.

The %s will be served by Dolibarr server so it does not need any extra web server (like Apache, Nginx, IIS) to be installed.
The inconvenient is that URL of pages are not user friendly and start with path of your Dolibarr.
URL served by Dolibarr:
%s

To use your own external web server to serve this web site, create a virtual host on your web server that point on directory
%s
then enter the name of this virtual server and click on the other preview button. NoPageYet=No pages yet \ No newline at end of file diff --git a/htdocs/websites/index.php b/htdocs/websites/index.php index 1a11ea2a4e1..a5c2ae4e046 100644 --- a/htdocs/websites/index.php +++ b/htdocs/websites/index.php @@ -727,7 +727,7 @@ if (count($object->records) > 0) print ''; //print ''; $htmltext=$langs->trans("SetHereVirtualHost", $dataroot); - print $form->textwithpicto('', $htmltext); + print $form->textwithpicto('', $htmltext, 1, 'help', '', 0, 2, 'helpvirtualhost'); print ''; $urlext=$virtualurl; @@ -846,8 +846,8 @@ if (count($object->records) > 0) print '
'; print ''; //print ''; - $htmltext=$langs->trans("WEBSITE_PAGENAME", $pagealias); - print $form->textwithpicto('', $htmltext); + $htmltext=$langs->trans("PageNameAliasHelp", $langs->transnoentitiesnoconv("EditPageMeta")); + print $form->textwithpicto('', $htmltext, 1, 'help', '', 0, 2, 'helppagealias'); print '
'; if (! empty($object->virtualhost)) From cb1c461b69440755cd5241c02807c14f1318ebb7 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 3 Jul 2017 12:28:52 +0200 Subject: [PATCH 222/227] Work on module builder --- htdocs/langs/en_US/modulebuilder.lang | 15 ++++++---- htdocs/modulebuilder/index.php | 43 ++++++++++++++++++++++++--- 2 files changed, 48 insertions(+), 10 deletions(-) diff --git a/htdocs/langs/en_US/modulebuilder.lang b/htdocs/langs/en_US/modulebuilder.lang index 1c3a7932263..9eb910da360 100644 --- a/htdocs/langs/en_US/modulebuilder.lang +++ b/htdocs/langs/en_US/modulebuilder.lang @@ -1,8 +1,8 @@ # Dolibarr language file - Source file is en_US - loan -ModuleBuilderDesc=This tools give you utilites to build or edit your own module (More information here). +ModuleBuilderDesc=This tools must be used by experienced users or developers. It gives you utilities to build or edit your own module (Documentation for alternative manual development is here). EnterNameOfModuleDesc=Enter name of the module/application to create with no spaces. Use uppercase to separate words (For example: MyModule, EcommerceForShop, SyncWithMySystem...) EnterNameOfObjectDesc=Enter name of the object to create with no spaces. Use uppercase to separate words (For example: MyObject, Student, Teacher...) -ModuleBuilderDesc2=Path were modules are generated/edited (first alternative directory defined into %s): %s +ModuleBuilderDesc2=Path where modules are generated/edited (first alternative directory defined into %s): %s ModuleBuilderDesc3=Generated/editable modules found: %s (they are detected as editable when the file %s exists in root of module directory). NewModule=New module NewObject=New object @@ -11,17 +11,19 @@ ObjectKey=Object key ModuleInitialized=Module initialized FilesForObjectInitialized=Files for new object initialized ModuleBuilderDescdescription=Enter here all general information that describe your module +ModuleBuilderDescspecifications=You can enter here a long text to describe the specifications of your module that is not already structured into other tabs. So you have on hand the rules to develop. Also this text content will be included into the generated documentation (see last tab). ModuleBuilderDescobjects=Define here the objects you want to manage with your module. A sql file, a page to list them, to create/edit/view a card and an API will be generated. ModuleBuilderDescmenus=This tab is dedicated to define menu entries provided by your module. ModuleBuilderDescpermissions=This tab is dedicated to define the new permissions you want to provide with your module. ModuleBuilderDesctriggers=This is the view of triggers provided by your module. To include code executed when a triggered business event is launched, just edit this file with your IDE. ModuleBuilderDeschooks=This tab is dedicated to hooks. ModuleBuilderDescwidgets=This tab is dedicated to manage/build widgets. -ModuleBuilderDescbuildpackage=You can generate here a "ready to distribute" package file (a normalized .zip file) of your module. Just click on button to build the module package file. -EnterNameOfModuleToDeleteDesc=You can delete your module. WARNING: All files of module will be definitly lost ! +ModuleBuilderDescbuildpackage=You can generate here a "ready to distribute" package file (a normalized .zip file) of your module and a "ready to distribute" documentation file. Just click on button to build the package or documentation file. +EnterNameOfModuleToDeleteDesc=You can delete your module. WARNING: All files of module but also structured data and documentation will be definitly lost ! EnterNameOfObjectToDeleteDesc=You can delete an object. WARNING: All files related to object will be definitly lost ! DangerZone=Danger zone -BuildPackage=Build package +BuildPackage=Build package/documentation +BuildDocumentation=Build documentation ModuleIsNotActive=This module was not activated yet (go into Home-Setup-Module to make it live) ModuleIsLive=This module has been activated. Any change on it may break a current active feature. DescriptionLong=Long description @@ -33,5 +35,6 @@ ApiClassFile=File for PHP API class PageForList=PHP page for list of record PageForCreateEditView=PHP page to create/edit/view a record PathToModulePackage=Path to zip of module/application package +PathToModuleDocumentation=Path to file of module/application documentation SpaceOrSpecialCharAreNotAllowed=Spaces or special characters are not allowed. -PackageFileNotYetGenerated=Package file not yet generated \ No newline at end of file +FileNotYetGenerated=File not yet generated diff --git a/htdocs/modulebuilder/index.php b/htdocs/modulebuilder/index.php index caa99d4b089..8ea54b78454 100644 --- a/htdocs/modulebuilder/index.php +++ b/htdocs/modulebuilder/index.php @@ -579,6 +579,11 @@ elseif (! empty($module)) $head2[$h][2] = 'description'; $h++; + $head2[$h][0] = $_SERVER["PHP_SELF"].'?tab=specifications&module='.$module; + $head2[$h][1] = $langs->trans("Specifications"); + $head2[$h][2] = 'specifications'; + $h++; + $head2[$h][0] = $_SERVER["PHP_SELF"].'?tab=objects&module='.$module; $head2[$h][1] = $langs->trans("Objects"); $head2[$h][2] = 'objects'; @@ -692,6 +697,13 @@ elseif (! empty($module)) print ''; } + + if ($tab == 'specifications') + { + print $langs->trans("FeatureNotYetAvailable"); + + } + if ($tab == 'objects') { $head3 = array(); @@ -849,7 +861,6 @@ elseif (! empty($module)) { print $langs->trans("FeatureNotYetAvailable"); - } if ($tab == 'permissions') @@ -900,7 +911,7 @@ elseif (! empty($module)) print ''; } - if ($tab == 'widget') + if ($tab == 'widgets') { print $langs->trans("FeatureNotYetAvailable"); @@ -947,17 +958,22 @@ elseif (! empty($module)) { $FILENAMEZIP="module_".$modulelowercase.'-'.$arrayversion[0].'.'.$arrayversion[1].($arrayversion[2]?".".$arrayversion[2]:"").".zip"; $outputfile = $conf->admin->dir_temp.'/'.$FILENAMEZIP; + + $FILENAMEDOC="module_".$modulelowercase.'-'.$arrayversion[0].'.'.$arrayversion[1].($arrayversion[2]?".".$arrayversion[2]:"").".md"; + $outputfiledoc = $conf->admin->dir_temp.'/'.$FILENAMEDOC; } + print '
'; + print ' '. $langs->trans("PathToModulePackage") . ' : '; - if (! dol_is_file($outputfile)) print ''.$langs->trans("PackageFileNotYetGenerated").''; + if (! dol_is_file($outputfile)) print ''.$langs->trans("FileNotYetGenerated").''; else { print ''.$outputfile.''; print ' ('.$langs->trans("GeneratedOn").' '.dol_print_date(dol_filemtime($outputfile), 'dayhour').')'; } print '
'; - print '

'; + print '
'; print '
'; print ''; @@ -965,6 +981,25 @@ elseif (! empty($module)) print ''; print ''; print '
'; + + print '


'; + + print ' '. $langs->trans("PathToModuleDocumentation") . ' : '; + if (! dol_is_file($outputfiledoc)) print ''.$langs->trans("FileNotYetGenerated").''; + else { + print ''.$outputfiledoc.''; + print ' ('.$langs->trans("GeneratedOn").' '.dol_print_date(dol_filemtime($outputfiledoc), 'dayhour').')'; + } + print '
'; + + print '
'; + + print '
'; + print ''; + print ''; + print ''; + print ''; + print '
'; } dol_fiche_end(); From 0ee93fb00c011243c2db224a6d3e8119dd412aa0 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 4 Jul 2017 10:29:38 +0200 Subject: [PATCH 223/227] Fix conflict between option login and logina and logint in agenda export --- htdocs/admin/agenda_xcal.php | 2 +- htdocs/comm/action/class/actioncomm.class.php | 64 +++++++++++-------- htdocs/langs/en_US/agenda.lang | 4 +- htdocs/public/agenda/agendaexport.php | 22 +++---- 4 files changed, 52 insertions(+), 40 deletions(-) diff --git a/htdocs/admin/agenda_xcal.php b/htdocs/admin/agenda_xcal.php index 1895eb5b15d..99742b19f57 100644 --- a/htdocs/admin/agenda_xcal.php +++ b/htdocs/admin/agenda_xcal.php @@ -174,8 +174,8 @@ $message.='
'; print $message; $message=$langs->trans("AgendaUrlOptions1",$user->login,$user->login).'
'; -//$message.=$langs->trans("AgendaUrlOptions2",$user->login,$user->login).'
'; $message.=$langs->trans("AgendaUrlOptions3",$user->login,$user->login).'
'; +$message.=$langs->trans("AgendaUrlOptionsNotAdmin",$user->login,$user->login).'
'; $message.=$langs->trans("AgendaUrlOptions4",$user->login,$user->login).'
'; $message.=$langs->trans("AgendaUrlOptionsProject",$user->login,$user->login); diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php index 8243268574c..70b2acb86b7 100644 --- a/htdocs/comm/action/class/actioncomm.class.php +++ b/htdocs/comm/action/class/actioncomm.class.php @@ -38,7 +38,7 @@ class ActionComm extends CommonObject public $table_rowid = 'id'; protected $ismultientitymanaged = 1; // 0=No test on entity, 1=Test with field entity, 2=Test with link by societe public $picto='action'; - + /** * Id of the event * @var int @@ -168,7 +168,7 @@ class ActionComm extends CommonObject var $email_subject; var $errors_to; - + /** * Constructor * @@ -444,7 +444,7 @@ class ActionComm extends CommonObject $u->fetch($fuser); $fuser = $u; } - else + else { $fuser = $user; } @@ -657,11 +657,11 @@ class ActionComm extends CommonObject $this->error=$this->db->lasterror(); $error++; } - + if (! $error) { $sql = "DELETE FROM ".MAIN_DB_PREFIX."actioncomm_resources"; $sql.= " WHERE fk_actioncomm=".$this->id; - + dol_syslog(get_class($this)."::delete", LOG_DEBUG); $res=$this->db->query($sql); if ($res < 0) { @@ -669,7 +669,7 @@ class ActionComm extends CommonObject $error++; } } - + // Removed extrafields if (! $error) { $result=$this->deleteExtraFields(); @@ -1091,7 +1091,7 @@ class ActionComm extends CommonObject else if ($percent > 0 && $percent < 100) return $percent.'% '.img_picto($langs->trans('StatusActionInProcess').' - '.$percent.'%','statut3'); else if ($percent >= 100) return img_picto($langs->trans('StatusActionDone'),'statut6'); } - + return ''; } @@ -1112,20 +1112,20 @@ class ActionComm extends CommonObject global $conf, $langs, $user, $hookmanager; if (! empty($conf->dol_no_mouse_hover)) $notooltip=1; // Force disable tooltips - + $label = $this->label; if (empty($label)) $label=$this->libelle; // For backward compatibility $result=''; - + // Set label of typ $labeltype = ($langs->transnoentities("Action".$this->type_code) != "Action".$this->type_code)?$langs->transnoentities("Action".$this->type_code):$this->type_label; if (empty($conf->global->AGENDA_USE_EVENT_TYPE)) { if ($this->type_code != 'AC_OTH_AUTO') $labeltype = $langs->trans('ActionAC_MANUAL'); } - - + + $tooltip = '' . $langs->trans('ShowAction'.$objp->code) . ''; if (! empty($this->ref)) $tooltip .= '
' . $langs->trans('Ref') . ': ' . $this->ref; @@ -1137,7 +1137,7 @@ class ActionComm extends CommonObject $tooltip .= '
' . $langs->trans('Location') . ': ' . $this->location; $linkclose=''; - if (! empty($conf->global->AGENDA_USE_EVENT_TYPE) && $this->type_color) + if (! empty($conf->global->AGENDA_USE_EVENT_TYPE) && $this->type_color) $linkclose = ' style="background-color:#'.$this->type_color.'"'; if (empty($notooltip)) @@ -1149,7 +1149,7 @@ class ActionComm extends CommonObject } $linkclose.=' title="'.dol_escape_htmltag($tooltip, 1).'"'; $linkclose.=' class="'.$classname.' classfortooltip"'; - + if (! is_object($hookmanager)) { include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; @@ -1161,17 +1161,17 @@ class ActionComm extends CommonObject $linkclose = ($hookmanager->resPrint ? $hookmanager->resPrint : $linkclose); } else $linkclose.=' class="'.$classname.'"'; - + $url=''; - if ($option=='birthday') + if ($option=='birthday') $url = DOL_URL_ROOT.'/contact/perso.php?id='.$this->id; - else + else $url = DOL_URL_ROOT.'/comm/action/card.php?id='.$this->id; - + $linkstart = ''; $linkend=''; - + //print 'rrr'.$this->libelle.'-'.$withpicto; if ($withpicto == 2) @@ -1279,7 +1279,7 @@ class ActionComm extends CommonObject $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."user as u on u.rowid = a.fk_user_author"; // Link to get author of event for export $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s on s.rowid = a.fk_soc"; // We must filter on assignement table - if ($filters['logint'] || $filters['login']) $sql.=", ".MAIN_DB_PREFIX."actioncomm_resources as ar"; + if ($filters['logint']) $sql.=", ".MAIN_DB_PREFIX."actioncomm_resources as ar"; $sql.= " WHERE a.fk_action=c.id"; $sql.= " AND a.entity IN (".getEntity('agenda').")"; foreach ($filters as $key => $value) @@ -1291,20 +1291,34 @@ class ActionComm extends CommonObject if ($key == 'idto') $sql.=" AND a.id <= ".(is_numeric($value)?$value:0); if ($key == 'project') $sql.=" AND a.fk_project=".(is_numeric($value)?$value:0); // We must filter on assignement table - if ($key == 'logint' || $key == 'login') $sql.= " AND ar.fk_actioncomm = a.id AND ar.element_type='user'"; + if ($key == 'logint') $sql.= " AND ar.fk_actioncomm = a.id AND ar.element_type='user'"; if ($key == 'logina') { $logina=$value; + $condition='='; + if (preg_match('/^!/',$logina)) + { + $logina=preg_replace('/^!/','',$logina); + $condition='<>'; + } $userforfilter=new User($this->db); - $result=$userforfilter->fetch('',$value); - $sql.= " AND a.fk_user_author = ".$userforfilter->id; + $result=$userforfilter->fetch('',$logina); + if ($result > 0) $sql.= " AND a.fk_user_author ".$condition." ".$userforfilter->id; + elseif ($result < 0 || $condition == '=') $sql.= " AND a.fk_user_author = 0"; } - if ($key == 'logint' || $key == 'login') + if ($key == 'logint') { $logint=$value; + $condition='='; + if (preg_match('/^!/',$logint)) + { + $logint=preg_replace('/^!/','',$logint); + $condition='<>'; + } $userforfilter=new User($this->db); - $result=$userforfilter->fetch('',$value); - $sql.= " AND ar.fk_element = ".$userforfilter->id; + $result=$userforfilter->fetch('',$logint); + if ($result > 0) $sql.= " AND ar.fk_element = ".$userforfilter->id; + elseif ($result < 0 || $condition == '=') $sql.= " AND ar.fk_element = 0"; } } $sql.= " AND a.datep IS NOT NULL"; // To exclude corrupted events and avoid errors in lightning/sunbird import diff --git a/htdocs/langs/en_US/agenda.lang b/htdocs/langs/en_US/agenda.lang index 9e7af7b0d06..4e2e2acf378 100644 --- a/htdocs/langs/en_US/agenda.lang +++ b/htdocs/langs/en_US/agenda.lang @@ -80,9 +80,9 @@ AgendaModelModule=Document templates for event DateActionStart=Start date DateActionEnd=End date AgendaUrlOptions1=You can also add following parameters to filter output: -AgendaUrlOptions2=login=%s to restrict output to actions created by or assigned to user %s. AgendaUrlOptions3=logina=%s to restrict output to actions owned by a user %s. -AgendaUrlOptions4=logint=%s to restrict output to actions assigned to user %s. +AgendaUrlOptionsNotAdmin=logina=!%s to restrict output to actions not owned by user %s. +AgendaUrlOptions4=logint=%s to restrict output to actions assigned to user %s (owner and others). AgendaUrlOptionsProject=project=PROJECT_ID to restrict output to actions associated to project PROJECT_ID. AgendaShowBirthdayEvents=Show birthdays of contacts AgendaHideBirthdayEvents=Hide birthdays of contacts diff --git a/htdocs/public/agenda/agendaexport.php b/htdocs/public/agenda/agendaexport.php index b3886824485..81a67204fdb 100644 --- a/htdocs/public/agenda/agendaexport.php +++ b/htdocs/public/agenda/agendaexport.php @@ -65,19 +65,18 @@ if (! isset($conf->global->MAIN_AGENDA_EXPORT_PAST_DELAY)) $conf->global->MAIN_A // Define format, type and filter $format='ical'; $type='event'; -if (! empty($_GET["format"])) $format=$_GET["format"]; -if (! empty($_GET["type"])) $type=$_GET["type"]; +if (GETPOST("format",'alpha')) $format=GETPOST("format",'apha'); +if (GETPOST("type",'apha')) $type=GETPOST("type",'alpha'); $filters=array(); -if (! empty($_GET["year"])) $filters['year']=$_GET["year"]; -if (! empty($_GET["id"])) $filters['id']=$_GET["id"]; -if (! empty($_GET["idfrom"])) $filters['idfrom']=$_GET["idfrom"]; -if (! empty($_GET["idto"])) $filters['idto']=$_GET["idto"]; -if (! empty($_GET["project"])) $filters['project']=$_GET["project"]; -if (! empty($_GET["login"])) $filters['login']=$_GET["login"]; -if (! empty($_GET["logina"])) $filters['logina']=$_GET["logina"]; -if (! empty($_GET["logint"])) $filters['logint']=$_GET["logint"]; -if (GETPOST("notolderthan")) $filters['notolderthan']=GETPOST("notolderthan","int"); +if (GETPOST("year",'int')) $filters['year']=GETPOST("year",'int'); +if (GETPOST("id",'int')) $filters['id']=GETPOST("id",'int'); +if (GETPOST("idfrom",'int')) $filters['idfrom']=GETPOST("idfrom",'int'); +if (GETPOST("idto",'int')) $filters['idto']=GETPOST("idto",'int'); +if (GETPOST("project",'apha')) $filters['project']=GETPOST("project",'apha'); +if (GETPOST("logina",'apha')) $filters['logina']=GETPOST("logina",'apha'); +if (GETPOST("logint",'apha')) $filters['logint']=GETPOST("logint",'apha'); +if (GETPOST("notolderthan",'int')) $filters['notolderthan']=GETPOST("notolderthan","int"); else $filters['notolderthan']=$conf->global->MAIN_AGENDA_EXPORT_PAST_DELAY; // Check config @@ -115,7 +114,6 @@ foreach ($filters as $key => $value) if ($key == 'idfrom') $filename.='-idfrom'.$value; if ($key == 'idto') $filename.='-idto'.$value; if ($key == 'project') $filename.='-project'.$value; - if ($key == 'login') $filename.='-login'.$value; if ($key == 'logina') $filename.='-logina'.$value; // Author if ($key == 'logint') $filename.='-logint'.$value; // Assigned to } From 95cf36c43bd814a7aeee09a17b432a4d8c8d778c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 4 Jul 2017 10:55:53 +0200 Subject: [PATCH 224/227] Fix use the getUrl function instead of hard coded curl --- htdocs/categories/admin/categorie.php | 3 ++- .../categories/admin/categorie_extrafields.php | 2 +- htdocs/langs/en_US/products.lang | 8 +++++++- htdocs/product/admin/dynamic_prices.php | 2 ++ .../price_global_variable_updater.class.php | 18 ++++++------------ 5 files changed, 18 insertions(+), 15 deletions(-) diff --git a/htdocs/categories/admin/categorie.php b/htdocs/categories/admin/categorie.php index d16b081e6ae..55006a8b171 100644 --- a/htdocs/categories/admin/categorie.php +++ b/htdocs/categories/admin/categorie.php @@ -37,6 +37,7 @@ $action=GETPOST('action','aZ09'); /* * Actions */ + if (preg_match('/set_(.*)/',$action,$reg)) { $code=$reg[1]; @@ -82,7 +83,7 @@ print load_fiche_titre($langs->trans("CategoriesSetup"),$linkback,'title_setup') $head=categoriesadmin_prepare_head(); -dol_fiche_head($head, 'setup', $langs->trans("Categories"), 0, 'category'); +dol_fiche_head($head, 'setup', $langs->trans("Categories"), -1, 'category'); print ''; diff --git a/htdocs/categories/admin/categorie_extrafields.php b/htdocs/categories/admin/categorie_extrafields.php index 2bc9f205334..6291d2065c2 100644 --- a/htdocs/categories/admin/categorie_extrafields.php +++ b/htdocs/categories/admin/categorie_extrafields.php @@ -68,7 +68,7 @@ print load_fiche_titre($langs->trans("CategoriesSetup"),$linkback,'title_setup') $head = categoriesadmin_prepare_head(); -dol_fiche_head($head, 'attributes_categories', $langs->trans("Categories"), 0, 'category'); +dol_fiche_head($head, 'attributes_categories', $langs->trans("Categories"), -1, 'category'); require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php'; diff --git a/htdocs/langs/en_US/products.lang b/htdocs/langs/en_US/products.lang index ae9cd743c8f..3c47b188972 100644 --- a/htdocs/langs/en_US/products.lang +++ b/htdocs/langs/en_US/products.lang @@ -247,12 +247,18 @@ ComposedProduct=Sub-product MinSupplierPrice=Minimum supplier price MinCustomerPrice=Minimum customer price DynamicPriceConfiguration=Dynamic price configuration -DynamicPriceDesc=On product card, with this module enabled, you should be able to set mathematic functions to calculate Customer or Supplier prices. Such function can use all mathematic operators, some constants and variables. You can set here the variables you want to be able and if the variable need an automatic update, the external URL to use to ask Dolibarr to update automaticaly the value. +DynamicPriceDesc=On product card, with this module enabled, you should be able to set mathematic functions to calculate Customer or Supplier prices. Such function can use all mathematic operators, some constants and variables. You can set here the variables you want to be able to use and if the variable need an automatic update, the external URL to use to ask Dolibarr to update automaticaly the value. AddVariable=Add Variable AddUpdater=Add Updater GlobalVariables=Global variables VariableToUpdate=Variable to update GlobalVariableUpdaters=Global variable updaters +GlobalVariableUpdaterType0=JSON data +GlobalVariableUpdaterHelp0=Parses JSON data from specified URL, VALUE specifies the location of relevant value, +GlobalVariableUpdaterHelpFormat0=Format for request {"URL": "http://example.com/urlofjson", "VALUE": "array1,array2,targetvalue"} +GlobalVariableUpdaterType1=WebService data +GlobalVariableUpdaterHelp1=Parses WebService data from specified URL, NS specifies the namespace, VALUE specifies the location of relevant value, DATA should contain the data to send and METHOD is the calling WS method +GlobalVariableUpdaterHelpFormat1=Format for request is {"URL": "http://example.com/urlofws", "VALUE": "array,targetvalue", "NS": "http://example.com/urlofns", "METHOD": "myWSMethod", "DATA": {"your": "data", "to": "send"}} UpdateInterval=Update interval (minutes) LastUpdated=Latest update CorrectlyUpdated=Correctly updated diff --git a/htdocs/product/admin/dynamic_prices.php b/htdocs/product/admin/dynamic_prices.php index 24f1d64e30c..b044471e3e1 100644 --- a/htdocs/product/admin/dynamic_prices.php +++ b/htdocs/product/admin/dynamic_prices.php @@ -54,9 +54,11 @@ if ($action == 'edit_updater') { } } + /* * Actions */ + if (!empty($action) && empty($cancel)) { //Global variable actions if ($action == 'create_variable' || $action == 'edit_variable') { diff --git a/htdocs/product/dynamic_price/class/price_global_variable_updater.class.php b/htdocs/product/dynamic_price/class/price_global_variable_updater.class.php index 3c176f0530e..0948275ce2b 100644 --- a/htdocs/product/dynamic_price/class/price_global_variable_updater.class.php +++ b/htdocs/product/dynamic_price/class/price_global_variable_updater.class.php @@ -464,24 +464,18 @@ class PriceGlobalVariableUpdater } $result = ""; if ($this->type == 0) { - //CURL client - $handle = curl_init(); - curl_setopt_array($handle, array( - CURLOPT_URL => $url, - CURLOPT_RETURNTRANSFER => true, - CURLOPT_TIMEOUT => 5, - CURLOPT_POST => false, - CURLOPT_HEADER => false, - )); + // Call JSON request + include_once DOL_DOCUMENT_ROOT.'/core/lib/geturl.lib.php'; + $tmpresult=getURLContent($url); + $code=$tmpresult['http_code']; + $result=$tmpresult['content']; - $result = curl_exec($handle); - $code = curl_getinfo($handle, CURLINFO_HTTP_CODE); if (!isset($result)) { $this->error = $langs->trans("ErrorGlobalVariableUpdater0", "empty response"); return -1; } if ($code !== 200) { - $this->error = $langs->trans("ErrorGlobalVariableUpdater0", $code); + $this->error = $langs->trans("ErrorGlobalVariableUpdater0", $code.' '.$tmpresult['curl_error_msg']); return -1; } From 77f5952318a6fd58617dcd35d7c3ab44471ad271 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 4 Jul 2017 11:18:48 +0200 Subject: [PATCH 225/227] Fix pgsql compatibility --- htdocs/core/db/mysqli.class.php | 10 +++++----- htdocs/core/db/pgsql.class.php | 7 +++++-- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/htdocs/core/db/mysqli.class.php b/htdocs/core/db/mysqli.class.php index 526d43de0ab..4358e8695fe 100644 --- a/htdocs/core/db/mysqli.class.php +++ b/htdocs/core/db/mysqli.class.php @@ -735,13 +735,13 @@ class DoliDBMysqli extends DoliDB { // cles recherchees dans le tableau des descriptions (field_desc) : type,value,attribute,null,default,extra // ex. : $field_desc = array('type'=>'int','value'=>'11','null'=>'not null','extra'=> 'auto_increment'); - $sql= "ALTER TABLE ".$table." ADD `".$field_name."` "; + $sql= "ALTER TABLE ".$table." ADD ".$field_name." "; $sql.= $field_desc['type']; if(preg_match("/^[^\s]/i",$field_desc['value'])) - if (! in_array($field_desc['type'],array('date','datetime'))) - { - $sql.= "(".$field_desc['value'].")"; - } + if (! in_array($field_desc['type'],array('date','datetime'))) + { + $sql.= "(".$field_desc['value'].")"; + } if(preg_match("/^[^\s]/i",$field_desc['attribute'])) $sql.= " ".$field_desc['attribute']; if(preg_match("/^[^\s]/i",$field_desc['null'])) diff --git a/htdocs/core/db/pgsql.class.php b/htdocs/core/db/pgsql.class.php index 4aa56b367f3..d02ff4a1341 100644 --- a/htdocs/core/db/pgsql.class.php +++ b/htdocs/core/db/pgsql.class.php @@ -1048,8 +1048,11 @@ class DoliDBPgsql extends DoliDB // ex. : $field_desc = array('type'=>'int','value'=>'11','null'=>'not null','extra'=> 'auto_increment'); $sql= "ALTER TABLE ".$table." ADD ".$field_name." "; $sql .= $field_desc['type']; - if ($field_desc['type'] != 'int' && preg_match("/^[^\s]/i",$field_desc['value'])) - $sql .= "(".$field_desc['value'].")"; + if(preg_match("/^[^\s]/i",$field_desc['value'])) + if (! in_array($field_desc['type'],array('int','date','datetime'))) + { + $sql.= "(".$field_desc['value'].")"; + } if (preg_match("/^[^\s]/i",$field_desc['attribute'])) $sql .= " ".$field_desc['attribute']; if (preg_match("/^[^\s]/i",$field_desc['null'])) From c1e747fa39d25490d6c1992684ebc7316fb70a0b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 4 Jul 2017 13:05:02 +0200 Subject: [PATCH 226/227] Look and feel v6 --- htdocs/adherents/stats/byproperties.php | 2 +- htdocs/adherents/stats/geo.php | 2 +- htdocs/opensurvey/list.php | 14 +++++++++++--- htdocs/resource/list.php | 4 +++- 4 files changed, 16 insertions(+), 6 deletions(-) diff --git a/htdocs/adherents/stats/byproperties.php b/htdocs/adherents/stats/byproperties.php index f067b27b3d4..ded3dec120e 100644 --- a/htdocs/adherents/stats/byproperties.php +++ b/htdocs/adherents/stats/byproperties.php @@ -101,7 +101,7 @@ else $head = member_stats_prepare_head($adh); -dol_fiche_head($head, 'statsbyproperties', $langs->trans("Statistics"), 0, 'user'); +dol_fiche_head($head, 'statsbyproperties', $langs->trans("Statistics"), -1, 'user'); // Print title diff --git a/htdocs/adherents/stats/geo.php b/htdocs/adherents/stats/geo.php index 1f9ff189068..1c6944c2a0a 100644 --- a/htdocs/adherents/stats/geo.php +++ b/htdocs/adherents/stats/geo.php @@ -198,7 +198,7 @@ if ($mode) $head = member_stats_prepare_head($adh); -dol_fiche_head($head, $tab, $langs->trans("Statistics"), 0, 'user'); +dol_fiche_head($head, $tab, $langs->trans("Statistics"), -1, 'user'); // Print title diff --git a/htdocs/opensurvey/list.php b/htdocs/opensurvey/list.php index 0593f9ccd05..d5a17f02239 100644 --- a/htdocs/opensurvey/list.php +++ b/htdocs/opensurvey/list.php @@ -172,7 +172,7 @@ while ($i < min($num,$limit)) $opensurvey_static->id=$obj->id_sondage; $opensurvey_static->status=$obj->status; - + print ''; print ''; print''."\n"; - + print ''; print''."\n"; - + print''."\n"; print ''."\n"; $i++; } +// If no record found +if ($num == 0) +{ + $colspan=8; + //foreach($arrayfields as $key => $val) { if (! empty($val['checked'])) $colspan++; } + print ''; +} + print '
'; print ''.img_picto('','object_opensurvey').' '.$obj->id_sondage.''; @@ -198,19 +198,27 @@ while ($i < min($num,$limit)) print ''.$nbuser.''.dol_print_date($db->jdate($obj->date_fin),'day'); if ($db->jdate($obj->date_fin) < time()) { print ' ('.$langs->trans("Expired").')'; } print ''.$opensurvey_static->getLibStatut(5).'
'.$langs->trans("NoRecordFound").'
'."\n"; print ''; print ''; diff --git a/htdocs/resource/list.php b/htdocs/resource/list.php index 11405d15acc..53658c588c6 100644 --- a/htdocs/resource/list.php +++ b/htdocs/resource/list.php @@ -311,7 +311,9 @@ if ($ret) } else { - print ''.$langs->trans('NoResourceInDatabase').''; + $colspan=1; + foreach($arrayfields as $key => $val) { if (! empty($val['checked'])) $colspan++; } + print ''.$langs->trans("NoRecordFound").''; } print ''; From e7e4252244e9a2a04e1d2e2b03265a6d1e3e49ec Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 5 Jul 2017 01:23:42 +0200 Subject: [PATCH 227/227] Fix deletion of category --- htdocs/categories/class/categorie.class.php | 40 ++++++++++----------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/htdocs/categories/class/categorie.class.php b/htdocs/categories/class/categorie.class.php index 60ef207bb48..b294f7c4aeb 100644 --- a/htdocs/categories/class/categorie.class.php +++ b/htdocs/categories/class/categorie.class.php @@ -447,9 +447,10 @@ class Categorie extends CommonObject * Delete a category from database * * @param User $user Object user that ask to delete - * @return int <0 KO >0 OK + * @param int $notrigger 1=Does not execute triggers, 0= execute triggers + * @return int <0 KO >0 OK */ - function delete($user) + function delete($user, $notrigger=0) { global $conf,$langs; @@ -462,6 +463,14 @@ class Categorie extends CommonObject $this->db->begin(); + if (! $error && ! $notrigger) + { + // Call trigger + $result=$this->call_trigger('CATEGORY_DELETE',$user); + if ($result < 0) $error++; + // End call triggers + } + /* FIX #1317 : Check for child category and move up 1 level*/ if (! $error) { @@ -580,25 +589,16 @@ class Categorie extends CommonObject $this->error=$this->db->lasterror(); $error++; } - else + } + + // Removed extrafields + if (! $error && empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used + { + $result=$this->deleteExtraFields(); + if ($result < 0) { - // Removed extrafields - if (! $error) - { - if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used - { - $result=$this->deleteExtraFields(); - if ($result < 0) - { - $error++; - dol_syslog(get_class($this)."::delete erreur ".$this->error, LOG_ERR); - } - } - } - // Call trigger - $result=$this->call_trigger('CATEGORY_DELETE',$user); - if ($result < 0) { $error++; } - // End call triggers + $error++; + dol_syslog(get_class($this)."::delete erreur ".$this->error, LOG_ERR); } }