diff --git a/ChangeLog b/ChangeLog index 10c0c98c625..610f34d669f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -18,6 +18,8 @@ Following changes may create regressions for some external modules, but were nec * Remove the old deprecated code of doActions and getInstanceDao in canvas. The doActions of standard hooks are already available and are better. * Removed method fetch_prods() and get_each_prod() not used, keep only get_arbo_each_prod() that is better. +* The hook contaxt commcard has been renamed thirdpartycomm +* The hook contaxt thirdpartycard has been renamed thirdpartycontact ***** ChangeLog for 7.0.1 compared to 7.0.0 ***** diff --git a/htdocs/accountancy/admin/account.php b/htdocs/accountancy/admin/account.php index 98ecd8e327c..2dd71e8e2e6 100644 --- a/htdocs/accountancy/admin/account.php +++ b/htdocs/accountancy/admin/account.php @@ -40,6 +40,7 @@ $action = GETPOST('action','aZ09'); $cancel = GETPOST('cancel','alpha'); $id = GETPOST('id', 'int'); $rowid = GETPOST('rowid', 'int'); +$contextpage=GETPOST('contextpage','aZ')?GETPOST('contextpage','aZ'):'accountingaccountlist'; // To manage different context of search $search_account = GETPOST("search_account"); $search_label = GETPOST("search_label"); @@ -74,8 +75,6 @@ $arrayfields=array( $accounting = new AccountingAccount($db); -// Initialize technical object to manage context to save list fields -$contextpage=GETPOST('contextpage','aZ')?GETPOST('contextpage','aZ'):'accountingaccountlist'; /* diff --git a/htdocs/adherents/list.php b/htdocs/adherents/list.php index b048d6ed551..6ae8058c189 100644 --- a/htdocs/adherents/list.php +++ b/htdocs/adherents/list.php @@ -79,6 +79,7 @@ if (! $sortorder) { $sortorder=($filter=='outofdate'?"DESC":"ASC"); } if (! $sortfield) { $sortfield=($filter=='outofdate'?"d.datefin":"d.lastname"); } // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context +$object = new Adherent($db); $hookmanager->initHooks(array('memberlist')); $extrafields = new ExtraFields($db); diff --git a/htdocs/admin/accountant.php b/htdocs/admin/accountant.php index e7733e64941..11fa5d68e64 100644 --- a/htdocs/admin/accountant.php +++ b/htdocs/admin/accountant.php @@ -29,6 +29,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; $action=GETPOST('action','aZ09'); +$contextpage=GETPOST('contextpage','aZ')?GETPOST('contextpage','aZ'):'adminaccoutant'; // To manage different context of search $langs->load("admin"); $langs->load("companies"); @@ -37,9 +38,6 @@ if (! $user->admin) accessforbidden(); $error=0; -// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context -$contextpage=array('adminaccoutant','globaladmin'); -$hookmanager->initHooks($contextpage); /* * Actions diff --git a/htdocs/admin/company.php b/htdocs/admin/company.php index 655a10f5735..0021cac68b4 100644 --- a/htdocs/admin/company.php +++ b/htdocs/admin/company.php @@ -38,6 +38,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; $action=GETPOST('action','aZ09'); +$contextpage=GETPOST('contextpage','aZ')?GETPOST('contextpage','aZ'):'admincompany'; // To manage different context of search $langs->load("admin"); $langs->load("companies"); @@ -47,8 +48,7 @@ if (! $user->admin) accessforbidden(); $error=0; // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context -$contextpage=array('admincompany','globaladmin'); -$hookmanager->initHooks($contextpage); +$hookmanager->initHooks(array('admincompany','globaladmin')); /* * Actions diff --git a/htdocs/admin/ihm.php b/htdocs/admin/ihm.php index 03f3d364cca..23cc0600705 100644 --- a/htdocs/admin/ihm.php +++ b/htdocs/admin/ihm.php @@ -46,12 +46,10 @@ $langs->load("agenda"); if (! $user->admin) accessforbidden(); $action = GETPOST('action','aZ09'); +$contextpage=GETPOST('contextpage','aZ')?GETPOST('contextpage','aZ'):'adminihm'; // To manage different context of search if (! defined("MAIN_MOTD")) define("MAIN_MOTD",""); -// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context -$contextpage=array('adminihm','globaladmin'); -$hookmanager->initHooks($contextpage); /* diff --git a/htdocs/comm/action/list.php b/htdocs/comm/action/list.php index 26c88b47ad3..a200c6571b2 100644 --- a/htdocs/comm/action/list.php +++ b/htdocs/comm/action/list.php @@ -35,6 +35,7 @@ include_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php'; $langs->loadLangs(array("users","companies","agenda","commercial")); $action=GETPOST('action','alpha'); +$contextpage=GETPOST('contextpage','aZ')?GETPOST('contextpage','aZ'):'actioncommlist'; // To manage different context of search $resourceid=GETPOST("resourceid","int"); $year=GETPOST("year",'int'); $month=GETPOST("month",'int'); @@ -68,8 +69,6 @@ $filtert = GETPOST("filtert","int",3); $usergroup = GETPOST("usergroup","int",3); $showbirthday = empty($conf->use_javascript_ajax)?GETPOST("showbirthday","int"):1; -$contextpage='actioncommlist'; - $extrafields = new ExtraFields($db); // fetch optionals attributes and labels $extralabels = $extrafields->fetch_name_optionals_label('actioncomm'); @@ -114,6 +113,7 @@ if (! $user->rights->agenda->allactions->read || $filter=='mine') // If no permi } // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context +$object = new ActionComm($db); $hookmanager->initHooks(array('agendalist')); $arrayfields=array( diff --git a/htdocs/comm/card.php b/htdocs/comm/card.php index 7471c9da962..eee4d529751 100644 --- a/htdocs/comm/card.php +++ b/htdocs/comm/card.php @@ -82,7 +82,7 @@ $extrafields = new ExtraFields($db); $extralabels=$extrafields->fetch_name_optionals_label($object->table_element); // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context -$hookmanager->initHooks(array('commcard','globalcard')); +$hookmanager->initHooks(array('thirdpartycomm','globalcard')); /* diff --git a/htdocs/comm/propal/list.php b/htdocs/comm/propal/list.php index de7715bdcf4..3e62d8d0298 100644 --- a/htdocs/comm/propal/list.php +++ b/htdocs/comm/propal/list.php @@ -53,6 +53,7 @@ $massaction=GETPOST('massaction','alpha'); $show_files=GETPOST('show_files','int'); $confirm=GETPOST('confirm','alpha'); $toselect = GETPOST('toselect', 'array'); +$contextpage=GETPOST('contextpage','aZ')?GETPOST('contextpage','aZ'):'proposallist'; $search_user=GETPOST('search_user','int'); $search_sale=GETPOST('search_sale','int'); @@ -95,9 +96,6 @@ $pagenext = $page + 1; if (! $sortfield) $sortfield='p.ref'; if (! $sortorder) $sortorder='DESC'; -// Initialize technical object to manage context to save list fields -$contextpage=GETPOST('contextpage','aZ')?GETPOST('contextpage','aZ'):'proposallist'; - // Security check $module='propal'; $dbtable=''; @@ -114,6 +112,7 @@ $result = restrictedArea($user, $module, $objectid, $dbtable); $diroutputmassaction=$conf->propal->multidir_output[$conf->entity] . '/temp/massgeneration/'.$user->id; // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context +$object = new Propal($db); $hookmanager->initHooks(array('propallist')); $extrafields = new ExtraFields($db); diff --git a/htdocs/commande/list.php b/htdocs/commande/list.php index 784f44aad4c..fa5cdb15633 100644 --- a/htdocs/commande/list.php +++ b/htdocs/commande/list.php @@ -51,6 +51,7 @@ $massaction=GETPOST('massaction','alpha'); $show_files=GETPOST('show_files','int'); $confirm=GETPOST('confirm','alpha'); $toselect = GETPOST('toselect', 'array'); +$contextpage=GETPOST('contextpage','aZ')?GETPOST('contextpage','aZ'):'orderlist'; $search_orderyear=GETPOST("search_orderyear","int"); $search_ordermonth=GETPOST("search_ordermonth","int"); @@ -95,11 +96,9 @@ $pagenext = $page + 1; if (! $sortfield) $sortfield='c.ref'; if (! $sortorder) $sortorder='DESC'; -// Initialize technical object to manage context to save list fields -$contextpage=GETPOST('contextpage','aZ')?GETPOST('contextpage','aZ'):'orderlist'; - // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context -$hookmanager->initHooks(array($contextpage)); +$object = new Commande($db); +$hookmanager->initHooks(array('orderlist')); $extrafields = new ExtraFields($db); // fetch optionals attributes and labels diff --git a/htdocs/compta/bank/bankentries_list.php b/htdocs/compta/bank/bankentries_list.php index 8c234716bee..397d9fd5d7b 100644 --- a/htdocs/compta/bank/bankentries_list.php +++ b/htdocs/compta/bank/bankentries_list.php @@ -54,6 +54,7 @@ $ref = GETPOST('ref','alpha'); $action=GETPOST('action','alpha'); $cancel=GETPOST('cancel','alpha'); $confirm=GETPOST('confirm','alpha'); +$contextpage='banktransactionlist'.(empty($object->ref)?'':'-'.$object->id); // Security check $fieldvalue = (! empty($id) ? $id : (! empty($ref) ? $ref :'')); @@ -120,10 +121,6 @@ if ($id > 0 || ! empty($ref)) } -// Initialize technical object to manage context to save list fields -$contextpage='banktransactionlist'.(empty($object->ref)?'':'-'.$object->id); -//var_dump($contextpage); - // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $hookmanager->initHooks(array('banktransactionlist', $contextpage)); $extrafields = new ExtraFields($db); diff --git a/htdocs/compta/bank/list.php b/htdocs/compta/bank/list.php index 6a39416342e..54e011d9db3 100644 --- a/htdocs/compta/bank/list.php +++ b/htdocs/compta/bank/list.php @@ -1,4 +1,6 @@ * Copyright (C) 2004-2016 Laurent Destailleur * Copyright (C) 2005-2012 Regis Houssin @@ -42,6 +44,7 @@ $massaction=GETPOST('massaction','alpha'); $show_files=GETPOST('show_files','int'); $confirm=GETPOST('confirm','alpha'); $toselect = GETPOST('toselect', 'array'); +$contextpage= GETPOST('contextpage','aZ')?GETPOST('contextpage','aZ'):'bankaccountlist'; // To manage different context of search $search_ref=GETPOST('search_ref','alpha'); $search_label=GETPOST('search_label','alpha'); @@ -66,11 +69,9 @@ $pagenext = $page + 1; if (! $sortfield) $sortfield='b.label'; if (! $sortorder) $sortorder='ASC'; -// Initialize technical object to manage context to save list fields -$contextpage='bankaccountlist'; - // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context -$hookmanager->initHooks(array($contextpage)); +$object = new Account($db); +$hookmanager->initHooks(array('bankaccountlist')); $extrafields = new ExtraFields($db); // fetch optionals attributes and labels diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index bb36535975e..d438c505a8d 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -3014,19 +3014,19 @@ else if ($id > 0 || ! empty($ref)) dol_fiche_head($head, 'compta', $langs->trans('InvoiceCustomer'), -1, 'bill'); - $formconfirm = array(); + $formconfirm = ''; // Confirmation de la conversion de l'avoir en reduc - //if ($action == 'converttoreduc') { + if ($action == 'converttoreduc') { if($object->type == Facture::TYPE_STANDARD) $type_fac = 'ExcessReceived'; elseif($object->type == Facture::TYPE_CREDIT_NOTE) $type_fac = 'CreditNote'; elseif($object->type == Facture::TYPE_DEPOSIT) $type_fac = 'Deposit'; $text = $langs->trans('ConfirmConvertToReduc', strtolower($langs->transnoentities($type_fac))); - $formconfirm['converttoreduc'] = $form->formconfirm($_SERVER['PHP_SELF'] . '?facid=' . $object->id, $langs->trans('ConvertToReduc'), $text, 'confirm_converttoreduc', '', "yes", 'converttoreduc'); - //} + $formconfirm = $form->formconfirm($_SERVER['PHP_SELF'] . '?facid=' . $object->id, $langs->trans('ConvertToReduc'), $text, 'confirm_converttoreduc', '', "yes", 2); + } // Confirmation to delete invoice - //if ($action == 'delete') { + if ($action == 'delete') { $text = $langs->trans('ConfirmDeleteBill', $object->ref); $formquestion = array(); @@ -3050,15 +3050,15 @@ else if ($id > 0 || ! empty($ref)) // array('type' => 'checkbox', 'name' => 'update_prices', 'label' => $langs->trans("PuttingPricesUpToDate"), 'value' // => 1), array('type' => 'other','name' => 'idwarehouse','label' => $label,'value' => $formproduct->selectWarehouses(GETPOST('idwarehouse')?GETPOST('idwarehouse'):'ifone', 'idwarehouse', '', 1, 0, 0, $langs->trans("NoStockAction")))); - $formconfirm['delete'] = $form->formconfirm($_SERVER['PHP_SELF'] . '?facid=' . $object->id, $langs->trans('DeleteBill'), $text, 'confirm_delete', $formquestion, "yes", 'delete'); + $formconfirm = $form->formconfirm($_SERVER['PHP_SELF'] . '?facid=' . $object->id, $langs->trans('DeleteBill'), $text, 'confirm_delete', $formquestion, "yes", 1); } else { - $formconfirm['delete'] = $form->formconfirm($_SERVER['PHP_SELF'] . '?facid=' . $object->id, $langs->trans('DeleteBill'), $text, 'confirm_delete', '', '', 'delete'); + $formconfirm = $form->formconfirm($_SERVER['PHP_SELF'] . '?facid=' . $object->id, $langs->trans('DeleteBill'), $text, 'confirm_delete', '', 'no', 1); } - //} + } // Confirmation of validation - //if ($action == 'valid') - //{ + if ($action == 'valid') + { // we check object has a draft number $objectref = substr($object->ref, 1, 4); if ($objectref == 'PROV') { @@ -3116,11 +3116,11 @@ else if ($id > 0 || ! empty($ref)) { $text .= '
' . img_warning() . ' ' . $langs->trans("ErrorInvoiceOfThisTypeMustBePositive"); } - $formconfirm['valid'] = $form->formconfirm($_SERVER["PHP_SELF"] . '?facid=' . $object->id, $langs->trans('ValidateBill'), $text, 'confirm_valid', $formquestion, (($object->type != Facture::TYPE_CREDIT_NOTE && $object->total_ttc < 0) ? "no" : "yes"), 'valid'); - //} + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?facid=' . $object->id, $langs->trans('ValidateBill'), $text, 'confirm_valid', $formquestion, (($object->type != Facture::TYPE_CREDIT_NOTE && $object->total_ttc < 0) ? "no" : "yes"), 2); + } // Confirm back to draft status - //if ($action == 'modif') { + if ($action == 'modif') { $text = $langs->trans('ConfirmUnvalidateBill', $object->ref); $formquestion = array(); @@ -3153,45 +3153,45 @@ else if ($id > 0 || ! empty($ref)) array('type' => 'other','name' => 'idwarehouse','label' => $label,'value' => $value)); } - $formconfirm['modif'] = $form->formconfirm($_SERVER["PHP_SELF"] . '?facid=' . $object->id, $langs->trans('UnvalidateBill'), $text, 'confirm_modif', $formquestion, "yes", 'modif'); - //} + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?facid=' . $object->id, $langs->trans('UnvalidateBill'), $text, 'confirm_modif', $formquestion, "yes", 1); + } // Confirmation du classement paye - if (/*$action == 'paid' && */$resteapayer <= 0) { - $formconfirm['paid'] = $form->formconfirm($_SERVER["PHP_SELF"] . '?facid=' . $object->id, $langs->trans('ClassifyPaid'), $langs->trans('ConfirmClassifyPaidBill', $object->ref), 'confirm_paid', '', "yes", 'paid'); - } else { - //if ($action == 'paid' $resteapayer > 0) { + if ($action == 'paid' && $resteapayer <= 0) { + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?facid=' . $object->id, $langs->trans('ClassifyPaid'), $langs->trans('ConfirmClassifyPaidBill', $object->ref), 'confirm_paid', '', "yes", 1); + } + if ($action == 'paid' && $resteapayer > 0) { // Code $i = 0; - $close [$i] ['code'] = 'discount_vat'; // escompte + $close [$i]['code'] = 'discount_vat'; // escompte $i ++; - $close [$i] ['code'] = 'badcustomer'; + $close [$i]['code'] = 'badcustomer'; $i ++; // Help $i = 0; - $close [$i] ['label'] = $langs->trans("HelpEscompte") . '

' . $langs->trans("ConfirmClassifyPaidPartiallyReasonDiscountVatDesc"); + $close [$i]['label'] = $langs->trans("HelpEscompte") . '

