From 39a422ef9481eba7f7713086de1619423b434983 Mon Sep 17 00:00:00 2001 From: lvessiller Date: Fri, 14 Aug 2020 11:48:53 +0200 Subject: [PATCH 01/92] FIX update margins rates on object line edit --- htdocs/core/tpl/objectline_edit.tpl.php | 70 +++++++++++++++++++++++++ 1 file changed, 70 insertions(+) diff --git a/htdocs/core/tpl/objectline_edit.tpl.php b/htdocs/core/tpl/objectline_edit.tpl.php index c14e5c20cf7..f9f0d5d71ac 100644 --- a/htdocs/core/tpl/objectline_edit.tpl.php +++ b/htdocs/core/tpl/objectline_edit.tpl.php @@ -303,6 +303,76 @@ if (!empty($extrafieldsline)) '; + } + print '
'; print ''."\n"; @@ -1092,7 +1102,7 @@ if ($resql) { if (($obj->fk_statut > 0 && $obj->fk_statut < 3) || ($obj->fk_statut == 3 && $obj->billed == 0)) { - print ' '; + print ' '; print img_picto($langs->trans("CreateInvoiceForThisCustomer").' : '.$companystatic->name, 'object_bill', 'hideonsmartphone').''; } } diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index e00d544ed22..7bf559240d9 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -647,7 +647,7 @@ class Form $disabled = 0; $ret = '
'; - $ret .= ''; // Complete list with data from external modules. THe module can use $_SERVER['PHP_SELF'] to know on which page we are, or use the $parameters['currentcontext'] completed by executeHooks. $parameters = array(); @@ -7552,8 +7552,8 @@ class Form global $conf, $langs; $out = ''; - $id = uniqid(); - if (!empty($conf->use_javascript_ajax)) $out .= '
'; + + if (!empty($conf->use_javascript_ajax)) $out .= '
'; $out .= ''; + $(".' . $cssclass.'").change(function() { + $(this).closest("tr").toggleClass("highlight", this.checked); + }); + }); + '; return $out; } From d912908aef1744e68a06e289e01ac01f3d8e4a22 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 1 Oct 2020 19:05:20 +0200 Subject: [PATCH 63/92] NEW Can build vendor invoice from vendor orders --- htdocs/comm/card.php | 4 +- htdocs/commande/list.php | 4 +- htdocs/core/actions_massactions.inc.php | 4 +- htdocs/fourn/card.php | 2 +- .../fourn/class/fournisseur.facture.class.php | 5 +- htdocs/fourn/commande/list.php | 214 +++++++++++------- 6 files changed, 145 insertions(+), 88 deletions(-) diff --git a/htdocs/comm/card.php b/htdocs/comm/card.php index 6f1a40b2fb0..79278fef056 100644 --- a/htdocs/comm/card.php +++ b/htdocs/comm/card.php @@ -777,8 +777,6 @@ if ($object->id > 0) print '
'; print ''; print ''; } @@ -1283,7 +1281,7 @@ if ($object->id > 0) { if ($object->client != 0 && $object->client != 2) { - if (!empty($orders2invoice) && $orders2invoice > 0) print ''; + if (!empty($orders2invoice) && $orders2invoice > 0) print ''; else print ''; } else print ''; } diff --git a/htdocs/commande/list.php b/htdocs/commande/list.php index 82fde75966b..ad422a8b930 100644 --- a/htdocs/commande/list.php +++ b/htdocs/commande/list.php @@ -1102,7 +1102,7 @@ if ($resql) { if (($obj->fk_statut > 0 && $obj->fk_statut < 3) || ($obj->fk_statut == 3 && $obj->billed == 0)) { - print ' '; + print ' '; print img_picto($langs->trans("CreateInvoiceForThisCustomer").' : '.$companystatic->name, 'object_bill', 'hideonsmartphone').''; } } @@ -1299,7 +1299,7 @@ if ($resql) } // Action column - print ''; - +print ''; +print ''; +print $object->showOptionals($extrafields, ($action == 'edit'?'edit':'view')); print '
'; print ''; - //if($num2 > 0) print ''; - //else print ''; print '
'.$langs->trans("LastCustomerOrders", ($num <= $MAXLIST ? "" : $MAXLIST)).''.$langs->trans("AllOrders").''.$num.''.img_picto($langs->trans("Statistics"), 'stats').''.img_picto($langs->trans("CreateInvoiceForThisCustomer"),'object_bill').''.img_picto($langs->trans("NoOrdersToInvoice"),'object_bill').'
'; + print ''; if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined { $selected = 0; diff --git a/htdocs/core/actions_massactions.inc.php b/htdocs/core/actions_massactions.inc.php index 2bdae583429..c2f0a314445 100644 --- a/htdocs/core/actions_massactions.inc.php +++ b/htdocs/core/actions_massactions.inc.php @@ -615,7 +615,7 @@ if ($massaction == 'confirm_createbills') // Create bills from orders $cmd->fetch_optionals(); $objecttmp->socid = $cmd->socid; - $objecttmp->type = Facture::TYPE_STANDARD; + $objecttmp->type = $objecttmp::TYPE_STANDARD; $objecttmp->cond_reglement_id = $cmd->cond_reglement_id; $objecttmp->mode_reglement_id = $cmd->mode_reglement_id; $objecttmp->fk_project = $cmd->fk_project; @@ -742,7 +742,7 @@ if ($massaction == 'confirm_createbills') // Create bills from orders 'HT', 0, $product_type, - $ii, + $lines[$i]->rang, $lines[$i]->special_code, $objecttmp->origin, $lines[$i]->rowid, diff --git a/htdocs/fourn/card.php b/htdocs/fourn/card.php index 8488abeee30..1de6d30b681 100644 --- a/htdocs/fourn/card.php +++ b/htdocs/fourn/card.php @@ -798,7 +798,7 @@ if ($object->id > 0) if ($object->status == 1) { // Company is open - print ''; + print ''; } else { print ''; } diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php index 23f0cc1f3ea..0c0e32a2055 100644 --- a/htdocs/fourn/class/fournisseur.facture.class.php +++ b/htdocs/fourn/class/fournisseur.facture.class.php @@ -1601,9 +1601,10 @@ class FactureFournisseur extends CommonInvoice * @param double $pu_ht_devise Amount in currency * @param string $ref_supplier Supplier ref * @param string $special_code Special code + * @param int $fk_parent_line Parent line id * @return int >0 if OK, <0 if KO */ - public function addline($desc, $pu, $txtva, $txlocaltax1, $txlocaltax2, $qty, $fk_product = 0, $remise_percent = 0, $date_start = '', $date_end = '', $ventil = 0, $info_bits = '', $price_base_type = 'HT', $type = 0, $rang = -1, $notrigger = false, $array_options = 0, $fk_unit = null, $origin_id = 0, $pu_ht_devise = 0, $ref_supplier = '', $special_code = '') + public function addline($desc, $pu, $txtva, $txlocaltax1, $txlocaltax2, $qty, $fk_product = 0, $remise_percent = 0, $date_start = '', $date_end = '', $ventil = 0, $info_bits = '', $price_base_type = 'HT', $type = 0, $rang = -1, $notrigger = false, $array_options = 0, $fk_unit = null, $origin_id = 0, $pu_ht_devise = 0, $ref_supplier = '', $special_code = '', $fk_parent_line = 0) { global $langs, $mysoc, $conf; @@ -1777,7 +1778,7 @@ class FactureFournisseur extends CommonInvoice $this->line->info_bits = $info_bits; $this->line->special_code = ((string) $special_code != '' ? $special_code : $this->special_code); - $this->line->fk_parent_line = $this->fk_parent_line; + $this->line->fk_parent_line = $fk_parent_line; $this->line->origin = $this->origin; $this->line->origin_id = $origin_id; $this->line->fk_unit = $fk_unit; diff --git a/htdocs/fourn/commande/list.php b/htdocs/fourn/commande/list.php index 6be60c04249..48613e67d43 100644 --- a/htdocs/fourn/commande/list.php +++ b/htdocs/fourn/commande/list.php @@ -35,6 +35,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.class.php'; require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php'; +require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formorder.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; @@ -130,6 +131,9 @@ $fieldstosearchall = array( 'cf.ref_supplier'=>'RefSupplierOrder', 'pd.description'=>'Description', 's.nom'=>"ThirdParty", + 's.name_alias'=>"AliasNameShort", + 's.zip'=>"Zip", + 's.town'=>"Town", 'cf.note_public'=>'NotePublic', ); if (empty($user->socid)) $fieldstosearchall["cf.note_private"] = "NotePrivate"; @@ -180,7 +184,7 @@ $arrayfields = dol_sort_array($arrayfields, 'position'); */ if (GETPOST('cancel', 'alpha')) { $action = 'list'; $massaction = ''; } -if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction = ''; } +if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend' && $massaction != 'confirm_createsupplierbills') { $massaction = ''; } $parameters = array('socid'=>$socid); $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks @@ -244,7 +248,7 @@ if (empty($reshook)) include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; // TODO Move this into mass action include - if ($massaction == 'confirm_createbills') + if ($massaction == 'confirm_createsupplierbills') { $orders = GETPOST('toselect', 'array'); $createbills_onebythird = GETPOST('createbills_onebythird', 'int'); @@ -258,34 +262,36 @@ if (empty($reshook)) $db->begin(); foreach ($orders as $id_order) { - $cmd = new Commande($db); + $cmd = new CommandeFournisseur($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. + $objecttmp = new FactureFournisseur($db); + if (!empty($createbills_onebythird) && !empty($TFactThird[$cmd->socid])) $objecttmp = $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; + $objecttmp->socid = $cmd->socid; + $objecttmp->type = $objecttmp::TYPE_STANDARD; + $objecttmp->cond_reglement_id = $cmd->cond_reglement_id; + $objecttmp->mode_reglement_id = $cmd->mode_reglement_id; + $objecttmp->fk_project = $cmd->fk_project; + $objecttmp->multicurrency_code = $cmd->multicurrency_code; + if (empty($createbills_onebythird)) $objecttmp->ref_client = $cmd->ref_client; - $datefacture = dol_mktime(12, 0, 0, $_POST['remonth'], $_POST['reday'], $_POST['reyear']); + $datefacture = dol_mktime(12, 0, 0, GETPOST('remonth', 'int'), GETPOST('reday', 'int'), GETPOST('reyear', 'int')); if (empty($datefacture)) { - $datefacture = dol_mktime(date("h"), date("M"), 0, date("m"), date("d"), date("Y")); + $datefacture = dol_now(); } - $object->date = $datefacture; - $object->origin = 'commande'; - $object->origin_id = $id_order; + $objecttmp->date = $datefacture; + $objecttmp->origin = 'order_supplier'; + $objecttmp->origin_id = $id_order; - $res = $object->create($user); + $res = $objecttmp->create($user); if ($res > 0) $nb_bills_created++; } - if ($object->id > 0) + if ($objecttmp->id > 0) { $sql = "INSERT INTO ".MAIN_DB_PREFIX."element_element ("; $sql .= "fk_source"; @@ -294,9 +300,9 @@ if (empty($reshook)) $sql .= ", targettype"; $sql .= ") VALUES ("; $sql .= $id_order; - $sql .= ", '".$db->escape($object->origin)."'"; - $sql .= ", ".$object->id; - $sql .= ", '".$db->escape($object->element)."'"; + $sql .= ", '".$db->escape($objecttmp->origin)."'"; + $sql .= ", ".$objecttmp->id; + $sql .= ", '".$db->escape($objecttmp->element)."'"; $sql .= ")"; if (!$db->query($sql)) @@ -323,7 +329,7 @@ if (empty($reshook)) { // Negative line, we create a discount line $discount = new DiscountAbsolute($db); - $discount->fk_soc = $object->socid; + $discount->fk_soc = $objecttmp->socid; $discount->amount_ht = abs($lines[$i]->total_ht); $discount->amount_tva = abs($lines[$i]->total_tva); $discount->amount_ttc = abs($lines[$i]->total_ttc); @@ -333,7 +339,7 @@ if (empty($reshook)) $discountid = $discount->create($user); if ($discountid > 0) { - $result = $object->insert_discount($discountid); + $result = $objecttmp->insert_discount($discountid); //$result=$discount->link_to_invoice($lineid,$id); } else { setEventMessages($discount->error, $discount->errors, 'errors'); @@ -358,32 +364,31 @@ if (empty($reshook)) { $fk_parent_line = 0; } - $result = $object->addline( + $result = $objecttmp->addline( $desc, $lines[$i]->subprice, - $lines[$i]->qty, $lines[$i]->tva_tx, $lines[$i]->localtax1_tx, $lines[$i]->localtax2_tx, - $lines[$i]->fk_product, + $lines[$i]->qty, + $lines[$i]->fk_product, $lines[$i]->remise_percent, $date_start, $date_end, 0, $lines[$i]->info_bits, - $lines[$i]->fk_remise_except, - 'HT', - 0, - $product_type, - $ii, - $lines[$i]->special_code, - $object->origin, - $lines[$i]->rowid, - $fk_parent_line, - $lines[$i]->fk_fournprice, - $lines[$i]->pa_ht, - $lines[$i]->label - ); + 'HT', + $product_type, + $lines[$i]->rang, + false, + $lines[$i]->array_options, + $lines[$i]->fk_unit, + $objecttmp->origin_id, + $lines[$i]->pa_ht, + $lines[$i]->ref_supplier, + $lines[$i]->special_code, + $fk_parent_line + ); if ($result > 0) { $lineid = $result; @@ -404,8 +409,8 @@ if (empty($reshook)) $cmd->classifyBilled($user); // TODO Move this in workflow like done for customer orders - if (!empty($createbills_onebythird) && empty($TFactThird[$cmd->socid])) $TFactThird[$cmd->socid] = $object; - else $TFact[$object->id] = $object; + if (!empty($createbills_onebythird) && empty($TFactThird[$cmd->socid])) $TFactThird[$cmd->socid] = $objecttmp; + else $TFact[$objecttmp->id] = $objecttmp; } // Build doc with all invoices @@ -415,38 +420,67 @@ if (empty($reshook)) if (!$error && $validate_invoices) { $massaction = $action = 'builddoc'; - foreach ($TAllFact as &$object) + foreach ($TAllFact as &$objecttmp) { - $object->validate($user); + $objecttmp->validate($user); if ($result <= 0) { $error++; - setEventMessages($object->error, $object->errors, 'errors'); + setEventMessages($objecttmp->error, $objecttmp->errors, 'errors'); break; } - $id = $object->id; // For builddoc action + $id = $objecttmp->id; // For builddoc action // Fac builddoc $donotredirect = 1; - $upload_dir = $conf->facture->dir_output; - $permissiontoadd = $user->rights->facture->creer; - include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php'; + $upload_dir = $conf->fournisseur->facture->dir_output; + $permissiontoadd = $user->rights->fournisseur->facture->creer; + //include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php'; } - $massaction = $action = 'confirm_createbills'; + $massaction = $action = 'confirm_createsupplierbills'; } if (!$error) { $db->commit(); setEventMessages($langs->trans('BillCreated', $nb_bills_created), null, 'mesgs'); + + // Make a redirect to avoid to bill twice if we make a refresh or back + $param = ''; + if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage); + if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit); + if ($sall) $param .= '&sall='.urlencode($sall); + if ($socid > 0) $param .= '&socid='.urlencode($socid); + if ($search_status != '') $param .= '&search_status='.urlencode($search_status); + if ($search_orderday) $param .= '&search_orderday='.urlencode($search_orderday); + if ($search_ordermonth) $param .= '&search_ordermonth='.urlencode($search_ordermonth); + if ($search_orderyear) $param .= '&search_orderyear='.urlencode($search_orderyear); + if ($search_deliveryday) $param .= '&search_deliveryday='.urlencode($search_deliveryday); + if ($search_deliverymonth) $param .= '&search_deliverymonth='.urlencode($search_deliverymonth); + if ($search_deliveryyear) $param .= '&search_deliveryyear='.urlencode($search_deliveryyear); + if ($search_ref) $param .= '&search_ref='.urlencode($search_ref); + if ($search_company) $param .= '&search_company='.urlencode($search_company); + if ($search_ref_customer) $param .= '&search_ref_customer='.urlencode($search_ref_customer); + if ($search_user > 0) $param .= '&search_user='.urlencode($search_user); + if ($search_sale > 0) $param .= '&search_sale='.urlencode($search_sale); + if ($search_total_ht != '') $param .= '&search_total_ht='.urlencode($search_total_ht); + if ($search_total_vat != '') $param .= '&search_total_vat='.urlencode($search_total_vat); + if ($search_total_ttc != '') $param .= '&search_total_ttc='.urlencode($search_total_ttc); + if ($search_project_ref >= 0) $param .= "&search_project_ref=".urlencode($search_project_ref); + if ($show_files) $param .= '&show_files='.urlencode($show_files); + if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss); + if ($billed != '') $param .= '&billed='.urlencode($billed); + + header("Location: ".$_SERVER['PHP_SELF'].'?'.$param); + exit; } else { $db->rollback(); $action = 'create'; $_GET["origin"] = $_POST["origin"]; $_GET["originid"] = $_POST["originid"]; - setEventMessages($object->error, $object->errors, 'errors'); + setEventMessages("Error", null, 'errors'); $error++; } } @@ -566,6 +600,7 @@ $sql .= $hookmanager->resPrint; $sql .= $db->order($sortfield, $sortorder); +// Count total nb of records $nbtotalofrecords = ''; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { @@ -579,6 +614,7 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) } $sql .= $db->plimit($limit + 1, $offset); +//print $sql; $resql = $db->query($sql); if ($resql) @@ -607,23 +643,24 @@ if ($resql) llxHeader('', $title, $help_url); $param = ''; - if ($socid > 0) $param .= '&socid='.$socid; - if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.$contextpage; - if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.$limit; - if ($sall) $param .= "&search_all=".$sall; - if ($search_orderday) $param .= '&search_orderday='.$search_orderday; - if ($search_ordermonth) $param .= '&search_ordermonth='.$search_ordermonth; - if ($search_orderyear) $param .= '&search_orderyear='.$search_orderyear; - if ($search_deliveryday) $param .= '&search_deliveryday='.$search_deliveryday; - if ($search_deliverymonth) $param .= '&search_deliverymonth='.$search_deliverymonth; - if ($search_deliveryyear) $param .= '&search_deliveryyear='.$search_deliveryyear; - if ($search_ref) $param .= '&search_ref='.$search_ref; - if ($search_company) $param .= '&search_company='.$search_company; - if ($search_user > 0) $param .= '&search_user='.$search_user; - if ($search_request_author) $param .= '&search_request_author='.$search_request_author; - if ($search_sale > 0) $param .= '&search_sale='.$search_sale; - if ($search_total_ht != '') $param .= '&search_total_ht='.$search_total_ht; - if ($search_total_ttc != '') $param .= "&search_total_ttc=".$search_total_ttc; + if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage); + if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit); + if ($sall) $param .= '&sall='.urlencode($sall); + if ($socid > 0) $param .= '&socid='.urlencode($socid); + if ($sall) $param .= "&search_all=".urlencode($sall); + if ($search_orderday) $param .= '&search_orderday='.urlencode($search_orderday); + if ($search_ordermonth) $param .= '&search_ordermonth='.urlencode($search_ordermonth); + if ($search_orderyear) $param .= '&search_orderyear='.urlencode($search_orderyear); + if ($search_deliveryday) $param .= '&search_deliveryday='.urlencode($search_deliveryday); + if ($search_deliverymonth) $param .= '&search_deliverymonth='.urlencode($search_deliverymonth); + if ($search_deliveryyear) $param .= '&search_deliveryyear='.urlencode($search_deliveryyear); + if ($search_ref) $param .= '&search_ref='.urlencode($search_ref); + if ($search_company) $param .= '&search_company='.urlencode($search_company); + if ($search_user > 0) $param .= '&search_user='.urlencode($search_user); + if ($search_request_author) $param .= '&search_request_author='.urlencode($search_request_author); + if ($search_sale > 0) $param .= '&search_sale='.urlencode($search_sale); + if ($search_total_ht != '') $param .= '&search_total_ht='.urlencode($search_total_ht); + if ($search_total_ttc != '') $param .= "&search_total_ttc=".urlencode($search_total_ttc); if ($search_multicurrency_code != '') $param .= '&search_multicurrency_code='.urlencode($search_multicurrency_code); if ($search_multicurrency_tx != '') $param .= '&search_multicurrency_tx='.urlencode($search_multicurrency_tx); if ($search_multicurrency_montant_ht != '') $param .= '&search_multicurrency_montant_ht='.urlencode($search_multicurrency_montant_ht); @@ -644,7 +681,7 @@ if ($resql) 'builddoc'=>$langs->trans("PDFMerge"), 'presend'=>$langs->trans("SendByMail"), ); - //if($user->rights->fournisseur->facture->creer) $arrayofmassactions['createbills']=$langs->trans("CreateInvoiceForThisCustomer"); + if ($user->rights->fournisseur->facture->creer) $arrayofmassactions['createbills'] = $langs->trans("CreateInvoiceForThisSupplier"); if ($user->rights->fournisseur->commande->supprimer) $arrayofmassactions['predelete'] = ''.$langs->trans("Delete"); if (in_array($massaction, array('presend', 'predelete', 'createbills'))) $arrayofmassactions = array(); $massactionbutton = $form->selectMassAction('', $arrayofmassactions); @@ -653,15 +690,16 @@ if ($resql) if (!empty($socid)) $url .= '&socid='.$socid; $newcardbutton = dolGetButtonTitle($langs->trans('NewOrder'), '', 'fa fa-plus-circle', $url, '', $user->rights->fournisseur->commande->creer); - // Fields title search - print '
'; + // Lines of title fields + print ''; if ($optioncss != '') print ''; print ''; print ''; print ''; - print ''; print ''; print ''; + print ''; + print ''; print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'supplier_order', 0, $newcardbutton, '', $limit, 0, 0, 1); @@ -674,11 +712,11 @@ if ($resql) if ($massaction == 'createbills') { //var_dump($_REQUEST); - print ''; + print ''; - print ''; + print '
'; print ''; - print ''; print '
'; + print ''; print $langs->trans('DateInvoice'); print ''; @@ -760,7 +798,17 @@ 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); + $selectedfields .= $form->showCheckAddButtons('checkforselect', 1); + + if (GETPOST('autoselectall', 'int')) { + $selectedfields .= ''; + } print '
'; print ''."\n"; @@ -933,6 +981,7 @@ if ($resql) print "\n"; + // Fields title print ''; if (!empty($arrayfields['cf.ref']['checked'])) print_liste_field_titre($arrayfields['cf.ref']['label'], $_SERVER["PHP_SELF"], "cf.ref", "", $param, '', $sortfield, $sortorder); if (!empty($arrayfields['cf.ref_supplier']['checked'])) print_liste_field_titre($arrayfields['cf.ref_supplier']['label'], $_SERVER["PHP_SELF"], "cf.ref_supplier", "", $param, '', $sortfield, $sortorder, 'tdoverflowmax100imp '); @@ -983,6 +1032,12 @@ if ($resql) { $obj = $db->fetch_object($resql); + $notshippable = 0; + $warning = 0; + $text_info = ''; + $text_warning = ''; + $nbprod = 0; + $objectstatic->id = $obj->rowid; $objectstatic->ref = $obj->ref; $objectstatic->ref_supplier = $obj->ref_supplier; @@ -1220,22 +1275,25 @@ if ($resql) if (!$i) $totalarray['nbfield']++; print "\n"; + + $total += $obj->total_ht; + $subtotal += $obj->total_ht; $i++; } // Show total line include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php'; + $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"; + print '
'."\n"; + print ''; - $db->free($resql); + print ''."\n"; $hidegeneratedfilelistifempty = 1; if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) $hidegeneratedfilelistifempty = 0; From f057488ae31386ecb7fdfdb8929bdd9f90c8e19a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Fri, 2 Oct 2020 00:21:13 +0200 Subject: [PATCH 64/92] add extrafields on ecm --- htdocs/admin/ecm.php | 5 + htdocs/core/lib/ecm.lib.php | 35 +++++++ htdocs/ecm/class/ecmdirectory.class.php | 8 +- htdocs/ecm/class/ecmfiles.class.php | 4 +- htdocs/ecm/dir_card.php | 16 ++++ htdocs/ecm/file_card.php | 21 +++- .../install/mysql/migration/12.0.0-13.0.0.sql | 96 +++++++++++-------- htdocs/langs/en_US/ecm.lang | 3 + 8 files changed, 143 insertions(+), 45 deletions(-) diff --git a/htdocs/admin/ecm.php b/htdocs/admin/ecm.php index 76bf86993e2..91236c33bd7 100644 --- a/htdocs/admin/ecm.php +++ b/htdocs/admin/ecm.php @@ -23,6 +23,7 @@ */ require '../main.inc.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/ecm.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; // Load translation files required by the page @@ -70,6 +71,10 @@ $linkback = ''; +$head = ecm_admin_prepare_head(); + +dol_fiche_head($head, 'ecm', $langs->trans("Sendings"), -1, 'ecm'); + print ''; print ''; print ''; diff --git a/htdocs/core/lib/ecm.lib.php b/htdocs/core/lib/ecm.lib.php index b9da91093bb..3b0cef1a809 100644 --- a/htdocs/core/lib/ecm.lib.php +++ b/htdocs/core/lib/ecm.lib.php @@ -138,3 +138,38 @@ function ecm_prepare_head_fm($object) return $head; } + +/** + * Return array head with list of tabs to view object informations. + * + * @return array head array with tabs + */ +function ecm_admin_prepare_head() +{ + global $langs, $conf; + $langs->load("ecm"); + + $h = 0; + $head = array(); + + $head[$h][0] = DOL_URL_ROOT."/admin/ecm.php"; + $head[$h][1] = $langs->trans("Setup"); + $head[$h][2] = 'ecm'; + $h++; + + $head[$h][0] = DOL_URL_ROOT.'/admin/ecm_files_extrafields.php'; + $head[$h][1] = $langs->trans("ExtraFieldsEcmFiles"); + $head[$h][2] = 'attributes_ecm_files'; + $h++; + + $head[$h][0] = DOL_URL_ROOT.'/admin/ecm_directories_extrafields.php'; + $head[$h][1] = $langs->trans("ExtraFieldsEcmDirectories"); + $head[$h][2] = 'attributes_ecm_directories'; + $h++; + + complete_head_from_modules($conf, $langs, null, $head, $h, 'ecm_admin'); + + complete_head_from_modules($conf, $langs, null, $head, $h, 'ecm_admin', 'remove'); + + return $head; +} diff --git a/htdocs/ecm/class/ecmdirectory.class.php b/htdocs/ecm/class/ecmdirectory.class.php index 8799af86017..25673c65c6c 100644 --- a/htdocs/ecm/class/ecmdirectory.class.php +++ b/htdocs/ecm/class/ecmdirectory.class.php @@ -25,7 +25,7 @@ /** * Class to manage ECM directories */ -class EcmDirectory // extends CommonObject +class EcmDirectory extends CommonObject { /** * @var string ID to identify managed object @@ -35,7 +35,7 @@ class EcmDirectory // extends CommonObject /** * @var string Name of table without prefix where object is stored */ - //public $table_element='ecm_directories'; + public $table_element='ecm_directories'; /** * @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png @@ -345,6 +345,10 @@ class EcmDirectory // extends CommonObject $this->date_m = $this->db->jdate($obj->date_m); } + // Retrieve all extrafields for ecm_files + // fetch optionals attributes and labels + $this->fetch_optionals(); + $this->db->free($resql); return $obj ? 1 : 0; diff --git a/htdocs/ecm/class/ecmfiles.class.php b/htdocs/ecm/class/ecmfiles.class.php index c3cb0e5462b..b0c1df8316f 100644 --- a/htdocs/ecm/class/ecmfiles.class.php +++ b/htdocs/ecm/class/ecmfiles.class.php @@ -403,9 +403,9 @@ class EcmFiles extends CommonObject $this->src_object_id = $obj->src_object_id; } - // Retrieve all extrafields for invoice + // Retrieve all extrafields for ecm_files // fetch optionals attributes and labels - // $this->fetch_optionals(); + $this->fetch_optionals(); // $this->fetch_lines(); diff --git a/htdocs/ecm/dir_card.php b/htdocs/ecm/dir_card.php index 27d08e9119f..b1473908c3a 100644 --- a/htdocs/ecm/dir_card.php +++ b/htdocs/ecm/dir_card.php @@ -27,6 +27,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; require_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmdirectory.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/ecm.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; // Load translation files required by page $langs->loadLangs(array('ecm', 'companies', 'other')); @@ -204,6 +205,16 @@ if ($action == 'update' && !GETPOST('cancel', 'alpha')) // Fetch was already done $ecmdir->label = dol_sanitizeFileName(GETPOST("label")); $ecmdir->description = GETPOST("description"); + $ret = $extrafields->setOptionalsFromPost(null, $ecmdir); + if ($ret < 0) $error++; + if (!$error) { + // Actions on extra fields + $result = $ecmdir->insertExtraFields(); + if ($result < 0) { + setEventMessages($ecmdir->error, $ecmdir->errors, 'errors'); + $error++; + } + } $result = $ecmdir->update($user); if ($result > 0) { @@ -266,6 +277,10 @@ if ($action == 'update' && !GETPOST('cancel', 'alpha')) $form = new Form($db); $object = new EcmDirectory($db); // Need to create a new one instance +$extrafields = new ExtraFields($db); +// fetch optionals attributes and labels +$extrafields->fetch_name_optionals_label($object->table_element); + if ($module == 'ecm') { @@ -415,6 +430,7 @@ print ''; print ''; +print $object->showOptionals($extrafields, ($action == 'edit' ? 'edit' : 'view')); print '
'.$langs->trans("Description").'
'.$langs->trans("TotalSizeOfAttachedFiles").''; print dol_print_size($totalsize); print '
'; if ($action == 'edit') diff --git a/htdocs/ecm/file_card.php b/htdocs/ecm/file_card.php index 48c15f92aa2..3b5cca1eebe 100644 --- a/htdocs/ecm/file_card.php +++ b/htdocs/ecm/file_card.php @@ -27,6 +27,7 @@ require_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmdirectory.class.php'; require_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmfiles.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/ecm.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; // Load translation files required by page $langs->loadLangs(array('ecm', 'companies', 'other', 'users', 'orders', 'propal', 'bills', 'contracts', 'categories')); @@ -94,6 +95,10 @@ $filepathtodocument = $relativetodocument.$file->label; // Try to load object from index $object = new ECMFiles($db); +$extrafields = new ExtraFields($db); +// fetch optionals attributes and labels +$extrafields->fetch_name_optionals_label($object->table_element); + $result = $object->fetch(0, '', $filepathtodocument); if ($result < 0) { @@ -148,7 +153,6 @@ if ($action == 'update') // Now we update index of file $db->begin(); - //print $oldfile.' - '.$newfile; if ($newlabel != $oldlabel) { @@ -181,6 +185,16 @@ if ($action == 'update') if ($object->id > 0) { + $ret = $extrafields->setOptionalsFromPost(null, $object); + if ($ret < 0) $error++; + if (!$error) { + // Actions on extra fields + $result = $object->insertExtraFields(); + if ($result < 0) { + setEventMessages($object->error, $object->errors, 'errors'); + $error++; + } + } // Call update to set the share key $result = $object->update($user); if ($result < 0) @@ -365,8 +379,9 @@ if (!empty($object->share)) print 'share ? ' checked="checked"' : '').' /> '; } } -print '
'; print '
'; diff --git a/htdocs/install/mysql/migration/12.0.0-13.0.0.sql b/htdocs/install/mysql/migration/12.0.0-13.0.0.sql index e76948808bb..af9d40d9449 100644 --- a/htdocs/install/mysql/migration/12.0.0-13.0.0.sql +++ b/htdocs/install/mysql/migration/12.0.0-13.0.0.sql @@ -105,28 +105,28 @@ ALTER TABLE llx_c_incoterms ADD COLUMN label varchar(100) NULL; CREATE TABLE llx_recruitment_recruitmentjobposition( - rowid integer AUTO_INCREMENT PRIMARY KEY NOT NULL, - ref varchar(128) DEFAULT '(PROV)' NOT NULL, - entity INTEGER DEFAULT 1 NOT NULL, - label varchar(255) NOT NULL, - qty integer DEFAULT 1 NOT NULL, - fk_soc integer, - fk_project integer, - fk_user_recruiter integer, - fk_user_supervisor integer, - fk_establishment integer, - date_planned date, - remuneration_suggested varchar(255), - description text, - note_public text, - note_private text, - date_creation datetime NOT NULL, - tms timestamp, - fk_user_creat integer NOT NULL, - fk_user_modif integer, - last_main_doc varchar(255), - import_key varchar(14), - model_pdf varchar(255), + rowid integer AUTO_INCREMENT PRIMARY KEY NOT NULL, + ref varchar(128) DEFAULT '(PROV)' NOT NULL, + entity INTEGER DEFAULT 1 NOT NULL, + label varchar(255) NOT NULL, + qty integer DEFAULT 1 NOT NULL, + fk_soc integer, + fk_project integer, + fk_user_recruiter integer, + fk_user_supervisor integer, + fk_establishment integer, + date_planned date, + remuneration_suggested varchar(255), + description text, + note_public text, + note_private text, + date_creation datetime NOT NULL, + tms timestamp, + fk_user_creat integer NOT NULL, + fk_user_modif integer, + last_main_doc varchar(255), + import_key varchar(14), + model_pdf varchar(255), status smallint NOT NULL ) ENGINE=innodb; @@ -160,24 +160,24 @@ CREATE TABLE llx_recruitment_recruitmentcandidature( -- BEGIN MODULEBUILDER FIELDS rowid integer AUTO_INCREMENT PRIMARY KEY NOT NULL, entity integer NOT NULL DEFAULT 1, - fk_recruitmentjobposition INTEGER NULL, - ref varchar(128) DEFAULT '(PROV)' NOT NULL, - description text, - note_public text, - note_private text, - date_creation datetime NOT NULL, - tms timestamp, - fk_user_creat integer NOT NULL, - fk_user_modif integer, - import_key varchar(14), - model_pdf varchar(255), - status smallint NOT NULL, - firstname varchar(128), + fk_recruitmentjobposition INTEGER NULL, + ref varchar(128) DEFAULT '(PROV)' NOT NULL, + description text, + note_public text, + note_private text, + date_creation datetime NOT NULL, + tms timestamp, + fk_user_creat integer NOT NULL, + fk_user_modif integer, + import_key varchar(14), + model_pdf varchar(255), + status smallint NOT NULL, + firstname varchar(128), lastname varchar(128), email varchar(255), phone varchar(64), date_birth date, - remuneration_requested integer, + remuneration_requested integer, remuneration_proposed integer, email_msgid varchar(255), fk_recruitment_origin INTEGER NULL @@ -272,8 +272,8 @@ ALTER TABLE llx_recruitment_recruitmentcandidature ADD UNIQUE INDEX uk_recruitme ALTER TABLE llx_product MODIFY COLUMN seuil_stock_alerte float; ALTER TABLE llx_product MODIFY COLUMN desiredstock float; -ALTER TABLE llx_product_warehouse_properties MODIFY COLUMN seuil_stock_alerte float; -ALTER TABLE llx_product_warehouse_properties MODIFY COLUMN desiredstock float; +ALTER TABLE llx_product_warehouse_properties MODIFY COLUMN seuil_stock_alerte float; +ALTER TABLE llx_product_warehouse_properties MODIFY COLUMN desiredstock float; ALTER TABLE llx_product ADD COLUMN fk_state integer DEFAULT NULL; @@ -330,3 +330,23 @@ ALTER TABLE llx_bank ADD COLUMN origin_type varchar(64) NULL; ALTER TABLE llx_bank ADD COLUMN import_key varchar(14); ALTER TABLE llx_menu MODIFY COLUMN enabled text; + +CREATE TABLE llx_ecm_files_extrafields +( + rowid integer AUTO_INCREMENT PRIMARY KEY, + tms timestamp, + fk_object integer NOT NULL, + import_key varchar(14) -- import key +) ENGINE=innodb; + +ALTER TABLE llx_ecm_files_extrafields ADD INDEX idx_ecm_files_extrafields (fk_object); + +CREATE TABLE llx_ecm_directories_extrafields +( + rowid integer AUTO_INCREMENT PRIMARY KEY, + tms timestamp, + fk_object integer NOT NULL, + import_key varchar(14) -- import key +) ENGINE=innodb; + +ALTER TABLE llx_ecm_directories_extrafields ADD INDEX idx_ecm_directories_extrafields (fk_object); diff --git a/htdocs/langs/en_US/ecm.lang b/htdocs/langs/en_US/ecm.lang index 369ac6dfdfa..aaf81b0f346 100644 --- a/htdocs/langs/en_US/ecm.lang +++ b/htdocs/langs/en_US/ecm.lang @@ -50,3 +50,6 @@ ReSyncListOfDir=Resync list of directories HashOfFileContent=Hash of file content NoDirectoriesFound=No directories found FileNotYetIndexedInDatabase=File not yet indexed into database (try to re-upload it) +ExtraFieldsEcmFiles=Extrafields Ecm Files +ExtraFieldsEcmDirectories=Extrafields Ecm Directories +ECMSetup=ECM Setup From b78e506e391d88861cc12c0ac435a83bf8b75532 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Fri, 2 Oct 2020 00:25:44 +0200 Subject: [PATCH 65/92] add files --- htdocs/admin/ecm_directories_extrafields.php | 123 ++++++++++++++++++ htdocs/admin/ecm_files_extrafields.php | 123 ++++++++++++++++++ .../llx_ecm_directories_extrafields.key.sql | 20 +++ .../llx_ecm_directories_extrafileds.sql | 26 ++++ .../tables/llx_ecm_files_extrafields.key.sql | 20 +++ .../tables/llx_ecm_files_extrafields.sql | 26 ++++ 6 files changed, 338 insertions(+) create mode 100644 htdocs/admin/ecm_directories_extrafields.php create mode 100644 htdocs/admin/ecm_files_extrafields.php create mode 100644 htdocs/install/mysql/tables/llx_ecm_directories_extrafields.key.sql create mode 100644 htdocs/install/mysql/tables/llx_ecm_directories_extrafileds.sql create mode 100644 htdocs/install/mysql/tables/llx_ecm_files_extrafields.key.sql create mode 100644 htdocs/install/mysql/tables/llx_ecm_files_extrafields.sql diff --git a/htdocs/admin/ecm_directories_extrafields.php b/htdocs/admin/ecm_directories_extrafields.php new file mode 100644 index 00000000000..71029c0fc67 --- /dev/null +++ b/htdocs/admin/ecm_directories_extrafields.php @@ -0,0 +1,123 @@ + + * Copyright (C) 2003 Jean-Louis Bergamo + * Copyright (C) 2004-2013 Laurent Destailleur + * Copyright (C) 2012 Regis Houssin + * Copyright (C) 2012 Florian Henry + * Copyright (C) 2013 Philippe Grand + * Copyright (C) 2015 Claudio Aschieri + * Copyright (C) 2020 Frédéric France + * + * 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 . + */ + +/** + * \file htdocs/admin/ecm_directories_extrafields.php + * \ingroup ecm + * \brief Page to setup extra fields of ecm + */ + +require '../main.inc.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/ecm.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; + + +if (!$user->admin) + accessforbidden(); + +// Load translation files required by the page +$langs->loadLangs(array('admin', 'other', 'ecm')); + + +$extrafields = new ExtraFields($db); +$form = new Form($db); + +// List of supported format +$tmptype2label = ExtraFields::$type2label; +$type2label = array(''); +foreach ($tmptype2label as $key => $val) { + $type2label[$key] = $langs->transnoentitiesnoconv($val); +} + +$action = GETPOST('action', 'aZ09'); +$attrname = GETPOST('attrname', 'alpha'); +$elementtype = 'ecm_directories'; //Must be the $table_element of the class that manage extrafield + +if (!$user->admin) { + accessforbidden(); +} + + +/* + * Actions + */ + +require DOL_DOCUMENT_ROOT.'/core/actions_extrafields.inc.php'; + + +/* + * View + */ + +$textobject = $langs->transnoentitiesnoconv("ECM"); + +llxHeader('', $langs->trans("ECMSetup")); + +$linkback = ''.$langs->trans("BackToModuleList").''; +print load_fiche_titre($langs->trans("ECMSetup"), $linkback, 'title_setup'); +print "
\n"; + +$head = ecm_admin_prepare_head(); + +dol_fiche_head($head, 'attributes_ecm_directories', $langs->trans("ECM"), -1, 'ecm'); + +require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php'; + +dol_fiche_end(); + + +// Buttons +if ($action != 'create' && $action != 'edit') { + print '
'; + print "".$langs->trans("NewAttribute").""; + print "
"; +} + + +/* ************************************************************************** */ +/* */ +/* Creation of an optional field */ +/* */ +/* ************************************************************************** */ + +if ($action == 'create') { + print '
'; + print load_fiche_titre($langs->trans('NewAttribute')); + require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php'; +} + +/* ************************************************************************** */ +/* */ +/* Edition of an optional field */ +/* */ +/* ************************************************************************** */ +if ($action == 'edit' && !empty($attrname)) { + print "
"; + print load_fiche_titre($langs->trans("FieldEdition", $attrname)); + require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php'; +} + +// End of page +llxFooter(); +$db->close(); diff --git a/htdocs/admin/ecm_files_extrafields.php b/htdocs/admin/ecm_files_extrafields.php new file mode 100644 index 00000000000..9d747d4f684 --- /dev/null +++ b/htdocs/admin/ecm_files_extrafields.php @@ -0,0 +1,123 @@ + + * Copyright (C) 2003 Jean-Louis Bergamo + * Copyright (C) 2004-2013 Laurent Destailleur + * Copyright (C) 2012 Regis Houssin + * Copyright (C) 2012 Florian Henry + * Copyright (C) 2013 Philippe Grand + * Copyright (C) 2015 Claudio Aschieri + * Copyright (C) 2020 Frédéric France + * + * 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 . + */ + +/** + * \file htdocs/admin/ecm_files_extrafields.php + * \ingroup ecm + * \brief Page to setup extra fields of ecm + */ + +require '../main.inc.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/ecm.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; + + +if (!$user->admin) + accessforbidden(); + +// Load translation files required by the page +$langs->loadLangs(array('admin', 'other', 'ecm')); + + +$extrafields = new ExtraFields($db); +$form = new Form($db); + +// List of supported format +$tmptype2label = ExtraFields::$type2label; +$type2label = array(''); +foreach ($tmptype2label as $key => $val) { + $type2label[$key] = $langs->transnoentitiesnoconv($val); +} + +$action = GETPOST('action', 'aZ09'); +$attrname = GETPOST('attrname', 'alpha'); +$elementtype = 'ecm_files'; //Must be the $table_element of the class that manage extrafield + +if (!$user->admin) { + accessforbidden(); +} + + +/* + * Actions + */ + +require DOL_DOCUMENT_ROOT.'/core/actions_extrafields.inc.php'; + + +/* + * View + */ + +$textobject = $langs->transnoentitiesnoconv("ECM"); + +llxHeader('', $langs->trans("ECMSetup")); + +$linkback = ''.$langs->trans("BackToModuleList").''; +print load_fiche_titre($langs->trans("ECMSetup"), $linkback, 'title_setup'); +print "
\n"; + +$head = ecm_admin_prepare_head(); + +dol_fiche_head($head, 'attributes_ecm_files', $langs->trans("ECM"), -1, 'ecm'); + +require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php'; + +dol_fiche_end(); + + +// Buttons +if ($action != 'create' && $action != 'edit') { + print '
'; + print "".$langs->trans("NewAttribute").""; + print "
"; +} + + +/* ************************************************************************** */ +/* */ +/* Creation of an optional field */ +/* */ +/* ************************************************************************** */ + +if ($action == 'create') { + print '
'; + print load_fiche_titre($langs->trans('NewAttribute')); + require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php'; +} + +/* ************************************************************************** */ +/* */ +/* Edition of an optional field */ +/* */ +/* ************************************************************************** */ +if ($action == 'edit' && !empty($attrname)) { + print "
"; + print load_fiche_titre($langs->trans("FieldEdition", $attrname)); + require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php'; +} + +// End of page +llxFooter(); +$db->close(); diff --git a/htdocs/install/mysql/tables/llx_ecm_directories_extrafields.key.sql b/htdocs/install/mysql/tables/llx_ecm_directories_extrafields.key.sql new file mode 100644 index 00000000000..a84fa2c845c --- /dev/null +++ b/htdocs/install/mysql/tables/llx_ecm_directories_extrafields.key.sql @@ -0,0 +1,20 @@ +-- =================================================================== +-- Copyright (C) 2020 Frédéric France +-- +-- 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 . +-- +-- =================================================================== + + +ALTER TABLE llx_ecm_directories_extrafields ADD INDEX idx_ecm_directories_extrafields (fk_object); diff --git a/htdocs/install/mysql/tables/llx_ecm_directories_extrafileds.sql b/htdocs/install/mysql/tables/llx_ecm_directories_extrafileds.sql new file mode 100644 index 00000000000..e2e496267ba --- /dev/null +++ b/htdocs/install/mysql/tables/llx_ecm_directories_extrafileds.sql @@ -0,0 +1,26 @@ +-- ======================================================================== +-- Copyright (C) 2020 Frédéric France +-- +-- 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 . +-- +-- ======================================================================== + +CREATE TABLE llx_ecm_directories_extrafields +( + rowid integer AUTO_INCREMENT PRIMARY KEY, + tms timestamp, + fk_object integer NOT NULL, + import_key varchar(14) -- import key +) ENGINE=innodb; + diff --git a/htdocs/install/mysql/tables/llx_ecm_files_extrafields.key.sql b/htdocs/install/mysql/tables/llx_ecm_files_extrafields.key.sql new file mode 100644 index 00000000000..3ebd3712184 --- /dev/null +++ b/htdocs/install/mysql/tables/llx_ecm_files_extrafields.key.sql @@ -0,0 +1,20 @@ +-- =================================================================== +-- Copyright (C) 2020 Frédéric France +-- +-- 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 . +-- +-- =================================================================== + + +ALTER TABLE llx_ecm_files_extrafields ADD INDEX idx_ecm_files_extrafields (fk_object); diff --git a/htdocs/install/mysql/tables/llx_ecm_files_extrafields.sql b/htdocs/install/mysql/tables/llx_ecm_files_extrafields.sql new file mode 100644 index 00000000000..0cf0de6d375 --- /dev/null +++ b/htdocs/install/mysql/tables/llx_ecm_files_extrafields.sql @@ -0,0 +1,26 @@ +-- ======================================================================== +-- Copyright (C) 2020 Frédéric France +-- +-- 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 . +-- +-- ======================================================================== + +CREATE TABLE llx_ecm_files_extrafields +( + rowid integer AUTO_INCREMENT PRIMARY KEY, + tms timestamp, + fk_object integer NOT NULL, + import_key varchar(14) -- import key +) ENGINE=innodb; + From 16ff15b48cd0f96d1b6879dba1e5b7c056460f22 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Fri, 2 Oct 2020 00:29:36 +0200 Subject: [PATCH 66/92] fix --- htdocs/admin/ecm.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/admin/ecm.php b/htdocs/admin/ecm.php index 91236c33bd7..e11434c45d6 100644 --- a/htdocs/admin/ecm.php +++ b/htdocs/admin/ecm.php @@ -73,7 +73,7 @@ print '
'; $head = ecm_admin_prepare_head(); -dol_fiche_head($head, 'ecm', $langs->trans("Sendings"), -1, 'ecm'); +dol_fiche_head($head, 'ecm', $langs->trans("ECM"), -1, 'ecm'); print ''; print ''; From 813deee4a512b5e3ac7a3542ef58fc1591ba4bbf Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 2 Oct 2020 01:14:43 +0200 Subject: [PATCH 67/92] Fix phpcs --- htdocs/accountancy/admin/journals_list.php | 2 +- htdocs/comm/action/card.php | 9 +++------ htdocs/core/lib/payments.lib.php | 5 ++--- 3 files changed, 6 insertions(+), 10 deletions(-) diff --git a/htdocs/accountancy/admin/journals_list.php b/htdocs/accountancy/admin/journals_list.php index 687ca02c91d..ebfa44e959f 100644 --- a/htdocs/accountancy/admin/journals_list.php +++ b/htdocs/accountancy/admin/journals_list.php @@ -22,7 +22,7 @@ * \brief Setup page to configure journals */ -if (! defined('CSRFCHECK_WITH_TOKEN')) define('CSRFCHECK_WITH_TOKEN','1'); // Force use of CSRF protection with tokens even for GET +if (!defined('CSRFCHECK_WITH_TOKEN')) define('CSRFCHECK_WITH_TOKEN','1'); // Force use of CSRF protection with tokens even for GET require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formadmin.class.php'; diff --git a/htdocs/comm/action/card.php b/htdocs/comm/action/card.php index cb63813139d..3c8ed94c2bf 100644 --- a/htdocs/comm/action/card.php +++ b/htdocs/comm/action/card.php @@ -1709,8 +1709,8 @@ if ($id > 0) // Reminders if ($conf->global->AGENDA_REMINDER_EMAIL || $conf->global->AGENDA_REMINDER_BROWSER) { - $filtreuserid = $user->id; - if ($user->rights->agenda->allactions->read) $filtreuserid = 0; + $filteruserid = $user->id; + if ($user->rights->agenda->allactions->read) $filteruserid = 0; $object->loadReminders('', $filteruserid, false); print '
'; @@ -1721,10 +1721,7 @@ if ($id > 0) $firstreminderId = array_shift($keys); $actionCommReminder = $object->reminders[$firstreminderId]; - - } - else - { + } else { $checked = ''; $actionCommReminder = new ActionCommReminder($db); $actionCommReminder->offsetvalue = 10; diff --git a/htdocs/core/lib/payments.lib.php b/htdocs/core/lib/payments.lib.php index 02b5727e174..4fb593e354d 100644 --- a/htdocs/core/lib/payments.lib.php +++ b/htdocs/core/lib/payments.lib.php @@ -59,12 +59,11 @@ function payment_prepare_head(Paiement $object) * Returns an array with the tabs for the "Bannkline" section * It loads tabs from modules looking for the entity payment * - * @param Bankline $object Current payment object - * @return array Tabs for the Bankline section + * @param int $id ID of bank line + * @return array Tabs for the Bankline section */ function bankline_prepare_head($id) { - global $langs, $conf; $h = 0; From e1d156973b320c62df361ec2a014bffc2bc11886 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 2 Oct 2020 02:08:04 +0200 Subject: [PATCH 68/92] phpcs --- htdocs/accountancy/admin/journals_list.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/accountancy/admin/journals_list.php b/htdocs/accountancy/admin/journals_list.php index ebfa44e959f..e48ee43ef8d 100644 --- a/htdocs/accountancy/admin/journals_list.php +++ b/htdocs/accountancy/admin/journals_list.php @@ -22,7 +22,7 @@ * \brief Setup page to configure journals */ -if (!defined('CSRFCHECK_WITH_TOKEN')) define('CSRFCHECK_WITH_TOKEN','1'); // Force use of CSRF protection with tokens even for GET +if (!defined('CSRFCHECK_WITH_TOKEN')) define('CSRFCHECK_WITH_TOKEN', '1'); // Force use of CSRF protection with tokens even for GET require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formadmin.class.php'; From 4e494611437de12d8d4747265a5f6a7a008550e9 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 2 Oct 2020 02:11:04 +0200 Subject: [PATCH 69/92] code comment --- htdocs/main.inc.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index 69f985db0b9..1344287044e 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -373,7 +373,9 @@ if ((!defined('NOCSRFCHECK') && empty($dolibarr_nocsrfcheck) && !empty($conf->gl || defined('CSRFCHECK_WITH_TOKEN')) // Check validity of token, only if option MAIN_SECURITY_CSRF_WITH_TOKEN enabled or if constant CSRFCHECK_WITH_TOKEN is set { // Check all cases that need a token (all POST actions, all actions and mass actions on pages with CSRFCHECK_WITH_TOKEN set, all sensitive GET actions) - if ($_SERVER['REQUEST_METHOD'] == 'POST' || ((GETPOSTISSET('action') || GETPOSTISSET('massaction')) && defined('CSRFCHECK_WITH_TOKEN')) || in_array(GETPOST('action', 'aZ09'), array('add', 'addtimespent', 'update', 'install', 'delete', 'deleteprof', 'deletepayment'))) + if ($_SERVER['REQUEST_METHOD'] == 'POST' || + ((GETPOSTISSET('action') || GETPOSTISSET('massaction')) && defined('CSRFCHECK_WITH_TOKEN')) || + in_array(GETPOST('action', 'aZ09'), array('add', 'addtimespent', 'update', 'install', 'delete', 'deleteprof', 'deletepayment'))) { if (!GETPOSTISSET('token')) { dol_syslog("--- Access to ".$_SERVER["PHP_SELF"]." refused by CSRFCHECK_WITH_TOKEN protection. Token not provided."); From ce0fa53cb0320fc961bfd5df29948cb3b08d016c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 2 Oct 2020 03:07:31 +0200 Subject: [PATCH 70/92] Fix delete of file from file manager --- htdocs/core/class/html.form.class.php | 3 +-- htdocs/website/index.php | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 7bf559240d9..0a186c02d92 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -4047,7 +4047,7 @@ class Form { global $langs, $conf; - $more = ''; + $more = ''; $formconfirm = ''; $inputok = array(); $inputko = array(); @@ -4232,7 +4232,6 @@ class Form }); } var urljump = pageyes + (pageyes.indexOf("?") < 0 ? "?" : "") + options; - //alert(urljump); if (pageyes.length > 0) { location.href = urljump; } $(this).dialog("close"); }, diff --git a/htdocs/website/index.php b/htdocs/website/index.php index 89ef1785186..fed5be51e87 100644 --- a/htdocs/website/index.php +++ b/htdocs/website/index.php @@ -2433,7 +2433,7 @@ if (!GETPOST('hide_websitemenu')) print ''; } } else { - print ''; + print ''; } From d976d474df10bfd4aa39e62d97fde537b49ebb5f Mon Sep 17 00:00:00 2001 From: Nicolas Date: Fri, 2 Oct 2020 08:42:48 +0200 Subject: [PATCH 71/92] NEW Hook on propal card --- htdocs/comm/propal/card.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php index 8febd8868e9..312a4865a22 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -13,6 +13,7 @@ * Copyright (C) 2014 Ferran Marcet * Copyright (C) 2016 Marcos García * Copyright (C) 2018-2019 Frédéric France + * Copyright (C) 2020 Nicolas ZABOURI * * 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 @@ -2368,6 +2369,10 @@ if ($action == 'create') $parameters = array(); $reshook = $hookmanager->executeHooks('formAddObjectLine', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + }else + { + $parameters = array(); + $reshook = $hookmanager->executeHooks('formEditObjectLine', $parameters, $object, $action); // Note that $action and $object may have been modified by hook } } From 4707ea2a27653b6df1464b9cf06e7a73cf862bb8 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Fri, 2 Oct 2020 06:48:14 +0000 Subject: [PATCH 72/92] Fixing style errors. --- htdocs/comm/propal/card.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php index 312a4865a22..536754214e4 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -2369,8 +2369,7 @@ if ($action == 'create') $parameters = array(); $reshook = $hookmanager->executeHooks('formAddObjectLine', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - }else - { + }else { $parameters = array(); $reshook = $hookmanager->executeHooks('formEditObjectLine', $parameters, $object, $action); // Note that $action and $object may have been modified by hook } From e72fbbfe170c598bde6028ae9c912718f1f3003f Mon Sep 17 00:00:00 2001 From: Nicolas Date: Fri, 2 Oct 2020 09:21:44 +0200 Subject: [PATCH 73/92] Hide the label into pdf document for variants --- htdocs/core/lib/pdf.lib.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/htdocs/core/lib/pdf.lib.php b/htdocs/core/lib/pdf.lib.php index deacc6c128b..1f572607acd 100644 --- a/htdocs/core/lib/pdf.lib.php +++ b/htdocs/core/lib/pdf.lib.php @@ -1315,7 +1315,11 @@ function pdf_getlinedesc($object, $i, $outputlangs, $hideref = 0, $hidedesc = 0, { $libelleproduitservice = $desc."\n".$libelleproduitservice; } else { - $libelleproduitservice .= $desc; + if (!empty($conf->global->HIDE_LABEL_VARIANT_PDF)) { + $libelleproduitservice = $desc; + } else { + $libelleproduitservice .= $desc; + } } } } else { From 85dfb5bf3ce7c9e1adae31b755629d2b376f9bc8 Mon Sep 17 00:00:00 2001 From: Nicolas Date: Fri, 2 Oct 2020 09:27:01 +0200 Subject: [PATCH 74/92] Hide the label into pdf document for variants --- htdocs/core/lib/pdf.lib.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/core/lib/pdf.lib.php b/htdocs/core/lib/pdf.lib.php index 1f572607acd..88a2850ca59 100644 --- a/htdocs/core/lib/pdf.lib.php +++ b/htdocs/core/lib/pdf.lib.php @@ -11,6 +11,7 @@ * Copyright (C) 2014 Teddy Andreotti <125155@supinfo.com> * Copyright (C) 2015-2016 Marcos García * Copyright (C) 2019 Lenin Rivas + * Copyright (C) 2020 Nicolas ZABOURI * * 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 9e4e027495327c04fe6472087952629d7f186260 Mon Sep 17 00:00:00 2001 From: Nicolas Date: Fri, 2 Oct 2020 09:39:42 +0200 Subject: [PATCH 75/92] Hide label --- htdocs/core/lib/pdf.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/pdf.lib.php b/htdocs/core/lib/pdf.lib.php index 88a2850ca59..ae26d4f9da6 100644 --- a/htdocs/core/lib/pdf.lib.php +++ b/htdocs/core/lib/pdf.lib.php @@ -1316,7 +1316,7 @@ function pdf_getlinedesc($object, $i, $outputlangs, $hideref = 0, $hidedesc = 0, { $libelleproduitservice = $desc."\n".$libelleproduitservice; } else { - if (!empty($conf->global->HIDE_LABEL_VARIANT_PDF)) { + if (!empty($conf->global->HIDE_LABEL_VARIANT_PDF) && $prodser->isVariant()) { $libelleproduitservice = $desc; } else { $libelleproduitservice .= $desc; From f31e689480d81af0b52aeca99e6e87fcbcaf2e50 Mon Sep 17 00:00:00 2001 From: John Botella Date: Fri, 2 Oct 2020 09:39:54 +0200 Subject: [PATCH 76/92] Fix new look and feel --- htdocs/commande/list.php | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/htdocs/commande/list.php b/htdocs/commande/list.php index ab284c4af8c..666d894bdda 100644 --- a/htdocs/commande/list.php +++ b/htdocs/commande/list.php @@ -813,12 +813,10 @@ if ($resql) { print '
'; } From a7b4f0ec49267519dfff01ba44e9185d3f6bfc97 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Fri, 2 Oct 2020 07:43:29 +0000 Subject: [PATCH 77/92] Fixing style errors. --- htdocs/commande/list.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/commande/list.php b/htdocs/commande/list.php index 666d894bdda..ae73b23a876 100644 --- a/htdocs/commande/list.php +++ b/htdocs/commande/list.php @@ -56,9 +56,9 @@ $toselect = GETPOST('toselect', 'array'); $contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'orderlist'; $search_datecloture_start = GETPOST('search_datecloture_start', 'int'); -if(empty($search_datecloture_start)) $search_datecloture_start = dol_mktime(0, 0, 0, GETPOST('search_datecloture_startmonth', 'int'), GETPOST('search_datecloture_startday', 'int'), GETPOST('search_datecloture_startyear', 'int')); +if (empty($search_datecloture_start)) $search_datecloture_start = dol_mktime(0, 0, 0, GETPOST('search_datecloture_startmonth', 'int'), GETPOST('search_datecloture_startday', 'int'), GETPOST('search_datecloture_startyear', 'int')); $search_datecloture_end = GETPOST('search_datecloture_end', 'int'); -if(empty($search_datecloture_end)) $search_datecloture_end = dol_mktime(23, 59, 59, GETPOST('search_datecloture_endmonth', 'int'), GETPOST('search_datecloture_endday', 'int'), GETPOST('search_datecloture_endyear', 'int')); +if (empty($search_datecloture_end)) $search_datecloture_end = dol_mktime(23, 59, 59, GETPOST('search_datecloture_endmonth', 'int'), GETPOST('search_datecloture_endday', 'int'), GETPOST('search_datecloture_endyear', 'int')); $search_dateorder_start = dol_mktime(0, 0, 0, GETPOST('search_dateorder_startmonth', 'int'), GETPOST('search_dateorder_startday', 'int'), GETPOST('search_dateorder_startyear', 'int')); $search_dateorder_end = dol_mktime(23, 59, 59, GETPOST('search_dateorder_endmonth', 'int'), GETPOST('search_dateorder_endday', 'int'), GETPOST('search_dateorder_endyear', 'int')); $search_datedelivery_start = dol_mktime(0, 0, 0, GETPOST('search_datedelivery_startmonth', 'int'), GETPOST('search_datedelivery_startday', 'int'), GETPOST('search_datedelivery_startyear', 'int')); @@ -813,7 +813,7 @@ if ($resql) { print ''; } - if ($object->fk_statut < 3) + if ($object->status < 3) { print ''; print ''; // Approbator @@ -1583,7 +1583,7 @@ if ($action == 'create') print ''; } - if ($object->fk_statut == 6) + if ($object->status == 6) { print ''; print ''; @@ -1618,7 +1618,7 @@ if ($action == 'create') if (!empty($user->rights->expensereport->readall)) $criteriaforfilter = ''; $formquestion = array( 'text' => '', - array('type' => 'other', 'name' => 'fk_user_author', 'label' => $langs->trans("SelectTargetUser"), 'value' => $form->select_dolusers((GETPOST('fk_user_author', 'int') > 0 ? GETPOST('fk_user_author', 'int') : $user->id), 'fk_user_author', 0, null, 0, $criteriaforfilter)) + array('type' => 'other', 'name' => 'fk_user_author', 'label' => $langs->trans("SelectTargetUser"), 'value' => $form->select_dolusers((GETPOST('fk_user_author', 'int') > 0 ? GETPOST('fk_user_author', 'int') : $user->id), 'fk_user_author', 0, null, 0, $criteriaforfilter, '', '0', 0, 0, '', 0, '', 'maxwidth150')) ); // Paiement incomplet. On demande si motif = escompte ou autre $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ToClone'), $langs->trans('ConfirmCloneExpenseReport', $object->ref), 'confirm_clone', $formquestion, 'yes', 1); @@ -1763,7 +1763,7 @@ if ($action == 'create') print ''; // User to inform for approval - if ($object->fk_statut <= ExpenseReport::STATUS_VALIDATED) // informed + if ($object->status <= ExpenseReport::STATUS_VALIDATED) // informed { print ''; print ''; // approver @@ -1780,7 +1780,7 @@ if ($action == 'create') } } print ''; - } elseif ($object->fk_statut == ExpenseReport::STATUS_CANCELED) + } elseif ($object->status == ExpenseReport::STATUS_CANCELED) { print ''; print ''; @@ -1819,7 +1819,7 @@ if ($action == 'create') print ''; } - if ($object->fk_statut == 99 || !empty($object->detail_refuse)) + if ($object->status == 99 || !empty($object->detail_refuse)) { print ''; print ''; @@ -1837,7 +1837,7 @@ if ($action == 'create') print ''; } - if ($object->fk_statut == $object::STATUS_CLOSED) + if ($object->status == $object::STATUS_CLOSED) { /* TODO this fields are not yet filled print ''; @@ -1872,11 +1872,11 @@ if ($action == 'create') print ''; print ''; $rowspan = 5; - if ($object->fk_statut <= ExpenseReport::STATUS_VALIDATED) $rowspan++; - elseif ($object->fk_statut == ExpenseReport::STATUS_CANCELED) $rowspan += 2; + if ($object->status <= ExpenseReport::STATUS_VALIDATED) $rowspan++; + elseif ($object->status == ExpenseReport::STATUS_CANCELED) $rowspan += 2; else $rowspan += 2; - if ($object->fk_statut == ExpenseReport::STATUS_REFUSED || !empty($object->detail_refuse)) $rowspan += 2; - if ($object->fk_statut == ExpenseReport::STATUS_CLOSED) $rowspan += 2; + if ($object->status == ExpenseReport::STATUS_REFUSED || !empty($object->detail_refuse)) $rowspan += 2; + if ($object->status == ExpenseReport::STATUS_CLOSED) $rowspan += 2; print ""; print ''; @@ -2010,7 +2010,7 @@ if ($action == 'create') print '
'; $actiontouse = 'updateline'; - if (($object->fk_statut == 0 || $object->fk_statut == 99) && $action != 'editline') $actiontouse = 'addline'; + if (($object->status == 0 || $object->status == 99) && $action != 'editline') $actiontouse = 'addline'; print ''; print ''; @@ -2046,7 +2046,7 @@ if ($action == 'create') print ''; // Ajout des boutons de modification/suppression - if (($object->fk_statut < 2 || $object->fk_statut == 99) && $user->rights->expensereport->creer) + if (($object->status < 2 || $object->status == 99) && $user->rights->expensereport->creer) { print ''; } @@ -2195,7 +2195,7 @@ if ($action == 'create') print ''; // Ajout des boutons de modification/suppression - if (($object->fk_statut < ExpenseReport::STATUS_VALIDATED || $object->fk_statut == ExpenseReport::STATUS_REFUSED) && $user->rights->expensereport->creer) + if (($object->status < ExpenseReport::STATUS_VALIDATED || $object->status == ExpenseReport::STATUS_REFUSED) && $user->rights->expensereport->creer) { print ''; print ''; print ''; - print ''; - print ''; + print ''; print ''; if ($num) { @@ -214,6 +216,7 @@ if (!empty($conf->holiday->enabled) && $user->rights->holiday->read) $holidaystatic->id = $obj->rowid; $holidaystatic->ref = $obj->ref; + $holidaystatic->statut = $obj->status; $userstatic->id = $obj->uid; $userstatic->lastname = $obj->lastname; @@ -221,7 +224,7 @@ if (!empty($conf->holiday->enabled) && $user->rights->holiday->read) $userstatic->login = $obj->login; $userstatic->photo = $obj->photo; $userstatic->email = $obj->email; - $userstatic->statut = $obj->statut; + $userstatic->statut = $obj->user_status; print ''; print ''; @@ -231,10 +234,10 @@ if (!empty($conf->holiday->enabled) && $user->rights->holiday->read) $starthalfday = ($obj->halfday == -1 || $obj->halfday == 2) ? 'afternoon' : 'morning'; $endhalfday = ($obj->halfday == 1 || $obj->halfday == 2) ? 'morning' : 'afternoon'; - print ''; - print ''; + print ''; print ''; $i++; @@ -252,7 +255,8 @@ if (!empty($conf->holiday->enabled) && $user->rights->holiday->read) // Latest expense report if (!empty($conf->expensereport->enabled) && $user->rights->expensereport->lire) { - $sql = "SELECT u.rowid as uid, u.lastname, u.firstname, u.login, u.email, u.statut, u.photo, x.rowid, x.ref, x.date_debut as date, x.tms as dm, x.total_ttc, x.fk_statut as status"; + $sql = "SELECT u.rowid as uid, u.lastname, u.firstname, u.login, u.email, u.statut as user_status, u.photo,"; + $sql .= " x.rowid, x.ref, x.date_debut as date, x.tms as dm, x.total_ttc, x.fk_statut as status"; $sql .= " FROM ".MAIN_DB_PREFIX."expensereport as x, ".MAIN_DB_PREFIX."user as u"; //if (!$user->rights->societe->client->voir && !$user->socid) $sql.= ", ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql .= " WHERE u.rowid = x.fk_user_author"; @@ -275,8 +279,7 @@ if (!empty($conf->expensereport->enabled) && $user->rights->expensereport->lire) print ''; print ''; print ''; - print ''; - print ''; + print ''; print ''; if ($num) { @@ -290,13 +293,14 @@ if (!empty($conf->expensereport->enabled) && $user->rights->expensereport->lire) $expensereportstatic->id = $obj->rowid; $expensereportstatic->ref = $obj->ref; + $expensereportstatic->statut = $obj->status; $userstatic->id = $obj->uid; $userstatic->lastname = $obj->lastname; $userstatic->firstname = $obj->firstname; $userstatic->email = $obj->email; $userstatic->login = $obj->login; - $userstatic->statut = $obj->statut; + $userstatic->statut = $obj->user_status; $userstatic->photo = $obj->photo; print ''; @@ -304,7 +308,7 @@ if (!empty($conf->expensereport->enabled) && $user->rights->expensereport->lire) print ''; print ''; print ''; - print ''; + print ''; print ''; $i++; @@ -314,10 +318,75 @@ if (!empty($conf->expensereport->enabled) && $user->rights->expensereport->lire) } print '
'; print '
'; - print $langs->trans('From').' '; - print $form->selectDate($search_datecloture_start ? $search_datecloture_start : -1, 'search_datecloture_start', 0, 0, 1); + print $form->selectDate($search_datecloture_start ? $search_datecloture_start : -1, 'search_datecloture_start', 0, 0, 1,'', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From')); print '
'; print '
'; - print $langs->trans('to').' '; - print $form->selectDate($search_datecloture_end ? $search_datecloture_end : -1, 'search_datecloture_end', 0, 0, 1); + print $form->selectDate($search_datecloture_end ? $search_datecloture_end : -1, 'search_datecloture_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to')); print '
'; print '
'; print '
'; - print $form->selectDate($search_datecloture_start ? $search_datecloture_start : -1, 'search_datecloture_start', 0, 0, 1,'', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From')); + print $form->selectDate($search_datecloture_start ? $search_datecloture_start : -1, 'search_datecloture_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From')); print '
'; print '
'; print $form->selectDate($search_datecloture_end ? $search_datecloture_end : -1, 'search_datecloture_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to')); From 1bbd4da0fead02eead89dbe682d073d6b1a9ab4a Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Fri, 2 Oct 2020 10:36:16 +0200 Subject: [PATCH 78/92] add missing translation --- htdocs/commande/contact.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/commande/contact.php b/htdocs/commande/contact.php index f44813a4994..2a1042c4347 100644 --- a/htdocs/commande/contact.php +++ b/htdocs/commande/contact.php @@ -33,7 +33,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; // Load translation files required by the page -$langs->loadLangs(array('orders', 'sendings', 'companies')); +$langs->loadLangs(array('orders', 'sendings', 'companies', 'bills')); $id = GETPOST('id', 'int'); $ref = GETPOST('ref', 'alpha'); From 18c946dc759231c5b076318bf9fae4eebc43d7fa Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Fri, 2 Oct 2020 10:37:02 +0200 Subject: [PATCH 79/92] add missing translation --- htdocs/commande/document.php | 2 +- htdocs/commande/info.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/commande/document.php b/htdocs/commande/document.php index 27d38378bcb..ab4f3990b78 100644 --- a/htdocs/commande/document.php +++ b/htdocs/commande/document.php @@ -37,7 +37,7 @@ if (!empty($conf->projet->enabled)) { } // Load translation files required by the page -$langs->loadLangs(array('companies', 'other')); +$langs->loadLangs(array('companies', 'other', 'bills')); $action = GETPOST('action', 'aZ09'); $confirm = GETPOST('confirm'); diff --git a/htdocs/commande/info.php b/htdocs/commande/info.php index 9b45bf66312..d08e8148101 100644 --- a/htdocs/commande/info.php +++ b/htdocs/commande/info.php @@ -34,7 +34,7 @@ if (!empty($conf->projet->enabled)) { if (!$user->rights->commande->lire) accessforbidden(); // Load translation files required by the page -$langs->loadLangs(array('orders', 'sendings')); +$langs->loadLangs(array('orders', 'sendings', 'bills')); $socid = 0; $comid = GETPOST("id", 'int'); From 0893f0250a4e0331e45a1e1a02aaaa480cd4cafb Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 2 Oct 2020 12:54:56 +0200 Subject: [PATCH 80/92] Minor bug fixes --- htdocs/core/lib/expensereport.lib.php | 2 +- htdocs/expensereport/card.php | 68 ++++++------- .../class/expensereport.class.php | 58 +++++++---- htdocs/hrm/index.php | 95 ++++++++++++++++--- htdocs/recruitment/recruitmentindex.php | 14 ++- 5 files changed, 166 insertions(+), 71 deletions(-) diff --git a/htdocs/core/lib/expensereport.lib.php b/htdocs/core/lib/expensereport.lib.php index c4e68356349..e7a6b897fdb 100644 --- a/htdocs/core/lib/expensereport.lib.php +++ b/htdocs/core/lib/expensereport.lib.php @@ -94,7 +94,7 @@ function payment_expensereport_prepare_head(PaymentExpenseReport $object) $head = array(); $head[$h][0] = DOL_URL_ROOT.'/expensereport/payment/card.php?id='.$object->id; - $head[$h][1] = $langs->trans("ExpenseReport"); + $head[$h][1] = $langs->trans("ExpenseReportPayment"); $head[$h][2] = 'payment'; $h++; diff --git a/htdocs/expensereport/card.php b/htdocs/expensereport/card.php index 34c33f5aaab..2e826cb4080 100644 --- a/htdocs/expensereport/card.php +++ b/htdocs/expensereport/card.php @@ -225,7 +225,7 @@ if (empty($reshook)) $fuser = new User($db); $fuser->fetch($object->fk_user_author); - $object->fk_statut = 1; + $object->status = 1; $object->fk_c_paiement = GETPOST('fk_c_paiement', 'int'); $object->fk_user_validator = GETPOST('fk_user_validator', 'int'); $object->note_public = GETPOST('note_public', 'restricthtml'); @@ -275,7 +275,7 @@ if (empty($reshook)) $object->date_debut = $date_start; $object->date_fin = $date_end; - if ($object->fk_statut < 3) + if ($object->status < 3) { $object->fk_user_validator = GETPOST('fk_user_validator', 'int'); } @@ -288,7 +288,7 @@ if (empty($reshook)) $result = $object->update($user); if ($result > 0) { - header("Location: ".$_SERVER["PHP_SELF"]."?id=".$_POST['id']); + header("Location: ".$_SERVER["PHP_SELF"]."?id=".GETPOST('id', 'int')); exit; } else { setEventMessages($object->error, $object->errors, 'errors'); @@ -1505,7 +1505,7 @@ if ($action == 'create') $head = expensereport_prepare_head($object); - if ($action == 'edit' && ($object->fk_statut < 3 || $object->fk_statut == 99)) + if ($action == 'edit' && ($object->status < 3 || $object->status == 99)) { print "
\n"; print ''; @@ -1513,7 +1513,7 @@ if ($action == 'create') dol_fiche_head($head, 'card', $langs->trans("ExpenseReport"), 0, 'trip'); - if ($object->fk_statut == 99) + if ($object->status == 99) { print ''; } else { @@ -1563,7 +1563,7 @@ if ($action == 'create') print '
'.$langs->trans("VALIDATOR").'
'.$langs->trans("AUTHORPAIEMENT").'
'.$langs->trans("VALIDATOR").'
'.$langs->trans("CANCEL_USER").'
'.$langs->trans("REFUSEUR").'
'.$langs->trans("AmountHT").''.price($object->total_ht, 1, '', 1, - 1, - 1, $conf->currency).'
'; print ''; @@ -2349,7 +2349,7 @@ if ($action == 'create') } // Add a new line - if (($object->fk_statut == ExpenseReport::STATUS_DRAFT || $object->fk_statut == ExpenseReport::STATUS_REFUSED) + if (($object->status == ExpenseReport::STATUS_DRAFT || $object->status == ExpenseReport::STATUS_REFUSED) && $action != 'editline' && $user->rights->expensereport->creer) { @@ -2549,7 +2549,7 @@ if ($action != 'create' && $action != 'edit') // Send if (empty($user->socid)) { - if ($object->fk_statut > ExpenseReport::STATUS_DRAFT) { + if ($object->status > ExpenseReport::STATUS_DRAFT) { //if ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) || $user->rights->expensereport->expensereport_advance->send)) { print ''; //} else @@ -2562,7 +2562,7 @@ if ($action != 'create' && $action != 'edit') * ET fk_user_author == user courant * Afficher : "Enregistrer" / "Modifier" / "Supprimer" */ - if ($user->rights->expensereport->creer && $object->fk_statut == ExpenseReport::STATUS_DRAFT) + if ($user->rights->expensereport->creer && $object->status == ExpenseReport::STATUS_DRAFT) { if (in_array($object->fk_user_author, $user->getAllChildIds(1)) || !empty($user->rights->expensereport->writeall_advance)) { @@ -2582,7 +2582,7 @@ if ($action != 'create' && $action != 'edit') * ET fk_user_author == user courant * Afficher : "Enregistrer" / "Modifier" / "Supprimer" */ - if ($user->rights->expensereport->creer && $object->fk_statut == ExpenseReport::STATUS_REFUSED) + if ($user->rights->expensereport->creer && $object->status == ExpenseReport::STATUS_REFUSED) { if ($user->id == $object->fk_user_author || $user->id == $object->fk_user_valid) { @@ -2596,7 +2596,7 @@ if ($action != 'create' && $action != 'edit') } } - if ($user->rights->expensereport->to_paid && $object->fk_statut == ExpenseReport::STATUS_APPROVED) + if ($user->rights->expensereport->to_paid && $object->status == ExpenseReport::STATUS_APPROVED) { if ($user->id == $object->fk_user_author || $user->id == $object->fk_user_valid) { @@ -2610,7 +2610,7 @@ if ($action != 'create' && $action != 'edit') * ET fk_user_validator == user courant * Afficher : "Valider" / "Refuser" / "Supprimer" */ - if ($object->fk_statut == ExpenseReport::STATUS_VALIDATED) + if ($object->status == ExpenseReport::STATUS_VALIDATED) { if (in_array($object->fk_user_author, $user->getAllChildIds(1))) { @@ -2619,7 +2619,7 @@ if ($action != 'create' && $action != 'edit') } } - if ($user->rights->expensereport->approve && $object->fk_statut == ExpenseReport::STATUS_VALIDATED) + if ($user->rights->expensereport->approve && $object->status == ExpenseReport::STATUS_VALIDATED) { //if($object->fk_user_validator==$user->id) //{ @@ -2640,13 +2640,13 @@ if ($action != 'create' && $action != 'edit') // If status is Approved // --------------------- - if ($user->rights->expensereport->approve && $object->fk_statut == ExpenseReport::STATUS_APPROVED) + if ($user->rights->expensereport->approve && $object->status == ExpenseReport::STATUS_APPROVED) { print ''; } // If bank module is used - if ($user->rights->expensereport->to_paid && !empty($conf->banque->enabled) && $object->fk_statut == ExpenseReport::STATUS_APPROVED) + if ($user->rights->expensereport->to_paid && !empty($conf->banque->enabled) && $object->status == ExpenseReport::STATUS_APPROVED) { // Pay if ($remaintopay == 0) @@ -2658,7 +2658,7 @@ if ($action != 'create' && $action != 'edit') } // If bank module is not used - if (($user->rights->expensereport->to_paid || empty($conf->banque->enabled)) && $object->fk_statut == ExpenseReport::STATUS_APPROVED) + if (($user->rights->expensereport->to_paid || empty($conf->banque->enabled)) && $object->status == ExpenseReport::STATUS_APPROVED) { //if ((round($remaintopay) == 0 || empty($conf->banque->enabled)) && $object->paid == 0) if ($object->paid == 0) @@ -2667,20 +2667,20 @@ if ($action != 'create' && $action != 'edit') } } - if ($user->rights->expensereport->creer && ($user->id == $object->fk_user_author || $user->id == $object->fk_user_valid) && $object->fk_statut == ExpenseReport::STATUS_APPROVED) + if ($user->rights->expensereport->creer && ($user->id == $object->fk_user_author || $user->id == $object->fk_user_valid) && $object->status == ExpenseReport::STATUS_APPROVED) { // Cancel print ''; } // TODO Replace this. It should be SetUnpaid and should go back to status unpaid not canceled. - if (($user->rights->expensereport->approve || $user->rights->expensereport->to_paid) && $object->fk_statut == ExpenseReport::STATUS_CLOSED) + if (($user->rights->expensereport->approve || $user->rights->expensereport->to_paid) && $object->status == ExpenseReport::STATUS_CLOSED) { // Cancel print ''; } - if ($user->rights->expensereport->to_paid && $object->paid && $object->fk_statut == ExpenseReport::STATUS_CLOSED) + if ($user->rights->expensereport->to_paid && $object->paid && $object->status == ExpenseReport::STATUS_CLOSED) { // Set unpaid print ''; @@ -2692,11 +2692,11 @@ if ($action != 'create' && $action != 'edit') } /* If draft, validated, cancel, and user can create, he can always delete its card before it is approved */ - if ($user->rights->expensereport->creer && $user->id == $object->fk_user_author && $object->fk_statut < ExpenseReport::STATUS_APPROVED) + if ($user->rights->expensereport->creer && $user->id == $object->fk_user_author && $object->status < ExpenseReport::STATUS_APPROVED) { // Delete print ''; - } elseif ($user->rights->expensereport->supprimer && $object->fk_statut != ExpenseReport::STATUS_CLOSED) + } elseif ($user->rights->expensereport->supprimer && $object->status != ExpenseReport::STATUS_CLOSED) { // Delete print ''; diff --git a/htdocs/expensereport/class/expensereport.class.php b/htdocs/expensereport/class/expensereport.class.php index b06e34eb92a..b32e95597e8 100644 --- a/htdocs/expensereport/class/expensereport.class.php +++ b/htdocs/expensereport/class/expensereport.class.php @@ -64,6 +64,13 @@ class ExpenseReport extends CommonObject * @var int Status */ public $status; + + /** + * 0=draft, 2=validated (attente approb), 4=canceled, 5=approved, 6=payed, 99=denied + * + * @var int Status + * @deprecated + */ public $fk_statut; public $fk_c_paiement; @@ -398,7 +405,7 @@ class ExpenseReport extends CommonObject $this->id = 0; $this->ref = ''; $this->status = 0; - $this->fk_statut = 0; + $this->fk_statut = 0; // deprecated // Clear fields $this->fk_user_author = $fk_user_author; // Note fk_user_author is not the 'author' but the guy the expense report is for. @@ -407,6 +414,15 @@ class ExpenseReport extends CommonObject $this->date_creation = ''; $this->date_validation = ''; + // Remove link on lines to a joined file + if (is_array($this->lines) && count($this->lines) > 0) + { + foreach ($this->lines as $key => $line) + { + $this->lines[$key]->fk_ecm_files = 0; + } + } + // Create clone $this->context['createfromclone'] = 'createfromclone'; $result = $this->create($user); @@ -578,7 +594,7 @@ class ExpenseReport extends CommonObject $this->fk_c_paiement = $obj->fk_c_paiement; $this->paid = $obj->paid; - if ($this->fk_statut == self::STATUS_APPROVED || $this->fk_statut == self::STATUS_CLOSED) + if ($this->status == self::STATUS_APPROVED || $this->status == self::STATUS_CLOSED) { $user_valid = new User($this->db); if ($this->fk_user_valid > 0) $user_valid->fetch($this->fk_user_valid); @@ -668,9 +684,9 @@ class ExpenseReport extends CommonObject // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** - * Returns the label of a statut + * Returns the label of a status * - * @param int $status id statut + * @param int $status ID status * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto * @return string Label */ @@ -857,7 +873,7 @@ class ExpenseReport extends CommonObject { $objp = $this->db->fetch_object($result); - $sql2 = "SELECT d.rowid, d.fk_user_author, d.ref, d.fk_statut"; + $sql2 = "SELECT d.rowid, d.fk_user_author, d.ref, d.fk_statut as status"; $sql2 .= " FROM ".MAIN_DB_PREFIX."expensereport as d"; $sql2 .= " WHERE d.rowid = ".((int) $objp->fk_expensereport); @@ -866,7 +882,7 @@ class ExpenseReport extends CommonObject $objp->fk_user_author = $obj->fk_user_author; $objp->ref = $obj->ref; - $objp->fk_c_expensereport_status = $obj->fk_statut; + $objp->fk_c_expensereport_status = $obj->status; $objp->rowid = $obj->rowid; $total_HT = $total_HT + $objp->total_ht; @@ -1107,7 +1123,7 @@ class ExpenseReport extends CommonObject $now = dol_now(); // Protection - if ($this->statut == self::STATUS_VALIDATED) + if ($this->status == self::STATUS_VALIDATED) { dol_syslog(get_class($this)."::valid action abandonned: already validated", LOG_WARNING); return 0; @@ -1195,7 +1211,7 @@ class ExpenseReport extends CommonObject if (!$error) { $this->ref = $num; - $this->statut = self::STATUS_VALIDATED; + $this->status = self::STATUS_VALIDATED; } if (empty($error)) @@ -1237,7 +1253,7 @@ class ExpenseReport extends CommonObject $this->date_debut = $this->db->jdate($objp->date_debut); - if ($this->fk_statut != self::STATUS_VALIDATED) + if ($this->status != self::STATUS_VALIDATED) { $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; $sql .= " SET fk_statut = ".self::STATUS_VALIDATED; @@ -1271,7 +1287,7 @@ class ExpenseReport extends CommonObject // date approval $this->date_approve = $now; - if ($this->fk_statut != self::STATUS_APPROVED) + if ($this->status != self::STATUS_APPROVED) { $this->db->begin(); @@ -1327,7 +1343,7 @@ class ExpenseReport extends CommonObject $error = 0; // date de refus - if ($this->fk_statut != self::STATUS_REFUSED) + if ($this->status != self::STATUS_REFUSED) { $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; $sql .= " SET ref = '".$this->db->escape($this->ref)."', fk_statut = ".self::STATUS_REFUSED.", fk_user_refuse = ".$fuser->id.","; @@ -1337,7 +1353,8 @@ class ExpenseReport extends CommonObject $sql .= ' WHERE rowid = '.$this->id; if ($this->db->query($sql)) { - $this->fk_statut = 99; + $this->fk_statut = 99; // deprecated + $this->status = 99; $this->fk_user_refuse = $fuser->id; $this->detail_refuse = $details; $this->date_refuse = $now; @@ -1441,7 +1458,7 @@ class ExpenseReport extends CommonObject // phpcs:enable $error = 0; $this->date_cancel = $this->db->idate(dol_now()); - if ($this->fk_statut != self::STATUS_CANCELED) + if ($this->status != self::STATUS_CANCELED) { $this->db->begin(); @@ -1565,6 +1582,9 @@ class ExpenseReport extends CommonObject $label .= '
'.$langs->trans('VAT').': '.price($this->total_tva, 0, $langs, 0, -1, -1, $conf->currency); if (!empty($this->total_ttc)) $label .= '
'.$langs->trans('AmountTTC').': '.price($this->total_ttc, 0, $langs, 0, -1, -1, $conf->currency); + if (isset($this->status)) { + $label .= '
'.$langs->trans("Status").": ".$this->getLibStatut(5); + } if ($moretitle) $label .= ' - '.$moretitle; //if ($option != 'nolink') @@ -1683,7 +1703,7 @@ class ExpenseReport extends CommonObject dol_syslog(get_class($this)."::addline qty=$qty, up=$up, fk_c_type_fees=$fk_c_type_fees, vatrate=$vatrate, date=$date, fk_project=$fk_project, type=$type, comments=$comments", LOG_DEBUG); - if ($this->fk_statut == self::STATUS_DRAFT) + if ($this->status == self::STATUS_DRAFT) { if (empty($qty)) $qty = 0; if (empty($fk_c_type_fees) || $fk_c_type_fees < 0) $fk_c_type_fees = 0; @@ -1925,7 +1945,7 @@ class ExpenseReport extends CommonObject { global $user, $mysoc; - if ($this->fk_statut == 0 || $this->fk_statut == 99) + if ($this->status == self::STATUS_DRAFT || $this->status == self::STATUS_REFUSED) { $this->db->begin(); @@ -2268,8 +2288,8 @@ class ExpenseReport extends CommonObject $sql = "SELECT ex.rowid, ex.date_valid"; $sql .= " FROM ".MAIN_DB_PREFIX."expensereport as ex"; - if ($option == 'toapprove') $sql .= " WHERE ex.fk_statut = 2"; - else $sql .= " WHERE ex.fk_statut = 5"; + if ($option == 'toapprove') $sql .= " WHERE ex.fk_statut = ".self::STATUS_VALIDATED; + else $sql .= " WHERE ex.fk_statut = ".self::STATUS_APPROVED; $sql .= " AND ex.entity IN (".getEntity('expensereport').")"; if (empty($user->rights->expensereport->readall)) { @@ -2289,12 +2309,12 @@ class ExpenseReport extends CommonObject $response->warning_delay = $conf->expensereport->approve->warning_delay / 60 / 60 / 24; $response->label = $langs->trans("ExpenseReportsToApprove"); $response->labelShort = $langs->trans("ToApprove"); - $response->url = DOL_URL_ROOT.'/expensereport/list.php?mainmenu=hrm&statut=2'; + $response->url = DOL_URL_ROOT.'/expensereport/list.php?mainmenu=hrm&statut='.self::STATUS_VALIDATED; } else { $response->warning_delay = $conf->expensereport->payment->warning_delay / 60 / 60 / 24; $response->label = $langs->trans("ExpenseReportsToPay"); $response->labelShort = $langs->trans("StatusToPay"); - $response->url = DOL_URL_ROOT.'/expensereport/list.php?mainmenu=hrm&statut=5'; + $response->url = DOL_URL_ROOT.'/expensereport/list.php?mainmenu=hrm&statut='.self::STATUS_APPROVED; } $response->img = img_object('', "trip"); diff --git a/htdocs/hrm/index.php b/htdocs/hrm/index.php index bcae66ca5bf..88141debfad 100644 --- a/htdocs/hrm/index.php +++ b/htdocs/hrm/index.php @@ -3,7 +3,7 @@ * Copyright (C) 2013-2015 Laurent Destailleur * Copyright (C) 2012-2014 Regis Houssin * Copyright (C) 2015-2016 Alexandre Spangaro - * Copyright (C) 2019 Nicolas ZABOURI + * Copyright (C) 2019 Nicolas ZABOURI * * 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 @@ -35,6 +35,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/usergroups.lib.php'; if ($conf->deplacement->enabled) require_once DOL_DOCUMENT_ROOT.'/compta/deplacement/class/deplacement.class.php'; if ($conf->expensereport->enabled) require_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php'; +require_once DOL_DOCUMENT_ROOT.'/recruitment/class/recruitmentcandidature.class.php'; require_once DOL_DOCUMENT_ROOT.'/holiday/class/holiday.class.php'; $hookmanager = new HookManager($db); @@ -52,6 +53,7 @@ if (empty($conf->global->MAIN_INFO_SOCIETE_NOM) || empty($conf->global->MAIN_INF $holiday = new Holiday($db); $holidaystatic = new Holiday($db); +$staticrecruitmentcandidature = new RecruitmentCandidature($db); $max = $conf->global->MAIN_SIZE_SHORTLIST_LIMIT; @@ -173,7 +175,8 @@ print '
'; // Latest leave requests if (!empty($conf->holiday->enabled) && $user->rights->holiday->read) { - $sql = "SELECT u.rowid as uid, u.lastname, u.firstname, u.login, u.email, u.photo, u.statut, x.rowid, x.rowid as ref, x.fk_type, x.date_debut as date_start, x.date_fin as date_end, x.halfday, x.tms as dm, x.statut as status"; + $sql = "SELECT u.rowid as uid, u.lastname, u.firstname, u.login, u.email, u.photo, u.statut as user_status,"; + $sql .= " x.rowid, x.rowid as ref, x.fk_type, x.date_debut as date_start, x.date_fin as date_end, x.halfday, x.tms as dm, x.statut as status"; $sql .= " FROM ".MAIN_DB_PREFIX."holiday as x, ".MAIN_DB_PREFIX."user as u"; $sql .= " WHERE u.rowid = x.fk_user"; $sql .= " AND x.entity = ".$conf->entity; @@ -203,8 +206,7 @@ if (!empty($conf->holiday->enabled) && $user->rights->holiday->read) print '
'.$langs->trans("BoxTitleLastLeaveRequests", min($max, $num)).''.$langs->trans("from").''.$langs->trans("to").''.$langs->trans("DateModificationShort").' '.$langs->trans("FullList").'
'.$holidaystatic->getNomUrl(1).''.dol_print_date($db->jdate($obj->date_start), 'day').' '.$langs->trans($listhalfday[$starthalfday]); - print ''.dol_print_date($db->jdate($obj->date_end), 'day').' '.$langs->trans($listhalfday[$endhalfday]); + print ''.dol_print_date($db->jdate($obj->date_start), 'day').' '.$langs->trans($listhalfday[$starthalfday]).''; + print ''.dol_print_date($db->jdate($obj->date_end), 'day').' '.$langs->trans($listhalfday[$endhalfday]).''; print ''.dol_print_date($db->jdate($obj->dm), 'day').''.$holidaystatic->LibStatut($obj->status, 3).''.$holidaystatic->LibStatut($obj->status, 3).'
'.$langs->trans("BoxTitleLastModifiedExpenses", min($max, $num)).''.$langs->trans("TotalTTC").''.$langs->trans("DateModificationShort").' '.$langs->trans("FullList").'
'.$userstatic->getNomUrl(-1).''.price($obj->total_ttc).''.dol_print_date($db->jdate($obj->dm), 'day').''.$expensereportstatic->LibStatut($obj->status, 3).''.$expensereportstatic->LibStatut($obj->status, 3).'
'; print ''; + print '
'; } else dol_print_error($db); } +// Last modified job position +if (!empty($conf->recruitment->enabled) && $user->rights->recruitment->recruitmentjobposition->read) +{ + $sql = "SELECT rc.rowid, rc.ref, rc.email, rc.lastname, rc.firstname, rc.date_creation, rc.tms, rc.status"; + $sql .= " FROM ".MAIN_DB_PREFIX."recruitment_recruitmentcandidature as rc"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."recruitment_recruitmentjobposition as s ON rc.fk_recruitmentjobposition = s.rowid"; + if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql .= " WHERE rc.entity IN (".getEntity($staticrecruitmentjobposition->element).")"; + if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.fk_soc = sc.fk_soc AND sc.fk_user = ".$user->id; + if ($socid) $sql .= " AND s.fk_soc = $socid"; + $sql .= " ORDER BY rc.tms DESC"; + $sql .= $db->plimit($max, 0); + + $resql = $db->query($sql); + if ($resql) + { + $num = $db->num_rows($resql); + $i = 0; + + print '
'; + print ''; + print ''; + print ''; + print ''; + print ''; + if ($num) + { + while ($i < $num) + { + $objp = $db->fetch_object($resql); + $staticrecruitmentcandidature->id = $objp->rowid; + $staticrecruitmentcandidature->ref = $objp->ref; + $staticrecruitmentcandidature->email = $objp->email; + $staticrecruitmentcandidature->status = $objp->status; + $staticrecruitmentcandidature->date_creation = $objp->date_creation; + $staticrecruitmentcandidature->firstname = $objp->firstname; + $staticrecruitmentcandidature->lastname = $objp->lastname; + + print ''; + print ''; + print '"; + print '"; + print '"; + print ''; + $i++; + } + + $db->free($resql); + } else { + print ''; + } + print "
'; + print $langs->trans("BoxTitleLatestModifiedCandidatures", $max); + print ''.$langs->trans("FullList").'
'.$staticrecruitmentcandidature->getNomUrl(1, '').''; + print "'.dol_print_date($db->jdate($objp->tms), 'day')."'; + print $staticrecruitmentcandidature->getLibStatut(3); + print "
'.$langs->trans("None").'
"; + print "
"; + print "
"; + } else { + dol_print_error($db); + } +} + print ''; // Initialize technical object to manage hooks. Note that conf->hooks_modules contains array diff --git a/htdocs/recruitment/recruitmentindex.php b/htdocs/recruitment/recruitmentindex.php index 93e4c53eb7c..04d50c34eb8 100644 --- a/htdocs/recruitment/recruitmentindex.php +++ b/htdocs/recruitment/recruitmentindex.php @@ -338,6 +338,7 @@ if (!empty($conf->recruitment->enabled) && $user->rights->recruitment->recruitme $num = $db->num_rows($resql); $i = 0; + print '
'; print ''; print ''; print '"; print '"; - print '"; print ''; @@ -372,7 +373,9 @@ if (!empty($conf->recruitment->enabled) && $user->rights->recruitment->recruitme } else { print ''; } - print "
'; @@ -361,7 +362,7 @@ if (!empty($conf->recruitment->enabled) && $user->rights->recruitment->recruitme print ''; print "'.dol_print_date($db->jdate($objp->tms), 'day')."'; + print ''; print $staticrecruitmentjobposition->getLibStatut(3); print "
'.$langs->trans("None").'