' . $langs->trans("ConfirmClassifyPaidPartiallyReasonDiscountVatDesc"); $i ++; - $close [$i] ['label'] = $langs->trans("ConfirmClassifyPaidPartiallyReasonBadCustomerDesc"); + $close [$i]['label'] = $langs->trans("ConfirmClassifyPaidPartiallyReasonBadCustomerDesc"); $i ++; // Texte $i = 0; - $close [$i] ['reason'] = $form->textwithpicto($langs->transnoentities("ConfirmClassifyPaidPartiallyReasonDiscount", $resteapayer, $langs->trans("Currency" . $conf->currency)), $close [$i] ['label'], 1); + $close [$i]['reason'] = $form->textwithpicto($langs->transnoentities("ConfirmClassifyPaidPartiallyReasonDiscount", $resteapayer, $langs->trans("Currency" . $conf->currency)), $close[$i]['label'], 1); $i ++; - $close [$i] ['reason'] = $form->textwithpicto($langs->transnoentities("ConfirmClassifyPaidPartiallyReasonBadCustomer", $resteapayer, $langs->trans("Currency" . $conf->currency)), $close [$i] ['label'], 1); + $close [$i]['reason'] = $form->textwithpicto($langs->transnoentities("ConfirmClassifyPaidPartiallyReasonBadCustomer", $resteapayer, $langs->trans("Currency" . $conf->currency)), $close[$i]['label'], 1); $i ++; // arrayreasons[code]=reason foreach ($close as $key => $val) { - $arrayreasons [$close [$key] ['code']] = $close [$key] ['reason']; + $arrayreasons[$close [$key]['code']] = $close[$key]['reason']; } // Cree un tableau formulaire - $formquestion = array('text' => $langs->trans("ConfirmClassifyPaidPartiallyQuestion"),array('type' => 'radio','name' => 'close_code','label' => $langs->trans("Reason"),'values' => $arrayreasons),array('type' => 'text','name' => 'close_note','label' => $langs->trans("Comment"),'value' => '','size' => '100')); + $formquestion = array('text' => $langs->trans("ConfirmClassifyPaidPartiallyQuestion"),array('type' => 'radio','name' => 'close_code','label' => $langs->trans("Reason"),'values' => $arrayreasons),array('type' => 'text','name' => 'close_note','label' => $langs->trans("Comment"),'value' => '','morecss' => 'minwidth300')); // Paiement incomplet. On demande si motif = escompte ou autre - $formconfirm['paid'] = $form->formconfirm($_SERVER["PHP_SELF"] . '?facid=' . $object->id, $langs->trans('ClassifyPaid'), $langs->trans('ConfirmClassifyPaidPartially', $object->ref), 'confirm_paid_partially', $formquestion, "yes", 'paid'); + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?facid=' . $object->id, $langs->trans('ClassifyPaid'), $langs->trans('ConfirmClassifyPaidPartially', $object->ref), 'confirm_paid_partially', $formquestion, "yes", 1, 250); } // Confirmation du classement abandonne - //if ($action == 'canceled') { + if ($action == 'canceled') { // S'il y a une facture de remplacement pas encore validee (etat brouillon), // on ne permet pas de classer abandonner la facture. if ($objectidnext) { @@ -3216,57 +3216,47 @@ else if ($id > 0 || ! empty($ref)) $arrayreasons [$close [2] ['code']] = $close [2] ['reason']; // Cree un tableau formulaire - $formquestion = array('text' => $langs->trans("ConfirmCancelBillQuestion"),array('type' => 'radio','name' => 'close_code','label' => $langs->trans("Reason"),'values' => $arrayreasons),array('type' => 'text','name' => 'close_note','label' => $langs->trans("Comment"),'value' => '','size' => '100')); + $formquestion = array('text' => $langs->trans("ConfirmCancelBillQuestion"),array('type' => 'radio','name' => 'close_code','label' => $langs->trans("Reason"),'values' => $arrayreasons),array('type' => 'text','name' => 'close_note','label' => $langs->trans("Comment"),'value' => '','morecss' => 'minwidth300')); - $formconfirm['canceled'] = $form->formconfirm($_SERVER['PHP_SELF'] . '?facid=' . $object->id, $langs->trans('CancelBill'), $langs->trans('ConfirmCancelBill', $object->ref), 'confirm_canceled', $formquestion, "yes"); + $formconfirm = $form->formconfirm($_SERVER['PHP_SELF'] . '?facid=' . $object->id, $langs->trans('CancelBill'), $langs->trans('ConfirmCancelBill', $object->ref), 'confirm_canceled', $formquestion, "yes", 1, 250); } - //} + } - //if ($action == 'deletepaiement') - //{ + if ($action == 'deletepaiement') + { $payment_id = GETPOST('paiement_id'); - $formconfirm['deletepaiement'] = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&paiement_id='.$payment_id, $langs->trans('DeletePayment'), $langs->trans('ConfirmDeletePayment'), 'confirm_delete_paiement', '', 0, 'deletepaiement'); + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&paiement_id='.$payment_id, $langs->trans('DeletePayment'), $langs->trans('ConfirmDeletePayment'), 'confirm_delete_paiement', '', 'no', 1); - //} + } // Confirmation de la suppression d'une ligne produit - //if ($action == 'ask_deleteline') { - $formconfirm['ask_deleteline'] = $form->formconfirm($_SERVER["PHP_SELF"] . '?facid=' . $object->id . '&lineid=' . $lineid, $langs->trans('DeleteProductLine'), $langs->trans('ConfirmDeleteProductLine'), 'confirm_deleteline', '', 'no', 'ask_deleteline'); - //} + if ($action == 'ask_deleteline') { + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?facid=' . $object->id . '&lineid=' . $lineid, $langs->trans('DeleteProductLine'), $langs->trans('ConfirmDeleteProductLine'), 'confirm_deleteline', '', 'no', 1); + } // Clone confirmation - //if ($action == 'clone') - //{ + if ($action == 'clone') + { // Create an array for form $formquestion = array( // 'text' => $langs->trans("ConfirmClone"), // array('type' => 'checkbox', 'name' => 'clone_content', 'label' => $langs->trans("CloneMainAttributes"), 'value' => 1) array('type' => 'other','name' => 'socid','label' => $langs->trans("SelectThirdParty"),'value' => $form->select_company($object->socid, 'socid', '(s.client=1 OR s.client=2 OR s.client=3)', 1))); // Paiement incomplet. On demande si motif = escompte ou autre - $formconfirm['clone'] = $form->formconfirm($_SERVER["PHP_SELF"] . '?facid=' . $object->id, $langs->trans('CloneInvoice'), $langs->trans('ConfirmCloneInvoice', $object->ref), 'confirm_clone', $formquestion, 'yes', 'clone'); - //} + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?facid=' . $object->id, $langs->trans('CloneInvoice'), $langs->trans('ConfirmCloneInvoice', $object->ref), 'confirm_clone', $formquestion, 'yes', 1); + } - - if (! empty($formconfirm[$action])) + if (! $formconfirm) { $parameters = array('lineid' => $lineid); $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - if (empty($reshook)) $formconfirm[$action].=$hookmanager->resPrint; - elseif ($reshook > 0) $formconfirm[$action]=$hookmanager->resPrint; - - // Print form confirm - print $formconfirm[$action]; - print ' - '; + if (empty($reshook)) $formconfirm.=$hookmanager->resPrint; + elseif ($reshook > 0) $formconfirm=$hookmanager->resPrint; } + // Print form confirm + print $formconfirm; + // Invoice content $linkback = '' . $langs->trans("BackToList") . ''; @@ -3914,13 +3904,9 @@ else if ($id > 0 || ! empty($ref)) print ''; if ($object->statut == Facture::STATUS_VALIDATED && $object->paye == 0 && $user->societe_id == 0) { - print 'use_javascript_ajax?' class="butActionFormConfirm" data-action-confirm="deletepaiement"':'').' href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=deletepaiement&paiement_id='.$objp->rowid.'">'; + print 'rowid.'">'; print img_delete(); print ''; - - if($conf->use_javascript_ajax) { - print $formconfirm['deletepaiement']; - } } print ''; print ''; @@ -4212,11 +4198,7 @@ else if ($id > 0 || ! empty($ref)) if ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->facture->creer)) || (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->facture->invoice_advance->unvalidate))) { - print ''; - - if($conf->use_javascript_ajax) { - print $formconfirm['modif']; - } + print ''; } else { print '
' . $langs->trans('Modify') . '
'; } @@ -4245,7 +4227,7 @@ else if ($id > 0 || ! empty($ref)) { if (! $objectidnext && $object->close_code != 'replaced') // Not replaced by another invoice { - print ''; + print ''; } else { print '
' . $langs->trans('ReOpen') . '
'; } @@ -4256,11 +4238,7 @@ else if ($id > 0 || ! empty($ref)) if ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->facture->creer)) || (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->facture->invoice_advance->validate))) { - print ''; - - if($conf->use_javascript_ajax) { - print $formconfirm['valid']; - } + print ''; } } @@ -4332,28 +4310,16 @@ else if ($id > 0 || ! empty($ref)) // For standard invoice with excess received if ($object->type == Facture::TYPE_STANDARD && empty($object->paye) && ($object->total_ttc - $totalpaye - $totalcreditnotes - $totaldeposits) < 0 && $user->rights->facture->creer && empty($discount->id)) { - print ''; - - if($conf->use_javascript_ajax) { - print $formconfirm['converttoreduc']; - } + print ''; } // For credit note if ($object->type == Facture::TYPE_CREDIT_NOTE && $object->statut == 1 && $object->paye == 0 && $user->rights->facture->creer && $object->getSommePaiement() == 0) { - print ''; - - if($conf->use_javascript_ajax) { - print $formconfirm['converttoreduc']; - } + print ''; } // For deposit invoice if ($object->type == Facture::TYPE_DEPOSIT && $user->rights->facture->creer && empty($discount->id)) { - print ''; - - if($conf->use_javascript_ajax) { - print $formconfirm['converttoreduc']; - } + print ''; } } @@ -4362,11 +4328,7 @@ else if ($id > 0 || ! empty($ref)) || ($object->type == Facture::TYPE_DEPOSIT && $object->paye == 0 && $object->total_ttc > 0 && $resteapayer == 0 && $user->rights->facture->paiement && empty($discount->id)) ) { - print ''; - - if($conf->use_javascript_ajax) { - print $formconfirm['paid']; - } + print ''; } // Classify 'closed not completely paid' (possible si validee et pas encore classee payee) @@ -4376,11 +4338,7 @@ else if ($id > 0 || ! empty($ref)) if ($totalpaye > 0 || $totalcreditnotes > 0) { // If one payment or one credit note was linked to this invoice - print ''; - - if($conf->use_javascript_ajax) { - print $formconfirm['paid']; - } + print ''; } else { @@ -4392,7 +4350,7 @@ else if ($id > 0 || ! empty($ref)) } else { - print ''; + print ''; } } } @@ -4401,11 +4359,7 @@ else if ($id > 0 || ! empty($ref)) // Clone if (($object->type == Facture::TYPE_STANDARD || $object->type == Facture::TYPE_DEPOSIT || $object->type == Facture::TYPE_PROFORMA) && $user->rights->facture->creer) { - print ''; - - if($conf->use_javascript_ajax) { - print $formconfirm['clone']; - } + print ''; } // Clone as predefined / Create template @@ -4464,11 +4418,7 @@ else if ($id > 0 || ! empty($ref)) } else { - print ''; - - if($conf->use_javascript_ajax) { - print $formconfirm['delete']; - } + print ''; } } else { print ''; diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php index a3576a438aa..b96c1220f52 100644 --- a/htdocs/compta/facture/list.php +++ b/htdocs/compta/facture/list.php @@ -66,6 +66,7 @@ $massaction=GETPOST('massaction','alpha'); $show_files=GETPOST('show_files','int'); $confirm=GETPOST('confirm','alpha'); $toselect = GETPOST('toselect', 'array'); +$contextpage=GETPOST('contextpage','aZ')?GETPOST('contextpage','aZ'):'invoicelist'; $lineid=GETPOST('lineid','int'); $userid=GETPOST('userid','int'); @@ -114,9 +115,6 @@ if (! $sortfield) $sortfield='f.datef'; $pageprev = $page - 1; $pagenext = $page + 1; -// Initialize technical object to manage context to save list fields -$contextpage=GETPOST('contextpage','aZ')?GETPOST('contextpage','aZ'):'invoicelist'; - // Security check $fieldid = (! empty($ref)?'facnumber':'rowid'); if (! empty($user->societe_id)) $socid=$user->societe_id; @@ -129,6 +127,7 @@ $object=new Facture($db); $now=dol_now(); // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context +$object = new Facture($db); $hookmanager->initHooks(array('invoicelist')); $extrafields = new ExtraFields($db); diff --git a/htdocs/compta/paiement.php b/htdocs/compta/paiement.php index 29528aacfa3..77d9cd0a93d 100644 --- a/htdocs/compta/paiement.php +++ b/htdocs/compta/paiement.php @@ -504,18 +504,18 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie print ''.$langs->trans('CheckTransmitter'); print ' ('.$langs->trans("ChequeMaker").')'; print ''; - print ''; + print ''; // Bank name print ''.$langs->trans('Bank'); print ' ('.$langs->trans("ChequeBank").')'; print ''; - print ''; + print ''; // Comments print ''.$langs->trans('Comments').''; print ''; - print ''; + print ''; print ''; diff --git a/htdocs/compta/paiement/card.php b/htdocs/compta/paiement/card.php index 2a8267aefb5..7c97b75d293 100644 --- a/htdocs/compta/paiement/card.php +++ b/htdocs/compta/paiement/card.php @@ -34,9 +34,7 @@ require_once DOL_DOCUMENT_ROOT .'/core/modules/facture/modules_facture.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/payments.lib.php'; if (! empty($conf->banque->enabled)) require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; -$langs->load('bills'); -$langs->load('banks'); -$langs->load('companies'); +$langs->loadLangs(array('bills','banks','companies')); $id=GETPOST('id','int'); $ref=GETPOST('ref', 'alpha'); @@ -222,57 +220,64 @@ print '
'; print ''."\n"; // Date payment -print ''; // Payment type (VIR, LIQ, ...) $labeltype=$langs->trans("PaymentType".$object->type_code)!=("PaymentType".$object->type_code)?$langs->trans("PaymentType".$object->type_code):$object->type_libelle; -print ''; - -// Payment numero -print ''; - -// Amount -print ''; - -// Note -print ''; +print ''; $disable_delete = 0; // Bank account if (! empty($conf->banque->enabled)) { - if ($object->fk_account > 0) - { - $bankline=new AccountLine($db); - $bankline->fetch($object->bank_line); - if ($bankline->rappro) - { - $disable_delete = 1; - $title_button = dol_escape_htmltag($langs->transnoentitiesnoconv("CantRemoveConciliatedPayment")); - } + if ($object->fk_account > 0) + { + $bankline=new AccountLine($db); + $bankline->fetch($object->bank_line); + if ($bankline->rappro) + { + $disable_delete = 1; + $title_button = dol_escape_htmltag($langs->transnoentitiesnoconv("CantRemoveConciliatedPayment")); + } - print ''; - print ''; - print ''; - print ''; - - print ''; - print ''; - print ''; + print ''; + print ''; - print ''; + print $accountstatic->getNomUrl(1); + print ''; + print ''; + } +} +// Payment numero +/* +$titlefield=$langs->trans('Numero').' ('.$langs->trans("ChequeOrTransferNumber").')'; +print ''; + +// Check transmitter +$titlefield=$langs->trans('CheckTransmitter').' ('.$langs->trans("ChequeMaker").')'; +print ''; + +// Bank name +$titlefield=$langs->trans('Bank').' ('.$langs->trans("ChequeBank").')'; +print ''; +*/ + +// Bank account +if (! empty($conf->banque->enabled)) +{ + if ($object->fk_account > 0) + { if ($object->type_code == 'CHQ' && $bankline->fk_bordereau > 0) { dol_include_once('/compta/paiement/cheque/class/remisecheque.class.php'); @@ -280,15 +285,30 @@ if (! empty($conf->banque->enabled)) $bordereau->fetch($bankline->fk_bordereau); print ''; - print ''; - print ''; + print ''; - print ''; + print ''; + print ''; } - } + } + + print ''; + print ''; + print ''; + print ''; } +// Comments +print ''; + +// Amount +print ''; + print '
'.$form->editfieldkey("Date",'datep',$object->date,$object,$user->rights->facture->paiement).''; +print '
'.$form->editfieldkey("Date",'datep',$object->date,$object,$user->rights->facture->paiement).''; print $form->editfieldval("Date",'datep',$object->date,$object,$user->rights->facture->paiement,'datepicker','',null,$langs->trans('PaymentDateUpdateSucceeded')); print '
'.$langs->trans('PaymentMode').''.$labeltype.'
'.$form->editfieldkey("Numero",'num_paiement',$object->numero,$object,$object->statut == 0 && $user->rights->fournisseur->facture->creer).''; -print $form->editfieldval("Numero",'num_paiement',$object->numero,$object,$object->statut == 0 && $user->rights->fournisseur->facture->creer,'string','',null,$langs->trans('PaymentNumberUpdateSucceeded')); -print '
'.$langs->trans('Amount').''.price($object->amount,'',$langs,0,-1,-1,$conf->currency).'
'.$form->editfieldkey("Note",'note',$object->note,$object,$user->rights->facture->paiement).''; -print $form->editfieldval("Note",'note',$object->note,$object,$user->rights->facture->paiement,'textarea'); -print '
'.$langs->trans('PaymentMode').''.$labeltype.'
'.$langs->trans('BankTransactionLine').''; - print $bankline->getNomUrl(1,0,'showconciliated'); - print '
'.$langs->trans('BankAccount').''; + print '
'.$langs->trans('BankAccount').''; $accountstatic=new Account($db); $accountstatic->fetch($bankline->fk_account); - print $accountstatic->getNomUrl(1); - print '
'.$form->editfieldkey($titlefield,'num_paiement',$object->num_paiement,$object,$object->statut == 0 && $user->rights->fournisseur->facture->creer).''; +print $form->editfieldval($titlefield,'num_paiement',$object->num_paiement,$object,$object->statut == 0 && $user->rights->fournisseur->facture->creer,'string','',null,$langs->trans('PaymentNumberUpdateSucceeded')); +print '
'.$form->editfieldkey($titlefield,'chqemetteur',$object->,$object,$object->statut == 0 && $user->rights->fournisseur->facture->creer).''; +print $form->editfieldval($titlefield,'chqemetteur',$object->aaa,$object,$object->statut == 0 && $user->rights->fournisseur->facture->creer,'string','',null,$langs->trans('ChequeMakeUpdateSucceeded')); +print '
'.$form->editfieldkey($titlefield,'chqbank',$object->aaa,$object,$object->statut == 0 && $user->rights->fournisseur->facture->creer).''; +print $form->editfieldval($titlefield,'chqbank',$object->aaa,$object,$object->statut == 0 && $user->rights->fournisseur->facture->creer,'string','',null,$langs->trans('ChequeBankUpdateSucceeded')); +print '
'.$langs->trans('CheckReceipt').''; + print ''.$langs->trans('CheckReceipt').''; print $bordereau->getNomUrl(1); - print '
'.$langs->trans('BankTransactionLine').''; + print $bankline->getNomUrl(1,0,'showconciliated'); + print '
'.$form->editfieldkey("Comments",'note',$object->note,$object,$user->rights->facture->paiement).''; +print $form->editfieldval("Note",'note',$object->note,$object,$user->rights->facture->paiement,'textarea:'.ROWS_3.':90%'); +print '
'.$langs->trans('Amount').''.price($object->amount,'',$langs,0,-1,-1,$conf->currency).'
'; print ''; diff --git a/htdocs/compta/paiement/class/paiement.class.php b/htdocs/compta/paiement/class/paiement.class.php index 705138f4df8..8b71cf40064 100644 --- a/htdocs/compta/paiement/class/paiement.class.php +++ b/htdocs/compta/paiement/class/paiement.class.php @@ -59,6 +59,7 @@ class Paiement extends CommonObject // de llx_paiement qui est lie aux types de //paiement de llx_c_paiement var $num_paiement; // Numero du CHQ, VIR, etc... + var $num_payment; // Numero du CHQ, VIR, etc... var $bank_account; // Id compte bancaire du paiement var $bank_line; // Id de la ligne d'ecriture bancaire // fk_paiement dans llx_paiement est l'id du type de paiement (7 pour CHQ, ...) @@ -88,7 +89,7 @@ class Paiement extends CommonObject { $sql = 'SELECT p.rowid, p.ref, p.datep as dp, p.amount, p.statut, p.fk_bank,'; $sql.= ' c.code as type_code, c.libelle as type_libelle,'; - $sql.= ' p.num_paiement, p.note,'; + $sql.= ' p.num_paiement as num_payment, p.note,'; $sql.= ' b.fk_account'; $sql.= ' FROM '.MAIN_DB_PREFIX.'paiement as p LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as c ON p.fk_paiement = c.id'; $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'bank as b ON p.fk_bank = b.rowid'; @@ -110,7 +111,9 @@ class Paiement extends CommonObject $this->ref = $obj->ref?$obj->ref:$obj->rowid; $this->date = $this->db->jdate($obj->dp); $this->datepaye = $this->db->jdate($obj->dp); - $this->numero = $obj->num_paiement; + $this->numero = $obj->num_payment; // deprecated + $this->num_paiement = $obj->num_payment; // deprecated + $this->num_payment = $obj->num_payment; $this->montant = $obj->amount; // deprecated $this->amount = $obj->amount; $this->note = $obj->note; diff --git a/htdocs/contact/list.php b/htdocs/contact/list.php index e2ad6031937..92e3f72595e 100644 --- a/htdocs/contact/list.php +++ b/htdocs/contact/list.php @@ -121,7 +121,8 @@ else if ($type == "o") } // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context -$hookmanager->initHooks(array($contextpage)); +$object = new Contact($db); +$hookmanager->initHooks(array('contactlist')); $extrafields = new ExtraFields($db); // fetch optionals attributes and labels diff --git a/htdocs/contrat/class/contrat.class.php b/htdocs/contrat/class/contrat.class.php index 755d3ff4bf0..215dc185ac4 100644 --- a/htdocs/contrat/class/contrat.class.php +++ b/htdocs/contrat/class/contrat.class.php @@ -264,6 +264,7 @@ class Contrat extends CommonObject * @param int $notrigger 1=Does not execute triggers, 0=Execute triggers * @param string $comment Comment * @return int <0 if KO, >0 if OK + * @see closeAll */ function activateAll($user, $date_start='', $notrigger=0, $comment='') { @@ -279,7 +280,7 @@ class Contrat extends CommonObject foreach($this->lines as $contratline) { // Open lines not already open - if ($contratline->statut != 4) + if ($contratline->statut != ContratLigne::STATUS_OPEN) { $contratline->context = $this->context; @@ -319,6 +320,7 @@ class Contrat extends CommonObject * @param int $notrigger 1=Does not execute triggers, 0=Execute triggers * @param string $comment Comment * @return int <0 if KO, >0 if OK + * @see activateAll */ function closeAll(User $user, $notrigger=0, $comment='') { @@ -334,11 +336,11 @@ class Contrat extends CommonObject foreach($this->lines as $contratline) { // Close lines not already closed - if ($contratline->statut != 5) + if ($contratline->statut != ContratLigne::STATUS_CLOSED) { $contratline->date_cloture=$now; $contratline->fk_user_cloture=$user->id; - $contratline->statut='5'; + $contratline->statut=ContratLigne::STATUS_CLOSED; $result=$contratline->close_line($user, $now, $comment, $notrigger); if ($result < 0) { @@ -806,10 +808,10 @@ class Contrat extends CommonObject //dol_syslog("1 ".$line->desc); //dol_syslog("2 ".$line->product_desc); - if ($line->statut == 0) $this->nbofserviceswait++; - if ($line->statut == 4 && (empty($line->date_fin_prevue) || $line->date_fin_prevue >= $now)) $this->nbofservicesopened++; - if ($line->statut == 4 && (! empty($line->date_fin_prevue) && $line->date_fin_prevue < $now)) $this->nbofservicesexpired++; - if ($line->statut == 5) $this->nbofservicesclosed++; + if ($line->statut == ContratLigne::STATUS_INITIAL) $this->nbofserviceswait++; + if ($line->statut == ContratLigne::STATUS_OPEN && (empty($line->date_fin_prevue) || $line->date_fin_prevue >= $now)) $this->nbofservicesopened++; + if ($line->statut == ContratLigne::STATUS_OPEN && (! empty($line->date_fin_prevue) && $line->date_fin_prevue < $now)) $this->nbofservicesexpired++; + if ($line->statut == ContratLigne::STATUS_CLOSED) $this->nbofservicesclosed++; $total_ttc+=$objp->total_ttc; // TODO Not saved into database $total_vat+=$objp->total_tva; @@ -2518,6 +2520,11 @@ class ContratLigne extends CommonObjectLine var $fk_user_cloture; var $commentaire; + const STATUS_INITIAL = 0; + const STATUS_OPEN = 4; + const STATUS_CLOSED = 5; + + /** * Constructor @@ -2556,51 +2563,51 @@ class ContratLigne extends CommonObjectLine $langs->load("contracts"); if ($mode == 0) { - if ($statut == 0) { return $langs->trans("ServiceStatusInitial"); } - if ($statut == 4 && $expired == -1) { return $langs->trans("ServiceStatusRunning"); } - if ($statut == 4 && $expired == 0) { return $langs->trans("ServiceStatusNotLate"); } - if ($statut == 4 && $expired == 1) { return $langs->trans("ServiceStatusLate"); } - if ($statut == 5) { return $langs->trans("ServiceStatusClosed"); } + if ($statut == self::STATUS_INITIAL) { return $langs->trans("ServiceStatusInitial"); } + if ($statut == self::STATUS_OPEN && $expired == -1) { return $langs->trans("ServiceStatusRunning"); } + if ($statut == self::STATUS_OPEN && $expired == 0) { return $langs->trans("ServiceStatusNotLate"); } + if ($statut == self::STATUS_OPEN && $expired == 1) { return $langs->trans("ServiceStatusLate"); } + if ($statut == self::STATUS_CLOSED) { return $langs->trans("ServiceStatusClosed"); } } if ($mode == 1) { - if ($statut == 0) { return $langs->trans("ServiceStatusInitial"); } - if ($statut == 4 && $expired == -1) { return $langs->trans("ServiceStatusRunning"); } - if ($statut == 4 && $expired == 0) { return $langs->trans("ServiceStatusNotLateShort"); } - if ($statut == 4 && $expired == 1) { return $langs->trans("ServiceStatusLateShort"); } - if ($statut == 5) { return $langs->trans("ServiceStatusClosed"); } + if ($statut == self::STATUS_INITIAL) { return $langs->trans("ServiceStatusInitial"); } + if ($statut == self::STATUS_OPEN && $expired == -1) { return $langs->trans("ServiceStatusRunning"); } + if ($statut == self::STATUS_OPEN && $expired == 0) { return $langs->trans("ServiceStatusNotLateShort"); } + if ($statut == self::STATUS_OPEN && $expired == 1) { return $langs->trans("ServiceStatusLateShort"); } + if ($statut == self::STATUS_CLOSED) { return $langs->trans("ServiceStatusClosed"); } } if ($mode == 2) { - if ($statut == 0) { return img_picto($langs->trans('ServiceStatusInitial'),'statut0').' '.$langs->trans("ServiceStatusInitial"); } - if ($statut == 4 && $expired == -1) { return img_picto($langs->trans('ServiceStatusRunning'),'statut4').' '.$langs->trans("ServiceStatusRunning"); } - if ($statut == 4 && $expired == 0) { return img_picto($langs->trans('ServiceStatusNotLate'),'statut4').' '.$langs->trans("ServiceStatusNotLateShort"); } - if ($statut == 4 && $expired == 1) { return img_picto($langs->trans('ServiceStatusLate'),'statut3').' '.$langs->trans("ServiceStatusLateShort"); } - if ($statut == 5) { return img_picto($langs->trans('ServiceStatusClosed'),'statut6') .' '.$langs->trans("ServiceStatusClosed"); } + if ($statut == self::STATUS_INITIAL) { return img_picto($langs->trans('ServiceStatusInitial'),'statut0').' '.$langs->trans("ServiceStatusInitial"); } + if ($statut == self::STATUS_OPEN && $expired == -1) { return img_picto($langs->trans('ServiceStatusRunning'),'statut4').' '.$langs->trans("ServiceStatusRunning"); } + if ($statut == self::STATUS_OPEN && $expired == 0) { return img_picto($langs->trans('ServiceStatusNotLate'),'statut4').' '.$langs->trans("ServiceStatusNotLateShort"); } + if ($statut == self::STATUS_OPEN && $expired == 1) { return img_picto($langs->trans('ServiceStatusLate'),'statut3').' '.$langs->trans("ServiceStatusLateShort"); } + if ($statut == self::STATUS_CLOSED) { return img_picto($langs->trans('ServiceStatusClosed'),'statut6') .' '.$langs->trans("ServiceStatusClosed"); } } if ($mode == 3) { - if ($statut == 0) { return img_picto($langs->trans('ServiceStatusInitial'),'statut0',$moreatt); } - if ($statut == 4 && $expired == -1) { return img_picto($langs->trans('ServiceStatusRunning'),'statut4',$moreatt); } - if ($statut == 4 && $expired == 0) { return img_picto($langs->trans('ServiceStatusNotLate'),'statut4',$moreatt); } - if ($statut == 4 && $expired == 1) { return img_picto($langs->trans('ServiceStatusLate'),'statut3',$moreatt); } - if ($statut == 5) { return img_picto($langs->trans('ServiceStatusClosed'),'statut6',$moreatt); } + if ($statut == self::STATUS_INITIAL) { return img_picto($langs->trans('ServiceStatusInitial'),'statut0',$moreatt); } + if ($statut == self::STATUS_OPEN && $expired == -1) { return img_picto($langs->trans('ServiceStatusRunning'),'statut4',$moreatt); } + if ($statut == self::STATUS_OPEN && $expired == 0) { return img_picto($langs->trans('ServiceStatusNotLate'),'statut4',$moreatt); } + if ($statut == self::STATUS_OPEN && $expired == 1) { return img_picto($langs->trans('ServiceStatusLate'),'statut3',$moreatt); } + if ($statut == self::STATUS_CLOSED) { return img_picto($langs->trans('ServiceStatusClosed'),'statut6',$moreatt); } } if ($mode == 4) { - if ($statut == 0) { return img_picto($langs->trans('ServiceStatusInitial'),'statut0').' '.$langs->trans("ServiceStatusInitial"); } - if ($statut == 4 && $expired == -1) { return img_picto($langs->trans('ServiceStatusRunning'),'statut4').' '.$langs->trans("ServiceStatusRunning"); } - if ($statut == 4 && $expired == 0) { return img_picto($langs->trans('ServiceStatusNotLate'),'statut4').' '.$langs->trans("ServiceStatusNotLate"); } - if ($statut == 4 && $expired == 1) { return img_picto($langs->trans('ServiceStatusLate'),'statut3').' '.$langs->trans("ServiceStatusLate"); } - if ($statut == 5) { return img_picto($langs->trans('ServiceStatusClosed'),'statut6') .' '.$langs->trans("ServiceStatusClosed"); } + if ($statut == self::STATUS_INITIAL) { return img_picto($langs->trans('ServiceStatusInitial'),'statut0').' '.$langs->trans("ServiceStatusInitial"); } + if ($statut == self::STATUS_OPEN && $expired == -1) { return img_picto($langs->trans('ServiceStatusRunning'),'statut4').' '.$langs->trans("ServiceStatusRunning"); } + if ($statut == self::STATUS_OPEN && $expired == 0) { return img_picto($langs->trans('ServiceStatusNotLate'),'statut4').' '.$langs->trans("ServiceStatusNotLate"); } + if ($statut == self::STATUS_OPEN && $expired == 1) { return img_picto($langs->trans('ServiceStatusLate'),'statut3').' '.$langs->trans("ServiceStatusLate"); } + if ($statut == self::STATUS_CLOSED) { return img_picto($langs->trans('ServiceStatusClosed'),'statut6') .' '.$langs->trans("ServiceStatusClosed"); } } if ($mode == 5) { - if ($statut == 0) { return $langs->trans("ServiceStatusInitial").' '.img_picto($langs->trans('ServiceStatusInitial'),'statut0'); } - if ($statut == 4 && $expired == -1) { return $langs->trans("ServiceStatusRunning").' '.img_picto($langs->trans('ServiceStatusRunning'),'statut4'); } - if ($statut == 4 && $expired == 0) { return $langs->trans("ServiceStatusNotLateShort").' '.img_picto($langs->trans('ServiceStatusNotLateShort'),'statut4'); } - if ($statut == 4 && $expired == 1) { return $langs->trans("ServiceStatusLateShort").' '.img_picto($langs->trans('ServiceStatusLate'),'statut3'); } - if ($statut == 5) { return $langs->trans("ServiceStatusClosed").' '.img_picto($langs->trans('ServiceStatusClosed'),'statut6'); } + if ($statut == self::STATUS_INITIAL) { return $langs->trans("ServiceStatusInitial").' '.img_picto($langs->trans('ServiceStatusInitial'),'statut0'); } + if ($statut == self::STATUS_OPEN && $expired == -1) { return $langs->trans("ServiceStatusRunning").' '.img_picto($langs->trans('ServiceStatusRunning'),'statut4'); } + if ($statut == self::STATUS_OPEN && $expired == 0) { return $langs->trans("ServiceStatusNotLateShort").' '.img_picto($langs->trans('ServiceStatusNotLateShort'),'statut4'); } + if ($statut == self::STATUS_OPEN && $expired == 1) { return $langs->trans("ServiceStatusLateShort").' '.img_picto($langs->trans('ServiceStatusLate'),'statut3'); } + if ($statut == self::STATUS_CLOSED) { return $langs->trans("ServiceStatusClosed").' '.img_picto($langs->trans('ServiceStatusClosed'),'statut6'); } } } @@ -3096,13 +3103,13 @@ class ContratLigne extends CommonObjectLine $this->db->begin(); - $sql = "UPDATE " . MAIN_DB_PREFIX . "contratdet SET statut = 4,"; + $sql = "UPDATE " . MAIN_DB_PREFIX . "contratdet SET statut = ".ContratLigne::STATUS_OPEN.","; $sql .= " date_ouverture = " . (dol_strlen($date) != 0 ? "'" . $this->db->idate($date) . "'" : "null") . ","; if ($date_end >= 0) $sql .= " date_fin_validite = " . (dol_strlen($date_end) != 0 ? "'" . $this->db->idate($date_end) . "'" : "null") . ","; $sql .= " fk_user_ouverture = " . $user->id . ","; $sql .= " date_cloture = null,"; $sql .= " commentaire = '" . $this->db->escape($comment) . "'"; - $sql .= " WHERE rowid = " . $this->id . " AND (statut = 0 OR statut = 3 OR statut = 5)"; + $sql .= " WHERE rowid = " . $this->id . " AND (statut = ".ContratLigne::STATUS_INITIAL." OR statut = ".ContratLigne::STATUS_CLOSED.")"; dol_syslog(get_class($this) . "::active_line", LOG_DEBUG); $resql = $this->db->query($sql); @@ -3114,7 +3121,7 @@ class ContratLigne extends CommonObjectLine if (! $error) { - $this->statut = 4; + $this->statut = ContratLigne::STATUS_OPEN; $this->date_ouverture = $date; $this->date_fin_validite = $date_end; $this->fk_user_ouverture = $user->id; @@ -3160,11 +3167,11 @@ class ContratLigne extends CommonObjectLine $this->db->begin(); - $sql = "UPDATE " . MAIN_DB_PREFIX . "contratdet SET statut = 5,"; + $sql = "UPDATE " . MAIN_DB_PREFIX . "contratdet SET statut = ".ContratLigne::STATUS_CLOSED.","; $sql .= " date_cloture = '" . $this->db->idate($date_end) . "',"; $sql .= " fk_user_cloture = " . $user->id . ","; $sql .= " commentaire = '" . $this->db->escape($comment) . "'"; - $sql .= " WHERE rowid = " . $this->id . " AND statut = 4"; + $sql .= " WHERE rowid = " . $this->id . " AND statut = ".ContratLigne::STATUS_OPEN; $resql = $this->db->query($sql); if ($resql) diff --git a/htdocs/contrat/list.php b/htdocs/contrat/list.php index 55dfacdf2c5..58fa3287c9a 100644 --- a/htdocs/contrat/list.php +++ b/htdocs/contrat/list.php @@ -45,6 +45,7 @@ $massaction=GETPOST('massaction','alpha'); $show_files=GETPOST('show_files','int'); $confirm=GETPOST('confirm','alpha'); $toselect = GETPOST('toselect', 'array'); +$contextpage= GETPOST('contextpage','aZ')?GETPOST('contextpage','aZ'):'contractlist'; // To manage different context of search $search_name=GETPOST('search_name'); $search_email=GETPOST('search_email'); @@ -95,10 +96,8 @@ $staticcontratligne=new ContratLigne($db); if ($search_status == '') $search_status=1; // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context -$contextpage='contractlist'; - -// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context -$hookmanager->initHooks(array($contextpage)); +$object = new Contrat($db); +$hookmanager->initHooks(array('contractlist')); $extrafields = new ExtraFields($db); // fetch optionals attributes and labels diff --git a/htdocs/contrat/services_list.php b/htdocs/contrat/services_list.php index 108fb6d4403..f78ed639804 100644 --- a/htdocs/contrat/services_list.php +++ b/htdocs/contrat/services_list.php @@ -53,6 +53,7 @@ $search_status=GETPOST("search_status","alpha"); $statut=GETPOST('statut')?GETPOST('statut'):1; $search_product_category=GETPOST('search_product_category','int'); $socid=GETPOST('socid','int'); +$contextpage=GETPOST('contextpage','aZ')?GETPOST('contextpage','aZ'):'contractservicelist'.$mode; $opouvertureprevuemonth=GETPOST('opouvertureprevuemonth'); $opouvertureprevueday=GETPOST('opouvertureprevueday'); @@ -74,11 +75,10 @@ $opclotureday=GETPOST('opclotureday'); $opclotureyear=GETPOST('opclotureyear'); $filter_opcloture=GETPOST('filter_opcloture'); -// Initialize context for list -$contextpage=GETPOST('contextpage','aZ')?GETPOST('contextpage','aZ'):'contractservicelist'.$mode; // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context -$hookmanager->initHooks(array($contextpage)); +$object = new ContratLigne($db); +$hookmanager->initHooks(array('contractservicelist')); $extrafields = new ExtraFields($db); // fetch optionals attributes and labels diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php index 2d5ba165365..d2177dfa33b 100644 --- a/htdocs/core/class/extrafields.class.php +++ b/htdocs/core/class/extrafields.class.php @@ -739,6 +739,21 @@ class ExtraFields // To avoid conflicts with external modules. TODO Remove this. if (!$forceload && !empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) return $array_name_label; + // Set array of label of entity + $labelmulticompany=array(); + if (!empty($conf->multicompany->enabled)) + { + $sql_entity_name='SELECT rowid, label FROM '.MAIN_DB_PREFIX.'entity WHERE rowid in (0,'.$conf->entity.')'; + $resql_entity_name=$this->db->query($sql_entity_name); + if ($resql_entity_name) + { + while ($obj = $this->db->fetch_object($resql_entity_name)) + { + $labelmulticompany[$obj->rowid]=$obj->label; + } + } + } + // We should not have several time this log. If we have, there is some optimization to do by calling a simple $object->fetch_optionals() that include cache management. dol_syslog("fetch_name_optionals_label elementtype=".$elementtype); @@ -778,6 +793,7 @@ class ExtraFields $this->attribute_langfile[$tab->name]=$tab->langs; $this->attribute_list[$tab->name]=$tab->list; $this->attribute_entityid[$tab->name]=$tab->entity; + $this->attribute_entitylabel[$tab->name]=(empty($labelmulticompany[$tab->entity])?'Entity'.$tab->entity:$labelmulticompany[$tab->entity]); // New usage $this->attributes[$tab->elementtype]['type'][$tab->name]=$tab->type; @@ -795,23 +811,7 @@ class ExtraFields $this->attributes[$tab->elementtype]['langfile'][$tab->name]=$tab->langs; $this->attributes[$tab->elementtype]['list'][$tab->name]=$tab->list; $this->attributes[$tab->elementtype]['entityid'][$tab->name]=$tab->entity; - - if (!empty($conf->multicompany->enabled)) - { - $sql_entity_name='SELECT label FROM '.MAIN_DB_PREFIX.'entity WHERE rowid='.$tab->entity; - $resql_entity_name=$this->db->query($sql_entity_name); - if ($resql_entity_name) - { - if ($this->db->num_rows($resql_entity_name)) - { - if ($obj = $this->db->fetch_object($resql_entity_name)) - { - $this->attribute_entitylabel[$tab->name]=$obj->label; // Old usage - $this->attributes[$tab->elementtype]['entitylabel'][$tab->name]=$obj->label; - } - } - } - } + $this->attributes[$tab->elementtype]['entitylabel'][$tab->name]=(empty($labelmulticompany[$tab->entity])?'Entity'.$tab->entity:$labelmulticompany[$tab->entity]); $this->attributes[$tab->elementtype]['loaded']=1; } @@ -1743,7 +1743,7 @@ class ExtraFields */ function showSeparator($key) { - $out = ''.$this->attribute_label[$key].''; + $out = ''.$this->attribute_label[$key].''; return $out; } diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index d53072efe0a..aa27be2d727 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -169,7 +169,7 @@ class Form $ret.=''; $ret.=''; $ret.=''; - if (empty($notabletag)) $ret.=''; + if (empty($notabletag)) $ret.='
'; if (empty($notabletag)) $ret.=''; + else print getTitleFieldOfList($langs->trans($extralabels[$key]), 0, $_SERVER["PHP_SELF"], $sortonfield, "", $param, ($align?'align="'.$align.'"':''), $sortfield, $sortorder)."\n"; } } } \ No newline at end of file diff --git a/htdocs/core/tpl/objectline_view.tpl.php b/htdocs/core/tpl/objectline_view.tpl.php index 6b8f24a2000..8fa73ed5709 100644 --- a/htdocs/core/tpl/objectline_view.tpl.php +++ b/htdocs/core/tpl/objectline_view.tpl.php @@ -277,13 +277,9 @@ if (empty($outputalsopricetotalwithtax)) $outputalsopricetotalwithtax=0; diff --git a/htdocs/expedition/list.php b/htdocs/expedition/list.php index d8e9925c08f..dd6fa84ec4b 100644 --- a/htdocs/expedition/list.php +++ b/htdocs/expedition/list.php @@ -32,6 +32,8 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; $langs->loadLangs(array("sendings","deliveries",'companies','bills')); +$contextpage= GETPOST('contextpage','aZ')?GETPOST('contextpage','aZ'):'shipmentlist'; // To manage different context of search + $socid=GETPOST('socid','int'); // Security check $expeditionid = GETPOST('id','int'); @@ -64,9 +66,6 @@ $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; -// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context -$contextpage='shipmentlist'; - $viewstatut=GETPOST('viewstatut'); // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context diff --git a/htdocs/expensereport/list.php b/htdocs/expensereport/list.php index 097a912b6c1..b32bf62f394 100644 --- a/htdocs/expensereport/list.php +++ b/htdocs/expensereport/list.php @@ -43,6 +43,7 @@ $massaction=GETPOST('massaction','alpha'); $show_files=GETPOST('show_files','int'); $confirm=GETPOST('confirm','alpha'); $toselect = GETPOST('toselect', 'array'); +$contextpage=GETPOST('contextpage','aZ')?GETPOST('contextpage','aZ'):'expensereportlist'; // Security check $socid = GETPOST('socid','int'); @@ -82,10 +83,8 @@ $optioncss = GETPOST('optioncss','alpha'); if ($search_status == '') $search_status=-1; if ($search_user == '') $search_user=-1; -// Initialize technical object to manage context to save list fields -$contextpage=GETPOST('contextpage','aZ')?GETPOST('contextpage','aZ'):'expensereportlist'; - // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context +$object = new ExpenseReport($db); $hookmanager->initHooks(array('expensereportlist')); $extrafields = new ExtraFields($db); diff --git a/htdocs/fichinter/list.php b/htdocs/fichinter/list.php index 7fc7ca244de..f0028e0760a 100644 --- a/htdocs/fichinter/list.php +++ b/htdocs/fichinter/list.php @@ -41,6 +41,7 @@ $massaction=GETPOST('massaction','alpha'); $show_files=GETPOST('show_files','int'); $confirm=GETPOST('confirm','alpha'); $toselect = GETPOST('toselect', 'array'); +$contextpage=GETPOST('contextpage','aZ')?GETPOST('contextpage','aZ'):'interventionlist'; $search_ref=GETPOST('search_ref')?GETPOST('search_ref','alpha'):GETPOST('search_inter','alpha'); $search_company=GETPOST('search_company','alpha'); @@ -72,9 +73,6 @@ if (! $sortfield) else $sortfield="f.ref"; } -// Initialize technical object to manage context to save list fields -$contextpage=GETPOST('contextpage','aZ')?GETPOST('contextpage','aZ'):'interventionlist'; - $sall=trim((GETPOST('search_all', 'alphanohtml')!='')?GETPOST('search_all', 'alphanohtml'):GETPOST('sall', 'alphanohtml')); $search_ref=GETPOST('search_ref')?GETPOST('search_ref','alpha'):GETPOST('search_inter','alpha'); $search_company=GETPOST('search_company','alpha'); @@ -83,7 +81,8 @@ $search_status=GETPOST('search_status'); $optioncss = GETPOST('optioncss','alpha'); // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context -$hookmanager->initHooks(array($contextpage)); +$object = new Fichinter($db); +$hookmanager->initHooks(array('interventionlist')); $extrafields = new ExtraFields($db); // fetch optionals attributes and labels diff --git a/htdocs/fourn/commande/list.php b/htdocs/fourn/commande/list.php index 760c80737f4..cca33fb4862 100644 --- a/htdocs/fourn/commande/list.php +++ b/htdocs/fourn/commande/list.php @@ -53,6 +53,7 @@ $massaction=GETPOST('massaction','alpha'); $show_files=GETPOST('show_files','int'); $confirm=GETPOST('confirm','alpha'); $toselect = GETPOST('toselect', 'array'); +$contextpage=GETPOST('contextpage','aZ')?GETPOST('contextpage','aZ'):'supplierorderlist'; $orderyear=GETPOST("orderyear","int"); $ordermonth=GETPOST("ordermonth","int"); @@ -109,11 +110,9 @@ if (! $sortorder) $sortorder='DESC'; if ($search_status == '') $search_status=-1; -// Initialize technical object to manage context to save list fields -$contextpage=GETPOST('contextpage','aZ')?GETPOST('contextpage','aZ'):'supplierorderlist'; - // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context -$hookmanager->initHooks(array($contextpage)); +$object = new CommandeFournisseur($db); +$hookmanager->initHooks(array('supplierorderlist')); $extrafields = new ExtraFields($db); // fetch optionals attributes and labels diff --git a/htdocs/fourn/facture/list.php b/htdocs/fourn/facture/list.php index efe029d7adf..2255722eed7 100644 --- a/htdocs/fourn/facture/list.php +++ b/htdocs/fourn/facture/list.php @@ -55,6 +55,7 @@ $show_files=GETPOST('show_files','int'); $confirm=GETPOST('confirm','alpha'); $toselect = GETPOST('toselect', 'array'); $optioncss = GETPOST('optioncss','alpha'); +$contextpage=GETPOST('contextpage','aZ')?GETPOST('contextpage','aZ'):'supplierinvoicelist'; $socid = GETPOST('socid','int'); @@ -118,16 +119,12 @@ $pagenext = $page + 1; if (! $sortorder) $sortorder="DESC"; if (! $sortfield) $sortfield="f.datef,f.rowid"; -// Initialize technical object to manage context to save list fields -$contextpage=GETPOST('contextpage','aZ')?GETPOST('contextpage','aZ'):'supplierinvoicelist'; - $diroutputmassaction=$conf->fournisseur->facture->dir_output . '/temp/massgeneration/'.$user->id; -$object=new FactureFournisseur($db); - $now=dol_now(); // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context +$object = new FactureFournisseur($db); $hookmanager->initHooks(array('supplierinvoicelist')); $extrafields = new ExtraFields($db); @@ -877,7 +874,7 @@ if ($resql) print ''; if (! $i) $totalarray['nbfield']++; } - + // Type if (! empty($arrayfields['f.type']['checked'])) { diff --git a/htdocs/holiday/define_holiday.php b/htdocs/holiday/define_holiday.php index 1620fa4733b..4dc1e92268e 100644 --- a/htdocs/holiday/define_holiday.php +++ b/htdocs/holiday/define_holiday.php @@ -34,6 +34,7 @@ $langs->load('users'); $langs->load('hrm'); $action=GETPOST('action','aZ09'); +$contextpage=GETPOST('contextpage','aZ')?GETPOST('contextpage','aZ'):'defineholidaylist'; $search_name=GETPOST('search_name', 'alpha'); $search_supervisor=GETPOST('search_supervisor', 'int'); @@ -58,9 +59,6 @@ if ($user->societe_id > 0) accessforbidden(); if (!$user->rights->holiday->read) accessforbidden(); -// Initialize technical object to manage context to save list fields -$contextpage=GETPOST('contextpage','aZ')?GETPOST('contextpage','aZ'):'defineholidaylist'; - // Initialize technical object to manage hooks. Note that conf->hooks_modules contains array $hookmanager->initHooks(array('defineholidaylist')); $extrafields = new ExtraFields($db); @@ -357,7 +355,7 @@ else print ''; - + // Button modify print ''."\n"; // Detect if we need a fetch on each output line $needToFetchEachLine=0; -foreach ($extrafields->attribute_computed as $key => $val) +foreach ($extrafields->attributes[$object->element]['computed'] as $key => $val) { if (preg_match('/\$object/',$val)) $needToFetchEachLine++; // There is at least one compute field that use $object } diff --git a/htdocs/modulebuilder/template/myobject_note.php b/htdocs/modulebuilder/template/myobject_note.php index 782be1c5bb9..3cb6a5791b3 100644 --- a/htdocs/modulebuilder/template/myobject_note.php +++ b/htdocs/modulebuilder/template/myobject_note.php @@ -54,7 +54,7 @@ $backtopage = GETPOST('backtopage', 'alpha'); $object=new MyObject($db); $extrafields = new ExtraFields($db); $diroutputmassaction=$conf->mymodule->dir_output . '/temp/massgeneration/'.$user->id; -$hookmanager->initHooks(array('myobjectnote')); // Note that conf->hooks_modules contains array +$hookmanager->initHooks(array('myobjectnote','globalcard')); // Note that conf->hooks_modules contains array // Fetch optionals attributes and labels $extralabels = $extrafields->fetch_name_optionals_label('myobject'); @@ -71,6 +71,7 @@ $permissionnote=1; //$permissionnote=$user->rights->mymodule->creer; // Used by the include of actions_setnotes.inc.php + /* * Actions */ diff --git a/htdocs/product/fournisseurs.php b/htdocs/product/fournisseurs.php index a2f79e4c402..ebb7f9753dc 100644 --- a/htdocs/product/fournisseurs.php +++ b/htdocs/product/fournisseurs.php @@ -47,6 +47,8 @@ $ref = GETPOST('ref', 'alpha'); $rowid=GETPOST('rowid','int'); $action=GETPOST('action', 'alpha'); $cancel=GETPOST('cancel', 'alpha'); +$contextpage=GETPOST('contextpage','aZ')?GETPOST('contextpage','aZ'):'pricesuppliercard'; + $socid=GETPOST('socid', 'int'); $cost_price=GETPOST('cost_price', 'alpha'); $backtopage=GETPOST('backtopage','alpha'); @@ -79,8 +81,6 @@ $pagenext = $page + 1; if (! $sortfield) $sortfield="s.nom"; if (! $sortorder) $sortorder="ASC"; -$contextpage='pricesuppliercard'; - // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $hookmanager->initHooks(array('pricesuppliercard','globalcard')); diff --git a/htdocs/product/inventory/card.php b/htdocs/product/inventory/card.php index 9c08fee974c..d41e3ea6d64 100644 --- a/htdocs/product/inventory/card.php +++ b/htdocs/product/inventory/card.php @@ -27,7 +27,7 @@ include_once DOL_DOCUMENT_ROOT.'/product/inventory/class/inventory.class.php'; include_once DOL_DOCUMENT_ROOT.'/product/inventory/lib/inventory.lib.php'; // Load traductions files requiredby by page -$langs->loadLangs(array("inventory","other")); +$langs->loadLangs(array("stocks","other")); // Get parameters $id = GETPOST('id', 'int'); diff --git a/htdocs/product/inventory/class/inventory.class.php b/htdocs/product/inventory/class/inventory.class.php index 8e0fde69687..dc4f600b529 100644 --- a/htdocs/product/inventory/class/inventory.class.php +++ b/htdocs/product/inventory/class/inventory.class.php @@ -76,11 +76,12 @@ class Inventory extends CommonObject */ public $fields=array( 'rowid' => array('type'=>'integer', 'label'=>'TechnicalID', 'visible'=>-1, 'enabled'=>1, 'position'=>1, 'notnull'=>1, 'index'=>1, 'comment'=>'Id',), - 'ref' => array('type'=>'varchar(64)', 'label'=>'Ref', 'visible'=>1, 'enabled'=>1, 'position'=>10, 'notnull'=>1, 'index'=>1, 'searchall'=>1, 'comment'=>'Reference of object', 'css'=>'maxwidth200'), - 'entity' => array('type'=>'integer', 'label'=>'Entity', 'visible'=>0, 'enabled'=>1, 'position'=>20, 'notnull'=>1, 'index'=>1,), - 'title' => array('type'=>'varchar(255)', 'label'=>'Label', 'visible'=>1, 'enabled'=>1, 'position'=>25, 'css'=>'minwidth300'), - 'fk_warehouse' => array('type'=>'integer:Entrepot:product/stock/class/entrepot.class.php', 'label'=>'Warehouse', 'visible'=>1, 'enabled'=>1, 'index'=>1, 'help'=>'LinkToThirparty'), - 'date_inventory' => array('type'=>'date', 'label'=>'DateValue', 'visible'=>1, 'enabled'=>1,), + 'ref' => array('type'=>'varchar(64)', 'label'=>'Ref', 'visible'=>1, 'enabled'=>1, 'position'=>10, 'notnull'=>1, 'index'=>1, 'searchall'=>1, 'comment'=>'Reference of object', 'css'=>'maxwidth200'), + 'entity' => array('type'=>'integer', 'label'=>'Entity', 'visible'=>0, 'enabled'=>1, 'position'=>20, 'notnull'=>1, 'index'=>1,), + 'title' => array('type'=>'varchar(255)', 'label'=>'Label', 'visible'=>1, 'enabled'=>1, 'position'=>25, 'css'=>'minwidth300'), + 'fk_warehouse' => array('type'=>'integer:Entrepot:product/stock/class/entrepot.class.php', 'label'=>'Warehouse', 'visible'=>1, 'enabled'=>1, 'position'=>30, 'index'=>1, 'help'=>'LinkToThirparty'), + 'fk_product' => array('type'=>'integer:Product:product/class/product.class.php', 'label'=>'Product', 'visible'=>1, 'enabled'=>1, 'position'=>32, 'index'=>1, 'help'=>'LinkToProduct'), + 'date_inventory' => array('type'=>'date', 'label'=>'DateValue', 'visible'=>1, 'enabled'=>1, 'position'=>35), 'date_validation' => array('type'=>'datetime', 'label'=>'DateValidation', 'visible'=>-2, 'enabled'=>1, 'position'=>502,), 'fk_user_valid' => array('type'=>'integer', 'label'=>'UserValidation', 'visible'=>-2, 'enabled'=>1, 'position'=>512,), @@ -358,31 +359,31 @@ class Inventory extends CommonObject } if ($mode == 2) { - if ($status == 0) return img_picto($langs->trans('Draft'),'statut5').' '.$langs->trans('Draft'); + if ($status == 0) return img_picto($langs->trans('Draft'),'statut0').' '.$langs->trans('Draft'); if ($status == 1) return img_picto($langs->trans('Enabled'),'statut4').' '.$langs->trans('Enabled'); if ($status == -1) return img_picto($langs->trans('Canceled'),'statut6').' '.$langs->trans('Canceled'); } if ($mode == 3) { - if ($status == 0) return img_picto($langs->trans('Draft'),'statut5'); + if ($status == 0) return img_picto($langs->trans('Draft'),'statut0'); if ($status == 1) return img_picto($langs->trans('Enabled'),'statut4'); if ($status == -1) return img_picto($langs->trans('Canceled'),'statut6'); } if ($mode == 4) { - if ($status == 0) return img_picto($langs->trans('Draft'),'statut5').' '.$langs->trans('Draft'); + if ($status == 0) return img_picto($langs->trans('Draft'),'statut0').' '.$langs->trans('Draft'); if ($status == 1) return img_picto($langs->trans('Enabled'),'statut4').' '.$langs->trans('Enabled'); if ($status == -1) return img_picto($langs->trans('Canceled'),'statut6').' '.$langs->trans('Canceled'); } if ($mode == 5) { - if ($status == 0) return $langs->trans('Draft').' '.img_picto($langs->trans('Draft'),'statut5'); + if ($status == 0) return $langs->trans('Draft').' '.img_picto($langs->trans('Draft'),'statut0'); if ($status == 1) return $langs->trans('Enabled').' '.img_picto($langs->trans('Enabled'),'statut4'); if ($status == -1) return $langs->trans('Canceled').' '.img_picto($langs->trans('Canceled'),'statut6'); } if ($mode == 6) { - if ($status == 0) return $langs->trans('Draft').' '.img_picto($langs->trans('Draft'),'statut5'); + if ($status == 0) return $langs->trans('Draft').' '.img_picto($langs->trans('Draft'),'statut0'); if ($status == 1) return $langs->trans('Enabled').' '.img_picto($langs->trans('Enabled'),'statut4'); if ($status == -1) return $langs->trans('Canceled').' '.img_picto($langs->trans('Canceled'),'statut6'); } diff --git a/htdocs/product/inventory/list.php b/htdocs/product/inventory/list.php index 8175d89d4ab..a24ca1c8808 100644 --- a/htdocs/product/inventory/list.php +++ b/htdocs/product/inventory/list.php @@ -28,19 +28,19 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; require_once DOL_DOCUMENT_ROOT.'/product/inventory/class/inventory.class.php'; // Load traductions files requiredby by page -$langs->loadLangs(array("inventory","other")); +$langs->loadLangs(array("stocks","other")); -$action = GETPOST('action','alpha'); -$massaction = GETPOST('massaction','alpha'); -$show_files = GETPOST('show_files','int'); -$confirm = GETPOST('confirm','alpha'); -$cancel = GETPOST('cancel', 'alpha'); -$toselect = GETPOST('toselect', 'array'); +$action = GETPOST('action','alpha')?GETPOST('action','alpha'):'view'; // The action 'add', 'create', 'edit', 'update', 'view', ... +$massaction = GETPOST('massaction','alpha'); // The bulk action (combo box choice into lists) +$show_files = GETPOST('show_files','int'); // Show files area generated by bulk actions ? +$confirm = GETPOST('confirm','alpha'); // Result of a confirmation +$cancel = GETPOST('cancel', 'alpha'); // We click on a Cancel button +$toselect = GETPOST('toselect', 'array'); // Array of ids of elements selected into a list $contextpage= GETPOST('contextpage','aZ')?GETPOST('contextpage','aZ'):'inventorylist'; // To manage different context of search +$backtopage = GETPOST('backtopage','alpha'); // Go back to a dedicated page +$optioncss = GETPOST('optioncss','aZ'); // Option for the css output (always '' except when 'print') $id = GETPOST('id','int'); -$backtopage = GETPOST('backtopage','alpha'); -$optioncss = GETPOST('optioncss','alpha'); // Load variable for pagination $limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit; @@ -65,7 +65,7 @@ $search_array_options=$extrafields->getOptionalsFromPost($extralabels,'','search if (! $sortfield) $sortfield="t.".key($object->fields); // Set here default search field. By default 1st field in definition. if (! $sortorder) $sortorder="ASC"; -// Protection if external user +// Security check $socid=0; if ($user->societe_id > 0) { @@ -78,7 +78,7 @@ if (empty($conf->global->MAIN_USE_ADVANCED_PERMS)) } else { - $result = restrictedArea($user, 'stock', $objectid, '', 'advance_inventory'); + $result = restrictedArea($user, 'stock', $objectid, '', 'advance_inventory'); } // Initialize array of search criterias @@ -101,22 +101,24 @@ $arrayfields=array(); foreach($object->fields as $key => $val) { // If $val['visible']==0, then we never show the field - if (! empty($val['visible'])) $arrayfields['t.'.$key]=array('label'=>$val['label'], 'checked'=>(($val['visible']<0)?0:1), 'enabled'=>$val['enabled']); + if (! empty($val['visible'])) $arrayfields['t.'.$key]=array('label'=>$val['label'], 'checked'=>(($val['visible']<0)?0:1), 'enabled'=>$val['enabled'], 'position'=>$val['position']); } // Extra fields -if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) +if (is_array($extrafields->attributes[$object->element]['label']) && count($extrafields->attributes[$object->element]['label'])) { - foreach($extrafields->attribute_label as $key => $val) + foreach($extrafields->attributes[$object->element]['label'] as $key => $val) { - if (! empty($extrafields->attribute_list[$key])) $arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>(($extrafields->attribute_list[$key]<0)?0:1), 'position'=>$extrafields->attribute_pos[$key], 'enabled'=>(abs($extrafields->attribute_list[$key])!=3 && $extrafields->attribute_perms[$key])); + if (! empty($extrafields->attributes[$object->element]['list'][$key])) + $arrayfields["ef.".$key]=array('label'=>$extrafields->attributes[$object->element]['label'][$key], 'checked'=>(($extrafields->attributes[$object->element]['list'][$key]<0)?0:1), 'position'=>$extrafields->attributes[$object->element]['pos'][$key], 'enabled'=>(abs($extrafields->attributes[$object->element]['list'][$key])!=3 && $extrafields->attributes[$object->element]['perms'][$key])); } } - +$object->fields = dol_sort_array($object->fields, 'position'); +$arrayfields = dol_sort_array($arrayfields, 'position'); /* - * ACTIONS + * Actions * * Put here all code to do according to value of "$action" parameter */ @@ -161,9 +163,9 @@ if (empty($reshook)) /* - * VIEW + * View * - * Put here all code to build page + * Put here all code to render page */ $form=new Form($db); @@ -172,7 +174,7 @@ $now=dol_now(); //$help_url="EN:Module_Inventory|FR:Module_Inventory_FR|ES:Módulo_Inventory"; $help_url=''; -$title = $langs->trans('ListOf', $langs->transnoentitiesnoconv("Inventorys")); +$title = $langs->trans('ListOfInventories'); // Build and execute select @@ -183,18 +185,19 @@ foreach($object->fields as $key => $val) $sql.='t.'.$key.', '; } // Add fields from extrafields -foreach ($extrafields->attribute_label as $key => $val) $sql.=($extrafields->attribute_type[$key] != 'separate' ? ", ef.".$key.' as options_'.$key : ''); +foreach ($extrafields->attributes[$object->element]['label'] as $key => $val) $sql.=($extrafields->attributes[$object->element]['type'][$key] != 'separate' ? ", ef.".$key.' as options_'.$key : ''); // Add fields from hooks $parameters=array(); $reshook=$hookmanager->executeHooks('printFieldListSelect', $parameters, $object); // Note that $action and $object may have been modified by hook $sql.=$hookmanager->resPrint; $sql=preg_replace('/, $/','', $sql); $sql.= " FROM ".MAIN_DB_PREFIX.$object->table_element." as t"; -if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."myobject_extrafields as ef on (t.rowid = ef.fk_object)"; -if ($object->ismultientitymanaged == 1) $sql.= " WHERE t.entity IN (".getEntity('inventory').")"; +if (is_array($extrafields->attributes[$object->element]['label']) && count($extrafields->attributes[$object->element]['label'])) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."myobject_extrafields as ef on (t.rowid = ef.fk_object)"; +if ($object->ismultientitymanaged == 1) $sql.= " WHERE t.entity IN (".getEntity('myobject').")"; else $sql.=" WHERE 1 = 1"; foreach($search as $key => $val) { + if ($key == 'status' && $search[$key] == -1) continue; $mode_search=(($object->isInt($object->fields[$key]) || $object->isFloat($object->fields[$key]))?1:0); if ($search[$key] != '') $sql.=natural_search($key, $search[$key], (($key == 'status')?2:$mode_search)); } @@ -207,18 +210,18 @@ $reshook=$hookmanager->executeHooks('printFieldListWhere', $parameters, $object) $sql.=$hookmanager->resPrint; /* If a group by is required - $sql.= " GROUP BY " - foreach($object->fields as $key => $val) - { - $sql.='t.'.$key.', '; - } - // Add fields from extrafields - foreach ($extrafields->attribute_label as $key => $val) $sql.=($extrafields->attribute_type[$key] != 'separate' ? ",ef.".$key : ''); - // Add where from hooks - $parameters=array(); - $reshook=$hookmanager->executeHooks('printFieldListGroupBy',$parameters); // Note that $action and $object may have been modified by hook - $sql.=$hookmanager->resPrint; - */ +$sql.= " GROUP BY " +foreach($object->fields as $key => $val) +{ + $sql.='t.'.$key.', '; +} +// Add fields from extrafields +foreach ($extrafields->attributes[$object->element]['label'] as $key => $val) $sql.=($extrafields->attributes[$object->element]['type'][$key] != 'separate' ? ",ef.".$key : ''); +// Add where from hooks +$parameters=array(); +$reshook=$hookmanager->executeHooks('printFieldListGroupBy',$parameters); // Note that $action and $object may have been modified by hook +$sql.=$hookmanager->resPrint; +*/ $sql.=$db->order($sortfield,$sortorder); @@ -229,17 +232,31 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) $result = $db->query($sql); $nbtotalofrecords = $db->num_rows($result); } - -$sql.= $db->plimit($limit+1, $offset); - -$resql=$db->query($sql); -if (! $resql) +// if total resultset is smaller then paging size (filtering), goto and load page 0 +if (($page * $limit) > $nbtotalofrecords) { - dol_print_error($db); - exit; + $page = 0; + $offset = 0; } +// if total resultset is smaller the limit, no need to do paging. +if (is_numeric($nbtotalofrecords) && $limit > $nbtotalofrecords) +{ + $resql = $result; + $num = $nbtotalofrecords; +} +else +{ + $sql.= $db->plimit($limit+1, $offset); -$num = $db->num_rows($resql); + $resql=$db->query($sql); + if (! $resql) + { + dol_print_error($db); + exit; + } + + $num = $db->num_rows($resql); +} // Direct jump if only one record found if ($num == 1 && ! empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $search_all) @@ -284,9 +301,10 @@ if ($optioncss != '') $param.='&optioncss='.urlencode($optioncss); // Add $param from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; +// List of mass actions available $arrayofmassactions = array( - 'presend'=>$langs->trans("SendByMail"), - 'builddoc'=>$langs->trans("PDFMerge"), + //'presend'=>$langs->trans("SendByMail"), + //'builddoc'=>$langs->trans("PDFMerge"), ); if ($user->rights->stock->supprimer) $arrayofmassactions['predelete']=$langs->trans("Delete"); if (in_array($massaction, array('presend','predelete'))) $arrayofmassactions=array(); @@ -348,7 +366,7 @@ print ''; foreach($object->fields as $key => $val) { $align=''; - if (in_array($val['type'], array('date','datetime','timestamp'))) $align=($align?' ':'').'center'; + if (in_array($val['type'], array('date','datetime','timestamp'))) $align.=($align?' ':'').'center'; if (in_array($val['type'], array('timestamp'))) $align.=($align?' ':'').'nowrap'; if ($key == 'status') $align.=($align?' ':'').'center'; if (! empty($arrayfields['t.'.$key]['checked'])) print ''; @@ -374,7 +392,7 @@ print ''; foreach($object->fields as $key => $val) { $align=''; - if (in_array($val['type'], array('date','datetime','timestamp'))) $align=($align?' ':'').'center'; + if (in_array($val['type'], array('date','datetime','timestamp'))) $align.=($align?' ':'').'center'; if (in_array($val['type'], array('timestamp'))) $align.=($align?' ':'').'nowrap'; if ($key == 'status') $align.=($align?' ':'').'center'; if (! empty($arrayfields['t.'.$key]['checked'])) print getTitleFieldOfList($arrayfields['t.'.$key]['label'], 0, $_SERVER['PHP_SELF'], 't.'.$key, '', $param, ($align?'class="'.$align.'"':''), $sortfield, $sortorder, $align.' ')."\n"; @@ -382,16 +400,16 @@ foreach($object->fields as $key => $val) // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; // Hook fields -$parameters=array('arrayfields'=>$arrayfields); +$parameters=array('arrayfields'=>$arrayfields,'param'=>$param,'sortfield'=>$sortfield,'sortorder'=>$sortorder); $reshook=$hookmanager->executeHooks('printFieldListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; -print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"],"",'','','align="center"',$sortfield,$sortorder,'maxwidthsearch ')."\n"; +print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"],'','','','align="center"',$sortfield,$sortorder,'maxwidthsearch ')."\n"; print ''."\n"; // Detect if we need a fetch on each output line $needToFetchEachLine=0; -foreach ($extrafields->attribute_computed as $key => $val) +foreach ($extrafields->attributes[$object->element]['computed'] as $key => $val) { if (preg_match('/\$object/',$val)) $needToFetchEachLine++; // There is at least one compute field that use $object } diff --git a/htdocs/product/list.php b/htdocs/product/list.php index e31a88e6f5c..c6a7835158d 100644 --- a/htdocs/product/list.php +++ b/htdocs/product/list.php @@ -94,7 +94,8 @@ if ((string) $type == '1') { $contextpage='servicelist'; if ($search_type=='') $ if ((string) $type == '0') { $contextpage='productlist'; if ($search_type=='') $search_type='0'; } // Initialize technical object to manage hooks. Note that conf->hooks_modules contains array of hooks -$hookmanager->initHooks(array($contextpage)); +$object=new Product($db); +$hookmanager->initHooks(array('productservicelist')); $extrafields = new ExtraFields($db); $form=new Form($db); @@ -179,13 +180,16 @@ $arrayfields=array( 'p.tobuy'=>array('label'=>$langs->trans("Status").' ('.$langs->trans("Buy").')', 'checked'=>1, 'position'=>1000) ); // Extra fields -if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) +if (is_array($extrafields->attributes[$object->element]['label']) && count($extrafields->attributes[$object->element]['label'])) { - foreach($extrafields->attribute_label as $key => $val) - { - if (! empty($extrafields->attribute_list[$key])) $arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>(($extrafields->attribute_list[$key]<0)?0:1), 'position'=>$extrafields->attribute_pos[$key], 'enabled'=>(abs($extrafields->attribute_list[$key])!=3 && $extrafields->attribute_perms[$key])); - } + foreach($extrafields->attributes[$object->element]['label'] as $key => $val) + { + if (! empty($extrafields->attributes[$object->element]['list'][$key])) + $arrayfields["ef.".$key]=array('label'=>$extrafields->attributes[$object->element]['label'][$key], 'checked'=>(($extrafields->attributes[$object->element]['list'][$key]<0)?0:1), 'position'=>$extrafields->attributes[$object->element]['pos'][$key], 'enabled'=>(abs($extrafields->attributes[$object->element]['list'][$key])!=3 && $extrafields->attributes[$object->element]['perms'][$key])); + } } +$object->fields = dol_sort_array($object->fields, 'position'); +$arrayfields = dol_sort_array($arrayfields, 'position'); @@ -274,13 +278,13 @@ else $sql .= ', pac.rowid prod_comb_id'; } // Add fields from extrafields - foreach ($extrafields->attribute_label as $key => $val) $sql.=($extrafields->attribute_type[$key] != 'separate' ? ",ef.".$key.' as options_'.$key : ''); + foreach ($extrafields->attributes[$object->element]['label'] as $key => $val) $sql.=($extrafields->attributes[$object->element]['type'][$key] != 'separate' ? ",ef.".$key.' as options_'.$key : ''); // Add fields from hooks $parameters=array(); $reshook=$hookmanager->executeHooks('printFieldListSelect',$parameters); // Note that $action and $object may have been modified by hook $sql.=$hookmanager->resPrint; $sql.= ' FROM '.MAIN_DB_PREFIX.'product as p'; - if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product_extrafields as ef on (p.rowid = ef.fk_object)"; + if (is_array($extrafields->attributes[$object->element]['label']) && count($extrafields->attributes[$object->element]['label'])) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product_extrafields as ef on (p.rowid = ef.fk_object)"; if (! empty($search_categ) || ! empty($catid)) $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX."categorie_product as cp ON p.rowid = cp.fk_product"; // We'll need this table joined to the select in order to filter by categ $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product_fournisseur_price as pfp ON p.rowid = pfp.fk_product"; // multilang @@ -331,7 +335,7 @@ else $sql .= ', pac.rowid'; } // Add fields from extrafields - foreach ($extrafields->attribute_label as $key => $val) $sql.=($extrafields->attribute_type[$key] != 'separate' ? ",ef.".$key : ''); + foreach ($extrafields->attributes[$object->element]['label'] as $key => $val) $sql.=($extrafields->attributes[$object->element]['type'][$key] != 'separate' ? ",ef.".$key : ''); // Add fields from hooks $parameters=array(); $reshook=$hookmanager->executeHooks('printFieldSelect',$parameters); // Note that $action and $object may have been modified by hook diff --git a/htdocs/product/stock/mouvement.php b/htdocs/product/stock/mouvement.php index 41c8f9ae1f0..0bed4022eb3 100644 --- a/htdocs/product/stock/mouvement.php +++ b/htdocs/product/stock/mouvement.php @@ -53,6 +53,8 @@ $msid=GETPOST('msid','int'); $product_id=GETPOST("product_id"); $action=GETPOST('action','aZ09'); $cancel=GETPOST('cancel','alpha'); +$contextpage=GETPOST('contextpage','aZ')?GETPOST('contextpage','aZ'):'movementlist'; + $idproduct = GETPOST('idproduct','int'); $year = GETPOST("year"); $month = GETPOST("month"); @@ -77,11 +79,9 @@ if (! $sortorder) $sortorder="DESC"; $pdluoid=GETPOST('pdluoid','int'); -// Initialize context for list -$contextpage=GETPOST('contextpage','aZ')?GETPOST('contextpage','aZ'):'movementlist'; - // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context -$hookmanager->initHooks(array($contextpage)); +$object = new MouvementStock($db); +$hookmanager->initHooks(array('movementlist')); $extrafields = new ExtraFields($db); // fetch optionals attributes and labels @@ -107,7 +107,6 @@ $arrayfields=array( //'m.tms'=>array('label'=>$langs->trans("DateModificationShort"), 'checked'=>0, 'position'=>500) ); -$object = new MouvementStock($db); // To be passed as parameter of executeHooks that need /* @@ -818,10 +817,10 @@ if ($resql) print '  '; print ''; } - + // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php'; - + // Fields from hook $parameters=array('arrayfields'=>$arrayfields); $reshook=$hookmanager->executeHooks('printFieldListOption',$parameters); // Note that $action and $object may have been modified by hook @@ -860,7 +859,7 @@ if ($resql) if (! empty($arrayfields['origin']['checked'])) print_liste_field_titre($arrayfields['origin']['label'],$_SERVER["PHP_SELF"], "","",$param,"",$sortfield,$sortorder); if (! empty($arrayfields['m.value']['checked'])) print_liste_field_titre($arrayfields['m.value']['label'],$_SERVER["PHP_SELF"], "m.value","",$param,'align="right"',$sortfield,$sortorder); if (! empty($arrayfields['m.price']['checked'])) print_liste_field_titre($arrayfields['m.price']['label'],$_SERVER["PHP_SELF"], "m.price","",$param,'align="right"',$sortfield,$sortorder); - + // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; @@ -891,7 +890,7 @@ if ($resql) $productstatic->label=$objp->produit; $productstatic->type=$objp->type; $productstatic->entity=$objp->entity; - $productstatic->status_batch=$objp->tobatch; + $productstatic->status_batch=$objp->tobatch; $productlot->id = $objp->lotid; $productlot->batch= $objp->batch; diff --git a/htdocs/product/stock/productlot_list.php b/htdocs/product/stock/productlot_list.php index 76d70c1ad10..1d1f6a89478 100644 --- a/htdocs/product/stock/productlot_list.php +++ b/htdocs/product/stock/productlot_list.php @@ -81,6 +81,7 @@ if ($user->societe_id > 0) } // Initialize technical object to manage hooks. Note that conf->hooks_modules contains array +$object = new Productlot($db); $hookmanager->initHooks(array('product_lotlist')); $extrafields = new ExtraFields($db); @@ -119,7 +120,6 @@ if (is_array($extrafields->attribute_label) && count($extrafields->attribute_lab } // Load object if id or ref is provided as parameter -$object=new Productlot($db); if (($id > 0 || ! empty($ref)) && $action != 'add') { $result=$object->fetch($id,$ref); diff --git a/htdocs/projet/list.php b/htdocs/projet/list.php index 22887c5e42d..3da1d4fe566 100644 --- a/htdocs/projet/list.php +++ b/htdocs/projet/list.php @@ -39,6 +39,7 @@ $massaction=GETPOST('massaction','alpha'); $show_files=GETPOST('show_files','int'); $confirm=GETPOST('confirm','alpha'); $toselect = GETPOST('toselect', 'array'); +$contextpage=GETPOST('contextpage','aZ')?GETPOST('contextpage','aZ'):'projectlist'; $title = $langs->trans("Projects"); @@ -95,12 +96,9 @@ $search_eyear = GETPOST('search_eyear','int'); if ($search_status == '') $search_status=-1; // -1 or 1 - -// Initialize context for list -$contextpage=GETPOST('contextpage','aZ')?GETPOST('contextpage','aZ'):'projectlist'; - // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context -$hookmanager->initHooks(array($contextpage)); +$object = new Project($db); +$hookmanager->initHooks(array('projectlist')); $extrafields = new ExtraFields($db); // fetch optionals attributes and labels @@ -141,7 +139,6 @@ if (is_array($extrafields->attribute_label) && count($extrafields->attribute_lab } } -$object = new Project($db); /* diff --git a/htdocs/projet/tasks/list.php b/htdocs/projet/tasks/list.php index 6ad2e51425f..a31ec6f57d4 100644 --- a/htdocs/projet/tasks/list.php +++ b/htdocs/projet/tasks/list.php @@ -71,7 +71,8 @@ $search_eyear = GETPOST('search_eyear','int'); $contextpage=GETPOST('contextpage','aZ')?GETPOST('contextpage','aZ'):'tasklist'; // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context -$hookmanager->initHooks(array($contextpage)); +$object = new Task($db); +$hookmanager->initHooks(array('tasklist')); $extrafields = new ExtraFields($db); // fetch optionals attributes and labels @@ -131,8 +132,6 @@ if (is_array($extrafields->attribute_label) && count($extrafields->attribute_lab } } -$object = new Task($db); - /* * Actions diff --git a/htdocs/projet/tasks/time.php b/htdocs/projet/tasks/time.php index 44a2ed1b8a8..e61d3ceb8ce 100644 --- a/htdocs/projet/tasks/time.php +++ b/htdocs/projet/tasks/time.php @@ -72,6 +72,7 @@ if (! $sortfield) $sortfield='t.task_date,t.task_datehour,t.rowid'; if (! $sortorder) $sortorder='DESC'; // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context +//$object = new TaskTime($db); $hookmanager->initHooks(array('projecttaskcard','globalcard')); $object = new Task($db); diff --git a/htdocs/resource/list.php b/htdocs/resource/list.php index 190659628f2..72c7945bf43 100644 --- a/htdocs/resource/list.php +++ b/htdocs/resource/list.php @@ -17,8 +17,8 @@ /** * \file resource/index.php - * \ingroup resource - * \brief Page to manage resource objects + * \ingroup resource + * \brief Page to manage resource objects */ @@ -43,8 +43,8 @@ $sortfield = GETPOST('sortfield','alpha'); // Initialize context for list $contextpage=GETPOST('contextpage','aZ')?GETPOST('contextpage','aZ'):'resourcelist'; +// Initialize technical objects $object = new Dolresource($db); - $extrafields = new ExtraFields($db); // fetch optionals attributes and labels @@ -84,7 +84,7 @@ foreach ($search_array_options as $key => $val) if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage; -$hookmanager->initHooks(array('resource_list')); +$hookmanager->initHooks(array('resourcelist')); if (empty($sortorder)) $sortorder="ASC"; if (empty($sortfield)) $sortfield="t.ref"; diff --git a/htdocs/societe/class/companypaymentmode.class.php b/htdocs/societe/class/companypaymentmode.class.php index 662361a619d..6a6dfa4d38c 100644 --- a/htdocs/societe/class/companypaymentmode.class.php +++ b/htdocs/societe/class/companypaymentmode.class.php @@ -203,7 +203,9 @@ class CompanyPaymentMode extends CommonObject */ public function create(User $user, $notrigger = false) { - return $this->createCommon($user, $notrigger); + $idpayment = $this->createCommon($user, $notrigger); + + return $idpayment; } /** diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index 62834b1271c..bb9748b1af3 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -1327,7 +1327,6 @@ class Societe extends CommonObject $result = 1; - // Retreive all extrafield // fetch optionals attributes and labels $this->fetch_optionals(); } diff --git a/htdocs/societe/document.php b/htdocs/societe/document.php index be549d6cac5..2cab1da971f 100644 --- a/htdocs/societe/document.php +++ b/htdocs/societe/document.php @@ -69,6 +69,10 @@ if ($id > 0 || ! empty($ref)) $courrier_dir = $conf->societe->multidir_output[$object->entity] . "/courrier/" . get_exdir($object->id,0,0,0,$object,'thirdparty'); } +// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context +$hookmanager->initHooks(array('thirdpartydocument','globalcard')); + + /* * Actions diff --git a/htdocs/societe/list.php b/htdocs/societe/list.php index d56e5b1e22a..460a0143c05 100644 --- a/htdocs/societe/list.php +++ b/htdocs/societe/list.php @@ -45,6 +45,7 @@ $massaction=GETPOST('massaction','alpha'); $show_files=GETPOST('show_files','int'); $confirm=GETPOST('confirm','alpha'); $toselect = GETPOST('toselect', 'array'); +$contextpage=GETPOST('contextpage','aZ')?GETPOST('contextpage','aZ'):'thirdpartylist'; // Security check $socid = GETPOST('socid','int'); @@ -106,18 +107,13 @@ $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; -// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context -$contextpage='thirdpartylist'; -/*if ($search_type == '1,3') { $contextpage='customerlist'; $type='c'; } -if ($search_type == '2,3') { $contextpage='prospectlist'; $type='p'; } -if ($search_type == '4') { $contextpage='supplierlist'; $type='f'; } -*/ if ($type == 'c') { $contextpage='customerlist'; if ($search_type=='') $search_type='1,3'; } if ($type == 'p') { $contextpage='prospectlist'; if ($search_type=='') $search_type='2,3'; } if ($type == 'f') { $contextpage='supplierlist'; if ($search_type=='') $search_type='4'; } // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context -$hookmanager->initHooks(array($contextpage)); +$object = new Societe($db); +$hookmanager->initHooks(array('thirdpartylist')); $extrafields = new ExtraFields($db); // fetch optionals attributes and labels diff --git a/htdocs/societe/note.php b/htdocs/societe/note.php index d0766bc24d8..e31a07e8e65 100644 --- a/htdocs/societe/note.php +++ b/htdocs/societe/note.php @@ -43,6 +43,9 @@ if ($id > 0) $object->fetch($id); $permissionnote=$user->rights->societe->creer; // Used by the include of actions_setnotes.inc.php +// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context +$hookmanager->initHooks(array('thirdpartynote','globalcard')); + /* * Actions diff --git a/htdocs/societe/website.php b/htdocs/societe/website.php index 9e57176250a..1f3e69a674c 100644 --- a/htdocs/societe/website.php +++ b/htdocs/societe/website.php @@ -59,16 +59,13 @@ $object=new Societe($db); $objectwebsiteaccount=new WebsiteAccount($db); $extrafields = new ExtraFields($db); $diroutputmassaction=$conf->website->dir_output . '/temp/massgeneration/'.$user->id; -$hookmanager->initHooks(array('websiteaccountlist')); // Note that conf->hooks_modules contains array +$hookmanager->initHooks(array('websitethirdpartylist')); // Note that conf->hooks_modules contains array // Fetch optionals attributes and labels $extralabels = $extrafields->fetch_name_optionals_label('websiteaccount'); $search_array_options=$extrafields->getOptionalsFromPost($extralabels,'','search_'); unset($objectwebsiteaccount->fields['fk_soc']); // Remove this field, we are already on the thirdparty -// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context -$hookmanager->initHooks(array('websitethirdparty')); - // Initialize array of search criterias $search_all=trim(GETPOST("search_all",'alpha')); $search=array(); diff --git a/htdocs/stripe/class/stripe.class.php b/htdocs/stripe/class/stripe.class.php index e093e93521a..6ed703d7a92 100644 --- a/htdocs/stripe/class/stripe.class.php +++ b/htdocs/stripe/class/stripe.class.php @@ -86,7 +86,7 @@ class Stripe extends CommonObject dol_print_error($this->db); } - dol_syslog("No dedicated Stipe Connect account available for entity".$conf->entity); + dol_syslog("No dedicated Stripe Connect account available for entity ".$conf->entity); return $key; } @@ -120,6 +120,12 @@ class Stripe extends CommonObject { global $conf, $user; + if (empty($object->id)) + { + dol_syslog("customerStripe is called with param object not loaded"); + return null; + } + $customer = null; $sql = "SELECT sa.key_account as key_account, sa.entity"; // key_account is cus_.... @@ -194,12 +200,12 @@ class Stripe extends CommonObject * * @param \Stripe\StripeCustomer $cu Object stripe customer * @param CompanyPaymentMode $object Object companypaymentmode to check, or create on stripe (create on stripe also update the societe_rib table for current entity) - * @param string $key ''=Use common API. If not '', it is the Stripe connect account 'acc_....' to use Stripe connect + * @param string $stripeacc ''=Use common API. If not '', it is the Stripe connect account 'acc_....' to use Stripe connect * @param int $status Status (0=test, 1=live) * @param int $createifnotlinkedtostripe 1=Create the stripe card and the link if the card is not yet linked to a stripe card * @return \Stripe\StripeCard|null Stripe Card or null if not found */ - public function cardStripe($cu, CompanyPaymentMode $object, $key='', $status=0, $createifnotlinkedtostripe=0) + public function cardStripe($cu, CompanyPaymentMode $object, $stripeacc='', $status=0, $createifnotlinkedtostripe=0) { global $conf, $user; @@ -222,10 +228,10 @@ class Stripe extends CommonObject if ($cardref) { try { - if (empty($key)) { // If the Stripe connect account not set, we use common API usage + if (empty($stripeacc)) { // If the Stripe connect account not set, we use common API usage $card = $cu->sources->retrieve($cardref); } else { - $card = $cu->sources->retrieve($cardref, array("stripe_account" => $key)); + $card = $cu->sources->retrieve($cardref, array("stripe_account" => $stripeacc)); } } catch(Exception $e) @@ -249,12 +255,12 @@ class Stripe extends CommonObject ); //$a = \Stripe\Stripe::getApiKey(); - //var_dump($a);var_dump($key);exit; + //var_dump($a);var_dump($stripeacc);exit; try { - if (empty($key)) { // If the Stripe connect account not set, we use common API usage + if (empty($stripeacc)) { // If the Stripe connect account not set, we use common API usage $card = $cu->sources->create($dataforcard); } else { - $card = $cu->sources->create($dataforcard, array("stripe_account" => $key)); + $card = $cu->sources->create($dataforcard, array("stripe_account" => $stripeacc)); } if ($card) diff --git a/htdocs/supplier_proposal/list.php b/htdocs/supplier_proposal/list.php index 685e9531072..2f676f9d6fa 100644 --- a/htdocs/supplier_proposal/list.php +++ b/htdocs/supplier_proposal/list.php @@ -57,6 +57,7 @@ $massaction=GETPOST('massaction','alpha'); $show_files=GETPOST('show_files','int'); $confirm=GETPOST('confirm','alpha'); $toselect = GETPOST('toselect', 'array'); +$contextpage=GETPOST('contextpage','aZ')?GETPOST('contextpage','aZ'):'supplierproposallist'; $search_user=GETPOST('search_user','int'); $search_sale=GETPOST('search_sale','int'); @@ -97,9 +98,6 @@ if ($object_statut != '') $search_status=$object_statut; // Nombre de ligne pour choix de produit/service predefinis $NBLINES=4; -// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context -$contextpage='supplierproposallist'; - // Security check $module='supplier_proposal'; $dbtable=''; @@ -116,6 +114,7 @@ $result = restrictedArea($user, $module, $objectid, $dbtable); $diroutputmassaction=$conf->supplier_proposal->dir_output . '/temp/massgeneration/'.$user->id; // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context +$object = new SupplierProposal($db); $hookmanager->initHooks(array('supplier_proposallist')); $extrafields = new ExtraFields($db); diff --git a/htdocs/ticketsup/list.php b/htdocs/ticketsup/list.php index 0e09333e7dd..364eab864e2 100644 --- a/htdocs/ticketsup/list.php +++ b/htdocs/ticketsup/list.php @@ -27,11 +27,9 @@ require_once DOL_DOCUMENT_ROOT . '/core/class/html.formticketsup.class.php'; require_once DOL_DOCUMENT_ROOT . '/core/lib/functions2.lib.php'; require_once DOL_DOCUMENT_ROOT . '/core/lib/company.lib.php'; require_once DOL_DOCUMENT_ROOT . '/user/class/user.class.php'; -if (!empty($conf->projet->enabled)) { - include_once DOL_DOCUMENT_ROOT . '/projet/class/project.class.php'; - include_once DOL_DOCUMENT_ROOT . '/core/class/html.formprojet.class.php'; - include_once DOL_DOCUMENT_ROOT . '/core/lib/project.lib.php'; -} +include_once DOL_DOCUMENT_ROOT . '/projet/class/project.class.php'; +include_once DOL_DOCUMENT_ROOT . '/core/class/html.formprojet.class.php'; +include_once DOL_DOCUMENT_ROOT . '/core/lib/project.lib.php'; // Load traductions files requiredby by page $langs->loadLangs(array("ticketsup","companies","other","projects")); @@ -71,7 +69,10 @@ $pagenext = $page + 1; $object=new Ticketsup($db); $extrafields = new ExtraFields($db); $diroutputmassaction=$conf->ticketsup->dir_output . '/temp/massgeneration/'.$user->id; -$hookmanager->initHooks(array('ticketsuplist')); // Note that conf->hooks_modules contains array +if ($socid > 0) $hookmanager->initHooks(array('thirdpartyticket')); +elseif ($project > 0) $hookmanager->initHooks(array('projectticket')); +else $hookmanager->initHooks(array('ticketsuplist')); + // Fetch optionals attributes and labels $extralabels = $extrafields->fetch_name_optionals_label('ticketsup'); $search_array_options=$extrafields->getOptionalsFromPost($extralabels,'','search_'); diff --git a/htdocs/user/agenda_extsites.php b/htdocs/user/agenda_extsites.php index 5b9e62c21df..46ca99d3727 100644 --- a/htdocs/user/agenda_extsites.php +++ b/htdocs/user/agenda_extsites.php @@ -40,6 +40,7 @@ $langs->load("other"); $def = array(); $actiontest=GETPOST('test','alpha'); $actionsave=GETPOST('save','alpha'); +$contextpage= GETPOST('contextpage','aZ')?GETPOST('contextpage','aZ'):'useragenda'; // To manage different context of search if (empty($conf->global->AGENDA_EXT_NB)) $conf->global->AGENDA_EXT_NB=5; $MAXAGENDA=$conf->global->AGENDA_EXT_NB; @@ -68,8 +69,7 @@ if (($object->id != $user->id) && (! $user->rights->user->user->lire)) accessforbidden(); // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context -$contextpage=array('usercard','useragenda','globalcard'); -$hookmanager->initHooks($contextpage); +$hookmanager->initHooks(array('usercard','useragenda','globalcard'); /* * Actions diff --git a/htdocs/user/card.php b/htdocs/user/card.php index 8eda5d47d97..3d63c308729 100644 --- a/htdocs/user/card.php +++ b/htdocs/user/card.php @@ -50,10 +50,11 @@ if (! empty($conf->categorie->enabled)) require_once DOL_DOCUMENT_ROOT.'/categor $id = GETPOST('id','int'); $action = GETPOST('action','aZ09'); $mode = GETPOST('mode','alpha'); -$confirm = GETPOST('confirm','alpha'); +$confirm = GETPOST('confirm','alpha'); $subaction = GETPOST('subaction','alpha'); $group = GETPOST("group","int",3); $cancel = GETPOST('cancel','alpha'); +$contextpage= GETPOST('contextpage','aZ')?GETPOST('contextpage','aZ'):'useracard'; // To manage different context of search // Define value to know what current user can do on users $canadduser=(! empty($user->admin) || $user->rights->user->user->creer); @@ -101,8 +102,7 @@ $extrafields = new ExtraFields($db); $extralabels=$extrafields->fetch_name_optionals_label($object->table_element); // Initialize technical object to manage hooks. Note that conf->hooks_modules contains array -$contextpage=array('usercard','globalcard'); -$hookmanager->initHooks($contextpage); +$hookmanager->initHooks(array('usercard','globalcard'); diff --git a/htdocs/user/document.php b/htdocs/user/document.php index ff7fe9b5ab9..d77b30a4721 100644 --- a/htdocs/user/document.php +++ b/htdocs/user/document.php @@ -34,11 +34,11 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; $langs->load("users"); $langs->load('other'); - $action=GETPOST('action','aZ09'); $confirm=GETPOST('confirm'); $id=(GETPOST('userid','int') ? GETPOST('userid','int') : GETPOST('id','int')); $ref = GETPOST('ref', 'alpha'); +$contextpage= GETPOST('contextpage','aZ')?GETPOST('contextpage','aZ'):'userdoc'; // To manage different context of search // Define value to know what current user can do on users $canadduser=(! empty($user->admin) || $user->rights->user->user->creer); @@ -94,8 +94,7 @@ if ($id > 0 || ! empty($ref)) } // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context -$contextpage=array('usercard','userdoc','globalcard'); -$hookmanager->initHooks($contextpage); +$hookmanager->initHooks(array('usercard','userdoc','globalcard'); /* diff --git a/htdocs/user/group/card.php b/htdocs/user/group/card.php index 97b1bfc028b..a8bc562d4a2 100644 --- a/htdocs/user/group/card.php +++ b/htdocs/user/group/card.php @@ -49,6 +49,7 @@ $id=GETPOST('id', 'int'); $action=GETPOST('action', 'alpha'); $confirm=GETPOST('confirm', 'alpha'); $userid=GETPOST('user', 'int'); +$contextpage=GETPOST('contextpage','aZ')?GETPOST('contextpage','aZ'):'groupcard'; // To manage different context of search // Security check $result = restrictedArea($user, 'user', $id, 'usergroup&usergroup', 'user'); @@ -71,8 +72,9 @@ $extrafields = new ExtraFields($db); $extralabels=$extrafields->fetch_name_optionals_label($object->table_element); // Initialize technical object to manage hooks. Note that conf->hooks_modules contains array -$contextpage=array('groupcard','globalcard'); -$hookmanager->initHooks($contextpage); +$hookmanager->initHooks(array('groupcard','globalcard')); + + /** * Actions diff --git a/htdocs/user/group/perms.php b/htdocs/user/group/perms.php index 740b106c728..27170062198 100644 --- a/htdocs/user/group/perms.php +++ b/htdocs/user/group/perms.php @@ -37,7 +37,7 @@ $action=GETPOST('action', 'alpha'); $confirm=GETPOST('confirm', 'alpha'); $module=GETPOST('module', 'alpha'); $rights=GETPOST('rights', 'int'); - +$contextpage= GETPOST('contextpage','aZ')?GETPOST('contextpage','aZ'):'groupperms'; // To manage different context of search // Defini si peux lire les permissions $canreadperms=($user->admin || $user->rights->user->user->lire); @@ -60,8 +60,7 @@ $object->fetch($id); $entity=$conf->entity; // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context -$contextpage=array('groupcard','globalcard'); -$hookmanager->initHooks($contextpage); +$hookmanager->initHooks('groupperms','globalcard'); /** diff --git a/htdocs/user/home.php b/htdocs/user/home.php index ac14f6b0243..64162d47a8f 100644 --- a/htdocs/user/home.php +++ b/htdocs/user/home.php @@ -24,6 +24,8 @@ require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/user/class/usergroup.class.php'; +$contextpage=GETPOST('contextpage','aZ')?GETPOST('contextpage','aZ'):'userhome'; // To manage different context of search + if (! $user->rights->user->user->lire && ! $user->admin) { // Redirection vers la page de l'utilisateur @@ -47,8 +49,7 @@ $companystatic = new Societe($db); $fuserstatic = new User($db); // Initialize technical object to manage hooks. Note that conf->hooks_modules contains array -$contextpage=array('userhome'); -$hookmanager->initHooks($contextpage); +$hookmanager->initHooks(array('userhome')); /* diff --git a/htdocs/user/index.php b/htdocs/user/index.php index 4d83903d0aa..964ac2df367 100644 --- a/htdocs/user/index.php +++ b/htdocs/user/index.php @@ -34,6 +34,8 @@ $langs->load("users"); $langs->load("companies"); $langs->load('hrm'); +$contextpage=GETPOST('contextpage','aZ')?GETPOST('contextpage','aZ'):'userlist'; // To manage different context of search + // Security check (for external users) $socid=0; if ($user->societe_id > 0) @@ -54,11 +56,9 @@ $pagenext = $page + 1; if (! $sortfield) $sortfield="u.login"; if (! $sortorder) $sortorder="ASC"; -// Initialize context for list -$contextpage=GETPOST('contextpage','aZ')?GETPOST('contextpage','aZ'):'userlist'; - // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context -$hookmanager->initHooks(array($contextpage)); +$object = new User($db); +$hookmanager->initHooks(array('userlist')); $extrafields = new ExtraFields($db); // fetch optionals attributes and labels diff --git a/htdocs/user/ldap.php b/htdocs/user/ldap.php index 1b5f7c77b78..c9bee3dd47c 100644 --- a/htdocs/user/ldap.php +++ b/htdocs/user/ldap.php @@ -33,6 +33,7 @@ $langs->load("companies"); $langs->load("ldap"); $id = GETPOST('id', 'int'); +$contextpage=GETPOST('contextpage','aZ')?GETPOST('contextpage','aZ'):'userldap'; // To manage different context of search // Security check $socid=0; @@ -46,8 +47,7 @@ $object->fetch($id, '', '', 1); $object->getrights(); // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context -$contextpage=array('usercard','userldap','globalcard'); -$hookmanager->initHooks($contextpage); +$hookmanager->initHooks(array('usercard','userldap','globalcard')); /* diff --git a/htdocs/user/note.php b/htdocs/user/note.php index 55dd46e1129..0868c6435cf 100644 --- a/htdocs/user/note.php +++ b/htdocs/user/note.php @@ -29,6 +29,7 @@ require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php'; $id = GETPOST('id','int'); $action = GETPOST('action','aZ09'); +$contextpage=GETPOST('contextpage','aZ')?GETPOST('contextpage','aZ'):'usernote'; // To manage different context of search $langs->load("companies"); $langs->load("members"); @@ -50,8 +51,7 @@ if ($user->id == $id) $feature2=''; // A user can always read its own card $result = restrictedArea($user, 'user', $id, 'user&user', $feature2); // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context -$contextpage=array('usercard','usernote','globalcard'); -$hookmanager->initHooks($contextpage); +$hookmanager->initHooks(array('usercard','usernote','globalcard')); /* diff --git a/htdocs/user/param_ihm.php b/htdocs/user/param_ihm.php index 64913683276..7c59b3e8f34 100644 --- a/htdocs/user/param_ihm.php +++ b/htdocs/user/param_ihm.php @@ -40,6 +40,7 @@ $canreaduser=($user->admin || $user->rights->user->user->lire); $id = GETPOST('id','int'); $action = GETPOST('action','alpha'); +$contextpage=GETPOST('contextpage','aZ')?GETPOST('contextpage','aZ'):'userihm'; // To manage different context of search if ($id) { @@ -79,8 +80,7 @@ $form = new Form($db); $formadmin=new FormAdmin($db); // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context -$contextpage=array('usercard','userihm','globalcard'); -$hookmanager->initHooks($contextpage); +$hookmanager->initHooks(array('usercard','userihm','globalcard')); /* diff --git a/htdocs/user/perms.php b/htdocs/user/perms.php index 209bc2541a8..7c855e0c80f 100644 --- a/htdocs/user/perms.php +++ b/htdocs/user/perms.php @@ -38,6 +38,7 @@ $action=GETPOST('action', 'alpha'); $confirm=GETPOST('confirm', 'alpha'); $module=GETPOST('module', 'alpha'); $rights=GETPOST('rights', 'int'); +$contextpage=GETPOST('contextpage','aZ')?GETPOST('contextpage','aZ'):'userperms'; // To manage different context of search if (! isset($id) || empty($id)) accessforbidden(); @@ -73,8 +74,7 @@ $object->getrights(); $entity=$conf->entity; // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context -$contextpage=array('usercard','userperms','globalcard'); -$hookmanager->initHooks($contextpage); +$hookmanager->initHooks(array('usercard','userperms','globalcard')); /**
'; if (preg_match('/^(string|email)/',$typeofdata)) { @@ -1072,11 +1072,11 @@ class Form // On recherche les societes $sql = "SELECT s.rowid, s.nom as name, s.name_alias, s.client, s.fournisseur, s.code_client, s.code_fournisseur"; $sql.= " FROM ".MAIN_DB_PREFIX ."societe as s"; - if (!$user->rights->societe->client->voir && !$user->societe_id) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + if (!$user->rights->societe->client->voir && !$user->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql.= " WHERE s.entity IN (".getEntity('societe').")"; - if (! empty($user->societe_id)) $sql.= " AND s.rowid = ".$user->societe_id; + if (! empty($user->socid)) $sql.= " AND s.rowid = ".$user->socid; if ($filter) $sql.= " AND (".$filter.")"; - if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; + if (!$user->rights->societe->client->voir && !$user->socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; if (! empty($conf->global->COMPANY_HIDE_INACTIVE_IN_COMBOBOX)) $sql.= " AND s.status <> 0"; // Add criteria if ($filterkey && $filterkey != '') @@ -3596,8 +3596,8 @@ class Form * @param string $question Question * @param string $action Action * @param array $formquestion An array with complementary inputs to add into forms: array(array('label'=> ,'type'=> , )) - * type can be 'hidden', 'text', 'password', 'checkbox', 'radio', 'date', ... - * @param string $selectedchoice '' or 'no' or 'yes' or '1' or '0' + * type can be 'hidden', 'text', 'password', 'checkbox', 'radio', 'date', 'morecss', ... + * @param string $selectedchoice '' or 'no', or 'yes' or '1' or '0' * @param int $useajax 0=No, 1=Yes, 2=Yes but submit page with &confirm=no if choice is No, 'xxx'=Yes and preoutput confirm box with div id=dialog-confirm-xxx * @param int $height Force height of box * @param int $width Force width of box ('999' or '90%'). Ignored and forced to 90% on smartphones. diff --git a/htdocs/core/js/lib_head.js.php b/htdocs/core/js/lib_head.js.php index 858a54d92cd..15dbc62ffa7 100644 --- a/htdocs/core/js/lib_head.js.php +++ b/htdocs/core/js/lib_head.js.php @@ -1090,13 +1090,4 @@ $(document).ready(function() { }); - -$(document).ready(function() { - $(document).on('click', 'a.butActionFormConfirm', function() { - var action = $(this).data('action-confirm'); - $('#dialog-confirm-'+action).dialog('open'); - return false; - }); -}); - // End of lib_head.js.php diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index b71ba047516..dc9d179bb59 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -3083,13 +3083,14 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $ $pictowithoutext = preg_replace('/(\.png|\.gif|\.svg)$/', '', $picto); //if (in_array($picto, array('switch_off', 'switch_on', 'off', 'on'))) - if (in_array($pictowithoutext, array('delete', 'edit', 'off', 'on', 'play', 'playdisabled', 'printer', 'resize', 'switch_off', 'switch_on', 'unlink', 'uparrow'))) + if (in_array($pictowithoutext, array('bank', 'delete', 'edit', 'off', 'on', 'play', 'playdisabled', 'printer', 'resize', 'switch_off', 'switch_on', 'unlink', 'uparrow'))) { $fakey = $pictowithoutext; $facolor=''; $fasize=''; if ($pictowithoutext == 'switch_off') { $fakey = 'fa-toggle-off'; $facolor='#999'; $fasize='2em'; } elseif ($pictowithoutext == 'switch_on') { $fakey = 'fa-toggle-on'; $facolor='#227722'; $fasize='2em'; } elseif ($pictowithoutext == 'off') { $fakey = 'fa-square-o'; $fasize='1.3em'; } elseif ($pictowithoutext == 'on') { $fakey = 'fa-check-square-o'; $fasize='1.3em'; } + elseif ($pictowithoutext == 'bank') { $fakey = 'fa-bank'; $facolor='#444'; } elseif ($pictowithoutext == 'delete') { $fakey = 'fa-trash'; $facolor='#444'; } elseif ($pictowithoutext == 'edit') { $fakey = 'fa-pencil'; $facolor='#444'; } elseif ($pictowithoutext == 'printer') { $fakey = 'fa-print'; $fasize='1.2em'; $facolor='#444'; } diff --git a/htdocs/core/tpl/extrafields_list_search_title.tpl.php b/htdocs/core/tpl/extrafields_list_search_title.tpl.php index 8b986b1e4e6..ae5f640828c 100644 --- a/htdocs/core/tpl/extrafields_list_search_title.tpl.php +++ b/htdocs/core/tpl/extrafields_list_search_title.tpl.php @@ -8,16 +8,17 @@ if (empty($conf) || ! is_object($conf)) } // Loop to show all columns of extrafields for the title line -if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) +if (is_array($extrafields->attributes[$object->element]['label']) && count($extrafields->attributes[$object->element]['label'])) { - foreach($extrafields->attribute_label as $key => $val) + foreach($extrafields->attributes[$object->element]['label'] as $key => $val) { if (! empty($arrayfields["ef.".$key]['checked'])) { $align=$extrafields->getAlignFlag($key); $sortonfield = "ef.".$key; - if (! empty($extrafields->attribute_computed[$key])) $sortonfield=''; - print getTitleFieldOfList($langs->trans($extralabels[$key]), 0, $_SERVER["PHP_SELF"], $sortonfield, "", $param, ($align?'align="'.$align.'"':''), $sortfield, $sortorder)."\n"; + if (! empty($extrafields->attributes[$object->element]['computed'][$key])) $sortonfield=''; + if ($extrafields->attributes[$object->element]['type'][$key] == 'separate') print ' situation_counter == 1 || !$this->situation_cycle_ref) && empty($disableremove)) { - print 'use_javascript_ajax?' class="butActionFormConfirm" data-action-confirm="ask_deleteline"':'').' href="' . $_SERVER["PHP_SELF"] . '?id=' . $this->id . '&action='.($conf->use_javascript_ajax?'confirm_deleteline':'ask_deleteline').'&lineid=' . $line->id . '">'; + print 'id . '">'; print img_delete(); print ''; - - if($conf->use_javascript_ajax) { - print $formconfirm['ask_deleteline']; - } } ?> '; if ($canedit) print ''; print ''; if (! empty($user->rights->holiday->define_holiday)) // Allowed to set the balance of any user diff --git a/htdocs/install/mysql/migration/7.0.0-8.0.0.sql b/htdocs/install/mysql/migration/7.0.0-8.0.0.sql index 92a58472700..d9513242969 100644 --- a/htdocs/install/mysql/migration/7.0.0-8.0.0.sql +++ b/htdocs/install/mysql/migration/7.0.0-8.0.0.sql @@ -49,6 +49,8 @@ delete from llx_user_rights where fk_user not IN (select rowid from llx_user); delete from llx_usergroup_rights where fk_usergroup not in (select rowid from llx_usergroup); delete from llx_usergroup_rights where fk_id not in (select id from llx_rights_def); +ALTER TABLE llx_inventory ADD COLUMN fk_product integer DEFAULT NULL; +ALTER TABLE llx_inventory MODIFY COLUMN fk_warehouse integer DEFAULT NULL; ALTER TABLE llx_c_type_fees ADD COLUMN llx_c_type_fees integer DEFAULT 0; diff --git a/htdocs/install/mysql/tables/llx_inventory.sql b/htdocs/install/mysql/tables/llx_inventory.sql index 1f3c3ecb111..9e4d02408c9 100644 --- a/htdocs/install/mysql/tables/llx_inventory.sql +++ b/htdocs/install/mysql/tables/llx_inventory.sql @@ -27,7 +27,8 @@ CREATE TABLE llx_inventory fk_user_creat integer, -- user making creation fk_user_modif integer, -- user making last change fk_user_valid integer, -- valideur de la fiche - fk_warehouse integer DEFAULT 0, + fk_warehouse integer DEFAULT NULL, + fk_product integer DEFAULT NULL, status integer DEFAULT 0, title varchar(255) NOT NULL, date_inventory datetime DEFAULT NULL, diff --git a/htdocs/langs/en_US/stocks.lang b/htdocs/langs/en_US/stocks.lang index d8261fbe2ec..31873ad527e 100644 --- a/htdocs/langs/en_US/stocks.lang +++ b/htdocs/langs/en_US/stocks.lang @@ -24,6 +24,7 @@ Movements=Movements ErrorWarehouseRefRequired=Warehouse reference name is required ListOfWarehouses=List of warehouses ListOfStockMovements=List of stock movements +ListOfInventories=List of inventories MovementId=Movement ID StockMovementForId=Movement ID %d ListMouvementStockProject=List of stock movements associated to project diff --git a/htdocs/modulebuilder/template/core/modules/modMyModule.class.php b/htdocs/modulebuilder/template/core/modules/modMyModule.class.php index 42d40e4dcc5..0ca707daa1c 100644 --- a/htdocs/modulebuilder/template/core/modules/modMyModule.class.php +++ b/htdocs/modulebuilder/template/core/modules/modMyModule.class.php @@ -127,6 +127,11 @@ class modMyModule extends DolibarrModules 1=>array('MYMODULE_MYCONSTANT', 'chaine', 'avalue', 'This is a constant to add', 1, 'allentities', 1) ); + // Some keys to add into the overwriting translation tables + /*$this->overwrite_translation = array( + 'en_US:ParentCompany'=>'Parent company or reseller', + 'fr_FR:ParentCompany'=>'Maison mère ou revendeur' + )*/ if (! isset($conf->mymodule) || ! isset($conf->mymodule->enabled)) { diff --git a/htdocs/modulebuilder/template/myobject_agenda.php b/htdocs/modulebuilder/template/myobject_agenda.php index 408d6fd88fd..3fafc181c5a 100644 --- a/htdocs/modulebuilder/template/myobject_agenda.php +++ b/htdocs/modulebuilder/template/myobject_agenda.php @@ -85,7 +85,7 @@ if (! $sortorder) $sortorder='DESC'; $object=new MyObject($db); $extrafields = new ExtraFields($db); $diroutputmassaction=$conf->mymodule->dir_output . '/temp/massgeneration/'.$user->id; -$hookmanager->initHooks(array('myobjectagenda')); // Note that conf->hooks_modules contains array +$hookmanager->initHooks(array('myobjectagenda','globalcard')); // Note that conf->hooks_modules contains array // Fetch optionals attributes and labels $extralabels = $extrafields->fetch_name_optionals_label('myobject'); diff --git a/htdocs/modulebuilder/template/myobject_card.php b/htdocs/modulebuilder/template/myobject_card.php index 470825a6a61..a9873d4c4bf 100644 --- a/htdocs/modulebuilder/template/myobject_card.php +++ b/htdocs/modulebuilder/template/myobject_card.php @@ -73,7 +73,7 @@ $backtopage = GETPOST('backtopage', 'alpha'); $object=new MyObject($db); $extrafields = new ExtraFields($db); $diroutputmassaction=$conf->mymodule->dir_output . '/temp/massgeneration/'.$user->id; -$hookmanager->initHooks(array('myobjectcard')); // Note that conf->hooks_modules contains array +$hookmanager->initHooks(array('myobjectcard','globalcard')); // Note that conf->hooks_modules contains array // Fetch optionals attributes and labels $extralabels = $extrafields->fetch_name_optionals_label('myobject'); $search_array_options=$extrafields->getOptionalsFromPost($extralabels,'','search_'); diff --git a/htdocs/modulebuilder/template/myobject_document.php b/htdocs/modulebuilder/template/myobject_document.php index 3d1580e1e3b..8ce85b8eee6 100644 --- a/htdocs/modulebuilder/template/myobject_document.php +++ b/htdocs/modulebuilder/template/myobject_document.php @@ -74,7 +74,7 @@ if (! $sortfield) $sortfield="name"; $object=new MyObject($db); $extrafields = new ExtraFields($db); $diroutputmassaction=$conf->mymodule->dir_output . '/temp/massgeneration/'.$user->id; -$hookmanager->initHooks(array('myobjectdocument')); // Note that conf->hooks_modules contains array +$hookmanager->initHooks(array('myobjectdocument','globalcard')); // Note that conf->hooks_modules contains array // Fetch optionals attributes and labels $extralabels = $extrafields->fetch_name_optionals_label('myobject'); @@ -85,7 +85,6 @@ include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be inclu if ($id > 0 || ! empty($ref)) $upload_dir = $conf->sellyoursaas->multidir_output[$object->entity] . "/packages/" . dol_sanitizeFileName($object->ref); - /* * Actions */ diff --git a/htdocs/modulebuilder/template/myobject_list.php b/htdocs/modulebuilder/template/myobject_list.php index c1867fb87f7..4d1eb6829bd 100644 --- a/htdocs/modulebuilder/template/myobject_list.php +++ b/htdocs/modulebuilder/template/myobject_list.php @@ -130,11 +130,12 @@ foreach($object->fields as $key => $val) if (! empty($val['visible'])) $arrayfields['t.'.$key]=array('label'=>$val['label'], 'checked'=>(($val['visible']<0)?0:1), 'enabled'=>$val['enabled'], 'position'=>$val['position']); } // Extra fields -if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) +if (is_array($extrafields->attributes[$object->element]['label']) && count($extrafields->attributes[$object->element]['label'])) { - foreach($extrafields->attribute_label as $key => $val) + foreach($extrafields->attributes[$object->element]['label'] as $key => $val) { - if (! empty($extrafields->attribute_list[$key])) $arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>(($extrafields->attribute_list[$key]<0)?0:1), 'position'=>$extrafields->attribute_pos[$key], 'enabled'=>(abs($extrafields->attribute_list[$key])!=3 && $extrafields->attribute_perms[$key])); + if (! empty($extrafields->attributes[$object->element]['list'][$key])) + $arrayfields["ef.".$key]=array('label'=>$extrafields->attributes[$object->element]['label'][$key], 'checked'=>(($extrafields->attributes[$object->element]['list'][$key]<0)?0:1), 'position'=>$extrafields->attributes[$object->element]['pos'][$key], 'enabled'=>(abs($extrafields->attributes[$object->element]['list'][$key])!=3 && $extrafields->attributes[$object->element]['perms'][$key])); } } $object->fields = dol_sort_array($object->fields, 'position'); @@ -210,14 +211,14 @@ foreach($object->fields as $key => $val) $sql.='t.'.$key.', '; } // Add fields from extrafields -foreach ($extrafields->attribute_label as $key => $val) $sql.=($extrafields->attribute_type[$key] != 'separate' ? ", ef.".$key.' as options_'.$key : ''); +foreach ($extrafields->attributes[$object->element]['label'] as $key => $val) $sql.=($extrafields->attributes[$object->element]['type'][$key] != 'separate' ? ", ef.".$key.' as options_'.$key : ''); // Add fields from hooks $parameters=array(); $reshook=$hookmanager->executeHooks('printFieldListSelect', $parameters, $object); // Note that $action and $object may have been modified by hook $sql.=$hookmanager->resPrint; $sql=preg_replace('/, $/','', $sql); $sql.= " FROM ".MAIN_DB_PREFIX.$object->table_element." as t"; -if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."myobject_extrafields as ef on (t.rowid = ef.fk_object)"; +if (is_array($extrafields->attributes[$object->element]['label']) && count($extrafields->attributes[$object->element]['label'])) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."myobject_extrafields as ef on (t.rowid = ef.fk_object)"; if ($object->ismultientitymanaged == 1) $sql.= " WHERE t.entity IN (".getEntity('myobject').")"; else $sql.=" WHERE 1 = 1"; foreach($search as $key => $val) @@ -241,7 +242,7 @@ foreach($object->fields as $key => $val) $sql.='t.'.$key.', '; } // Add fields from extrafields -foreach ($extrafields->attribute_label as $key => $val) $sql.=($extrafields->attribute_type[$key] != 'separate' ? ",ef.".$key : ''); +foreach ($extrafields->attributes[$object->element]['label'] as $key => $val) $sql.=($extrafields->attributes[$object->element]['type'][$key] != 'separate' ? ",ef.".$key : ''); // Add where from hooks $parameters=array(); $reshook=$hookmanager->executeHooks('printFieldListGroupBy',$parameters); // Note that $action and $object may have been modified by hook @@ -434,7 +435,7 @@ print '