"; + print ""; + print "
"; + print "
"; } else { dol_print_error($db); } @@ -397,6 +400,7 @@ if (!empty($conf->recruitment->enabled) && $user->rights->recruitment->recruitme $num = $db->num_rows($resql); $i = 0; + print '
'; print ''; print ''; print '"; print '"; - print '"; print ''; @@ -433,7 +437,9 @@ if (!empty($conf->recruitment->enabled) && $user->rights->recruitment->recruitme } else { print ''; } - print "
'; @@ -422,7 +426,7 @@ if (!empty($conf->recruitment->enabled) && $user->rights->recruitment->recruitme print ''; print "'.dol_print_date($db->jdate($objp->tms), 'day')."'; + print ''; print $staticrecruitmentcandidature->getLibStatut(3); print "
'.$langs->trans("None").'

"; + print ""; + print "
"; + print "
"; } else { dol_print_error($db); } From f67189aaa86dc595eecdfbe808298dbd8f0529da Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Fri, 2 Oct 2020 13:16:42 +0200 Subject: [PATCH 81/92] FIX missing hook 'formConfirm' in 'addreplace' $hooktype --- htdocs/core/class/hookmanager.class.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/core/class/hookmanager.class.php b/htdocs/core/class/hookmanager.class.php index e24bce5e247..1ea5daf9be3 100644 --- a/htdocs/core/class/hookmanager.class.php +++ b/htdocs/core/class/hookmanager.class.php @@ -171,6 +171,7 @@ class HookManager 'formattachOptions', 'formBuilddocLineOptions', 'formatNotificationMessage', + 'formConfirm', 'getAccessForbiddenMessage', 'getDirList', 'getFormMail', From 3c6fcced8e14883a1bb68274fe3af094faf739bc Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 2 Oct 2020 13:38:35 +0200 Subject: [PATCH 82/92] Clean code --- htdocs/core/class/hookmanager.class.php | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/htdocs/core/class/hookmanager.class.php b/htdocs/core/class/hookmanager.class.php index 4c2db065e66..934c8d424a4 100644 --- a/htdocs/core/class/hookmanager.class.php +++ b/htdocs/core/class/hookmanager.class.php @@ -137,7 +137,7 @@ class HookManager * @param array $parameters Array of parameters * @param Object $object Object to use hooks on * @param string $action Action code on calling page ('create', 'edit', 'view', 'add', 'update', 'delete'...) - * @return mixed For 'addreplace' hooks (doActions,formObjectOptions,pdf_xxx,...): Return 0 if we want to keep standard actions, >0 if we want to stop/replace standard actions, <0 if KO. Things to print are returned into ->resprints and set into ->resPrint. Things to return are returned into ->results by hook and set into ->resArray for caller. + * @return mixed For 'addreplace' hooks (doActions, formConfirm, formObjectOptions, pdf_xxx,...): Return 0 if we want to keep standard actions, >0 if we want to stop/replace standard actions, <0 if KO. Things to print are returned into ->resprints and set into ->resPrint. Things to return are returned into ->results by hook and set into ->resArray for caller. * For 'output' hooks (printLeftBlock, formAddObjectLine, formBuilddocOptions, ...): Return 0, <0 if KO. Things to print are returned into ->resprints and set into ->resPrint. Things to return are returned into ->results by hook and set into ->resArray for caller. * All types can also return some values into an array ->results that will be finaly merged into this->resArray for caller. * $this->error or this->errors are also defined by class called by this function if error. @@ -149,7 +149,8 @@ class HookManager $parameters['context'] = join(':', $this->contextarray); //dol_syslog(get_class($this).'::executeHooks method='.$method." action=".$action." context=".$parameters['context']); - // Define type of hook ('output' or 'addreplace'). Type 'returnvalue' is deprecated because a 'addreplace' hook can also return resPrint and resArray). + // Define type of hook ('output' or 'addreplace'). + // TODO Remove hooks with type 'output'. All hooks must be converted into 'addreplace' hooks. $hooktype = 'output'; if (in_array( $method, @@ -216,11 +217,6 @@ class HookManager ) )) $hooktype = 'addreplace'; - if ($method == 'insertExtraFields') { - $hooktype = 'returnvalue'; // @deprecated. TODO Remove all code with "executeHooks('insertExtraFields'" as soon as there is a trigger available. - dol_syslog("Warning: The hook 'insertExtraFields' is deprecated and must not be used. Use instead trigger on CRUD event (ask it to dev team if not implemented)", LOG_WARNING); - } - // Init return properties $this->resPrint = ''; $this->resArray = array(); $this->resNbOfHooks = 0; From d297e0b05ab6b4d60aa742514ca4cf69b5763d91 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 2 Oct 2020 13:46:44 +0200 Subject: [PATCH 83/92] Update card.php --- htdocs/comm/propal/card.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php index 536754214e4..9caf2c8483c 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -2362,14 +2362,13 @@ if ($action == 'create') // Form to add new line if ($object->statut == Propal::STATUS_DRAFT && $usercancreate && $action != 'selectlines') { - if ($action != 'editline') - { + if ($action != 'editline') { // Add products/services form $object->formAddObjectLine(1, $mysoc, $soc); $parameters = array(); $reshook = $hookmanager->executeHooks('formAddObjectLine', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - }else { + } else { $parameters = array(); $reshook = $hookmanager->executeHooks('formEditObjectLine', $parameters, $object, $action); // Note that $action and $object may have been modified by hook } From 10deb1baadc374658a9d5cabf137c8c207724a00 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 2 Oct 2020 13:51:32 +0200 Subject: [PATCH 84/92] Clean code - Removed no more used files orderstoinvoice.php --- htdocs/comm/card.php | 6 +- htdocs/commande/orderstoinvoice.php | 723 ---------------------- htdocs/fourn/card.php | 5 +- htdocs/fourn/commande/orderstoinvoice.php | 635 ------------------- 4 files changed, 4 insertions(+), 1365 deletions(-) delete mode 100644 htdocs/commande/orderstoinvoice.php delete mode 100644 htdocs/fourn/commande/orderstoinvoice.php diff --git a/htdocs/comm/card.php b/htdocs/comm/card.php index 79278fef056..d056f4fb3af 100644 --- a/htdocs/comm/card.php +++ b/htdocs/comm/card.php @@ -1274,13 +1274,11 @@ if ($object->id > 0) { print ''; } else { - $langs->load("bills"); - $langs->load("orders"); + $langs->loadLangs(array("orders", "bills")); if (!empty($conf->commande->enabled)) { - if ($object->client != 0 && $object->client != 2) - { + if ($object->client != 0 && $object->client != 2) { if (!empty($orders2invoice) && $orders2invoice > 0) print ''; else print ''; } else print ''; diff --git a/htdocs/commande/orderstoinvoice.php b/htdocs/commande/orderstoinvoice.php deleted file mode 100644 index a4d4ed07dee..00000000000 --- a/htdocs/commande/orderstoinvoice.php +++ /dev/null @@ -1,723 +0,0 @@ - - * Copyright (C) 2004-2019 Laurent Destailleur - * Copyright (C) 2005 Marc Barilley / Ocebo - * Copyright (C) 2005-2012 Regis Houssin - * Copyright (C) 2012 Andreu Bisquerra Gaya - * Copyright (C) 2012 David Rodriguez Martinez - * Copyright (C) 2012-2018 Juanjo Menent - * Copyright (C) 2015 Ferran Marcet - * Copyright (C) 2018 Frédéric France - * - * 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 . - */ - -/** - * \file htdocs/commande/orderstoinvoice.php - * \ingroup commande - * \brief Page to invoice multiple orders - */ - -require '../main.inc.php'; -require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; -require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; -require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; -require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; -require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; -require_once DOL_DOCUMENT_ROOT.'/core/lib/report.lib.php'; -if (!empty($conf->projet->enabled)) { - require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php'; -} - -// Load translation files required by the page -$langs->loadLangs(array("orders", "deliveries", "companies")); - -if (!$user->rights->facture->creer) - accessforbidden(); - -$id = (GETPOST('id') ?GETPOST('id', 'int') : GETPOST("facid", "int")); // For backward compatibility -$ref = GETPOST('ref', 'alpha'); -$action = GETPOST('action', 'alpha'); -$confirm = GETPOST('confirm', 'alpha'); -$sref = GETPOST('sref', 'alpha'); -$sref_client = GETPOST('sref_client', 'alpha'); -$sall = trim((GETPOST('search_all', 'alphanohtml') != '') ?GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml')); -$socid = GETPOST('socid', 'int'); -$selected = GETPOST('orders_to_invoice'); -$sortfield = GETPOST("sortfield", 'alpha'); -$sortorder = GETPOST("sortorder", 'alpha'); -$search_status = GETPOST('search_status', 'alpha'); - -$error = 0; - -if (!$sortfield) $sortfield = 'c.rowid'; -if (!$sortorder) $sortorder = 'DESC'; - -$now = dol_now(); -$date_start = dol_mktime(0, 0, 0, $_REQUEST["date_startmonth"], $_REQUEST["date_startday"], $_REQUEST["date_startyear"]); // Date for local PHP server -$date_end = dol_mktime(23, 59, 59, $_REQUEST["date_endmonth"], $_REQUEST["date_endday"], $_REQUEST["date_endyear"]); -$date_starty = dol_mktime(0, 0, 0, $_REQUEST["date_start_delymonth"], $_REQUEST["date_start_delyday"], $_REQUEST["date_start_delyyear"]); // Date for local PHP server -$date_endy = dol_mktime(23, 59, 59, $_REQUEST["date_end_delymonth"], $_REQUEST["date_end_delyday"], $_REQUEST["date_end_delyyear"]); - -$extrafields = new ExtraFields($db); - -$object = new Facture($db); - -// fetch optionals attributes and labels -$extrafields->fetch_name_optionals_label($object->table_element); - -if ($action == 'create') -{ - if (!is_array($selected)) - { - $error++; - setEventMessages($langs->trans('Error_OrderNotChecked'), null, 'errors'); - } else { - $origin = GETPOST('origin'); - $originid = GETPOST('originid'); - } -} - -// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context -include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; -$hookmanager = new HookManager($db); -$hookmanager->initHooks(array('orderstoinvoice')); - - -/* - * Actions - */ - -if (($action == 'create' || $action == 'add') && !$error) -{ - require_once DOL_DOCUMENT_ROOT.'/core/modules/facture/modules_facture.php'; - require_once DOL_DOCUMENT_ROOT.'/core/class/discount.class.php'; - require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; - require_once DOL_DOCUMENT_ROOT.'/core/lib/invoice.lib.php'; - if (!empty($conf->projet->enabled)) require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; - - $langs->load('bills'); - $langs->load('products'); - $langs->load('main'); - if (isset($_GET['orders_to_invoice'])) - { - $orders_id = GETPOST('orders_to_invoice', '', 1); - $n = count($orders_id); - $i = 0; - - $originid = $orders_id[0]; - $_GET['originid'] = $orders_id[0]; - } - if (isset($_POST['orders_to_invoice'])) - { - $orders_id = GETPOST('orders_to_invoice', '', 2); - $nn = count($orders_id); - $ii = 0; - - $originid = $orders_id[0]; - $_POST['originid'] = $orders_id[0]; - } - - $projectid = GETPOST('projectid', 'int') ?GETPOST('projectid', 'int') : 0; - $lineid = GETPOST('lineid', 'int'); - $userid = GETPOST('userid', 'int'); - $search_ref = GETPOST('sf_ref') ?GETPOST('sf_ref') : GETPOST('search_ref'); - $closeOrders = GETPOST('autocloseorders') ? true : false; - - // Security check - $fieldid = GETPOST('ref', 'alpha') ? 'ref' : 'rowid'; - if ($user->socid) $socid = $user->socid; - $result = restrictedArea($user, 'facture', $id, '', '', 'fk_soc', $fieldid); - - $usehm = $conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE; - - // Insert new invoice in database - if ($action == 'add' && $user->rights->facture->creer) - { - $object->socid = GETPOST('socid'); - $db->begin(); - $error = 0; - - // Standard or deposit or proforma invoice - if ($_POST['type'] == 0) - { - $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")); - } - if (!$error) - { - // Si facture standard - $object->socid = $_POST['socid']; - $object->type = $_POST['type']; - $object->number = $_POST['ref']; - $object->date = $datefacture; - $object->note_public = trim($_POST['note_public']); - $object->note = trim($_POST['note']); - $object->ref_client = $_POST['ref_client']; - $object->model_pdf = $_POST['model']; - $object->fk_project = $_POST['projectid']; - $object->cond_reglement_id = ($_POST['type'] == 3 ? 1 : $_POST['cond_reglement_id']); - $object->mode_reglement_id = $_POST['mode_reglement_id']; - $object->amount = $_POST['amount']; - $object->remise_absolue = $_POST['remise_absolue']; - $object->remise_percent = $_POST['remise_percent']; - - $ret = $extrafields->setOptionalsFromPost(null, $object); - if ($ret < 0) $error++; - - if ($_POST['origin'] && $_POST['originid']) - { - $object->origin = $_POST['origin']; - $object->origin_id = $orders_id[$ii]; - $object->linked_objects = $orders_id; - $id = $object->create($user); - $object->fetch_thirdparty(); - - if ($id > 0) - { - foreach ($orders_id as $origin => $origin_id) - { - $origin_id = (!empty($origin_id) ? $origin_id : $object->origin_id); - $db->begin(); - $sql = "INSERT INTO ".MAIN_DB_PREFIX."element_element ("; - $sql .= "fk_source"; - $sql .= ", sourcetype"; - $sql .= ", fk_target"; - $sql .= ", targettype"; - $sql .= ") VALUES ("; - $sql .= $origin_id; - $sql .= ", '".$db->escape($object->origin)."'"; - $sql .= ", ".$id; - $sql .= ", '".$db->escape($object->element)."'"; - $sql .= ")"; - - if ($db->query($sql)) - { - $db->commit(); - } else { - $db->rollback(); - } - } - - while ($ii < $nn) - { - include_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; - $objectsrc = new Commande($db); - dol_syslog("Try to find source object origin=".$object->origin." originid=".$object->origin_id." to add lines"); - $result = $objectsrc->fetch($orders_id[$ii]); - if ($result > 0) - { - if ($closeOrders) - { - $objectsrc->classifyBilled($user); - $objectsrc->setStatut(3); - } - $lines = $objectsrc->lines; - if (empty($lines) && method_exists($objectsrc, 'fetch_lines')) - { - $objectsrc->fetch_lines(); - $lines = $objectsrc->lines; - } - $fk_parent_line = 0; - $num = count($lines); - for ($i = 0; $i < $num; $i++) - { - $desc = ($lines[$i]->desc ? $lines[$i]->desc : $lines[$i]->libelle); - if ($lines[$i]->subprice < 0) - { - // Negative line, we create a discount line - $discount = new DiscountAbsolute($db); - $discount->fk_soc = $object->socid; - $discount->amount_ht = abs($lines[$i]->total_ht); - $discount->amount_tva = abs($lines[$i]->total_tva); - $discount->amount_ttc = abs($lines[$i]->total_ttc); - $discount->tva_tx = $lines[$i]->tva_tx; - $discount->fk_user = $user->id; - $discount->description = $desc; - $discountid = $discount->create($user); - if ($discountid > 0) - { - $result = $object->insert_discount($discountid); - //$result=$discount->link_to_invoice($lineid,$id); - } else { - setEventMessages($discount->error, $discount->errors, 'errors'); - $error++; - break; - } - } else { - // Positive line - $product_type = ($lines[$i]->product_type ? $lines[$i]->product_type : 0); - // Date start - $date_start = false; - if ($lines[$i]->date_debut_prevue) $date_start = $lines[$i]->date_debut_prevue; - if ($lines[$i]->date_debut_reel) $date_start = $lines[$i]->date_debut_reel; - if ($lines[$i]->date_start) $date_start = $lines[$i]->date_start; - //Date end - $date_end = false; - if ($lines[$i]->date_fin_prevue) $date_end = $lines[$i]->date_fin_prevue; - if ($lines[$i]->date_fin_reel) $date_end = $lines[$i]->date_fin_reel; - if ($lines[$i]->date_end) $date_end = $lines[$i]->date_end; - // Reset fk_parent_line for no child products and special product - if (($lines[$i]->product_type != 9 && empty($lines[$i]->fk_parent_line)) || $lines[$i]->product_type == 9) - { - $fk_parent_line = 0; - } - - // Extrafields - if (method_exists($lines[$i], 'fetch_optionals')) { - $lines[$i]->fetch_optionals(); - $array_options = $lines[$i]->array_options; - } - - $result = $object->addline( - $desc, - $lines[$i]->subprice, - $lines[$i]->qty, - $lines[$i]->tva_tx, - $lines[$i]->localtax1_tx, - $lines[$i]->localtax2_tx, - $lines[$i]->fk_product, - $lines[$i]->remise_percent, - $date_start, - $date_end, - 0, - $lines[$i]->info_bits, - $lines[$i]->fk_remise_except, - 'HT', - 0, - $product_type, - $ii, - $lines[$i]->special_code, - $object->origin, - $lines[$i]->rowid, - $fk_parent_line, - $lines[$i]->fk_fournprice, - $lines[$i]->pa_ht, - $lines[$i]->label, - $array_options - ); - if ($result > 0) - { - $lineid = $result; - } else { - $lineid = 0; - $error++; - break; - } - // Defined the new fk_parent_line - if ($result > 0 && $lines[$i]->product_type == 9) - { - $fk_parent_line = $result; - } - } - } - } else { - setEventMessages($objectsrc->error, $objectsrc->errors, 'errors'); - $error++; - } - $ii++; - } - } else { - setEventMessages($object->error, $object->errors, 'errors'); - $error++; - } - } - } - } - - // End of object creation, we show it - if ($id > 0 && !$error) - { - $db->commit(); - header('Location: '.DOL_URL_ROOT.'/compta/facture/card.php?facid='.$id); - exit; - } else { - $db->rollback(); - $action = 'create'; - $_GET["origin"] = $_POST["origin"]; - $_GET["originid"] = $_POST["originid"]; - setEventMessages($object->error, $object->errors, 'errors'); - $error++; - } - } -} - - -/* - * View - */ - -$html = new Form($db); -$htmlother = new FormOther($db); -$formfile = new FormFile($db); -$companystatic = new Societe($db); - -// Mode creation -if ($action == 'create' && !$error) -{ - $facturestatic = new Facture($db); - - llxHeader(); - print load_fiche_titre($langs->trans('NewBill')); - - $soc = new Societe($db); - if ($socid) $res = $soc->fetch($socid); - if ($res) - { - $cond_reglement_id = $soc->cond_reglement_id; - $mode_reglement_id = $soc->mode_reglement_id; - $remise_percent = $soc->remise_percent; - } - $remise_absolue = 0; - $dateinvoice = empty($conf->global->MAIN_AUTOFILL_DATE) ?-1 : ''; - - $absolute_discount = $soc->getAvailableDiscounts(); - print ''; - print ''; - print ''; - print ''."\n"; - print ''; - print ''; - print ''; - print ''; - - dol_fiche_head(); - - print ''; - - // Ref - print ''; - - // Third party - print ''; - print ''."\n"; - - // Type - print ''; - // Payment term - print ''; - // Payment mode - print ''; - // Project - if (!empty($conf->projet->enabled)) - { - $formproject = new FormProjets($db); - - $langs->load('projects'); - print ''; - } - - include_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; - $objectsrc = new Commande($db); - $listoforders = array(); - foreach ($selected as $sel) - { - $result = $objectsrc->fetch($sel); - if ($result > 0) - { - $listoforders[] = $objectsrc->ref; - } - } - - // Other attributes - $parameters = array('objectsrc' => $objectsrc, 'idsrc' => $listoforders); - $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - print $hookmanager->resPrint; - if (empty($reshook)) - { - $object = new Facture($db); - print $object->showOptionals($extrafields, 'edit'); - } - - // Modele PDF - print ''; - print '"; - - // Public note - print ''; - print ''; - print ''; - // Private note - if (empty($user->socid)) - { - print ''; - print ''; - print ''; - } - - print '
'.$langs->trans('Ref').''.$langs->trans('Draft').'
'.$langs->trans('Customer').''; - print $soc->getNomUrl(1); - print ''; - print '
'.$langs->trans('Type').''; - print ''."\n"; - - // Standard invoice - print ''."\n"; - print '
'; - print ''; - print ''; - $desc = $html->textwithpicto($langs->trans("InvoiceStandardAsk"), $langs->transnoentities("InvoiceStandardDesc"), 1); - print $desc; - print '
'; - - // Date invoice - print '
'.$langs->trans('Date').''; - print $html->selectDate('', '', '', '', '', "add", 1, 1); - print '
'.$langs->trans('PaymentConditionsShort').''; - $html->select_conditions_paiements(isset($_POST['cond_reglement_id']) ? $_POST['cond_reglement_id'] : $cond_reglement_id, 'cond_reglement_id'); - print '
'.$langs->trans('PaymentMode').''; - $html->select_types_paiements(isset($_POST['mode_reglement_id']) ? $_POST['mode_reglement_id'] : $mode_reglement_id, 'mode_reglement_id'); - print '
'.$langs->trans('Project').''; - $formproject->select_projects($soc->id, $projectid, 'projectid'); - print '
'.$langs->trans('Model').''; - include_once DOL_DOCUMENT_ROOT.'/core/modules/facture/modules_facture.php'; - $liste = ModelePDFFactures::liste_modeles($db); - print $html->selectarray('model', $liste, $conf->global->FACTURE_ADDON_PDF); - print "
'.$langs->trans('NotePublic').''; - print '
'.$langs->trans('NotePrivate').''; - print '
'; - - while ($i < $n) - { - print ''; - - $i++; - } - - dol_fiche_end(); - - // Button "Create Draft" - print '
'; - print "\n"; - - print ''; - print "\n"; -} - -// Mode liste -if (($action != 'create' && $action != 'add') || ($action == 'create' && $error)) -{ - llxHeader(); - ?> - - rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql .= ' WHERE c.entity IN ('.getEntity('commande').')'; - $sql .= ' AND c.fk_soc = s.rowid'; - - // Show orders with status validated, shipping started and delivered (well any order we can bill) - $sql .= " AND ((c.fk_statut IN (1,2)) OR (c.fk_statut = 3 AND c.facture = 0))"; - - if ($socid) $sql .= ' AND s.rowid = '.$socid; - if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; - if ($sref) - { - $sql .= " AND c.ref LIKE '%".$db->escape($sref)."%'"; - } - if ($sall) - { - $sql .= " AND (c.ref LIKE '%".$db->escape($sall)."%' OR c.note LIKE '%".$db->escape($sall)."%')"; - } - - //Date filter - if ($date_start && $date_end) $sql .= " AND c.date_commande >= '".$db->idate($date_start)."' AND c.date_commande <= '".$db->idate($date_end)."'"; - if ($date_starty && $date_endy) $sql .= " AND c.date_livraison >= '".$db->idate($date_starty)."' AND c.date_livraison <= '".$db->idate($date_endy)."'"; - - if (!empty($sref_client)) - { - $sql .= ' AND c.ref_client LIKE \'%'.$db->escape($sref_client).'%\''; - } - $sql .= $db->order($sortfield, $sortorder); - - $resql = $db->query($sql); - if ($resql) - { - if ($socid) - { - $soc = new Societe($db); - $soc->fetch($socid); - } - $title = $langs->trans('ListOfOrders'); - $title .= ' - '.$langs->trans('StatusOrderValidated').', '.$langs->trans("StatusOrderSent").', '.$langs->trans('StatusOrderToBill'); - $num = $db->num_rows($resql); - print load_fiche_titre($title); - $i = 0; - $period = $html->selectDate($date_start, 'date_start', 0, 0, 1, '', 1, 0).' - '.$html->selectDate($date_end, 'date_end', 0, 0, 1, '', 1, 0); - $periodely = $html->selectDate($date_starty, 'date_start_dely', 0, 0, 1, '', 1, 0).' - '.$html->selectDate($date_endy, 'date_end_dely', 0, 0, 1, '', 1, 0); - - if (!empty($socid)) - { - // Company - $companystatic->id = $socid; - $companystatic->name = $soc->name; - print '

'.$companystatic->getNomUrl(1, 'customer').'

'; - } - - print '
'; - print ''; - print ''; - print_liste_field_titre('Ref', $_SERVER["PHP_SELF"], 'c.ref', '', '&socid='.$socid, '', $sortfield, $sortorder); - print_liste_field_titre('RefCustomerOrder', $_SERVER["PHP_SELF"], 'c.ref_client', '', '&socid='.$socid, '', $sortfield, $sortorder); - print_liste_field_titre('OrderDate', $_SERVER["PHP_SELF"], 'c.date_commande', '', '&socid='.$socid, 'align="center"', $sortfield, $sortorder); - print_liste_field_titre('DeliveryDate', $_SERVER["PHP_SELF"], 'c.date_livraison', '', '&socid='.$socid, 'align="center"', $sortfield, $sortorder); - print_liste_field_titre('Status', '', '', '', '', 'class="right"'); - print_liste_field_titre('GenerateBill', '', '', '', '', 'align="center"'); - print ''; - - // Fields title search - print ''; - print ''; - print ''; - - //REF - print ''; - - print ''; - - //DATE ORDER - print ''; - - //DATE DELIVERY - print ''; - - //SEARCH BUTTON - print ''; - - //ALL/NONE - print ''; - - print ''; - print ''; - - print ''; - - $generic_commande = new Commande($db); - - while ($i < $num) - { - $objp = $db->fetch_object($resql); - - print ''; - print ''; - - print ''; - - // Order date - print ''; - - //Delivery date - print ''; - - // Statut - print ''; - - // Checkbox - print ''; - - print ''; - - $total = $total + $objp->price; - $subtotal = $subtotal + $objp->price; - $i++; - } - print '
'; - print ''; - print ''; - print ''; - print ''; - print $period; - print ''; - print $periodely; - print ''; - print ''; - print ''; - if ($conf->use_javascript_ajax) print ''.$langs->trans("All").' / '.$langs->trans("None").''; - print '
'; - - $generic_commande->id = $objp->rowid; - $generic_commande->ref = $objp->ref; - $generic_commande->statut = $objp->fk_statut; - $generic_commande->date_commande = $db->jdate($objp->date_commande); - $generic_commande->date_livraison = $db->jdate($objp->date_livraison); - - print ''; - print ''; - - print ''; - - print '
'; - print $generic_commande->getNomUrl(1, 0); - print ''; - if ($generic_commande->hasDelay()) { - print img_picto($langs->trans("Late"), "warning"); - } - print ''; - $filename = dol_sanitizeFileName($objp->ref); - $filedir = $conf->commande->multidir_output[$objp->entity].'/'.dol_sanitizeFileName($objp->ref); - $urlsource = $_SERVER['PHP_SELF'].'?id='.$objp->rowid; - print $formfile->getDocumentsLink($generic_commande->element, $filename, $filedir); - print '
'; - print '
'.$objp->ref_client.''; - print dol_print_date($db->jdate($objp->date_commande), 'day'); - print ''; - print dol_print_date($db->jdate($objp->date_livraison), 'day'); - print ''.$generic_commande->LibStatut($objp->fk_statut, $objp->billed, 5).''; - print ''; - print '
'; - print '
'; - - // Buttons actions - print '
global->INVOICE_CLOSE_ORDERS_OFF_BY_DEFAULT_FORMASSINVOICE) ? ' checked="checked"' : '').' name="autocloseorders"> '.$langs->trans("CloseProcessedOrdersAutomatically"); - print '
'; - print ''; - print ''; - print '
'; - //print ''.$langs->trans("GoBack").''; - print ''; - print '
'; - print '
'; - - print ''; - - $db->free($resql); - } else { - dol_print_error($db); - } -} - -// End of page -llxFooter(); -$db->close(); diff --git a/htdocs/fourn/card.php b/htdocs/fourn/card.php index 1de6d30b681..9aeef877bab 100644 --- a/htdocs/fourn/card.php +++ b/htdocs/fourn/card.php @@ -595,7 +595,7 @@ if ($object->id > 0) // Show orders we can bill if (empty($conf->global->SUPPLIER_ORDER_TO_INVOICE_STATUS)) { - $sql2 .= " AND c.fk_statut IN (".$db->sanitize(CommandeFournisseur::STATUS_RECEIVED_COMPLETELY).")"; // Must match filter in htdocs/fourn/orderstoinvoice.php + $sql2 .= " AND c.fk_statut IN (".$db->sanitize(CommandeFournisseur::STATUS_RECEIVED_COMPLETELY).")"; // Must match filter in htdocs/fourn/commande/list.php } else { // CommandeFournisseur::STATUS_ORDERSENT.", ".CommandeFournisseur::STATUS_RECEIVED_PARTIALLY.", ".CommandeFournisseur::STATUS_RECEIVED_COMPLETELY $sql2 .= " AND c.fk_statut IN (".$db->sanitize($db->escape($conf->global->SUPPLIER_ORDER_TO_INVOICE_STATUS)).")"; @@ -795,8 +795,7 @@ if ($object->id > 0) { if (!empty($orders2invoice) && $orders2invoice > 0) { - if ($object->status == 1) - { + if ($object->status == 1) { // Company is open print ''; } else { diff --git a/htdocs/fourn/commande/orderstoinvoice.php b/htdocs/fourn/commande/orderstoinvoice.php deleted file mode 100644 index 83dd50a32e0..00000000000 --- a/htdocs/fourn/commande/orderstoinvoice.php +++ /dev/null @@ -1,635 +0,0 @@ - - * Copyright (C) 2004-2013 Laurent Destailleur - * Copyright (C) 2005 Marc Barilley / Ocebo - * Copyright (C) 2005-2012 Regis Houssin - * Copyright (C) 2012 Andreu Bisquerra Gaya - * Copyright (C) 2012 David Rodriguez Martinez - * Copyright (C) 2012-2017 Juanjo Menent - * Copyright (C) 2014 Florian Henry - * Copyright (C) 2015 Marcos García - * Copyright (C) 2018 Frédéric France - * - * 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 . - */ - -/** - * \file htdocs/fourn/commande/orderstoinvoice.php - * \ingroup commande - * \brief Page to invoice multiple supplier orders - */ -require '../../main.inc.php'; -require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php'; -require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php'; -require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; -require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; -require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; -require_once DOL_DOCUMENT_ROOT.'/core/lib/report.lib.php'; -require_once DOL_DOCUMENT_ROOT.'/core/modules/supplier_invoice/modules_facturefournisseur.php'; -if (!empty($conf->projet->enabled)) { - require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php'; -} - -// Load translation files required by the page -$langs->loadLangs(array("orders", "companies", "deliveries")); - -if (!$user->rights->fournisseur->facture->creer) - accessforbidden(); - -$id = (GETPOST('id') ? GETPOST('id', 'int') : GETPOST("facid")); // For backward compatibility -$ref = GETPOST('ref', 'alpha'); -$action = GETPOST('action', 'aZ09'); -$confirm = GETPOST('confirm', 'alpha'); -$sref = GETPOST('sref'); -$sref_client = GETPOST('sref_client'); -$sall = trim((GETPOST('search_all', 'alphanohtml') != '') ?GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml')); -$socid = GETPOST('socid', 'int'); -$selected = GETPOST('orders_to_invoice'); -$sortfield = GETPOST("sortfield", 'alpha'); -$sortorder = GETPOST("sortorder", 'alpha'); -$search_status = GETPOST('search_status'); - -if (!$sortfield) - $sortfield = 'c.rowid'; -if (!$sortorder) - $sortorder = 'DESC'; - -$now = dol_now(); -$date_start = dol_mktime(0, 0, 0, $_REQUEST["date_startmonth"], $_REQUEST["date_startday"], $_REQUEST["date_startyear"]); // Date for local PHP server -$date_end = dol_mktime(23, 59, 59, $_REQUEST["date_endmonth"], $_REQUEST["date_endday"], $_REQUEST["date_endyear"]); -$date_starty = dol_mktime(0, 0, 0, $_REQUEST["date_start_delymonth"], $_REQUEST["date_start_delyday"], $_REQUEST["date_start_delyyear"]); // Date for local PHP server -$date_endy = dol_mktime(23, 59, 59, $_REQUEST["date_end_delymonth"], $_REQUEST["date_end_delyday"], $_REQUEST["date_end_delyyear"]); - -$extrafields = new ExtraFields($db); - -$object = new FactureFournisseur($db); - -// fetch optionals attributes and labels -$extrafields->fetch_name_optionals_label($object->table_element); - -if ($action == 'create') -{ - if (!GETPOST('createbill')) - { - $action = ''; - } else { - if (!is_array($selected)) - { - //$error++; - setEventMessages($langs->trans('Error_OrderNotChecked'), null, 'errors'); - $action = ''; - } else { - $origin = GETPOST('origin', 'alpha'); - $originid = GETPOST('originid', 'int'); - } - } -} - -// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context -include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; -$hookmanager = new HookManager($db); -$hookmanager->initHooks(array('orderstoinvoicesupplier')); - - -/* - * Actions - */ - -if (($action == 'create' || $action == 'add') && !$error) { - require_once DOL_DOCUMENT_ROOT.'/core/lib/fourn.lib.php'; - if (!empty($conf->projet->enabled)) - require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; - - // Load translation files required by the page - $langs->loadLangs(array("bills", "main", "products")); - - if (isset($_GET['orders_to_invoice'])) { - $orders_id = GETPOST('orders_to_invoice', '', 1); - $n = count($orders_id); - $i = 0; - - $originid = $orders_id[0]; - $_GET['originid'] = $orders_id[0]; - } - if (isset($_POST['orders_to_invoice'])) { - $orders_id = GETPOST('orders_to_invoice', '', 2); - $nn = count($orders_id); - $ii = 0; - - $originid = $orders_id[0]; - $_POST['originid'] = $orders_id[0]; - } - - $projectid = GETPOST('projectid', 'int') ? GETPOST('projectid', 'int') : 0; - $lineid = GETPOST('lineid', 'int'); - $userid = GETPOST('userid', 'int'); - $search_ref = GETPOST('sf_ref') ? GETPOST('sf_ref') : GETPOST('search_ref'); - - // Security check - if ($user->socid) - $socid = $user->socid; - $result = restrictedArea($user, 'fournisseur', $id, 'facture_fourn', 'facture'); - - $usehm = $conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE; - $object = new FactureFournisseur($db); - - // Insert new invoice in database - if ($action == 'add' && $user->rights->fournisseur->facture->creer) { - $object->socid = GETPOST('socid'); - $db->begin(); - $error = 0; - - // Standard or deposit or proforma invoice - $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")); - } - if (!$error) { - $object->ref = GETPOST('ref', 'nohtml'); - $object->ref_supplier = GETPOST('ref_supplier', 'alpha'); - $object->socid = GETPOST('socid', 'int'); - $object->libelle = (GETPOSTISSET('libelle') ? GETPOST('libelle', 'nohtml') : GETPOST('label', 'nohtml')); - $object->label = (GETPOSTISSET('libelle') ? GETPOST('libelle', 'nohtml') : GETPOST('label', 'nohtml')); - $object->date = $datefacture; - $object->date_echeance = $datedue; - $object->note_public = GETPOST('note_public', 'restricthtml'); - $object->note_private = GETPOST('note_private', 'restricthtml'); - $object->cond_reglement_id = GETPOST('cond_reglement_id'); - $object->mode_reglement_id = GETPOST('mode_reglement_id'); - $projectid = GETPOST('projectid', 'int'); - if ($projectid > 0) - $object->fk_project = $projectid; - - // Auto calculation of date due if not filled by user - if (empty($object->date_echeance)) - $object->date_echeance = $object->calculate_date_lim_reglement(); - - $ret = $extrafields->setOptionalsFromPost(null, $object); - if ($ret < 0) $error++; - - if ($_POST['origin'] && $_POST['originid']) { - $linked_orders_ids = array(); - foreach ($orders_id as $origin => $origin_id) { - $origin_id = (!empty($origin_id) ? $origin_id : $orders_id[$ii]); - $linked_orders_ids[] = $origin_id; - } - $object->linked_objects = array(GETPOST('origin')=>$linked_orders_ids); - $id = $object->create($user); - - if ($id > 0) { - while ($ii < $nn) { - $objectsrc = new CommandeFournisseur($db); - dol_syslog("Try to find source object origin=".$object->origin." originid=".$object->origin_id." to add lines"); - $result = $objectsrc->fetch($orders_id[$ii]); - if ($result > 0) { - $lines = $objectsrc->lines; - if (empty($lines) && method_exists($objectsrc, 'fetch_lines')) { - $objectsrc->fetch_lines(); - $lines = $objectsrc->lines; - } - $fk_parent_line = 0; - $num = count($lines); - for ($i = 0; $i < $num; $i++) { - $desc = ($lines[$i]->desc ? $lines[$i]->desc : $lines[$i]->libelle); - - $desc = ($lines[$i]->desc ? $lines[$i]->desc : $lines[$i]->libelle); - $product_type = ($lines[$i]->product_type ? $lines[$i]->product_type : 0); - - // Dates - // TODO mutualiser - $date_start = $lines[$i]->date_debut_prevue; - if ($lines[$i]->date_debut_reel) - $date_start = $lines[$i]->date_debut_reel; - if ($lines[$i]->date_start) - $date_start = $lines[$i]->date_start; - $date_end = $lines[$i]->date_fin_prevue; - if ($lines[$i]->date_fin_reel) - $date_end = $lines[$i]->date_fin_reel; - if ($lines[$i]->date_end) - $date_end = $lines[$i]->date_end; - - // Reset fk_parent_line for no child products and special product - if (($lines[$i]->product_type != 9 && empty($lines[$i]->fk_parent_line)) || $lines[$i]->product_type == 9) { - $fk_parent_line = 0; - } - // FIXME Missing $lines[$i]->ref_supplier and $lines[$i]->label into addline and updateline methods. They are filled when coming from order for example. - $result = $object->addline($desc, $lines[$i]->subprice, $lines[$i]->tva_tx, $lines[$i]->localtax1_tx, $lines[$i]->localtax2_tx, $lines[$i]->qty, $lines[$i]->fk_product, $lines[$i]->remise_percent, $date_start, $date_end, 0, $lines[$i]->info_bits, 'HT', $product_type, -1, false, 0, $lines[$i]->fk_unit, $line[$i]->id); - - if ($result > 0) { - $lineid = $result; - } else { - $lineid = 0; - $error++; - break; - } - // Defined the new fk_parent_line - if ($result > 0 && $lines[$i]->product_type == 9) { - $fk_parent_line = $result; - } - } - } else { - $mesgs[] = $objectsrc->error; - $error++; - } - $ii++; - } - } else { - $mesgs[] = $object->error; - $error++; - } - } - } - - // End of object creation, we show it - if ($id > 0 && !$error) { - foreach ($orders_id as $fk_supplier_order) { - $supplier_order = new CommandeFournisseur($db); - if ($supplier_order->fetch($fk_supplier_order) > 0 && $supplier_order->statut == 5) - { - if ($supplier_order->classifyBilled($user) < 0) - { - $db->rollback(); - $action = 'create'; - $_GET["origin"] = $_POST["origin"]; - $_GET["originid"] = $_POST["originid"]; - $mesgs[] = '
'.$object->error.'
'; - - $error++; - break; - } - } - } - - if (!$error) { - $db->commit(); - header('Location: '.DOL_URL_ROOT.'/fourn/facture/card.php?facid='.$id); - exit(); - } - } else { - $db->rollback(); - $action = 'create'; - $_GET["origin"] = $_POST["origin"]; - $_GET["originid"] = $_POST["originid"]; - $mesgs[] = '
'.$object->error.'
'; - } - } -} - -/* - * View - */ - -$html = new Form($db); -$htmlother = new FormOther($db); -$formfile = new FormFile($db); - -// Mode creation -if ($action == 'create' && !$error) { - llxHeader(); - print load_fiche_titre($langs->trans('NewBill')); - - $soc = new Societe($db); - if ($socid) - $res = $soc->fetch($socid); - if ($res) { - $cond_reglement_id = $soc->cond_reglement_supplier_id; - $mode_reglement_id = $soc->mode_reglement_supplier_id; - } - $dateinvoice = empty($conf->global->MAIN_AUTOFILL_DATE) ? -1 : ''; - - $objectsrc = new CommandeFournisseur($db); - $listoforders = array(); - foreach ($selected as $sel) { - $result = $objectsrc->fetch($sel); - if ($result > 0) { - $listoforders[] = $objectsrc->ref; - } - - if (empty($cond_reglement_id)) $cond_reglement_id = $objectsrc->cond_reglement_id; - if (empty($mode_reglement_id)) $mode_reglement_id = $objectsrc->mode_reglement_id; - } - - print '
'; - print ''; - print ''; - print ''."\n"; - print ''; - print ''; - print ''; - print ''; - - print ''; - - // Ref - print ''; - - // Ref supplier - print ''; - print ''; - - // Date invoice - print ''; - // Payment term - print ''; - // Payment mode - print ''; - // Project - if (!empty($conf->projet->enabled)) { - $formproject = new FormProjets($db); - - $langs->load('projects'); - print ''; - } - - // Other attributes - $parameters = array( - 'objectsrc' => $objectsrc, - 'idsrc' => $listoforders - ); - $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - print $hookmanager->resPrint; - - if (empty($reshook)) - { - $object = new FactureFournisseur($db); - print $object->showOptionals($extrafields, 'edit'); - } - - // Modele PDF - print ''; - print '"; - - // Public note - print ''; - print ''; - print ''; - - // Private note - if (empty($user->socid)) { - print ''; - print ''; - print ''; - } - - print '
'.$langs->trans('Ref').''.$langs->trans('Draft').'
'.$langs->trans('RefSupplier').'
'.$langs->trans('Date').''; - print $html->selectDate('', '', '', '', '', "add", 1, 1); - print '
'.$langs->trans('PaymentConditionsShort').''; - $html->select_conditions_paiements(isset($_POST['cond_reglement_id']) ? $_POST['cond_reglement_id'] : $cond_reglement_id, 'cond_reglement_id'); - print '
'.$langs->trans('PaymentMode').''; - $html->select_types_paiements(isset($_POST['mode_reglement_id']) ? $_POST['mode_reglement_id'] : $mode_reglement_id, 'mode_reglement_id'); - print '
'.$langs->trans('Project').''; - $formproject->select_projects($soc->id, $projectid, 'projectid'); - print '
'.$langs->trans('Model').''; - $liste = ModelePDFSuppliersInvoices::liste_modeles($db); - print $html->selectarray('model', $liste, $conf->global->INVOICE_SUPPLIER_ADDON_PDF); - print "
'.$langs->trans('NotePublic').''; - print '
'.$langs->trans('NotePrivate').''; - print '
'; - - while ($i < $n) { - print ''; - - $i++; - } - - // Button "Create Draft" - print '
'; - print "
\n"; - - print ''; - print "\n"; -} - -// Mode liste -if (($action != 'create' && $action != 'add') && !$error) { - llxHeader(); - ?> - - rights->societe->client->voir && !$socid) - $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql .= ' WHERE c.entity = '.$conf->entity; - $sql .= ' AND c.fk_soc = s.rowid'; - - // Show orders we can bill - if (empty($conf->global->SUPPLIER_ORDER_TO_INVOICE_STATUS)) - { - $sql .= " AND c.fk_statut IN (".$db->sanitize($db->escape(CommandeFournisseur::STATUS_RECEIVED_COMPLETELY)).")"; // Must match filter in htdocs/fourn/card.php - } else { - // CommandeFournisseur::STATUS_ORDERSENT.", ".CommandeFournisseur::STATUS_RECEIVED_PARTIALLY.", ".CommandeFournisseur::STATUS_RECEIVED_COMPLETELY - $sql .= " AND c.fk_statut IN (".$db->sanitize($db->escape($conf->global->SUPPLIER_ORDER_TO_INVOICE_STATUS)).")"; - } - - $sql .= " AND c.billed = 0"; - - // Find order that are not already invoiced - //No need due to the billed status - //$sql .= " AND c.rowid NOT IN (SELECT fk_source FROM " . MAIN_DB_PREFIX . "element_element WHERE targettype='invoice_supplier')"; - - if ($socid) - $sql .= ' AND s.rowid = '.$socid; - if (!$user->rights->societe->client->voir && !$socid) - $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; - if ($sref) { - $sql .= natural_search("c.ref", $sref); - } - if ($sall) { - $sql .= natural_search(array("c.ref", "c.note"), $sall); - } - - // Date filter - //$sql.= dolSqlDateFilter("c.date_commande", GETPOST("date_startday", 'int'), GETPOST("date_startmonth", 'int'), GETPOST("date_startyear", 'int')); - //$sql.= dolSqlDateFilter("c.date_livraison", $search_deliveryday, $search_deliverymonth, $search_deliveryyear); - if ($date_start) - $sql .= " AND c.date_commande >= '".$db->idate($date_start)."'"; - if ($date_end) - $sql .= " AND c.date_commande <= '".$db->idate($date_end)."'"; - if ($date_starty) - $sql .= " AND c.date_livraison >= '".$db->idate($date_starty)."'"; - if ($date_endy) - $sql .= " AND c.date_livraison <= '".$db->idate($date_endy)."'"; - - if (!empty($sref_client)) { - $sql .= natural_search('c.ref_supplier', $sref_client); - } - $sql .= ' ORDER BY '.$sortfield.' '.$sortorder; - dol_syslog('fourn/commande/ordertoinvoice.php sql='.$sql); - $resql = $db->query($sql); - - if ($resql) { - if ($socid) { - $soc = new Societe($db); - $soc->fetch($socid); - } - $title = $langs->trans('ListOfSupplierOrders'); - $title .= ' - '.$langs->trans('StatusOrderReceivedAllShort'); - $title .= ' - '.$soc->getNomUrl(1, 'supplier'); - - $num = $db->num_rows($resql); - - print load_fiche_titre($title); - - $i = 0; - $period = $html->selectDate($date_start, 'date_start', 0, 0, 1, '', 1, 0).' - '.$html->selectDate($date_end, 'date_end', 0, 0, 1, '', 1, 0); - $periodely = $html->selectDate($date_starty, 'date_start_dely', 0, 0, 1, '', 1, 0).' - '.$html->selectDate($date_endy, 'date_end_dely', 0, 0, 1, '', 1, 0); - - print '
'; - print ''; - print ''; - - - print ''; - print ''; - print_liste_field_titre('Ref', 'orderstoinvoice.php', 'c.ref', '', '&socid='.$socid, '', $sortfield, $sortorder); - print_liste_field_titre('RefSupplier', 'orderstoinvoice.php', 'c.ref_supplier', '', '&socid='.$socid, '', $sortfield, $sortorder); - print_liste_field_titre('OrderDate', 'orderstoinvoice.php', 'c.date_commande', '', '&socid='.$socid, '', $sortfield, $sortorder, 'center '); - print_liste_field_titre('DeliveryDate', 'orderstoinvoice.php', 'c.date_livraison', '', '&socid='.$socid, '', $sortfield, $sortorder, 'center '); - print_liste_field_titre('Status', '', '', '', '', '', '', '', 'right '); - print_liste_field_titre('GenerateBill', '', '', '', '', '', '', '', 'center '); - print "\n"; - - // Fields title search - print ''; - - print ''; - - // print ''; - - // DATE ORDER - print ''; - - // DATE DELIVERY - print ''; - - // SEARCH BUTTON - print ''; - - // ALL/NONE - print ''; - - print ''; - - $generic_commande = new CommandeFournisseur($db); - - while ($i < $num) { - $objp = $db->fetch_object($resql); - - print ''; - print ''; - - print ''; - - // Order date - print ''; - - // Delivery date - print ''; - - // Statut - print ''; - - // Checkbox - print ''; - - print ''; - - $total = $total + $objp->price; - $subtotal = $subtotal + $objp->price; - $i++; - } - print '
'; - // REF - print ''; - print ''; - print ''; - print ''; - print ''; - print $period; - print ''; - print $periodely; - print ''; - print ''; - print ''; - if ($conf->use_javascript_ajax) - print ''.$langs->trans("All").' / '.$langs->trans("None").''; - print '
'; - - $generic_commande->id = $objp->rowid; - $generic_commande->ref = $objp->ref; - - print ''; - print ''; - - print '
'; - print $generic_commande->getNomUrl(1, $objp->fk_statut); - print ''; - $filename = dol_sanitizeFileName($objp->ref); - $filedir = $conf->fournisseur->commande->dir_output.'/'.dol_sanitizeFileName($objp->ref); - $urlsource = $_SERVER['PHP_SELF'].'?id='.$objp->rowid; - print $formfile->getDocumentsLink($generic_commande->element, $filename, $filedir); - print '
'; - print '
'.$objp->ref_supplier.''; - print dol_print_date($db->jdate($objp->date_commande), 'day'); - print ''; - print dol_print_date($db->jdate($objp->date_livraison), 'day'); - print ''.$generic_commande->LibStatut($objp->fk_statut, 5).''; - print ''; - print '
'; - - /* - * Boutons actions - */ - print '
'; - print '
'; - print ''; - print ''; - print '
'; - // print ''.$langs->trans("GoBack").''; - print ''; - print '
'; - print '
'; - - print '
'; - - $db->free($resql); - } else { - dol_print_error($db); - } -} - -dol_htmloutput_mesg($mesg, $mesgs); - -// End of page -llxFooter(); -$db->close(); From bc308fc662474af2ef8823c5145d61699485705b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 2 Oct 2020 14:19:44 +0200 Subject: [PATCH 85/92] Look and feel v13 - Disabled users are greyed --- htdocs/core/class/html.form.class.php | 29 +++++++++++++++------------ 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 0a186c02d92..84960b21832 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -1733,16 +1733,7 @@ class Form $disableline = ''; if (is_array($enableonly) && count($enableonly) && !in_array($obj->rowid, $enableonly)) $disableline = ($enableonlytext ? $enableonlytext : '1'); - if ((is_object($selected) && $selected->id == $obj->rowid) || (!is_object($selected) && in_array($obj->rowid, $selected))) - { - $out .= ''; + $outarray[$userstatic->id] = $userstatic->getFullName($langs, $fullNameMode, -1, $maxlength).$moreinfo; $i++; From 954a6b5b3b8cb532661236e1e12af7112a908846 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 2 Oct 2020 14:26:16 +0200 Subject: [PATCH 86/92] CSS --- htdocs/ticket/class/ticket.class.php | 2 +- htdocs/ticket/list.php | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/ticket/class/ticket.class.php b/htdocs/ticket/class/ticket.class.php index 2264fb3d9ee..9076a236978 100644 --- a/htdocs/ticket/class/ticket.class.php +++ b/htdocs/ticket/class/ticket.class.php @@ -208,7 +208,7 @@ class Ticket extends CommonObject * 'foreignkey'=>'tablename.field' if the field is a foreign key (it is recommanded to name the field fk_...). * 'searchall' is 1 if we want to search in this field when making a search from the quick search button. * 'isameasure' must be set to 1 if you want to have a total on list for this field. Field type must be summable like integer or double(24,8). - * 'css' is the CSS style to use on field. For example: 'maxwidth200' + * 'css' and 'cssview' is the CSS style to use on field. 'css' is used in creation and update. 'cssview' is used in view mode. For example: 'maxwidth200', 'wordbreak' * 'help' is a string visible as a tooltip on field * 'showoncombobox' if value of the field must be visible into the label of the combobox that list record * 'disabled' is 1 if we want to have the field locked by a 'disabled' attribute. In most cases, this is never set into the definition of $fields into class, but is set dynamically by some part of code. diff --git a/htdocs/ticket/list.php b/htdocs/ticket/list.php index 91d84270a30..d3521b6f5a0 100644 --- a/htdocs/ticket/list.php +++ b/htdocs/ticket/list.php @@ -638,7 +638,7 @@ foreach ($object->fields as $key => $val) $formTicket->selectGroupTickets(dol_escape_htmltag($search[$key]), 'search_'.$key.'', '', 2, 1, 1, 0, ($val['css'] ? $val['css'] : 'maxwidth150')); print ''; } elseif ($key == 'severity_code') { - print ''; + print ''; $formTicket->selectSeveritiesTickets(dol_escape_htmltag($search[$key]), 'search_'.$key.'', '', 2, 1, 1, 0, ($val['css'] ? $val['css'] : 'maxwidth150')); print ''; } elseif ($key == 'fk_user_assign') { @@ -692,7 +692,7 @@ print ''; foreach ($object->fields as $key => $val) { $cssforfield = (empty($val['css']) ? '' : $val['css']); - if ($key == 'fk_statut') $cssforfield .= ($cssforfield ? ' ' : '').'center'; + if ($key == 'fk_statut' || $key == 'severity_code') $cssforfield .= ($cssforfield ? ' ' : '').'center'; elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'center'; elseif (in_array($val['type'], array('timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID') $cssforfield .= ($cssforfield ? ' ' : '').'right'; @@ -748,7 +748,7 @@ while ($i < min($num, $limit)) if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'center'; if (in_array($val['type'], array('timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; if (in_array($key, array('ref', 'fk_project'))) $cssforfield .= ($cssforfield ? ' ' : '').'nowraponall'; - if ($key == 'fk_statut') $cssforfield .= ($cssforfield ? ' ' : '').'center'; + if ($key == 'fk_statut' || $key == 'severity_code') $cssforfield .= ($cssforfield ? ' ' : '').'center'; if (!empty($arrayfields['t.'.$key]['checked'])) { print ' Date: Fri, 2 Oct 2020 14:55:02 +0200 Subject: [PATCH 87/92] Update list.php --- htdocs/fourn/commande/list.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/htdocs/fourn/commande/list.php b/htdocs/fourn/commande/list.php index ce596c30c65..9977caa3d54 100644 --- a/htdocs/fourn/commande/list.php +++ b/htdocs/fourn/commande/list.php @@ -522,11 +522,9 @@ if ($search_user > 0) $sql .= ", ".MAIN_DB_PREFIX."element_contact as ec"; $sql .= ", ".MAIN_DB_PREFIX."c_type_contact as tc"; } - $parameters = array(); -$reshook = $hookmanager->executeHooks('printFieldListTable', $parameters); // Note that $action and $object may have been modified by hook +$reshook = $hookmanager->executeHooks('printFieldListFrom', $parameters); // Note that $action and $object may have been modified by hook $sql .= $hookmanager->resPrint; - $sql .= ' WHERE cf.fk_soc = s.rowid'; $sql .= ' AND cf.entity IN ('.getEntity('supplier_order').')'; if ($socid > 0) $sql .= " AND s.rowid = ".$socid; From 31710479dc52eb67d829a8c8a2ef698581dffb15 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 2 Oct 2020 14:59:18 +0200 Subject: [PATCH 88/92] Update list.php --- htdocs/fourn/commande/list.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/fourn/commande/list.php b/htdocs/fourn/commande/list.php index 9977caa3d54..f54f8383cf3 100644 --- a/htdocs/fourn/commande/list.php +++ b/htdocs/fourn/commande/list.php @@ -503,7 +503,7 @@ if (!empty($extrafields->attributes[$object->table_element]['label'])) { } // Add fields from hooks $parameters = array(); -$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook +$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object); // Note that $action and $object may have been modified by hook $sql .= $hookmanager->resPrint; $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as country on (country.rowid = s.fk_pays)"; @@ -523,7 +523,7 @@ if ($search_user > 0) $sql .= ", ".MAIN_DB_PREFIX."c_type_contact as tc"; } $parameters = array(); -$reshook = $hookmanager->executeHooks('printFieldListFrom', $parameters); // Note that $action and $object may have been modified by hook +$reshook = $hookmanager->executeHooks('printFieldListFrom', $parameters, $object); // Note that $action and $object may have been modified by hook $sql .= $hookmanager->resPrint; $sql .= ' WHERE cf.fk_soc = s.rowid'; $sql .= ' AND cf.entity IN ('.getEntity('supplier_order').')'; @@ -564,7 +564,7 @@ if ($search_project_ref != '') $sql .= natural_search("p.ref", $search_project_r include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php'; // Add where from hooks $parameters = array(); -$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook +$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $object); // Note that $action and $object may have been modified by hook $sql .= $hookmanager->resPrint; $sql .= $db->order($sortfield, $sortorder); @@ -642,7 +642,7 @@ if ($resql) include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; $parameters = array(); - $reshook = $hookmanager->executeHooks('printFieldListSearchParam', $parameters); // Note that $action and $object may have been modified by hook + $reshook = $hookmanager->executeHooks('printFieldListSearchParam', $parameters, $object); // Note that $action and $object may have been modified by hook $param .= $hookmanager->resPrint; // List of mass actions available From 9ea7e26458dc05e9b6aa1ce32b024a812e4226c3 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 2 Oct 2020 15:00:39 +0200 Subject: [PATCH 89/92] Complete #14866 --- htdocs/modulebuilder/template/myobject_list.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/htdocs/modulebuilder/template/myobject_list.php b/htdocs/modulebuilder/template/myobject_list.php index e79128e1657..b1ec021e774 100644 --- a/htdocs/modulebuilder/template/myobject_list.php +++ b/htdocs/modulebuilder/template/myobject_list.php @@ -248,6 +248,10 @@ $sql .= preg_replace('/^,/', '', $hookmanager->resPrint); $sql = preg_replace('/,\s*$/', '', $sql); $sql .= " FROM ".MAIN_DB_PREFIX.$object->table_element." as t"; if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (t.rowid = ef.fk_object)"; +// Add table from hooks +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldListFrom', $parameters, $object); // Note that $action and $object may have been modified by hook +$sql .= $hookmanager->resPrint; if ($object->ismultientitymanaged == 1) $sql .= " WHERE t.entity IN (".getEntity($object->element).")"; else $sql .= " WHERE 1 = 1"; foreach ($search as $key => $val) @@ -281,7 +285,7 @@ if (! empty($extrafields->attributes[$object->table_element]['label'])) { } // Add where from hooks $parameters=array(); -$reshook=$hookmanager->executeHooks('printFieldListGroupBy',$parameters); // Note that $action and $object may have been modified by hook +$reshook=$hookmanager->executeHooks('printFieldListGroupBy',$parameters, $object); // Note that $action and $object may have been modified by hook $sql.=$hookmanager->resPrint; $sql=preg_replace('/,\s*$/','', $sql); */ @@ -360,6 +364,10 @@ foreach ($search as $key => $val) if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss); // Add $param from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; +// Add $param from hooks +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldListSearchParam', $parameters, $object); // Note that $action and $object may have been modified by hook +$param .= $hookmanager->resPrint; // List of mass actions available $arrayofmassactions = array( From bede4040f6ac65074ee151ad3ed85b3260843e67 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 2 Oct 2020 15:04:03 +0200 Subject: [PATCH 90/92] Update productcustomerprice.class.php --- htdocs/product/class/productcustomerprice.class.php | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/htdocs/product/class/productcustomerprice.class.php b/htdocs/product/class/productcustomerprice.class.php index 3758cc72238..f8b837ce472 100644 --- a/htdocs/product/class/productcustomerprice.class.php +++ b/htdocs/product/class/productcustomerprice.class.php @@ -252,7 +252,6 @@ class Productcustomerprice extends CommonObject $sql = "SELECT"; $sql .= " t.rowid,"; - $sql .= " t.entity,"; $sql .= " t.datec,"; $sql .= " t.tms,"; @@ -270,7 +269,7 @@ class Productcustomerprice extends CommonObject $sql .= " t.localtax2_tx,"; $sql .= " t.fk_user,"; $sql .= " t.import_key"; - + $sql .= " FROM ".MAIN_DB_PREFIX."product_customer_price as t"; $sql .= " WHERE t.rowid = ".$id; @@ -330,7 +329,6 @@ class Productcustomerprice extends CommonObject $sql = "SELECT"; $sql .= " t.rowid,"; - $sql .= " t.entity,"; $sql .= " t.datec,"; $sql .= " t.tms,"; @@ -363,8 +361,7 @@ class Productcustomerprice extends CommonObject // Manage filter if (count($filter) > 0) { foreach ($filter as $key => $value) { - if (strpos($key, 'date')) // To allow $filter['YEAR(s.dated)']=>$year - { + if (strpos($key, 'date')) { // To allow $filter['YEAR(s.dated)']=>$year $sql .= ' AND '.$key.' = \''.$this->db->escape($value).'\''; } elseif ($key == 'soc.nom') { $sql .= ' AND '.$key.' LIKE \'%'.$this->db->escape($value).'%\''; @@ -373,7 +370,7 @@ class Productcustomerprice extends CommonObject } elseif ($key == 't.price' || $key == 't.price_ttc') { $sql .= ' AND ' . $key . ' LIKE \'%' . price2num($value) . '%\''; } else { - $sql .= ' AND '.$key.' = '.$this->db->escape($value); + $sql .= ' AND '.$key.' = '.((int) $value); } } } From 2ea6c092a43eb5ee7b1abda904b7170257cc1e57 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Fri, 2 Oct 2020 13:05:50 +0000 Subject: [PATCH 91/92] Fixing style errors. --- htdocs/product/class/productcustomerprice.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/product/class/productcustomerprice.class.php b/htdocs/product/class/productcustomerprice.class.php index f8b837ce472..1553869d1f1 100644 --- a/htdocs/product/class/productcustomerprice.class.php +++ b/htdocs/product/class/productcustomerprice.class.php @@ -269,7 +269,7 @@ class Productcustomerprice extends CommonObject $sql .= " t.localtax2_tx,"; $sql .= " t.fk_user,"; $sql .= " t.import_key"; - + $sql .= " FROM ".MAIN_DB_PREFIX."product_customer_price as t"; $sql .= " WHERE t.rowid = ".$id; From 533fdda8485512635a28f99f07d6aa41c29f7452 Mon Sep 17 00:00:00 2001 From: Anthony Berton Date: Fri, 2 Oct 2020 15:11:02 +0200 Subject: [PATCH 92/92] Update vcard.php --- htdocs/user/vcard.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/htdocs/user/vcard.php b/htdocs/user/vcard.php index 5d99a4a9e89..9d8fd6478b4 100644 --- a/htdocs/user/vcard.php +++ b/htdocs/user/vcard.php @@ -40,8 +40,6 @@ if ($user->socid > 0) $socid = $user->socid; $feature2 = 'user'; $result = restrictedArea($user, 'user', $id, 'user', $feature2); -if ($user->id <> $id && !$canreaduser) accessforbidden(); - $result = $user2->fetch($id); if ($result <= 0)