diff --git a/ChangeLog b/ChangeLog index eae34c792a6..2e365b4f645 100644 --- a/ChangeLog +++ b/ChangeLog @@ -222,6 +222,7 @@ NEW: standardizes API thirdparties by email like other object NEW: thirdparty REST API: endpoint to set price level NEW: Use new category API for project list view NEW: Triggers Attributes and Attributes values +NEW: Add hooks on newpayment page to allow external payment modules WARNING: diff --git a/htdocs/accountancy/admin/card.php b/htdocs/accountancy/admin/card.php index fdbb86d1a62..d015d8f07b5 100644 --- a/htdocs/accountancy/admin/card.php +++ b/htdocs/accountancy/admin/card.php @@ -252,7 +252,7 @@ if ($action == 'create') { print ''; - dol_fiche_end(); + print dol_get_fiche_end(); print '
'; print ''; @@ -314,7 +314,7 @@ if ($action == 'create') { print ''; - dol_fiche_end(); + print dol_get_fiche_end(); print '
'; print ''; @@ -364,7 +364,7 @@ if ($action == 'create') { print '
'; - dol_fiche_end(); + print dol_get_fiche_end(); /* * Actions buttons diff --git a/htdocs/accountancy/admin/categories.php b/htdocs/accountancy/admin/categories.php index db17be68e1e..eefe62a47a4 100644 --- a/htdocs/accountancy/admin/categories.php +++ b/htdocs/accountancy/admin/categories.php @@ -146,7 +146,7 @@ if (!empty($cat_id)) print ''; -dol_fiche_end(); +print dol_get_fiche_end(); print ''; diff --git a/htdocs/accountancy/admin/fiscalyear_card.php b/htdocs/accountancy/admin/fiscalyear_card.php index 97b92bdd172..aa10c0101c1 100644 --- a/htdocs/accountancy/admin/fiscalyear_card.php +++ b/htdocs/accountancy/admin/fiscalyear_card.php @@ -187,7 +187,7 @@ if ($action == 'create') print ''; - dol_fiche_end(); + print dol_get_fiche_end(); print '
'; print ''; @@ -248,7 +248,7 @@ if ($action == 'create') print ''; - dol_fiche_end(); + print dol_get_fiche_end(); } else { /* * Confirm delete @@ -296,7 +296,7 @@ if ($action == 'create') print ""; - dol_fiche_end(); + print dol_get_fiche_end(); if (!empty($user->rights->accounting->fiscalyear->write)) { diff --git a/htdocs/accountancy/bookkeeping/card.php b/htdocs/accountancy/bookkeeping/card.php index 6a9fdcbffff..ef9ebe3f9b9 100644 --- a/htdocs/accountancy/bookkeeping/card.php +++ b/htdocs/accountancy/bookkeeping/card.php @@ -386,7 +386,7 @@ if ($action == 'create') print ''; - dol_fiche_end(); + print dol_get_fiche_end(); print '
'; print ''; @@ -573,7 +573,7 @@ if ($action == 'create') print '
'; - dol_fiche_end(); + print dol_get_fiche_end(); print '
'; @@ -719,7 +719,7 @@ if ($action == 'create') } } -dol_fiche_end(); +print dol_get_fiche_end(); // End of page llxFooter(); diff --git a/htdocs/accountancy/bookkeeping/thirdparty_lettering_customer.php b/htdocs/accountancy/bookkeeping/thirdparty_lettering_customer.php index 9e21a712e7e..8e6387d4608 100644 --- a/htdocs/accountancy/bookkeeping/thirdparty_lettering_customer.php +++ b/htdocs/accountancy/bookkeeping/thirdparty_lettering_customer.php @@ -141,7 +141,7 @@ $linkback = 'socid ? 0 : 1), 'rowid', 'nom', '', '', 0, '', '', 'arearefnobottom'); -dol_fiche_end(); +print dol_get_fiche_end(); $sql = "SELECT bk.rowid, bk.doc_date, bk.doc_type, bk.doc_ref, "; $sql .= " bk.subledger_account, bk.numero_compte , bk.label_compte, bk.debit, "; diff --git a/htdocs/accountancy/class/accountingaccount.class.php b/htdocs/accountancy/class/accountingaccount.class.php index 199899f89d5..e7a65ceec97 100644 --- a/htdocs/accountancy/class/accountingaccount.class.php +++ b/htdocs/accountancy/class/accountingaccount.class.php @@ -453,21 +453,22 @@ class AccountingAccount extends CommonObject */ public function getNomUrl($withpicto = 0, $withlabel = 0, $nourl = 0, $moretitle = '', $notooltip = 0, $save_lastsearch_value = -1, $withcompletelabel = 0, $option = '') { - global $langs, $conf, $user; + global $langs, $conf; require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; if (!empty($conf->dol_no_mouse_hover)) $notooltip = 1; // Force disable tooltips $result = ''; + $url = ''; if (empty($option) || $option == 'ledger') { - $url = DOL_URL_ROOT . '/accountancy/bookkeeping/listbyaccount.php?search_accountancy_code_start=' . $this->account_number . '&search_accountancy_code_end=' . $this->account_number; + $url = DOL_URL_ROOT.'/accountancy/bookkeeping/listbyaccount.php?search_accountancy_code_start='.urlencode($this->account_number).'&search_accountancy_code_end='.urlencode($this->account_number); $labelurl = $langs->trans("ShowAccountingAccountInLedger"); } elseif ($option == 'journals') { - $url = DOL_URL_ROOT . '/accountancy/bookkeeping/list.php?search_accountancy_code_start=' . $this->account_number . '&search_accountancy_code_end=' . $this->account_number; + $url = DOL_URL_ROOT.'/accountancy/bookkeeping/list.php?search_accountancy_code_start='.urlencode($this->account_number).'&search_accountancy_code_end='.urlencode($this->account_number); $labelurl = $langs->trans("ShowAccountingAccountInJournals"); } elseif ($option == 'accountcard') { - $url = DOL_URL_ROOT . '/accountancy/admin/card.php?id=' . $this->id; + $url = DOL_URL_ROOT.'/accountancy/admin/card.php?id='.urlencode($this->id); $labelurl = $langs->trans("ShowAccountingAccount"); } diff --git a/htdocs/accountancy/customer/card.php b/htdocs/accountancy/customer/card.php index 4343946a85e..1a37bb1019b 100644 --- a/htdocs/accountancy/customer/card.php +++ b/htdocs/accountancy/customer/card.php @@ -137,7 +137,7 @@ if (!empty($id)) { print ''; print ''; - dol_fiche_end(); + print dol_get_fiche_end(); print '
'; print ''; diff --git a/htdocs/accountancy/expensereport/card.php b/htdocs/accountancy/expensereport/card.php index 153717d05e4..67c790a9c36 100644 --- a/htdocs/accountancy/expensereport/card.php +++ b/htdocs/accountancy/expensereport/card.php @@ -146,7 +146,7 @@ if (!empty($id)) { print ''; print ''; - dol_fiche_end(); + print dol_get_fiche_end(); print '
'; print ''; diff --git a/htdocs/accountancy/supplier/card.php b/htdocs/accountancy/supplier/card.php index bee34f291f5..d6b289a76c8 100644 --- a/htdocs/accountancy/supplier/card.php +++ b/htdocs/accountancy/supplier/card.php @@ -141,7 +141,7 @@ if (!empty($id)) { print ''; print ''; - dol_fiche_end(); + print dol_get_fiche_end(); print '
'; print ''; diff --git a/htdocs/adherents/admin/adherent.php b/htdocs/adherents/admin/adherent.php index 07d4454feae..17d5f51d6eb 100644 --- a/htdocs/adherents/admin/adherent.php +++ b/htdocs/adherents/admin/adherent.php @@ -246,7 +246,7 @@ $helptext .= '__YEAR__, __MONTH__, __DAY__'; form_constantes($constantes, 0, $helptext); -dol_fiche_end(); +print dol_get_fiche_end(); // End of page llxFooter(); diff --git a/htdocs/adherents/admin/adherent_emails.php b/htdocs/adherents/admin/adherent_emails.php index e5b612e3d86..4374d281895 100644 --- a/htdocs/adherents/admin/adherent_emails.php +++ b/htdocs/adherents/admin/adherent_emails.php @@ -136,7 +136,7 @@ form_constantes($constantes, 0, $helptext); //print '
'; //print ''; -dol_fiche_end(); +print dol_get_fiche_end(); // End of page llxFooter(); diff --git a/htdocs/adherents/admin/adherent_extrafields.php b/htdocs/adherents/admin/adherent_extrafields.php index 689e7c11be3..ae4f1989114 100644 --- a/htdocs/adherents/admin/adherent_extrafields.php +++ b/htdocs/adherents/admin/adherent_extrafields.php @@ -74,7 +74,7 @@ print dol_get_fiche_head($head, 'attributes', $langs->trans("Members"), -1, 'use require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php'; -dol_fiche_end(); +print dol_get_fiche_end(); // Buttons diff --git a/htdocs/adherents/admin/adherent_type_extrafields.php b/htdocs/adherents/admin/adherent_type_extrafields.php index 9fef3ad5c21..92b5ed990e3 100644 --- a/htdocs/adherents/admin/adherent_type_extrafields.php +++ b/htdocs/adherents/admin/adherent_type_extrafields.php @@ -77,7 +77,7 @@ print dol_get_fiche_head($head, 'attributes_type', $langs->trans("Members"), -1, require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php'; -dol_fiche_end(); +print dol_get_fiche_end(); // Buttons diff --git a/htdocs/adherents/admin/website.php b/htdocs/adherents/admin/website.php index beaf05ce3fa..330568c20bf 100644 --- a/htdocs/adherents/admin/website.php +++ b/htdocs/adherents/admin/website.php @@ -208,7 +208,7 @@ if (!empty($conf->global->MEMBER_ENABLE_PUBLIC)) { } -dol_fiche_end(); +print dol_get_fiche_end(); print ''; diff --git a/htdocs/adherents/agenda.php b/htdocs/adherents/agenda.php index c0b5998f035..3af330f0066 100644 --- a/htdocs/adherents/agenda.php +++ b/htdocs/adherents/agenda.php @@ -133,7 +133,7 @@ if ($object->id > 0) { print '
'; - dol_fiche_end(); + print dol_get_fiche_end(); //print '
'; diff --git a/htdocs/adherents/card.php b/htdocs/adherents/card.php index 128b915ef0f..4bffb8bc0db 100644 --- a/htdocs/adherents/card.php +++ b/htdocs/adherents/card.php @@ -969,7 +969,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { print ''; print "\n"; - dol_fiche_end(); + print dol_get_fiche_end(); print '
'; print ''; @@ -1229,7 +1229,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_add.tpl.php'; print ''; - dol_fiche_end(); + print dol_get_fiche_end(); print '
'; print ''; @@ -1608,7 +1608,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { print "
\n"; print '
'; - dol_fiche_end(); + print dol_get_fiche_end(); /* diff --git a/htdocs/adherents/document.php b/htdocs/adherents/document.php index 0f6e6250796..cb6384cfb63 100644 --- a/htdocs/adherents/document.php +++ b/htdocs/adherents/document.php @@ -145,7 +145,7 @@ if ($id > 0) { print '
'; - dol_fiche_end(); + print dol_get_fiche_end(); $modulepart = 'member'; $permission = $user->rights->adherent->creer; diff --git a/htdocs/adherents/index.php b/htdocs/adherents/index.php index c63bb9049ca..aa7564007a6 100644 --- a/htdocs/adherents/index.php +++ b/htdocs/adherents/index.php @@ -285,6 +285,7 @@ print '
'; $max = $conf->global->MAIN_SIZE_SHORTLIST_LIMIT; $sql = "SELECT a.rowid, a.statut, a.lastname, a.firstname, a.societe as company, a.fk_soc,"; +$sql .= " a.gender, a.email, a.photo, a.morphy,"; $sql .= " a.tms as datem, datefin as date_end_subscription,"; $sql .= " ta.rowid as typeid, ta.libelle as label, ta.subscription"; $sql .= " FROM ".MAIN_DB_PREFIX."adherent as a, ".MAIN_DB_PREFIX."adherent_type as ta"; @@ -307,8 +308,13 @@ if ($resql) { $obj = $db->fetch_object($resql); print ''; $staticmember->id = $obj->rowid; + $staticmember->ref = $obj->rowid; $staticmember->lastname = $obj->lastname; $staticmember->firstname = $obj->firstname; + $staticmember->gender = $obj->gender; + $staticmember->email = $obj->email; + $staticmember->photo = $obj->photo; + $staticmember->morphy = $obj->morphy; if (!empty($obj->fk_soc)) { $staticmember->fk_soc = $obj->fk_soc; $staticmember->fetch_thirdparty(); @@ -316,10 +322,9 @@ if ($resql) { } else { $staticmember->name = $obj->company; } - $staticmember->ref = $staticmember->getFullName($langs); $statictype->id = $obj->typeid; $statictype->label = $obj->label; - print ''.$staticmember->getNomUrl(1, 32).''; + print ''.$staticmember->getNomUrl(-1, 32).''; print ''.$statictype->getNomUrl(1, 32).''; print ''.dol_print_date($db->jdate($obj->datem), 'dayhour').''; print ''.$staticmember->LibStatut($obj->statut, ($obj->subscription == 'yes' ? 1 : 0), $db->jdate($obj->date_end_subscription), 3).''; @@ -340,7 +345,8 @@ if ($resql) { $max = $conf->global->MAIN_SIZE_SHORTLIST_LIMIT; $sql = "SELECT a.rowid, a.statut, a.lastname, a.firstname, a.societe as company, a.fk_soc,"; -$sql .= " datefin as date_end_subscription,"; +$sql .= " a.gender, a.email, a.photo, a.morphy,"; +$sql .= " a.datefin as date_end_subscription,"; $sql .= " c.rowid as cid, c.tms as datem, c.datec as datec, c.dateadh as date_start, c.datef as date_end, c.subscription"; $sql .= " FROM ".MAIN_DB_PREFIX."adherent as a, ".MAIN_DB_PREFIX."subscription as c"; $sql .= " WHERE a.entity IN (".getEntity('adherent').")"; @@ -364,8 +370,13 @@ if ($resql) { $subscriptionstatic->id = $obj->cid; $subscriptionstatic->ref = $obj->cid; $staticmember->id = $obj->rowid; + $staticmember->ref = $obj->rowid; $staticmember->lastname = $obj->lastname; $staticmember->firstname = $obj->firstname; + $staticmember->gender = $obj->gender; + $staticmember->email = $obj->email; + $staticmember->photo = $obj->photo; + $staticmember->morphy = $obj->morphy; if (!empty($obj->fk_soc)) { $staticmember->fk_soc = $obj->fk_soc; $staticmember->fetch_thirdparty(); @@ -373,9 +384,8 @@ if ($resql) { } else { $staticmember->name = $obj->company; } - $staticmember->ref = $staticmember->getFullName($langs); print ''.$subscriptionstatic->getNomUrl(1).''; - print ''.$staticmember->getNomUrl(1, 32, 'subscription').''; + print ''.$staticmember->getNomUrl(-1, 32, 'subscription').''; print ''.get_date_range($db->jdate($obj->date_start), $db->jdate($obj->date_end)).''; print ''.price($obj->subscription).''; //print ''.$staticmember->LibStatut($obj->statut,($obj->subscription=='yes'?1:0),$db->jdate($obj->date_end_subscription),5).''; diff --git a/htdocs/adherents/ldap.php b/htdocs/adherents/ldap.php index 80fdfc99479..14d886b6cc4 100644 --- a/htdocs/adherents/ldap.php +++ b/htdocs/adherents/ldap.php @@ -128,7 +128,7 @@ print ''; print '
'; -dol_fiche_end(); +print dol_get_fiche_end(); /* * Barre d'actions diff --git a/htdocs/adherents/list.php b/htdocs/adherents/list.php index ef4639e4b5e..05100582ec2 100644 --- a/htdocs/adherents/list.php +++ b/htdocs/adherents/list.php @@ -656,6 +656,7 @@ while ($i < min($num, $limit)) { $memberstatic->datefin = $datefin; $memberstatic->socid = $obj->fk_soc; $memberstatic->photo = $obj->photo; + $memberstatic->email = $obj->email; $memberstatic->morphy = $obj->morphy; $memberstatic->note_public = $obj->note_public; $memberstatic->note_private = $obj->note_private; @@ -725,12 +726,10 @@ while ($i < min($num, $limit)) { if (!empty($arrayfields['d.morphy']['checked'])) { print ''; $s = ''; - if ($obj->morphy == 'phy') - { + if ($obj->morphy == 'phy') { $s .= ''.dol_substr($langs->trans("Physical"), 0, 1).''; } - if ($obj->morphy == 'mor') - { + if ($obj->morphy == 'mor') { $s .= ''.dol_substr($langs->trans("Moral"), 0, 1).''; } print $s; diff --git a/htdocs/adherents/note.php b/htdocs/adherents/note.php index 4026dded2a2..1ce2da4751b 100644 --- a/htdocs/adherents/note.php +++ b/htdocs/adherents/note.php @@ -112,7 +112,7 @@ if ($id) { include DOL_DOCUMENT_ROOT.'/core/tpl/notes.tpl.php'; - dol_fiche_end(); + print dol_get_fiche_end(); } // End of page diff --git a/htdocs/adherents/stats/byproperties.php b/htdocs/adherents/stats/byproperties.php index 0a5bee034c2..cd0f90d27c6 100644 --- a/htdocs/adherents/stats/byproperties.php +++ b/htdocs/adherents/stats/byproperties.php @@ -173,7 +173,7 @@ foreach ($data as $val) { print ''; print '
'; -dol_fiche_end(); +print dol_get_fiche_end(); // End of page llxFooter(); diff --git a/htdocs/adherents/stats/geo.php b/htdocs/adherents/stats/geo.php index 44da065d888..7d05678263a 100644 --- a/htdocs/adherents/stats/geo.php +++ b/htdocs/adherents/stats/geo.php @@ -299,7 +299,7 @@ if ($mode) { } -dol_fiche_end(); +print dol_get_fiche_end(); // End of page llxFooter(); diff --git a/htdocs/adherents/stats/index.php b/htdocs/adherents/stats/index.php index a3c77e1c64a..472a93cfce7 100644 --- a/htdocs/adherents/stats/index.php +++ b/htdocs/adherents/stats/index.php @@ -219,7 +219,7 @@ print '
'; print '
'; -dol_fiche_end(); +print dol_get_fiche_end(); // End of page llxFooter(); diff --git a/htdocs/adherents/subscription.php b/htdocs/adherents/subscription.php index 9c9589eaec2..ca88854d27e 100644 --- a/htdocs/adherents/subscription.php +++ b/htdocs/adherents/subscription.php @@ -76,26 +76,26 @@ $defaultdelay = 1; $defaultdelayunit = 'y'; if ($rowid) { - // Load member - $result = $object->fetch($rowid); + // Load member + $result = $object->fetch($rowid); - // Define variables to know what current user can do on users - $canadduser = ($user->admin || $user->rights->user->user->creer); - // Define variables to know what current user can do on properties of user linked to edited member - if ($object->user_id) { - // $user is the user editing, $object->user_id is the user's id linked to the edited member - $caneditfielduser = ((($user->id == $object->user_id) && $user->rights->user->self->creer) - || (($user->id != $object->user_id) && $user->rights->user->user->creer)); - $caneditpassworduser = ((($user->id == $object->user_id) && $user->rights->user->self->password) - || (($user->id != $object->user_id) && $user->rights->user->user->password)); - } + // Define variables to know what current user can do on users + $canadduser = ($user->admin || $user->rights->user->user->creer); + // Define variables to know what current user can do on properties of user linked to edited member + if ($object->user_id) { + // $user is the user editing, $object->user_id is the user's id linked to the edited member + $caneditfielduser = ((($user->id == $object->user_id) && $user->rights->user->self->creer) + || (($user->id != $object->user_id) && $user->rights->user->user->creer)); + $caneditpassworduser = ((($user->id == $object->user_id) && $user->rights->user->self->password) + || (($user->id != $object->user_id) && $user->rights->user->user->password)); + } } // Define variables to know what current user can do on members $canaddmember = $user->rights->adherent->creer; // Define variables to know what current user can do on properties of a member if ($rowid) { - $caneditfieldmember = $user->rights->adherent->creer; + $caneditfieldmember = $user->rights->adherent->creer; } // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context @@ -130,242 +130,242 @@ if ($action == 'confirm_create_thirdparty' && $confirm == 'yes' && $user->rights } if ($action == 'setuserid' && ($user->rights->user->self->creer || $user->rights->user->user->creer)) { - $error = 0; - if (empty($user->rights->user->user->creer)) { // If can edit only itself user, we can link to itself only + $error = 0; + if (empty($user->rights->user->user->creer)) { // If can edit only itself user, we can link to itself only if ($_POST["userid"] != $user->id && $_POST["userid"] != $object->user_id) { - $error++; - setEventMessages($langs->trans("ErrorUserPermissionAllowsToLinksToItselfOnly"), null, 'errors'); + $error++; + setEventMessages($langs->trans("ErrorUserPermissionAllowsToLinksToItselfOnly"), null, 'errors'); } - } + } - if (!$error) { - if ($_POST["userid"] != $object->user_id) { // If link differs from currently in database + if (!$error) { + if ($_POST["userid"] != $object->user_id) { // If link differs from currently in database $result = $object->setUserId($_POST["userid"]); - if ($result < 0) dol_print_error('', $object->error); - $_POST['action'] = ''; - $action = ''; - } - } + if ($result < 0) dol_print_error('', $object->error); + $_POST['action'] = ''; + $action = ''; + } + } } if ($action == 'setsocid') { - $error = 0; - if (!$error) { - if (GETPOST('socid', 'int') != $object->fk_soc) { // If link differs from currently in database + $error = 0; + if (!$error) { + if (GETPOST('socid', 'int') != $object->fk_soc) { // If link differs from currently in database $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."adherent"; - $sql .= " WHERE fk_soc = '".GETPOST('socid', 'int')."'"; - $resql = $db->query($sql); - if ($resql) { - $obj = $db->fetch_object($resql); - if ($obj && $obj->rowid > 0) { - $othermember = new Adherent($db); - $othermember->fetch($obj->rowid); - $thirdparty = new Societe($db); - $thirdparty->fetch(GETPOST('socid', 'int')); - $error++; - setEventMessages($langs->trans("ErrorMemberIsAlreadyLinkedToThisThirdParty", $othermember->getFullName($langs), $othermember->login, $thirdparty->name), null, 'errors'); - } - } + $sql .= " WHERE fk_soc = '".GETPOST('socid', 'int')."'"; + $resql = $db->query($sql); + if ($resql) { + $obj = $db->fetch_object($resql); + if ($obj && $obj->rowid > 0) { + $othermember = new Adherent($db); + $othermember->fetch($obj->rowid); + $thirdparty = new Societe($db); + $thirdparty->fetch(GETPOST('socid', 'int')); + $error++; + setEventMessages($langs->trans("ErrorMemberIsAlreadyLinkedToThisThirdParty", $othermember->getFullName($langs), $othermember->login, $thirdparty->name), null, 'errors'); + } + } - if (!$error) { - $result = $object->setThirdPartyId(GETPOST('socid', 'int')); - if ($result < 0) dol_print_error('', $object->error); - $_POST['action'] = ''; - $action = ''; - } - } - } + if (!$error) { + $result = $object->setThirdPartyId(GETPOST('socid', 'int')); + if ($result < 0) dol_print_error('', $object->error); + $_POST['action'] = ''; + $action = ''; + } + } + } } if ($user->rights->adherent->cotisation->creer && $action == 'subscription' && !$_POST["cancel"]) { - $error = 0; + $error = 0; - $langs->load("banks"); + $langs->load("banks"); - $result = $object->fetch($rowid); - $result = $adht->fetch($object->typeid); + $result = $object->fetch($rowid); + $result = $adht->fetch($object->typeid); - // Subscription informations - $datesubscription = 0; - $datesubend = 0; - $paymentdate = 0; - if ($_POST["reyear"] && $_POST["remonth"] && $_POST["reday"]) { - $datesubscription = dol_mktime(0, 0, 0, $_POST["remonth"], $_POST["reday"], $_POST["reyear"]); - } - if ($_POST["endyear"] && $_POST["endmonth"] && $_POST["endday"]) { - $datesubend = dol_mktime(0, 0, 0, $_POST["endmonth"], $_POST["endday"], $_POST["endyear"]); - } - if ($_POST["paymentyear"] && $_POST["paymentmonth"] && $_POST["paymentday"]) { - $paymentdate = dol_mktime(0, 0, 0, $_POST["paymentmonth"], $_POST["paymentday"], $_POST["paymentyear"]); - } - $amount = price2num(GETPOST("subscription", 'alpha')); // Amount of subscription - $label = $_POST["label"]; + // Subscription informations + $datesubscription = 0; + $datesubend = 0; + $paymentdate = 0; + if ($_POST["reyear"] && $_POST["remonth"] && $_POST["reday"]) { + $datesubscription = dol_mktime(0, 0, 0, $_POST["remonth"], $_POST["reday"], $_POST["reyear"]); + } + if ($_POST["endyear"] && $_POST["endmonth"] && $_POST["endday"]) { + $datesubend = dol_mktime(0, 0, 0, $_POST["endmonth"], $_POST["endday"], $_POST["endyear"]); + } + if ($_POST["paymentyear"] && $_POST["paymentmonth"] && $_POST["paymentday"]) { + $paymentdate = dol_mktime(0, 0, 0, $_POST["paymentmonth"], $_POST["paymentday"], $_POST["paymentyear"]); + } + $amount = price2num(GETPOST("subscription", 'alpha')); // Amount of subscription + $label = $_POST["label"]; - // Payment informations - $accountid = $_POST["accountid"]; - $operation = $_POST["operation"]; // Payment mode - $num_chq = GETPOST("num_chq", "alphanohtml"); - $emetteur_nom = $_POST["chqemetteur"]; - $emetteur_banque = $_POST["chqbank"]; - $option = $_POST["paymentsave"]; - if (empty($option)) $option = 'none'; - $sendalsoemail = GETPOST("sendmail", 'alpha'); + // Payment informations + $accountid = $_POST["accountid"]; + $operation = $_POST["operation"]; // Payment mode + $num_chq = GETPOST("num_chq", "alphanohtml"); + $emetteur_nom = $_POST["chqemetteur"]; + $emetteur_banque = $_POST["chqbank"]; + $option = $_POST["paymentsave"]; + if (empty($option)) $option = 'none'; + $sendalsoemail = GETPOST("sendmail", 'alpha'); - // Check parameters - if (!$datesubscription) { - $error++; - $langs->load("errors"); - $errmsg = $langs->trans("ErrorBadDateFormat", $langs->transnoentitiesnoconv("DateSubscription")); - setEventMessages($errmsg, null, 'errors'); - $action = 'addsubscription'; - } - if (GETPOST('end') && !$datesubend) { - $error++; - $langs->load("errors"); - $errmsg = $langs->trans("ErrorBadDateFormat", $langs->transnoentitiesnoconv("DateEndSubscription")); - setEventMessages($errmsg, null, 'errors'); - $action = 'addsubscription'; - } - if (!$datesubend) { - $datesubend = dol_time_plus_duree(dol_time_plus_duree($datesubscription, $defaultdelay, $defaultdelayunit), -1, 'd'); - } - if (($option == 'bankviainvoice' || $option == 'bankdirect') && !$paymentdate) { - $error++; - $errmsg = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("DatePayment")); - setEventMessages($errmsg, null, 'errors'); - $action = 'addsubscription'; - } + // Check parameters + if (!$datesubscription) { + $error++; + $langs->load("errors"); + $errmsg = $langs->trans("ErrorBadDateFormat", $langs->transnoentitiesnoconv("DateSubscription")); + setEventMessages($errmsg, null, 'errors'); + $action = 'addsubscription'; + } + if (GETPOST('end') && !$datesubend) { + $error++; + $langs->load("errors"); + $errmsg = $langs->trans("ErrorBadDateFormat", $langs->transnoentitiesnoconv("DateEndSubscription")); + setEventMessages($errmsg, null, 'errors'); + $action = 'addsubscription'; + } + if (!$datesubend) { + $datesubend = dol_time_plus_duree(dol_time_plus_duree($datesubscription, $defaultdelay, $defaultdelayunit), -1, 'd'); + } + if (($option == 'bankviainvoice' || $option == 'bankdirect') && !$paymentdate) { + $error++; + $errmsg = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("DatePayment")); + setEventMessages($errmsg, null, 'errors'); + $action = 'addsubscription'; + } - // Check if a payment is mandatory or not - if (!$error && $adht->subscription) { // Member type need subscriptions + // Check if a payment is mandatory or not + if (!$error && $adht->subscription) { // Member type need subscriptions if (!is_numeric($amount)) { - // If field is '' or not a numeric value - $errmsg = $langs->trans("ErrorFieldRequired", $langs->transnoentities("Amount")); - setEventMessages($errmsg, null, 'errors'); - $error++; - $action = 'addsubscription'; + // If field is '' or not a numeric value + $errmsg = $langs->trans("ErrorFieldRequired", $langs->transnoentities("Amount")); + setEventMessages($errmsg, null, 'errors'); + $error++; + $action = 'addsubscription'; } else { - if (!empty($conf->banque->enabled) && $_POST["paymentsave"] != 'none') { - if ($_POST["subscription"]) { - if (!$_POST["label"]) $errmsg = $langs->trans("ErrorFieldRequired", $langs->transnoentities("Label")); - if ($_POST["paymentsave"] != 'invoiceonly' && !$_POST["operation"]) $errmsg = $langs->trans("ErrorFieldRequired", $langs->transnoentities("PaymentMode")); - if ($_POST["paymentsave"] != 'invoiceonly' && !($_POST["accountid"] > 0)) $errmsg = $langs->trans("ErrorFieldRequired", $langs->transnoentities("FinancialAccount")); - } else { - if ($_POST["accountid"]) $errmsg = $langs->trans("ErrorDoNotProvideAccountsIfNullAmount"); - } - if ($errmsg) { - $error++; - setEventMessages($errmsg, null, 'errors'); - $error++; - $action = 'addsubscription'; - } - } - } - } + if (!empty($conf->banque->enabled) && $_POST["paymentsave"] != 'none') { + if ($_POST["subscription"]) { + if (!$_POST["label"]) $errmsg = $langs->trans("ErrorFieldRequired", $langs->transnoentities("Label")); + if ($_POST["paymentsave"] != 'invoiceonly' && !$_POST["operation"]) $errmsg = $langs->trans("ErrorFieldRequired", $langs->transnoentities("PaymentMode")); + if ($_POST["paymentsave"] != 'invoiceonly' && !($_POST["accountid"] > 0)) $errmsg = $langs->trans("ErrorFieldRequired", $langs->transnoentities("FinancialAccount")); + } else { + if ($_POST["accountid"]) $errmsg = $langs->trans("ErrorDoNotProvideAccountsIfNullAmount"); + } + if ($errmsg) { + $error++; + setEventMessages($errmsg, null, 'errors'); + $error++; + $action = 'addsubscription'; + } + } + } + } - // Record the subscription then complementary actions - if (!$error && $action == 'subscription') { - $db->begin(); + // Record the subscription then complementary actions + if (!$error && $action == 'subscription') { + $db->begin(); - // Create subscription - $crowid = $object->subscription($datesubscription, $amount, $accountid, $operation, $label, $num_chq, $emetteur_nom, $emetteur_banque, $datesubend); - if ($crowid <= 0) { - $error++; - $errmsg = $object->error; - setEventMessages($object->error, $object->errors, 'errors'); - } + // Create subscription + $crowid = $object->subscription($datesubscription, $amount, $accountid, $operation, $label, $num_chq, $emetteur_nom, $emetteur_banque, $datesubend); + if ($crowid <= 0) { + $error++; + $errmsg = $object->error; + setEventMessages($object->error, $object->errors, 'errors'); + } - if (!$error) { - $result = $object->subscriptionComplementaryActions($crowid, $option, $accountid, $datesubscription, $paymentdate, $operation, $label, $amount, $num_chq, $emetteur_nom, $emetteur_banque); + if (!$error) { + $result = $object->subscriptionComplementaryActions($crowid, $option, $accountid, $datesubscription, $paymentdate, $operation, $label, $amount, $num_chq, $emetteur_nom, $emetteur_banque); if ($result < 0) { $error++; setEventMessages($object->error, $object->errors, 'errors'); } else { // If an invoice was created, it is into $object->invoice } - } + } - if (!$error) { - $db->commit(); - } else { - $db->rollback(); - $action = 'addsubscription'; - } + if (!$error) { + $db->commit(); + } else { + $db->rollback(); + $action = 'addsubscription'; + } - if (!$error) { - setEventMessages("SubscriptionRecorded", null, 'mesgs'); - } + if (!$error) { + setEventMessages("SubscriptionRecorded", null, 'mesgs'); + } - // Send email - if (!$error) { - // Send confirmation Email - if ($object->email && $sendalsoemail) { // $object is 'Adherent' + // Send email + if (!$error) { + // Send confirmation Email + if ($object->email && $sendalsoemail) { // $object is 'Adherent' $subject = ''; - $msg = ''; + $msg = ''; - // Send subscription email - include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php'; - $formmail = new FormMail($db); - // Set output language - $outputlangs = new Translate('', $conf); - $outputlangs->setDefaultLang(empty($object->thirdparty->default_lang) ? $mysoc->default_lang : $object->thirdparty->default_lang); - // Load traductions files required by page - $outputlangs->loadLangs(array("main", "members")); + // Send subscription email + include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php'; + $formmail = new FormMail($db); + // Set output language + $outputlangs = new Translate('', $conf); + $outputlangs->setDefaultLang(empty($object->thirdparty->default_lang) ? $mysoc->default_lang : $object->thirdparty->default_lang); + // Load traductions files required by page + $outputlangs->loadLangs(array("main", "members")); - // Get email content from template - $arraydefaultmessage = null; - $labeltouse = $conf->global->ADHERENT_EMAIL_TEMPLATE_SUBSCRIPTION; + // Get email content from template + $arraydefaultmessage = null; + $labeltouse = $conf->global->ADHERENT_EMAIL_TEMPLATE_SUBSCRIPTION; - if (!empty($labeltouse)) $arraydefaultmessage = $formmail->getEMailTemplate($db, 'member', $user, $outputlangs, 0, 1, $labeltouse); + if (!empty($labeltouse)) $arraydefaultmessage = $formmail->getEMailTemplate($db, 'member', $user, $outputlangs, 0, 1, $labeltouse); - if (!empty($labeltouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0) { - $subject = $arraydefaultmessage->topic; - $msg = $arraydefaultmessage->content; - } + if (!empty($labeltouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0) { + $subject = $arraydefaultmessage->topic; + $msg = $arraydefaultmessage->content; + } - $substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $object); - complete_substitutions_array($substitutionarray, $outputlangs, $object); - $subjecttosend = make_substitutions($subject, $substitutionarray, $outputlangs); - $texttosend = make_substitutions(dol_concatdesc($msg, $adht->getMailOnSubscription()), $substitutionarray, $outputlangs); + $substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $object); + complete_substitutions_array($substitutionarray, $outputlangs, $object); + $subjecttosend = make_substitutions($subject, $substitutionarray, $outputlangs); + $texttosend = make_substitutions(dol_concatdesc($msg, $adht->getMailOnSubscription()), $substitutionarray, $outputlangs); - // Attach a file ? - $file = ''; - $listofpaths = array(); - $listofnames = array(); - $listofmimes = array(); - if (is_object($object->invoice)) { - $invoicediroutput = $conf->facture->dir_output; - $fileparams = dol_most_recent_file($invoicediroutput.'/'.$object->invoice->ref, preg_quote($object->invoice->ref, '/').'[^\-]+'); - $file = $fileparams['fullname']; + // Attach a file ? + $file = ''; + $listofpaths = array(); + $listofnames = array(); + $listofmimes = array(); + if (is_object($object->invoice)) { + $invoicediroutput = $conf->facture->dir_output; + $fileparams = dol_most_recent_file($invoicediroutput.'/'.$object->invoice->ref, preg_quote($object->invoice->ref, '/').'[^\-]+'); + $file = $fileparams['fullname']; - $listofpaths = array($file); - $listofnames = array(basename($file)); - $listofmimes = array(dol_mimetype($file)); - } + $listofpaths = array($file); + $listofnames = array(basename($file)); + $listofmimes = array(dol_mimetype($file)); + } - $moreinheader = 'X-Dolibarr-Info: send_an_email by adherents/subscription.php'."\r\n"; + $moreinheader = 'X-Dolibarr-Info: send_an_email by adherents/subscription.php'."\r\n"; - $result = $object->send_an_email($texttosend, $subjecttosend, $listofpaths, $listofmimes, $listofnames, "", "", 0, -1, '', $moreinheader); - if ($result < 0) { - $errmsg = $object->error; - setEventMessages($object->error, $object->errors, 'errors'); - } else { - setEventMessages($langs->trans("EmailSentToMember", $object->email), null, 'mesgs'); - } - } else { - setEventMessages($langs->trans("NoEmailSentToMember"), null, 'mesgs'); - } - } + $result = $object->send_an_email($texttosend, $subjecttosend, $listofpaths, $listofmimes, $listofnames, "", "", 0, -1, '', $moreinheader); + if ($result < 0) { + $errmsg = $object->error; + setEventMessages($object->error, $object->errors, 'errors'); + } else { + setEventMessages($langs->trans("EmailSentToMember", $object->email), null, 'mesgs'); + } + } else { + setEventMessages($langs->trans("NoEmailSentToMember"), null, 'mesgs'); + } + } - // Clean some POST vars - if (!$error) { - $_POST["subscription"] = ''; - $_POST["accountid"] = ''; - $_POST["operation"] = ''; - $_POST["label"] = ''; - $_POST["num_chq"] = ''; - } - } + // Clean some POST vars + if (!$error) { + $_POST["subscription"] = ''; + $_POST["accountid"] = ''; + $_POST["operation"] = ''; + $_POST["label"] = ''; + $_POST["num_chq"] = ''; + } + } } @@ -393,32 +393,32 @@ if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss); if ($rowid > 0) { - $res = $object->fetch($rowid); - if ($res < 0) { dol_print_error($db, $object->error); exit; } + $res = $object->fetch($rowid); + if ($res < 0) { dol_print_error($db, $object->error); exit; } - $adht->fetch($object->typeid); + $adht->fetch($object->typeid); - $head = member_prepare_head($object); + $head = member_prepare_head($object); - $rowspan = 10; - if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) $rowspan++; - if (!empty($conf->societe->enabled)) $rowspan++; + $rowspan = 10; + if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) $rowspan++; + if (!empty($conf->societe->enabled)) $rowspan++; - print '
'; - print ''; - print ''; + print ''; + print ''; + print ''; - print dol_get_fiche_head($head, 'subscription', $langs->trans("Member"), -1, 'user'); + print dol_get_fiche_head($head, 'subscription', $langs->trans("Member"), -1, 'user'); - $linkback = ''.$langs->trans("BackToList").''; + $linkback = ''.$langs->trans("BackToList").''; - dol_banner_tab($object, 'rowid', $linkback); + dol_banner_tab($object, 'rowid', $linkback); - print '
'; - print '
'; + print '
'; + print '
'; - print '
'; - print ''; + print '
'; + print '
'; // Login if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) { @@ -443,20 +443,20 @@ if ($rowid > 0) { if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) { print ''; } - print '
'.$langs->trans("Password").''.preg_replace('/./i', '*', $object->pass); if ((!empty($object->pass) || !empty($object->pass_crypted)) && empty($object->user_id)) { - $langs->load("errors"); - $htmltext = $langs->trans("WarningPasswordSetWithNoAccount"); - print ' '.$form->textwithpicto('', $htmltext, 1, 'warning'); + $langs->load("errors"); + $htmltext = $langs->trans("WarningPasswordSetWithNoAccount"); + print ' '.$form->textwithpicto('', $htmltext, 1, 'warning'); } print '
'; + print ''; - print '
'; - print '
'; + print '
'; + print '
'; - print '
'; - print ''; + print '
'; + print '
'; // Birthday print ''; @@ -472,25 +472,25 @@ if ($rowid > 0) { print ''; } - // Other attributes - $cols = 2; - include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php'; + // Other attributes + $cols = 2; + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php'; // Date end subscription print ''; @@ -555,7 +555,7 @@ if ($rowid > 0) { print "\n"; print '
'; - dol_fiche_end(); + print dol_get_fiche_end(); print ''; @@ -660,71 +660,71 @@ if ($rowid > 0) { $accountstatic->accountancy_journal = $accountingjournal->getNomUrl(0, 1, 1, '', 1); } - $accountstatic->ref = $objp->ref; - print $accountstatic->getNomUrl(1); - } else { - print ' '; - } - print ''; - } - print ""; - $i++; - } + $accountstatic->ref = $objp->ref; + print $accountstatic->getNomUrl(1); + } else { + print ' '; + } + print ''; + } + print ""; + $i++; + } - if (empty($num)) { - $colspan = 6; - if (!empty($conf->banque->enabled)) $colspan++; - print ''; - } + if (empty($num)) { + $colspan = 6; + if (!empty($conf->banque->enabled)) $colspan++; + print ''; + } - print "
'.$langs->trans("Birthday").''.dol_print_date($object->birth, 'day').'
'.$langs->trans("SubscriptionEndDate").''; if ($object->datefin) { - print dol_print_date($object->datefin, 'day'); - if ($object->hasDelay()) { - print " ".img_warning($langs->trans("Late")); - } + print dol_print_date($object->datefin, 'day'); + if ($object->hasDelay()) { + print " ".img_warning($langs->trans("Late")); + } } else { - if (!$adht->subscription) { - print $langs->trans("SubscriptionNotRecorded"); - if ($object->statut > 0) print " ".img_warning($langs->trans("Late")); // Display a delay picto only if it is not a draft and is not canceled - } else { - print $langs->trans("SubscriptionNotReceived"); - if ($object->statut > 0) print " ".img_warning($langs->trans("Late")); // Display a delay picto only if it is not a draft and is not canceled - } + if (!$adht->subscription) { + print $langs->trans("SubscriptionNotRecorded"); + if ($object->statut > 0) print " ".img_warning($langs->trans("Late")); // Display a delay picto only if it is not a draft and is not canceled + } else { + print $langs->trans("SubscriptionNotReceived"); + if ($object->statut > 0) print " ".img_warning($langs->trans("Late")); // Display a delay picto only if it is not a draft and is not canceled + } } print '
'.$langs->trans("None").'
'.$langs->trans("None").'
"; - } else { - dol_print_error($db); - } - } + print ""; + } else { + dol_print_error($db); + } + } - if (($action != 'addsubscription' && $action != 'create_thirdparty')) { - // Shon online payment link - $useonlinepayment = (!empty($conf->paypal->enabled) || !empty($conf->stripe->enabled) || !empty($conf->paybox->enabled)); + if (($action != 'addsubscription' && $action != 'create_thirdparty')) { + // Shon online payment link + $useonlinepayment = (!empty($conf->paypal->enabled) || !empty($conf->stripe->enabled) || !empty($conf->paybox->enabled)); - if ($useonlinepayment) { - print '
'; + if ($useonlinepayment) { + print '
'; - require_once DOL_DOCUMENT_ROOT.'/core/lib/payments.lib.php'; - print showOnlinePaymentUrl('membersubscription', $object->ref); - print '
'; - } - } + require_once DOL_DOCUMENT_ROOT.'/core/lib/payments.lib.php'; + print showOnlinePaymentUrl('membersubscription', $object->ref); + print '
'; + } + } - /* + /* * Add new subscription form */ - if (($action == 'addsubscription' || $action == 'create_thirdparty') && $user->rights->adherent->cotisation->creer) { - print '
'; + if (($action == 'addsubscription' || $action == 'create_thirdparty') && $user->rights->adherent->cotisation->creer) { + print '
'; - print load_fiche_titre($langs->trans("NewCotisation")); + print load_fiche_titre($langs->trans("NewCotisation")); - // Define default choice for complementary actions - $bankdirect = 0; // 1 means option by default is write to bank direct with no invoice - $invoiceonly = 0; // 1 means option by default is invoice only - $bankviainvoice = 0; // 1 means option by default is write to bank via invoice - if (GETPOST('paymentsave')) { - if (GETPOST('paymentsave') == 'bankdirect') $bankdirect = 1; - if (GETPOST('paymentsave') == 'invoiceonly') $invoiceonly = 1; - if (GETPOST('paymentsave') == 'bankviainvoice') $bankviainvoice = 1; - } else { - if (!empty($conf->global->ADHERENT_BANK_USE) && $conf->global->ADHERENT_BANK_USE == 'bankviainvoice' && !empty($conf->banque->enabled) && !empty($conf->societe->enabled) && !empty($conf->facture->enabled)) $bankviainvoice = 1; - elseif (!empty($conf->global->ADHERENT_BANK_USE) && $conf->global->ADHERENT_BANK_USE == 'bankdirect' && !empty($conf->banque->enabled)) $bankdirect = 1; - elseif (!empty($conf->global->ADHERENT_BANK_USE) && $conf->global->ADHERENT_BANK_USE == 'invoiceonly' && !empty($conf->banque->enabled) && !empty($conf->societe->enabled) && !empty($conf->facture->enabled)) $invoiceonly = 1; - } + // Define default choice for complementary actions + $bankdirect = 0; // 1 means option by default is write to bank direct with no invoice + $invoiceonly = 0; // 1 means option by default is invoice only + $bankviainvoice = 0; // 1 means option by default is write to bank via invoice + if (GETPOST('paymentsave')) { + if (GETPOST('paymentsave') == 'bankdirect') $bankdirect = 1; + if (GETPOST('paymentsave') == 'invoiceonly') $invoiceonly = 1; + if (GETPOST('paymentsave') == 'bankviainvoice') $bankviainvoice = 1; + } else { + if (!empty($conf->global->ADHERENT_BANK_USE) && $conf->global->ADHERENT_BANK_USE == 'bankviainvoice' && !empty($conf->banque->enabled) && !empty($conf->societe->enabled) && !empty($conf->facture->enabled)) $bankviainvoice = 1; + elseif (!empty($conf->global->ADHERENT_BANK_USE) && $conf->global->ADHERENT_BANK_USE == 'bankdirect' && !empty($conf->banque->enabled)) $bankdirect = 1; + elseif (!empty($conf->global->ADHERENT_BANK_USE) && $conf->global->ADHERENT_BANK_USE == 'invoiceonly' && !empty($conf->banque->enabled) && !empty($conf->societe->enabled) && !empty($conf->facture->enabled)) $invoiceonly = 1; + } - print "\n\n\n"; + print "\n\n\n"; - if ($conf->use_javascript_ajax) { - //var_dump($bankdirect.'-'.$bankviainvoice.'-'.$invoiceonly.'-'.empty($conf->global->ADHERENT_BANK_USE)); - print "\n".''."\n"; - } + if (GETPOST('paymentsave')) print '$("#'.GETPOST('paymentsave').'").prop("checked",true);'; + print '});'; + print ''."\n"; + } // Confirm create third party @@ -778,16 +778,16 @@ if ($rowid > 0) { if (!empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED)) { $tmpcompany = new Societe($db); $tmpcompany->name = $companyname; - $tmpcompany->get_codeclient($tmpcompany, 0); + $tmpcompany->get_codeclient($tmpcompany, 0); $customercode = $tmpcompany->code_client; $formquestion[] = array( - 'label' => $langs->trans("CustomerCode"), - 'type' => 'text', - 'name' => 'customercode', - 'value' => $customercode, - 'morecss' => 'minwidth300', - 'moreattr' => 'maxlength="128"', - ); + 'label' => $langs->trans("CustomerCode"), + 'type' => 'text', + 'name' => 'customercode', + 'value' => $customercode, + 'morecss' => 'minwidth300', + 'moreattr' => 'maxlength="128"', + ); } // @todo Add other extrafields mandatory for thirdparty creation @@ -795,99 +795,99 @@ if ($rowid > 0) { } - print '
'; - print ''; - print ''; - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; print dol_get_fiche_head(''); print "\n"; - print ''; + print ''; $today = dol_now(); - $datefrom = 0; - $dateto = 0; - $paymentdate = -1; + $datefrom = 0; + $dateto = 0; + $paymentdate = -1; - // Date payment - if (GETPOST('paymentyear') && GETPOST('paymentmonth') && GETPOST('paymentday')) { - $paymentdate = dol_mktime(0, 0, 0, GETPOST('paymentmonth'), GETPOST('paymentday'), GETPOST('paymentyear')); - } + // Date payment + if (GETPOST('paymentyear') && GETPOST('paymentmonth') && GETPOST('paymentday')) { + $paymentdate = dol_mktime(0, 0, 0, GETPOST('paymentmonth'), GETPOST('paymentday'), GETPOST('paymentyear')); + } - print ''; - // Date start subscription - print '"; + print ''; + // Date start subscription + print '"; - // Date end subscription - if (GETPOST('endday')) { - $dateto = dol_mktime(0, 0, 0, GETPOST('endmonth'), GETPOST('endday'), GETPOST('endyear')); - } - if (!$dateto) { - $dateto = -1; // By default, no date is suggested - } - print '"; + // Date end subscription + if (GETPOST('endday')) { + $dateto = dol_mktime(0, 0, 0, GETPOST('endmonth'), GETPOST('endday'), GETPOST('endyear')); + } + if (!$dateto) { + $dateto = -1; // By default, no date is suggested + } + print '"; - if ($adht->subscription) { - // Amount - print ''; + if ($adht->subscription) { + // Amount + print ''; - // Label - print ''; - print ''; + // Label + print ''; + print ''; - // Complementary action - if ((!empty($conf->banque->enabled) || !empty($conf->facture->enabled)) && empty($conf->global->ADHERENT_SUBSCRIPTION_HIDECOMPLEMENTARYACTIONS)) { - $company = new Societe($db); - if ($object->fk_soc) { - $result = $company->fetch($object->fk_soc); - } + // Complementary action + if ((!empty($conf->banque->enabled) || !empty($conf->facture->enabled)) && empty($conf->global->ADHERENT_SUBSCRIPTION_HIDECOMPLEMENTARYACTIONS)) { + $company = new Societe($db); + if ($object->fk_soc) { + $result = $company->fetch($object->fk_soc); + } - // Title payments - //print ''; + // Title payments + //print ''; - // No more action - print ''; - print ''; + print ''; print '
'.$langs->trans("DateSubscription").''; - if (GETPOST('reday')) { - $datefrom = dol_mktime(0, 0, 0, GETPOST('remonth'), GETPOST('reday'), GETPOST('reyear')); - } - if (!$datefrom) { - $datefrom = $object->datevalid; - if ($object->datefin > 0) { - $datefrom = dol_time_plus_duree($object->datefin, 1, 'd'); - } - } - print $form->selectDate($datefrom, '', '', '', '', "subscription", 1, 1); - print "
'.$langs->trans("DateSubscription").''; + if (GETPOST('reday')) { + $datefrom = dol_mktime(0, 0, 0, GETPOST('remonth'), GETPOST('reday'), GETPOST('reyear')); + } + if (!$datefrom) { + $datefrom = $object->datevalid; + if ($object->datefin > 0) { + $datefrom = dol_time_plus_duree($object->datefin, 1, 'd'); + } + } + print $form->selectDate($datefrom, '', '', '', '', "subscription", 1, 1); + print "
'.$langs->trans("DateEndSubscription").''; - print $form->selectDate($dateto, 'end', '', '', '', "subscription", 1, 0); - print "
'.$langs->trans("DateEndSubscription").''; + print $form->selectDate($dateto, 'end', '', '', '', "subscription", 1, 0); + print "
'.$langs->trans("Amount").' '.$langs->trans("Currency".$conf->currency).'
'.$langs->trans("Amount").' '.$langs->trans("Currency".$conf->currency).'
'.$langs->trans("Label").'
'.$langs->trans("Label").'
'.$langs->trans("Payment").'
'.$langs->trans("Payment").'
'.$langs->trans('MoreActions'); - print ''; - print ' '.$langs->trans("None").'
'; - // Add entry into bank accoun - if (!empty($conf->banque->enabled)) { - print ' '.$langs->trans("MoreActionBankDirect").'
'; - } - // Add invoice with no payments - if (!empty($conf->societe->enabled) && !empty($conf->facture->enabled)) { - print 'fk_soc)) print ' disabled'; - print '> '.$langs->trans("MoreActionInvoiceOnly"); - if ($object->fk_soc) print ' ('.$langs->trans("ThirdParty").': '.$company->getNomUrl(1).')'; - else { - print ' ('; - if (empty($object->fk_soc)) print img_warning($langs->trans("NoThirdPartyAssociatedToMember")); - print $langs->trans("NoThirdPartyAssociatedToMember"); - print ' - '; - print $langs->trans("CreateDolibarrThirdParty"); - print ')'; - } - if (empty($conf->global->ADHERENT_VAT_FOR_SUBSCRIPTIONS) || $conf->global->ADHERENT_VAT_FOR_SUBSCRIPTIONS != 'defaultforfoundationcountry') print '. '.$langs->trans("NoVatOnSubscription", 0).''; + // No more action + print '
'.$langs->trans('MoreActions'); + print ''; + print ' '.$langs->trans("None").'
'; + // Add entry into bank accoun + if (!empty($conf->banque->enabled)) { + print ' '.$langs->trans("MoreActionBankDirect").'
'; + } + // Add invoice with no payments + if (!empty($conf->societe->enabled) && !empty($conf->facture->enabled)) { + print 'fk_soc)) print ' disabled'; + print '> '.$langs->trans("MoreActionInvoiceOnly"); + if ($object->fk_soc) print ' ('.$langs->trans("ThirdParty").': '.$company->getNomUrl(1).')'; + else { + print ' ('; + if (empty($object->fk_soc)) print img_warning($langs->trans("NoThirdPartyAssociatedToMember")); + print $langs->trans("NoThirdPartyAssociatedToMember"); + print ' - '; + print $langs->trans("CreateDolibarrThirdParty"); + print ')'; + } + if (empty($conf->global->ADHERENT_VAT_FOR_SUBSCRIPTIONS) || $conf->global->ADHERENT_VAT_FOR_SUBSCRIPTIONS != 'defaultforfoundationcountry') print '. '.$langs->trans("NoVatOnSubscription", 0).''; if (!empty($conf->global->ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS) && (!empty($conf->product->enabled) || !empty($conf->service->enabled))) { $prodtmp = new Product($db); $result = $prodtmp->fetch($conf->global->ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS); @@ -896,23 +896,23 @@ if ($rowid > 0) { } print '. '.$langs->transnoentitiesnoconv("ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS", $prodtmp->getNomUrl(1)); // must use noentitiesnoconv to avoid to encode html into getNomUrl of product } - print '
'; - } - // Add invoice with payments - if (!empty($conf->banque->enabled) && !empty($conf->societe->enabled) && !empty($conf->facture->enabled)) { - print 'fk_soc)) print ' disabled'; - print '> '.$langs->trans("MoreActionBankViaInvoice"); - if ($object->fk_soc) print ' ('.$langs->trans("ThirdParty").': '.$company->getNomUrl(1).')'; - else { - print ' ('; - if (empty($object->fk_soc)) print img_warning($langs->trans("NoThirdPartyAssociatedToMember")); - print $langs->trans("NoThirdPartyAssociatedToMember"); - print ' - '; - print $langs->trans("CreateDolibarrThirdParty"); - print ')'; - } - if (empty($conf->global->ADHERENT_VAT_FOR_SUBSCRIPTIONS) || $conf->global->ADHERENT_VAT_FOR_SUBSCRIPTIONS != 'defaultforfoundationcountry') print '. '.$langs->trans("NoVatOnSubscription", 0).''; + print '
'; + } + // Add invoice with payments + if (!empty($conf->banque->enabled) && !empty($conf->societe->enabled) && !empty($conf->facture->enabled)) { + print 'fk_soc)) print ' disabled'; + print '> '.$langs->trans("MoreActionBankViaInvoice"); + if ($object->fk_soc) print ' ('.$langs->trans("ThirdParty").': '.$company->getNomUrl(1).')'; + else { + print ' ('; + if (empty($object->fk_soc)) print img_warning($langs->trans("NoThirdPartyAssociatedToMember")); + print $langs->trans("NoThirdPartyAssociatedToMember"); + print ' - '; + print $langs->trans("CreateDolibarrThirdParty"); + print ')'; + } + if (empty($conf->global->ADHERENT_VAT_FOR_SUBSCRIPTIONS) || $conf->global->ADHERENT_VAT_FOR_SUBSCRIPTIONS != 'defaultforfoundationcountry') print '. '.$langs->trans("NoVatOnSubscription", 0).''; if (!empty($conf->global->ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS) && (!empty($conf->product->enabled) || !empty($conf->service->enabled))) { $prodtmp = new Product($db); $result = $prodtmp->fetch($conf->global->ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS); @@ -1020,7 +1020,7 @@ if ($rowid > 0) { print '
'; - dol_fiche_end(); + print dol_get_fiche_end(); print '
'; print ''; diff --git a/htdocs/adherents/subscription/card.php b/htdocs/adherents/subscription/card.php index 7dd6f3f0e66..6479b5c479f 100644 --- a/htdocs/adherents/subscription/card.php +++ b/htdocs/adherents/subscription/card.php @@ -232,7 +232,7 @@ if ($user->rights->adherent->cotisation->creer && $action == 'edit') { print ''; - dol_fiche_end(); + print dol_get_fiche_end(); print '
'; print ''; @@ -335,7 +335,7 @@ if ($rowid && $action != 'edit') { print ''; - dol_fiche_end(); + print dol_get_fiche_end(); /* * Barre d'actions diff --git a/htdocs/adherents/subscription/info.php b/htdocs/adherents/subscription/info.php index cbc659df766..a7a4a897505 100644 --- a/htdocs/adherents/subscription/info.php +++ b/htdocs/adherents/subscription/info.php @@ -72,7 +72,7 @@ print ''; print '
'; -dol_fiche_end(); +print dol_get_fiche_end(); // End of page llxFooter(); diff --git a/htdocs/adherents/subscription/list.php b/htdocs/adherents/subscription/list.php index 364a7854fb7..9b5efa214b9 100644 --- a/htdocs/adherents/subscription/list.php +++ b/htdocs/adherents/subscription/list.php @@ -142,6 +142,7 @@ $now = dol_now(); // List of subscriptions $sql = "SELECT d.rowid, d.login, d.firstname, d.lastname, d.societe, d.photo, d.statut,"; +$sql .= " d.gender, d.email, d.morphy,"; $sql .= " c.rowid as crowid, c.fk_type, c.subscription,"; $sql .= " c.dateadh, c.datef, c.datec as date_creation, c.tms as date_update,"; $sql .= " c.fk_bank as bank, c.note,"; @@ -151,8 +152,7 @@ $sql .= " JOIN ".MAIN_DB_PREFIX."subscription as c on d.rowid = c.fk_adherent"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."adherent_extrafields as ef on (d.rowid = ef.fk_object)"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."bank as b ON c.fk_bank=b.rowid"; $sql .= " WHERE d.entity IN (".getEntity('adherent').")"; -if (isset($date_select) && $date_select != '') -{ +if (isset($date_select) && $date_select != '') { $sql .= " AND c.dateadh >= '".((int) $date_select)."-01-01 00:00:00'"; $sql .= " AND c.dateadh < '".((int) $date_select + 1)."-01-01 00:00:00'"; } @@ -403,6 +403,9 @@ while ($i < min($num, $limit)) { $adherent->statut = $obj->statut; $adherent->login = $obj->login; $adherent->photo = $obj->photo; + $adherent->gender = $obj->gender; + $adherent->morphy = $obj->morphy; + $adherent->email = $obj->email; $adherent->typeid = $obj->type; $typeid = ($obj->fk_type > 0 ? $obj->fk_type : $adherent->typeid); diff --git a/htdocs/adherents/type.php b/htdocs/adherents/type.php index 3d9dc7ace60..d1573f316f9 100644 --- a/htdocs/adherents/type.php +++ b/htdocs/adherents/type.php @@ -358,7 +358,7 @@ if ($action == 'create') { print ''; print "\n"; - dol_fiche_end(); + print dol_get_fiche_end(); print '
'; print ''; @@ -433,7 +433,7 @@ if ($rowid > 0) { print ''; print '
'; - dol_fiche_end(); + print dol_get_fiche_end(); /* * Buttons @@ -759,7 +759,7 @@ if ($rowid > 0) { print ''; - dol_fiche_end(); + print dol_get_fiche_end(); print '
'; print ''; diff --git a/htdocs/adherents/type_ldap.php b/htdocs/adherents/type_ldap.php index f743de5421a..d8deebba9ba 100644 --- a/htdocs/adherents/type_ldap.php +++ b/htdocs/adherents/type_ldap.php @@ -114,7 +114,7 @@ print ''; print '
'; -dol_fiche_end(); +print dol_get_fiche_end(); /* * Action bar diff --git a/htdocs/adherents/type_translation.php b/htdocs/adherents/type_translation.php index 971d8411640..6cf349270e8 100644 --- a/htdocs/adherents/type_translation.php +++ b/htdocs/adherents/type_translation.php @@ -166,7 +166,7 @@ $linkback = ''.$langs->tra dol_banner_tab($object, 'rowid', $linkback); -dol_fiche_end(); +print dol_get_fiche_end(); @@ -272,7 +272,7 @@ if ($action == 'add' && $user->rights->adherent->configurer) { print ''; - dol_fiche_end(); + print dol_get_fiche_end(); print '
'; print ''; diff --git a/htdocs/admin/agenda.php b/htdocs/admin/agenda.php index fa459ceb926..0cd9dd52648 100644 --- a/htdocs/admin/agenda.php +++ b/htdocs/admin/agenda.php @@ -197,7 +197,7 @@ if (!empty($triggers)) print ''; print '
'; -dol_fiche_end(); +print dol_get_fiche_end(); print '
'; print ''; diff --git a/htdocs/admin/agenda_extrafields.php b/htdocs/admin/agenda_extrafields.php index 476bad8ce75..0c46e84dff6 100644 --- a/htdocs/admin/agenda_extrafields.php +++ b/htdocs/admin/agenda_extrafields.php @@ -78,7 +78,7 @@ print dol_get_fiche_head($head, 'attributes', $langs->trans("Agenda"), -1, 'acti require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php'; -dol_fiche_end(); +print dol_get_fiche_end(); // Buttons diff --git a/htdocs/admin/agenda_extsites.php b/htdocs/admin/agenda_extsites.php index d29ba6c4830..c743ed06e55 100644 --- a/htdocs/admin/agenda_extsites.php +++ b/htdocs/admin/agenda_extsites.php @@ -224,7 +224,7 @@ while ($i <= $MAXAGENDA) print ''; -dol_fiche_end(); +print dol_get_fiche_end(); print '
'; print ''; diff --git a/htdocs/admin/agenda_other.php b/htdocs/admin/agenda_other.php index e6f0885a6cb..a31c4ed1dbe 100644 --- a/htdocs/admin/agenda_other.php +++ b/htdocs/admin/agenda_other.php @@ -376,7 +376,7 @@ print ''."\n"; print ''; -dol_fiche_end(); +print dol_get_fiche_end(); print '
'; diff --git a/htdocs/admin/agenda_reminder.php b/htdocs/admin/agenda_reminder.php index 0f8b64c48b1..51a9d4f327b 100644 --- a/htdocs/admin/agenda_reminder.php +++ b/htdocs/admin/agenda_reminder.php @@ -229,7 +229,7 @@ if ($conf->global->MAIN_FEATURES_LEVEL == 2) print ''; -dol_fiche_end(); +print dol_get_fiche_end(); //print '
'; diff --git a/htdocs/admin/agenda_xcal.php b/htdocs/admin/agenda_xcal.php index 83fc2155236..fd80a545aa5 100644 --- a/htdocs/admin/agenda_xcal.php +++ b/htdocs/admin/agenda_xcal.php @@ -135,7 +135,7 @@ print ""; print ''; -dol_fiche_end(); +print dol_get_fiche_end(); print '
'; print "trans("Save")."\">"; diff --git a/htdocs/admin/bank.php b/htdocs/admin/bank.php index 71891c9c08d..c8157a40d81 100644 --- a/htdocs/admin/bank.php +++ b/htdocs/admin/bank.php @@ -495,7 +495,7 @@ if ($conf->global->BANK_REPORT_LAST_NUM_RELEVE) { print "\n"; print ''; -dol_fiche_end(); +print dol_get_fiche_end(); print '
'; print ''; diff --git a/htdocs/admin/bank_extrafields.php b/htdocs/admin/bank_extrafields.php index a554aa4a3cf..7ad9e1d0f23 100644 --- a/htdocs/admin/bank_extrafields.php +++ b/htdocs/admin/bank_extrafields.php @@ -75,7 +75,7 @@ print dol_get_fiche_head($head, 'attributes', $langs->trans("BankSetupModule"), require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php'; -dol_fiche_end(); +print dol_get_fiche_end(); // Buttons diff --git a/htdocs/admin/bom_extrafields.php b/htdocs/admin/bom_extrafields.php index a1dd1cde985..8ae26587ebd 100644 --- a/htdocs/admin/bom_extrafields.php +++ b/htdocs/admin/bom_extrafields.php @@ -74,7 +74,7 @@ print dol_get_fiche_head($head, 'bom_extrafields', $langs->trans("ExtraFields"), require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php'; -dol_fiche_end(); +print dol_get_fiche_end(); // Buttons diff --git a/htdocs/admin/chequereceipts.php b/htdocs/admin/chequereceipts.php index c5cf9b2eee9..4fee30d274e 100644 --- a/htdocs/admin/chequereceipts.php +++ b/htdocs/admin/chequereceipts.php @@ -266,7 +266,7 @@ print "
"; print ''."\n"; -dol_fiche_end(); +print dol_get_fiche_end(); print ''; diff --git a/htdocs/admin/commande_fournisseur_dispatch_extrafields.php b/htdocs/admin/commande_fournisseur_dispatch_extrafields.php index 3642205e158..98a98a7ec2c 100644 --- a/htdocs/admin/commande_fournisseur_dispatch_extrafields.php +++ b/htdocs/admin/commande_fournisseur_dispatch_extrafields.php @@ -83,7 +83,7 @@ print dol_get_fiche_head($head, 'attributeslines_reception', $langs->trans("Rece require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php'; -dol_fiche_end(); +print dol_get_fiche_end(); // Buttons diff --git a/htdocs/admin/company.php b/htdocs/admin/company.php index 2eb2c0edad1..2705ede5540 100644 --- a/htdocs/admin/company.php +++ b/htdocs/admin/company.php @@ -88,9 +88,9 @@ if (($action == 'update' && !GETPOST("cancel", 'alpha')) dolibarr_del_const($db, "MAIN_INFO_SOCIETE_STATE", $conf->entity); } - $db->begin(); + $db->begin(); - dolibarr_set_const($db, "MAIN_INFO_SOCIETE_NOM", GETPOST("nom", 'nohtml'), 'chaine', 0, '', $conf->entity); + dolibarr_set_const($db, "MAIN_INFO_SOCIETE_NOM", GETPOST("nom", 'nohtml'), 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, "MAIN_INFO_SOCIETE_ADDRESS", GETPOST("MAIN_INFO_SOCIETE_ADDRESS", 'nohtml'), 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, "MAIN_INFO_SOCIETE_TOWN", GETPOST("MAIN_INFO_SOCIETE_TOWN", 'nohtml'), 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, "MAIN_INFO_SOCIETE_ZIP", GETPOST("MAIN_INFO_SOCIETE_ZIP", 'alphanohtml'), 'chaine', 0, '', $conf->entity); @@ -141,8 +141,8 @@ if (($action == 'update' && !GETPOST("cancel", 'alpha')) // Create thumbs of logo (Note that PDF use original file and not thumbs) if ($isimage > 0) { - // Create thumbs - //$object->addThumbs($newfile); // We can't use addThumbs here yet because we need name of generated thumbs to add them into constants. TODO Check if need such constants. We should be able to retrieve value with get... + // Create thumbs + //$object->addThumbs($newfile); // We can't use addThumbs here yet because we need name of generated thumbs to add them into constants. TODO Check if need such constants. We should be able to retrieve value with get... // Create small thumb, Used on logon for example $imgThumbSmall = vignette($dirforimage.$original_file, $maxwidthsmall, $maxheightsmall, '_small', $quality); @@ -269,7 +269,7 @@ if ($action == 'addthumb' || $action == 'addthumbsquarred') // Regenerate thumb $reg = array(); - // Create thumbs + // Create thumbs //$object->addThumbs($newfile); // We can't use addThumbs here yet because we need name of generated thumbs to add them into constants. TODO Check if need such constants. We should be able to retrieve value with get... // Create small thumb. Used on logon for example @@ -777,8 +777,8 @@ if ($mysoc->useLocalTax(2)) $tooltiphelp = ($tooltiphelp != "LocalTax2IsUsedExample" ? "".$langs->trans("Example").': '.$langs->transcountry("LocalTax2IsUsedExample", $mysoc->country_code)."\n" : ""); if (!isOnlyOneLocalTax(2)) { - print '
: '; - $formcompany->select_localtax(2, $conf->global->MAIN_INFO_VALUE_LOCALTAX2, "lt2"); + print '
: '; + $formcompany->select_localtax(2, $conf->global->MAIN_INFO_VALUE_LOCALTAX2, "lt2"); } print '
: '; print $form->selectarray("clt2", $opcions, $conf->global->MAIN_INFO_LOCALTAX_CALC2); diff --git a/htdocs/admin/contract.php b/htdocs/admin/contract.php index 6ba10068c4c..b7065a230bd 100644 --- a/htdocs/admin/contract.php +++ b/htdocs/admin/contract.php @@ -488,7 +488,7 @@ print '
'; print ''; -dol_fiche_end(); +print dol_get_fiche_end(); // End of page llxFooter(); diff --git a/htdocs/admin/dav.php b/htdocs/admin/dav.php index 2dd5af492aa..2e8d29500ed 100644 --- a/htdocs/admin/dav.php +++ b/htdocs/admin/dav.php @@ -148,7 +148,7 @@ if ($action == 'edit') } -dol_fiche_end(); +print dol_get_fiche_end(); /*print '
'; print "trans("Save")."\">"; diff --git a/htdocs/admin/defaultvalues.php b/htdocs/admin/defaultvalues.php index 3d2bc3121d3..e3006635b39 100644 --- a/htdocs/admin/defaultvalues.php +++ b/htdocs/admin/defaultvalues.php @@ -401,7 +401,7 @@ if ($result) print ''; print '
'; -dol_fiche_end(); +print dol_get_fiche_end(); print "\n"; diff --git a/htdocs/admin/delivery_extrafields.php b/htdocs/admin/delivery_extrafields.php index 38628fa171b..c0ed636abac 100644 --- a/htdocs/admin/delivery_extrafields.php +++ b/htdocs/admin/delivery_extrafields.php @@ -80,7 +80,7 @@ print dol_get_fiche_head($head, 'attributes_receivings', $langs->trans("Receivin require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php'; -dol_fiche_end(); +print dol_get_fiche_end(); // Buttons diff --git a/htdocs/admin/deliverydet_extrafields.php b/htdocs/admin/deliverydet_extrafields.php index 50dea86c2a5..50032e8f793 100644 --- a/htdocs/admin/deliverydet_extrafields.php +++ b/htdocs/admin/deliverydet_extrafields.php @@ -81,7 +81,7 @@ print dol_get_fiche_head($head, 'attributeslines_receivings', $langs->trans("Rec require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php'; -dol_fiche_end(); +print dol_get_fiche_end(); // Buttons diff --git a/htdocs/admin/dict.php b/htdocs/admin/dict.php index 987d7a256af..43ce69f6e02 100644 --- a/htdocs/admin/dict.php +++ b/htdocs/admin/dict.php @@ -881,7 +881,7 @@ if (GETPOST('actionadd') || GETPOST('actionmodify')) if (in_array($rowidcol, array('code', 'code_iso'))) { $sql .= " WHERE ".$rowidcol." = '".$db->escape($rowid)."'"; } else { - $sql .= " WHERE ".$rowidcol." = ".((int) $rowid); + $sql .= " WHERE ".$rowidcol." = ".((int) $rowid); } if (in_array('entity', $listfieldmodify)) $sql .= " AND entity = '".getEntity($tabname[$id])."'"; diff --git a/htdocs/admin/ecm_directories_extrafields.php b/htdocs/admin/ecm_directories_extrafields.php index da1fcdbfae5..3179c01960c 100644 --- a/htdocs/admin/ecm_directories_extrafields.php +++ b/htdocs/admin/ecm_directories_extrafields.php @@ -84,7 +84,7 @@ print dol_get_fiche_head($head, 'attributes_ecm_directories', $langs->trans("ECM require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php'; -dol_fiche_end(); +print dol_get_fiche_end(); // Buttons diff --git a/htdocs/admin/ecm_files_extrafields.php b/htdocs/admin/ecm_files_extrafields.php index 20c379532b8..9fc297fd37a 100644 --- a/htdocs/admin/ecm_files_extrafields.php +++ b/htdocs/admin/ecm_files_extrafields.php @@ -84,7 +84,7 @@ print dol_get_fiche_head($head, 'attributes_ecm_files', $langs->trans("ECM"), -1 require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php'; -dol_fiche_end(); +print dol_get_fiche_end(); // Buttons diff --git a/htdocs/admin/emailcollector_card.php b/htdocs/admin/emailcollector_card.php index 71b25dde669..7a48883fd55 100644 --- a/htdocs/admin/emailcollector_card.php +++ b/htdocs/admin/emailcollector_card.php @@ -261,7 +261,7 @@ if ($action == 'create') { print ''."\n"; - dol_fiche_end(); + print dol_get_fiche_end(); print '
'; print ''; @@ -295,7 +295,7 @@ if (($id || $ref) && $action == 'edit') print ''; - dol_fiche_end(); + print dol_get_fiche_end(); print '
'; print '   '; @@ -655,7 +655,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print '

'; - dol_fiche_end(); + print dol_get_fiche_end(); // Buttons for actions if ($action != 'presend' && $action != 'editline') { diff --git a/htdocs/admin/events.php b/htdocs/admin/events.php index 37e19acc13b..b75606f739c 100644 --- a/htdocs/admin/events.php +++ b/htdocs/admin/events.php @@ -125,7 +125,7 @@ foreach ($eventstolog as $key => $arr) } print ''; -dol_fiche_end(); +print dol_get_fiche_end(); print '
'; print "trans("Save")."\">"; diff --git a/htdocs/admin/expedition_extrafields.php b/htdocs/admin/expedition_extrafields.php index bd46148175a..901caf58c00 100644 --- a/htdocs/admin/expedition_extrafields.php +++ b/htdocs/admin/expedition_extrafields.php @@ -80,7 +80,7 @@ print dol_get_fiche_head($head, 'attributes_shipment', $langs->trans("Sendings") require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php'; -dol_fiche_end(); +print dol_get_fiche_end(); // Buttons diff --git a/htdocs/admin/expeditiondet_extrafields.php b/htdocs/admin/expeditiondet_extrafields.php index 669b4c56a64..a61581ce18a 100644 --- a/htdocs/admin/expeditiondet_extrafields.php +++ b/htdocs/admin/expeditiondet_extrafields.php @@ -81,7 +81,7 @@ print dol_get_fiche_head($head, 'attributeslines_shipment', $langs->trans("Sendi require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php'; -dol_fiche_end(); +print dol_get_fiche_end(); // Buttons diff --git a/htdocs/admin/expensereport.php b/htdocs/admin/expensereport.php index 2466fbe7cab..fb2782d3aa7 100644 --- a/htdocs/admin/expensereport.php +++ b/htdocs/admin/expensereport.php @@ -480,7 +480,7 @@ print '
'; print ''; -dol_fiche_end(); +print dol_get_fiche_end(); // End of page llxFooter(); diff --git a/htdocs/admin/expensereport_extrafields.php b/htdocs/admin/expensereport_extrafields.php index 51b82e64d4f..ac88ec78912 100644 --- a/htdocs/admin/expensereport_extrafields.php +++ b/htdocs/admin/expensereport_extrafields.php @@ -74,7 +74,7 @@ print dol_get_fiche_head($head, 'attributes', $langs->trans("ExpenseReports"), - require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php'; -dol_fiche_end(); +print dol_get_fiche_end(); // Buttons diff --git a/htdocs/admin/expensereport_ik.php b/htdocs/admin/expensereport_ik.php index f798aaf2c60..2e00d0d8ff9 100644 --- a/htdocs/admin/expensereport_ik.php +++ b/htdocs/admin/expensereport_ik.php @@ -180,7 +180,7 @@ foreach ($rangesbycateg as $fk_c_exp_tax_cat => $Tab) echo ''; echo ''; -dol_fiche_end(); +print dol_get_fiche_end(); // End of page llxFooter(); diff --git a/htdocs/admin/expensereport_rules.php b/htdocs/admin/expensereport_rules.php index 52f690801cc..9a4bf2804b2 100644 --- a/htdocs/admin/expensereport_rules.php +++ b/htdocs/admin/expensereport_rules.php @@ -338,7 +338,7 @@ echo ''; -dol_fiche_end(); +print dol_get_fiche_end(); // End of page llxFooter(); diff --git a/htdocs/admin/export.php b/htdocs/admin/export.php index bf1a514df90..5dd541b34b5 100644 --- a/htdocs/admin/export.php +++ b/htdocs/admin/export.php @@ -103,7 +103,7 @@ print ''; print ''; -dol_fiche_end(); +print dol_get_fiche_end(); // End of page llxFooter(); diff --git a/htdocs/admin/facture.php b/htdocs/admin/facture.php index ff3953822f4..35dd1002b12 100644 --- a/htdocs/admin/facture.php +++ b/htdocs/admin/facture.php @@ -802,7 +802,7 @@ print ''; print "
\n"; -dol_fiche_end(); +print dol_get_fiche_end(); // End of page llxFooter(); diff --git a/htdocs/admin/facture_situation.php b/htdocs/admin/facture_situation.php index e4f87bbd4be..7ef9e216ad9 100644 --- a/htdocs/admin/facture_situation.php +++ b/htdocs/admin/facture_situation.php @@ -140,7 +140,7 @@ _updateBtn(); print ''; -dol_fiche_end(); +print dol_get_fiche_end(); // End of page llxFooter(); diff --git a/htdocs/admin/holiday.php b/htdocs/admin/holiday.php index 87319d7b5dd..44b7034064b 100644 --- a/htdocs/admin/holiday.php +++ b/htdocs/admin/holiday.php @@ -282,7 +282,7 @@ print '
'; if ($conf->global->MAIN_FEATURES_LEVEL < 2) { - dol_fiche_end(); + print dol_get_fiche_end(); // End of page llxFooter(); $db->close(); @@ -501,7 +501,7 @@ print ''; -dol_fiche_end(); +print dol_get_fiche_end(); // End of page llxFooter(); diff --git a/htdocs/admin/holiday_extrafields.php b/htdocs/admin/holiday_extrafields.php index 4c7ef209e21..1205b592e5f 100644 --- a/htdocs/admin/holiday_extrafields.php +++ b/htdocs/admin/holiday_extrafields.php @@ -74,7 +74,7 @@ print dol_get_fiche_head($head, 'attributes', $langs->trans("Holidays"), -1, 'ho require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php'; -dol_fiche_end(); +print dol_get_fiche_end(); // Buttons diff --git a/htdocs/admin/import.php b/htdocs/admin/import.php index 598bab92c10..e70d8eadbba 100644 --- a/htdocs/admin/import.php +++ b/htdocs/admin/import.php @@ -93,7 +93,7 @@ print ''; print ''; -dol_fiche_end(); +print dol_get_fiche_end(); // End of page llxFooter(); diff --git a/htdocs/admin/ldap.php b/htdocs/admin/ldap.php index 8bab5c4e968..b8c207644c6 100644 --- a/htdocs/admin/ldap.php +++ b/htdocs/admin/ldap.php @@ -251,7 +251,7 @@ print ''.$langs->trans('Password').' (ex: secret)'; print ''; -dol_fiche_end(); +print dol_get_fiche_end(); print '
'; diff --git a/htdocs/admin/ldap_contacts.php b/htdocs/admin/ldap_contacts.php index 8923bb26d20..b29fa00e49e 100644 --- a/htdocs/admin/ldap_contacts.php +++ b/htdocs/admin/ldap_contacts.php @@ -246,7 +246,7 @@ print ''; print info_admin($langs->trans("LDAPDescValues")); -dol_fiche_end(); +print dol_get_fiche_end(); print '
'; diff --git a/htdocs/admin/ldap_groups.php b/htdocs/admin/ldap_groups.php index 9a3aa4c706a..9de9c195f8f 100644 --- a/htdocs/admin/ldap_groups.php +++ b/htdocs/admin/ldap_groups.php @@ -180,7 +180,7 @@ print ''; print info_admin($langs->trans("LDAPDescValues")); -dol_fiche_end(); +print dol_get_fiche_end(); print '
'; diff --git a/htdocs/admin/ldap_members.php b/htdocs/admin/ldap_members.php index 3bcd6c27dbc..214a4f2cb9b 100644 --- a/htdocs/admin/ldap_members.php +++ b/htdocs/admin/ldap_members.php @@ -366,7 +366,7 @@ print ''; print info_admin($langs->trans("LDAPDescValues")); -dol_fiche_end(); +print dol_get_fiche_end(); print '
'; diff --git a/htdocs/admin/ldap_members_types.php b/htdocs/admin/ldap_members_types.php index 3641947d6d1..489e6047f9b 100644 --- a/htdocs/admin/ldap_members_types.php +++ b/htdocs/admin/ldap_members_types.php @@ -162,7 +162,7 @@ print ''; print info_admin($langs->trans("LDAPDescValues")); -dol_fiche_end(); +print dol_get_fiche_end(); print '
'; diff --git a/htdocs/admin/ldap_users.php b/htdocs/admin/ldap_users.php index a46c98645e1..efb34cca413 100644 --- a/htdocs/admin/ldap_users.php +++ b/htdocs/admin/ldap_users.php @@ -336,7 +336,7 @@ print ''; print info_admin($langs->trans("LDAPDescValues")); -dol_fiche_end(); +print dol_get_fiche_end(); print '
'; diff --git a/htdocs/admin/limits.php b/htdocs/admin/limits.php index 89d0c58e4df..82e28f3cf73 100644 --- a/htdocs/admin/limits.php +++ b/htdocs/admin/limits.php @@ -201,7 +201,7 @@ if (!empty($conf->multicurrency->enabled) && !empty($conf->global->MULTICURRENCY { if (!empty($aCurrencies) && count($aCurrencies) > 1) { - dol_fiche_end(); + print dol_get_fiche_end(); } } diff --git a/htdocs/admin/mailman.php b/htdocs/admin/mailman.php index 977d27c0866..58e904f02ce 100644 --- a/htdocs/admin/mailman.php +++ b/htdocs/admin/mailman.php @@ -198,7 +198,7 @@ if (!empty($conf->global->ADHERENT_USE_MAILMAN)) print '*'.$langs->trans("FollowingConstantsWillBeSubstituted").'
'; print '%LISTE%, %MAILMAN_ADMINPW%, %EMAIL%
'; - dol_fiche_end(); + print dol_get_fiche_end(); print '
'; @@ -212,7 +212,7 @@ if (!empty($conf->global->ADHERENT_USE_MAILMAN)) $link .= '
'; print load_fiche_titre($langs->trans('MailmanTitle'), $link, ''); - dol_fiche_end(); + print dol_get_fiche_end(); } diff --git a/htdocs/admin/mails.php b/htdocs/admin/mails.php index 17846b05452..cc81c78255d 100644 --- a/htdocs/admin/mails.php +++ b/htdocs/admin/mails.php @@ -506,7 +506,7 @@ if ($action == 'edit') print ''; - dol_fiche_end(); + print dol_get_fiche_end(); print '
'; print ''; @@ -529,211 +529,215 @@ if ($action == 'edit') if (!empty($conf->global->MAIN_DISABLE_ALL_MAILS)) print img_warning($langs->trans("Disabled")); print ''; - // Force e-mail recipient - print ''.$langs->trans("MAIN_MAIL_FORCE_SENDTO").''.$conf->global->MAIN_MAIL_FORCE_SENDTO; - if (!empty($conf->global->MAIN_MAIL_FORCE_SENDTO)) - { - if (!isValidEmail($conf->global->MAIN_MAIL_FORCE_SENDTO)) print img_warning($langs->trans("ErrorBadEMail")); - else print img_warning($langs->trans("RecipientEmailsWillBeReplacedWithThisValue")); + if (empty($conf->global->MAIN_DISABLE_ALL_MAILS)) { + // Force e-mail recipient + print ''.$langs->trans("MAIN_MAIL_FORCE_SENDTO").''.$conf->global->MAIN_MAIL_FORCE_SENDTO; + if (!empty($conf->global->MAIN_MAIL_FORCE_SENDTO)) + { + if (!isValidEmail($conf->global->MAIN_MAIL_FORCE_SENDTO)) print img_warning($langs->trans("ErrorBadEMail")); + else print img_warning($langs->trans("RecipientEmailsWillBeReplacedWithThisValue")); + } + print ''; } - print ''; print ''; - print '
'; + if (empty($conf->global->MAIN_DISABLE_ALL_MAILS)) { + print '
'; - print ''; - print ''; + print '
'.$langs->trans("MAIN_MAIL_SENDMODE").'
'; + print ''; - // Method - print ''; + print ''; - // Host server - if ($linuxlike && (isset($conf->global->MAIN_MAIL_SENDMODE) && $conf->global->MAIN_MAIL_SENDMODE == 'mail')) - { - print ''; - } else { - print ''; - } - - // Port - if ($linuxlike && (isset($conf->global->MAIN_MAIL_SENDMODE) && $conf->global->MAIN_MAIL_SENDMODE == 'mail')) - { - print ''; - } else { - print ''; - } - - // SMTPS ID - if (isset($conf->global->MAIN_MAIL_SENDMODE) && in_array($conf->global->MAIN_MAIL_SENDMODE, array('smtps', 'swiftmailer'))) - { - print ''; - } - - // SMTPS PW - if (isset($conf->global->MAIN_MAIL_SENDMODE) && in_array($conf->global->MAIN_MAIL_SENDMODE, array('smtps', 'swiftmailer'))) - { - print ''; - } - - // TLS - print ''; + print ''; + } else { + print ''; + } - // STARTTLS - print ''; + print ''; + } else { + print ''; + } - // SMTP_ALLOW_SELF_SIGNED - print ''; + print ''; + } + // SMTPS PW + if (isset($conf->global->MAIN_MAIL_SENDMODE) && in_array($conf->global->MAIN_MAIL_SENDMODE, array('smtps', 'swiftmailer'))) + { + print ''; + } - if ($conf->global->MAIN_MAIL_SENDMODE == 'swiftmailer') - { - // DKIM - print ''; - // Domain - print ''; - print ''; - - // Selector - print ''; - print ''; - - // PRIVATE KEY - print ''; - print ''; - } - - print '
'.$langs->trans("MAIN_MAIL_SENDMODE").'
'.$langs->trans("MAIN_MAIL_SENDMODE").''; - $text = $listofmethods[$conf->global->MAIN_MAIL_SENDMODE]; - if (empty($text)) $text = $langs->trans("Undefined").img_warning(); - print $text; + // Method + print '
'.$langs->trans("MAIN_MAIL_SENDMODE").''; + $text = $listofmethods[$conf->global->MAIN_MAIL_SENDMODE]; + if (empty($text)) $text = $langs->trans("Undefined").img_warning(); + print $text; - if ($conf->global->MAIN_MAIL_SENDMODE == 'mail' && empty($conf->global->MAIN_HIDE_WARNING_TO_ENCOURAGE_SMTP_SETUP)) { - print $form->textwithpicto('', $langs->trans("WarningPHPMail").'
'.$langs->trans("WarningPHPMailA").'
'.$langs->trans("WarningPHPMailB").'
'.$langs->trans("WarningPHPMailC").'

'.$langs->trans("WarningPHPMailD"), 1, 'warning'); - } + if ($conf->global->MAIN_MAIL_SENDMODE == 'mail' && empty($conf->global->MAIN_HIDE_WARNING_TO_ENCOURAGE_SMTP_SETUP)) { + print $form->textwithpicto('', $langs->trans("WarningPHPMail").'
'.$langs->trans("WarningPHPMailA").'
'.$langs->trans("WarningPHPMailB").'
'.$langs->trans("WarningPHPMailC").'

'.$langs->trans("WarningPHPMailD"), 1, 'warning'); + } - print '
'.$langs->trans("MAIN_MAIL_SMTP_SERVER_NotAvailableOnLinuxLike").''.$langs->trans("SeeLocalSendMailSetup").'
'.$langs->trans("MAIN_MAIL_SMTP_SERVER", ini_get('SMTP') ?ini_get('SMTP') : $langs->transnoentities("Undefined")).''.(!empty($conf->global->MAIN_MAIL_SMTP_SERVER) ? $conf->global->MAIN_MAIL_SMTP_SERVER : '').'
'.$langs->trans("MAIN_MAIL_SMTP_PORT_NotAvailableOnLinuxLike").''.$langs->trans("SeeLocalSendMailSetup").'
'.$langs->trans("MAIN_MAIL_SMTP_PORT", ini_get('smtp_port') ?ini_get('smtp_port') : $langs->transnoentities("Undefined")).''.(!empty($conf->global->MAIN_MAIL_SMTP_PORT) ? $conf->global->MAIN_MAIL_SMTP_PORT : '').'
'.$langs->trans("MAIN_MAIL_SMTPS_ID").''.$conf->global->MAIN_MAIL_SMTPS_ID.'
'.$langs->trans("MAIN_MAIL_SMTPS_PW").''.preg_replace('/./', '*', $conf->global->MAIN_MAIL_SMTPS_PW).'
'.$langs->trans("MAIN_MAIL_EMAIL_TLS").''; - if (isset($conf->global->MAIN_MAIL_SENDMODE) && in_array($conf->global->MAIN_MAIL_SENDMODE, array('smtps', 'swiftmailer'))) - { - if (function_exists('openssl_open')) + // Host server + if ($linuxlike && (isset($conf->global->MAIN_MAIL_SENDMODE) && $conf->global->MAIN_MAIL_SENDMODE == 'mail')) { - print yn($conf->global->MAIN_MAIL_EMAIL_TLS); - } else print yn(0).' ('.$langs->trans("YourPHPDoesNotHaveSSLSupport").')'; - } else print ''.yn(0).' ('.$langs->trans("NotSupported").')'; - print '
'.$langs->trans("MAIN_MAIL_SMTP_SERVER_NotAvailableOnLinuxLike").''.$langs->trans("SeeLocalSendMailSetup").'
'.$langs->trans("MAIN_MAIL_SMTP_SERVER", ini_get('SMTP') ?ini_get('SMTP') : $langs->transnoentities("Undefined")).''.(!empty($conf->global->MAIN_MAIL_SMTP_SERVER) ? $conf->global->MAIN_MAIL_SMTP_SERVER : '').'
'.$langs->trans("MAIN_MAIL_EMAIL_STARTTLS").''; - if (isset($conf->global->MAIN_MAIL_SENDMODE) && in_array($conf->global->MAIN_MAIL_SENDMODE, array('smtps', 'swiftmailer'))) - { - if (function_exists('openssl_open')) + // Port + if ($linuxlike && (isset($conf->global->MAIN_MAIL_SENDMODE) && $conf->global->MAIN_MAIL_SENDMODE == 'mail')) { - print yn($conf->global->MAIN_MAIL_EMAIL_STARTTLS); - } else print yn(0).' ('.$langs->trans("YourPHPDoesNotHaveSSLSupport").')'; - } else print ''.yn(0).' ('.$langs->trans("NotSupported").')'; - print '
'.$langs->trans("MAIN_MAIL_SMTP_PORT_NotAvailableOnLinuxLike").''.$langs->trans("SeeLocalSendMailSetup").'
'.$langs->trans("MAIN_MAIL_SMTP_PORT", ini_get('smtp_port') ?ini_get('smtp_port') : $langs->transnoentities("Undefined")).''.(!empty($conf->global->MAIN_MAIL_SMTP_PORT) ? $conf->global->MAIN_MAIL_SMTP_PORT : '').'
'.$langs->trans("MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED").''; - if (isset($conf->global->MAIN_MAIL_SENDMODE) && in_array($conf->global->MAIN_MAIL_SENDMODE, array('smtps', 'swiftmailer'))) - { - if (function_exists('openssl_open')) + // SMTPS ID + if (isset($conf->global->MAIN_MAIL_SENDMODE) && in_array($conf->global->MAIN_MAIL_SENDMODE, array('smtps', 'swiftmailer'))) { - print yn($conf->global->MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED); - } else print yn(0).' ('.$langs->trans("YourPHPDoesNotHaveSSLSupport").')'; - } else print ''.yn(0).' ('.$langs->trans("NotSupported").')'; - print '
'.$langs->trans("MAIN_MAIL_SMTPS_ID").''.$conf->global->MAIN_MAIL_SMTPS_ID.'
'.$langs->trans("MAIN_MAIL_SMTPS_PW").''.preg_replace('/./', '*', $conf->global->MAIN_MAIL_SMTPS_PW).'
'.$langs->trans("MAIN_MAIL_EMAIL_DKIM_ENABLED").''; - if (isset($conf->global->MAIN_MAIL_SENDMODE) && in_array($conf->global->MAIN_MAIL_SENDMODE, array('swiftmailer'))) + // TLS + print '
'.$langs->trans("MAIN_MAIL_EMAIL_TLS").''; + if (isset($conf->global->MAIN_MAIL_SENDMODE) && in_array($conf->global->MAIN_MAIL_SENDMODE, array('smtps', 'swiftmailer'))) { if (function_exists('openssl_open')) { - print yn($conf->global->MAIN_MAIL_EMAIL_DKIM_ENABLED); + print yn($conf->global->MAIN_MAIL_EMAIL_TLS); } else print yn(0).' ('.$langs->trans("YourPHPDoesNotHaveSSLSupport").')'; - } else print yn(0).' ('.$langs->trans("NotSupported").')'; + } else print ''.yn(0).' ('.$langs->trans("NotSupported").')'; print '
'.$langs->trans("MAIN_MAIL_EMAIL_DKIM_DOMAIN").''.$conf->global->MAIN_MAIL_EMAIL_DKIM_DOMAIN; - print '
'.$langs->trans("MAIN_MAIL_EMAIL_DKIM_SELECTOR").''.$conf->global->MAIN_MAIL_EMAIL_DKIM_SELECTOR; - print '
'.$langs->trans("MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY").''.$conf->global->MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY; - print '
'; - - if ($conf->global->MAIN_MAIL_SENDMODE == 'mail' && empty($conf->global->MAIN_HIDE_WARNING_TO_ENCOURAGE_SMTP_SETUP)) { - print info_admin($langs->trans("WarningPHPMail").'
'.$langs->trans("WarningPHPMailA").'
'.$langs->trans("WarningPHPMailB").'
'.$langs->trans("WarningPHPMailC").'

'.$langs->trans("WarningPHPMailD"), 0, 0, 'warning'); - } - - print '
'; - - print ''; - print ''; - - // From - print ''; - print ''; - - // Default from type - $liste = array(); - $liste['user'] = $langs->trans('UserEmail'); - $liste['company'] = $langs->trans('CompanyEmail').' ('.(empty($conf->global->MAIN_INFO_SOCIETE_MAIL) ? $langs->trans("NotDefined") : $conf->global->MAIN_INFO_SOCIETE_MAIL).')'; - $sql = 'SELECT rowid, label, email FROM '.MAIN_DB_PREFIX.'c_email_senderprofile'; - $sql .= ' WHERE active = 1 AND (private = 0 OR private = '.$user->id.')'; - $resql = $db->query($sql); - if ($resql) - { - $num = $db->num_rows($resql); - $i = 0; - while ($i < $num) + // STARTTLS + print ''; - print ''; - print ''; + + + if ($conf->global->MAIN_MAIL_SENDMODE == 'swiftmailer') + { + // DKIM + print ''; + + // Domain + print ''; + print ''; + + // Selector + print ''; + print ''; + + // PRIVATE KEY + print ''; + print ''; } + + print '
'.$langs->trans("OtherOptions").'
'.$langs->trans("MAIN_MAIL_EMAIL_FROM", ini_get('sendmail_from') ?ini_get('sendmail_from') : $langs->transnoentities("Undefined")).''.$conf->global->MAIN_MAIL_EMAIL_FROM; - if (!empty($conf->global->MAIN_MAIL_EMAIL_FROM) && !isValidEmail($conf->global->MAIN_MAIL_EMAIL_FROM)) print img_warning($langs->trans("ErrorBadEMail")); - print '
'.$langs->trans("MAIN_MAIL_EMAIL_STARTTLS").''; + if (isset($conf->global->MAIN_MAIL_SENDMODE) && in_array($conf->global->MAIN_MAIL_SENDMODE, array('smtps', 'swiftmailer'))) { - $obj = $db->fetch_object($resql); - if ($obj) + if (function_exists('openssl_open')) { - $liste['senderprofile_'.$obj->rowid] = $obj->label.' <'.$obj->email.'>'; - } - $i++; - } - } else dol_print_error($db); + print yn($conf->global->MAIN_MAIL_EMAIL_STARTTLS); + } else print yn(0).' ('.$langs->trans("YourPHPDoesNotHaveSSLSupport").')'; + } else print ''.yn(0).' ('.$langs->trans("NotSupported").')'; + print '
'.$langs->trans('MAIN_MAIL_DEFAULT_FROMTYPE').''; - if ($conf->global->MAIN_MAIL_DEFAULT_FROMTYPE === 'robot') - { - print $langs->trans('RobotEmail'); - } elseif ($conf->global->MAIN_MAIL_DEFAULT_FROMTYPE === 'user') - { - print $langs->trans('UserEmail'); - } elseif ($conf->global->MAIN_MAIL_DEFAULT_FROMTYPE === 'company') - { - print $langs->trans('CompanyEmail').' '.dol_escape_htmltag('<'.$mysoc->email.'>'); - } else { - $id = preg_replace('/senderprofile_/', '', $conf->global->MAIN_MAIL_DEFAULT_FROMTYPE); - if ($id > 0) + // SMTP_ALLOW_SELF_SIGNED + print '
'.$langs->trans("MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED").''; + if (isset($conf->global->MAIN_MAIL_SENDMODE) && in_array($conf->global->MAIN_MAIL_SENDMODE, array('smtps', 'swiftmailer'))) { - include_once DOL_DOCUMENT_ROOT.'/core/class/emailsenderprofile.class.php'; - $emailsenderprofile = new EmailSenderProfile($db); - $emailsenderprofile->fetch($id); - print $emailsenderprofile->label.' '.dol_escape_htmltag('<'.$emailsenderprofile->email.'>'); + if (function_exists('openssl_open')) + { + print yn($conf->global->MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED); + } else print yn(0).' ('.$langs->trans("YourPHPDoesNotHaveSSLSupport").')'; + } else print ''.yn(0).' ('.$langs->trans("NotSupported").')'; + print '
'.$langs->trans("MAIN_MAIL_EMAIL_DKIM_ENABLED").''; + if (isset($conf->global->MAIN_MAIL_SENDMODE) && in_array($conf->global->MAIN_MAIL_SENDMODE, array('swiftmailer'))) + { + if (function_exists('openssl_open')) + { + print yn($conf->global->MAIN_MAIL_EMAIL_DKIM_ENABLED); + } else print yn(0).' ('.$langs->trans("YourPHPDoesNotHaveSSLSupport").')'; + } else print yn(0).' ('.$langs->trans("NotSupported").')'; + print '
'.$langs->trans("MAIN_MAIL_EMAIL_DKIM_DOMAIN").''.$conf->global->MAIN_MAIL_EMAIL_DKIM_DOMAIN; + print '
'.$langs->trans("MAIN_MAIL_EMAIL_DKIM_SELECTOR").''.$conf->global->MAIN_MAIL_EMAIL_DKIM_SELECTOR; + print '
'.$langs->trans("MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY").''.$conf->global->MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY; + print '
'; + + if ($conf->global->MAIN_MAIL_SENDMODE == 'mail' && empty($conf->global->MAIN_HIDE_WARNING_TO_ENCOURAGE_SMTP_SETUP)) { + print info_admin($langs->trans("WarningPHPMail").'
'.$langs->trans("WarningPHPMailA").'
'.$langs->trans("WarningPHPMailB").'
'.$langs->trans("WarningPHPMailC").'

'.$langs->trans("WarningPHPMailD"), 0, 0, 'warning'); + } + + print '
'; + + print ''; + print ''; + + // From + print ''; + print ''; + + // Default from type + $liste = array(); + $liste['user'] = $langs->trans('UserEmail'); + $liste['company'] = $langs->trans('CompanyEmail').' ('.(empty($conf->global->MAIN_INFO_SOCIETE_MAIL) ? $langs->trans("NotDefined") : $conf->global->MAIN_INFO_SOCIETE_MAIL).')'; + $sql = 'SELECT rowid, label, email FROM '.MAIN_DB_PREFIX.'c_email_senderprofile'; + $sql .= ' WHERE active = 1 AND (private = 0 OR private = '.$user->id.')'; + $resql = $db->query($sql); + if ($resql) + { + $num = $db->num_rows($resql); + $i = 0; + while ($i < $num) + { + $obj = $db->fetch_object($resql); + if ($obj) + { + $liste['senderprofile_'.$obj->rowid] = $obj->label.' <'.$obj->email.'>'; + } + $i++; + } + } else dol_print_error($db); + + print ''; + print ''; + + // Errors To + print ''; + print ''; + + // Autocopy to + print ''; + print ''; + + //Add user to select destinaries list + print ''; + + print '
'.$langs->trans("OtherOptions").'
'.$langs->trans("MAIN_MAIL_EMAIL_FROM", ini_get('sendmail_from') ?ini_get('sendmail_from') : $langs->transnoentities("Undefined")).''.$conf->global->MAIN_MAIL_EMAIL_FROM; + if (!empty($conf->global->MAIN_MAIL_EMAIL_FROM) && !isValidEmail($conf->global->MAIN_MAIL_EMAIL_FROM)) print img_warning($langs->trans("ErrorBadEMail")); + print '
'.$langs->trans('MAIN_MAIL_DEFAULT_FROMTYPE').''; + if ($conf->global->MAIN_MAIL_DEFAULT_FROMTYPE === 'robot') + { + print $langs->trans('RobotEmail'); + } elseif ($conf->global->MAIN_MAIL_DEFAULT_FROMTYPE === 'user') + { + print $langs->trans('UserEmail'); + } elseif ($conf->global->MAIN_MAIL_DEFAULT_FROMTYPE === 'company') + { + print $langs->trans('CompanyEmail').' '.dol_escape_htmltag('<'.$mysoc->email.'>'); + } else { + $id = preg_replace('/senderprofile_/', '', $conf->global->MAIN_MAIL_DEFAULT_FROMTYPE); + if ($id > 0) + { + include_once DOL_DOCUMENT_ROOT.'/core/class/emailsenderprofile.class.php'; + $emailsenderprofile = new EmailSenderProfile($db); + $emailsenderprofile->fetch($id); + print $emailsenderprofile->label.' '.dol_escape_htmltag('<'.$emailsenderprofile->email.'>'); + } + } + print '
'.$langs->trans("MAIN_MAIL_ERRORS_TO").''.$conf->global->MAIN_MAIL_ERRORS_TO; + if (!empty($conf->global->MAIN_MAIL_ERRORS_TO) && !isValidEmail($conf->global->MAIN_MAIL_ERRORS_TO)) print img_warning($langs->trans("ErrorBadEMail")); + print '
'.$langs->trans("MAIN_MAIL_AUTOCOPY_TO").''; + if (!empty($conf->global->MAIN_MAIL_AUTOCOPY_TO)) + { + print $conf->global->MAIN_MAIL_AUTOCOPY_TO; + if (!isValidEmail($conf->global->MAIN_MAIL_AUTOCOPY_TO)) print img_warning($langs->trans("ErrorBadEMail")); + } else { + print ' '; + } + print '
'.$langs->trans("MAIN_MAIL_ENABLED_USER_DEST_SELECT").''.yn($conf->global->MAIN_MAIL_ENABLED_USER_DEST_SELECT).'
'; } - print ''; - // Errors To - print ''.$langs->trans("MAIN_MAIL_ERRORS_TO").''; - print ''.$conf->global->MAIN_MAIL_ERRORS_TO; - if (!empty($conf->global->MAIN_MAIL_ERRORS_TO) && !isValidEmail($conf->global->MAIN_MAIL_ERRORS_TO)) print img_warning($langs->trans("ErrorBadEMail")); - print ''; - - // Autocopy to - print ''.$langs->trans("MAIN_MAIL_AUTOCOPY_TO").''; - print ''; - if (!empty($conf->global->MAIN_MAIL_AUTOCOPY_TO)) - { - print $conf->global->MAIN_MAIL_AUTOCOPY_TO; - if (!isValidEmail($conf->global->MAIN_MAIL_AUTOCOPY_TO)) print img_warning($langs->trans("ErrorBadEMail")); - } else { - print ' '; - } - print ''; - - //Add user to select destinaries list - print ''.$langs->trans("MAIN_MAIL_ENABLED_USER_DEST_SELECT").''.yn($conf->global->MAIN_MAIL_ENABLED_USER_DEST_SELECT).''; - - print ''; - - dol_fiche_end(); + print dol_get_fiche_end(); // Actions button @@ -741,21 +745,23 @@ if ($action == 'edit') print ''.$langs->trans("Modify").''; - if ($conf->global->MAIN_MAIL_SENDMODE != 'mail' || !$linuxlike) - { - if (function_exists('fsockopen') && $port && $server) + if (empty($conf->global->MAIN_DISABLE_ALL_MAILS)) { + if ($conf->global->MAIN_MAIL_SENDMODE != 'mail' || !$linuxlike) { - print ''.$langs->trans("DoTestServerAvailability").''; + if (function_exists('fsockopen') && $port && $server) + { + print ''.$langs->trans("DoTestServerAvailability").''; + } + } else { + print ''.$langs->trans("DoTestServerAvailability").''; } - } else { - print ''.$langs->trans("DoTestServerAvailability").''; - } - print ''.$langs->trans("DoTestSend").''; + print ''.$langs->trans("DoTestSend").''; - if (!empty($conf->fckeditor->enabled)) - { - print ''.$langs->trans("DoTestSendHTML").''; + if (!empty($conf->fckeditor->enabled)) + { + print ''.$langs->trans("DoTestSendHTML").''; + } } print '
'; @@ -886,7 +892,7 @@ if ($action == 'edit') print $formmail->get_form('addfile', 'removefile'); - dol_fiche_end(); + print dol_get_fiche_end(); // References print ''.$langs->trans("EMailsWillHaveMessageID").': '; diff --git a/htdocs/admin/mails_emailing.php b/htdocs/admin/mails_emailing.php index ebc3201dcdf..a464c0fca8e 100644 --- a/htdocs/admin/mails_emailing.php +++ b/htdocs/admin/mails_emailing.php @@ -384,7 +384,7 @@ if ($action == 'edit') print ''; - dol_fiche_end(); + print dol_get_fiche_end(); print '
'; print ''; @@ -475,7 +475,7 @@ if ($action == 'edit') print ''; - dol_fiche_end(); + print dol_get_fiche_end(); if ($conf->global->MAIN_MAIL_SENDMODE_EMAILING == 'mail' && empty($conf->global->MAIN_FIX_FOR_BUGGED_MTA)) @@ -599,7 +599,7 @@ if ($action == 'edit') print $formmail->get_form('addfile', 'removefile'); - dol_fiche_end(); + print dol_get_fiche_end(); } } diff --git a/htdocs/admin/mails_senderprofile_list.php b/htdocs/admin/mails_senderprofile_list.php index 6f80706276e..4556ec80bff 100644 --- a/htdocs/admin/mails_senderprofile_list.php +++ b/htdocs/admin/mails_senderprofile_list.php @@ -645,7 +645,7 @@ if (in_array('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $n print $formfile->showdocuments('massfilesarea_emailsenderprofile', '', $filedir, $urlsource, 0, $delallowed, '', 1, 1, 0, 48, 1, $param, $title, '', '', '', null, $hidegeneratedfilelistifempty); } -dol_fiche_end(); +print dol_get_fiche_end(); // End of page llxFooter(); diff --git a/htdocs/admin/mails_templates.php b/htdocs/admin/mails_templates.php index 4dfdc413af5..8cbd9675160 100644 --- a/htdocs/admin/mails_templates.php +++ b/htdocs/admin/mails_templates.php @@ -953,7 +953,7 @@ print '
'; print ''; -dol_fiche_end(); +print dol_get_fiche_end(); // End of page llxFooter(); diff --git a/htdocs/admin/mails_ticket.php b/htdocs/admin/mails_ticket.php index 0be41dce273..e0a42ee3a2d 100644 --- a/htdocs/admin/mails_ticket.php +++ b/htdocs/admin/mails_ticket.php @@ -361,7 +361,7 @@ if ($action == 'edit') print ''; - dol_fiche_end(); + print dol_get_fiche_end(); print '
'; print ''; @@ -441,7 +441,7 @@ if ($action == 'edit') print ''; - dol_fiche_end(); + print dol_get_fiche_end(); if ($conf->global->MAIN_MAIL_SENDMODE_TICKET == 'mail' && empty($conf->global->MAIN_FIX_FOR_BUGGED_MTA)) @@ -565,7 +565,7 @@ if ($action == 'edit') print $formmail->get_form('addfile', 'removefile'); - dol_fiche_end(); + print dol_get_fiche_end(); } } diff --git a/htdocs/admin/menus.php b/htdocs/admin/menus.php index a62385bf2ca..9bdc497c776 100644 --- a/htdocs/admin/menus.php +++ b/htdocs/admin/menus.php @@ -206,7 +206,7 @@ print ''; print ''; -dol_fiche_end(); +print dol_get_fiche_end(); print '
'; print ''; diff --git a/htdocs/admin/menus/edit.php b/htdocs/admin/menus/edit.php index f56bf284fc9..70d2f4bcda6 100644 --- a/htdocs/admin/menus/edit.php +++ b/htdocs/admin/menus/edit.php @@ -398,7 +398,7 @@ if ($action == 'create') print ''; - dol_fiche_end(); + print dol_get_fiche_end(); print '
'; print ''; @@ -507,7 +507,7 @@ if ($action == 'create') print ''; - dol_fiche_end(); + print dol_get_fiche_end(); // Bouton print '
'; diff --git a/htdocs/admin/modulehelp.php b/htdocs/admin/modulehelp.php index 065146489a7..9aec5ef0c29 100644 --- a/htdocs/admin/modulehelp.php +++ b/htdocs/admin/modulehelp.php @@ -554,7 +554,7 @@ if ($mode == 'changelog') print $text; -dol_fiche_end(); +print dol_get_fiche_end(); print '
'; diff --git a/htdocs/admin/modules.php b/htdocs/admin/modules.php index db4a2d85d8e..e281cb21155 100644 --- a/htdocs/admin/modules.php +++ b/htdocs/admin/modules.php @@ -883,7 +883,7 @@ if ($mode == 'common' || $mode == 'commonkanban') } } - dol_fiche_end(); + print dol_get_fiche_end(); print '
'; @@ -916,7 +916,7 @@ if ($mode == 'marketplace') print "\n"; print '
'; - dol_fiche_end(); + print dol_get_fiche_end(); print '
'; @@ -1136,7 +1136,7 @@ if ($mode == 'deploy') } } - dol_fiche_end(); + print dol_get_fiche_end(); } if ($mode == 'develop') @@ -1170,7 +1170,7 @@ if ($mode == 'develop') print "\n"; - dol_fiche_end(); + print dol_get_fiche_end(); } // End of page diff --git a/htdocs/admin/mrp_extrafields.php b/htdocs/admin/mrp_extrafields.php index 4078043c001..e81c7f1cf75 100644 --- a/htdocs/admin/mrp_extrafields.php +++ b/htdocs/admin/mrp_extrafields.php @@ -74,7 +74,7 @@ print dol_get_fiche_head($head, 'mrp_extrafields', $langs->trans("ExtraFields"), require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php'; -dol_fiche_end(); +print dol_get_fiche_end(); // Buttons diff --git a/htdocs/admin/oauth.php b/htdocs/admin/oauth.php index cfd93b195b3..af352558a71 100644 --- a/htdocs/admin/oauth.php +++ b/htdocs/admin/oauth.php @@ -141,7 +141,7 @@ foreach ($list as $key) print ''."\n"; -dol_fiche_end(); +print dol_get_fiche_end(); print '
'; diff --git a/htdocs/admin/oauthlogintokens.php b/htdocs/admin/oauthlogintokens.php index f0fdeb28760..99510f4b7c8 100644 --- a/htdocs/admin/oauthlogintokens.php +++ b/htdocs/admin/oauthlogintokens.php @@ -402,7 +402,7 @@ if ($mode == 'userconf' && $user->admin) print ''; } -dol_fiche_end(); +print dol_get_fiche_end(); // End of page llxFooter(); diff --git a/htdocs/admin/order_extrafields.php b/htdocs/admin/order_extrafields.php index 8435e801902..81d0312ab69 100644 --- a/htdocs/admin/order_extrafields.php +++ b/htdocs/admin/order_extrafields.php @@ -77,7 +77,7 @@ print dol_get_fiche_head($head, 'attributes', $langs->trans("Orders"), -1, 'orde require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php'; -dol_fiche_end(); +print dol_get_fiche_end(); // Buttons diff --git a/htdocs/admin/orderdet_extrafields.php b/htdocs/admin/orderdet_extrafields.php index 3d228baeb57..734d617f564 100644 --- a/htdocs/admin/orderdet_extrafields.php +++ b/htdocs/admin/orderdet_extrafields.php @@ -78,7 +78,7 @@ print dol_get_fiche_head($head, 'attributeslines', $langs->trans("Orders"), -1, require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php'; -dol_fiche_end(); +print dol_get_fiche_end(); // Buttons diff --git a/htdocs/admin/payment.php b/htdocs/admin/payment.php index 35e738754bf..8edf851f49e 100644 --- a/htdocs/admin/payment.php +++ b/htdocs/admin/payment.php @@ -262,7 +262,7 @@ print "\n"; print ''; print '
'; -dol_fiche_end(); +print dol_get_fiche_end(); print '
'; print '
'; diff --git a/htdocs/admin/paymentbybanktransfer.php b/htdocs/admin/paymentbybanktransfer.php index 718e64e6446..6a419d39e53 100644 --- a/htdocs/admin/paymentbybanktransfer.php +++ b/htdocs/admin/paymentbybanktransfer.php @@ -361,7 +361,7 @@ foreach ($dirmodels as $reldir) */ -dol_fiche_end(); +print dol_get_fiche_end(); print '
'; diff --git a/htdocs/admin/perms.php b/htdocs/admin/perms.php index 41b0cc75ab1..3677daa38a5 100644 --- a/htdocs/admin/perms.php +++ b/htdocs/admin/perms.php @@ -260,7 +260,7 @@ if ($result) print ''; print '
'; -dol_fiche_end(); +print dol_get_fiche_end(); // End of page llxFooter(); diff --git a/htdocs/admin/prelevement.php b/htdocs/admin/prelevement.php index 50d01924364..c16b5c30c47 100644 --- a/htdocs/admin/prelevement.php +++ b/htdocs/admin/prelevement.php @@ -368,7 +368,7 @@ foreach ($dirmodels as $reldir) */ -dol_fiche_end(); +print dol_get_fiche_end(); print '
'; diff --git a/htdocs/admin/proxy.php b/htdocs/admin/proxy.php index a9205cb9e5f..71bd50ef5ce 100644 --- a/htdocs/admin/proxy.php +++ b/htdocs/admin/proxy.php @@ -197,7 +197,7 @@ print ''; print ''; -dol_fiche_end(); +print dol_get_fiche_end(); print '
'; print ''; diff --git a/htdocs/admin/receiptprinter.php b/htdocs/admin/receiptprinter.php index 0e3008c57cd..3f66d04ca01 100644 --- a/htdocs/admin/receiptprinter.php +++ b/htdocs/admin/receiptprinter.php @@ -354,7 +354,7 @@ if ($mode == 'config' && $user->admin) { print ''; - dol_fiche_end(); + print dol_get_fiche_end(); print ''; @@ -460,7 +460,7 @@ if ($mode == 'template' && $user->admin) { } print ''; - dol_fiche_end(); + print dol_get_fiche_end(); print '
'; diff --git a/htdocs/admin/reception_extrafields.php b/htdocs/admin/reception_extrafields.php index 27f33be8157..605b8cf465e 100644 --- a/htdocs/admin/reception_extrafields.php +++ b/htdocs/admin/reception_extrafields.php @@ -83,7 +83,7 @@ print dol_get_fiche_head($head, 'attributes_reception', $langs->trans("Reception require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php'; -dol_fiche_end(); +print dol_get_fiche_end(); // Buttons diff --git a/htdocs/admin/resource.php b/htdocs/admin/resource.php index 286e6d15565..ecf72df9b37 100644 --- a/htdocs/admin/resource.php +++ b/htdocs/admin/resource.php @@ -142,7 +142,7 @@ print ''; //RESOURCE_HIDE_ADD_CONTACT_USER //RESOURCE_HIDE_ADD_CONTACT_THIPARTY -dol_fiche_end(); +print dol_get_fiche_end(); // End of page llxFooter(); diff --git a/htdocs/admin/resource_extrafields.php b/htdocs/admin/resource_extrafields.php index d0e2a3e5b0a..d7287b53019 100644 --- a/htdocs/admin/resource_extrafields.php +++ b/htdocs/admin/resource_extrafields.php @@ -77,7 +77,7 @@ print dol_get_fiche_head($head, 'attributes', $langs->trans("ResourceSingular"), require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php'; -dol_fiche_end(); +print dol_get_fiche_end(); // Buttons diff --git a/htdocs/admin/security_file.php b/htdocs/admin/security_file.php index fba88d768c4..fc2c4e141d5 100644 --- a/htdocs/admin/security_file.php +++ b/htdocs/admin/security_file.php @@ -177,7 +177,7 @@ print ''; print ''; print '
'; -dol_fiche_end(); +print dol_get_fiche_end(); print '
'; diff --git a/htdocs/admin/security_other.php b/htdocs/admin/security_other.php index ff0ca0006af..2e4f1f05229 100644 --- a/htdocs/admin/security_other.php +++ b/htdocs/admin/security_other.php @@ -184,7 +184,7 @@ print ''; print ''; -dol_fiche_end(); +print dol_get_fiche_end(); print '
'; diff --git a/htdocs/admin/socialnetworks.php b/htdocs/admin/socialnetworks.php index 3d959b04b83..faf8897126f 100644 --- a/htdocs/admin/socialnetworks.php +++ b/htdocs/admin/socialnetworks.php @@ -108,7 +108,7 @@ foreach ($arrayofsocialnetworks as $snkey => $snlabel) { } -dol_fiche_end(); +print dol_get_fiche_end(); print ''; diff --git a/htdocs/admin/spip.php b/htdocs/admin/spip.php index 772d4e32707..fe98d4bfe9e 100644 --- a/htdocs/admin/spip.php +++ b/htdocs/admin/spip.php @@ -146,7 +146,7 @@ if (!empty($conf->global->ADHERENT_USE_SPIP)) form_constantes($constantes, 2); - dol_fiche_end(); + print dol_get_fiche_end(); print '
'; @@ -160,7 +160,7 @@ if (!empty($conf->global->ADHERENT_USE_SPIP)) $link .= ''; print load_fiche_titre($langs->trans('SPIPTitle'), $link, ''); - dol_fiche_end(); + print dol_get_fiche_end(); } // End of page diff --git a/htdocs/admin/supplier_payment.php b/htdocs/admin/supplier_payment.php index bda90d0ac74..c0c04eb9430 100644 --- a/htdocs/admin/supplier_payment.php +++ b/htdocs/admin/supplier_payment.php @@ -454,7 +454,7 @@ print "\n"; print ''; -dol_fiche_end(); +print dol_get_fiche_end(); print '
'; print '
'; diff --git a/htdocs/admin/supplierinvoice_extrafields.php b/htdocs/admin/supplierinvoice_extrafields.php index 10de9a09735..d84779c7477 100644 --- a/htdocs/admin/supplierinvoice_extrafields.php +++ b/htdocs/admin/supplierinvoice_extrafields.php @@ -78,7 +78,7 @@ print dol_get_fiche_head($head, 'supplierinvoice', $langs->trans("Suppliers"), - require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php'; -dol_fiche_end(); +print dol_get_fiche_end(); // Buttons diff --git a/htdocs/admin/supplierinvoicedet_extrafields.php b/htdocs/admin/supplierinvoicedet_extrafields.php index 576e3f7b3b3..ac40ef66e09 100644 --- a/htdocs/admin/supplierinvoicedet_extrafields.php +++ b/htdocs/admin/supplierinvoicedet_extrafields.php @@ -80,7 +80,7 @@ print dol_get_fiche_head($head, 'supplierinvoicedet', $langs->trans("Suppliers") require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php'; -dol_fiche_end(); +print dol_get_fiche_end(); // Buttons diff --git a/htdocs/admin/supplierorder_extrafields.php b/htdocs/admin/supplierorder_extrafields.php index a35820806fb..c46eebfb037 100644 --- a/htdocs/admin/supplierorder_extrafields.php +++ b/htdocs/admin/supplierorder_extrafields.php @@ -78,7 +78,7 @@ print dol_get_fiche_head($head, 'supplierorder', $langs->trans("Suppliers"), -1, require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php'; -dol_fiche_end(); +print dol_get_fiche_end(); // Buttons diff --git a/htdocs/admin/supplierorderdet_extrafields.php b/htdocs/admin/supplierorderdet_extrafields.php index 8043c56bcd2..7017bebf61f 100644 --- a/htdocs/admin/supplierorderdet_extrafields.php +++ b/htdocs/admin/supplierorderdet_extrafields.php @@ -79,7 +79,7 @@ print dol_get_fiche_head($head, 'supplierorderdet', $langs->trans("Suppliers"), require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php'; -dol_fiche_end(); +print dol_get_fiche_end(); // Buttons diff --git a/htdocs/admin/system/filecheck.php b/htdocs/admin/system/filecheck.php index a3d54104a02..c8878b6b69f 100644 --- a/htdocs/admin/system/filecheck.php +++ b/htdocs/admin/system/filecheck.php @@ -147,7 +147,7 @@ if (GETPOST('target') == 'remote') $xmlarray = getURLContent($xmlremote); // Return array('content'=>response,'curl_error_no'=>errno,'curl_error_msg'=>errmsg...) - if (!$xmlarray['curl_error_no'] && $xmlarray['http_code'] != '404') + if (!$xmlarray['curl_error_no'] && $xmlarray['http_code'] != '400' && $xmlarray['http_code'] != '404') { $xmlfile = $xmlarray['content']; //print "xmlfilestart".$xmlfile."xmlfileend"; diff --git a/htdocs/admin/system/perf.php b/htdocs/admin/system/perf.php index 7857773924f..d9901818c92 100644 --- a/htdocs/admin/system/perf.php +++ b/htdocs/admin/system/perf.php @@ -431,7 +431,6 @@ print '
'; print ''; print $form->textwithpicto($langs->trans("CompressionOfResources"), $langs->trans("CompressionOfResourcesDesc")); print ': '; -//$tmp=getURLContent(DOL_URL_ROOT.'/index.php','GET');var_dump($tmp); print '
'; // on PHP print '
'.img_picto('', 'tick.png').' '.$langs->trans("FilesOfTypeCompressed", 'php (.php)').'
'; diff --git a/htdocs/admin/system/security.php b/htdocs/admin/system/security.php index 0cf70f2bbaa..05cf9dd1b8e 100644 --- a/htdocs/admin/system/security.php +++ b/htdocs/admin/system/security.php @@ -50,15 +50,21 @@ llxHeader(); print load_fiche_titre($langs->trans("Security"), '', 'title_setup'); print ''.$langs->trans("YouMayFindSecurityAdviceHere", 'hhttps://wiki.dolibarr.org/index.php/Security_information').' ('.$langs->trans("Reload").')
'; +print '
'; -// Recupere la version de PHP +print load_fiche_titre($langs->trans("PHPSetup"), '', ''); + +// Get version of PHP $phpversion = version_php(); -print "
PHP - ".$langs->trans("Version").": ".$phpversion."
\n"; +print "PHP - ".$langs->trans("Version").": ".$phpversion."
\n"; -// Recupere la version du serveur web +// Get versionof web server print "
Web server - ".$langs->trans("Version").": ".$_SERVER["SERVER_SOFTWARE"]."
\n"; print '
'; +print "PHP safe_mode = ".(ini_get('safe_mode') ? ini_get('safe_mode') : yn(0))."
\n"; +print "PHP open_basedir = ".(ini_get('open_basedir') ? ini_get('open_basedir') : yn(0))."
\n"; +print '
'; print load_fiche_titre($langs->trans("ConfigFile"), '', ''); @@ -73,6 +79,7 @@ print load_fiche_titre($langs->trans("PermissionsOnFiles"), '', ''); print ''.$langs->trans("PermissionOnFileInWebRoot").': '; // TODO +print 'TODO'; print '
'; @@ -126,6 +133,8 @@ print ''.$langs->trans("AntivirusEnabledOnUpload").': '; // TODO print '
'; +print '
'; + print ''.$langs->trans("SecurityAudit").': '; // TODO Disabled or enabled ? print '
'; diff --git a/htdocs/admin/ticket.php b/htdocs/admin/ticket.php index 03b590a318c..e8da4a8d736 100644 --- a/htdocs/admin/ticket.php +++ b/htdocs/admin/ticket.php @@ -186,7 +186,7 @@ print dol_get_fiche_head($head, 'settings', $langs->trans("Module56000Name"), -1 print ''.$langs->trans("TicketSetupDictionaries").' : '.$langs->trans("ClickHereToGoTo", $langs->transnoentitiesnoconv("DictionarySetup")).'
'; -dol_fiche_end(); +print dol_get_fiche_end(); /* diff --git a/htdocs/admin/ticket_extrafields.php b/htdocs/admin/ticket_extrafields.php index ad88e5adbf8..4a50beaa32e 100644 --- a/htdocs/admin/ticket_extrafields.php +++ b/htdocs/admin/ticket_extrafields.php @@ -75,7 +75,7 @@ print dol_get_fiche_head($head, 'attributes', $langs->trans("Module56000Name"), require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php'; -dol_fiche_end(); +print dol_get_fiche_end(); // Buttons if ($action != 'create' && $action != 'edit') { diff --git a/htdocs/admin/ticket_public.php b/htdocs/admin/ticket_public.php index 8de245ab8db..50ff514c6a7 100644 --- a/htdocs/admin/ticket_public.php +++ b/htdocs/admin/ticket_public.php @@ -175,7 +175,7 @@ print dol_get_fiche_head($head, 'public', $langs->trans("Module56000Name"), -1, print ''.$langs->trans("TicketPublicAccess").' : '.dol_buildpath('/public/ticket/index.php', 2).''; -dol_fiche_end(); +print dol_get_fiche_end(); $enabledisablehtml = $langs->trans("TicketsActivatePublicInterface").' '; diff --git a/htdocs/admin/tools/update.php b/htdocs/admin/tools/update.php index 27b53e8266e..f39766818f3 100644 --- a/htdocs/admin/tools/update.php +++ b/htdocs/admin/tools/update.php @@ -54,7 +54,7 @@ $version = '0.0'; if ($action == 'getlastversion') { - $result = getURLContent('http://sourceforge.net/projects/dolibarr/rss'); + $result = getURLContent('https://sourceforge.net/projects/dolibarr/rss'); //var_dump($result['content']); $sfurl = simplexml_load_string($result['content']); } diff --git a/htdocs/admin/translation.php b/htdocs/admin/translation.php index e6f667a169b..edd5ca95026 100644 --- a/htdocs/admin/translation.php +++ b/htdocs/admin/translation.php @@ -547,7 +547,7 @@ if ($mode == 'searchkey') print '
'; } -dol_fiche_end(); +print dol_get_fiche_end(); print "\n"; diff --git a/htdocs/admin/user.php b/htdocs/admin/user.php index b6fc6f43ae9..a22e585f972 100644 --- a/htdocs/admin/user.php +++ b/htdocs/admin/user.php @@ -328,7 +328,7 @@ foreach ($dirmodels as $reldir) print ''; print "
"; -dol_fiche_end(); +print dol_get_fiche_end(); // End of page llxFooter(); diff --git a/htdocs/admin/usergroup.php b/htdocs/admin/usergroup.php index e9cdcaf09b6..e73e01ccbdf 100644 --- a/htdocs/admin/usergroup.php +++ b/htdocs/admin/usergroup.php @@ -260,7 +260,7 @@ foreach ($dirmodels as $reldir) print ''; print "
"; -dol_fiche_end(); +print dol_get_fiche_end(); // End of page llxFooter(); diff --git a/htdocs/admin/website.php b/htdocs/admin/website.php index 01ef915d137..208caf85666 100644 --- a/htdocs/admin/website.php +++ b/htdocs/admin/website.php @@ -621,7 +621,7 @@ if ($id) } } -dol_fiche_end(); +print dol_get_fiche_end(); // End of page llxFooter(); diff --git a/htdocs/admin/website_options.php b/htdocs/admin/website_options.php index 479bbdbe7b9..738fd5bc998 100644 --- a/htdocs/admin/website_options.php +++ b/htdocs/admin/website_options.php @@ -140,7 +140,7 @@ if ($action == 'edit') } -dol_fiche_end(); +print dol_get_fiche_end(); // End of page llxFooter(); diff --git a/htdocs/api/class/api.class.php b/htdocs/api/class/api.class.php index 554edbb892e..5987ddfea66 100644 --- a/htdocs/api/class/api.class.php +++ b/htdocs/api/class/api.class.php @@ -104,7 +104,7 @@ class DolibarrApi unset($object->restrictiononfksoc); unset($object->table_rowid); - // Remove linkedObjects. We should already have linkedObjectIds that avoid huge responses + // Remove linkedObjects. We should already have linkedObjectsIds that avoid huge responses unset($object->linkedObjects); unset($object->fields); diff --git a/htdocs/api/class/api_setup.class.php b/htdocs/api/class/api_setup.class.php index 8177fbf7e1e..8e632fa0032 100644 --- a/htdocs/api/class/api_setup.class.php +++ b/htdocs/api/class/api_setup.class.php @@ -1634,7 +1634,7 @@ class Setup extends DolibarrApi $xmlarray = getURLContent($xmlremote); // Return array('content'=>response,'curl_error_no'=>errno,'curl_error_msg'=>errmsg...) - if (!$xmlarray['curl_error_no'] && $xmlarray['http_code'] != '404') + if (!$xmlarray['curl_error_no'] && $xmlarray['http_code'] != '400' && $xmlarray['http_code'] != '404') { $xmlfile = $xmlarray['content']; //print "xmlfilestart".$xmlfile."endxmlfile"; diff --git a/htdocs/asset/admin/assets_extrafields.php b/htdocs/asset/admin/assets_extrafields.php index 393f028f950..3334610b927 100644 --- a/htdocs/asset/admin/assets_extrafields.php +++ b/htdocs/asset/admin/assets_extrafields.php @@ -70,7 +70,7 @@ print dol_get_fiche_head($head, 'attributes', $langs->trans("Assets"), -1, 'gene require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php'; -dol_fiche_end(); +print dol_get_fiche_end(); // Buttons diff --git a/htdocs/asset/admin/assets_type_extrafields.php b/htdocs/asset/admin/assets_type_extrafields.php index 2b67be78e2b..25d7df8e1a7 100644 --- a/htdocs/asset/admin/assets_type_extrafields.php +++ b/htdocs/asset/admin/assets_type_extrafields.php @@ -69,7 +69,7 @@ print dol_get_fiche_head($head, 'attributes_type', $langs->trans("Assets"), -1, require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php'; -dol_fiche_end(); +print dol_get_fiche_end(); // Buttons if ($action != 'create' && $action != 'edit') diff --git a/htdocs/asset/admin/setup.php b/htdocs/asset/admin/setup.php index 6cda5f6eaa7..6fec16ef0a0 100644 --- a/htdocs/asset/admin/setup.php +++ b/htdocs/asset/admin/setup.php @@ -105,7 +105,7 @@ if ($action == 'edit') print '
'; } -dol_fiche_end(); +print dol_get_fiche_end(); // End of page llxFooter(); diff --git a/htdocs/asset/card.php b/htdocs/asset/card.php index 8b087297b79..0fa78edf9ce 100644 --- a/htdocs/asset/card.php +++ b/htdocs/asset/card.php @@ -180,7 +180,7 @@ if ($action == 'create') print ''."\n"; - dol_fiche_end(); + print dol_get_fiche_end(); print '
'; print ''; @@ -218,7 +218,7 @@ if (($id || $ref) && $action == 'edit') print ''; - dol_fiche_end(); + print dol_get_fiche_end(); print '
'; print '   '; @@ -297,7 +297,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print '
'; - dol_fiche_end(); + print dol_get_fiche_end(); // Buttons for actions diff --git a/htdocs/asset/class/asset.class.php b/htdocs/asset/class/asset.class.php index 036f31a99d7..05782b8ec67 100644 --- a/htdocs/asset/class/asset.class.php +++ b/htdocs/asset/class/asset.class.php @@ -113,17 +113,17 @@ class Asset extends CommonObject */ public $entity; - /** - * @var string Asset label - */ - public $label; + /** + * @var string Asset label + */ + public $label; public $amount; /** * @var int Thirdparty ID */ - public $fk_soc; + public $fk_soc; /** * @var string description @@ -134,21 +134,21 @@ class Asset extends CommonObject public $note_private; /** - * @var integer|string date_creation - */ + * @var integer|string date_creation + */ public $date_creation; public $tms; /** - * @var int ID - */ + * @var int ID + */ public $fk_user_creat; /** - * @var int ID - */ + * @var int ID + */ public $fk_user_modif; public $import_key; @@ -381,7 +381,7 @@ class Asset extends CommonObject return $this->LibStatut($this->status, $mode); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return the status * @@ -391,14 +391,14 @@ class Asset extends CommonObject */ public static function LibStatut($status, $mode = 0) { - // phpcs:enable + // phpcs:enable global $langs; $langs->load("contracts"); - $labelStatus = array(); + $labelStatus = array(); $labelStatus[self::STATUS_DRAFT] = $langs->trans('Disabled'); $labelStatus[self::STATUS_VALIDATED] = $langs->trans('Enabled'); - $labelStatusShort = array(); + $labelStatusShort = array(); $labelStatusShort[self::STATUS_DRAFT] = $langs->trans('Disabled'); $labelStatusShort[self::STATUS_VALIDATED] = $langs->trans('Enabled'); diff --git a/htdocs/asset/document.php b/htdocs/asset/document.php index 021f54a1ad2..4c2e36aed9a 100644 --- a/htdocs/asset/document.php +++ b/htdocs/asset/document.php @@ -135,7 +135,7 @@ if ($object->id) print '
'; - dol_fiche_end(); + print dol_get_fiche_end(); $modulepart = 'asset'; //$permission = $user->rights->asset->create; diff --git a/htdocs/asset/info.php b/htdocs/asset/info.php index 0cca7015573..d211cf0dbad 100644 --- a/htdocs/asset/info.php +++ b/htdocs/asset/info.php @@ -82,7 +82,7 @@ print ''; print '
'; -dol_fiche_end(); +print dol_get_fiche_end(); // End of page llxFooter(); diff --git a/htdocs/asset/note.php b/htdocs/asset/note.php index b1665d7fcc4..514e05bff72 100644 --- a/htdocs/asset/note.php +++ b/htdocs/asset/note.php @@ -146,7 +146,7 @@ if ($id > 0 || !empty($ref)) print '
'; - dol_fiche_end(); + print dol_get_fiche_end(); } // End of page diff --git a/htdocs/asset/type.php b/htdocs/asset/type.php index 3c6773f5992..28f2ce59df0 100644 --- a/htdocs/asset/type.php +++ b/htdocs/asset/type.php @@ -382,7 +382,7 @@ if ($action == 'create') print ''; print "\n"; - dol_fiche_end(); + print dol_get_fiche_end(); print '
'; print ''; @@ -490,7 +490,7 @@ if ($rowid > 0) print ''; print '
'; - dol_fiche_end(); + print dol_get_fiche_end(); /* * Buttons @@ -595,7 +595,7 @@ if ($rowid > 0) print ''; - dol_fiche_end(); + print dol_get_fiche_end(); print '
'; print '   '; diff --git a/htdocs/blockedlog/admin/blockedlog.php b/htdocs/blockedlog/admin/blockedlog.php index 674c5b771d0..b6ce9cda1bc 100644 --- a/htdocs/blockedlog/admin/blockedlog.php +++ b/htdocs/blockedlog/admin/blockedlog.php @@ -170,7 +170,7 @@ print ''; if (GETPOST('withtab', 'alpha')) { - dol_fiche_end(); + print dol_get_fiche_end(); } print '

'; diff --git a/htdocs/blockedlog/admin/blockedlog_list.php b/htdocs/blockedlog/admin/blockedlog_list.php index b4e26337c50..0a77c6ddf3b 100644 --- a/htdocs/blockedlog/admin/blockedlog_list.php +++ b/htdocs/blockedlog/admin/blockedlog_list.php @@ -582,7 +582,7 @@ if (!empty($conf->global->BLOCKEDLOG_USE_REMOTE_AUTHORITY) && !empty($conf->glob if (GETPOST('withtab', 'alpha')) { - dol_fiche_end(); + print dol_get_fiche_end(); } print '

'; diff --git a/htdocs/bom/bom_agenda.php b/htdocs/bom/bom_agenda.php index d5e929796e5..317fd6f9032 100644 --- a/htdocs/bom/bom_agenda.php +++ b/htdocs/bom/bom_agenda.php @@ -185,7 +185,7 @@ if ($object->id > 0) print '
'; - dol_fiche_end(); + print dol_get_fiche_end(); diff --git a/htdocs/bom/bom_card.php b/htdocs/bom/bom_card.php index 37db34f283c..7970911d84d 100644 --- a/htdocs/bom/bom_card.php +++ b/htdocs/bom/bom_card.php @@ -275,7 +275,7 @@ if ($action == 'create') print ''."\n"; - dol_fiche_end(); + print dol_get_fiche_end(); print '
'; print ''; @@ -311,7 +311,7 @@ if (($id || $ref) && $action == 'edit') print ''; - dol_fiche_end(); + print dol_get_fiche_end(); print '
'; print '   '; @@ -535,7 +535,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print '
'; - dol_fiche_end(); + print dol_get_fiche_end(); diff --git a/htdocs/bom/bom_document.php b/htdocs/bom/bom_document.php index 0f2a88366aa..f6a34a9c25d 100644 --- a/htdocs/bom/bom_document.php +++ b/htdocs/bom/bom_document.php @@ -130,7 +130,7 @@ if ($object->id) print '
'; - dol_fiche_end(); + print dol_get_fiche_end(); $modulepart = 'bom'; $permission = $user->rights->bom->write; diff --git a/htdocs/bom/bom_note.php b/htdocs/bom/bom_note.php index e69be248a1d..78b38732f7f 100644 --- a/htdocs/bom/bom_note.php +++ b/htdocs/bom/bom_note.php @@ -144,7 +144,7 @@ if ($id > 0 || !empty($ref)) print '
'; - dol_fiche_end(); + print dol_get_fiche_end(); } // End of page diff --git a/htdocs/bookmarks/card.php b/htdocs/bookmarks/card.php index 1506dd70269..30ccc6cdd75 100644 --- a/htdocs/bookmarks/card.php +++ b/htdocs/bookmarks/card.php @@ -177,7 +177,7 @@ if ($action == 'create') print ''; - dol_fiche_end(); + print dol_get_fiche_end(); print '
'; print '   '; @@ -295,7 +295,7 @@ if ($id > 0 && !preg_match('/^add/i', $action)) print '
'; - dol_fiche_end(); + print dol_get_fiche_end(); if ($action == 'edit') { diff --git a/htdocs/categories/admin/categorie_extrafields.php b/htdocs/categories/admin/categorie_extrafields.php index 404d35d6065..9bc1dd685ff 100644 --- a/htdocs/categories/admin/categorie_extrafields.php +++ b/htdocs/categories/admin/categorie_extrafields.php @@ -72,7 +72,7 @@ print dol_get_fiche_head($head, 'attributes_categories', $langs->trans("Categori require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php'; -dol_fiche_end(); +print dol_get_fiche_end(); // Buttons diff --git a/htdocs/categories/card.php b/htdocs/categories/card.php index 8949ba25ef4..6598387c36a 100644 --- a/htdocs/categories/card.php +++ b/htdocs/categories/card.php @@ -41,8 +41,8 @@ if (!$user->rights->categorie->lire) accessforbidden(); $action = GETPOST('action', 'alpha'); $cancel = GETPOST('cancel', 'alpha'); $origin = GETPOST('origin', 'alpha'); -$catorigin = GETPOST('catorigin', 'int'); -$type = GETPOST('type', 'alpha'); +$catorigin = GETPOST('catorigin', 'int'); +$type = GETPOST('type', 'aZ09'); $urlfrom = GETPOST('urlfrom', 'alpha'); $backtopage = GETPOST('backtopage', 'alpha'); @@ -73,6 +73,8 @@ $extrafields->fetch_name_optionals_label($object->table_element); // Initialize technical object to manage hooks. Note that conf->hooks_modules contains array array $hookmanager->initHooks(array('categorycard')); +$error = 0; + /* * Actions @@ -127,7 +129,7 @@ if ($action == 'add' && $user->rights->categorie->creer) $object->label = $label; $object->color = $color; $object->description = dol_htmlcleanlastbr($description); - $object->socid = ($socid ? $socid : 'null'); + $object->socid = ($socid > 0 ? $socid : 0); $object->visible = $visible; $object->type = $type; @@ -270,7 +272,7 @@ if ($user->rights->categorie->creer) print ''; - dol_fiche_end(''); + print dol_get_fiche_end(''); print '
'; print ''; diff --git a/htdocs/categories/class/categorie.class.php b/htdocs/categories/class/categorie.class.php index d3752ef43d8..086e14b27d0 100644 --- a/htdocs/categories/class/categorie.class.php +++ b/htdocs/categories/class/categorie.class.php @@ -208,6 +208,11 @@ class Categorie extends CommonObject */ public $color; + /** + * @var int Visible + */ + public $visible; + /** * @var int Id of thirdparty when CATEGORY_ASSIGNED_TO_A_CUSTOMER is set */ @@ -312,40 +317,36 @@ class Categorie extends CommonObject $sql = "SELECT rowid, fk_parent, entity, label, description, color, fk_soc, visible, type, ref_ext"; $sql .= ", date_creation, tms, fk_user_creat, fk_user_modif"; $sql .= " FROM ".MAIN_DB_PREFIX."categorie"; - if ($id > 0) - { + if ($id > 0) { $sql .= " WHERE rowid = ".$id; - } elseif (!empty($ref_ext)) - { + } elseif (!empty($ref_ext)) { $sql .= " WHERE ref_ext LIKE '".$this->db->escape($ref_ext)."'"; } else { $sql .= " WHERE label = '".$this->db->escape($label)."' AND entity IN (".getEntity('category').")"; - if (!is_null($type)) $sql .= " AND type = ".$this->db->escape($type); + if (!is_null($type)) $sql .= " AND type = ".((int) $type); } dol_syslog(get_class($this)."::fetch", LOG_DEBUG); $resql = $this->db->query($sql); - if ($resql) - { - if ($this->db->num_rows($resql) > 0) - { + if ($resql) { + if ($this->db->num_rows($resql) > 0) { $res = $this->db->fetch_array($resql); $this->id = $res['rowid']; //$this->ref = $res['rowid']; - $this->fk_parent = $res['fk_parent']; + $this->fk_parent = (int) $res['fk_parent']; $this->label = $res['label']; $this->description = $res['description']; $this->color = $res['color']; - $this->socid = $res['fk_soc']; - $this->visible = $res['visible']; - $this->type = $res['type']; + $this->socid = (int) $res['fk_soc']; + $this->visible = (int) $res['visible']; + $this->type = (int) $res['type']; $this->ref_ext = $res['ref_ext']; - $this->entity = $res['entity']; + $this->entity = (int) $res['entity']; $this->date_creation = $this->db->jdate($res['date_creation']); $this->date_modification = $this->db->jdate($res['tms']); - $this->user_creation = $res['fk_user_creat']; - $this->user_modification = $res['fk_user_modif']; + $this->user_creation = (int) $res['fk_user_creat']; + $this->user_modification = (int) $res['fk_user_modif']; // Retrieve all extrafield // fetch optionals attributes and labels @@ -397,8 +398,7 @@ class Categorie extends CommonObject if (empty($this->visible)) $this->visible = 0; $this->fk_parent = ($this->fk_parent != "" ? intval($this->fk_parent) : 0); - if ($this->already_exists()) - { + if ($this->already_exists()) { $this->error = $langs->trans("ImpossibleAddCat", $this->label); $this->error .= " : ".$langs->trans("CategoryExistsAtSameLevel"); dol_syslog($this->error, LOG_WARNING); @@ -412,8 +412,7 @@ class Categorie extends CommonObject $sql .= " label,"; $sql .= " description,"; $sql .= " color,"; - if (!empty($conf->global->CATEGORY_ASSIGNED_TO_A_CUSTOMER)) - { + if (!empty($conf->global->CATEGORY_ASSIGNED_TO_A_CUSTOMER)) { $sql .= "fk_soc,"; } $sql .= " visible,"; @@ -424,54 +423,47 @@ class Categorie extends CommonObject $sql .= " date_creation,"; $sql .= " fk_user_creat"; $sql .= ") VALUES ("; - $sql .= $this->db->escape($this->fk_parent).","; - $sql .= "'".$this->db->escape($this->label)."',"; - $sql .= "'".$this->db->escape($this->description)."',"; - $sql .= "'".$this->db->escape($this->color)."',"; - if (!empty($conf->global->CATEGORY_ASSIGNED_TO_A_CUSTOMER)) - { - $sql .= ($this->socid != -1 ? $this->socid : 'null').","; + $sql .= (int) $this->fk_parent.","; + $sql .= "'".$this->db->escape($this->label)."', "; + $sql .= "'".$this->db->escape($this->description)."', "; + $sql .= "'".$this->db->escape($this->color)."', "; + if (!empty($conf->global->CATEGORY_ASSIGNED_TO_A_CUSTOMER)) { + $sql .= ($this->socid > 0 ? $this->socid : 'null').", "; } - $sql .= "'".$this->db->escape($this->visible)."',"; - $sql .= $this->db->escape($type).","; - $sql .= (!empty($this->import_key) ? "'".$this->db->escape($this->import_key)."'" : 'null').","; - $sql .= (!empty($this->ref_ext) ? "'".$this->db->escape($this->ref_ext)."'" : 'null').","; - $sql .= $this->db->escape($conf->entity).","; + $sql .= "'".$this->db->escape($this->visible)."', "; + $sql .= $this->db->escape($type).", "; + $sql .= (!empty($this->import_key) ? "'".$this->db->escape($this->import_key)."'" : 'null').", "; + $sql .= (!empty($this->ref_ext) ? "'".$this->db->escape($this->ref_ext)."'" : 'null').", "; + $sql .= (int) $conf->entity.", "; $sql .= "'".$this->db->idate($now)."', "; $sql .= (int) $user->id; $sql .= ")"; $res = $this->db->query($sql); - if ($res) - { + if ($res) { $id = $this->db->last_insert_id(MAIN_DB_PREFIX."categorie"); - if ($id > 0) - { + if ($id > 0) { $this->id = $id; $action = 'create'; // Actions on extra fields - if (!$error) - { + if (!$error) { $result = $this->insertExtraFields(); - if ($result < 0) - { + if ($result < 0) { $error++; } } - if (!$error) - { + if (!$error) { // Call trigger $result = $this->call_trigger('CATEGORY_CREATE', $user); if ($result < 0) { $error++; } // End call triggers } - if (!$error) - { + if (!$error) { $this->db->commit(); return $id; } else { @@ -510,8 +502,7 @@ class Categorie extends CommonObject $this->fk_parent = ($this->fk_parent != "" ? intval($this->fk_parent) : 0); $this->visible = ($this->visible != "" ? intval($this->visible) : 0); - if ($this->already_exists()) - { + if ($this->already_exists()) { $this->error = $langs->trans("ImpossibleUpdateCat"); $this->error .= " : ".$langs->trans("CategoryExistsAtSameLevel"); return -1; @@ -524,32 +515,27 @@ class Categorie extends CommonObject $sql .= " description = '".$this->db->escape($this->description)."',"; $sql .= " ref_ext = '".$this->db->escape($this->ref_ext)."',"; $sql .= " color = '".$this->db->escape($this->color)."'"; - if (!empty($conf->global->CATEGORY_ASSIGNED_TO_A_CUSTOMER)) - { - $sql .= ", fk_soc = ".($this->socid != -1 ? $this->socid : 'null'); + if (!empty($conf->global->CATEGORY_ASSIGNED_TO_A_CUSTOMER)) { + $sql .= ", fk_soc = ".($this->socid > 0 ? $this->socid : 'null'); } - $sql .= ", visible = '".$this->db->escape($this->visible)."'"; - $sql .= ", fk_parent = ".$this->fk_parent; + $sql .= ", visible = ".(int) $this->visible; + $sql .= ", fk_parent = ".(int) $this->fk_parent; $sql .= ", fk_user_modif = ".(int) $user->id; $sql .= " WHERE rowid = ".$this->id; dol_syslog(get_class($this)."::update", LOG_DEBUG); - if ($this->db->query($sql)) - { + if ($this->db->query($sql)) { $action = 'update'; // Actions on extra fields - if (!$error) - { + if (!$error) { $result = $this->insertExtraFields(); - if ($result < 0) - { + if ($result < 0) { $error++; } } - if (!$error) - { + if (!$error) { // Call trigger $result = $this->call_trigger('CATEGORY_MODIFY', $user); if ($result < 0) { $error++; $this->db->rollback(); return -1; } @@ -586,8 +572,7 @@ class Categorie extends CommonObject $this->db->begin(); - if (!$error && !$notrigger) - { + if (!$error && !$notrigger) { // Call trigger $result = $this->call_trigger('CATEGORY_DELETE', $user); if ($result < 0) $error++; @@ -595,14 +580,12 @@ class Categorie extends CommonObject } /* FIX #1317 : Check for child category and move up 1 level*/ - if (!$error) - { + if (!$error) { $sql = "UPDATE ".MAIN_DB_PREFIX."categorie"; $sql .= " SET fk_parent = ".$this->fk_parent; $sql .= " WHERE fk_parent = ".$this->id; - if (!$this->db->query($sql)) - { + if (!$this->db->query($sql)) { $this->error = $this->db->lasterror(); $error++; } @@ -630,18 +613,15 @@ class Categorie extends CommonObject } // Removed extrafields - if (!$error) - { + if (!$error) { $result = $this->deleteExtraFields(); - if ($result < 0) - { + if ($result < 0) { $error++; dol_syslog(get_class($this)."::delete erreur ".$this->error, LOG_ERR); } } - if (!$error) - { + if (!$error) { $this->db->commit(); return 1; } else { @@ -676,29 +656,23 @@ class Categorie extends CommonObject $sql .= " VALUES (".$this->id.", ".$obj->id.")"; dol_syslog(get_class($this).'::add_type', LOG_DEBUG); - if ($this->db->query($sql)) - { - if (!empty($conf->global->CATEGORIE_RECURSIV_ADD)) - { + if ($this->db->query($sql)) { + if (!empty($conf->global->CATEGORIE_RECURSIV_ADD)) { $sql = 'SELECT fk_parent FROM '.MAIN_DB_PREFIX.'categorie'; $sql .= " WHERE rowid = ".$this->id; dol_syslog(get_class($this)."::add_type", LOG_DEBUG); $resql = $this->db->query($sql); - if ($resql) - { - if ($this->db->num_rows($resql) > 0) - { + if ($resql) { + if ($this->db->num_rows($resql) > 0) { $objparent = $this->db->fetch_object($resql); - if (!empty($objparent->fk_parent)) - { + if (!empty($objparent->fk_parent)) { $cat = new Categorie($this->db); $cat->id = $objparent->fk_parent; if (!$cat->containsObject($type, $obj->id)) { $result = $cat->add_type($obj, $type); - if ($result < 0) - { + if ($result < 0) { $this->error = $cat->error; $error++; } @@ -710,8 +684,7 @@ class Categorie extends CommonObject $this->error = $this->db->lasterror(); } - if ($error) - { + if ($error) { $this->db->rollback(); return -1; } @@ -725,8 +698,7 @@ class Categorie extends CommonObject if ($result < 0) { $error++; } // End call triggers - if (!$error) - { + if (!$error) { $this->db->commit(); return 1; } else { @@ -735,8 +707,7 @@ class Categorie extends CommonObject } } else { $this->db->rollback(); - if ($this->db->lasterrno() == 'DB_ERROR_RECORD_ALREADY_EXISTS') - { + if ($this->db->lasterrno() == 'DB_ERROR_RECORD_ALREADY_EXISTS') { $this->error = $this->db->lasterrno(); return -3; } else { @@ -778,16 +749,14 @@ class Categorie extends CommonObject $sql .= " AND fk_".(empty($this->MAP_CAT_FK[$type]) ? $type : $this->MAP_CAT_FK[$type])." = ".$obj->id; dol_syslog(get_class($this).'::del_type', LOG_DEBUG); - if ($this->db->query($sql)) - { + if ($this->db->query($sql)) { // Call trigger $this->context = array('unlinkoff'=>$obj); // Save object we want to link category to into category instance to provide information to trigger $result = $this->call_trigger('CATEGORY_UNLINK', $user); if ($result < 0) { $error++; } // End call triggers - if (!$error) - { + if (!$error) { $this->db->commit(); return 1; } else { @@ -829,8 +798,7 @@ class Categorie extends CommonObject $sql .= " AND c.fk_categorie = ".$this->id; $sql .= " AND c.fk_".(empty($this->MAP_CAT_FK[$type]) ? $type : $this->MAP_CAT_FK[$type])." = o.rowid"; // Protection for external users - if (($type == 'customer' || $type == 'supplier') && $user->socid > 0) - { + if (($type == 'customer' || $type == 'supplier') && $user->socid > 0) { $sql .= " AND o.rowid = ".$user->socid; } if ($limit > 0 || $offset > 0) $sql .= $this->db->plimit($limit + 1, $offset); @@ -838,10 +806,8 @@ class Categorie extends CommonObject dol_syslog(get_class($this)."::getObjectsInCateg", LOG_DEBUG); $resql = $this->db->query($sql); - if ($resql) - { - while ($rec = $this->db->fetch_array($resql)) - { + if ($resql) { + while ($rec = $this->db->fetch_array($resql)) { if ($onlyids) { $objs[] = $rec['fk_'.(empty($this->MAP_CAT_FK[$type]) ? $type : $this->MAP_CAT_FK[$type])]; } else { @@ -927,20 +893,17 @@ class Categorie extends CommonObject $offset = 0; $nbtotalofrecords = ''; - if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) - { + if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $result = $this->db->query($sql); $nbtotalofrecords = $this->db->num_rows($result); - if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 - { + if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0 $page = 0; $offset = 0; } } if ($limit) { - if ($page < 0) - { + if ($page < 0) { $page = 0; } $offset = $limit * $page; @@ -949,17 +912,14 @@ class Categorie extends CommonObject } $result = $this->db->query($sql); - if ($result) - { + if ($result) { $i = 0; $num = $this->db->num_rows($result); $min = min($num, ($limit <= 0 ? $num : $limit)); - while ($i < $min) - { + while ($i < $min) { $obj = $this->db->fetch_object($result); $category_static = new Categorie($this->db); - if ($category_static->fetch($obj->rowid)) - { + if ($category_static->fetch($obj->rowid)) { $categories[$i]['id'] = $category_static->id; $categories[$i]['fk_parent'] = $category_static->fk_parent; $categories[$i]['label'] = $category_static->label; @@ -1004,11 +964,9 @@ class Categorie extends CommonObject $sql .= " AND entity IN (".getEntity('category').")"; $res = $this->db->query($sql); - if ($res) - { + if ($res) { $cats = array(); - while ($rec = $this->db->fetch_array($res)) - { + while ($rec = $this->db->fetch_array($res)) { $cat = new Categorie($this->db); $cat->fetch($rec['rowid']); $cats[] = $cat; @@ -1039,10 +997,8 @@ class Categorie extends CommonObject dol_syslog(get_class($this)."::load_motherof", LOG_DEBUG); $resql = $this->db->query($sql); - if ($resql) - { - while ($obj = $this->db->fetch_object($resql)) - { + if ($resql) { + while ($obj = $this->db->fetch_object($resql)) { $this->motherof[$obj->id_son] = $obj->id_parent; } return 1; @@ -1083,19 +1039,15 @@ class Categorie extends CommonObject return -1; } - if (is_string($markafterid)) - { + if (is_string($markafterid)) { $markafterid = explode(',', $markafterid); - } elseif (is_numeric($markafterid)) - { - if ($markafterid > 0) - { + } elseif (is_numeric($markafterid)) { + if ($markafterid > 0) { $markafterid = array($markafterid); } else { $markafterid = array(); } - } elseif (!is_array($markafterid)) - { + } elseif (!is_array($markafterid)) { $markafterid = array(); } @@ -1115,11 +1067,9 @@ class Categorie extends CommonObject dol_syslog(get_class($this)."::get_full_arbo get category list", LOG_DEBUG); $resql = $this->db->query($sql); - if ($resql) - { + if ($resql) { $i = 0; - while ($obj = $this->db->fetch_object($resql)) - { + while ($obj = $this->db->fetch_object($resql)) { $this->cats[$obj->rowid]['rowid'] = $obj->rowid; $this->cats[$obj->rowid]['id'] = $obj->rowid; $this->cats[$obj->rowid]['fk_parent'] = $obj->fk_parent; @@ -1137,15 +1087,13 @@ class Categorie extends CommonObject // We add the fullpath property to each elements of first level (no parent exists) dol_syslog(get_class($this)."::get_full_arbo call to build_path_from_id_categ", LOG_DEBUG); - foreach ($this->cats as $key => $val) - { + foreach ($this->cats as $key => $val) { //print 'key='.$key.'
'."\n"; $this->build_path_from_id_categ($key, 0); // Process a branch from the root category key (this category has no parent) } // Include or exclude leaf including $markafterid from tree - if (count($markafterid) > 0) - { + if (count($markafterid) > 0) { $keyfiltercatid = '('.implode('|', $markafterid).')'; //print "Look to discard category ".$markafterid."\n"; @@ -1153,13 +1101,11 @@ class Categorie extends CommonObject $keyfilter2 = '_'.$keyfiltercatid.'$'; $keyfilter3 = '^'.$keyfiltercatid.'_'; $keyfilter4 = '_'.$keyfiltercatid.'_'; - foreach ($this->cats as $key => $val) - { + foreach ($this->cats as $key => $val) { $test = (preg_match('/'.$keyfilter1.'/', $val['fullpath']) || preg_match('/'.$keyfilter2.'/', $val['fullpath']) || preg_match('/'.$keyfilter3.'/', $val['fullpath']) || preg_match('/'.$keyfilter4.'/', $val['fullpath'])); - if (($test && !$include) || (!$test && $include)) - { + if (($test && !$include) || (!$test && $include)) { unset($this->cats[$key]); } } @@ -1189,8 +1135,7 @@ class Categorie extends CommonObject // phpcs:enable dol_syslog(get_class($this)."::build_path_from_id_categ id_categ=".$id_categ." protection=".$protection, LOG_DEBUG); - if (!empty($this->cats[$id_categ]['fullpath'])) - { + if (!empty($this->cats[$id_categ]['fullpath'])) { // Already defined dol_syslog(get_class($this)."::build_path_from_id_categ fullpath and fulllabel already defined", LOG_WARNING); return; @@ -1204,8 +1149,7 @@ class Categorie extends CommonObject $this->cats[$id_categ]['fulllabel'] = $this->cats[$id_categ]['label']; $i = 0; $cursor_categ = $id_categ; //print 'Work for id_categ='.$id_categ.'
'."\n"; - while ((empty($protection) || $i < $protection) && !empty($this->motherof[$cursor_categ])) - { + while ((empty($protection) || $i < $protection) && !empty($this->motherof[$cursor_categ])) { //print '  cursor_categ='.$cursor_categ.' i='.$i.' '.$this->motherof[$cursor_categ].'
'."\n"; $this->cats[$id_categ]['fullpath'] = '_'.$this->motherof[$cursor_categ].$this->cats[$id_categ]['fullpath']; $this->cats[$id_categ]['fulllabel'] = $this->cats[$this->motherof[$cursor_categ]]['label'].' >> '.$this->cats[$id_categ]['fulllabel']; @@ -1231,8 +1175,7 @@ class Categorie extends CommonObject { // phpcs:enable // Display $this->cats - foreach ($this->cats as $key => $val) - { + foreach ($this->cats as $key => $val) { print 'id: '.$this->cats[$key]['id']; print ' label: '.$this->cats[$key]['label']; print ' mother: '.$this->cats[$key]['fk_parent']; @@ -1260,16 +1203,14 @@ class Categorie extends CommonObject $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."categorie"; $sql .= " WHERE entity IN (".getEntity('category').")"; if (!is_null($type)) - $sql .= " AND type = ".$type; + $sql .= " AND type = ".(int) $type; if ($parent) $sql .= " AND fk_parent = 0"; $res = $this->db->query($sql); - if ($res) - { + if ($res) { $cats = array(); - while ($rec = $this->db->fetch_array($res)) - { + while ($rec = $this->db->fetch_array($res)) { $cat = new Categorie($this->db); $cat->fetch($rec['rowid']); $cats[$rec['rowid']] = $cat; @@ -1319,18 +1260,15 @@ class Categorie extends CommonObject dol_syslog(get_class($this)."::already_exists", LOG_DEBUG); $resql = $this->db->query($sql); - if ($resql) - { - if ($this->db->num_rows($resql) > 0) // Checking for empty resql - { + if ($resql) { + if ($this->db->num_rows($resql) > 0) { // Checking for empty resql $obj = $this->db->fetch_array($resql); /* If object called create, obj cannot have is id. * If object called update, he mustn't have the same label as an other category for this mother. * So if the result have the same id, update is not for label, and if result have an other one, * update may be for label. */ - if ($obj[0] > 0 && $obj[0] != $this->id) - { + if ($obj[0] > 0 && $obj[0] != $this->id) { dol_syslog(get_class($this)."::already_exists category with name=".$this->label." and parent ".$this->fk_parent." exists: rowid=".$obj[0]." current_id=".$this->id, LOG_DEBUG); return 1; } @@ -1361,24 +1299,19 @@ class Categorie extends CommonObject $ways = array(); $allways = $this->get_all_ways(); // Load array of categories - foreach ($allways as $way) - { + foreach ($allways as $way) { $w = array(); $i = 0; $forced_color = ''; - foreach ($way as $cat) - { + foreach ($way as $cat) { $i++; - if (empty($nocolor)) - { + if (empty($nocolor)) { $forced_color = 'toreplace'; - if ($i == count($way)) - { + if ($i == count($way)) { // Check contrast with background and correct text color $forced_color = 'categtextwhite'; - if ($cat->color) - { + if ($cat->color) { if (colorIsLight($cat->color)) $forced_color = 'categtextblack'; } } @@ -1421,12 +1354,9 @@ class Categorie extends CommonObject $res = $this->db->query($sql); - if ($res) - { - while ($rec = $this->db->fetch_array($res)) - { - if ($rec['fk_parent'] > 0) - { + if ($res) { + while ($rec = $this->db->fetch_array($res)) { + if ($rec['fk_parent'] > 0) { $cat = new Categorie($this->db); $cat->fetch($rec['fk_parent']); $parents[] = $cat; @@ -1452,13 +1382,10 @@ class Categorie extends CommonObject $ways = array(); $parents = $this->get_meres(); - if (!empty($parents)) - { - foreach ($parents as $parent) - { + if (!empty($parents)) { + foreach ($parents as $parent) { $allways = $parent->get_all_ways(); - foreach ($allways as $way) - { + foreach ($allways as $way) { $w = $way; $w[] = $this; $ways[] = $w; @@ -1488,8 +1415,7 @@ class Categorie extends CommonObject if (is_numeric($type)) $type = Categorie::$MAP_ID_TO_CODE[$type]; - if ($type === Categorie::TYPE_BANK_LINE) // TODO Remove this with standard category code - { + if ($type === Categorie::TYPE_BANK_LINE) { // TODO Remove this with standard category code // Load bank groups $sql = "SELECT c.label, c.rowid"; $sql .= " FROM ".MAIN_DB_PREFIX."bank_class as a, ".MAIN_DB_PREFIX."bank_categ as c"; @@ -1497,10 +1423,8 @@ class Categorie extends CommonObject $sql .= " ORDER BY c.label"; $res = $this->db->query($sql); - if ($res) - { - while ($obj = $this->db->fetch_object($res)) - { + if ($res) { + while ($obj = $this->db->fetch_object($res)) { if ($mode == 'id') { $cats[] = $obj->rowid; } elseif ($mode == 'label') { @@ -1523,10 +1447,8 @@ class Categorie extends CommonObject $sql .= " AND c.entity IN (".getEntity('category').")"; $res = $this->db->query($sql); - if ($res) - { - while ($obj = $this->db->fetch_object($res)) - { + if ($res) { + while ($obj = $this->db->fetch_object($res)) { if ($mode == 'id') { $cats[] = $obj->rowid; } elseif ($mode == 'label') { @@ -1579,24 +1501,20 @@ class Categorie extends CommonObject $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."categorie"; $sql .= " WHERE type = ".$this->MAP_ID[$type]; $sql .= " AND entity IN (".getEntity('category').")"; - if ($nom) - { + if ($nom) { if (!$exact) $nom = '%'.str_replace('*', '%', $nom).'%'; if (!$case) $sql .= " AND label LIKE '".$this->db->escape($nom)."'"; else $sql .= " AND label LIKE BINARY '".$this->db->escape($nom)."'"; } - if ($id) - { + if ($id) { $sql .= " AND rowid = '".$id."'"; } $res = $this->db->query($sql); - if ($res) - { - while ($rec = $this->db->fetch_array($res)) - { + if ($res) { + while ($rec = $this->db->fetch_array($res)) { $cat = new Categorie($this->db); $cat->fetch($rec['rowid']); $cats[] = $cat; @@ -1628,8 +1546,7 @@ class Categorie extends CommonObject // Check contrast with background and correct text color $forced_color = 'categtextwhite'; - if ($this->color) - { + if ($this->color) { if (colorIsLight($this->color)) $forced_color = 'categtextblack'; } @@ -1662,14 +1579,12 @@ class Categorie extends CommonObject $dir = $sdir.'/'.get_exdir($this->id, 2, 0, 0, $this, 'category').$this->id."/"; $dir .= "photos/"; - if (!file_exists($dir)) - { + if (!file_exists($dir)) { dol_mkdir($dir); } if (file_exists($dir)) { - if (is_array($file['name']) && count($file['name']) > 0) - { + if (is_array($file['name']) && count($file['name']) > 0) { $nbfile = count($file['name']); for ($i = 0; $i <= $nbfile; $i++) { $originImage = $dir.$file['name'][$i]; @@ -1714,22 +1629,17 @@ class Categorie extends CommonObject $dirthumb = $dir.'thumbs/'; - if (file_exists($dir)) - { + if (file_exists($dir)) { $handle = opendir($dir); - if (is_resource($handle)) - { - while (($file = readdir($handle)) !== false) - { - if (dol_is_file($dir.$file) && preg_match('/(\.jpeg|\.jpg|\.bmp|\.gif|\.png|\.tiff)$/i', $dir.$file)) - { + if (is_resource($handle)) { + while (($file = readdir($handle)) !== false) { + if (dol_is_file($dir.$file) && preg_match('/(\.jpeg|\.jpg|\.bmp|\.gif|\.png|\.tiff)$/i', $dir.$file)) { $nbphoto++; $photo = $file; // On determine nom du fichier vignette $photo_vignette = ''; - if (preg_match('/(\.jpeg|\.jpg|\.bmp|\.gif|\.png|\.tiff)$/i', $photo, $regs)) - { + if (preg_match('/(\.jpeg|\.jpg|\.bmp|\.gif|\.png|\.tiff)$/i', $photo, $regs)) { $photo_vignette = preg_replace('/'.$regs[0].'/i', '', $photo).'_small'.$regs[0]; } @@ -1773,11 +1683,9 @@ class Categorie extends CommonObject dol_delete_file($file, 1); // Si elle existe, on efface la vignette - if (preg_match('/(\.jpeg|\.jpg|\.bmp|\.gif|\.png|\.tiff)$/i', $filename, $regs)) - { + if (preg_match('/(\.jpeg|\.jpg|\.bmp|\.gif|\.png|\.tiff)$/i', $filename, $regs)) { $photo_vignette = preg_replace('/'.$regs[0].'/i', '', $filename).'_small'.$regs[0]; - if (file_exists($dirthumb.$photo_vignette)) - { + if (file_exists($dirthumb.$photo_vignette)) { dol_delete_file($dirthumb.$photo_vignette, 1); } } @@ -1812,8 +1720,7 @@ class Categorie extends CommonObject $langs_available = $langs->get_available_languages(); $current_lang = $langs->getDefaultLang(); - foreach ($langs_available as $key => $value) - { + foreach ($langs_available as $key => $value) { $sql = "SELECT rowid"; $sql .= " FROM ".MAIN_DB_PREFIX."categorie_lang"; $sql .= " WHERE fk_category=".$this->id; @@ -1821,10 +1728,8 @@ class Categorie extends CommonObject $result = $this->db->query($sql); - if ($key == $current_lang) - { - if ($this->db->num_rows($result)) // si aucune ligne dans la base - { + if ($key == $current_lang) { + if ($this->db->num_rows($result)) { // si aucune ligne dans la base $sql2 = "UPDATE ".MAIN_DB_PREFIX."categorie_lang"; $sql2 .= " SET label='".$this->db->escape($this->label)."',"; $sql2 .= " description='".$this->db->escape($this->description)."'"; @@ -1835,15 +1740,12 @@ class Categorie extends CommonObject $sql2 .= "','".$this->db->escape($this->multilangs["$key"]["description"])."')"; } dol_syslog(get_class($this).'::setMultiLangs', LOG_DEBUG); - if (!$this->db->query($sql2)) - { + if (!$this->db->query($sql2)) { $this->error = $this->db->lasterror(); return -1; } - } elseif (isset($this->multilangs["$key"])) - { - if ($this->db->num_rows($result)) // si aucune ligne dans la base - { + } elseif (isset($this->multilangs["$key"])) { + if ($this->db->num_rows($result)) { // si aucune ligne dans la base $sql2 = "UPDATE ".MAIN_DB_PREFIX."categorie_lang"; $sql2 .= " SET label='".$this->db->escape($this->multilangs["$key"]["label"])."',"; $sql2 .= " description='".$this->db->escape($this->multilangs["$key"]["description"])."'"; @@ -1857,8 +1759,7 @@ class Categorie extends CommonObject // on ne sauvegarde pas des champs vides if ($this->multilangs["$key"]["label"] || $this->multilangs["$key"]["description"] || $this->multilangs["$key"]["note"]) dol_syslog(get_class($this).'::setMultiLangs', LOG_DEBUG); - if (!$this->db->query($sql2)) - { + if (!$this->db->query($sql2)) { $this->error = $this->db->lasterror(); return -1; } @@ -1892,13 +1793,10 @@ class Categorie extends CommonObject $sql .= " WHERE fk_category=".$this->id; $result = $this->db->query($sql); - if ($result) - { - while ($obj = $this->db->fetch_object($result)) - { + if ($result) { + while ($obj = $this->db->fetch_object($result)) { //print 'lang='.$obj->lang.' current='.$current_lang.'
'; - if ($obj->lang == $current_lang) // si on a les traduct. dans la langue courante on les charge en infos principales. - { + if ($obj->lang == $current_lang) { // si on a les traduct. dans la langue courante on les charge en infos principales. $this->label = $obj->label; $this->description = $obj->description; } @@ -1988,26 +1886,21 @@ class Categorie extends CommonObject { if ($type == 'bank_account') $type = 'account'; - if (empty($searchList) && !is_array($searchList)) - { + if (empty($searchList) && !is_array($searchList)) { return ""; } - foreach ($searchList as $searchCategory) - { - if (intval($searchCategory) == -2) - { + foreach ($searchList as $searchCategory) { + if (intval($searchCategory) == -2) { $searchCategorySqlList[] = " cp.fk_categorie IS NULL"; - } elseif (intval($searchCategory) > 0) - { + } elseif (intval($searchCategory) > 0) { $searchCategorySqlList[] = " ".$rowIdName ." IN (SELECT fk_".$type." FROM ".MAIN_DB_PREFIX."categorie_".$type ." WHERE fk_categorie = ".$searchCategory.")"; } } - if (!empty($searchCategorySqlList)) - { + if (!empty($searchCategorySqlList)) { return " AND (".implode(' AND ', $searchCategorySqlList).")"; } else { return ""; diff --git a/htdocs/categories/edit.php b/htdocs/categories/edit.php index 8c05c313987..4b4eaffeb57 100644 --- a/htdocs/categories/edit.php +++ b/htdocs/categories/edit.php @@ -34,7 +34,7 @@ $langs->load("categories"); $id = GETPOST('id', 'int'); $ref = GETPOST('ref', 'alphanohtml'); -$type = GETPOST('type', 'alphanohtml'); +$type = (int) GETPOST('type', 'int'); $action = (GETPOST('action', 'aZ09') ?GETPOST('action', 'aZ09') : 'edit'); $confirm = GETPOST('confirm'); $cancel = GETPOST('cancel', 'alpha'); @@ -43,11 +43,10 @@ $socid = GETPOST('socid', 'int'); $label = GETPOST('label', 'alphanohtml'); $description = GETPOST('description', 'restricthtml'); $color = preg_replace('/[^0-9a-f#]/i', '', GETPOST('color', 'alphanohtml')); -$visible = GETPOST('visible'); -$parent = GETPOST('parent'); +$visible = (int) GETPOST('visible', 'int'); +$parent = (int) GETPOST('parent', 'int'); -if ($id == "") -{ +if ($id == "") { dol_print_error('', 'Missing parameter id'); exit(); } @@ -56,8 +55,7 @@ if ($id == "") $result = restrictedArea($user, 'categorie', $id, '&category'); $object = new Categorie($db); -if ($id > 0) -{ +if ($id > 0) { $result = $object->fetch($id); } @@ -67,45 +65,39 @@ $extrafields->fetch_name_optionals_label($object->table_element); // Initialize technical object to manage hooks. Note that conf->hooks_modules contains array array $hookmanager->initHooks(array('categorycard')); +$error = 0; + /* * Actions */ -if ($cancel) -{ +if ($cancel) { header('Location: '.DOL_URL_ROOT.'/categories/viewcat.php?id='.$object->id.'&type='.$type); exit; } // Action mise a jour d'une categorie -if ($action == 'update' && $user->rights->categorie->creer) -{ +if ($action == 'update' && $user->rights->categorie->creer) { $object->oldcopy = dol_clone($object); $object->label = $label; $object->description = dol_htmlcleanlastbr($description); $object->color = $color; - $object->socid = ($socid ? $socid : 'null'); + $object->socid = ($socid > 0 ? $socid : 0); $object->visible = $visible; - - if ($parent != "-1") - $object->fk_parent = $parent; - else $object->fk_parent = ""; + $object->fk_parent = $parent != -1 ? $parent : 0; - if (empty($object->label)) - { + if (empty($object->label)) { $error++; $action = 'edit'; setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Label")), null, 'errors'); } - if (!$error && empty($object->error)) - { + if (!$error && empty($object->error)) { $ret = $extrafields->setOptionalsFromPost(null, $object); if ($ret < 0) $error++; - if (!$error && $object->update($user) > 0) - { + if (!$error && $object->update($user) > 0) { header('Location: '.DOL_URL_ROOT.'/categories/viewcat.php?id='.$object->id.'&type='.$type); exit; } else { @@ -173,15 +165,14 @@ print ''; $parameters = array(); $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; -if (empty($reshook)) -{ +if (empty($reshook)) { print $object->showOptionals($extrafields, 'edit', $parameters); } print ''; -dol_fiche_end(); +print dol_get_fiche_end(); print '
 
'; diff --git a/htdocs/categories/info.php b/htdocs/categories/info.php index 0011b4c1f5f..5bd8f6c9d24 100644 --- a/htdocs/categories/info.php +++ b/htdocs/categories/info.php @@ -95,7 +95,7 @@ print ''; print '
'; -dol_fiche_end(); +print dol_get_fiche_end(); // End of page llxFooter(); diff --git a/htdocs/categories/photos.php b/htdocs/categories/photos.php index 0c7c35da1fe..73c7664f6c2 100644 --- a/htdocs/categories/photos.php +++ b/htdocs/categories/photos.php @@ -161,7 +161,7 @@ if ($object->id) print "\n"; print '
'; - dol_fiche_end(); + print dol_get_fiche_end(); diff --git a/htdocs/categories/traduction.php b/htdocs/categories/traduction.php index c690cfcab84..660dbf9317d 100644 --- a/htdocs/categories/traduction.php +++ b/htdocs/categories/traduction.php @@ -223,7 +223,7 @@ print ''; print ''; print '
'; -dol_fiche_end(); +print dol_get_fiche_end(); diff --git a/htdocs/categories/viewcat.php b/htdocs/categories/viewcat.php index 1985e756d45..280b278657c 100644 --- a/htdocs/categories/viewcat.php +++ b/htdocs/categories/viewcat.php @@ -267,7 +267,7 @@ include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php'; print ''; print '
'; -dol_fiche_end(); +print dol_get_fiche_end(); /* diff --git a/htdocs/comm/action/card.php b/htdocs/comm/action/card.php index 7e9e63895aa..a46e302bd4b 100644 --- a/htdocs/comm/action/card.php +++ b/htdocs/comm/action/card.php @@ -1291,7 +1291,7 @@ if ($action == 'create') print ''."\n"; } - dol_fiche_end(); + print dol_get_fiche_end(); print '
'; print ''; @@ -1782,7 +1782,7 @@ if ($id > 0) print ''."\n"; } - dol_fiche_end(); + print dol_get_fiche_end(); print '
'; print ''; @@ -2095,7 +2095,7 @@ if ($id > 0) print '
'; print '
'; - dol_fiche_end(); + print dol_get_fiche_end(); } diff --git a/htdocs/comm/action/document.php b/htdocs/comm/action/document.php index 0c3ff22801a..613ac76380e 100644 --- a/htdocs/comm/action/document.php +++ b/htdocs/comm/action/document.php @@ -254,7 +254,7 @@ if ($object->id > 0) print '
'; - dol_fiche_end(); + print dol_get_fiche_end(); $modulepart = 'actions'; diff --git a/htdocs/comm/action/index.php b/htdocs/comm/action/index.php index 65123586e89..e62f411d786 100644 --- a/htdocs/comm/action/index.php +++ b/htdocs/comm/action/index.php @@ -417,7 +417,7 @@ print ''; //print dol_get_fiche_head($head, $tabactive, $langs->trans('Agenda'), 0, 'action'); //print_actions_filter($form, $canedit, $status, $year, $month, $day, $showbirthday, 0, $filtert, 0, $pid, $socid, $action, $listofextcals, $actioncode, $usergroup, '', $resourceid); -//dol_fiche_end(); +//print dol_get_fiche_end(); $viewmode = ''; $viewmode .= ''; diff --git a/htdocs/comm/action/info.php b/htdocs/comm/action/info.php index 813e3240b7a..292c0ea94ce 100644 --- a/htdocs/comm/action/info.php +++ b/htdocs/comm/action/info.php @@ -112,7 +112,7 @@ print '
'; dol_print_object_info($object); print '
'; -dol_fiche_end(); +print dol_get_fiche_end(); // End of page llxFooter(); diff --git a/htdocs/comm/action/list.php b/htdocs/comm/action/list.php index ed96a3a2d4f..582f1c538f0 100644 --- a/htdocs/comm/action/list.php +++ b/htdocs/comm/action/list.php @@ -454,7 +454,7 @@ if ($resql) //print dol_get_fiche_head($head, $tabactive, $langs->trans('Agenda'), 0, 'action'); //print_actions_filter($form, $canedit, $search_status, $year, $month, $day, $showbirthday, 0, $filtert, 0, $pid, $socid, $action, -1, $actioncode, $usergroup, '', $resourceid); - //dol_fiche_end(); + //print dol_get_fiche_end(); // Add link to show birthdays $link = ''; diff --git a/htdocs/comm/admin/propal_extrafields.php b/htdocs/comm/admin/propal_extrafields.php index f926afb56a9..79836087775 100644 --- a/htdocs/comm/admin/propal_extrafields.php +++ b/htdocs/comm/admin/propal_extrafields.php @@ -72,7 +72,7 @@ print dol_get_fiche_head($head, 'attributes', $langs->trans("Proposals"), -1, 'p require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php'; -dol_fiche_end(); +print dol_get_fiche_end(); // Buttons diff --git a/htdocs/comm/admin/propaldet_extrafields.php b/htdocs/comm/admin/propaldet_extrafields.php index aa6dac82910..fa12fe9b555 100644 --- a/htdocs/comm/admin/propaldet_extrafields.php +++ b/htdocs/comm/admin/propaldet_extrafields.php @@ -79,7 +79,7 @@ print dol_get_fiche_head($head, 'attributeslines', $langs->trans("Proposals"), - require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php'; -dol_fiche_end(); +print dol_get_fiche_end(); // Buttons diff --git a/htdocs/comm/card.php b/htdocs/comm/card.php index 63a6a24aeaa..df7e96fc742 100644 --- a/htdocs/comm/card.php +++ b/htdocs/comm/card.php @@ -1256,7 +1256,7 @@ if ($object->id > 0) print '
'; print '
'; - dol_fiche_end(); + print dol_get_fiche_end(); /* diff --git a/htdocs/comm/mailing/card.php b/htdocs/comm/mailing/card.php index 812dea03f43..bb74fb686aa 100644 --- a/htdocs/comm/mailing/card.php +++ b/htdocs/comm/mailing/card.php @@ -741,7 +741,7 @@ if ($action == 'create') $doleditor->Create(); print '
'; - dol_fiche_end(); + print dol_get_fiche_end(); print '
'; @@ -923,7 +923,7 @@ if ($action == 'create') print "
"; - dol_fiche_end(); + print dol_get_fiche_end(); // Clone confirmation @@ -1064,7 +1064,7 @@ if ($action == 'create') print '
'; - dol_fiche_end(); + print dol_get_fiche_end(); print dol_set_focus('#sendto'); } @@ -1122,7 +1122,7 @@ if ($action == 'create') } else print dol_htmlentitiesbr($object->body); print '
'; - dol_fiche_end(); + print dol_get_fiche_end(); } else { /* * Edition mode mailing (CKeditor or HTML source) @@ -1195,7 +1195,7 @@ if ($action == 'create') print ''; print '
'; - dol_fiche_end(); + print dol_get_fiche_end(); @@ -1289,7 +1289,7 @@ if ($action == 'create') print ''; - dol_fiche_end(); + print dol_get_fiche_end(); print '
'; print ''; diff --git a/htdocs/comm/mailing/cibles.php b/htdocs/comm/mailing/cibles.php index 2b59550cf2b..7c219cc448a 100644 --- a/htdocs/comm/mailing/cibles.php +++ b/htdocs/comm/mailing/cibles.php @@ -305,7 +305,7 @@ if ($object->fetch($id) >= 0) print "
"; - dol_fiche_end(); + print dol_get_fiche_end(); print '
'; diff --git a/htdocs/comm/mailing/info.php b/htdocs/comm/mailing/info.php index 05ae0885ba8..199a5caad8b 100644 --- a/htdocs/comm/mailing/info.php +++ b/htdocs/comm/mailing/info.php @@ -81,7 +81,7 @@ if ($object->fetch($id) >= 0) //print ''; - dol_fiche_end(); + print dol_get_fiche_end(); } // End of page diff --git a/htdocs/comm/multiprix.php b/htdocs/comm/multiprix.php index 6bd1fe715e3..bd4c16f89ca 100644 --- a/htdocs/comm/multiprix.php +++ b/htdocs/comm/multiprix.php @@ -105,7 +105,7 @@ if ($_socid > 0) print ""; - dol_fiche_end(); + print dol_get_fiche_end(); print '
'; diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php index 3a9fc38fbaf..f03986d471c 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -287,7 +287,7 @@ if (empty($reshook)) dol_print_error($db, $object->error); } elseif ($action == 'setdate_livraison' && $usercancreate) { - $result = $object->set_delivery_date($user, dol_mktime(12, 0, 0, $_POST['date_livraisonmonth'], $_POST['date_livraisonday'], $_POST['date_livraisonyear'])); + $result = $object->setDeliveryDate($user, dol_mktime(12, 0, 0, $_POST['date_livraisonmonth'], $_POST['date_livraisonday'], $_POST['date_livraisonyear'])); if ($result < 0) dol_print_error($db, $object->error); } // Positionne ref client @@ -806,7 +806,7 @@ if (empty($reshook)) $tva_tx = ''; } - $qty = GETPOST('qty'.$predef); + $qty = price2num(GETPOST('qty'.$predef), 'MS'); $remise_percent = GETPOST('remise_percent'.$predef); if (empty($remise_percent)) $remise_percent = 0; @@ -1234,7 +1234,10 @@ if (empty($reshook)) } } } - $result = $object->updateline(GETPOST('lineid'), $pu_ht, GETPOST('qty'), GETPOST('remise_percent'), $vat_rate, $localtax1_rate, $localtax2_rate, $description, 'HT', $info_bits, $special_code, GETPOST('fk_parent_line'), 0, $fournprice, $buyingprice, $label, $type, $date_start, $date_end, $array_options, $_POST["units"], $pu_ht_devise); + + $qty = price2num(GETPOST('qty'), 'MS'); + + $result = $object->updateline(GETPOST('lineid', 'int'), $pu_ht, $qty, GETPOST('remise_percent'), $vat_rate, $localtax1_rate, $localtax2_rate, $description, 'HT', $info_bits, $special_code, GETPOST('fk_parent_line'), 0, $fournprice, $buyingprice, $label, $type, $date_start, $date_end, $array_options, $_POST["units"], $pu_ht_devise); if ($result >= 0) { $db->commit(); @@ -1776,7 +1779,7 @@ if ($action == 'create') print ''; } - dol_fiche_end(); + print dol_get_fiche_end(); $langs->load("bills"); print '
'; @@ -2387,7 +2390,7 @@ if ($action == 'create') print "\n"; - dol_fiche_end(); + print dol_get_fiche_end(); /* diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index c772044af81..7496f98a394 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -2060,8 +2060,23 @@ class Propal extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** + * Set delivery date + * + * @param User $user Object user that modify + * @param int $delivery_date Delivery date + * @param int $notrigger 1=Does not execute triggers, 0= execute triggers + * @return int <0 if ko, >0 if ok + * @deprecated Use setDeliveryDate + */ + public function set_date_livraison($user, $delivery_date, $notrigger = 0) + { + // phpcs:enable + return $this->setDeliveryDate($user, $delivery_date, $notrigger); + } + + /** * Set delivery date * * @param User $user Object user that modify @@ -2069,9 +2084,8 @@ class Propal extends CommonObject * @param int $notrigger 1=Does not execute triggers, 0= execute triggers * @return int <0 if ko, >0 if ok */ - public function set_delivery_date($user, $delivery_date, $notrigger = 0) + public function setDeliveryDate($user, $delivery_date, $notrigger = 0) { - // phpcs:enable if (!empty($user->rights->propal->creer)) { $error = 0; diff --git a/htdocs/comm/propal/contact.php b/htdocs/comm/propal/contact.php index 7d1cd05c706..9c491c7227c 100644 --- a/htdocs/comm/propal/contact.php +++ b/htdocs/comm/propal/contact.php @@ -188,7 +188,7 @@ if ($object->id > 0) dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref, '', 0, '', '', 1); - dol_fiche_end(); + print dol_get_fiche_end(); // Contacts lines (modules that overwrite templates must declare this into descriptor) diff --git a/htdocs/comm/propal/document.php b/htdocs/comm/propal/document.php index f1eef2164a0..309c2a44ad4 100644 --- a/htdocs/comm/propal/document.php +++ b/htdocs/comm/propal/document.php @@ -172,7 +172,7 @@ if ($object->id > 0) print '
'; - dol_fiche_end(); + print dol_get_fiche_end(); $modulepart = 'propal'; $permission = $user->rights->propal->creer; diff --git a/htdocs/comm/propal/info.php b/htdocs/comm/propal/info.php index fd9595f3579..e56a5129c5c 100644 --- a/htdocs/comm/propal/info.php +++ b/htdocs/comm/propal/info.php @@ -126,7 +126,7 @@ dol_print_object_info($object); print ''; -dol_fiche_end(); +print dol_get_fiche_end(); // End of page llxFooter(); diff --git a/htdocs/comm/propal/note.php b/htdocs/comm/propal/note.php index 1435d7f7f30..80b991a2526 100644 --- a/htdocs/comm/propal/note.php +++ b/htdocs/comm/propal/note.php @@ -140,7 +140,7 @@ if ($id > 0 || !empty($ref)) print ''; - dol_fiche_end(); + print dol_get_fiche_end(); } } } diff --git a/htdocs/comm/propal/stats/index.php b/htdocs/comm/propal/stats/index.php index fe847f6ff64..e439056de5f 100644 --- a/htdocs/comm/propal/stats/index.php +++ b/htdocs/comm/propal/stats/index.php @@ -355,7 +355,7 @@ print ''; print '
'; -dol_fiche_end(); +print dol_get_fiche_end(); // End of page llxFooter(); diff --git a/htdocs/comm/remise.php b/htdocs/comm/remise.php index 753e22a5ce8..21f06e7bc1d 100644 --- a/htdocs/comm/remise.php +++ b/htdocs/comm/remise.php @@ -121,7 +121,7 @@ if ($socid > 0) if (!$isCustomer && !$isSupplier) { print '

'.$langs->trans('ThirdpartyIsNeitherCustomerNorClientSoCannotHaveDiscounts').'

'; - dol_fiche_end(); + print dol_get_fiche_end(); print ''; @@ -189,7 +189,7 @@ if ($socid > 0) print ''; - dol_fiche_end(); + print dol_get_fiche_end(); print '
'; print ''; diff --git a/htdocs/comm/remx.php b/htdocs/comm/remx.php index 1ee05562bf7..922e384af4d 100644 --- a/htdocs/comm/remx.php +++ b/htdocs/comm/remx.php @@ -261,7 +261,7 @@ if ($socid > 0) if (!$isCustomer && !$isSupplier) { print '

'.$langs->trans('ThirdpartyIsNeitherCustomerNorClientSoCannotHaveDiscounts').'

'; - dol_fiche_end(); + print dol_get_fiche_end(); print ''; @@ -336,7 +336,7 @@ if ($socid > 0) print '
'; - dol_fiche_end(); + print dol_get_fiche_end(); if ($user->rights->societe->creer) @@ -375,7 +375,7 @@ if ($socid > 0) print ""; - dol_fiche_end(); + print dol_get_fiche_end(); } if ($user->rights->societe->creer) diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index 585b85def0b..6572a383532 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -541,7 +541,7 @@ if (empty($reshook)) $datedelivery = dol_mktime(GETPOST('liv_hour', 'int'), GETPOST('liv_min', 'int'), 0, GETPOST('liv_month', 'int'), GETPOST('liv_day', 'int'), GETPOST('liv_year', 'int')); $object->fetch($id); - $result = $object->set_delivery_date($user, $datedelivery); + $result = $object->setDeliveryDate($user, $datedelivery); if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); } @@ -1833,7 +1833,7 @@ if ($action == 'create' && $usercancreate) print ''; - dol_fiche_end(); + print dol_get_fiche_end(); // Button "Create Draft" print '
'; @@ -2479,7 +2479,7 @@ if ($action == 'create' && $usercancreate) print "\n"; - dol_fiche_end(); + print dol_get_fiche_end(); /* * Buttons for actions diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index b7095bef93a..fdc9ddaf646 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -478,7 +478,7 @@ class Commande extends CommonOrder $sql .= " fk_user_valid = ".$user->id; $sql .= " WHERE rowid = ".$this->id; - dol_syslog(get_class($this)."::valid()", LOG_DEBUG); + dol_syslog(get_class($this)."::valid", LOG_DEBUG); $resql = $this->db->query($sql); if (!$resql) { @@ -544,7 +544,7 @@ class Commande extends CommonOrder $dirdest = $conf->commande->multidir_output[$this->entity].'/'.$newref; if (!$error && file_exists($dirsource)) { - dol_syslog(get_class($this)."::valid() rename dir ".$dirsource." into ".$dirdest); + dol_syslog(get_class($this)."::valid rename dir ".$dirsource." into ".$dirdest); if (@rename($dirsource, $dirdest)) { @@ -2548,6 +2548,21 @@ class Commande extends CommonOrder } // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Set delivery date + * + * @param User $user Object user that modify + * @param int $delivery_date Delivery date + * @param int $notrigger 1=Does not execute triggers, 0= execute triggers + * @return int <0 if ko, >0 if ok + * @deprecated Use setDeliveryDate + */ + public function set_date_livraison($user, $delivery_date, $notrigger = 0) + { + // phpcs:enable + return $this->setDeliveryDate($user, $delivery_date, $notrigger); + } + /** * Set the planned delivery date * @@ -2556,9 +2571,8 @@ class Commande extends CommonOrder * @param int $notrigger 1=Does not execute triggers, 0= execute triggers * @return int <0 si ko, >0 si ok */ - public function set_delivery_date($user, $delivery_date, $notrigger = 0) + public function setDeliveryDate($user, $delivery_date, $notrigger = 0) { - // phpcs:enable if ($user->rights->commande->creer) { $error = 0; diff --git a/htdocs/commande/contact.php b/htdocs/commande/contact.php index 51b94d82d23..84c4eb5626a 100644 --- a/htdocs/commande/contact.php +++ b/htdocs/commande/contact.php @@ -188,7 +188,7 @@ if ($id > 0 || !empty($ref)) dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref, '', 0, '', '', 1); - dol_fiche_end(); + print dol_get_fiche_end(); print '
'; diff --git a/htdocs/commande/document.php b/htdocs/commande/document.php index 20f49195e10..c3afff9e00d 100644 --- a/htdocs/commande/document.php +++ b/htdocs/commande/document.php @@ -175,7 +175,7 @@ if ($id > 0 || !empty($ref)) print "
\n"; - dol_fiche_end(); + print dol_get_fiche_end(); $modulepart = 'commande'; $permission = $user->rights->commande->creer; diff --git a/htdocs/commande/info.php b/htdocs/commande/info.php index 9001a3ffb51..dd31e547569 100644 --- a/htdocs/commande/info.php +++ b/htdocs/commande/info.php @@ -127,7 +127,7 @@ print ''; print ''; -dol_fiche_end(); +print dol_get_fiche_end(); // End of page llxFooter(); diff --git a/htdocs/commande/note.php b/htdocs/commande/note.php index 9542e432d7e..c996aea7601 100644 --- a/htdocs/commande/note.php +++ b/htdocs/commande/note.php @@ -139,7 +139,7 @@ if ($id > 0 || !empty($ref)) print ''; - dol_fiche_end(); + print dol_get_fiche_end(); } diff --git a/htdocs/commande/stats/index.php b/htdocs/commande/stats/index.php index 13657c61553..1da32f13e80 100644 --- a/htdocs/commande/stats/index.php +++ b/htdocs/commande/stats/index.php @@ -388,7 +388,7 @@ print ''; print ''; print '
'; -dol_fiche_end(); +print dol_get_fiche_end(); // End of page llxFooter(); diff --git a/htdocs/compta/accounting-files.php b/htdocs/compta/accounting-files.php index 221299fe8b7..ac31d091833 100644 --- a/htdocs/compta/accounting-files.php +++ b/htdocs/compta/accounting-files.php @@ -567,7 +567,7 @@ print ' 0 || !empty($ref)) { print ''; - dol_fiche_end(); + print dol_get_fiche_end(); $modulepart = 'bank'; diff --git a/htdocs/compta/bank/annuel.php b/htdocs/compta/bank/annuel.php index 6db4714db3d..f190ddb1471 100644 --- a/htdocs/compta/bank/annuel.php +++ b/htdocs/compta/bank/annuel.php @@ -166,7 +166,7 @@ if (!empty($id)) print $langs->trans("AllAccounts"); } -dol_fiche_end(); +print dol_get_fiche_end(); // Affiche tableau diff --git a/htdocs/compta/bank/bankentries_list.php b/htdocs/compta/bank/bankentries_list.php index e4bed6376f1..5d0df32cd3e 100644 --- a/htdocs/compta/bank/bankentries_list.php +++ b/htdocs/compta/bank/bankentries_list.php @@ -436,7 +436,7 @@ if ($id > 0 || !empty($ref)) dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref, '', 0, '', '', 1); - dol_fiche_end(); + print dol_get_fiche_end(); /* diff --git a/htdocs/compta/bank/card.php b/htdocs/compta/bank/card.php index 7bddd7915cb..8b086516351 100644 --- a/htdocs/compta/bank/card.php +++ b/htdocs/compta/bank/card.php @@ -544,7 +544,7 @@ if ($action == 'create') print ''; - dol_fiche_end(); + print dol_get_fiche_end(); print '
'; print ''; @@ -752,7 +752,7 @@ if ($action == 'create') print '
'; - dol_fiche_end(); + print dol_get_fiche_end(); /* * Barre d'actions @@ -1028,7 +1028,7 @@ if ($action == 'create') print ''; } - dol_fiche_end(); + print dol_get_fiche_end(); print '
'; print ''; diff --git a/htdocs/compta/bank/document.php b/htdocs/compta/bank/document.php index 1369a629d2f..896b91545db 100644 --- a/htdocs/compta/bank/document.php +++ b/htdocs/compta/bank/document.php @@ -123,7 +123,7 @@ if ($id > 0 || !empty($ref)) { print '
'; - dol_fiche_end(); + print dol_get_fiche_end(); $modulepart = 'bank'; diff --git a/htdocs/compta/bank/graph.php b/htdocs/compta/bank/graph.php index 496988ba74a..9350e211284 100644 --- a/htdocs/compta/bank/graph.php +++ b/htdocs/compta/bank/graph.php @@ -762,7 +762,7 @@ if ($account) print $langs->trans("AllAccounts"); } -dol_fiche_end(); +print dol_get_fiche_end(); print ''; diff --git a/htdocs/compta/bank/line.php b/htdocs/compta/bank/line.php index eab2c1ad182..7ae7c995935 100644 --- a/htdocs/compta/bank/line.php +++ b/htdocs/compta/bank/line.php @@ -566,7 +566,7 @@ if ($result) print ''; - dol_fiche_end(); + print dol_get_fiche_end(); print '

'; diff --git a/htdocs/compta/bank/releve.php b/htdocs/compta/bank/releve.php index 137712d5cec..166d69fdd30 100644 --- a/htdocs/compta/bank/releve.php +++ b/htdocs/compta/bank/releve.php @@ -251,7 +251,7 @@ if (empty($numref)) dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref, '', 0, '', '', 1); - dol_fiche_end(); + print dol_get_fiche_end(); print '
'; diff --git a/htdocs/compta/bank/treso.php b/htdocs/compta/bank/treso.php index f59723436d2..03844897a15 100644 --- a/htdocs/compta/bank/treso.php +++ b/htdocs/compta/bank/treso.php @@ -96,7 +96,7 @@ if ($_REQUEST["account"] || $_REQUEST["ref"]) dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref, '', 0, '', '', 1); - dol_fiche_end(); + print dol_get_fiche_end(); print '
'; diff --git a/htdocs/compta/bank/various_payment/card.php b/htdocs/compta/bank/various_payment/card.php index 7218a191d1c..8a7f5415339 100644 --- a/htdocs/compta/bank/various_payment/card.php +++ b/htdocs/compta/bank/various_payment/card.php @@ -454,7 +454,7 @@ if ($action == 'create') print '
'; - dol_fiche_end(); + print dol_get_fiche_end(); print '
'; print ''; @@ -603,7 +603,7 @@ if ($id) print '
'; - dol_fiche_end(); + print dol_get_fiche_end(); /* diff --git a/htdocs/compta/bank/various_payment/document.php b/htdocs/compta/bank/various_payment/document.php index 32351e5fe3b..14187bf51e3 100644 --- a/htdocs/compta/bank/various_payment/document.php +++ b/htdocs/compta/bank/various_payment/document.php @@ -143,7 +143,7 @@ if ($object->id) print '
'; - dol_fiche_end(); + print dol_get_fiche_end(); $modulepart = 'banque'; $permission = $user->rights->banque->modifier; diff --git a/htdocs/compta/cashcontrol/cashcontrol_card.php b/htdocs/compta/cashcontrol/cashcontrol_card.php index c63b1f921d6..96299886070 100644 --- a/htdocs/compta/cashcontrol/cashcontrol_card.php +++ b/htdocs/compta/cashcontrol/cashcontrol_card.php @@ -28,6 +28,7 @@ */ require '../../main.inc.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/cashcontrol/class/cashcontrol.class.php'; @@ -659,7 +660,7 @@ if (empty($action) || $action == "view" || $action == "close") print '
'; print '
'; - dol_fiche_end(); + print dol_get_fiche_end(); if ($action != 'close') { print '
'; diff --git a/htdocs/compta/cashcontrol/report.php b/htdocs/compta/cashcontrol/report.php index 02299788794..5df55ab7849 100644 --- a/htdocs/compta/cashcontrol/report.php +++ b/htdocs/compta/cashcontrol/report.php @@ -1,6 +1,6 @@ - * Copyright (C) 2004-2016 Laurent Destailleur + * Copyright (C) 2004-2020 Laurent Destailleur * Copyright (C) 2005-2010 Regis Houssin * Copyright (C) 2012 Vinícius Nogueira * Copyright (C) 2014 Florian Henry @@ -29,13 +29,16 @@ * \brief List of bank transactions */ +if (!defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); // If there is no need to load and show top and left menu +if (!defined('NOBROWSERNOTIF')) define('NOBROWSERNOTIF', '1'); // Disable browser notification + require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/compta/cashcontrol/class/cashcontrol.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/cashcontrol/class/cashcontrol.class.php'; -$langs->load("bills"); +$langs->loadLangs(array("bills", "banks")); $id = GETPOST('id', 'int'); @@ -127,8 +130,9 @@ if ($resql) $num = $db->num_rows($resql); $i = 0; + print "\n"; print "

"; - if ($cashcontrol->status == 2) print $langs->trans("CashControl")." ".$cashcontrol->id; + if ($cashcontrol->status != $cashcontrol::STATUS_DRAFT) print $langs->trans("CashControl")." ".$cashcontrol->id; else print $langs->trans("CashControl")." - ".$langs->trans("Draft"); print "
".$langs->trans("DateCreationShort").": ".dol_print_date($cashcontrol->date_creation, 'dayhour')."

"; diff --git a/htdocs/compta/deplacement/stats/index.php b/htdocs/compta/deplacement/stats/index.php index b17c3f4f9a4..e9a2a3a93a7 100644 --- a/htdocs/compta/deplacement/stats/index.php +++ b/htdocs/compta/deplacement/stats/index.php @@ -306,7 +306,7 @@ print '
'; print '
'; -dol_fiche_end(); +print dol_get_fiche_end(); // End of page llxFooter(); diff --git a/htdocs/compta/facture/admin/facture_cust_extrafields.php b/htdocs/compta/facture/admin/facture_cust_extrafields.php index 16327c8b348..54234b4a10c 100644 --- a/htdocs/compta/facture/admin/facture_cust_extrafields.php +++ b/htdocs/compta/facture/admin/facture_cust_extrafields.php @@ -73,7 +73,7 @@ print dol_get_fiche_head($head, 'attributes', $langs->trans("Invoices"), -1, 'in require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php'; -dol_fiche_end(); +print dol_get_fiche_end(); // Buttons diff --git a/htdocs/compta/facture/admin/facture_rec_cust_extrafields.php b/htdocs/compta/facture/admin/facture_rec_cust_extrafields.php index 50a7fd18586..3f85d7ba074 100644 --- a/htdocs/compta/facture/admin/facture_rec_cust_extrafields.php +++ b/htdocs/compta/facture/admin/facture_rec_cust_extrafields.php @@ -74,7 +74,7 @@ print dol_get_fiche_head($head, 'attributesrec', $langs->trans("Invoices"), -1, require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php'; -dol_fiche_end(); +print dol_get_fiche_end(); // Buttons diff --git a/htdocs/compta/facture/admin/facturedet_cust_extrafields.php b/htdocs/compta/facture/admin/facturedet_cust_extrafields.php index 2b9e37e43c6..5b1daff5913 100644 --- a/htdocs/compta/facture/admin/facturedet_cust_extrafields.php +++ b/htdocs/compta/facture/admin/facturedet_cust_extrafields.php @@ -74,7 +74,7 @@ print dol_get_fiche_head($head, 'attributeslines', $langs->trans("Invoices"), -1 require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php'; -dol_fiche_end(); +print dol_get_fiche_end(); // Buttons diff --git a/htdocs/compta/facture/admin/facturedet_rec_cust_extrafields.php b/htdocs/compta/facture/admin/facturedet_rec_cust_extrafields.php index 58fd39e33fe..539fb89e675 100644 --- a/htdocs/compta/facture/admin/facturedet_rec_cust_extrafields.php +++ b/htdocs/compta/facture/admin/facturedet_rec_cust_extrafields.php @@ -74,7 +74,7 @@ print dol_get_fiche_head($head, 'attributeslinesrec', $langs->trans("Invoices"), require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php'; -dol_fiche_end(); +print dol_get_fiche_end(); // Buttons diff --git a/htdocs/compta/facture/card-rec.php b/htdocs/compta/facture/card-rec.php index 4a9a0a197b3..0d483665e40 100644 --- a/htdocs/compta/facture/card-rec.php +++ b/htdocs/compta/facture/card-rec.php @@ -1056,7 +1056,7 @@ if ($action == 'create') print ""; - dol_fiche_end(); + print dol_get_fiche_end(); // Autogeneration @@ -1102,7 +1102,7 @@ if ($action == 'create') print ""; - dol_fiche_end(); + print dol_get_fiche_end(); $title = $langs->trans("ProductsAndServices"); @@ -1641,7 +1641,7 @@ if ($action == 'create') print "\n"; - dol_fiche_end(); + print dol_get_fiche_end(); /** diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index ae58bfc5f55..80e60dd8784 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -3623,7 +3623,7 @@ if ($action == 'create') print "\n"; - dol_fiche_end(); + print dol_get_fiche_end(); // Button "Create Draft" print '
'; @@ -5035,7 +5035,7 @@ if ($action == 'create') print "\n"; - dol_fiche_end(); + print dol_get_fiche_end(); // Actions buttons diff --git a/htdocs/compta/facture/class/facture-rec.class.php b/htdocs/compta/facture/class/facture-rec.class.php index 8aeaa2a9fe8..5771ead70f1 100644 --- a/htdocs/compta/facture/class/facture-rec.class.php +++ b/htdocs/compta/facture/class/facture-rec.class.php @@ -97,7 +97,7 @@ class FactureRec extends CommonInvoice */ public $frequency; - /** + /** * @var string Unit frequency */ public $unit_frequency; @@ -317,46 +317,46 @@ class FactureRec extends CommonInvoice $tva_tx = $facsrc->lines[$i]->tva_tx; if (!empty($facsrc->lines[$i]->vat_src_code) && !preg_match('/\(/', $tva_tx)) $tva_tx .= ' ('.$facsrc->lines[$i]->vat_src_code.')'; - $result_insert = $this->addline( - $facsrc->lines[$i]->desc, - $facsrc->lines[$i]->subprice, - $facsrc->lines[$i]->qty, + $result_insert = $this->addline( + $facsrc->lines[$i]->desc, + $facsrc->lines[$i]->subprice, + $facsrc->lines[$i]->qty, $tva_tx, - $facsrc->lines[$i]->localtax1_tx, - $facsrc->lines[$i]->localtax2_tx, - $facsrc->lines[$i]->fk_product, - $facsrc->lines[$i]->remise_percent, - 'HT', + $facsrc->lines[$i]->localtax1_tx, + $facsrc->lines[$i]->localtax2_tx, + $facsrc->lines[$i]->fk_product, + $facsrc->lines[$i]->remise_percent, + 'HT', $facsrc->lines[$i]->info_bits, - '', - 0, - $facsrc->lines[$i]->product_type, - $facsrc->lines[$i]->rang, - $facsrc->lines[$i]->special_code, - $facsrc->lines[$i]->label, + '', + 0, + $facsrc->lines[$i]->product_type, + $facsrc->lines[$i]->rang, + $facsrc->lines[$i]->special_code, + $facsrc->lines[$i]->label, $facsrc->lines[$i]->fk_unit, $facsrc->lines[$i]->multicurrency_subprice - ); + ); if ($result_insert < 0) { $error++; } else { - $objectline = new FactureLigneRec($this->db); - if ($objectline->fetch($result_insert)) - { - // Extrafields - if (method_exists($facsrc->lines[$i], 'fetch_optionals')) { - $facsrc->lines[$i]->fetch_optionals($facsrc->lines[$i]->rowid); - $objectline->array_options = $facsrc->lines[$i]->array_options; - } + $objectline = new FactureLigneRec($this->db); + if ($objectline->fetch($result_insert)) + { + // Extrafields + if (method_exists($facsrc->lines[$i], 'fetch_optionals')) { + $facsrc->lines[$i]->fetch_optionals($facsrc->lines[$i]->rowid); + $objectline->array_options = $facsrc->lines[$i]->array_options; + } - $result = $objectline->insertExtraFields(); - if ($result < 0) - { - $error++; - } - } + $result = $objectline->insertExtraFields(); + if ($result < 0) + { + $error++; + } + } } } @@ -370,27 +370,27 @@ class FactureRec extends CommonInvoice { foreach ($this->linked_objects as $origin => $tmp_origin_id) { - if (is_array($tmp_origin_id)) // New behaviour, if linked_object can have several links per type, so is something like array('contract'=>array(id1, id2, ...)) - { - foreach ($tmp_origin_id as $origin_id) - { - $ret = $this->add_object_linked($origin, $origin_id); - if (!$ret) - { - $this->error = $this->db->lasterror(); - $error++; - } - } - } else // Old behaviour, if linked_object has only one link per type, so is something like array('contract'=>id1)) - { - $origin_id = $tmp_origin_id; - $ret = $this->add_object_linked($origin, $origin_id); - if (!$ret) - { - $this->error = $this->db->lasterror(); - $error++; - } - } + if (is_array($tmp_origin_id)) // New behaviour, if linked_object can have several links per type, so is something like array('contract'=>array(id1, id2, ...)) + { + foreach ($tmp_origin_id as $origin_id) + { + $ret = $this->add_object_linked($origin, $origin_id); + if (!$ret) + { + $this->error = $this->db->lasterror(); + $error++; + } + } + } else // Old behaviour, if linked_object has only one link per type, so is something like array('contract'=>id1)) + { + $origin_id = $tmp_origin_id; + $ret = $this->add_object_linked($origin, $origin_id); + if (!$ret) + { + $this->error = $this->db->lasterror(); + $error++; + } + } } } @@ -422,7 +422,7 @@ class FactureRec extends CommonInvoice return $this->id; } } else { - $this->error = $this->db->lasterror(); + $this->error = $this->db->lasterror(); $this->db->rollback(); return -2; } @@ -442,46 +442,46 @@ class FactureRec extends CommonInvoice */ public function update(User $user, $notrigger = 0) { - global $conf; + global $conf; - $error = 0; + $error = 0; - $sql = "UPDATE ".MAIN_DB_PREFIX."facture_rec SET"; - $sql .= " fk_soc = ".$this->fk_soc; - // TODO Add missing fields - $sql .= " WHERE rowid = ".$this->id; + $sql = "UPDATE ".MAIN_DB_PREFIX."facture_rec SET"; + $sql .= " fk_soc = ".$this->fk_soc; + // TODO Add missing fields + $sql .= " WHERE rowid = ".$this->id; - dol_syslog(get_class($this)."::update", LOG_DEBUG); - $resql = $this->db->query($sql); - if ($resql) - { - if (!$error) - { - $result = $this->insertExtraFields(); - if ($result < 0) - { - $error++; - } - } + dol_syslog(get_class($this)."::update", LOG_DEBUG); + $resql = $this->db->query($sql); + if ($resql) + { + if (!$error) + { + $result = $this->insertExtraFields(); + if ($result < 0) + { + $error++; + } + } - if (!$error && !$notrigger) - { - // Call trigger - $result = $this->call_trigger('BILLREC_UPDATE', $user); - if ($result < 0) - { - $this->db->rollback(); - return -2; - } - // End call triggers - } - $this->db->commit(); - return 1; - } else { - $this->error = $this->db->lasterror(); - $this->db->rollback(); - return -2; - } + if (!$error && !$notrigger) + { + // Call trigger + $result = $this->call_trigger('BILLREC_UPDATE', $user); + if ($result < 0) + { + $this->db->rollback(); + return -2; + } + // End call triggers + } + $this->db->commit(); + return 1; + } else { + $this->error = $this->db->lasterror(); + $this->db->rollback(); + return -2; + } } /** @@ -498,13 +498,13 @@ class FactureRec extends CommonInvoice $sql .= ', f.remise_percent, f.remise_absolue, f.remise'; $sql .= ', f.date_lim_reglement as dlr'; $sql .= ', f.note_private, f.note_public, f.fk_user_author'; - $sql .= ', f.modelpdf'; + $sql .= ', f.modelpdf'; $sql .= ', f.fk_mode_reglement, f.fk_cond_reglement, f.fk_projet as fk_project'; $sql .= ', f.fk_account'; $sql .= ', f.frequency, f.unit_frequency, f.date_when, f.date_last_gen, f.nb_gen_done, f.nb_gen_max, f.usenewprice, f.auto_validate'; - $sql .= ', f.generate_pdf'; - $sql .= ", f.fk_multicurrency, f.multicurrency_code, f.multicurrency_tx, f.multicurrency_total_ht, f.multicurrency_total_tva, f.multicurrency_total_ttc"; - $sql .= ', p.code as mode_reglement_code, p.libelle as mode_reglement_libelle'; + $sql .= ', f.generate_pdf'; + $sql .= ", f.fk_multicurrency, f.multicurrency_code, f.multicurrency_tx, f.multicurrency_total_ht, f.multicurrency_total_tva, f.multicurrency_total_ttc"; + $sql .= ', p.code as mode_reglement_code, p.libelle as mode_reglement_libelle'; $sql .= ', c.code as cond_reglement_code, c.libelle as cond_reglement_libelle, c.libelle_facture as cond_reglement_libelle_doc'; //$sql.= ', el.fk_source'; $sql .= ' FROM '.MAIN_DB_PREFIX.'facture_rec as f'; @@ -618,21 +618,21 @@ class FactureRec extends CommonInvoice */ public function getLinesArray() { - return $this->fetch_lines(); + return $this->fetch_lines(); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Get lines of template invoices into this->lines * * @return int 1 if OK, < 0 if KO - */ + */ public function fetch_lines() { global $extrafields; - // phpcs:enable + // phpcs:enable $this->lines = array(); // Retrieve all extrafield for line @@ -710,7 +710,7 @@ class FactureRec extends CommonInvoice $line->rang = $objp->rang; $line->special_code = $objp->special_code; $line->fk_unit = $objp->fk_unit; - $line->fk_contract_line = $objp->fk_contract_line; + $line->fk_contract_line = $objp->fk_contract_line; // Ne plus utiliser $line->price = $objp->price; @@ -750,17 +750,17 @@ class FactureRec extends CommonInvoice */ public function delete(User $user, $notrigger = 0, $idwarehouse = -1) { - $rowid = $this->id; + $rowid = $this->id; - dol_syslog(get_class($this)."::delete rowid=".$rowid, LOG_DEBUG); + dol_syslog(get_class($this)."::delete rowid=".$rowid, LOG_DEBUG); - $error = 0; + $error = 0; $this->db->begin(); $main = MAIN_DB_PREFIX.'facturedet_rec'; - $ef = $main."_extrafields"; - $sqlef = "DELETE FROM $ef WHERE fk_object IN (SELECT rowid FROM $main WHERE fk_facture = $rowid)"; - dol_syslog($sqlef); + $ef = $main."_extrafields"; + $sqlef = "DELETE FROM $ef WHERE fk_object IN (SELECT rowid FROM $main WHERE fk_facture = $rowid)"; + dol_syslog($sqlef); $sql = "DELETE FROM ".MAIN_DB_PREFIX."facturedet_rec WHERE fk_facture = ".$rowid; dol_syslog($sql); if ($this->db->query($sqlef) && $this->db->query($sql)) @@ -773,8 +773,8 @@ class FactureRec extends CommonInvoice $res = $this->deleteObjectLinked(); if ($res < 0) $error = -3; // Delete extrafields - $res = $this->deleteExtraFields(); - if ($res < 0) $error = -4; + $res = $this->deleteExtraFields(); + if ($res < 0) $error = -4; } else { $this->error = $this->db->lasterror(); $error = -1; @@ -786,11 +786,11 @@ class FactureRec extends CommonInvoice if (!$error) { - $this->db->commit(); - return 1; + $this->db->commit(); + return 1; } else { - $this->db->rollback(); - return $error; + $this->db->rollback(); + return $error; } } @@ -798,33 +798,33 @@ class FactureRec extends CommonInvoice /** * Add a line to invoice * - * @param string $desc Description de la ligne - * @param double $pu_ht Prix unitaire HT (> 0 even for credit note) - * @param double $qty Quantite - * @param double $txtva Taux de tva force, sinon -1 + * @param string $desc Description de la ligne + * @param double $pu_ht Prix unitaire HT (> 0 even for credit note) + * @param double $qty Quantite + * @param double $txtva Taux de tva force, sinon -1 * @param double $txlocaltax1 Local tax 1 rate (deprecated) * @param double $txlocaltax2 Local tax 2 rate (deprecated) - * @param int $fk_product Product/Service ID predefined - * @param double $remise_percent Percentage discount of the line - * @param string $price_base_type HT or TTC - * @param int $info_bits VAT npr or not ? - * @param int $fk_remise_except Id remise - * @param double $pu_ttc Prix unitaire TTC (> 0 even for credit note) - * @param int $type Type of line (0=product, 1=service) - * @param int $rang Position of line - * @param int $special_code Special code - * @param string $label Label of the line - * @param string $fk_unit Unit + * @param int $fk_product Product/Service ID predefined + * @param double $remise_percent Percentage discount of the line + * @param string $price_base_type HT or TTC + * @param int $info_bits VAT npr or not ? + * @param int $fk_remise_except Id remise + * @param double $pu_ttc Prix unitaire TTC (> 0 even for credit note) + * @param int $type Type of line (0=product, 1=service) + * @param int $rang Position of line + * @param int $special_code Special code + * @param string $label Label of the line + * @param string $fk_unit Unit * @param double $pu_ht_devise Unit price in currency * @param int $date_start_fill 1=Flag to fill start date when generating invoice * @param int $date_end_fill 1=Flag to fill end date when generating invoice * @param int $fk_fournprice Supplier price id (to calculate margin) or '' * @param int $pa_ht Buying price of line (to calculate margin) or '' - * @return int <0 if KO, Id of line if OK + * @return int <0 if KO, Id of line if OK */ public function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1 = 0, $txlocaltax2 = 0, $fk_product = 0, $remise_percent = 0, $price_base_type = 'HT', $info_bits = 0, $fk_remise_except = '', $pu_ttc = 0, $type = 0, $rang = -1, $special_code = 0, $label = '', $fk_unit = null, $pu_ht_devise = 0, $date_start_fill = 0, $date_end_fill = 0, $fk_fournprice = null, $pa_ht = 0) { - global $mysoc; + global $mysoc; $facid = $this->id; @@ -1008,131 +1008,131 @@ class FactureRec extends CommonInvoice */ public function updateline($rowid, $desc, $pu_ht, $qty, $txtva, $txlocaltax1 = 0, $txlocaltax2 = 0, $fk_product = 0, $remise_percent = 0, $price_base_type = 'HT', $info_bits = 0, $fk_remise_except = '', $pu_ttc = 0, $type = 0, $rang = -1, $special_code = 0, $label = '', $fk_unit = null, $pu_ht_devise = 0, $notrigger = 0, $date_start_fill = 0, $date_end_fill = 0, $fk_fournprice = null, $pa_ht = 0) { - global $mysoc; + global $mysoc; - $facid = $this->id; + $facid = $this->id; - dol_syslog(get_class($this)."::updateline facid=".$facid." rowid=$rowid, desc=$desc, pu_ht=$pu_ht, qty=$qty, txtva=$txtva, txlocaltax1=$txlocaltax1, txlocaltax2=$txlocaltax2, fk_product=$fk_product, remise_percent=$remise_percent, info_bits=$info_bits, fk_remise_except=$fk_remise_except, price_base_type=$price_base_type, pu_ttc=$pu_ttc, type=$type, fk_unit=$fk_unit, pu_ht_devise=$pu_ht_devise", LOG_DEBUG); - include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php'; + dol_syslog(get_class($this)."::updateline facid=".$facid." rowid=$rowid, desc=$desc, pu_ht=$pu_ht, qty=$qty, txtva=$txtva, txlocaltax1=$txlocaltax1, txlocaltax2=$txlocaltax2, fk_product=$fk_product, remise_percent=$remise_percent, info_bits=$info_bits, fk_remise_except=$fk_remise_except, price_base_type=$price_base_type, pu_ttc=$pu_ttc, type=$type, fk_unit=$fk_unit, pu_ht_devise=$pu_ht_devise", LOG_DEBUG); + include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php'; - // Clean parameters - if (empty($remise_percent)) $remise_percent = 0; + // Clean parameters + if (empty($remise_percent)) $remise_percent = 0; - // Check parameters - if ($type < 0) return -1; + // Check parameters + if ($type < 0) return -1; - if ($this->brouillon) - { - // Clean parameters - $remise_percent = price2num($remise_percent); - $qty = price2num($qty); - if (empty($info_bits)) $info_bits = 0; - $pu_ht = price2num($pu_ht); - $pu_ttc = price2num($pu_ttc); - $pu_ht_devise = price2num($pu_ht_devise); - $txtva = price2num($txtva); - $txlocaltax1 = price2num($txlocaltax1); - $txlocaltax2 = price2num($txlocaltax2); - if (empty($txlocaltax1)) $txlocaltax1 = 0; - if (empty($txlocaltax2)) $txlocaltax2 = 0; + if ($this->brouillon) + { + // Clean parameters + $remise_percent = price2num($remise_percent); + $qty = price2num($qty); + if (empty($info_bits)) $info_bits = 0; + $pu_ht = price2num($pu_ht); + $pu_ttc = price2num($pu_ttc); + $pu_ht_devise = price2num($pu_ht_devise); + $txtva = price2num($txtva); + $txlocaltax1 = price2num($txlocaltax1); + $txlocaltax2 = price2num($txlocaltax2); + if (empty($txlocaltax1)) $txlocaltax1 = 0; + if (empty($txlocaltax2)) $txlocaltax2 = 0; - if (empty($this->multicurrency_subprice)) $this->multicurrency_subprice = 0; - if (empty($this->multicurrency_total_ht)) $this->multicurrency_total_ht = 0; - if (empty($this->multicurrency_total_tva)) $this->multicurrency_total_tva = 0; - if (empty($this->multicurrency_total_ttc)) $this->multicurrency_total_ttc = 0; + if (empty($this->multicurrency_subprice)) $this->multicurrency_subprice = 0; + if (empty($this->multicurrency_total_ht)) $this->multicurrency_total_ht = 0; + if (empty($this->multicurrency_total_tva)) $this->multicurrency_total_tva = 0; + if (empty($this->multicurrency_total_ttc)) $this->multicurrency_total_ttc = 0; - if ($price_base_type == 'HT') - { - $pu = $pu_ht; - } else { - $pu = $pu_ttc; - } + if ($price_base_type == 'HT') + { + $pu = $pu_ht; + } else { + $pu = $pu_ttc; + } - // Calculate total with, without tax and tax from qty, pu, remise_percent and txtva - // TRES IMPORTANT: C'est au moment de l'insertion ligne qu'on doit stocker - // la part ht, tva et ttc, et ce au niveau de la ligne qui a son propre taux tva. + // Calculate total with, without tax and tax from qty, pu, remise_percent and txtva + // TRES IMPORTANT: C'est au moment de l'insertion ligne qu'on doit stocker + // la part ht, tva et ttc, et ce au niveau de la ligne qui a son propre taux tva. - $localtaxes_type = getLocalTaxesFromRate($txtva, 0, $this->thirdparty, $mysoc); + $localtaxes_type = getLocalTaxesFromRate($txtva, 0, $this->thirdparty, $mysoc); - // Clean vat code - $vat_src_code = ''; - if (preg_match('/\((.*)\)/', $txtva, $reg)) - { - $vat_src_code = $reg[1]; - $txtva = preg_replace('/\s*\(.*\)/', '', $txtva); // Remove code into vatrate. - } + // Clean vat code + $vat_src_code = ''; + if (preg_match('/\((.*)\)/', $txtva, $reg)) + { + $vat_src_code = $reg[1]; + $txtva = preg_replace('/\s*\(.*\)/', '', $txtva); // Remove code into vatrate. + } - $tabprice = calcul_price_total($qty, $pu, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, 0, $price_base_type, $info_bits, $type, $mysoc, $localtaxes_type, 100, $this->multicurrency_tx, $pu_ht_devise); + $tabprice = calcul_price_total($qty, $pu, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, 0, $price_base_type, $info_bits, $type, $mysoc, $localtaxes_type, 100, $this->multicurrency_tx, $pu_ht_devise); - $total_ht = $tabprice[0]; - $total_tva = $tabprice[1]; - $total_ttc = $tabprice[2]; - $total_localtax1 = $tabprice[9]; - $total_localtax2 = $tabprice[10]; - $pu_ht = $tabprice[3]; - $pu_tva = $tabprice[4]; - $pu_ttc = $tabprice[5]; + $total_ht = $tabprice[0]; + $total_tva = $tabprice[1]; + $total_ttc = $tabprice[2]; + $total_localtax1 = $tabprice[9]; + $total_localtax2 = $tabprice[10]; + $pu_ht = $tabprice[3]; + $pu_tva = $tabprice[4]; + $pu_ttc = $tabprice[5]; - // MultiCurrency - $multicurrency_total_ht = $tabprice[16]; - $multicurrency_total_tva = $tabprice[17]; - $multicurrency_total_ttc = $tabprice[18]; - $pu_ht_devise = $tabprice[19]; + // MultiCurrency + $multicurrency_total_ht = $tabprice[16]; + $multicurrency_total_tva = $tabprice[17]; + $multicurrency_total_ttc = $tabprice[18]; + $pu_ht_devise = $tabprice[19]; - $product_type = $type; - if ($fk_product) - { - $product = new Product($this->db); - $result = $product->fetch($fk_product); - $product_type = $product->type; - } + $product_type = $type; + if ($fk_product) + { + $product = new Product($this->db); + $result = $product->fetch($fk_product); + $product_type = $product->type; + } - $sql = "UPDATE ".MAIN_DB_PREFIX."facturedet_rec SET "; - $sql .= "fk_facture = ".((int) $facid); - $sql .= ", label=".(!empty($label) ? "'".$this->db->escape($label)."'" : "null"); - $sql .= ", description='".$this->db->escape($desc)."'"; - $sql .= ", price=".price2num($pu_ht); - $sql .= ", qty=".price2num($qty); - $sql .= ", tva_tx=".price2num($txtva); - $sql .= ", vat_src_code='".$this->db->escape($vat_src_code)."'"; - $sql .= ", localtax1_tx=".$txlocaltax1; - $sql .= ", localtax1_type='".$this->db->escape($localtaxes_type[0])."'"; - $sql .= ", localtax2_tx=".$txlocaltax2; - $sql .= ", localtax2_type='".$this->db->escape($localtaxes_type[2])."'"; - $sql .= ", fk_product=".(!empty($fk_product) ? "'".$this->db->escape($fk_product)."'" : "null"); - $sql .= ", product_type=".$product_type; - $sql .= ", remise_percent='".price2num($remise_percent)."'"; - $sql .= ", subprice='".price2num($pu_ht)."'"; - $sql .= ", total_ht='".price2num($total_ht)."'"; - $sql .= ", total_tva='".price2num($total_tva)."'"; - $sql .= ", total_localtax1='".price2num($total_localtax1)."'"; - $sql .= ", total_localtax2='".price2num($total_localtax2)."'"; - $sql .= ", total_ttc='".price2num($total_ttc)."'"; - $sql .= ", date_start_fill=".((int) $date_start_fill); - $sql .= ", date_end_fill=".((int) $date_end_fill); - $sql .= ", fk_product_fournisseur_price=".($fk_fournprice > 0 ? $fk_fournprice : 'null'); - $sql .= ", buy_price_ht=".($pa_ht ? price2num($pa_ht) : 0); - $sql .= ", info_bits=".$info_bits; - $sql .= ", rang=".$rang; - $sql .= ", special_code=".$special_code; - $sql .= ", fk_unit=".($fk_unit ? "'".$this->db->escape($fk_unit)."'" : "null"); - $sql .= ', multicurrency_subprice = '.$pu_ht_devise; - $sql .= ', multicurrency_total_ht = '.$multicurrency_total_ht; - $sql .= ', multicurrency_total_tva = '.$multicurrency_total_tva; - $sql .= ', multicurrency_total_ttc = '.$multicurrency_total_ttc; - $sql .= " WHERE rowid = ".$rowid; + $sql = "UPDATE ".MAIN_DB_PREFIX."facturedet_rec SET "; + $sql .= "fk_facture = ".((int) $facid); + $sql .= ", label=".(!empty($label) ? "'".$this->db->escape($label)."'" : "null"); + $sql .= ", description='".$this->db->escape($desc)."'"; + $sql .= ", price=".price2num($pu_ht); + $sql .= ", qty=".price2num($qty); + $sql .= ", tva_tx=".price2num($txtva); + $sql .= ", vat_src_code='".$this->db->escape($vat_src_code)."'"; + $sql .= ", localtax1_tx=".$txlocaltax1; + $sql .= ", localtax1_type='".$this->db->escape($localtaxes_type[0])."'"; + $sql .= ", localtax2_tx=".$txlocaltax2; + $sql .= ", localtax2_type='".$this->db->escape($localtaxes_type[2])."'"; + $sql .= ", fk_product=".(!empty($fk_product) ? "'".$this->db->escape($fk_product)."'" : "null"); + $sql .= ", product_type=".$product_type; + $sql .= ", remise_percent='".price2num($remise_percent)."'"; + $sql .= ", subprice='".price2num($pu_ht)."'"; + $sql .= ", total_ht='".price2num($total_ht)."'"; + $sql .= ", total_tva='".price2num($total_tva)."'"; + $sql .= ", total_localtax1='".price2num($total_localtax1)."'"; + $sql .= ", total_localtax2='".price2num($total_localtax2)."'"; + $sql .= ", total_ttc='".price2num($total_ttc)."'"; + $sql .= ", date_start_fill=".((int) $date_start_fill); + $sql .= ", date_end_fill=".((int) $date_end_fill); + $sql .= ", fk_product_fournisseur_price=".($fk_fournprice > 0 ? $fk_fournprice : 'null'); + $sql .= ", buy_price_ht=".($pa_ht ? price2num($pa_ht) : 0); + $sql .= ", info_bits=".$info_bits; + $sql .= ", rang=".$rang; + $sql .= ", special_code=".$special_code; + $sql .= ", fk_unit=".($fk_unit ? "'".$this->db->escape($fk_unit)."'" : "null"); + $sql .= ', multicurrency_subprice = '.$pu_ht_devise; + $sql .= ', multicurrency_total_ht = '.$multicurrency_total_ht; + $sql .= ', multicurrency_total_tva = '.$multicurrency_total_tva; + $sql .= ', multicurrency_total_ttc = '.$multicurrency_total_ttc; + $sql .= " WHERE rowid = ".$rowid; - dol_syslog(get_class($this)."::updateline", LOG_DEBUG); - if ($this->db->query($sql)) - { - $this->id = $facid; - $this->update_price(); - return 1; - } else { - $this->error = $this->db->lasterror(); - return -1; - } - } + dol_syslog(get_class($this)."::updateline", LOG_DEBUG); + if ($this->db->query($sql)) + { + $this->id = $facid; + $this->update_price(); + return 1; + } else { + $this->error = $this->db->lasterror(); + return -1; + } + } } @@ -1328,8 +1328,8 @@ class FactureRec extends CommonInvoice * @param int $max Maxlength of ref * @param int $short 1=Return just URL * @param string $moretitle Add more text to title tooltip - * @param int $notooltip 1=Disable tooltip - * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking + * @param int $notooltip 1=Disable tooltip + * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking * @return string String with URL */ public function getNomUrl($withpicto = 0, $option = '', $max = 0, $short = 0, $moretitle = '', $notooltip = '', $save_lastsearch_value = -1) @@ -1356,17 +1356,17 @@ class FactureRec extends CommonInvoice } } - $url = DOL_URL_ROOT.'/compta/facture/card-rec.php?facid='.$this->id; + $url = DOL_URL_ROOT.'/compta/facture/card-rec.php?facid='.$this->id; - if ($short) return $url; + if ($short) return $url; - if ($option != 'nolink') - { - // Add param to save lastsearch_values or not - $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0); - if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values = 1; - if ($add_save_lastsearch_values) $url .= '&save_lastsearch_values=1'; - } + if ($option != 'nolink') + { + // Add param to save lastsearch_values or not + $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0); + if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values = 1; + if ($add_save_lastsearch_values) $url .= '&save_lastsearch_values=1'; + } $linkstart = ''; $linkend = ''; @@ -1391,7 +1391,7 @@ class FactureRec extends CommonInvoice return $this->LibStatut($this->frequency ? 1 : 0, $this->suspended, $mode, $alreadypaid, empty($this->type) ? 0 : $this->type); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return label of a status * @@ -1404,7 +1404,7 @@ class FactureRec extends CommonInvoice */ public function LibStatut($recur, $status, $mode = 0, $alreadypaid = -1, $type = 0) { - // phpcs:enable + // phpcs:enable global $langs; $langs->load('bills'); @@ -1553,7 +1553,7 @@ class FactureRec extends CommonInvoice $arraynow = dol_getdate($now); $nownotime = dol_mktime(0, 0, 0, $arraynow['mon'], $arraynow['mday'], $arraynow['year']); - // Load array of products prodids + // Load array of products prodids $num_prods = 0; $prodids = array(); @@ -1690,190 +1690,190 @@ class FactureRec extends CommonInvoice } /** - * Update frequency and unit - * - * @param int $frequency value of frequency - * @param string $unit unit of frequency (d, m, y) - * @return int <0 if KO, >0 if OK - */ - public function setFrequencyAndUnit($frequency, $unit) - { - if (!$this->table_element) { - dol_syslog(get_class($this)."::setFrequencyAndUnit was called on objet with property table_element not defined", LOG_ERR); - return -1; - } - - if (!empty($frequency) && empty($unit)) { - dol_syslog(get_class($this)."::setFrequencyAndUnit was called on objet with params frequency defined but unit not defined", LOG_ERR); - return -2; - } - - $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; - $sql .= ' SET frequency = '.($frequency ? $this->db->escape($frequency) : 'null'); - if (!empty($unit)) { - $sql .= ', unit_frequency = \''.$this->db->escape($unit).'\''; + * Update frequency and unit + * + * @param int $frequency value of frequency + * @param string $unit unit of frequency (d, m, y) + * @return int <0 if KO, >0 if OK + */ + public function setFrequencyAndUnit($frequency, $unit) + { + if (!$this->table_element) { + dol_syslog(get_class($this)."::setFrequencyAndUnit was called on objet with property table_element not defined", LOG_ERR); + return -1; } - $sql .= ' WHERE rowid = '.$this->id; - dol_syslog(get_class($this)."::setFrequencyAndUnit", LOG_DEBUG); - if ($this->db->query($sql)) { - $this->frequency = $frequency; - if (!empty($unit)) $this->unit_frequency = $unit; - return 1; - } else { - dol_print_error($this->db); - return -1; - } - } + if (!empty($frequency) && empty($unit)) { + dol_syslog(get_class($this)."::setFrequencyAndUnit was called on objet with params frequency defined but unit not defined", LOG_ERR); + return -2; + } + + $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; + $sql .= ' SET frequency = '.($frequency ? $this->db->escape($frequency) : 'null'); + if (!empty($unit)) { + $sql .= ', unit_frequency = \''.$this->db->escape($unit).'\''; + } + $sql .= ' WHERE rowid = '.$this->id; + + dol_syslog(get_class($this)."::setFrequencyAndUnit", LOG_DEBUG); + if ($this->db->query($sql)) { + $this->frequency = $frequency; + if (!empty($unit)) $this->unit_frequency = $unit; + return 1; + } else { + dol_print_error($this->db); + return -1; + } + } /** - * Update the next date of execution - * - * @param datetime $date date of execution - * @param int $increment_nb_gen_done 0 do nothing more, >0 increment nb_gen_done - * @return int <0 if KO, >0 if OK - */ - public function setNextDate($date, $increment_nb_gen_done = 0) - { - if (!$this->table_element) - { - dol_syslog(get_class($this)."::setNextDate was called on objet with property table_element not defined", LOG_ERR); - return -1; - } - $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; - $sql .= " SET date_when = ".($date ? "'".$this->db->idate($date)."'" : "null"); - if ($increment_nb_gen_done > 0) $sql .= ', nb_gen_done = nb_gen_done + 1'; - $sql .= ' WHERE rowid = '.$this->id; + * Update the next date of execution + * + * @param datetime $date date of execution + * @param int $increment_nb_gen_done 0 do nothing more, >0 increment nb_gen_done + * @return int <0 if KO, >0 if OK + */ + public function setNextDate($date, $increment_nb_gen_done = 0) + { + if (!$this->table_element) + { + dol_syslog(get_class($this)."::setNextDate was called on objet with property table_element not defined", LOG_ERR); + return -1; + } + $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; + $sql .= " SET date_when = ".($date ? "'".$this->db->idate($date)."'" : "null"); + if ($increment_nb_gen_done > 0) $sql .= ', nb_gen_done = nb_gen_done + 1'; + $sql .= ' WHERE rowid = '.$this->id; - dol_syslog(get_class($this)."::setNextDate", LOG_DEBUG); - if ($this->db->query($sql)) - { - $this->date_when = $date; - if ($increment_nb_gen_done > 0) $this->nb_gen_done++; - return 1; - } else { - dol_print_error($this->db); - return -1; - } - } + dol_syslog(get_class($this)."::setNextDate", LOG_DEBUG); + if ($this->db->query($sql)) + { + $this->date_when = $date; + if ($increment_nb_gen_done > 0) $this->nb_gen_done++; + return 1; + } else { + dol_print_error($this->db); + return -1; + } + } /** - * Update the maximum period - * - * @param int $nb number of maximum period - * @return int <0 if KO, >0 if OK - */ - public function setMaxPeriod($nb) - { - if (!$this->table_element) - { - dol_syslog(get_class($this)."::setMaxPeriod was called on objet with property table_element not defined", LOG_ERR); - return -1; - } + * Update the maximum period + * + * @param int $nb number of maximum period + * @return int <0 if KO, >0 if OK + */ + public function setMaxPeriod($nb) + { + if (!$this->table_element) + { + dol_syslog(get_class($this)."::setMaxPeriod was called on objet with property table_element not defined", LOG_ERR); + return -1; + } - if (empty($nb)) $nb = 0; + if (empty($nb)) $nb = 0; - $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; - $sql .= ' SET nb_gen_max = '.$nb; - $sql .= ' WHERE rowid = '.$this->id; + $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; + $sql .= ' SET nb_gen_max = '.$nb; + $sql .= ' WHERE rowid = '.$this->id; - dol_syslog(get_class($this)."::setMaxPeriod", LOG_DEBUG); - if ($this->db->query($sql)) - { - $this->nb_gen_max = $nb; - return 1; - } else { - dol_print_error($this->db); - return -1; - } - } + dol_syslog(get_class($this)."::setMaxPeriod", LOG_DEBUG); + if ($this->db->query($sql)) + { + $this->nb_gen_max = $nb; + return 1; + } else { + dol_print_error($this->db); + return -1; + } + } /** - * Update the auto validate flag of invoice - * - * @param int $validate 0 to create in draft, 1 to create and validate invoice - * @return int <0 if KO, >0 if OK - */ - public function setAutoValidate($validate) - { - if (!$this->table_element) - { - dol_syslog(get_class($this)."::setAutoValidate was called on objet with property table_element not defined", LOG_ERR); - return -1; - } + * Update the auto validate flag of invoice + * + * @param int $validate 0 to create in draft, 1 to create and validate invoice + * @return int <0 if KO, >0 if OK + */ + public function setAutoValidate($validate) + { + if (!$this->table_element) + { + dol_syslog(get_class($this)."::setAutoValidate was called on objet with property table_element not defined", LOG_ERR); + return -1; + } - $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; - $sql .= ' SET auto_validate = '.$validate; - $sql .= ' WHERE rowid = '.$this->id; + $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; + $sql .= ' SET auto_validate = '.$validate; + $sql .= ' WHERE rowid = '.$this->id; - dol_syslog(get_class($this)."::setAutoValidate", LOG_DEBUG); - if ($this->db->query($sql)) - { - $this->auto_validate = $validate; - return 1; - } else { - dol_print_error($this->db); - return -1; - } - } + dol_syslog(get_class($this)."::setAutoValidate", LOG_DEBUG); + if ($this->db->query($sql)) + { + $this->auto_validate = $validate; + return 1; + } else { + dol_print_error($this->db); + return -1; + } + } - /** - * Update the auto generate documents - * - * @param int $validate 0 no document, 1 to generate document - * @return int <0 if KO, >0 if OK - */ - public function setGeneratePdf($validate) - { - if (!$this->table_element) - { - dol_syslog(get_class($this)."::setGeneratePdf was called on objet with property table_element not defined", LOG_ERR); - return -1; - } + /** + * Update the auto generate documents + * + * @param int $validate 0 no document, 1 to generate document + * @return int <0 if KO, >0 if OK + */ + public function setGeneratePdf($validate) + { + if (!$this->table_element) + { + dol_syslog(get_class($this)."::setGeneratePdf was called on objet with property table_element not defined", LOG_ERR); + return -1; + } - $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; - $sql .= ' SET generate_pdf = '.$validate; - $sql .= ' WHERE rowid = '.$this->id; + $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; + $sql .= ' SET generate_pdf = '.$validate; + $sql .= ' WHERE rowid = '.$this->id; - dol_syslog(get_class($this)."::setGeneratePdf", LOG_DEBUG); - if ($this->db->query($sql)) - { - $this->generate_pdf = $validate; - return 1; - } else { - dol_print_error($this->db); - return -1; - } - } + dol_syslog(get_class($this)."::setGeneratePdf", LOG_DEBUG); + if ($this->db->query($sql)) + { + $this->generate_pdf = $validate; + return 1; + } else { + dol_print_error($this->db); + return -1; + } + } - /** - * Update the model for documents - * - * @param string $model model of document generator - * @return int <0 if KO, >0 if OK - */ - public function setModelPdf($model) - { - if (!$this->table_element) - { - dol_syslog(get_class($this)."::setModelPdf was called on objet with property table_element not defined", LOG_ERR); - return -1; - } + /** + * Update the model for documents + * + * @param string $model model of document generator + * @return int <0 if KO, >0 if OK + */ + public function setModelPdf($model) + { + if (!$this->table_element) + { + dol_syslog(get_class($this)."::setModelPdf was called on objet with property table_element not defined", LOG_ERR); + return -1; + } - $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; - $sql .= ' SET modelpdf = "'.$model.'"'; - $sql .= ' WHERE rowid = '.$this->id; + $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; + $sql .= ' SET modelpdf = "'.$model.'"'; + $sql .= ' WHERE rowid = '.$this->id; - dol_syslog(get_class($this)."::setModelPdf", LOG_DEBUG); - if ($this->db->query($sql)) - { - $this->modelpdf = $model; - return 1; - } else { - dol_print_error($this->db); - return -1; - } - } + dol_syslog(get_class($this)."::setModelPdf", LOG_DEBUG); + if ($this->db->query($sql)) + { + $this->modelpdf = $model; + return 1; + } else { + dol_print_error($this->db); + return -1; + } + } } @@ -1898,206 +1898,206 @@ class FactureLigneRec extends CommonInvoiceLine public $date_end_fill; - /** - * Delete line in database - * - * @param User $user Object user - * @param int $notrigger Disable triggers - * @return int <0 if KO, >0 if OK - */ - public function delete(User $user, $notrigger = false) - { - $error = 0; + /** + * Delete line in database + * + * @param User $user Object user + * @param int $notrigger Disable triggers + * @return int <0 if KO, >0 if OK + */ + public function delete(User $user, $notrigger = false) + { + $error = 0; - $this->db->begin(); + $this->db->begin(); - if (!$error) { - if (!$notrigger) { - // Call triggers - $result = $this->call_trigger('LINEBILLREC_DELETE', $user); - if ($result < 0) { $error++; } // Do also here what you must do to rollback action if trigger fail - // End call triggers - } - } + if (!$error) { + if (!$notrigger) { + // Call triggers + $result = $this->call_trigger('LINEBILLREC_DELETE', $user); + if ($result < 0) { $error++; } // Do also here what you must do to rollback action if trigger fail + // End call triggers + } + } if (!$error) - { - $result = $this->deleteExtraFields(); - if ($result < 0) { - $error++; - } - } - - if (!$error) - { - $sql = 'DELETE FROM '.MAIN_DB_PREFIX.$this->table_element.' WHERE rowid='.$this->id; - - $res = $this->db->query($sql); - if ($res === false) { - $error++; - $this->errors[] = $this->db->lasterror(); - } - } - - // Commit or rollback - if ($error) { - $this->db->rollback(); - return -1; - } else { - $this->db->commit(); - return 1; + { + $result = $this->deleteExtraFields(); + if ($result < 0) { + $error++; + } } - } + + if (!$error) + { + $sql = 'DELETE FROM '.MAIN_DB_PREFIX.$this->table_element.' WHERE rowid='.$this->id; + + $res = $this->db->query($sql); + if ($res === false) { + $error++; + $this->errors[] = $this->db->lasterror(); + } + } + + // Commit or rollback + if ($error) { + $this->db->rollback(); + return -1; + } else { + $this->db->commit(); + return 1; + } + } - /** - * Get line of template invoice - * - * @param int $rowid Id of invoice - * @return int 1 if OK, < 0 if KO - */ - public function fetch($rowid) - { - $sql = 'SELECT l.rowid, l.fk_facture ,l.fk_product, l.product_type, l.label as custom_label, l.description, l.product_type, l.price, l.qty, l.vat_src_code, l.tva_tx,'; - $sql .= ' l.localtax1_tx, l.localtax2_tx, l.localtax1_type, l.localtax2_type, l.remise, l.remise_percent, l.subprice,'; - $sql .= ' l.date_start_fill, l.date_end_fill, l.info_bits, l.total_ht, l.total_tva, l.total_ttc,'; - $sql .= ' l.rang, l.special_code,'; - $sql .= ' l.fk_unit, l.fk_contract_line,'; - $sql .= ' p.ref as product_ref, p.fk_product_type as fk_product_type, p.label as product_label, p.description as product_desc'; - $sql .= ' FROM '.MAIN_DB_PREFIX.'facturedet_rec as l'; - $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON l.fk_product = p.rowid'; - $sql .= ' WHERE l.rowid = '.$rowid; - $sql .= ' ORDER BY l.rang'; + /** + * Get line of template invoice + * + * @param int $rowid Id of invoice + * @return int 1 if OK, < 0 if KO + */ + public function fetch($rowid) + { + $sql = 'SELECT l.rowid, l.fk_facture ,l.fk_product, l.product_type, l.label as custom_label, l.description, l.product_type, l.price, l.qty, l.vat_src_code, l.tva_tx,'; + $sql .= ' l.localtax1_tx, l.localtax2_tx, l.localtax1_type, l.localtax2_type, l.remise, l.remise_percent, l.subprice,'; + $sql .= ' l.date_start_fill, l.date_end_fill, l.info_bits, l.total_ht, l.total_tva, l.total_ttc,'; + $sql .= ' l.rang, l.special_code,'; + $sql .= ' l.fk_unit, l.fk_contract_line,'; + $sql .= ' p.ref as product_ref, p.fk_product_type as fk_product_type, p.label as product_label, p.description as product_desc'; + $sql .= ' FROM '.MAIN_DB_PREFIX.'facturedet_rec as l'; + $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON l.fk_product = p.rowid'; + $sql .= ' WHERE l.rowid = '.$rowid; + $sql .= ' ORDER BY l.rang'; - dol_syslog('FactureRec::fetch', LOG_DEBUG); - $result = $this->db->query($sql); - if ($result) - { - $objp = $this->db->fetch_object($result); + dol_syslog('FactureRec::fetch', LOG_DEBUG); + $result = $this->db->query($sql); + if ($result) + { + $objp = $this->db->fetch_object($result); - $this->id = $objp->rowid; - $this->label = $objp->custom_label; // Label line - $this->desc = $objp->description; // Description line - $this->description = $objp->description; // Description line - $this->product_type = $objp->product_type; // Type of line - $this->ref = $objp->product_ref; // Ref product - $this->product_ref = $objp->product_ref; // Ref product - $this->libelle = $objp->product_label; // deprecated - $this->product_label = $objp->product_label; // Label product - $this->product_desc = $objp->product_desc; // Description product - $this->fk_product_type = $objp->fk_product_type; // Type of product - $this->qty = $objp->qty; - $this->price = $objp->price; - $this->subprice = $objp->subprice; - $this->fk_facture = $objp->fk_facture; - $this->vat_src_code = $objp->vat_src_code; - $this->tva_tx = $objp->tva_tx; - $this->localtax1_tx = $objp->localtax1_tx; - $this->localtax2_tx = $objp->localtax2_tx; - $this->localtax1_type = $objp->localtax1_type; - $this->localtax2_type = $objp->localtax2_type; - $this->remise_percent = $objp->remise_percent; - $this->fk_remise_except = $objp->fk_remise_except; - $this->fk_product = $objp->fk_product; - $this->date_start_fill = $objp->date_start_fill; - $this->date_end_fill = $objp->date_end_fill; - $this->info_bits = $objp->info_bits; - $this->total_ht = $objp->total_ht; - $this->total_tva = $objp->total_tva; - $this->total_ttc = $objp->total_ttc; - $this->code_ventilation = $objp->fk_code_ventilation; - $this->rang = $objp->rang; - $this->special_code = $objp->special_code; - $this->fk_unit = $objp->fk_unit; - $this->fk_contract_line = $objp->fk_contract_line; + $this->id = $objp->rowid; + $this->label = $objp->custom_label; // Label line + $this->desc = $objp->description; // Description line + $this->description = $objp->description; // Description line + $this->product_type = $objp->product_type; // Type of line + $this->ref = $objp->product_ref; // Ref product + $this->product_ref = $objp->product_ref; // Ref product + $this->libelle = $objp->product_label; // deprecated + $this->product_label = $objp->product_label; // Label product + $this->product_desc = $objp->product_desc; // Description product + $this->fk_product_type = $objp->fk_product_type; // Type of product + $this->qty = $objp->qty; + $this->price = $objp->price; + $this->subprice = $objp->subprice; + $this->fk_facture = $objp->fk_facture; + $this->vat_src_code = $objp->vat_src_code; + $this->tva_tx = $objp->tva_tx; + $this->localtax1_tx = $objp->localtax1_tx; + $this->localtax2_tx = $objp->localtax2_tx; + $this->localtax1_type = $objp->localtax1_type; + $this->localtax2_type = $objp->localtax2_type; + $this->remise_percent = $objp->remise_percent; + $this->fk_remise_except = $objp->fk_remise_except; + $this->fk_product = $objp->fk_product; + $this->date_start_fill = $objp->date_start_fill; + $this->date_end_fill = $objp->date_end_fill; + $this->info_bits = $objp->info_bits; + $this->total_ht = $objp->total_ht; + $this->total_tva = $objp->total_tva; + $this->total_ttc = $objp->total_ttc; + $this->code_ventilation = $objp->fk_code_ventilation; + $this->rang = $objp->rang; + $this->special_code = $objp->special_code; + $this->fk_unit = $objp->fk_unit; + $this->fk_contract_line = $objp->fk_contract_line; - $this->db->free($result); - return 1; - } else { - $this->error = $this->db->lasterror(); - return -3; - } - } + $this->db->free($result); + return 1; + } else { + $this->error = $this->db->lasterror(); + return -3; + } + } - /** - * Update a line to invoice_rec. - * - * @param User $user User - * @param int $notrigger No trigger - * @return int <0 if KO, Id of line if OK - */ - public function update(User $user, $notrigger = 0) - { - global $conf; + /** + * Update a line to invoice_rec. + * + * @param User $user User + * @param int $notrigger No trigger + * @return int <0 if KO, Id of line if OK + */ + public function update(User $user, $notrigger = 0) + { + global $conf; - $error = 0; + $error = 0; - include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php'; + include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php'; - $sql = "UPDATE ".MAIN_DB_PREFIX."facturedet_rec SET"; - $sql .= " fk_facture = ".$this->fk_facture; - $sql .= ", label=".(!empty($this->label) ? "'".$this->db->escape($this->label)."'" : "null"); - $sql .= ", description='".$this->db->escape($this->desc)."'"; - $sql .= ", price=".price2num($this->price); - $sql .= ", qty=".price2num($this->qty); - $sql .= ", tva_tx=".price2num($this->tva_tx); - $sql .= ", vat_src_code='".$this->db->escape($this->vat_src_code)."'"; - $sql .= ", localtax1_tx=".price2num($this->localtax1_tx); - $sql .= ", localtax1_type='".$this->db->escape($this->localtax1_type)."'"; - $sql .= ", localtax2_tx=".price2num($this->localtax2_tx); - $sql .= ", localtax2_type='".$this->db->escape($this->localtax2_type)."'"; - $sql .= ", fk_product=".($this->fk_product > 0 ? $this->fk_product : "null"); - $sql .= ", product_type=".$this->product_type; - $sql .= ", remise_percent='".price2num($this->remise_percent)."'"; - $sql .= ", subprice='".price2num($this->subprice)."'"; - $sql .= ", info_bits='".price2num($this->info_bits)."'"; - $sql .= ", date_start_fill=".(int) $this->date_start_fill; - $sql .= ", date_end_fill=".(int) $this->date_end_fill; - if (empty($this->skip_update_total)) { - $sql .= ", total_ht=".price2num($this->total_ht); - $sql .= ", total_tva=".price2num($this->total_tva); - $sql .= ", total_localtax1=".price2num($this->total_localtax1); - $sql .= ", total_localtax2=".price2num($this->total_localtax2); - $sql .= ", total_ttc=".price2num($this->total_ttc); - } - $sql .= ", rang=".$this->rang; - $sql .= ", special_code=".$this->special_code; - $sql .= ", fk_unit=".($this->fk_unit ? "'".$this->db->escape($this->fk_unit)."'" : "null"); - $sql .= ", fk_contract_line=".($this->fk_contract_line ? $this->fk_contract_line : "null"); - $sql .= " WHERE rowid = ".$this->id; + $sql = "UPDATE ".MAIN_DB_PREFIX."facturedet_rec SET"; + $sql .= " fk_facture = ".$this->fk_facture; + $sql .= ", label=".(!empty($this->label) ? "'".$this->db->escape($this->label)."'" : "null"); + $sql .= ", description='".$this->db->escape($this->desc)."'"; + $sql .= ", price=".price2num($this->price); + $sql .= ", qty=".price2num($this->qty); + $sql .= ", tva_tx=".price2num($this->tva_tx); + $sql .= ", vat_src_code='".$this->db->escape($this->vat_src_code)."'"; + $sql .= ", localtax1_tx=".price2num($this->localtax1_tx); + $sql .= ", localtax1_type='".$this->db->escape($this->localtax1_type)."'"; + $sql .= ", localtax2_tx=".price2num($this->localtax2_tx); + $sql .= ", localtax2_type='".$this->db->escape($this->localtax2_type)."'"; + $sql .= ", fk_product=".($this->fk_product > 0 ? $this->fk_product : "null"); + $sql .= ", product_type=".$this->product_type; + $sql .= ", remise_percent='".price2num($this->remise_percent)."'"; + $sql .= ", subprice='".price2num($this->subprice)."'"; + $sql .= ", info_bits='".price2num($this->info_bits)."'"; + $sql .= ", date_start_fill=".(int) $this->date_start_fill; + $sql .= ", date_end_fill=".(int) $this->date_end_fill; + if (empty($this->skip_update_total)) { + $sql .= ", total_ht=".price2num($this->total_ht); + $sql .= ", total_tva=".price2num($this->total_tva); + $sql .= ", total_localtax1=".price2num($this->total_localtax1); + $sql .= ", total_localtax2=".price2num($this->total_localtax2); + $sql .= ", total_ttc=".price2num($this->total_ttc); + } + $sql .= ", rang=".$this->rang; + $sql .= ", special_code=".$this->special_code; + $sql .= ", fk_unit=".($this->fk_unit ? "'".$this->db->escape($this->fk_unit)."'" : "null"); + $sql .= ", fk_contract_line=".($this->fk_contract_line ? $this->fk_contract_line : "null"); + $sql .= " WHERE rowid = ".$this->id; - dol_syslog(get_class($this)."::updateline", LOG_DEBUG); - $resql = $this->db->query($sql); - if ($resql) - { - if (!$error) - { - $result = $this->insertExtraFields(); - if ($result < 0) - { - $error++; - } - } + dol_syslog(get_class($this)."::updateline", LOG_DEBUG); + $resql = $this->db->query($sql); + if ($resql) + { + if (!$error) + { + $result = $this->insertExtraFields(); + if ($result < 0) + { + $error++; + } + } - if (!$error && !$notrigger) - { - // Call trigger - $result = $this->call_trigger('LINEBILLREC_UPDATE', $user); - if ($result < 0) - { - $this->db->rollback(); - return -2; - } - // End call triggers - } - $this->db->commit(); - return 1; - } else { - $this->error = $this->db->lasterror(); - $this->db->rollback(); - return -2; - } - } + if (!$error && !$notrigger) + { + // Call trigger + $result = $this->call_trigger('LINEBILLREC_UPDATE', $user); + if ($result < 0) + { + $this->db->rollback(); + return -2; + } + // End call triggers + } + $this->db->commit(); + return 1; + } else { + $this->error = $this->db->lasterror(); + $this->db->rollback(); + return -2; + } + } } diff --git a/htdocs/compta/facture/contact.php b/htdocs/compta/facture/contact.php index f50f6b85a55..fc66715dd3d 100644 --- a/htdocs/compta/facture/contact.php +++ b/htdocs/compta/facture/contact.php @@ -185,7 +185,7 @@ if ($id > 0 || !empty($ref)) dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref, '', 0, '', '', 1); - dol_fiche_end(); + print dol_get_fiche_end(); print '
'; diff --git a/htdocs/compta/facture/document.php b/htdocs/compta/facture/document.php index 548fefab0fa..e001b203296 100644 --- a/htdocs/compta/facture/document.php +++ b/htdocs/compta/facture/document.php @@ -174,7 +174,7 @@ if ($id > 0 || !empty($ref)) print "
\n"; - dol_fiche_end(); + print dol_get_fiche_end(); $modulepart = 'facture'; $permission = $user->rights->facture->creer; diff --git a/htdocs/compta/facture/info.php b/htdocs/compta/facture/info.php index a7af3893883..f26f4ea0255 100644 --- a/htdocs/compta/facture/info.php +++ b/htdocs/compta/facture/info.php @@ -120,7 +120,7 @@ print ''; print ''; -dol_fiche_end(); +print dol_get_fiche_end(); // End of page llxFooter(); diff --git a/htdocs/compta/facture/note.php b/htdocs/compta/facture/note.php index 76c6833c07b..a2343171d66 100644 --- a/htdocs/compta/facture/note.php +++ b/htdocs/compta/facture/note.php @@ -139,7 +139,7 @@ if ($id > 0 || !empty($ref)) $cssclass = "titlefield"; include DOL_DOCUMENT_ROOT.'/core/tpl/notes.tpl.php'; - dol_fiche_end(); + print dol_get_fiche_end(); } // End of page diff --git a/htdocs/compta/facture/prelevement.php b/htdocs/compta/facture/prelevement.php index 2f44b0b2437..eea3b29aa36 100644 --- a/htdocs/compta/facture/prelevement.php +++ b/htdocs/compta/facture/prelevement.php @@ -573,7 +573,7 @@ if ($object->id > 0) print '
'; - dol_fiche_end(); + print dol_get_fiche_end(); $numopen = 0; $pending = 0; $numclosed = 0; diff --git a/htdocs/compta/facture/stats/index.php b/htdocs/compta/facture/stats/index.php index afbe4528b14..fb1002d45a5 100644 --- a/htdocs/compta/facture/stats/index.php +++ b/htdocs/compta/facture/stats/index.php @@ -381,7 +381,7 @@ print ''; print '
'; -dol_fiche_end(); +print dol_get_fiche_end(); // End of page llxFooter(); diff --git a/htdocs/compta/localtax/card.php b/htdocs/compta/localtax/card.php index b787878f31d..c3700d9e994 100644 --- a/htdocs/compta/localtax/card.php +++ b/htdocs/compta/localtax/card.php @@ -61,44 +61,44 @@ if ($_POST["cancel"] == $langs->trans("Cancel") && !$id) if ($action == 'add' && $_POST["cancel"] <> $langs->trans("Cancel")) { - $db->begin(); + $db->begin(); - $datev = dol_mktime(12, 0, 0, $_POST["datevmonth"], $_POST["datevday"], $_POST["datevyear"]); - $datep = dol_mktime(12, 0, 0, $_POST["datepmonth"], $_POST["datepday"], $_POST["datepyear"]); + $datev = dol_mktime(12, 0, 0, $_POST["datevmonth"], $_POST["datevday"], $_POST["datevyear"]); + $datep = dol_mktime(12, 0, 0, $_POST["datepmonth"], $_POST["datepday"], $_POST["datepyear"]); - $object->accountid = GETPOST("accountid"); - $object->paymenttype = GETPOST("paiementtype"); - $object->datev = $datev; - $object->datep = $datep; - $object->amount = price2num(GETPOST("amount")); + $object->accountid = GETPOST("accountid"); + $object->paymenttype = GETPOST("paiementtype"); + $object->datev = $datev; + $object->datep = $datep; + $object->amount = price2num(GETPOST("amount")); $object->label = GETPOST("label"); $object->ltt = $lttype; - $ret = $object->addPayment($user); - if ($ret > 0) - { - $db->commit(); - header("Location: list.php?localTaxType=".$lttype); - exit; - } else { - $db->rollback(); - setEventMessages($object->error, $object->errors, 'errors'); - $_GET["action"] = "create"; - } + $ret = $object->addPayment($user); + if ($ret > 0) + { + $db->commit(); + header("Location: list.php?localTaxType=".$lttype); + exit; + } else { + $db->rollback(); + setEventMessages($object->error, $object->errors, 'errors'); + $_GET["action"] = "create"; + } } //delete payment of localtax if ($action == 'delete') { - $result = $object->fetch($id); + $result = $object->fetch($id); if ($object->rappro == 0) { - $db->begin(); + $db->begin(); - $ret = $object->delete($user); - if ($ret > 0) - { + $ret = $object->delete($user); + if ($ret > 0) + { if ($object->fk_bank) { $accountline = new AccountLine($db); @@ -116,13 +116,13 @@ if ($action == 'delete') $db->rollback(); setEventMessages($object->error, $object->errors, 'errors'); } - } else { - $db->rollback(); - setEventMessages($object->error, $object->errors, 'errors'); - } + } else { + $db->rollback(); + setEventMessages($object->error, $object->errors, 'errors'); + } } else { - $mesg = 'Error try do delete a line linked to a conciliated bank transaction'; - setEventMessages($mesg, null, 'errors'); + $mesg = 'Error try do delete a line linked to a conciliated bank transaction'; + setEventMessages($mesg, null, 'errors'); } } @@ -149,25 +149,25 @@ llxHeader("", $title, $helpurl); if ($action == 'create') { - print load_fiche_titre($langs->transcountry($lttype == 2 ? "newLT2Payment" : "newLT1Payment", $mysoc->country_code)); + print load_fiche_titre($langs->transcountry($lttype == 2 ? "newLT2Payment" : "newLT1Payment", $mysoc->country_code)); - print '
'."\n"; - print ''; - print ''; - print ''; + print ''."\n"; + print ''; + print ''; + print ''; - print dol_get_fiche_head(); + print dol_get_fiche_head(); - print ''; + print '
'; - print ""; - print ''; + print ""; + print ''; - print ''; + print ''; // Label print ''; @@ -198,7 +198,7 @@ if ($action == 'create') print '
'.$langs->trans("DatePayment").''; - print $form->selectDate($datep, "datep", '', '', '', 'add', 1, 1); - print '
'.$langs->trans("DatePayment").''; + print $form->selectDate($datep, "datep", '', '', '', 'add', 1, 1); + print '
'.$form->textwithpicto($langs->trans("PeriodEndDate"), $langs->trans("LastDayTaxIsRelatedTo")).''; - print $form->selectDate($datev, "datev", '', '', '', 'add', 1, 1); - print '
'.$form->textwithpicto($langs->trans("PeriodEndDate"), $langs->trans("LastDayTaxIsRelatedTo")).''; + print $form->selectDate($datev, "datev", '', '', '', 'add', 1, 1); + print '
'.$langs->trans("Label").'transcountry(($lttype == 2 ? "LT2Payment" : "LT1Payment"), $mysoc->country_code)).'">
'; - dol_fiche_end(); + print dol_get_fiche_end(); print '
'; print ''; @@ -271,7 +271,7 @@ if ($id) print '
'; - dol_fiche_end(); + print dol_get_fiche_end(); /* diff --git a/htdocs/compta/paiement.php b/htdocs/compta/paiement.php index 21e9fba85bc..d1da6de0c3e 100644 --- a/htdocs/compta/paiement.php +++ b/htdocs/compta/paiement.php @@ -528,7 +528,7 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie print ''; - dol_fiche_end(); + print dol_get_fiche_end(); /* diff --git a/htdocs/compta/paiement/card.php b/htdocs/compta/paiement/card.php index 9d0758b48bf..db942328d13 100644 --- a/htdocs/compta/paiement/card.php +++ b/htdocs/compta/paiement/card.php @@ -299,7 +299,7 @@ print ''; print ''; -dol_fiche_end(); +print dol_get_fiche_end(); /* diff --git a/htdocs/compta/paiement/cheque/card.php b/htdocs/compta/paiement/cheque/card.php index 21b7ac83f58..49a8cf5d61b 100644 --- a/htdocs/compta/paiement/cheque/card.php +++ b/htdocs/compta/paiement/cheque/card.php @@ -370,7 +370,7 @@ if ($action == 'new') print ''; print ''; - dol_fiche_end(); + print dol_get_fiche_end(); print '
'; print ''; @@ -719,7 +719,7 @@ if ($action == 'new') dol_print_error($db); } - dol_fiche_end(); + print dol_get_fiche_end(); } diff --git a/htdocs/compta/paiement/info.php b/htdocs/compta/paiement/info.php index a1640f08496..208d74a316f 100644 --- a/htdocs/compta/paiement/info.php +++ b/htdocs/compta/paiement/info.php @@ -74,7 +74,7 @@ print ''; print '
'; -dol_fiche_end(); +print dol_get_fiche_end(); // End of page llxFooter(); diff --git a/htdocs/compta/paiement/list.php b/htdocs/compta/paiement/list.php index f3ea57ea084..b6dbd8195d1 100644 --- a/htdocs/compta/paiement/list.php +++ b/htdocs/compta/paiement/list.php @@ -78,7 +78,7 @@ $pagenext = $page + 1; if (!$sortorder) $sortorder = "DESC"; if (!$sortfield) $sortfield = "p.ref"; -$search_all = trim(GETPOSTISSET("search_all") ? GETPOSTISSET("search_all", 'alpha') : GETPOST('sall')); +$search_all = trim(GETPOSTISSET("search_all") ? GETPOST("search_all", 'alpha') : GETPOST('sall')); // List of fields to search into when doing a "search in all" $fieldstosearchall = array( diff --git a/htdocs/compta/paiement_charge.php b/htdocs/compta/paiement_charge.php index 17970037b4a..e5941624910 100644 --- a/htdocs/compta/paiement_charge.php +++ b/htdocs/compta/paiement_charge.php @@ -252,7 +252,7 @@ if ($action == 'create') print ''; - dol_fiche_end(); + print dol_get_fiche_end(); /* * Other unpaid charges diff --git a/htdocs/compta/payment_sc/card.php b/htdocs/compta/payment_sc/card.php index 6dfa4e3be7a..5ee71863dd2 100644 --- a/htdocs/compta/payment_sc/card.php +++ b/htdocs/compta/payment_sc/card.php @@ -158,7 +158,7 @@ print ''; print ''; -dol_fiche_end(); +print dol_get_fiche_end(); /* diff --git a/htdocs/compta/prelevement/card.php b/htdocs/compta/prelevement/card.php index 69968503a5d..5d87303236a 100644 --- a/htdocs/compta/prelevement/card.php +++ b/htdocs/compta/prelevement/card.php @@ -250,7 +250,7 @@ if ($id > 0 || $ref) print ''; - dol_fiche_end(); + print dol_get_fiche_end(); $formconfirm = ''; diff --git a/htdocs/compta/prelevement/factures.php b/htdocs/compta/prelevement/factures.php index b1a15a766f6..1f8ecdaeced 100644 --- a/htdocs/compta/prelevement/factures.php +++ b/htdocs/compta/prelevement/factures.php @@ -150,7 +150,7 @@ if ($id > 0 || $ref) print ''; - dol_fiche_end(); + print dol_get_fiche_end(); } else { dol_print_error($db); } diff --git a/htdocs/compta/prelevement/fiche-rejet.php b/htdocs/compta/prelevement/fiche-rejet.php index 9135616d915..fb1a9451aed 100644 --- a/htdocs/compta/prelevement/fiche-rejet.php +++ b/htdocs/compta/prelevement/fiche-rejet.php @@ -144,7 +144,7 @@ if ($prev_id > 0 || $ref) print ''; - dol_fiche_end(); + print dol_get_fiche_end(); } else { dol_print_error($db); } diff --git a/htdocs/compta/prelevement/fiche-stat.php b/htdocs/compta/prelevement/fiche-stat.php index 151e53e4a59..81e854ef5a0 100644 --- a/htdocs/compta/prelevement/fiche-stat.php +++ b/htdocs/compta/prelevement/fiche-stat.php @@ -143,7 +143,7 @@ if ($prev_id > 0 || $ref) print ''; - dol_fiche_end(); + print dol_get_fiche_end(); } else { dol_print_error($db); } diff --git a/htdocs/compta/prelevement/line.php b/htdocs/compta/prelevement/line.php index 71f39f6c98d..ccb60486c76 100644 --- a/htdocs/compta/prelevement/line.php +++ b/htdocs/compta/prelevement/line.php @@ -179,7 +179,7 @@ if ($id) } print ''; - dol_fiche_end(); + print dol_get_fiche_end(); } else { dol_print_error($db); } diff --git a/htdocs/compta/recap-compta.php b/htdocs/compta/recap-compta.php index 8e8521e4026..3930d711a1c 100644 --- a/htdocs/compta/recap-compta.php +++ b/htdocs/compta/recap-compta.php @@ -97,7 +97,7 @@ if ($id > 0) print dol_get_fiche_head($head, 'customer', $langs->trans("ThirdParty"), 0, 'company'); dol_banner_tab($object, 'socid', '', ($user->socid ? 0 : 1), 'rowid', 'nom', '', '', 0, '', '', 1); - dol_fiche_end(); + print dol_get_fiche_end(); if (!empty($conf->facture->enabled) && $user->rights->facture->lire) { diff --git a/htdocs/compta/sociales/card.php b/htdocs/compta/sociales/card.php index 98131687cb1..8af8c54752b 100644 --- a/htdocs/compta/sociales/card.php +++ b/htdocs/compta/sociales/card.php @@ -376,7 +376,7 @@ if ($action == 'create') print ''; - dol_fiche_end(); + print dol_get_fiche_end(); print '
'; print ''; @@ -681,7 +681,7 @@ if ($id > 0) print '
'; - dol_fiche_end(); + print dol_get_fiche_end(); if ($action == 'edit') { diff --git a/htdocs/compta/sociales/class/chargesociales.class.php b/htdocs/compta/sociales/class/chargesociales.class.php index 11b225d0896..6e018e0bb84 100644 --- a/htdocs/compta/sociales/class/chargesociales.class.php +++ b/htdocs/compta/sociales/class/chargesociales.class.php @@ -32,79 +32,79 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php'; */ class ChargeSociales extends CommonObject { - /** + /** * @var string ID to identify managed object */ public $element = 'chargesociales'; - public $table = 'chargesociales'; + public $table = 'chargesociales'; - /** + /** * @var string Name of table without prefix where object is stored */ public $table_element = 'chargesociales'; - /** - * @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png - */ - public $picto = 'bill'; - - /** - * {@inheritdoc} - */ - protected $table_ref_field = 'ref'; - - /** - * @var integer|string $date_ech - */ - public $date_ech; - - - public $label; - public $type; - public $type_label; - public $amount; - public $paye; - public $periode; - - /** - * @var integer|string date_creation - */ - public $date_creation; - - /** - * @var integer|string $date_modification - */ - public $date_modification; - - /** - * @var integer|string $date_validation - */ - public $date_validation; - - /** - * @deprecated Use label instead - */ - public $lib; - - /** - * @var int account ID - */ - public $fk_account; + /** + * @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png + */ + public $picto = 'bill'; /** - * @var int account ID (identical to fk_account) - */ - public $accountid; + * {@inheritdoc} + */ + protected $table_ref_field = 'ref'; - /** - * @var int payment type (identical to mode_reglement_id in commonobject class) - */ - public $paiementtype; + /** + * @var integer|string $date_ech + */ + public $date_ech; - /** - * @var int ID - */ + + public $label; + public $type; + public $type_label; + public $amount; + public $paye; + public $periode; + + /** + * @var integer|string date_creation + */ + public $date_creation; + + /** + * @var integer|string $date_modification + */ + public $date_modification; + + /** + * @var integer|string $date_validation + */ + public $date_validation; + + /** + * @deprecated Use label instead + */ + public $lib; + + /** + * @var int account ID + */ + public $fk_account; + + /** + * @var int account ID (identical to fk_account) + */ + public $accountid; + + /** + * @var int payment type (identical to mode_reglement_id in commonobject class) + */ + public $paiementtype; + + /** + * @var int ID + */ public $fk_project; @@ -112,73 +112,73 @@ class ChargeSociales extends CommonObject const STATUS_PAID = 1; - /** - * Constructor - * - * @param DoliDB $db Database handler - */ - public function __construct($db) - { - $this->db = $db; - } + /** + * Constructor + * + * @param DoliDB $db Database handler + */ + public function __construct($db) + { + $this->db = $db; + } - /** - * Retrouve et charge une charge sociale - * - * @param int $id Id - * @param string $ref Ref - * @return int <0 KO >0 OK - */ - public function fetch($id, $ref = '') - { - $sql = "SELECT cs.rowid, cs.date_ech"; - $sql .= ", cs.libelle as label, cs.fk_type, cs.amount, cs.fk_projet as fk_project, cs.paye, cs.periode, cs.import_key"; - $sql .= ", cs.fk_account, cs.fk_mode_reglement"; - $sql .= ", c.libelle"; - $sql .= ', p.code as mode_reglement_code, p.libelle as mode_reglement_libelle'; - $sql .= " FROM ".MAIN_DB_PREFIX."chargesociales as cs"; - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_chargesociales as c ON cs.fk_type = c.id"; - $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as p ON cs.fk_mode_reglement = p.id'; - $sql .= ' WHERE cs.entity IN ('.getEntity('tax').')'; - if ($ref) $sql .= " AND cs.rowid = ".$ref; - else $sql .= " AND cs.rowid = ".$id; + /** + * Retrouve et charge une charge sociale + * + * @param int $id Id + * @param string $ref Ref + * @return int <0 KO >0 OK + */ + public function fetch($id, $ref = '') + { + $sql = "SELECT cs.rowid, cs.date_ech"; + $sql .= ", cs.libelle as label, cs.fk_type, cs.amount, cs.fk_projet as fk_project, cs.paye, cs.periode, cs.import_key"; + $sql .= ", cs.fk_account, cs.fk_mode_reglement"; + $sql .= ", c.libelle"; + $sql .= ', p.code as mode_reglement_code, p.libelle as mode_reglement_libelle'; + $sql .= " FROM ".MAIN_DB_PREFIX."chargesociales as cs"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_chargesociales as c ON cs.fk_type = c.id"; + $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as p ON cs.fk_mode_reglement = p.id'; + $sql .= ' WHERE cs.entity IN ('.getEntity('tax').')'; + if ($ref) $sql .= " AND cs.rowid = ".$ref; + else $sql .= " AND cs.rowid = ".$id; - dol_syslog(get_class($this)."::fetch", LOG_DEBUG); - $resql = $this->db->query($sql); - if ($resql) - { - if ($this->db->num_rows($resql)) - { - $obj = $this->db->fetch_object($resql); + dol_syslog(get_class($this)."::fetch", LOG_DEBUG); + $resql = $this->db->query($sql); + if ($resql) + { + if ($this->db->num_rows($resql)) + { + $obj = $this->db->fetch_object($resql); - $this->id = $obj->rowid; - $this->ref = $obj->rowid; - $this->date_ech = $this->db->jdate($obj->date_ech); - $this->lib = $obj->label; - $this->label = $obj->label; - $this->type = $obj->fk_type; - $this->type_label = $obj->libelle; - $this->fk_account = $obj->fk_account; - $this->mode_reglement_id = $obj->fk_mode_reglement; - $this->mode_reglement_code = $obj->mode_reglement_code; - $this->mode_reglement = $obj->mode_reglement_libelle; - $this->amount = $obj->amount; + $this->id = $obj->rowid; + $this->ref = $obj->rowid; + $this->date_ech = $this->db->jdate($obj->date_ech); + $this->lib = $obj->label; + $this->label = $obj->label; + $this->type = $obj->fk_type; + $this->type_label = $obj->libelle; + $this->fk_account = $obj->fk_account; + $this->mode_reglement_id = $obj->fk_mode_reglement; + $this->mode_reglement_code = $obj->mode_reglement_code; + $this->mode_reglement = $obj->mode_reglement_libelle; + $this->amount = $obj->amount; $this->fk_project = $obj->fk_project; - $this->paye = $obj->paye; - $this->periode = $this->db->jdate($obj->periode); - $this->import_key = $this->import_key; + $this->paye = $obj->paye; + $this->periode = $this->db->jdate($obj->periode); + $this->import_key = $this->import_key; - $this->db->free($resql); + $this->db->free($resql); - return 1; - } else { - return 0; - } - } else { - $this->error = $this->db->lasterror(); - return -1; - } - } + return 1; + } else { + return 0; + } + } else { + $this->error = $this->db->lasterror(); + return -1; + } + } /** * Check if a social contribution can be created into database @@ -189,59 +189,59 @@ class ChargeSociales extends CommonObject { $newamount = price2num($this->amount, 'MT'); - // Validation parametres - if (!$newamount > 0 || empty($this->date_ech) || empty($this->periode)) - { - return false; - } + // Validation parametres + if (!$newamount > 0 || empty($this->date_ech) || empty($this->periode)) + { + return false; + } return true; } - /** - * Create a social contribution into database - * - * @param User $user User making creation - * @return int <0 if KO, id if OK - */ - public function create($user) - { - global $conf; + /** + * Create a social contribution into database + * + * @param User $user User making creation + * @return int <0 if KO, id if OK + */ + public function create($user) + { + global $conf; $error = 0; - $now = dol_now(); + $now = dol_now(); - // Nettoyage parametres - $newamount = price2num($this->amount, 'MT'); + // Nettoyage parametres + $newamount = price2num($this->amount, 'MT'); if (!$this->check()) { $this->error = "ErrorBadParameter"; return -2; } - $this->db->begin(); + $this->db->begin(); - $sql = "INSERT INTO ".MAIN_DB_PREFIX."chargesociales (fk_type, fk_account, fk_mode_reglement, libelle, date_ech, periode, amount, fk_projet, entity, fk_user_author, date_creation)"; - $sql .= " VALUES (".$this->type; - $sql .= ", ".($this->fk_account > 0 ? $this->fk_account : 'NULL'); - $sql .= ", ".($this->mode_reglement_id > 0 ? $this->mode_reglement_id : "NULL"); - $sql .= ", '".$this->db->escape($this->label ? $this->label : $this->lib)."'"; - $sql .= ", '".$this->db->idate($this->date_ech)."'"; + $sql = "INSERT INTO ".MAIN_DB_PREFIX."chargesociales (fk_type, fk_account, fk_mode_reglement, libelle, date_ech, periode, amount, fk_projet, entity, fk_user_author, date_creation)"; + $sql .= " VALUES (".$this->type; + $sql .= ", ".($this->fk_account > 0 ? $this->fk_account : 'NULL'); + $sql .= ", ".($this->mode_reglement_id > 0 ? $this->mode_reglement_id : "NULL"); + $sql .= ", '".$this->db->escape($this->label ? $this->label : $this->lib)."'"; + $sql .= ", '".$this->db->idate($this->date_ech)."'"; $sql .= ", '".$this->db->idate($this->periode)."'"; - $sql .= ", '".price2num($newamount)."'"; + $sql .= ", '".price2num($newamount)."'"; $sql .= ", ".($this->fk_project > 0 ? $this->fk_project : 'NULL'); - $sql .= ", ".$conf->entity; - $sql .= ", ".$user->id; - $sql .= ", '".$this->db->idate($now)."'"; - $sql .= ")"; + $sql .= ", ".$conf->entity; + $sql .= ", ".$user->id; + $sql .= ", '".$this->db->idate($now)."'"; + $sql .= ")"; - dol_syslog(get_class($this)."::create", LOG_DEBUG); - $resql = $this->db->query($sql); - if ($resql) { - $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."chargesociales"); + dol_syslog(get_class($this)."::create", LOG_DEBUG); + $resql = $this->db->query($sql); + if ($resql) { + $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."chargesociales"); - //dol_syslog("ChargesSociales::create this->id=".$this->id); + //dol_syslog("ChargesSociales::create this->id=".$this->id); $result = $this->call_trigger('SOCIALCONTRIBUTION_CREATE', $user); if ($result < 0) $error++; @@ -252,429 +252,429 @@ class ChargeSociales extends CommonObject $this->db->rollback(); return -1 * $error; } - } else { - $this->error = $this->db->error(); - $this->db->rollback(); - return -1; - } - } + } else { + $this->error = $this->db->error(); + $this->db->rollback(); + return -1; + } + } - /** - * Delete a social contribution - * - * @param User $user Object user making delete - * @return int <0 if KO, >0 if OK - */ - public function delete($user) - { - $error = 0; + /** + * Delete a social contribution + * + * @param User $user Object user making delete + * @return int <0 if KO, >0 if OK + */ + public function delete($user) + { + $error = 0; - $this->db->begin(); + $this->db->begin(); - // Get bank transaction lines for this social contributions - include_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; - $account = new Account($this->db); - $lines_url = $account->get_url('', $this->id, 'sc'); + // Get bank transaction lines for this social contributions + include_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; + $account = new Account($this->db); + $lines_url = $account->get_url('', $this->id, 'sc'); - // Delete bank urls - foreach ($lines_url as $line_url) - { - if (!$error) - { - $accountline = new AccountLine($this->db); - $accountline->fetch($line_url['fk_bank']); - $result = $accountline->delete_urls($user); - if ($result < 0) - { - $error++; - } - } - } + // Delete bank urls + foreach ($lines_url as $line_url) + { + if (!$error) + { + $accountline = new AccountLine($this->db); + $accountline->fetch($line_url['fk_bank']); + $result = $accountline->delete_urls($user); + if ($result < 0) + { + $error++; + } + } + } - // Delete payments - if (!$error) - { - $sql = "DELETE FROM ".MAIN_DB_PREFIX."paiementcharge WHERE fk_charge=".$this->id; - dol_syslog(get_class($this)."::delete", LOG_DEBUG); - $resql = $this->db->query($sql); - if (!$resql) - { - $error++; - $this->error = $this->db->lasterror(); - } - } + // Delete payments + if (!$error) + { + $sql = "DELETE FROM ".MAIN_DB_PREFIX."paiementcharge WHERE fk_charge=".$this->id; + dol_syslog(get_class($this)."::delete", LOG_DEBUG); + $resql = $this->db->query($sql); + if (!$resql) + { + $error++; + $this->error = $this->db->lasterror(); + } + } - if (!$error) - { - $sql = "DELETE FROM ".MAIN_DB_PREFIX."chargesociales WHERE rowid=".$this->id; - dol_syslog(get_class($this)."::delete", LOG_DEBUG); - $resql = $this->db->query($sql); - if (!$resql) - { - $error++; - $this->error = $this->db->lasterror(); - } - } + if (!$error) + { + $sql = "DELETE FROM ".MAIN_DB_PREFIX."chargesociales WHERE rowid=".$this->id; + dol_syslog(get_class($this)."::delete", LOG_DEBUG); + $resql = $this->db->query($sql); + if (!$resql) + { + $error++; + $this->error = $this->db->lasterror(); + } + } - if (!$error) - { - $this->db->commit(); - return 1; - } else { - $this->db->rollback(); - return -1; - } - } + if (!$error) + { + $this->db->commit(); + return 1; + } else { + $this->db->rollback(); + return -1; + } + } - /** - * Update social or fiscal contribution - * - * @param User $user User that modify - * @param int $notrigger 0=launch triggers after, 1=disable triggers - * @return int <0 if KO, >0 if OK - */ - public function update($user, $notrigger = 0) - { - $error = 0; - $this->db->begin(); + /** + * Update social or fiscal contribution + * + * @param User $user User that modify + * @param int $notrigger 0=launch triggers after, 1=disable triggers + * @return int <0 if KO, >0 if OK + */ + public function update($user, $notrigger = 0) + { + $error = 0; + $this->db->begin(); - $sql = "UPDATE ".MAIN_DB_PREFIX."chargesociales"; - $sql .= " SET libelle='".$this->db->escape($this->label ? $this->label : $this->lib)."'"; - $sql .= ", date_ech='".$this->db->idate($this->date_ech)."'"; - $sql .= ", periode='".$this->db->idate($this->periode)."'"; - $sql .= ", amount='".price2num($this->amount, 'MT')."'"; - $sql .= ", fk_projet=".($this->fk_project > 0 ? $this->db->escape($this->fk_project) : "NULL"); - $sql .= ", fk_user_modif=".$user->id; - $sql .= " WHERE rowid=".$this->id; + $sql = "UPDATE ".MAIN_DB_PREFIX."chargesociales"; + $sql .= " SET libelle='".$this->db->escape($this->label ? $this->label : $this->lib)."'"; + $sql .= ", date_ech='".$this->db->idate($this->date_ech)."'"; + $sql .= ", periode='".$this->db->idate($this->periode)."'"; + $sql .= ", amount='".price2num($this->amount, 'MT')."'"; + $sql .= ", fk_projet=".($this->fk_project > 0 ? $this->db->escape($this->fk_project) : "NULL"); + $sql .= ", fk_user_modif=".$user->id; + $sql .= " WHERE rowid=".$this->id; - dol_syslog(get_class($this)."::update", LOG_DEBUG); - $resql = $this->db->query($sql); + dol_syslog(get_class($this)."::update", LOG_DEBUG); + $resql = $this->db->query($sql); - if (!$resql) { - $error++; $this->errors[] = "Error ".$this->db->lasterror(); - } + if (!$resql) { + $error++; $this->errors[] = "Error ".$this->db->lasterror(); + } - if (!$error) - { - if (!$notrigger) - { - // Call trigger - $result = $this->call_trigger('SOCIALCHARGES_MODIFY', $user); - if ($result < 0) $error++; - // End call triggers - } - } + if (!$error) + { + if (!$notrigger) + { + // Call trigger + $result = $this->call_trigger('SOCIALCHARGES_MODIFY', $user); + if ($result < 0) $error++; + // End call triggers + } + } - // Commit or rollback - if ($error) - { - foreach ($this->errors as $errmsg) - { - dol_syslog(get_class($this)."::update ".$errmsg, LOG_ERR); - $this->error .= ($this->error ? ', '.$errmsg : $errmsg); - } - $this->db->rollback(); - return -1 * $error; - } else { - $this->db->commit(); - return 1; - } - } + // Commit or rollback + if ($error) + { + foreach ($this->errors as $errmsg) + { + dol_syslog(get_class($this)."::update ".$errmsg, LOG_ERR); + $this->error .= ($this->error ? ', '.$errmsg : $errmsg); + } + $this->db->rollback(); + return -1 * $error; + } else { + $this->db->commit(); + return 1; + } + } - /** - * Calculate amount remaining to pay by year - * - * @param int $year Year - * @return number - */ - public function solde($year = 0) - { - global $conf; + /** + * Calculate amount remaining to pay by year + * + * @param int $year Year + * @return number + */ + public function solde($year = 0) + { + global $conf; - $sql = "SELECT SUM(f.amount) as amount"; - $sql .= " FROM ".MAIN_DB_PREFIX."chargesociales as f"; - $sql .= " WHERE f.entity = ".$conf->entity; - $sql .= " AND paye = 0"; + $sql = "SELECT SUM(f.amount) as amount"; + $sql .= " FROM ".MAIN_DB_PREFIX."chargesociales as f"; + $sql .= " WHERE f.entity = ".$conf->entity; + $sql .= " AND paye = 0"; - if ($year) { - $sql .= " AND f.datev >= '".((int) $year)."-01-01' AND f.datev <= '".((int) $year)."-12-31' "; - } + if ($year) { + $sql .= " AND f.datev >= '".((int) $year)."-01-01' AND f.datev <= '".((int) $year)."-12-31' "; + } - $result = $this->db->query($sql); - if ($result) - { - if ($this->db->num_rows($result)) - { - $obj = $this->db->fetch_object($result); - $this->db->free($result); - return $obj->amount; - } else { - return 0; - } - } else { - print $this->db->error(); - return -1; - } - } + $result = $this->db->query($sql); + if ($result) + { + if ($this->db->num_rows($result)) + { + $obj = $this->db->fetch_object($result); + $this->db->free($result); + return $obj->amount; + } else { + return 0; + } + } else { + print $this->db->error(); + return -1; + } + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Tag social contribution as payed completely - * - * @param User $user Object user making change - * @return int <0 if KO, >0 if OK - */ - public function set_paid($user) - { - // phpcs:enable - $sql = "UPDATE ".MAIN_DB_PREFIX."chargesociales SET"; - $sql .= " paye = 1"; - $sql .= " WHERE rowid = ".$this->id; - $return = $this->db->query($sql); - if ($return) return 1; - else return -1; - } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Tag social contribution as payed completely + * + * @param User $user Object user making change + * @return int <0 if KO, >0 if OK + */ + public function set_paid($user) + { + // phpcs:enable + $sql = "UPDATE ".MAIN_DB_PREFIX."chargesociales SET"; + $sql .= " paye = 1"; + $sql .= " WHERE rowid = ".$this->id; + $return = $this->db->query($sql); + if ($return) return 1; + else return -1; + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Remove tag payed on social contribution - * - * @param User $user Object user making change - * @return int <0 if KO, >0 if OK - */ - public function set_unpaid($user) - { - // phpcs:enable - $sql = "UPDATE ".MAIN_DB_PREFIX."chargesociales SET"; - $sql .= " paye = 0"; - $sql .= " WHERE rowid = ".$this->id; - $return = $this->db->query($sql); - if ($return) return 1; - else return -1; - } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Remove tag payed on social contribution + * + * @param User $user Object user making change + * @return int <0 if KO, >0 if OK + */ + public function set_unpaid($user) + { + // phpcs:enable + $sql = "UPDATE ".MAIN_DB_PREFIX."chargesociales SET"; + $sql .= " paye = 0"; + $sql .= " WHERE rowid = ".$this->id; + $return = $this->db->query($sql); + if ($return) return 1; + else return -1; + } - /** - * Retourne le libelle du statut d'une charge (impaye, payee) - * - * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=short label + picto, 6=Long label + picto + /** + * Retourne le libelle du statut d'une charge (impaye, payee) + * + * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=short label + picto, 6=Long label + picto * @param double $alreadypaid 0=No payment already done, >0=Some payments were already done (we recommand to put here amount payed if you have it, 1 otherwise) - * @return string Label - */ - public function getLibStatut($mode = 0, $alreadypaid = -1) - { - return $this->LibStatut($this->paye, $mode, $alreadypaid); - } + * @return string Label + */ + public function getLibStatut($mode = 0, $alreadypaid = -1) + { + return $this->LibStatut($this->paye, $mode, $alreadypaid); + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Renvoi le libelle d'un statut donne - * - * @param int $status Id status - * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=short label + picto, 6=Long label + picto + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Renvoi le libelle d'un statut donne + * + * @param int $status Id status + * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=short label + picto, 6=Long label + picto * @param double $alreadypaid 0=No payment already done, >0=Some payments were already done (we recommand to put here amount payed if you have it, 1 otherwise) - * @return string Label - */ - public function LibStatut($status, $mode = 0, $alreadypaid = -1) - { - // phpcs:enable - global $langs; + * @return string Label + */ + public function LibStatut($status, $mode = 0, $alreadypaid = -1) + { + // phpcs:enable + global $langs; - // Load translation files required by the page - $langs->loadLangs(array("customers", "bills")); + // Load translation files required by the page + $langs->loadLangs(array("customers", "bills")); - // We reinit status array to force to redefine them because label may change according to properties values. - $this->labelStatus = array(); - $this->labelStatusShort = array(); + // We reinit status array to force to redefine them because label may change according to properties values. + $this->labelStatus = array(); + $this->labelStatusShort = array(); - if (empty($this->labelStatus) || empty($this->labelStatusShort)) - { - global $langs; - //$langs->load("mymodule"); - $this->labelStatus[self::STATUS_UNPAID] = $langs->trans('Unpaid'); - $this->labelStatus[self::STATUS_PAID] = $langs->trans('Paid'); - if ($status == self::STATUS_UNPAID && $alreadypaid > 0) $this->labelStatus[self::STATUS_UNPAID] = $langs->trans("BillStatusStarted"); - $this->labelStatusShort[self::STATUS_UNPAID] = $langs->trans('Unpaid'); - $this->labelStatusShort[self::STATUS_PAID] = $langs->trans('Paid'); - if ($status == self::STATUS_UNPAID && $alreadypaid > 0) $this->labelStatusShort[self::STATUS_UNPAID] = $langs->trans("BillStatusStarted"); - } + if (empty($this->labelStatus) || empty($this->labelStatusShort)) + { + global $langs; + //$langs->load("mymodule"); + $this->labelStatus[self::STATUS_UNPAID] = $langs->trans('Unpaid'); + $this->labelStatus[self::STATUS_PAID] = $langs->trans('Paid'); + if ($status == self::STATUS_UNPAID && $alreadypaid > 0) $this->labelStatus[self::STATUS_UNPAID] = $langs->trans("BillStatusStarted"); + $this->labelStatusShort[self::STATUS_UNPAID] = $langs->trans('Unpaid'); + $this->labelStatusShort[self::STATUS_PAID] = $langs->trans('Paid'); + if ($status == self::STATUS_UNPAID && $alreadypaid > 0) $this->labelStatusShort[self::STATUS_UNPAID] = $langs->trans("BillStatusStarted"); + } - $statusType = 'status1'; - if ($status == 0 && $alreadypaid > 0) $statusType = 'status3'; - if ($status == 1) $statusType = 'status6'; + $statusType = 'status1'; + if ($status == 0 && $alreadypaid > 0) $statusType = 'status3'; + if ($status == 1) $statusType = 'status6'; - return dolGetStatus($this->labelStatus[$status], $this->labelStatusShort[$status], '', $statusType, $mode); - } + return dolGetStatus($this->labelStatus[$status], $this->labelStatusShort[$status], '', $statusType, $mode); + } - /** + /** * Return a link to the object card (with optionaly the picto) * * @param int $withpicto Include picto in link (0=No picto, 1=Include picto into link, 2=Only picto) - * @param int $maxlen Max length of label - * @param int $notooltip 1=Disable tooltip + * @param int $maxlen Max length of label + * @param int $notooltip 1=Disable tooltip * @param int $short 1=Return just URL - * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking - * @return string String with link - */ - public function getNomUrl($withpicto = 0, $maxlen = 0, $notooltip = 0, $short = 0, $save_lastsearch_value = -1) - { - global $langs, $conf, $user, $form; + * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking + * @return string String with link + */ + public function getNomUrl($withpicto = 0, $maxlen = 0, $notooltip = 0, $short = 0, $save_lastsearch_value = -1) + { + global $langs, $conf, $user, $form; - if (!empty($conf->dol_no_mouse_hover)) $notooltip = 1; // Force disable tooltips + if (!empty($conf->dol_no_mouse_hover)) $notooltip = 1; // Force disable tooltips - $result = ''; + $result = ''; - $url = DOL_URL_ROOT.'/compta/sociales/card.php?id='.$this->id; + $url = DOL_URL_ROOT.'/compta/sociales/card.php?id='.$this->id; - if ($short) return $url; + if ($short) return $url; - if ($option !== 'nolink') - { - // Add param to save lastsearch_values or not - $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0); - if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values = 1; - if ($add_save_lastsearch_values) $url .= '&save_lastsearch_values=1'; - } + if ($option !== 'nolink') + { + // Add param to save lastsearch_values or not + $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0); + if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values = 1; + if ($add_save_lastsearch_values) $url .= '&save_lastsearch_values=1'; + } - if (empty($this->ref)) $this->ref = $this->label; + if (empty($this->ref)) $this->ref = $this->label; - $label = ''.$langs->trans("SocialContribution").''; - if (!empty($this->ref)) - $label .= '
'.$langs->trans('Ref').': '.$this->ref; - if (!empty($this->label)) - $label .= '
'.$langs->trans('Label').': '.$this->label; - if (!empty($this->type_label)) - $label .= '
'.$langs->trans('Type').': '.$this->type_label; + $label = ''.$langs->trans("SocialContribution").''; + if (!empty($this->ref)) + $label .= '
'.$langs->trans('Ref').': '.$this->ref; + if (!empty($this->label)) + $label .= '
'.$langs->trans('Label').': '.$this->label; + if (!empty($this->type_label)) + $label .= '
'.$langs->trans('Type').': '.$this->type_label; - $linkclose = ''; - if (empty($notooltip) && $user->rights->facture->lire) - { - if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) - { - $label = $langs->trans("SocialContribution"); - $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"'; - } - $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"'; - $linkclose .= ' class="classfortooltip"'; - } + $linkclose = ''; + if (empty($notooltip) && $user->rights->facture->lire) + { + if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) + { + $label = $langs->trans("SocialContribution"); + $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"'; + } + $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"'; + $linkclose .= ' class="classfortooltip"'; + } - $linkstart = ''; - $linkend = ''; + $linkstart = ''; + $linkend = ''; - $result .= $linkstart; - if ($withpicto) $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1); - if ($withpicto != 2) $result .= ($maxlen ?dol_trunc($this->ref, $maxlen) : $this->ref); - $result .= $linkend; + $result .= $linkstart; + if ($withpicto) $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1); + if ($withpicto != 2) $result .= ($maxlen ?dol_trunc($this->ref, $maxlen) : $this->ref); + $result .= $linkend; - return $result; - } + return $result; + } - /** - * Return amount of payments already done - * - * @return int Amount of payment already done, <0 if KO - */ - public function getSommePaiement() - { - $table = 'paiementcharge'; - $field = 'fk_charge'; + /** + * Return amount of payments already done + * + * @return int Amount of payment already done, <0 if KO + */ + public function getSommePaiement() + { + $table = 'paiementcharge'; + $field = 'fk_charge'; - $sql = 'SELECT sum(amount) as amount'; - $sql .= ' FROM '.MAIN_DB_PREFIX.$table; - $sql .= ' WHERE '.$field.' = '.$this->id; + $sql = 'SELECT sum(amount) as amount'; + $sql .= ' FROM '.MAIN_DB_PREFIX.$table; + $sql .= ' WHERE '.$field.' = '.$this->id; - dol_syslog(get_class($this)."::getSommePaiement", LOG_DEBUG); - $resql = $this->db->query($sql); - if ($resql) { - $amount = 0; + dol_syslog(get_class($this)."::getSommePaiement", LOG_DEBUG); + $resql = $this->db->query($sql); + if ($resql) { + $amount = 0; - $obj = $this->db->fetch_object($resql); - if ($obj) $amount = $obj->amount ? $obj->amount : 0; + $obj = $this->db->fetch_object($resql); + if ($obj) $amount = $obj->amount ? $obj->amount : 0; - $this->db->free($resql); - return $amount; - } else { - return -1; - } - } + $this->db->free($resql); + return $amount; + } else { + return -1; + } + } - /** - * Charge les informations d'ordre info dans l'objet entrepot - * - * @param int $id Id of social contribution - * @return int <0 if KO, >0 if OK - */ - public function info($id) - { - $sql = "SELECT e.rowid, e.tms as datem, e.date_creation as datec, e.date_valid as datev, e.import_key,"; - $sql .= " e.fk_user_author, e.fk_user_modif, e.fk_user_valid"; + /** + * Charge les informations d'ordre info dans l'objet entrepot + * + * @param int $id Id of social contribution + * @return int <0 if KO, >0 if OK + */ + public function info($id) + { + $sql = "SELECT e.rowid, e.tms as datem, e.date_creation as datec, e.date_valid as datev, e.import_key,"; + $sql .= " e.fk_user_author, e.fk_user_modif, e.fk_user_valid"; $sql .= " FROM ".MAIN_DB_PREFIX."chargesociales as e"; - $sql .= " WHERE e.rowid = ".$id; + $sql .= " WHERE e.rowid = ".$id; - dol_syslog(get_class($this)."::info", LOG_DEBUG); - $result = $this->db->query($sql); - if ($result) - { - if ($this->db->num_rows($result)) - { - $obj = $this->db->fetch_object($result); + dol_syslog(get_class($this)."::info", LOG_DEBUG); + $result = $this->db->query($sql); + if ($result) + { + if ($this->db->num_rows($result)) + { + $obj = $this->db->fetch_object($result); - $this->id = $obj->rowid; + $this->id = $obj->rowid; - if ($obj->fk_user_author) { - $cuser = new User($this->db); - $cuser->fetch($obj->fk_user_author); - $this->user_creation = $cuser; - } + if ($obj->fk_user_author) { + $cuser = new User($this->db); + $cuser->fetch($obj->fk_user_author); + $this->user_creation = $cuser; + } - if ($obj->fk_user_modif) { - $muser = new User($this->db); - $muser->fetch($obj->fk_user_modif); - $this->user_modification = $muser; - } + if ($obj->fk_user_modif) { + $muser = new User($this->db); + $muser->fetch($obj->fk_user_modif); + $this->user_modification = $muser; + } - if ($obj->fk_user_valid) { - $vuser = new User($this->db); - $vuser->fetch($obj->fk_user_valid); - $this->user_validation = $vuser; - } + if ($obj->fk_user_valid) { + $vuser = new User($this->db); + $vuser->fetch($obj->fk_user_valid); + $this->user_validation = $vuser; + } - $this->date_creation = $this->db->jdate($obj->datec); - $this->date_modification = $this->db->jdate($obj->datem); - $this->date_validation = $this->db->jdate($obj->datev); - $this->import_key = $obj->import_key; - } + $this->date_creation = $this->db->jdate($obj->datec); + $this->date_modification = $this->db->jdate($obj->datem); + $this->date_validation = $this->db->jdate($obj->datev); + $this->import_key = $obj->import_key; + } - $this->db->free($result); - } else { - dol_print_error($this->db); - } - } + $this->db->free($result); + } else { + dol_print_error($this->db); + } + } - /** - * Initialise an instance with random values. - * Used to build previews or test instances. - * id must be 0 if object instance is a specimen. - * - * @return void - */ - public function initAsSpecimen() - { - // Initialize parameters - $this->id = 0; - $this->ref = 'SPECIMEN'; - $this->specimen = 1; - $this->paye = 0; - $this->date = dol_now(); - $this->date_ech = $this->date + 3600 * 24 * 30; - $this->periode = $this->date + 3600 * 24 * 30; - $this->amount = 100; - $this->label = 'Social contribution label'; - $this->type = 1; - $this->type_label = 'Type of social contribution'; - } + /** + * Initialise an instance with random values. + * Used to build previews or test instances. + * id must be 0 if object instance is a specimen. + * + * @return void + */ + public function initAsSpecimen() + { + // Initialize parameters + $this->id = 0; + $this->ref = 'SPECIMEN'; + $this->specimen = 1; + $this->paye = 0; + $this->date = dol_now(); + $this->date_ech = $this->date + 3600 * 24 * 30; + $this->periode = $this->date + 3600 * 24 * 30; + $this->amount = 100; + $this->label = 'Social contribution label'; + $this->type = 1; + $this->type_label = 'Type of social contribution'; + } } diff --git a/htdocs/compta/sociales/document.php b/htdocs/compta/sociales/document.php index dd07afd416f..eea97c13a1d 100644 --- a/htdocs/compta/sociales/document.php +++ b/htdocs/compta/sociales/document.php @@ -156,7 +156,7 @@ if ($object->id) print '
'; - dol_fiche_end(); + print dol_get_fiche_end(); $modulepart = 'tax'; $permission = $user->rights->tax->charges->creer; diff --git a/htdocs/compta/stats/cabyuser.php b/htdocs/compta/stats/cabyuser.php index 8b6caa89a8f..33e69c3cf4c 100644 --- a/htdocs/compta/stats/cabyuser.php +++ b/htdocs/compta/stats/cabyuser.php @@ -281,7 +281,7 @@ if ($modecompta != 'CREANCES-DETTES') { } } -$morefilter = ''; +$moreforfilter = ''; print '
'; print ''."\n"; diff --git a/htdocs/compta/tva/card.php b/htdocs/compta/tva/card.php index 1f20bcd28e3..7e7f236b3ab 100644 --- a/htdocs/compta/tva/card.php +++ b/htdocs/compta/tva/card.php @@ -293,7 +293,7 @@ if ($action == 'create') print '
'; - dol_fiche_end(); + print dol_get_fiche_end(); print '
'; print ''; @@ -369,7 +369,7 @@ if ($id) print '
'; - dol_fiche_end(); + print dol_get_fiche_end(); /* * Action buttons diff --git a/htdocs/compta/tva/document.php b/htdocs/compta/tva/document.php index 8d097e6aad5..10efd84288c 100644 --- a/htdocs/compta/tva/document.php +++ b/htdocs/compta/tva/document.php @@ -142,7 +142,7 @@ if ($object->id) print '
'; - dol_fiche_end(); + print dol_get_fiche_end(); $permission = $user->rights->tax->charges->creer; $permtoedit = $user->rights->fournisseur->facture->creer; diff --git a/htdocs/compta/tva/info.php b/htdocs/compta/tva/info.php index 71ff7b14844..ddabf6e2b49 100644 --- a/htdocs/compta/tva/info.php +++ b/htdocs/compta/tva/info.php @@ -89,7 +89,7 @@ print ''; print '
'; -dol_fiche_end(); +print dol_get_fiche_end(); llxFooter(); diff --git a/htdocs/contact/agenda.php b/htdocs/contact/agenda.php index 1d42d638bc8..95ec50be24f 100644 --- a/htdocs/contact/agenda.php +++ b/htdocs/contact/agenda.php @@ -227,7 +227,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) print '
'; - dol_fiche_end(); + print dol_get_fiche_end(); // Actions buttons diff --git a/htdocs/contact/card.php b/htdocs/contact/card.php index 746d2222c39..b4406207977 100644 --- a/htdocs/contact/card.php +++ b/htdocs/contact/card.php @@ -873,7 +873,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) print ""; - dol_fiche_end(); + print dol_get_fiche_end(); print '
'; print ''; @@ -1237,7 +1237,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) print ''; - dol_fiche_end(); + print dol_get_fiche_end(); print '
'; print ''; @@ -1482,7 +1482,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) print '
'; print '
'; - dol_fiche_end(); + print dol_get_fiche_end(); // Barre d'actions print '
'; diff --git a/htdocs/contact/consumption.php b/htdocs/contact/consumption.php index f2eb1e4cfaf..d3992296aec 100644 --- a/htdocs/contact/consumption.php +++ b/htdocs/contact/consumption.php @@ -158,7 +158,7 @@ print ''; print '
'; -dol_fiche_end(); +print dol_get_fiche_end(); print '
'; diff --git a/htdocs/contact/document.php b/htdocs/contact/document.php index d2979081189..8a70ec6e2df 100644 --- a/htdocs/contact/document.php +++ b/htdocs/contact/document.php @@ -162,7 +162,7 @@ if ($object->id) print ''; - dol_fiche_end(); + print dol_get_fiche_end(); $modulepart = 'contact'; $permission = $user->rights->societe->contact->creer; diff --git a/htdocs/contact/info.php b/htdocs/contact/info.php index fbe56cb9587..c39c20d3d25 100644 --- a/htdocs/contact/info.php +++ b/htdocs/contact/info.php @@ -77,7 +77,7 @@ if ($id > 0) print ''; - dol_fiche_end(); + print dol_get_fiche_end(); } llxFooter(); diff --git a/htdocs/contact/ldap.php b/htdocs/contact/ldap.php index 2a24d7ab518..68d810967ad 100644 --- a/htdocs/contact/ldap.php +++ b/htdocs/contact/ldap.php @@ -130,7 +130,7 @@ print ''; print ''; -dol_fiche_end(); +print dol_get_fiche_end(); /* diff --git a/htdocs/contact/note.php b/htdocs/contact/note.php index 2e2eefb2995..478288046e1 100644 --- a/htdocs/contact/note.php +++ b/htdocs/contact/note.php @@ -114,7 +114,7 @@ if ($id > 0) print ''; - dol_fiche_end(); + print dol_get_fiche_end(); } llxFooter(); diff --git a/htdocs/contact/perso.php b/htdocs/contact/perso.php index 8df4dca28d4..bbaf013efa1 100644 --- a/htdocs/contact/perso.php +++ b/htdocs/contact/perso.php @@ -204,7 +204,7 @@ if ($action == 'edit') print ""; - dol_fiche_end(); + print dol_get_fiche_end(); print '
'; print ''; @@ -296,7 +296,7 @@ if ($action == 'edit') print '
'; - dol_fiche_end(); + print dol_get_fiche_end(); } diff --git a/htdocs/contrat/admin/contract_extrafields.php b/htdocs/contrat/admin/contract_extrafields.php index b221aa55398..8571856362a 100644 --- a/htdocs/contrat/admin/contract_extrafields.php +++ b/htdocs/contrat/admin/contract_extrafields.php @@ -74,7 +74,7 @@ print dol_get_fiche_head($head, 'attributes', $langs->trans("Contracts"), -1, 'c require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php'; -dol_fiche_end(); +print dol_get_fiche_end(); // Buttons diff --git a/htdocs/contrat/admin/contractdet_extrafields.php b/htdocs/contrat/admin/contractdet_extrafields.php index fba9843eea0..4b3f03ffedf 100644 --- a/htdocs/contrat/admin/contractdet_extrafields.php +++ b/htdocs/contrat/admin/contractdet_extrafields.php @@ -74,7 +74,7 @@ print dol_get_fiche_head($head, 'attributeslines', $langs->trans("Contracts"), - require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php'; -dol_fiche_end(); +print dol_get_fiche_end(); // Buttons diff --git a/htdocs/contrat/agenda.php b/htdocs/contrat/agenda.php index 48238496721..f88b470215c 100644 --- a/htdocs/contrat/agenda.php +++ b/htdocs/contrat/agenda.php @@ -204,7 +204,7 @@ if ($id > 0) print ''; - dol_fiche_end(); + print dol_get_fiche_end(); diff --git a/htdocs/contrat/card.php b/htdocs/contrat/card.php index f3dc0355331..034709ef110 100644 --- a/htdocs/contrat/card.php +++ b/htdocs/contrat/card.php @@ -1203,7 +1203,7 @@ if ($action == 'create') print "\n"; - dol_fiche_end(); + print dol_get_fiche_end(); print '
'; print ''; @@ -2021,7 +2021,7 @@ if ($action == 'create') print ''; } - dol_fiche_end(); + print dol_get_fiche_end(); /* diff --git a/htdocs/contrat/class/contrat.class.php b/htdocs/contrat/class/contrat.class.php index 14f5c2d0d42..f31901c5ccd 100644 --- a/htdocs/contrat/class/contrat.class.php +++ b/htdocs/contrat/class/contrat.class.php @@ -928,7 +928,7 @@ class Contrat extends CommonObject $this->nbofservices = count($this->lines); $this->total_ttc = price2num($total_ttc); // TODO For the moment value is false as value is not stored in database for line linked to products - $this->total_vat = price2num($total_vat); // TODO For the moment value is false as value is not stored in database for line linked to products + $this->total_tva = price2num($total_vat); // TODO For the moment value is false as value is not stored in database for line linked to products $this->total_ht = price2num($total_ht); // TODO For the moment value is false as value is not stored in database for line linked to products return $this->lines; diff --git a/htdocs/contrat/contact.php b/htdocs/contrat/contact.php index 32c3dd67ada..4f69d5a2c56 100644 --- a/htdocs/contrat/contact.php +++ b/htdocs/contrat/contact.php @@ -230,7 +230,7 @@ if ($id > 0 || !empty($ref)) print '
'; - dol_fiche_end(); + print dol_get_fiche_end(); print '
'; diff --git a/htdocs/contrat/document.php b/htdocs/contrat/document.php index fb7291c5d6b..759c2080930 100644 --- a/htdocs/contrat/document.php +++ b/htdocs/contrat/document.php @@ -186,7 +186,7 @@ if ($object->id) print ''; - dol_fiche_end(); + print dol_get_fiche_end(); $modulepart = 'contract'; $permission = $user->rights->contrat->creer; diff --git a/htdocs/contrat/note.php b/htdocs/contrat/note.php index d2f7a7e71fa..0368340bffd 100644 --- a/htdocs/contrat/note.php +++ b/htdocs/contrat/note.php @@ -176,7 +176,7 @@ if ($id > 0 || !empty($ref)) include DOL_DOCUMENT_ROOT.'/core/tpl/notes.tpl.php'; - dol_fiche_end(); + print dol_get_fiche_end(); } diff --git a/htdocs/core/boxes/box_members.php b/htdocs/core/boxes/box_members.php index 2b2d8418e47..2ca1fb3ae25 100644 --- a/htdocs/core/boxes/box_members.php +++ b/htdocs/core/boxes/box_members.php @@ -86,10 +86,10 @@ class box_members extends ModeleBoxes $this->info_box_head = array('text' => $langs->trans("BoxTitleLastModifiedMembers", $max)); - if ($user->rights->adherent->lire) - { + if ($user->rights->adherent->lire) { $sql = "SELECT a.rowid, a.lastname, a.firstname, a.societe as company, a.fk_soc,"; $sql .= " a.datec, a.tms, a.statut as status, a.datefin as date_end_subscription,"; + $sql .= ' a.photo, a.email, a.gender, a.morphy,'; $sql .= " t.subscription"; $sql .= " FROM ".MAIN_DB_PREFIX."adherent as a, ".MAIN_DB_PREFIX."adherent_type as t"; $sql .= " WHERE a.entity IN (".getEntity('member').")"; @@ -98,13 +98,11 @@ class box_members extends ModeleBoxes $sql .= $this->db->plimit($max, 0); $result = $this->db->query($sql); - if ($result) - { + if ($result) { $num = $this->db->num_rows($result); $line = 0; - while ($line < $num) - { + while ($line < $num) { $objp = $this->db->fetch_object($result); $datec = $this->db->jdate($objp->datec); $datem = $this->db->jdate($objp->tms); @@ -113,6 +111,10 @@ class box_members extends ModeleBoxes $memberstatic->firstname = $objp->firstname; $memberstatic->id = $objp->rowid; $memberstatic->ref = $objp->rowid; + $memberstatic->photo = $objp->photo; + $memberstatic->gender = $objp->gender; + $memberstatic->email = $objp->email; + $memberstatic->morphy = $objp->morphy; $memberstatic->company = $objp->company; if (!empty($objp->fk_soc)) { @@ -125,7 +127,7 @@ class box_members extends ModeleBoxes $this->info_box_contents[$line][] = array( 'td' => 'class="tdoverflowmax150 maxwidth150onsmartphone"', - 'text' => $memberstatic->getNomUrl(1), + 'text' => $memberstatic->getNomUrl(-1), 'asis' => 1, ); diff --git a/htdocs/core/boxes/box_services_contracts.php b/htdocs/core/boxes/box_services_contracts.php index 5a1ef8df7b9..a5a1c4bea8a 100644 --- a/htdocs/core/boxes/box_services_contracts.php +++ b/htdocs/core/boxes/box_services_contracts.php @@ -126,7 +126,6 @@ class box_services_contracts extends ModeleBoxes $contractlinestatic->product_id = $objp->product_id; $contractlinestatic->product_ref = $objp->product_ref; $contractlinestatic->product_type = $objp->product_type; - $contractlinestatic->statut = $objp->contractline_status; $contractstatic->id = $objp->rowid; diff --git a/htdocs/core/class/commonincoterm.class.php b/htdocs/core/class/commonincoterm.class.php index b2d5491684e..f98f3aaabad 100644 --- a/htdocs/core/class/commonincoterm.class.php +++ b/htdocs/core/class/commonincoterm.class.php @@ -105,7 +105,7 @@ trait CommonIncoterm * * @param int $id_incoterm Id of incoterm to set or '' to remove * @param string $location location of incoterm - * @return int <0 if KO, >0 if OK + * @return int <0 if KO, >0 if OK */ public function setIncoterms($id_incoterm, $location) { diff --git a/htdocs/core/class/commoninvoice.class.php b/htdocs/core/class/commoninvoice.class.php index 034e436a612..c278eaeedb7 100644 --- a/htdocs/core/class/commoninvoice.class.php +++ b/htdocs/core/class/commoninvoice.class.php @@ -33,36 +33,36 @@ abstract class CommonInvoice extends CommonObject { use CommonIncoterm; - /** - * Standard invoice - */ - const TYPE_STANDARD = 0; + /** + * Standard invoice + */ + const TYPE_STANDARD = 0; - /** - * Replacement invoice - */ - const TYPE_REPLACEMENT = 1; + /** + * Replacement invoice + */ + const TYPE_REPLACEMENT = 1; - /** - * Credit note invoice - */ - const TYPE_CREDIT_NOTE = 2; + /** + * Credit note invoice + */ + const TYPE_CREDIT_NOTE = 2; - /** - * Deposit invoice - */ - const TYPE_DEPOSIT = 3; + /** + * Deposit invoice + */ + const TYPE_DEPOSIT = 3; - /** - * Proforma invoice. - * @deprectad Remove this. A "proforma invoice" is an order with a look of invoice, not an invoice ! - */ - const TYPE_PROFORMA = 4; + /** + * Proforma invoice. + * @deprectad Remove this. A "proforma invoice" is an order with a look of invoice, not an invoice ! + */ + const TYPE_PROFORMA = 4; - /** - * Situation invoice - */ - const TYPE_SITUATION = 5; + /** + * Situation invoice + */ + const TYPE_SITUATION = 5; /** * Draft status @@ -102,16 +102,16 @@ abstract class CommonInvoice extends CommonObject */ public function getRemainToPay($multicurrency = 0) { - $alreadypaid = 0.0; - $alreadypaid += $this->getSommePaiement($multicurrency); - $alreadypaid += $this->getSumDepositsUsed($multicurrency); - $alreadypaid += $this->getSumCreditNotesUsed($multicurrency); + $alreadypaid = 0.0; + $alreadypaid += $this->getSommePaiement($multicurrency); + $alreadypaid += $this->getSumDepositsUsed($multicurrency); + $alreadypaid += $this->getSumCreditNotesUsed($multicurrency); - $remaintopay = price2num($this->total_ttc - $alreadypaid, 'MT'); - if ($this->statut == self::STATUS_CLOSED && $this->close_code == 'discount_vat') { // If invoice closed with discount for anticipated payment - $remaintopay = 0.0; - } - return $remaintopay; + $remaintopay = price2num($this->total_ttc - $alreadypaid, 'MT'); + if ($this->statut == self::STATUS_CLOSED && $this->close_code == 'discount_vat') { // If invoice closed with discount for anticipated payment + $remaintopay = 0.0; + } + return $remaintopay; } /** @@ -151,7 +151,7 @@ abstract class CommonInvoice extends CommonObject /** * Return amount (with tax) of all deposits invoices used by invoice. - * Should always be empty, except if option FACTURE_DEPOSITS_ARE_JUST_PAYMENTS is on (not recommended). + * Should always be empty, except if option FACTURE_DEPOSITS_ARE_JUST_PAYMENTS is on (not recommended). * * @param int $multicurrency Return multicurrency_amount instead of amount * @return float <0 if KO, Sum of deposits amount otherwise @@ -159,21 +159,21 @@ abstract class CommonInvoice extends CommonObject public function getSumDepositsUsed($multicurrency = 0) { if ($this->element == 'facture_fourn' || $this->element == 'invoice_supplier') - { - // TODO - return 0.0; - } + { + // TODO + return 0.0; + } - require_once DOL_DOCUMENT_ROOT.'/core/class/discount.class.php'; + require_once DOL_DOCUMENT_ROOT.'/core/class/discount.class.php'; - $discountstatic = new DiscountAbsolute($this->db); - $result = $discountstatic->getSumDepositsUsed($this, $multicurrency); - if ($result >= 0) { - return $result; - } else { - $this->error = $discountstatic->error; - return -1; - } + $discountstatic = new DiscountAbsolute($this->db); + $result = $discountstatic->getSumDepositsUsed($this, $multicurrency); + if ($result >= 0) { + return $result; + } else { + $this->error = $discountstatic->error; + return -1; + } } /** @@ -184,16 +184,16 @@ abstract class CommonInvoice extends CommonObject */ public function getSumCreditNotesUsed($multicurrency = 0) { - require_once DOL_DOCUMENT_ROOT.'/core/class/discount.class.php'; + require_once DOL_DOCUMENT_ROOT.'/core/class/discount.class.php'; - $discountstatic = new DiscountAbsolute($this->db); - $result = $discountstatic->getSumCreditNotesUsed($this, $multicurrency); - if ($result >= 0) { - return $result; - } else { - $this->error = $discountstatic->error; - return -1; - } + $discountstatic = new DiscountAbsolute($this->db); + $result = $discountstatic->getSumCreditNotesUsed($this, $multicurrency); + if ($result >= 0) { + return $result; + } else { + $this->error = $discountstatic->error; + return -1; + } } /** @@ -204,16 +204,16 @@ abstract class CommonInvoice extends CommonObject */ public function getSumFromThisCreditNotesNotUsed($multicurrency = 0) { - require_once DOL_DOCUMENT_ROOT.'/core/class/discount.class.php'; + require_once DOL_DOCUMENT_ROOT.'/core/class/discount.class.php'; - $discountstatic = new DiscountAbsolute($this->db); - $result = $discountstatic->getSumFromThisCreditNotesNotUsed($this, $multicurrency); - if ($result >= 0) { - return $result; - } else { - $this->error = $discountstatic->error; - return -1; - } + $discountstatic = new DiscountAbsolute($this->db); + $result = $discountstatic->getSumFromThisCreditNotesNotUsed($this, $multicurrency); + if ($result >= 0) { + return $result; + } else { + $this->error = $discountstatic->error; + return -1; + } } /** @@ -329,7 +329,7 @@ abstract class CommonInvoice extends CommonObject $obj = $this->db->fetch_object($resql); $tmp = array('amount'=>$obj->amount,'type'=>$obj->code, 'date'=>$obj->datep, 'num'=>$obj->num, 'ref'=>$obj->ref); if (!empty($field3)) { - $tmp['ref_ext'] = $obj->ref_ext; + $tmp['ref_ext'] = $obj->ref_ext; } $retarray[]=$tmp; $i++; @@ -385,7 +385,7 @@ abstract class CommonInvoice extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return if an invoice can be deleted * Rule is: @@ -399,9 +399,9 @@ abstract class CommonInvoice extends CommonObject * * @return int <=0 if no, >0 if yes */ - public function is_erasable() - { - // phpcs:enable + public function is_erasable() + { + // phpcs:enable global $conf; // We check if invoice is a temporary number (PROVxxxx) @@ -486,15 +486,15 @@ abstract class CommonInvoice extends CommonObject * * @return string Label of type of invoice */ - public function getLibType() + public function getLibType() { global $langs; - if ($this->type == CommonInvoice::TYPE_STANDARD) return $langs->trans("InvoiceStandard"); - elseif ($this->type == CommonInvoice::TYPE_REPLACEMENT) return $langs->trans("InvoiceReplacement"); - elseif ($this->type == CommonInvoice::TYPE_CREDIT_NOTE) return $langs->trans("InvoiceAvoir"); - elseif ($this->type == CommonInvoice::TYPE_DEPOSIT) return $langs->trans("InvoiceDeposit"); - elseif ($this->type == CommonInvoice::TYPE_PROFORMA) return $langs->trans("InvoiceProForma"); // Not used. - elseif ($this->type == CommonInvoice::TYPE_SITUATION) return $langs->trans("InvoiceSituation"); + if ($this->type == CommonInvoice::TYPE_STANDARD) return $langs->trans("InvoiceStandard"); + elseif ($this->type == CommonInvoice::TYPE_REPLACEMENT) return $langs->trans("InvoiceReplacement"); + elseif ($this->type == CommonInvoice::TYPE_CREDIT_NOTE) return $langs->trans("InvoiceAvoir"); + elseif ($this->type == CommonInvoice::TYPE_DEPOSIT) return $langs->trans("InvoiceDeposit"); + elseif ($this->type == CommonInvoice::TYPE_PROFORMA) return $langs->trans("InvoiceProForma"); // Not used. + elseif ($this->type == CommonInvoice::TYPE_SITUATION) return $langs->trans("InvoiceSituation"); return $langs->trans("Unknown"); } @@ -510,7 +510,7 @@ abstract class CommonInvoice extends CommonObject return $this->LibStatut($this->paye, $this->statut, $mode, $alreadypaid, $this->type); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return label of a status * @@ -523,52 +523,52 @@ abstract class CommonInvoice extends CommonObject */ public function LibStatut($paye, $status, $mode = 0, $alreadypaid = -1, $type = 0) { - // phpcs:enable + // phpcs:enable global $langs; $langs->load('bills'); $statusType = 'status0'; $prefix = 'Short'; if (!$paye) { - if ($status == 0) { - $labelStatus = $langs->transnoentitiesnoconv('BillStatusDraft'); - $labelStatusShort = $langs->transnoentitiesnoconv('Bill'.$prefix.'StatusDraft'); - } elseif (($status == 3 || $status == 2) && $alreadypaid <= 0) { - $labelStatus = $langs->transnoentitiesnoconv('BillStatusClosedUnpaid'); - $labelStatusShort = $langs->transnoentitiesnoconv('Bill'.$prefix.'StatusClosedUnpaid'); - $statusType = 'status5'; - } elseif (($status == 3 || $status == 2) && $alreadypaid > 0) { - $labelStatus = $langs->transnoentitiesnoconv('BillStatusClosedPaidPartially'); - $labelStatusShort = $langs->transnoentitiesnoconv('Bill'.$prefix.'StatusClosedPaidPartially'); - $statusType = 'status9'; - } elseif ($alreadypaid == 0) { - $labelStatus = $langs->transnoentitiesnoconv('BillStatusNotPaid'); - $labelStatusShort = $langs->transnoentitiesnoconv('Bill'.$prefix.'StatusNotPaid'); - $statusType = 'status1'; - } else { - $labelStatus = $langs->transnoentitiesnoconv('BillStatusStarted'); - $labelStatusShort = $langs->transnoentitiesnoconv('Bill'.$prefix.'StatusStarted'); - $statusType = 'status3'; - } + if ($status == 0) { + $labelStatus = $langs->transnoentitiesnoconv('BillStatusDraft'); + $labelStatusShort = $langs->transnoentitiesnoconv('Bill'.$prefix.'StatusDraft'); + } elseif (($status == 3 || $status == 2) && $alreadypaid <= 0) { + $labelStatus = $langs->transnoentitiesnoconv('BillStatusClosedUnpaid'); + $labelStatusShort = $langs->transnoentitiesnoconv('Bill'.$prefix.'StatusClosedUnpaid'); + $statusType = 'status5'; + } elseif (($status == 3 || $status == 2) && $alreadypaid > 0) { + $labelStatus = $langs->transnoentitiesnoconv('BillStatusClosedPaidPartially'); + $labelStatusShort = $langs->transnoentitiesnoconv('Bill'.$prefix.'StatusClosedPaidPartially'); + $statusType = 'status9'; + } elseif ($alreadypaid == 0) { + $labelStatus = $langs->transnoentitiesnoconv('BillStatusNotPaid'); + $labelStatusShort = $langs->transnoentitiesnoconv('Bill'.$prefix.'StatusNotPaid'); + $statusType = 'status1'; + } else { + $labelStatus = $langs->transnoentitiesnoconv('BillStatusStarted'); + $labelStatusShort = $langs->transnoentitiesnoconv('Bill'.$prefix.'StatusStarted'); + $statusType = 'status3'; + } } else { - $statusType = 'status6'; + $statusType = 'status6'; - if ($type == self::TYPE_CREDIT_NOTE) { - $labelStatus = $langs->transnoentitiesnoconv('BillStatusPaidBackOrConverted'); // credit note - $labelStatusShort = $langs->transnoentitiesnoconv('Bill'.$prefix.'StatusPaidBackOrConverted'); // credit note - } elseif ($type == self::TYPE_DEPOSIT) { - $labelStatus = $langs->transnoentitiesnoconv('BillStatusConverted'); // deposit invoice - $labelStatusShort = $langs->transnoentitiesnoconv('Bill'.$prefix.'StatusConverted'); // deposit invoice - } else { - $labelStatus = $langs->transnoentitiesnoconv('BillStatusPaid'); - $labelStatusShort = $langs->transnoentitiesnoconv('Bill'.$prefix.'StatusPaid'); - } + if ($type == self::TYPE_CREDIT_NOTE) { + $labelStatus = $langs->transnoentitiesnoconv('BillStatusPaidBackOrConverted'); // credit note + $labelStatusShort = $langs->transnoentitiesnoconv('Bill'.$prefix.'StatusPaidBackOrConverted'); // credit note + } elseif ($type == self::TYPE_DEPOSIT) { + $labelStatus = $langs->transnoentitiesnoconv('BillStatusConverted'); // deposit invoice + $labelStatusShort = $langs->transnoentitiesnoconv('Bill'.$prefix.'StatusConverted'); // deposit invoice + } else { + $labelStatus = $langs->transnoentitiesnoconv('BillStatusPaid'); + $labelStatusShort = $langs->transnoentitiesnoconv('Bill'.$prefix.'StatusPaid'); + } } return dolGetStatus($labelStatus, $labelStatusShort, '', $statusType, $mode); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Returns an invoice payment deadline based on the invoice settlement * conditions and billing date. @@ -576,15 +576,15 @@ abstract class CommonInvoice extends CommonObject * @param integer $cond_reglement Condition of payment (code or id) to use. If 0, we use current condition. * @return integer Date limite de reglement si ok, <0 si ko */ - public function calculate_date_lim_reglement($cond_reglement = 0) + public function calculate_date_lim_reglement($cond_reglement = 0) { - // phpcs:enable + // phpcs:enable if (!$cond_reglement) $cond_reglement = $this->cond_reglement_code; if (!$cond_reglement) $cond_reglement = $this->cond_reglement_id; $cdr_nbjour = 0; - $cdr_type = 0; - $cdr_decalage = 0; + $cdr_type = 0; + $cdr_decalage = 0; $sqltemp = 'SELECT c.type_cdr, c.nbjour, c.decalage'; $sqltemp .= ' FROM '.MAIN_DB_PREFIX.'c_payment_term as c'; @@ -643,7 +643,7 @@ abstract class CommonInvoice extends CommonObject // 2 : application of the rule, the N of the current or next month elseif ($cdr_type == 2 && !empty($cdr_decalage)) { - include_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; + include_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; $datelim = $this->date + ($cdr_nbjour * 3600 * 24); $date_piece = dol_mktime(0, 0, 0, date('m', $datelim), date('d', $datelim), date('Y', $datelim)); // Sans les heures minutes et secondes diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index dea2ce4865b..58b36ac3643 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -8039,6 +8039,18 @@ abstract class CommonObject } } + // Delete llx_ecm_files + if (!$error) { + $sql = 'DELETE FROM '.MAIN_DB_PREFIX."ecm_files WHERE src_object_type = '".$this->db->escape($this->table_element.(empty($this->module) ? '' : '@'.$this->module))."' AND src_object_id = ".$this->id; + $resql = $this->db->query($sql); + if (!$resql) + { + $this->error = $this->db->lasterror(); + $this->errors[] = $this->error; + $error++; + } + } + if (!$error && !empty($this->isextrafieldmanaged)) { $result = $this->deleteExtraFields(); diff --git a/htdocs/core/class/html.formticket.class.php b/htdocs/core/class/html.formticket.class.php index d83aa3cc19a..8b1618c8da9 100644 --- a/htdocs/core/class/html.formticket.class.php +++ b/htdocs/core/class/html.formticket.class.php @@ -422,7 +422,7 @@ class FormTicket print ''; - if ($withdolfichehead) dol_fiche_end(); + if ($withdolfichehead) print dol_get_fiche_end(); print '
'; print ''; diff --git a/htdocs/core/class/translate.class.php b/htdocs/core/class/translate.class.php index 184724c0319..6bfe5cdc195 100644 --- a/htdocs/core/class/translate.class.php +++ b/htdocs/core/class/translate.class.php @@ -113,7 +113,7 @@ class Translate } else $srclang = strtolower($langpart[0])."_".strtoupper($langpart[0]); } else { // If it's for a codetouse that is a short code xx // Array to convert short lang code into long code. - $longforshort = array('ar'=>'ar_SA', 'el'=>'el_GR', 'ca'=>'ca_ES', 'en'=>'en_US', 'nb'=>'nb_NO', 'no'=>'nb_NO'); + $longforshort = array('ar'=>'ar_SA', 'el'=>'el_GR', 'ca'=>'ca_ES', 'en'=>'en_US', 'ja'=>'ja_JP', 'nb'=>'nb_NO', 'no'=>'nb_NO'); if (isset($longforshort[strtolower($langpart[0])])) $srclang = $longforshort[strtolower($langpart[0])]; elseif (!empty($langpart[0])) $srclang = strtolower($langpart[0])."_".strtoupper($langpart[0]); else $srclang = 'en_US'; diff --git a/htdocs/core/customreports.php b/htdocs/core/customreports.php index 859f6e5cac1..433ec4969ca 100644 --- a/htdocs/core/customreports.php +++ b/htdocs/core/customreports.php @@ -758,7 +758,7 @@ if ($sql) { print '
'; if (!defined('USE_CUSTOME_REPORT_AS_INCLUDE')) { - dol_fiche_end(); + print dol_get_fiche_end(); } // End of page diff --git a/htdocs/core/lib/accounting.lib.php b/htdocs/core/lib/accounting.lib.php index f380152abdb..20ffa3f52b6 100644 --- a/htdocs/core/lib/accounting.lib.php +++ b/htdocs/core/lib/accounting.lib.php @@ -235,7 +235,7 @@ function journalHead($nom, $variante, $period, $periodlink, $description, $build print ''; - dol_fiche_end(); + print dol_get_fiche_end(); print '
'; diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index f7c81e148e4..6b76148d350 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -1258,7 +1258,7 @@ function dolButtonToOpenUrlInDialogPopup($name, $label, $buttonstring, $url, $di * @param array $links Array of tabs. Currently initialized by calling a function xxx_admin_prepare_head * @param string $active Active tab name (document', 'info', 'ldap', ....) * @param string $title Title - * @param int $notab -1 or 0=Add tab header, 1=no tab header (if you set this to 1, using dol_fiche_end() to close tab is not required), -2=Add tab header with no seaparation under tab (to start a tab just after) + * @param int $notab -1 or 0=Add tab header, 1=no tab header (if you set this to 1, using print dol_get_fiche_end() to close tab is not required), -2=Add tab header with no seaparation under tab (to start a tab just after) * @param string $picto Add a picto on tab title * @param int $pictoisfullpath If 1, image path is a full path. If you set this to 1, you can use url returned by dol_buildpath('/mymodyle/img/myimg.png',1) for $picto. * @param string $morehtmlright Add more html content on right of tabs title @@ -1279,7 +1279,7 @@ function dol_fiche_head($links = array(), $active = '0', $title = '', $notab = 0 * @param array $links Array of tabs * @param string $active Active tab name * @param string $title Title - * @param int $notab -1 or 0=Add tab header, 1=no tab header (if you set this to 1, using dol_fiche_end() to close tab is not required), -2=Add tab header with no seaparation under tab (to start a tab just after) + * @param int $notab -1 or 0=Add tab header, 1=no tab header (if you set this to 1, using print dol_get_fiche_end() to close tab is not required), -2=Add tab header with no seaparation under tab (to start a tab just after) * @param string $picto Add a picto on tab title * @param int $pictoisfullpath If 1, image path is a full path. If you set this to 1, you can use url returned by dol_buildpath('/mymodyle/img/myimg.png',1) for $picto. * @param string $morehtmlright Add more html content on right of tabs title @@ -1456,6 +1456,7 @@ function dol_get_fiche_head($links = array(), $active = '', $title = '', $notab * * @param int $notab -1 or 0=Add tab footer, 1=no tab footer * @return void + * @deprecated Use print dol_get_fiche_end() instead */ function dol_fiche_end($notab = 0) { @@ -3316,9 +3317,9 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $ $enabledisablehtml = ''; - if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { + /*if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { $enabledisablehtml .= $titlealt; - } + }*/ $enabledisablehtml .= ''; return $enabledisablehtml; @@ -3952,7 +3953,7 @@ function info_admin($text, $infoonimgalt = 0, $nodiv = 0, $admin = '1', $morecss * However, one must try to call it only within php pages, classes must return their error through their property "error". * * @param DoliDB $db Database handler - * @param string|[string] $error String or array of errors strings to show + * @param string|string[] $error String or array of errors strings to show * @param array $errors Array of errors * @return void * @see dol_htmloutput_errors() @@ -6691,7 +6692,7 @@ function dolGetFirstLastname($firstname, $lastname, $nameorder = -1) * Note: Calling dol_htmloutput_events is done into pages by standard llxFooter() function. * Note: Prefer to use setEventMessages instead. * - * @param string|[string] $mesgs Message string or array + * @param string|string[] $mesgs Message string or array * @param string $style Which style to use ('mesgs' by default, 'warnings', 'errors') * @return void * @see dol_htmloutput_events() @@ -6700,10 +6701,10 @@ function setEventMessage($mesgs, $style = 'mesgs') { //dol_syslog(__FUNCTION__ . " is deprecated", LOG_WARNING); This is not deprecated, it is used by setEventMessages function if (!is_array($mesgs)) { - // If mesgs is a string + // If mesgs is a string if ($mesgs) $_SESSION['dol_events'][$style][] = $mesgs; } else { - // If mesgs is an array + // If mesgs is an array foreach ($mesgs as $mesg) { if ($mesg) $_SESSION['dol_events'][$style][] = $mesg; @@ -8994,8 +8995,7 @@ function addSummaryTableLine($tableColumnCount, $num, $nbofloop = 0, $total = 0, } /** - * Return a file on output using a lo memory. - * It can return very large files with no need of memory. + * Return a file on output using a low memory. It can return very large files with no need of memory. * WARNING: This close output buffers. * * @param string $fullpath_original_file_osencoded Full path of file to return. diff --git a/htdocs/core/lib/functions2.lib.php b/htdocs/core/lib/functions2.lib.php index d49085ecb8e..8b37604ce20 100644 --- a/htdocs/core/lib/functions2.lib.php +++ b/htdocs/core/lib/functions2.lib.php @@ -227,12 +227,12 @@ function dol_print_object_info($object, $usetable = 0) else print ': '; if (is_object($object->user_creation)) { - if ($object->user_creation->id) print $object->user_creation->getNomUrl(1, '', 0, 0, 0); + if ($object->user_creation->id) print $object->user_creation->getNomUrl(-1, '', 0, 0, 0); else print $langs->trans("Unknown"); } else { $userstatic = new User($db); $userstatic->fetch($object->user_creation_id ? $object->user_creation_id : $object->user_creation); - if ($userstatic->id) print $userstatic->getNomUrl(1, '', 0, 0, 0); + if ($userstatic->id) print $userstatic->getNomUrl(-1, '', 0, 0, 0); else print $langs->trans("Unknown"); } if ($usetable) print ''; @@ -261,12 +261,12 @@ function dol_print_object_info($object, $usetable = 0) else print ': '; if (is_object($object->user_modification)) { - if ($object->user_modification->id) print $object->user_modification->getNomUrl(1, '', 0, 0, 0); + if ($object->user_modification->id) print $object->user_modification->getNomUrl(-1, '', 0, 0, 0); else print $langs->trans("Unknown"); } else { $userstatic = new User($db); $userstatic->fetch($object->user_modification_id ? $object->user_modification_id : $object->user_modification); - if ($userstatic->id) print $userstatic->getNomUrl(1, '', 0, 0, 0); + if ($userstatic->id) print $userstatic->getNomUrl(-1, '', 0, 0, 0); else print $langs->trans("Unknown"); } if ($usetable) print ''; @@ -295,12 +295,12 @@ function dol_print_object_info($object, $usetable = 0) else print ': '; if (is_object($object->user_validation)) { - if ($object->user_validation->id) print $object->user_validation->getNomUrl(1, '', 0, 0, 0); + if ($object->user_validation->id) print $object->user_validation->getNomUrl(-1, '', 0, 0, 0); else print $langs->trans("Unknown"); } else { $userstatic = new User($db); $userstatic->fetch($object->user_validation_id ? $object->user_validation_id : $object->user_validation); - if ($userstatic->id) print $userstatic->getNomUrl(1, '', 0, 0, 0); + if ($userstatic->id) print $userstatic->getNomUrl(-1, '', 0, 0, 0); else print $langs->trans("Unknown"); } if ($usetable) print ''; @@ -329,12 +329,12 @@ function dol_print_object_info($object, $usetable = 0) else print ': '; if (is_object($object->user_approve)) { - if ($object->user_approve->id) print $object->user_approve->getNomUrl(1, '', 0, 0, 0); + if ($object->user_approve->id) print $object->user_approve->getNomUrl(-1, '', 0, 0, 0); else print $langs->trans("Unknown"); } else { $userstatic = new User($db); $userstatic->fetch($object->user_approve_id ? $object->user_approve_id : $object->user_approve); - if ($userstatic->id) print $userstatic->getNomUrl(1, '', 0, 0, 0); + if ($userstatic->id) print $userstatic->getNomUrl(-1, '', 0, 0, 0); else print $langs->trans("Unknown"); } if ($usetable) print ''; @@ -363,7 +363,7 @@ function dol_print_object_info($object, $usetable = 0) else print ': '; $userstatic = new User($db); $userstatic->fetch($object->user_approve_id2); - if ($userstatic->id) print $userstatic->getNomUrl(1, '', 0, 0, 0); + if ($userstatic->id) print $userstatic->getNomUrl(-1, '', 0, 0, 0); else print $langs->trans("Unknown"); if ($usetable) print ''; else print '
'; @@ -392,12 +392,12 @@ function dol_print_object_info($object, $usetable = 0) else print ': '; if (is_object($object->user_closing)) { - if ($object->user_closing->id) print $object->user_closing->getNomUrl(1, '', 0, 0, 0); + if ($object->user_closing->id) print $object->user_closing->getNomUrl(-1, '', 0, 0, 0); else print $langs->trans("Unknown"); } else { $userstatic = new User($db); $userstatic->fetch($object->user_closing); - if ($userstatic->id) print $userstatic->getNomUrl(1, '', 0, 0, 0); + if ($userstatic->id) print $userstatic->getNomUrl(-1, '', 0, 0, 0); else print $langs->trans("Unknown"); } if ($usetable) print ''; @@ -427,7 +427,7 @@ function dol_print_object_info($object, $usetable = 0) else print ': '; if (is_object($object->user_rappro)) { - if ($object->user_rappro->id) print $object->user_rappro->getNomUrl(1, '', 0, 0, 0); + if ($object->user_rappro->id) print $object->user_rappro->getNomUrl(-1, '', 0, 0, 0); else print $langs->trans("Unknown"); } else { $userstatic = new User($db); @@ -492,7 +492,7 @@ function dolAddEmailTrackId($email, $trackingid) function isValidMailDomain($mail) { list($user, $domain) = explode("@", $mail, 2); - return ($domain ? isValidMXRecord($domain, "MX") : 0); + return ($domain ? isValidMXRecord($domain) : 0); } /** @@ -1641,7 +1641,7 @@ function getListOfModels($db, $type, $maxfilenamelength = 0) $liste[$obj->id.':'.$key] = ($obj->label ? $obj->label : $obj->doc_template_name).' '.$val['name']; } } else { - // Common usage + // Common usage $liste[$obj->id] = $obj->label ? $obj->label : $obj->doc_template_name; } } diff --git a/htdocs/core/lib/geturl.lib.php b/htdocs/core/lib/geturl.lib.php index e6e20692317..9a4ac16e2f2 100644 --- a/htdocs/core/lib/geturl.lib.php +++ b/htdocs/core/lib/geturl.lib.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2008-2020 Laurent Destailleur * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -18,20 +18,24 @@ /** * \file htdocs/core/lib/geturl.lib.php - * \brief This file contains functions dedicated to get URL. + * \brief This file contains functions dedicated to get URLs. */ /** - * Function to get a content from an URL (use proxy if proxy defined) + * Function to get a content from an URL (use proxy if proxy defined). + * Support Dolibarr setup for timeout and proxy. + * Enhancement of CURL to add an anti SSRF protection. * * @param string $url URL to call. * @param string $postorget 'POST', 'GET', 'HEAD', 'PUT', 'PUTALREADYFORMATED', 'POSTALREADYFORMATED', 'DELETE' - * @param string $param Parameters of URL (x=value1&y=value2) or may be a formated content with PUTALREADYFORMATED - * @param integer $followlocation 1=Follow location, 0=Do not follow + * @param string $param Parameters of URL (x=value1&y=value2) or may be a formated content with $postorget='PUTALREADYFORMATED' + * @param integer $followlocation 0=Do not follow, 1=Follow location. * @param string[] $addheaders Array of string to add into header. Example: ('Accept: application/xrds+xml', ....) + * @param string[] $allowedschemes List of schemes that are allowed ('http' + 'https' only by default) + * @param int $localurl 0=Only external URL are possible, 1=Only local URL, 2=Both external and local URL are allowed. * @return array Returns an associative array containing the response from the server array('content'=>response,'curl_error_no'=>errno,'curl_error_msg'=>errmsg...) */ -function getURLContent($url, $postorget = 'GET', $param = '', $followlocation = 1, $addheaders = array()) +function getURLContent($url, $postorget = 'GET', $param = '', $followlocation = 1, $addheaders = array(), $allowedschemes = array('http', 'https'), $localurl = 0) { //declaring of global variables global $conf; @@ -50,13 +54,14 @@ function getURLContent($url, $postorget = 'GET', $param = '', $followlocation = print $USE_PROXY."-".$gv_ApiErrorURL."
"; print $nvpStr; exit;*/ - curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_VERBOSE, 1); curl_setopt($ch, CURLOPT_USERAGENT, 'Dolibarr geturl function'); - @curl_setopt($ch, CURLOPT_FOLLOWLOCATION, ($followlocation ?true:false)); // We use @ here because this may return warning if safe mode is on or open_basedir is on + // We use @ here because this may return warning if safe mode is on or open_basedir is on (following location is forbidden when safe mode is on). + // We force value to false so we will manage redirection ourself later. + @curl_setopt($ch, CURLOPT_FOLLOWLOCATION, false); - if (count($addheaders)) curl_setopt($ch, CURLOPT_HTTPHEADER, $addheaders); + if (is_array($addheaders) && count($addheaders)) curl_setopt($ch, CURLOPT_HTTPHEADER, $addheaders); curl_setopt($ch, CURLINFO_HEADER_OUT, true); // To be able to retrieve request header and log it // By default use tls decied by PHP. @@ -64,25 +69,33 @@ function getURLContent($url, $postorget = 'GET', $param = '', $followlocation = if (!empty($conf->global->MAIN_CURL_SSLVERSION)) curl_setopt($ch, CURLOPT_SSLVERSION, $conf->global->MAIN_CURL_SSLVERSION); //curl_setopt($ch, CURLOPT_SSLVERSION, 6); for tls 1.2 - //turning off the server and peer verification(TrustManager Concept). + // Turning off the server and peer verification(TrustManager Concept). curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); + // Restrict use to some protocols only + $protocols = 0; + if (is_array($allowedschemes)) { + foreach($allowedschemes as $allowedscheme) { + if ($allowedscheme == 'http') $protocols |= CURLPROTO_HTTP; + if ($allowedscheme == 'https') $protocols |= CURLPROTO_HTTPS; + } + curl_setopt($ch, CURLOPT_PROTOCOLS, $protocols); + curl_setopt($ch, CURLOPT_REDIR_PROTOCOLS, $protocols); + } + curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, empty($conf->global->MAIN_USE_CONNECT_TIMEOUT) ? 5 : $conf->global->MAIN_USE_CONNECT_TIMEOUT); curl_setopt($ch, CURLOPT_TIMEOUT, empty($conf->global->MAIN_USE_RESPONSE_TIMEOUT) ? 30 : $conf->global->MAIN_USE_RESPONSE_TIMEOUT); //curl_setopt($ch, CURLOPT_SAFE_UPLOAD, true); // PHP 5.5 curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); // We want response - if ($postorget == 'POST') - { + if ($postorget == 'POST') { curl_setopt($ch, CURLOPT_POST, 1); // POST curl_setopt($ch, CURLOPT_POSTFIELDS, $param); // Setting param x=a&y=z as POST fields - } elseif ($postorget == 'POSTALREADYFORMATED') - { + } elseif ($postorget == 'POSTALREADYFORMATED') { curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST'); // HTTP request is 'POST' but param string is taken as it is curl_setopt($ch, CURLOPT_POSTFIELDS, $param); // param = content of post, like a xml string - } elseif ($postorget == 'PUT') - { + } elseif ($postorget == 'PUT') { $array_param = null; curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT'); // HTTP request is 'PUT' if (!is_array($param)) parse_str($param, $array_param); @@ -91,32 +104,90 @@ function getURLContent($url, $postorget = 'GET', $param = '', $followlocation = $array_param = $param; } curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($array_param)); // Setting param x=a&y=z as PUT fields - } elseif ($postorget == 'PUTALREADYFORMATED') - { + } elseif ($postorget == 'PUTALREADYFORMATED') { curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT'); // HTTP request is 'PUT' curl_setopt($ch, CURLOPT_POSTFIELDS, $param); // param = content of post, like a xml string - } elseif ($postorget == 'HEAD') - { + } elseif ($postorget == 'HEAD') { curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'HEAD'); // HTTP request is 'HEAD' curl_setopt($ch, CURLOPT_NOBODY, true); - } elseif ($postorget == 'DELETE') - { + } elseif ($postorget == 'DELETE') { curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'DELETE'); // POST } else { curl_setopt($ch, CURLOPT_POST, 0); // GET } //if USE_PROXY constant set at begin of this method. - if ($USE_PROXY) - { + if ($USE_PROXY) { dol_syslog("getURLContent set proxy to ".$PROXY_HOST.":".$PROXY_PORT." - ".$PROXY_USER.":".$PROXY_PASS); //curl_setopt ($ch, CURLOPT_PROXYTYPE, CURLPROXY_HTTP); // Curl 7.10 curl_setopt($ch, CURLOPT_PROXY, $PROXY_HOST.":".$PROXY_PORT); if ($PROXY_USER) curl_setopt($ch, CURLOPT_PROXYUSERPWD, $PROXY_USER.":".$PROXY_PASS); } - //getting response from server - $response = curl_exec($ch); + $newUrl = $url; + $maxRedirection = 5; + $info = array(); + $response = ''; + + do + { + if ($maxRedirection < 1) break; + + curl_setopt($ch, CURLOPT_URL, $newUrl); + + // Parse $newUrl + $newUrlArray = parse_url($newUrl); + $hosttocheck = $newUrlArray['host']; + $hosttocheck = str_replace(array('[', ']'), '', $hosttocheck); // Remove brackets of IPv6 + + if (in_array($hosttocheck, array('localhost', 'localhost.domain'))) { + $iptocheck = '127.0.0.1'; + } else { + // TODO Resolve $iptocheck to get an IP and set CURLOPT_CONNECT_TO to use this ip + $iptocheck = $hosttocheck; + } + + if (!filter_var($iptocheck, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4 | FILTER_FLAG_IPV6)) { // This is not an IP + $iptocheck = 0; // + } + + if ($iptocheck) { + if ($localurl == 0) { // Only external url allowed (dangerous, may allow to get malware) + if (!filter_var($iptocheck, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE)) { + $info['http_code'] = 400; + $info['content'] = 'Error bad hostname IP (private or reserved range). Must be an external URL.'; + break; + } + if (in_array($iptocheck, array('100.100.100.200'))) { + $info['http_code'] = 400; + $info['content'] = 'Error bad hostname IP (Used by Alibaba metadata). Must be an external URL.'; + break; + } + } + if ($localurl == 1) { // Only local url allowed (dangerous, may allow to get metadata on server or make internal port scanning) + if (filter_var($iptocheck, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE)) { + $info['http_code'] = 400; + $info['content'] = 'Error bad hostname. Must be a local URL.'; + break; + } + } + } + + // Getting response from server + $response = curl_exec($ch); + + $info = curl_getinfo($ch); // Reading of request must be done after sending request + $http_code = $info['http_code']; + if ($followlocation && ($http_code == 301 || $http_code == 302 || $http_code == 303 || $http_code == 307)) { + $newUrl = $info['redirect_url']; + $maxRedirection--; + // TODO Use $info['local_ip'] and $info['primary_ip'] ? + continue; + } else { + $http_code = 0; + } + } + while($http_code); $request = curl_getinfo($ch, CURLINFO_HEADER_OUT); // Reading of request must be done after sending request @@ -136,7 +207,7 @@ function getURLContent($url, $postorget = 'GET', $param = '', $followlocation = dol_syslog("getURLContent response array is ".join(',', $rep)); } else { - $info = curl_getinfo($ch); + //$info = curl_getinfo($ch); // Ad keys to $rep $rep = $info; @@ -148,11 +219,11 @@ function getURLContent($url, $postorget = 'GET', $param = '', $followlocation = $rep['content'] = $response; $rep['curl_error_no'] = ''; $rep['curl_error_msg'] = ''; - - //closing the curl - curl_close($ch); } + //closing the curl + curl_close($ch); + return $rep; } diff --git a/htdocs/core/lib/loan.lib.php b/htdocs/core/lib/loan.lib.php index 638eb83b9cd..3a34d3e57c4 100644 --- a/htdocs/core/lib/loan.lib.php +++ b/htdocs/core/lib/loan.lib.php @@ -32,10 +32,10 @@ */ function loan_prepare_head($object) { - global $db, $langs, $conf; + global $db, $langs, $conf; - $tab = 0; - $head = array(); + $tab = 0; + $head = array(); $head[$tab][0] = DOL_URL_ROOT.'/loan/card.php?id='.$object->id; $head[$tab][1] = $langs->trans('Card'); @@ -47,17 +47,17 @@ function loan_prepare_head($object) $head[$tab][2] = 'FinancialCommitment'; $tab++; - // Show more tabs from modules - // Entries must be declared in modules descriptor with line - // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab - // $this->tabs = array('entity:-tabname); to remove a tab - complete_head_from_modules($conf, $langs, $object, $head, $tab, 'loan'); + // Show more tabs from modules + // Entries must be declared in modules descriptor with line + // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab + // $this->tabs = array('entity:-tabname); to remove a tab + complete_head_from_modules($conf, $langs, $object, $head, $tab, 'loan'); require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; - require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php'; + require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php'; $upload_dir = $conf->loan->dir_output."/".dol_sanitizeFileName($object->ref); $nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$')); - $nbLinks = Link::count($db, $object->element, $object->id); + $nbLinks = Link::count($db, $object->element, $object->id); $head[$tab][0] = DOL_URL_ROOT.'/loan/document.php?id='.$object->id; $head[$tab][1] = $langs->trans("Documents"); if (($nbFiles + $nbLinks) > 0) $head[$tab][1] .= ''.($nbFiles + $nbLinks).''; @@ -73,14 +73,14 @@ function loan_prepare_head($object) $tab++; } - $head[$tab][0] = DOL_URL_ROOT.'/loan/info.php?id='.$object->id; - $head[$tab][1] = $langs->trans("Info"); - $head[$tab][2] = 'info'; - $tab++; + $head[$tab][0] = DOL_URL_ROOT.'/loan/info.php?id='.$object->id; + $head[$tab][1] = $langs->trans("Info"); + $head[$tab][2] = 'info'; + $tab++; - complete_head_from_modules($conf, $langs, $object, $head, $tab, 'loan', 'remove'); + complete_head_from_modules($conf, $langs, $object, $head, $tab, 'loan', 'remove'); - return $head; + return $head; } /** @@ -95,42 +95,42 @@ function loan_prepare_head($object) */ function loanCalcMonthlyPayment($mens, $capital, $rate, $echance, $nbterm) { - global $conf, $db; - require_once DOL_DOCUMENT_ROOT.'/loan/class/loanschedule.class.php'; - $object = new LoanSchedule($db); - $output = array(); + global $conf, $db; + require_once DOL_DOCUMENT_ROOT.'/loan/class/loanschedule.class.php'; + $object = new LoanSchedule($db); + $output = array(); - // If mensuality is 0 we don't pay interests and remaining capital not modified - if ($mens == 0) { - $int = 0; - $cap_rest = $capital; - } else { - $int = ($capital * ($rate / 12)); - $int = round($int, 2, PHP_ROUND_HALF_UP); - $cap_rest = round($capital - ($mens - $int), 2, PHP_ROUND_HALF_UP); - } - $output[$echance] = array('cap_rest'=>$cap_rest, 'cap_rest_str'=>price($cap_rest, 0, '', 1, -1, -1, $conf->currency), 'interet'=>$int, 'interet_str'=>price($int, 0, '', 1, -1, -1, $conf->currency), 'mens'=>$mens); + // If mensuality is 0 we don't pay interests and remaining capital not modified + if ($mens == 0) { + $int = 0; + $cap_rest = $capital; + } else { + $int = ($capital * ($rate / 12)); + $int = round($int, 2, PHP_ROUND_HALF_UP); + $cap_rest = round($capital - ($mens - $int), 2, PHP_ROUND_HALF_UP); + } + $output[$echance] = array('cap_rest'=>$cap_rest, 'cap_rest_str'=>price($cap_rest, 0, '', 1, -1, -1, $conf->currency), 'interet'=>$int, 'interet_str'=>price($int, 0, '', 1, -1, -1, $conf->currency), 'mens'=>$mens); - $echance++; - $capital = $cap_rest; - while ($echance <= $nbterm) { - $mens = round($object->calcMonthlyPayments($capital, $rate, $nbterm - $echance + 1), 2, PHP_ROUND_HALF_UP); + $echance++; + $capital = $cap_rest; + while ($echance <= $nbterm) { + $mens = round($object->calcMonthlyPayments($capital, $rate, $nbterm - $echance + 1), 2, PHP_ROUND_HALF_UP); - $int = ($capital * ($rate / 12)); - $int = round($int, 2, PHP_ROUND_HALF_UP); - $cap_rest = round($capital - ($mens - $int), 2, PHP_ROUND_HALF_UP); + $int = ($capital * ($rate / 12)); + $int = round($int, 2, PHP_ROUND_HALF_UP); + $cap_rest = round($capital - ($mens - $int), 2, PHP_ROUND_HALF_UP); - $output[$echance] = array( - 'cap_rest' => $cap_rest, - 'cap_rest_str' => price($cap_rest, 0, '', 1, -1, -1, $conf->currency), - 'interet' => $int, - 'interet_str' => price($int, 0, '', 1, -1, -1, $conf->currency), - 'mens' => $mens, - ); + $output[$echance] = array( + 'cap_rest' => $cap_rest, + 'cap_rest_str' => price($cap_rest, 0, '', 1, -1, -1, $conf->currency), + 'interet' => $int, + 'interet_str' => price($int, 0, '', 1, -1, -1, $conf->currency), + 'mens' => $mens, + ); - $capital = $cap_rest; - $echance++; - } + $capital = $cap_rest; + $echance++; + } - return $output; + return $output; } diff --git a/htdocs/core/lib/product.lib.php b/htdocs/core/lib/product.lib.php index 8c0253e927c..d643498162f 100644 --- a/htdocs/core/lib/product.lib.php +++ b/htdocs/core/lib/product.lib.php @@ -357,7 +357,7 @@ function show_stats_for_company($product, $socid) print ''.$langs->trans("TotalQuantity").''; print ''; - // Customer proposals + // Customer proposals if (!empty($conf->propal->enabled) && $user->rights->propale->lire) { $nblines++; @@ -509,7 +509,6 @@ function show_stats_for_company($product, $socid) print ''; } - // MO if (!empty($conf->mrp->enabled) && $user->rights->mrp->read) { diff --git a/htdocs/core/lib/report.lib.php b/htdocs/core/lib/report.lib.php index 385c22146b9..b23acd76a5b 100644 --- a/htdocs/core/lib/report.lib.php +++ b/htdocs/core/lib/report.lib.php @@ -115,7 +115,7 @@ function report_header($reportname, $notused, $period, $periodlink, $description print ''."\n"; - dol_fiche_end(); + print dol_get_fiche_end(); print '
'; diff --git a/htdocs/core/lib/usergroups.lib.php b/htdocs/core/lib/usergroups.lib.php index 722c0f41263..d82b57f8d0c 100644 --- a/htdocs/core/lib/usergroups.lib.php +++ b/htdocs/core/lib/usergroups.lib.php @@ -38,8 +38,7 @@ function user_prepare_head($object) $langs->load("users"); $canreadperms = true; - if (!empty($conf->global->MAIN_USE_ADVANCED_PERMS)) - { + if (!empty($conf->global->MAIN_USE_ADVANCED_PERMS)) { $canreadperms = ($user->admin || ($user->id != $object->id && $user->rights->user->user_advance->readperms) || ($user->id == $object->id && $user->rights->user->self_advance->readperms)); } @@ -52,8 +51,7 @@ function user_prepare_head($object) $h++; if ((!empty($conf->ldap->enabled) && !empty($conf->global->LDAP_SYNCHRO_ACTIVE)) - && (empty($conf->global->MAIN_DISABLE_LDAP_TAB) || !empty($user->admin))) - { + && (empty($conf->global->MAIN_DISABLE_LDAP_TAB) || !empty($user->admin))) { $langs->load("ldap"); $head[$h][0] = DOL_URL_ROOT.'/user/ldap.php?id='.$object->id; $head[$h][1] = $langs->trans("LDAPCard"); @@ -61,8 +59,7 @@ function user_prepare_head($object) $h++; } - if ($canreadperms) - { + if ($canreadperms) { $head[$h][0] = DOL_URL_ROOT.'/user/perms.php?id='.$object->id; $head[$h][1] = $langs->trans("Rights").(empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER) ? ''.($object->nb_rights).'' : ''); $head[$h][2] = 'rights'; @@ -74,15 +71,13 @@ function user_prepare_head($object) $head[$h][2] = 'guisetup'; $h++; - if (!empty($conf->agenda->enabled)) - { + if (!empty($conf->agenda->enabled)) { if (empty($conf->global->AGENDA_EXT_NB)) $conf->global->AGENDA_EXT_NB = 5; $MAXAGENDA = $conf->global->AGENDA_EXT_NB; $i = 1; $nbagenda = 0; - while ($i <= $MAXAGENDA) - { + while ($i <= $MAXAGENDA) { $key = $i; $name = 'AGENDA_EXT_NAME_'.$object->id.'_'.$key; $src = 'AGENDA_EXT_SRC_'.$object->id.'_'.$key; @@ -99,8 +94,7 @@ function user_prepare_head($object) $h++; } - if (!empty($conf->clicktodial->enabled)) - { + if (!empty($conf->clicktodial->enabled)) { $head[$h][0] = DOL_URL_ROOT.'/user/clicktodial.php?id='.$object->id; $head[$h][1] = $langs->trans("ClickToDial"); $head[$h][2] = 'clicktodial'; @@ -108,19 +102,16 @@ function user_prepare_head($object) } // Notifications - if ($user->socid == 0 && !empty($conf->notification->enabled)) - { + if ($user->socid == 0 && !empty($conf->notification->enabled)) { $nbNote = 0; $sql = "SELECT COUNT(n.rowid) as nb"; $sql .= " FROM ".MAIN_DB_PREFIX."notify_def as n"; $sql .= " WHERE fk_user = ".$object->id; $resql = $db->query($sql); - if ($resql) - { + if ($resql) { $num = $db->num_rows($resql); $i = 0; - while ($i < $num) - { + while ($i < $num) { $obj = $db->fetch_object($resql); $nbNote = $obj->nb; $i++; @@ -147,8 +138,7 @@ function user_prepare_head($object) || (!empty($conf->hrm->enabled) && !empty($user->rights->hrm->employee->read)) || (!empty($conf->expensereport->enabled) && !empty($user->rights->expensereport->lire) && ($user->id == $object->id || $user->rights->expensereport->readall)) || (!empty($conf->holiday->enabled) && !empty($user->rights->holiday->read) && ($user->id == $object->id || $user->rights->holiday->read_all)) - ) - { + ) { // Bank $head[$h][0] = DOL_URL_ROOT.'/user/bank.php?id='.$object->id; $head[$h][1] = $langs->trans("HRAndBank"); @@ -157,8 +147,7 @@ function user_prepare_head($object) } // Such info on users is visible only by internal user - if (empty($user->socid)) - { + if (empty($user->socid)) { // Notes $nbNote = 0; if (!empty($object->note)) $nbNote++; @@ -202,8 +191,7 @@ function group_prepare_head($object) global $langs, $conf, $user; $canreadperms = true; - if (!empty($conf->global->MAIN_USE_ADVANCED_PERMS)) - { + if (!empty($conf->global->MAIN_USE_ADVANCED_PERMS)) { $canreadperms = ($user->admin || $user->rights->user->group_advance->readperms); } @@ -216,8 +204,7 @@ function group_prepare_head($object) $h++; if ((!empty($conf->ldap->enabled) && !empty($conf->global->LDAP_SYNCHRO_ACTIVE)) - && (empty($conf->global->MAIN_DISABLE_LDAP_TAB) || !empty($user->admin))) - { + && (empty($conf->global->MAIN_DISABLE_LDAP_TAB) || !empty($user->admin))) { $langs->load("ldap"); $head[$h][0] = DOL_URL_ROOT.'/user/group/ldap.php?id='.$object->id; $head[$h][1] = $langs->trans("LDAPCard"); @@ -225,8 +212,7 @@ function group_prepare_head($object) $h++; } - if ($canreadperms) - { + if ($canreadperms) { $head[$h][0] = DOL_URL_ROOT.'/user/group/perms.php?id='.$object->id; $head[$h][1] = $langs->trans("GroupRights").''.($object->nb_rights).''; $head[$h][2] = 'rights'; @@ -305,10 +291,8 @@ function showSkins($fuser, $edit = 0, $foruserprofile = false) $formother = new FormOther($db); $dirthemes = array('/theme'); - if (!empty($conf->modules_parts['theme'])) // Using this feature slow down application - { - foreach ($conf->modules_parts['theme'] as $reldir) - { + if (!empty($conf->modules_parts['theme'])) { // Using this feature slow down application + foreach ($conf->modules_parts['theme'] as $reldir) { $dirthemes = array_merge($dirthemes, (array) ($reldir.'theme')); } } @@ -334,8 +318,7 @@ function showSkins($fuser, $edit = 0, $foruserprofile = false) print ''; // Title - if ($foruserprofile) - { + if ($foruserprofile) { print ''; print ''; print ''; @@ -348,8 +331,7 @@ function showSkins($fuser, $edit = 0, $foruserprofile = false) print ''; } else { $dirthemestring = ''; - foreach ($dirthemes as $dirtheme) - { + foreach ($dirthemes as $dirtheme) { $dirthemestring .= '"'.$dirtheme.'" '; } @@ -369,22 +351,17 @@ function showSkins($fuser, $edit = 0, $foruserprofile = false) print '
'.$langs->trans("Parameter").''.$langs->trans("DefaultValue").' 
'; print ''; @@ -469,7 +442,7 @@ function showSkins($fuser, $edit = 0, $foruserprofile = false) print ''; print ''; print ''; print ''; @@ -510,7 +481,7 @@ function showSkins($fuser, $edit = 0, $foruserprofile = false) print ''; print ''; print ''; @@ -552,7 +521,7 @@ function showSkins($fuser, $edit = 0, $foruserprofile = false) print ''; print ''; print ''; print ''; @@ -595,7 +562,7 @@ function showSkins($fuser, $edit = 0, $foruserprofile = false) print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; @@ -773,7 +726,7 @@ function showSkins($fuser, $edit = 0, $foruserprofile = false) print ''; print ''; print ''; print ''; @@ -828,16 +779,14 @@ function showSkins($fuser, $edit = 0, $foruserprofile = false) print ''; print ''; @@ -868,16 +816,14 @@ function showSkins($fuser, $edit = 0, $foruserprofile = false) print ''; print ''; print ''; @@ -953,8 +895,7 @@ function showSkins($fuser, $edit = 0, $foruserprofile = false) 'tritanopes' => $langs->trans('Tritanopes'), ); - if ($edit) - { + if ($edit) { print $form->selectArray('MAIN_OPTIMIZEFORCOLORBLIND', $colorBlindOptions, $fuser->conf->MAIN_OPTIMIZEFORCOLORBLIND, 0); } else { if (!empty($fuser->conf->MAIN_OPTIMIZEFORCOLORBLIND) && isset($colorBlindOptions[$fuser->conf->MAIN_OPTIMIZEFORCOLORBLIND])) { diff --git a/htdocs/core/modules/commande/doc/doc_generic_order_odt.modules.php b/htdocs/core/modules/commande/doc/doc_generic_order_odt.modules.php index 9c8bd72a6a0..64bdf4b9e5c 100644 --- a/htdocs/core/modules/commande/doc/doc_generic_order_odt.modules.php +++ b/htdocs/core/modules/commande/doc/doc_generic_order_odt.modules.php @@ -320,7 +320,7 @@ class doc_generic_order_odt extends ModelePDFCommandes '__FROM_EMAIL__' => $this->emetteur->email, '__TOTAL_TTC__' => $object->total_ttc, '__TOTAL_HT__' => $object->total_ht, - '__TOTAL_VAT__' => $object->total_vat + '__TOTAL_VAT__' => $object->total_tva ); complete_substitutions_array($substitutionarray, $langs, $object); // Call the ODTSubstitution hook diff --git a/htdocs/core/modules/expedition/doc/doc_generic_shipment_odt.modules.php b/htdocs/core/modules/expedition/doc/doc_generic_shipment_odt.modules.php index 122a5abdc10..83f99ec048a 100644 --- a/htdocs/core/modules/expedition/doc/doc_generic_shipment_odt.modules.php +++ b/htdocs/core/modules/expedition/doc/doc_generic_shipment_odt.modules.php @@ -320,7 +320,7 @@ class doc_generic_shipment_odt extends ModelePdfExpedition '__FROM_EMAIL__' => $this->emetteur->email, '__TOTAL_TTC__' => $object->total_ttc, '__TOTAL_HT__' => $object->total_ht, - '__TOTAL_VAT__' => $object->total_vat + '__TOTAL_VAT__' => $object->total_tva ); complete_substitutions_array($substitutionarray, $langs, $object); // Call the ODTSubstitution hook diff --git a/htdocs/core/modules/project/task/mod_task_universal.php b/htdocs/core/modules/project/task/mod_task_universal.php index 0a15a99dfc0..011ac381254 100644 --- a/htdocs/core/modules/project/task/mod_task_universal.php +++ b/htdocs/core/modules/project/task/mod_task_universal.php @@ -31,15 +31,15 @@ require_once DOL_DOCUMENT_ROOT.'/core/modules/project/task/modules_task.php'; class mod_task_universal extends ModeleNumRefTask { /** - * Dolibarr version of the loaded document - * @var string - */ + * Dolibarr version of the loaded document + * @var string + */ public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' /** - * @var string Error code (or message) - */ - public $error = ''; + * @var string Error code (or message) + */ + public $error = ''; /** * @var string @@ -54,17 +54,17 @@ class mod_task_universal extends ModeleNumRefTask public $name = 'Universal'; - /** - * Returns the description of the numbering model - * - * @return string Texte descripif - */ - public function info() - { - global $conf, $langs, $db; + /** + * Returns the description of the numbering model + * + * @return string Texte descripif + */ + public function info() + { + global $conf, $langs, $db; // Load translation files required by the page - $langs->loadLangs(array("projects", "admin")); + $langs->loadLangs(array("projects", "admin")); $form = new Form($db); @@ -93,37 +93,37 @@ class mod_task_universal extends ModeleNumRefTask $texte .= ''; return $texte; - } + } - /** - * Return an example of numbering - * - * @return string Example - */ - public function getExample() - { - global $conf, $langs, $mysoc; + /** + * Return an example of numbering + * + * @return string Example + */ + public function getExample() + { + global $conf, $langs, $mysoc; - $old_code_client = $mysoc->code_client; - $mysoc->code_client = 'CCCCCCCCCC'; - $numExample = $this->getNextValue($mysoc, ''); + $old_code_client = $mysoc->code_client; + $mysoc->code_client = 'CCCCCCCCCC'; + $numExample = $this->getNextValue($mysoc, ''); $mysoc->code_client = $old_code_client; if (!$numExample) { $numExample = $langs->trans('NotConfigured'); } return $numExample; - } + } - /** - * Return next value - * - * @param Societe $objsoc Object third party - * @param Task $object Object task - * @return string Value if OK, 0 if KO - */ - public function getNextValue($objsoc, $object) - { + /** + * Return next value + * + * @param Societe $objsoc Object third party + * @param Task $object Object task + * @return string Value if OK, 0 if KO + */ + public function getNextValue($objsoc, $object) + { global $db, $conf; require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; @@ -143,17 +143,17 @@ class mod_task_universal extends ModeleNumRefTask } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Return next reference not yet used as a reference - * - * @param Societe $objsoc Object third party - * @param Task $object Object task - * @return string Next not used reference - */ - public function project_get_num($objsoc = 0, $object = '') - { - // phpcs:enable - return $this->getNextValue($objsoc, $object); - } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Return next reference not yet used as a reference + * + * @param Societe $objsoc Object third party + * @param Task $object Object task + * @return string Next not used reference + */ + public function project_get_num($objsoc = 0, $object = '') + { + // phpcs:enable + return $this->getNextValue($objsoc, $object); + } } diff --git a/htdocs/core/modules/propale/doc/doc_generic_proposal_odt.modules.php b/htdocs/core/modules/propale/doc/doc_generic_proposal_odt.modules.php index 59e0e27b677..81934f0b97c 100644 --- a/htdocs/core/modules/propale/doc/doc_generic_proposal_odt.modules.php +++ b/htdocs/core/modules/propale/doc/doc_generic_proposal_odt.modules.php @@ -348,7 +348,7 @@ class doc_generic_proposal_odt extends ModelePDFPropales '__FROM_EMAIL__' => $this->emetteur->email, '__TOTAL_TTC__' => $object->total_ttc, '__TOTAL_HT__' => $object->total_ht, - '__TOTAL_VAT__' => $object->total_vat + '__TOTAL_VAT__' => $object->total_tva ); complete_substitutions_array($substitutionarray, $langs, $object); // Call the ODTSubstitution hook diff --git a/htdocs/core/modules/stock/doc/doc_generic_stock_odt.modules.php b/htdocs/core/modules/stock/doc/doc_generic_stock_odt.modules.php index 89be1983115..89a5ea9d784 100644 --- a/htdocs/core/modules/stock/doc/doc_generic_stock_odt.modules.php +++ b/htdocs/core/modules/stock/doc/doc_generic_stock_odt.modules.php @@ -323,7 +323,7 @@ class doc_generic_stock_odt extends ModelePDFStock '__FROM_EMAIL__' => $this->emetteur->email, '__TOTAL_TTC__' => $object->total_ttc, '__TOTAL_HT__' => $object->total_ht, - '__TOTAL_VAT__' => $object->total_vat + '__TOTAL_VAT__' => $object->total_tva ); complete_substitutions_array($substitutionarray, $langs, $object); // Call the ODTSubstitution hook diff --git a/htdocs/core/modules/supplier_order/doc/doc_generic_supplier_order_odt.modules.php b/htdocs/core/modules/supplier_order/doc/doc_generic_supplier_order_odt.modules.php index 9c9e43a9475..80cb9fcd00a 100644 --- a/htdocs/core/modules/supplier_order/doc/doc_generic_supplier_order_odt.modules.php +++ b/htdocs/core/modules/supplier_order/doc/doc_generic_supplier_order_odt.modules.php @@ -312,7 +312,7 @@ class doc_generic_supplier_order_odt extends ModelePDFSuppliersOrders '__FROM_EMAIL__' => $this->issuer->email, '__TOTAL_TTC__' => $object->total_ttc, '__TOTAL_HT__' => $object->total_ht, - '__TOTAL_VAT__' => $object->total_vat + '__TOTAL_VAT__' => $object->total_tva ); complete_substitutions_array($substitutionarray, $langs, $object); // Call the ODTSubstitution hook diff --git a/htdocs/core/modules/supplier_proposal/doc/doc_generic_supplier_proposal_odt.modules.php b/htdocs/core/modules/supplier_proposal/doc/doc_generic_supplier_proposal_odt.modules.php index ea6c1574149..56438ce9071 100644 --- a/htdocs/core/modules/supplier_proposal/doc/doc_generic_supplier_proposal_odt.modules.php +++ b/htdocs/core/modules/supplier_proposal/doc/doc_generic_supplier_proposal_odt.modules.php @@ -349,7 +349,7 @@ class doc_generic_supplier_proposal_odt extends ModelePDFSupplierProposal '__FROM_EMAIL__' => $this->emetteur->email, '__TOTAL_TTC__' => $object->total_ttc, '__TOTAL_HT__' => $object->total_ht, - '__TOTAL_VAT__' => $object->total_vat + '__TOTAL_VAT__' => $object->total_tva ); complete_substitutions_array($substitutionarray, $langs, $object); // Call the ODTSubstitution hook diff --git a/htdocs/core/modules/ticket/mod_ticket_simple.php b/htdocs/core/modules/ticket/mod_ticket_simple.php index 679224c5357..2badaf4a33f 100644 --- a/htdocs/core/modules/ticket/mod_ticket_simple.php +++ b/htdocs/core/modules/ticket/mod_ticket_simple.php @@ -115,9 +115,9 @@ class mod_ticket_simple extends ModeleNumRefTicket /** * Return next value * - * @param Societe $objsoc Object third party - * @param Project $ticket Object ticket - * @return string Value if OK, 0 if KO + * @param Societe $objsoc Object third party + * @param Ticket $ticket Object ticket + * @return string Value if OK, 0 if KO */ public function getNextValue($objsoc, $ticket) { diff --git a/htdocs/core/modules/ticket/mod_ticket_universal.php b/htdocs/core/modules/ticket/mod_ticket_universal.php index 010eb973f9b..db1f9e3b391 100644 --- a/htdocs/core/modules/ticket/mod_ticket_universal.php +++ b/htdocs/core/modules/ticket/mod_ticket_universal.php @@ -116,9 +116,9 @@ class mod_ticket_universal extends ModeleNumRefTicket /** * Return next value * - * @param Societe $objsoc Object third party - * @param Project $ticket Object ticket - * @return string Value if OK, 0 if KO + * @param Societe $objsoc Object third party + * @param Ticket $ticket Object ticket + * @return string Value if OK, 0 if KO */ public function getNextValue($objsoc, $ticket) { @@ -134,7 +134,7 @@ class mod_ticket_universal extends ModeleNumRefTicket return 0; } - $date = empty($ticket->date_c) ? dol_now() : $ticket->datec; + $date = empty($ticket->datec) ? dol_now() : $ticket->datec; $numFinal = get_next_value($db, $mask, 'ticket', 'ref', '', $objsoc->code_client, $date); return $numFinal; diff --git a/htdocs/core/modules/usergroup/doc/doc_generic_usergroup_odt.modules.php b/htdocs/core/modules/usergroup/doc/doc_generic_usergroup_odt.modules.php index 391eab28838..ef1d72736f9 100644 --- a/htdocs/core/modules/usergroup/doc/doc_generic_usergroup_odt.modules.php +++ b/htdocs/core/modules/usergroup/doc/doc_generic_usergroup_odt.modules.php @@ -330,7 +330,7 @@ class doc_generic_usergroup_odt extends ModelePDFUserGroup '__FROM_EMAIL__' => $this->emetteur->email, '__TOTAL_TTC__' => $object->total_ttc, '__TOTAL_HT__' => $object->total_ht, - '__TOTAL_VAT__' => $object->total_vat + '__TOTAL_VAT__' => $object->total_tva ); complete_substitutions_array($substitutionarray, $langs, $object); // Call the ODTSubstitution hook diff --git a/htdocs/core/tpl/admin_extrafields_add.tpl.php b/htdocs/core/tpl/admin_extrafields_add.tpl.php index 69bf77262c8..4bc2bbe8d7a 100644 --- a/htdocs/core/tpl/admin_extrafields_add.tpl.php +++ b/htdocs/core/tpl/admin_extrafields_add.tpl.php @@ -211,7 +211,7 @@ $listofexamplesforlink = 'Societe:societe/class/societe.class.php
Contact:con
'; $i = 0; - foreach ($dirthemes as $dir) - { + foreach ($dirthemes as $dir) { //print $dirroot.$dir;exit; $dirtheme = dol_buildpath($dir, 0); // This include loop on $conf->file->dol_document_root $urltheme = dol_buildpath($dir, 1); - if (is_dir($dirtheme)) - { + if (is_dir($dirtheme)) { $handle = opendir($dirtheme); - if (is_resource($handle)) - { - while (($subdir = readdir($handle)) !== false) - { + if (is_resource($handle)) { + while (($subdir = readdir($handle)) !== false) { if (is_dir($dirtheme."/".$subdir) && substr($subdir, 0, 1) <> '.' - && substr($subdir, 0, 3) <> 'CVS' && !preg_match('/common|phones/i', $subdir)) - { + && substr($subdir, 0, 3) <> 'CVS' && !preg_match('/common|phones/i', $subdir)) { // Disable not stable themes (dir ends with _exp or _dev) if ($conf->global->MAIN_FEATURES_LEVEL < 2 && preg_match('/_dev$/i', $subdir)) continue; if ($conf->global->MAIN_FEATURES_LEVEL < 1 && preg_match('/_exp$/i', $subdir)) continue; @@ -398,8 +375,7 @@ function showSkins($fuser, $edit = 0, $foruserprofile = false) else $title = $langs->trans("ShowPreview"); print ''.$title.''; print '
'; - if ($subdir == $selected_theme) - { + if ($subdir == $selected_theme) { print ' '.$subdir.''; } else { print ' '.$subdir; @@ -435,14 +411,12 @@ function showSkins($fuser, $edit = 0, $foruserprofile = false) } // Show logo - if ($foruserprofile) - { + if ($foruserprofile) { // Nothing } else { // Show logo print '
'.$langs->trans("EnableShowLogo").''; - if ($edit) - { + if ($edit) { print ajax_constantonoff('MAIN_SHOW_LOGO', array(), null, 0, 0, 1); //print $form->selectyesno('MAIN_SHOW_LOGO', $conf->global->MAIN_SHOW_LOGO, 1); } else { @@ -457,8 +431,7 @@ function showSkins($fuser, $edit = 0, $foruserprofile = false) // TopMenuDisableImages - if ($foruserprofile) - { + if ($foruserprofile) { /* print '
'.$langs->trans("TopMenuDisableImages").''; if ($edit) { - print $formother->selectColor(colorArrayToHex(colorStringToArray($conf->global->THEME_TOPMENU_DISABLE_IMAGE,array()),''),'THEME_TOPMENU_DISABLE_IMAGE','formcolor',1).' '; + print $formother->selectColor(colorArrayToHex(colorStringToArray($conf->global->THEME_TOPMENU_DISABLE_IMAGE,array()),''),'THEME_TOPMENU_DISABLE_IMAGE','',1).' '; } else { @@ -484,8 +457,7 @@ function showSkins($fuser, $edit = 0, $foruserprofile = false) print '
'.$langs->trans("TopMenuDisableImages").''; - if ($edit) - { + if ($edit) { print ajax_constantonoff('THEME_TOPMENU_DISABLE_IMAGE', array(), null, 0, 0, 1); //print $form->selectyesno('THEME_TOPMENU_DISABLE_IMAGE', $conf->global->THEME_TOPMENU_DISABLE_IMAGE, 1); } else { @@ -498,8 +470,7 @@ function showSkins($fuser, $edit = 0, $foruserprofile = false) } // Background color THEME_ELDY_BACKBODY - if ($foruserprofile) - { + if ($foruserprofile) { /* print '
'.$langs->trans("TopMenuBackgroundColor").''; if ($edit) { - print $formother->selectColor(colorArrayToHex(colorStringToArray($conf->global->THEME_ELDY_TOPMENU_BACK1,array()),''),'THEME_ELDY_TOPMENU_BACK1','formcolor',1).' '; + print $formother->selectColor(colorArrayToHex(colorStringToArray($conf->global->THEME_ELDY_TOPMENU_BACK1,array()),''),'THEME_ELDY_TOPMENU_BACK1','',1).' '; } else { @@ -525,9 +496,8 @@ function showSkins($fuser, $edit = 0, $foruserprofile = false) print ''.$langs->trans("BackgroundColor").''; //var_dump($conf->global->THEME_ELDY_BACKBODY); - if ($edit) - { - print $formother->selectColor(colorArrayToHex(colorStringToArray($conf->global->THEME_ELDY_BACKBODY, array()), ''), 'THEME_ELDY_BACKBODY', 'formcolor', 1, '', '', 'colorbackbody').' '; + if ($edit) { + print $formother->selectColor(colorArrayToHex(colorStringToArray($conf->global->THEME_ELDY_BACKBODY, array()), ''), 'THEME_ELDY_BACKBODY', '', 1, '', '', 'colorbackbody').' '; } else { $color = colorArrayToHex(colorStringToArray($conf->global->THEME_ELDY_BACKBODY, array()), ''); if ($color) print ''; @@ -540,8 +510,7 @@ function showSkins($fuser, $edit = 0, $foruserprofile = false) } // TopMenuBackgroundColor - if ($foruserprofile) - { + if ($foruserprofile) { /* print '
'.$langs->trans("TopMenuBackgroundColor").''; if ($edit) { - print $formother->selectColor(colorArrayToHex(colorStringToArray($conf->global->THEME_ELDY_TOPMENU_BACK1,array()),''),'THEME_ELDY_TOPMENU_BACK1','formcolor',1).' '; + print $formother->selectColor(colorArrayToHex(colorStringToArray($conf->global->THEME_ELDY_TOPMENU_BACK1,array()),''),'THEME_ELDY_TOPMENU_BACK1','',1).' '; } else { @@ -568,9 +537,8 @@ function showSkins($fuser, $edit = 0, $foruserprofile = false) print '
'.$langs->trans("TopMenuBackgroundColor").''; - if ($edit) - { - print $formother->selectColor(colorArrayToHex(colorStringToArray($conf->global->THEME_ELDY_TOPMENU_BACK1, array()), ''), 'THEME_ELDY_TOPMENU_BACK1', 'formcolor', 1, '', '', 'colorbackhmenu1').' '; + if ($edit) { + print $formother->selectColor(colorArrayToHex(colorStringToArray($conf->global->THEME_ELDY_TOPMENU_BACK1, array()), ''), 'THEME_ELDY_TOPMENU_BACK1', '', 1, '', '', 'colorbackhmenu1').' '; } else { $color = colorArrayToHex(colorStringToArray($conf->global->THEME_ELDY_TOPMENU_BACK1, array()), ''); if ($color) print ''; @@ -583,8 +551,7 @@ function showSkins($fuser, $edit = 0, $foruserprofile = false) } // LeftMenuBackgroundColor - if ($foruserprofile) - { + if ($foruserprofile) { /* print '
'.$langs->trans("TopMenuBackgroundColor").''; if ($edit) { - print $formother->selectColor(colorArrayToHex(colorStringToArray($conf->global->THEME_ELDY_VERMENU_BACK1,array()),''),'THEME_ELDY_VERMENU_BACK1','formcolor',1).' '; + print $formother->selectColor(colorArrayToHex(colorStringToArray($conf->global->THEME_ELDY_VERMENU_BACK1,array()),''),'THEME_ELDY_VERMENU_BACK1','',1).' '; } else { @@ -611,9 +578,8 @@ function showSkins($fuser, $edit = 0, $foruserprofile = false) print '
'.$langs->trans("LeftMenuBackgroundColor").''; - if ($edit) - { - print $formother->selectColor(colorArrayToHex(colorStringToArray($conf->global->THEME_ELDY_VERMENU_BACK1, array()), ''), 'THEME_ELDY_VERMENU_BACK1', 'formcolor', 1, '', '', 'colorbackvmenu1').' '; + if ($edit) { + print $formother->selectColor(colorArrayToHex(colorStringToArray($conf->global->THEME_ELDY_VERMENU_BACK1, array()), ''), 'THEME_ELDY_VERMENU_BACK1', '', 1, '', '', 'colorbackvmenu1').' '; } else { $color = colorArrayToHex(colorStringToArray($conf->global->THEME_ELDY_VERMENU_BACK1, array()), ''); if ($color) print ''; @@ -626,17 +592,15 @@ function showSkins($fuser, $edit = 0, $foruserprofile = false) } // TextTitleColor for title of Pages - if ($foruserprofile) - { + if ($foruserprofile) { } else { $default = (empty($colortexttitlenotab) ? $langs->trans("Unknown") : colorArrayToHex(colorStringToArray($colortexttitlenotab))); print '
'.$langs->trans("TextTitleColor").''; - if ($edit) - { - print $formother->selectColor(colorArrayToHex(colorStringToArray($conf->global->THEME_ELDY_TEXTTITLENOTAB, array()), ''), 'THEME_ELDY_TEXTTITLENOTAB', 'formcolor', 1, '', '', 'colortexttitlenotab').' '; + if ($edit) { + print $formother->selectColor(colorArrayToHex(colorStringToArray($conf->global->THEME_ELDY_TEXTTITLENOTAB, array()), ''), 'THEME_ELDY_TEXTTITLENOTAB', '', 1, '', '', 'colortexttitlenotab').' '; } else { print $formother->showColor($conf->global->THEME_ELDY_TEXTTITLENOTAB, $langs->trans("Default")); } @@ -648,17 +612,15 @@ function showSkins($fuser, $edit = 0, $foruserprofile = false) } // BackgroundTableTitleColor - if ($foruserprofile) - { + if ($foruserprofile) { } else { $default = (empty($colorbacktitle1) ? $langs->trans("Unknown") : colorArrayToHex(colorStringToArray($colorbacktitle1))); print '
'.$langs->trans("BackgroundTableTitleColor").''; - if ($edit) - { - print $formother->selectColor(colorArrayToHex(colorStringToArray($conf->global->THEME_ELDY_BACKTITLE1, array()), ''), 'THEME_ELDY_BACKTITLE1', 'formcolor', 1, '', '', 'colorbacktitle1').' '; + if ($edit) { + print $formother->selectColor(colorArrayToHex(colorStringToArray($conf->global->THEME_ELDY_BACKTITLE1, array()), ''), 'THEME_ELDY_BACKTITLE1', '', 1, '', '', 'colorbacktitle1').' '; } else { print $formother->showColor($conf->global->THEME_ELDY_BACKTITLE1, $langs->trans("Default")); } @@ -670,17 +632,15 @@ function showSkins($fuser, $edit = 0, $foruserprofile = false) } // TextTitleColor - if ($foruserprofile) - { + if ($foruserprofile) { } else { $default = (empty($colortexttitle) ? $langs->trans("Unknown") : colorArrayToHex(colorStringToArray($colortexttitle))); print '
'.$langs->trans("BackgroundTableTitleTextColor").''; - if ($edit) - { - print $formother->selectColor(colorArrayToHex(colorStringToArray($conf->global->THEME_ELDY_TEXTTITLE, array()), ''), 'THEME_ELDY_TEXTTITLE', 'formcolor', 1, '', '', 'colortexttitle').' '; + if ($edit) { + print $formother->selectColor(colorArrayToHex(colorStringToArray($conf->global->THEME_ELDY_TEXTTITLE, array()), ''), 'THEME_ELDY_TEXTTITLE', '', 1, '', '', 'colortexttitle').' '; } else { print $formother->showColor($conf->global->THEME_ELDY_TEXTTITLE, $langs->trans("Default")); } @@ -692,17 +652,15 @@ function showSkins($fuser, $edit = 0, $foruserprofile = false) } // TextTitleLinkColor - if ($foruserprofile) - { + if ($foruserprofile) { } else { $default=(empty($colortexttitlelink) ? $langs->trans("Unknown") : colorArrayToHex(colorStringToArray($colortexttitlelink))); print '
'.$langs->trans("BackgroundTableTitleTextlinkColor").''; - if ($edit) - { - print $formother->selectColor(colorArrayToHex(colorStringToArray($conf->global->THEME_ELDY_TEXTTITLELINK, array()), ''), 'THEME_ELDY_TEXTTITLELINK', 'formcolor', 1, '', '', 'colortexttitlelink').' '; + if ($edit) { + print $formother->selectColor(colorArrayToHex(colorStringToArray($conf->global->THEME_ELDY_TEXTTITLELINK, array()), ''), 'THEME_ELDY_TEXTTITLELINK', '', 1, '', '', 'colortexttitlelink').' '; } else { print $formother->showColor($conf->global->THEME_ELDY_TEXTTITLELINK, $langs->trans("Default")); } @@ -715,17 +673,15 @@ function showSkins($fuser, $edit = 0, $foruserprofile = false) } // BackgroundTableLineOddColor - if ($foruserprofile) - { + if ($foruserprofile) { } else { $default = (empty($colorbacklineimpair1) ? $langs->trans("Unknown") : colorArrayToHex(colorStringToArray($colorbacklineimpair1))); print '
'.$langs->trans("BackgroundTableLineOddColor").''; - if ($edit) - { - print $formother->selectColor(colorArrayToHex(colorStringToArray($conf->global->THEME_ELDY_LINEIMPAIR1, array()), ''), 'THEME_ELDY_LINEIMPAIR1', 'formcolor', 1, '', '', 'colorbacklinepair2').' '; + if ($edit) { + print $formother->selectColor(colorArrayToHex(colorStringToArray($conf->global->THEME_ELDY_LINEIMPAIR1, array()), ''), 'THEME_ELDY_LINEIMPAIR1', '', 1, '', '', 'colorbacklinepair2').' '; } else { $color = colorArrayToHex(colorStringToArray($conf->global->THEME_ELDY_LINEIMPAIR1, array()), ''); if ($color) print ''; @@ -738,17 +694,15 @@ function showSkins($fuser, $edit = 0, $foruserprofile = false) } // BackgroundTableLineEvenColor - if ($foruserprofile) - { + if ($foruserprofile) { } else { $default = (empty($colorbacklinepair1) ? $langs->trans("Unknown") : colorArrayToHex(colorStringToArray($colorbacklinepair1))); print '
'.$langs->trans("BackgroundTableLineEvenColor").''; - if ($edit) - { - print $formother->selectColor(colorArrayToHex(colorStringToArray($conf->global->THEME_ELDY_LINEPAIR1, array()), ''), 'THEME_ELDY_LINEPAIR1', 'formcolor', 1, '', '', 'colorbacklineimpair2').' '; + if ($edit) { + print $formother->selectColor(colorArrayToHex(colorStringToArray($conf->global->THEME_ELDY_LINEPAIR1, array()), ''), 'THEME_ELDY_LINEPAIR1', '', 1, '', '', 'colorbacklineimpair2').' '; } else { $color = colorArrayToHex(colorStringToArray($conf->global->THEME_ELDY_LINEPAIR1, array()), ''); if ($color) print ''; @@ -761,8 +715,7 @@ function showSkins($fuser, $edit = 0, $foruserprofile = false) } // Text LinkColor - if ($foruserprofile) - { + if ($foruserprofile) { /* print '
'.$langs->trans("TopMenuBackgroundColor").''; if ($edit) { - print $formother->selectColor(colorArrayToHex(colorStringToArray($conf->global->THEME_ELDY_TEXTLINK,array()),''),'THEME_ELDY_TEXTLINK','formcolor',1).' '; + print $formother->selectColor(colorArrayToHex(colorStringToArray($conf->global->THEME_ELDY_TEXTLINK,array()),''),'THEME_ELDY_TEXTLINK','',1).' '; } else { @@ -789,9 +742,8 @@ function showSkins($fuser, $edit = 0, $foruserprofile = false) print '
'.$langs->trans("LinkColor").''; - if ($edit) - { - print $formother->selectColor(colorArrayToHex(colorStringToArray($conf->global->THEME_ELDY_TEXTLINK, array()), ''), 'THEME_ELDY_TEXTLINK', 'formcolor', 1, '', '', 'colortextlink').' '; + if ($edit) { + print $formother->selectColor(colorArrayToHex(colorStringToArray($conf->global->THEME_ELDY_TEXTLINK, array()), ''), 'THEME_ELDY_TEXTLINK', '', 1, '', '', 'colortextlink').' '; } else { $color = colorArrayToHex(colorStringToArray($conf->global->THEME_ELDY_TEXTLINK, array()), ''); if ($color) print ''; @@ -808,8 +760,7 @@ function showSkins($fuser, $edit = 0, $foruserprofile = false) } // Use Hover - if ($foruserprofile) - { + if ($foruserprofile) { /* Must first change option to choose color of highlight instead of yes or no. print '
'.$langs->trans("HighlightLinesOnMouseHover").''; //print ''; //print '   ('.$langs->trans("NotSupportedByAllThemes").', '.$langs->trans("PressF5AfterChangingThis").')'; - if ($edit) - { + if ($edit) { if ($conf->global->THEME_ELDY_USE_HOVER == '1') $color = colorArrayToHex(colorStringToArray($colorbacklinepairhover)); else $color = colorArrayToHex(colorStringToArray($conf->global->THEME_ELDY_USE_HOVER, array()), ''); - print $formother->selectColor($color, 'THEME_ELDY_USE_HOVER', 'formcolor', 1, '', '', 'colorbacklinepairhover').' '; + print $formother->selectColor($color, 'THEME_ELDY_USE_HOVER', '', 1, '', '', 'colorbacklinepairhover').' '; } else { if ($conf->global->THEME_ELDY_USE_HOVER == '1') $color = colorArrayToHex(colorStringToArray($colorbacklinepairhover)); else $color = colorArrayToHex(colorStringToArray($conf->global->THEME_ELDY_USE_HOVER, array()), ''); - if ($color) - { + if ($color) { if ($color != colorArrayToHex(colorStringToArray($colorbacklinepairhover))) print ''; else print $langs->trans("Default"); } else print $langs->trans("Default"); @@ -848,8 +797,7 @@ function showSkins($fuser, $edit = 0, $foruserprofile = false) } // Use Checked - if ($foruserprofile) - { + if ($foruserprofile) { /* Must first change option to choose color of highlight instead of yes or no. print '
'.$langs->trans("HighlightLinesOnMouseHover").''; //print ''; //print '   ('.$langs->trans("NotSupportedByAllThemes").', '.$langs->trans("PressF5AfterChangingThis").')'; - if ($edit) - { + if ($edit) { if ($conf->global->THEME_ELDY_USE_CHECKED == '1') $color = 'e6edf0'; else $color = colorArrayToHex(colorStringToArray($conf->global->THEME_ELDY_USE_CHECKED, array()), ''); - print $formother->selectColor($color, 'THEME_ELDY_USE_CHECKED', 'formcolor', 1, '', '', 'colorbacklinepairchecked').' '; + print $formother->selectColor($color, 'THEME_ELDY_USE_CHECKED', '', 1, '', '', 'colorbacklinepairchecked').' '; } else { if ($conf->global->THEME_ELDY_USE_CHECKED == '1') $color = 'e6edf0'; else $color = colorArrayToHex(colorStringToArray($conf->global->THEME_ELDY_USE_CHECKED, array()), ''); - if ($color) - { + if ($color) { if ($color != 'e6edf0') print ''; else print $langs->trans("Default"); } else print $langs->trans("Default"); @@ -889,20 +835,17 @@ function showSkins($fuser, $edit = 0, $foruserprofile = false) } // Use MAIN_OPTIMIZEFORTEXTBROWSER - if ($foruserprofile) - { + if ($foruserprofile) { //$default=yn($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER); $default = $langs->trans('No'); print '
'.$langs->trans("MAIN_OPTIMIZEFORTEXTBROWSER").''; //print ajax_constantonoff("MAIN_OPTIMIZEFORTEXTBROWSER", array(), null, 0, 0, 1, 0); - if ($edit) - { + if ($edit) { print $form->selectyesno('MAIN_OPTIMIZEFORTEXTBROWSER', $fuser->conf->MAIN_OPTIMIZEFORTEXTBROWSER, 1); } else { - if (empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) - { + if (empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { print yn($fuser->conf->MAIN_OPTIMIZEFORTEXTBROWSER); } else { print yn(1); @@ -937,8 +880,7 @@ function showSkins($fuser, $edit = 0, $foruserprofile = false) // Use MAIN_OPTIMIZEFORTEXTBROWSER - if ($foruserprofile) - { + if ($foruserprofile) { //$default=yn($conf->global->MAIN_OPTIMIZEFORCOLORBLIND); $default = $langs->trans('No'); print '
- +
">      ">
diff --git a/htdocs/core/tpl/admin_extrafields_edit.tpl.php b/htdocs/core/tpl/admin_extrafields_edit.tpl.php index 396406932e7..19b5322ace5 100644 --- a/htdocs/core/tpl/admin_extrafields_edit.tpl.php +++ b/htdocs/core/tpl/admin_extrafields_edit.tpl.php @@ -298,7 +298,7 @@ if (in_array($type, array_keys($typewecanchangeinto))) - +
">      ">
diff --git a/htdocs/core/tpl/card_presend.tpl.php b/htdocs/core/tpl/card_presend.tpl.php index ea72f29607b..ef288f97589 100644 --- a/htdocs/core/tpl/card_presend.tpl.php +++ b/htdocs/core/tpl/card_presend.tpl.php @@ -292,5 +292,5 @@ if ($action == 'presend') // Show form print $formmail->get_form(); - dol_fiche_end(); + print dol_get_fiche_end(); } diff --git a/htdocs/core/tpl/contacts.tpl.php b/htdocs/core/tpl/contacts.tpl.php index 1cb8b813001..012c39c126d 100644 --- a/htdocs/core/tpl/contacts.tpl.php +++ b/htdocs/core/tpl/contacts.tpl.php @@ -108,7 +108,7 @@ if ($permission) element == 'shipping' || $object->element == 'reception') && is_object($objectsrc)) $tmpobject = $objectsrc; - echo $formcompany->selectTypeContact($tmpobject, '', 'type', 'internal'); + $formcompany->selectTypeContact($tmpobject, '', 'type', 'internal'); ?>
 
">
@@ -117,8 +117,7 @@ if ($permission)
dol_use_jmobile) ? '' : '?version='.urlencode(DOL_VERSION)), '/core/js/dst.js'.(empty($conf->dol_use_jmobile) ? '' : '?version='.urlencode(DOL_VERSION)) ); -$titleofloginpage = $langs->trans('Login').' @ '.$titletruedolibarrversion; // $titletruedolibarrversion is defined by dol_loginfunction in security2.lib.php. We must keep the @, some tools use it to know it is login page and find true dolibarr version. + +// We display application title instead Login term +if (!empty($conf->global->MAIN_APPLICATION_TITLE)) { + $titleofloginpage = $conf->global->MAIN_APPLICATION_TITLE; +} else { + $titleofloginpage = $langs->trans('Login'); +} +$titleofloginpage.= ' @ '.$titletruedolibarrversion; // $titletruedolibarrversion is defined by dol_loginfunction in security2.lib.php. We must keep the @, some tools use it to know it is login page and find true dolibarr version. $disablenofollow = 1; if (!preg_match('/'.constant('DOL_APPLICATION_TITLE').'/', $title)) $disablenofollow = 0; @@ -290,9 +297,9 @@ if (!empty($_SESSION['dol_loginmesg'])) if (!empty($conf->global->MAIN_EASTER_EGG_COMMITSTRIP)) { include_once DOL_DOCUMENT_ROOT.'/core/lib/geturl.lib.php'; if (substr($langs->defaultlang, 0, 2) == 'fr') { - $resgetcommitstrip = getURLContent("http://www.commitstrip.com/fr/feed/"); + $resgetcommitstrip = getURLContent("https://www.commitstrip.com/fr/feed/"); } else { - $resgetcommitstrip = getURLContent("http://www.commitstrip.com/en/feed/"); + $resgetcommitstrip = getURLContent("https://www.commitstrip.com/en/feed/"); } if ($resgetcommitstrip && $resgetcommitstrip['http_code'] == '200') { diff --git a/htdocs/core/tpl/massactions_pre.tpl.php b/htdocs/core/tpl/massactions_pre.tpl.php index d81a79d7b80..68f45284582 100644 --- a/htdocs/core/tpl/massactions_pre.tpl.php +++ b/htdocs/core/tpl/massactions_pre.tpl.php @@ -160,7 +160,7 @@ if ($massaction == 'presend') print $formmail->get_form(); } - dol_fiche_end(); + print dol_get_fiche_end(); } // Allow Pre-Mass-Action hook (eg for confirmation dialog) $parameters = array( diff --git a/htdocs/core/triggers/dolibarrtriggers.class.php b/htdocs/core/triggers/dolibarrtriggers.class.php index 3d60ea890ed..a06b4f89528 100644 --- a/htdocs/core/triggers/dolibarrtriggers.class.php +++ b/htdocs/core/triggers/dolibarrtriggers.class.php @@ -70,8 +70,19 @@ abstract class DolibarrTriggers */ public $errors = array(); + /** + * @var string module is in development + */ const VERSION_DEVELOPMENT = 'development'; + + /** + * @var string module is experimental + */ const VERSION_EXPERIMENTAL = 'experimental'; + + /** + * @var string module is dolibarr ready + */ const VERSION_DOLIBARR = 'dolibarr'; /** @@ -84,8 +95,7 @@ abstract class DolibarrTriggers $this->db = $db; - if (empty($this->name)) - { + if (empty($this->name)) { $this->name = preg_replace('/^Interface/i', '', get_class($this)); } } diff --git a/htdocs/core/triggers/interface_20_all_Logevents.class.php b/htdocs/core/triggers/interface_20_all_Logevents.class.php index 4f368f95473..d5e31c36d28 100644 --- a/htdocs/core/triggers/interface_20_all_Logevents.class.php +++ b/htdocs/core/triggers/interface_20_all_Logevents.class.php @@ -31,20 +31,22 @@ require_once DOL_DOCUMENT_ROOT.'/core/triggers/dolibarrtriggers.class.php'; */ class InterfaceLogevents extends DolibarrTriggers { - /** - * @var string Image of the trigger - */ - public $picto = 'technic'; + /** + * Constructor + * + * @param DoliDB $db Database handler + */ + public function __construct($db) + { + $this->db = $db; - public $family = 'core'; - - public $description = "Triggers of this module allows to add security event records inside Dolibarr."; - - /** - * Version of the trigger - * @var string - */ - public $version = self::VERSION_DOLIBARR; + $this->name = preg_replace('/^Interface/i', '', get_class($this)); + $this->family = "core"; + $this->description = "Triggers of this module allows to add security event records inside Dolibarr."; + // 'development', 'experimental', 'dolibarr' or version + $this->version = self::VERSION_DOLIBARR; + $this->picto = 'technic'; + } /** * Function called when a Dolibarrr security audit event is done. @@ -70,8 +72,7 @@ class InterfaceLogevents extends DolibarrTriggers $date = dol_now(); // Actions - if ($action == 'USER_LOGIN') - { + if ($action == 'USER_LOGIN') { dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); $langs->load("users"); @@ -80,89 +81,72 @@ class InterfaceLogevents extends DolibarrTriggers $text .= (empty($object->trigger_mesg) ? '' : ' - '.$object->trigger_mesg); $desc = "(UserLogged,".$object->login.")"; $desc .= (empty($object->trigger_mesg) ? '' : ' - '.$object->trigger_mesg); - } - if ($action == 'USER_LOGIN_FAILED') - { + } elseif ($action == 'USER_LOGIN_FAILED') { dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); // Initialisation donnees (date,duree,texte,desc) $text = $object->trigger_mesg; // Message direct $desc = $object->trigger_mesg; // Message direct - } - if ($action == 'USER_LOGOUT') - { + } elseif ($action == 'USER_LOGOUT') { dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); $langs->load("users"); // Initialisation donnees (date,duree,texte,desc) $text = "(UserLogoff,".$object->login.")"; $desc = "(UserLogoff,".$object->login.")"; - } - if ($action == 'USER_CREATE') - { + } elseif ($action == 'USER_CREATE') { dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); $langs->load("users"); // Initialisation donnees (date,duree,texte,desc) $text = $langs->transnoentities("NewUserCreated", $object->login); $desc = $langs->transnoentities("NewUserCreated", $object->login); - } elseif ($action == 'USER_MODIFY') - { + } elseif ($action == 'USER_MODIFY') { dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); $langs->load("users"); // Initialisation donnees (date,duree,texte,desc) $text = $langs->transnoentities("EventUserModified", $object->login); $desc = $langs->transnoentities("EventUserModified", $object->login); - } elseif ($action == 'USER_NEW_PASSWORD') - { + } elseif ($action == 'USER_NEW_PASSWORD') { dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); $langs->load("users"); // Initialisation donnees (date,duree,texte,desc) $text = $langs->transnoentities("NewUserPassword", $object->login); $desc = $langs->transnoentities("NewUserPassword", $object->login); - } elseif ($action == 'USER_ENABLEDISABLE') - { + } elseif ($action == 'USER_ENABLEDISABLE') { dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); $langs->load("users"); // Initialisation donnees (date,duree,texte,desc) - if ($object->statut == 0) - { + if ($object->statut == 0) { $text = $langs->transnoentities("UserEnabled", $object->login); $desc = $langs->transnoentities("UserEnabled", $object->login); } - if ($object->statut == 1) - { + if ($object->statut == 1) { $text = $langs->transnoentities("UserDisabled", $object->login); $desc = $langs->transnoentities("UserDisabled", $object->login); } - } elseif ($action == 'USER_DELETE') - { + } elseif ($action == 'USER_DELETE') { dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); $langs->load("users"); // Initialisation donnees (date,duree,texte,desc) $text = $langs->transnoentities("UserDeleted", $object->login); $desc = $langs->transnoentities("UserDeleted", $object->login); - } - - // Groupes - elseif ($action == 'USERGROUP_CREATE') - { + } elseif ($action == 'USERGROUP_CREATE') { + // Groups dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); $langs->load("users"); // Initialisation donnees (date,duree,texte,desc) $text = $langs->transnoentities("NewGroupCreated", $object->name); $desc = $langs->transnoentities("NewGroupCreated", $object->name); - } elseif ($action == 'USERGROUP_MODIFY') - { + } elseif ($action == 'USERGROUP_MODIFY') { dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); $langs->load("users"); // Initialisation donnees (date,duree,texte,desc) $text = $langs->transnoentities("GroupModified", $object->name); $desc = $langs->transnoentities("GroupModified", $object->name); - } elseif ($action == 'USERGROUP_DELETE') - { + } elseif ($action == 'USERGROUP_DELETE') { dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); $langs->load("users"); // Initialisation donnees (date,duree,texte,desc) @@ -193,8 +177,7 @@ class InterfaceLogevents extends DolibarrTriggers $event->user_agent = $_SERVER["HTTP_USER_AGENT"]; $result = $event->create($user); - if ($result > 0) - { + if ($result > 0) { return 1; } else { $error = "Failed to insert security event: ".$event->error; diff --git a/htdocs/core/triggers/interface_20_modWorkflow_WorkflowManager.class.php b/htdocs/core/triggers/interface_20_modWorkflow_WorkflowManager.class.php index b40900dd6c7..3b2e4fb6db0 100644 --- a/htdocs/core/triggers/interface_20_modWorkflow_WorkflowManager.class.php +++ b/htdocs/core/triggers/interface_20_modWorkflow_WorkflowManager.class.php @@ -32,19 +32,22 @@ require_once DOL_DOCUMENT_ROOT.'/core/triggers/dolibarrtriggers.class.php'; class InterfaceWorkflowManager extends DolibarrTriggers { - /** - * @var string Image of the trigger - */ - public $picto = 'technic'; + /** + * Constructor + * + * @param DoliDB $db Database handler + */ + public function __construct($db) + { + $this->db = $db; - public $family = 'core'; - public $description = "Triggers of this module allows to manage workflows"; - - /** - * Version of the trigger - * @var string - */ - public $version = self::VERSION_DOLIBARR; + $this->name = preg_replace('/^Interface/i', '', get_class($this)); + $this->family = "core"; + $this->description = "Triggers of this module allows to manage workflows"; + // 'development', 'experimental', 'dolibarr' or version + $this->version = self::VERSION_DOLIBARR; + $this->picto = 'technic'; + } /** * Function called when a Dolibarrr business event is done. @@ -62,11 +65,9 @@ class InterfaceWorkflowManager extends DolibarrTriggers if (empty($conf->workflow->enabled)) return 0; // Module not active, we do nothing // Proposals to order - if ($action == 'PROPAL_CLOSE_SIGNED') - { + if ($action == 'PROPAL_CLOSE_SIGNED') { dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); - if (!empty($conf->commande->enabled) && !empty($conf->global->WORKFLOW_PROPAL_AUTOCREATE_ORDER)) - { + if (!empty($conf->commande->enabled) && !empty($conf->global->WORKFLOW_PROPAL_AUTOCREATE_ORDER)) { include_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; $newobject = new Commande($this->db); @@ -81,11 +82,9 @@ class InterfaceWorkflowManager extends DolibarrTriggers } // Order to invoice - if ($action == 'ORDER_CLOSE') - { + if ($action == 'ORDER_CLOSE') { dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); - if (!empty($conf->facture->enabled) && !empty($conf->global->WORKFLOW_ORDER_AUTOCREATE_INVOICE)) - { + if (!empty($conf->facture->enabled) && !empty($conf->global->WORKFLOW_ORDER_AUTOCREATE_INVOICE)) { include_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; $newobject = new Facture($this->db); @@ -100,24 +99,18 @@ class InterfaceWorkflowManager extends DolibarrTriggers } // Order classify billed proposal - if ($action == 'ORDER_CLASSIFY_BILLED') - { + if ($action == 'ORDER_CLASSIFY_BILLED') { dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); - if (!empty($conf->propal->enabled) && !empty($conf->workflow->enabled) && !empty($conf->global->WORKFLOW_ORDER_CLASSIFY_BILLED_PROPAL)) - { + if (!empty($conf->propal->enabled) && !empty($conf->workflow->enabled) && !empty($conf->global->WORKFLOW_ORDER_CLASSIFY_BILLED_PROPAL)) { $object->fetchObjectLinked('', 'propal', $object->id, $object->element); - if (!empty($object->linkedObjects)) - { + if (!empty($object->linkedObjects)) { $totalonlinkedelements = 0; - foreach ($object->linkedObjects['propal'] as $element) - { + foreach ($object->linkedObjects['propal'] as $element) { if ($element->statut == Propal::STATUS_SIGNED || $element->statut == Propal::STATUS_BILLED) $totalonlinkedelements += $element->total_ht; } dol_syslog("Amount of linked proposals = ".$totalonlinkedelements.", of order = ".$object->total_ht.", egality is ".($totalonlinkedelements == $object->total_ht)); - if ($this->shouldClassify($conf, $totalonlinkedelements, $object->total_ht)) - { - foreach ($object->linkedObjects['propal'] as $element) - { + if ($this->shouldClassify($conf, $totalonlinkedelements, $object->total_ht)) { + foreach ($object->linkedObjects['propal'] as $element) { $ret = $element->classifyBilled($user); } } @@ -127,27 +120,21 @@ class InterfaceWorkflowManager extends DolibarrTriggers } // classify billed order & billed propososal - if ($action == 'BILL_VALIDATE') - { + if ($action == 'BILL_VALIDATE') { dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); $ret = 0; // First classify billed the order to allow the proposal classify process - if (!empty($conf->commande->enabled) && !empty($conf->workflow->enabled) && !empty($conf->global->WORKFLOW_INVOICE_AMOUNT_CLASSIFY_BILLED_ORDER)) - { + if (!empty($conf->commande->enabled) && !empty($conf->workflow->enabled) && !empty($conf->global->WORKFLOW_INVOICE_AMOUNT_CLASSIFY_BILLED_ORDER)) { $object->fetchObjectLinked('', 'commande', $object->id, $object->element); - if (!empty($object->linkedObjects)) - { + if (!empty($object->linkedObjects)) { $totalonlinkedelements = 0; - foreach ($object->linkedObjects['commande'] as $element) - { + foreach ($object->linkedObjects['commande'] as $element) { if ($element->statut == Commande::STATUS_VALIDATED || $element->statut == Commande::STATUS_SHIPMENTONPROCESS || $element->statut == Commande::STATUS_CLOSED) $totalonlinkedelements += $element->total_ht; } dol_syslog("Amount of linked orders = ".$totalonlinkedelements.", of invoice = ".$object->total_ht.", egality is ".($totalonlinkedelements == $object->total_ht)); - if ($this->shouldClassify($conf, $totalonlinkedelements, $object->total_ht)) - { - foreach ($object->linkedObjects['commande'] as $element) - { + if ($this->shouldClassify($conf, $totalonlinkedelements, $object->total_ht)) { + foreach ($object->linkedObjects['commande'] as $element) { $ret = $element->classifyBilled($user); } } @@ -155,21 +142,16 @@ class InterfaceWorkflowManager extends DolibarrTriggers } // Second classify billed the proposal. - if (!empty($conf->propal->enabled) && !empty($conf->workflow->enabled) && !empty($conf->global->WORKFLOW_INVOICE_CLASSIFY_BILLED_PROPAL)) - { + if (!empty($conf->propal->enabled) && !empty($conf->workflow->enabled) && !empty($conf->global->WORKFLOW_INVOICE_CLASSIFY_BILLED_PROPAL)) { $object->fetchObjectLinked('', 'propal', $object->id, $object->element); - if (!empty($object->linkedObjects)) - { + if (!empty($object->linkedObjects)) { $totalonlinkedelements = 0; - foreach ($object->linkedObjects['propal'] as $element) - { + foreach ($object->linkedObjects['propal'] as $element) { if ($element->statut == Propal::STATUS_SIGNED || $element->statut == Propal::STATUS_BILLED) $totalonlinkedelements += $element->total_ht; } dol_syslog("Amount of linked proposals = ".$totalonlinkedelements.", of invoice = ".$object->total_ht.", egality is ".($totalonlinkedelements == $object->total_ht)); - if ($this->shouldClassify($conf, $totalonlinkedelements, $object->total_ht)) - { - foreach ($object->linkedObjects['propal'] as $element) - { + if ($this->shouldClassify($conf, $totalonlinkedelements, $object->total_ht)) { + foreach ($object->linkedObjects['propal'] as $element) { $ret = $element->classifyBilled($user); } } @@ -180,26 +162,20 @@ class InterfaceWorkflowManager extends DolibarrTriggers } // classify billed order & billed propososal - if ($action == 'BILL_SUPPLIER_VALIDATE') - { + if ($action == 'BILL_SUPPLIER_VALIDATE') { dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); // First classify billed the order to allow the proposal classify process - if (!empty($conf->fournisseur->enabled) && !empty($conf->global->WORKFLOW_INVOICE_AMOUNT_CLASSIFY_BILLED_SUPPLIER_ORDER)) - { + if (!empty($conf->fournisseur->enabled) && !empty($conf->global->WORKFLOW_INVOICE_AMOUNT_CLASSIFY_BILLED_SUPPLIER_ORDER)) { $object->fetchObjectLinked('', 'order_supplier', $object->id, $object->element); - if (!empty($object->linkedObjects)) - { + if (!empty($object->linkedObjects)) { $totalonlinkedelements = 0; - foreach ($object->linkedObjects['order_supplier'] as $element) - { + foreach ($object->linkedObjects['order_supplier'] as $element) { if ($element->statut == CommandeFournisseur::STATUS_ACCEPTED || $element->statut == CommandeFournisseur::STATUS_ORDERSENT || $element->statut == CommandeFournisseur::STATUS_RECEIVED_PARTIALLY || $element->statut == CommandeFournisseur::STATUS_RECEIVED_COMPLETELY) $totalonlinkedelements += $element->total_ht; } dol_syslog("Amount of linked orders = ".$totalonlinkedelements.", of invoice = ".$object->total_ht.", egality is ".($totalonlinkedelements == $object->total_ht)); - if ($this->shouldClassify($conf, $totalonlinkedelements, $object->total_ht)) - { - foreach ($object->linkedObjects['order_supplier'] as $element) - { + if ($this->shouldClassify($conf, $totalonlinkedelements, $object->total_ht)) { + foreach ($object->linkedObjects['order_supplier'] as $element) { $ret = $element->classifyBilled($user); } } @@ -208,21 +184,16 @@ class InterfaceWorkflowManager extends DolibarrTriggers } // Second classify billed the proposal. - if (!empty($conf->supplier_proposal->enabled) && !empty($conf->global->WORKFLOW_INVOICE_CLASSIFY_BILLED_SUPPLIER_PROPOSAL)) - { + if (!empty($conf->supplier_proposal->enabled) && !empty($conf->global->WORKFLOW_INVOICE_CLASSIFY_BILLED_SUPPLIER_PROPOSAL)) { $object->fetchObjectLinked('', 'supplier_proposal', $object->id, $object->element); - if (!empty($object->linkedObjects)) - { + if (!empty($object->linkedObjects)) { $totalonlinkedelements = 0; - foreach ($object->linkedObjects['supplier_proposal'] as $element) - { + foreach ($object->linkedObjects['supplier_proposal'] as $element) { if ($element->statut == SupplierProposal::STATUS_SIGNED || $element->statut == SupplierProposal::STATUS_BILLED) $totalonlinkedelements += $element->total_ht; } dol_syslog("Amount of linked supplier proposals = ".$totalonlinkedelements.", of supplier invoice = ".$object->total_ht.", egality is ".($totalonlinkedelements == $object->total_ht)); - if ($this->shouldClassify($conf, $totalonlinkedelements, $object->total_ht)) - { - foreach ($object->linkedObjects['supplier_proposal'] as $element) - { + if ($this->shouldClassify($conf, $totalonlinkedelements, $object->total_ht)) { + foreach ($object->linkedObjects['supplier_proposal'] as $element) { $ret = $element->classifyBilled($user); } } @@ -232,25 +203,19 @@ class InterfaceWorkflowManager extends DolibarrTriggers } // Invoice classify billed order - if ($action == 'BILL_PAYED') - { + if ($action == 'BILL_PAYED') { dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); - if (!empty($conf->commande->enabled) && !empty($conf->global->WORKFLOW_INVOICE_CLASSIFY_BILLED_ORDER)) - { + if (!empty($conf->commande->enabled) && !empty($conf->global->WORKFLOW_INVOICE_CLASSIFY_BILLED_ORDER)) { $object->fetchObjectLinked('', 'commande', $object->id, $object->element); - if (!empty($object->linkedObjects)) - { + if (!empty($object->linkedObjects)) { $totalonlinkedelements = 0; - foreach ($object->linkedObjects['commande'] as $element) - { + foreach ($object->linkedObjects['commande'] as $element) { if ($element->statut == Commande::STATUS_VALIDATED || $element->statut == Commande::STATUS_SHIPMENTONPROCESS || $element->statut == Commande::STATUS_CLOSED) $totalonlinkedelements += $element->total_ht; } dol_syslog("Amount of linked orders = ".$totalonlinkedelements.", of invoice = ".$object->total_ht.", egality is ".($totalonlinkedelements == $object->total_ht)); - if ($this->shouldClassify($conf, $totalonlinkedelements, $object->total_ht)) - { - foreach ($object->linkedObjects['commande'] as $element) - { + if ($this->shouldClassify($conf, $totalonlinkedelements, $object->total_ht)) { + foreach ($object->linkedObjects['commande'] as $element) { $ret = $element->classifyBilled($user); } } @@ -259,12 +224,10 @@ class InterfaceWorkflowManager extends DolibarrTriggers } } - if ($action == 'SHIPPING_VALIDATE') - { + if ($action == 'SHIPPING_VALIDATE') { dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); - if (!empty($conf->commande->enabled) && !empty($conf->expedition->enabled) && !empty($conf->workflow->enabled) && !empty($conf->global->WORKFLOW_ORDER_CLASSIFY_SHIPPED_SHIPPING)) - { + if (!empty($conf->commande->enabled) && !empty($conf->expedition->enabled) && !empty($conf->workflow->enabled) && !empty($conf->global->WORKFLOW_ORDER_CLASSIFY_SHIPPED_SHIPPING)) { $qtyshipped = array(); $qtyordred = array(); require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; @@ -318,25 +281,19 @@ class InterfaceWorkflowManager extends DolibarrTriggers } } // classify billed reception - if ($action == 'BILL_SUPPLIER_VALIDATE') - { + if ($action == 'BILL_SUPPLIER_VALIDATE') { dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id, LOG_DEBUG); - if (!empty($conf->reception->enabled) && !empty($conf->global->WORKFLOW_BILL_ON_RECEPTION)) - { + if (!empty($conf->reception->enabled) && !empty($conf->global->WORKFLOW_BILL_ON_RECEPTION)) { $object->fetchObjectLinked('', 'reception', $object->id, $object->element); - if (!empty($object->linkedObjects)) - { + if (!empty($object->linkedObjects)) { $totalonlinkedelements = 0; - foreach ($object->linkedObjects['reception'] as $element) - { + foreach ($object->linkedObjects['reception'] as $element) { if ($element->statut == Reception::STATUS_VALIDATED) $totalonlinkedelements += $element->total_ht; } dol_syslog("Amount of linked proposals = ".$totalonlinkedelements.", of invoice = ".$object->total_ht.", egality is ".($totalonlinkedelements == $object->total_ht), LOG_DEBUG); - if ($totalonlinkedelements == $object->total_ht) - { - foreach ($object->linkedObjects['reception'] as $element) - { + if ($totalonlinkedelements == $object->total_ht) { + foreach ($object->linkedObjects['reception'] as $element) { $ret = $element->set_billed(); } } diff --git a/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php b/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php index 15637dc4a61..ce5d6da1b30 100644 --- a/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php +++ b/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php @@ -34,19 +34,22 @@ require_once DOL_DOCUMENT_ROOT.'/core/triggers/dolibarrtriggers.class.php'; */ class InterfaceActionsAuto extends DolibarrTriggers { - public $family = 'agenda'; - public $description = "Triggers of this module add actions in agenda according to setup made in agenda setup."; + /** + * Constructor + * + * @param DoliDB $db Database handler + */ + public function __construct($db) + { + $this->db = $db; - /** - * Version of the trigger - * @var string - */ - public $version = self::VERSION_DOLIBARR; - - /** - * @var string Image of the trigger - */ - public $picto = 'action'; + $this->name = preg_replace('/^Interface/i', '', get_class($this)); + $this->family = "agenda"; + $this->description = "Triggers of this module add actions in agenda according to setup made in agenda setup."; + // 'development', 'experimental', 'dolibarr' or version + $this->version = self::VERSION_DOLIBARR; + $this->picto = 'action'; + } /** * Function called when a Dolibarrr business event is done. @@ -87,8 +90,7 @@ class InterfaceActionsAuto extends DolibarrTriggers if (empty($object->actiontypecode)) $object->actiontypecode = 'AC_OTH_AUTO'; // Actions - if ($action == 'COMPANY_CREATE') - { + if ($action == 'COMPANY_CREATE') { // Load translation files required by the page $langs->loadLangs(array("agenda", "other", "companies")); @@ -97,8 +99,7 @@ class InterfaceActionsAuto extends DolibarrTriggers $object->sendtoid = 0; $object->socid = $object->id; - } elseif ($action == 'COMPANY_SENTBYMAIL') - { + } elseif ($action == 'COMPANY_SENTBYMAIL') { // Load translation files required by the page $langs->loadLangs(array("agenda", "other", "orders")); @@ -106,8 +107,7 @@ class InterfaceActionsAuto extends DolibarrTriggers // Parameters $object->sendtoid defined by caller //$object->sendtoid=0; - } elseif ($action == 'CONTACT_CREATE') - { + } elseif ($action == 'CONTACT_CREATE') { // Load translation files required by the page $langs->loadLangs(array("agenda", "other", "companies")); @@ -116,8 +116,7 @@ class InterfaceActionsAuto extends DolibarrTriggers $object->sendtoid = array($object->id => $object->id); $object->socid = $object->socid; - } elseif ($action == 'CONTRACT_VALIDATE') - { + } elseif ($action == 'CONTRACT_VALIDATE') { // Load translation files required by the page $langs->loadLangs(array("agenda", "other", "contracts")); @@ -125,21 +124,18 @@ class InterfaceActionsAuto extends DolibarrTriggers $object->actionmsg = $langs->transnoentities("ContractValidatedInDolibarr", ($object->newref ? $object->newref : $object->ref)); $object->sendtoid = 0; - } elseif ($action == 'CONTRACT_SENTBYMAIL') - { + } elseif ($action == 'CONTRACT_SENTBYMAIL') { // Load translation files required by the page $langs->loadLangs(array("agenda", "other", "contracts")); if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("ContractSentByEMail", $object->ref); - if (empty($object->actionmsg)) - { + if (empty($object->actionmsg)) { $object->actionmsg = $langs->transnoentities("ContractSentByEMail", $object->ref); } // Parameters $object->sendtoid defined by caller //$object->sendtoid=0; - } elseif ($action == 'PROPAL_VALIDATE') - { + } elseif ($action == 'PROPAL_VALIDATE') { // Load translation files required by the page $langs->loadLangs(array("agenda", "other", "propal")); @@ -147,21 +143,18 @@ class InterfaceActionsAuto extends DolibarrTriggers $object->actionmsg = $langs->transnoentities("PropalValidatedInDolibarr", ($object->newref ? $object->newref : $object->ref)); $object->sendtoid = 0; - } elseif ($action == 'PROPAL_SENTBYMAIL') - { + } elseif ($action == 'PROPAL_SENTBYMAIL') { // Load translation files required by the page $langs->loadLangs(array("agenda", "other", "propal")); if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("ProposalSentByEMail", $object->ref); - if (empty($object->actionmsg)) - { + if (empty($object->actionmsg)) { $object->actionmsg = $langs->transnoentities("ProposalSentByEMail", $object->ref); } // Parameters $object->sendtoid defined by caller //$object->sendtoid=0; - } elseif ($action == 'PROPAL_CLOSE_SIGNED') - { + } elseif ($action == 'PROPAL_CLOSE_SIGNED') { // Load translation files required by the page $langs->loadLangs(array("agenda", "other", "propal")); @@ -169,8 +162,7 @@ class InterfaceActionsAuto extends DolibarrTriggers $object->actionmsg = $langs->transnoentities("PropalClosedSignedInDolibarr", $object->ref); $object->sendtoid = 0; - } elseif ($action == 'PROPAL_CLASSIFY_BILLED') - { + } elseif ($action == 'PROPAL_CLASSIFY_BILLED') { // Load translation files required by the page $langs->loadLangs(array("agenda", "other", "propal")); @@ -178,8 +170,7 @@ class InterfaceActionsAuto extends DolibarrTriggers $object->actionmsg = $langs->transnoentities("PropalClassifiedBilledInDolibarr", $object->ref); $object->sendtoid = 0; - } elseif ($action == 'PROPAL_CLOSE_REFUSED') - { + } elseif ($action == 'PROPAL_CLOSE_REFUSED') { // Load translation files required by the page $langs->loadLangs(array("agenda", "other", "propal")); @@ -187,8 +178,7 @@ class InterfaceActionsAuto extends DolibarrTriggers $object->actionmsg = $langs->transnoentities("PropalClosedRefusedInDolibarr", $object->ref); $object->sendtoid = 0; - } elseif ($action == 'ORDER_VALIDATE') - { + } elseif ($action == 'ORDER_VALIDATE') { // Load translation files required by the page $langs->loadLangs(array("agenda", "orders")); @@ -196,8 +186,7 @@ class InterfaceActionsAuto extends DolibarrTriggers $object->actionmsg = $langs->transnoentities("OrderValidatedInDolibarr", ($object->newref ? $object->newref : $object->ref)); $object->sendtoid = 0; - } elseif ($action == 'ORDER_CLOSE') - { + } elseif ($action == 'ORDER_CLOSE') { // Load translation files required by the page $langs->loadLangs(array("agenda", "other", "orders")); @@ -205,8 +194,7 @@ class InterfaceActionsAuto extends DolibarrTriggers $object->actionmsg = $langs->transnoentities("OrderDeliveredInDolibarr", $object->ref); $object->sendtoid = 0; - } elseif ($action == 'ORDER_CLASSIFY_BILLED') - { + } elseif ($action == 'ORDER_CLASSIFY_BILLED') { // Load translation files required by the page $langs->loadLangs(array("agenda", "other", "orders")); @@ -214,8 +202,7 @@ class InterfaceActionsAuto extends DolibarrTriggers $object->actionmsg = $langs->transnoentities("OrderBilledInDolibarr", $object->ref); $object->sendtoid = 0; - } elseif ($action == 'ORDER_CANCEL') - { + } elseif ($action == 'ORDER_CANCEL') { // Load translation files required by the page $langs->loadLangs(array("agenda", "other", "orders")); @@ -223,21 +210,18 @@ class InterfaceActionsAuto extends DolibarrTriggers $object->actionmsg = $langs->transnoentities("OrderCanceledInDolibarr", $object->ref); $object->sendtoid = 0; - } elseif ($action == 'ORDER_SENTBYMAIL') - { + } elseif ($action == 'ORDER_SENTBYMAIL') { // Load translation files required by the page $langs->loadLangs(array("agenda", "other", "orders")); if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("OrderSentByEMail", $object->ref); - if (empty($object->actionmsg)) - { + if (empty($object->actionmsg)) { $object->actionmsg = $langs->transnoentities("OrderSentByEMail", $object->ref); } // Parameters $object->sendtoid defined by caller //$object->sendtoid=0; - } elseif ($action == 'BILL_VALIDATE') - { + } elseif ($action == 'BILL_VALIDATE') { // Load translation files required by the page $langs->loadLangs(array("agenda", "other", "bills")); @@ -245,8 +229,7 @@ class InterfaceActionsAuto extends DolibarrTriggers $object->actionmsg = $langs->transnoentities("InvoiceValidatedInDolibarr", ($object->newref ? $object->newref : $object->ref)); $object->sendtoid = 0; - } elseif ($action == 'BILL_UNVALIDATE') - { + } elseif ($action == 'BILL_UNVALIDATE') { // Load translation files required by the page $langs->loadLangs(array("agenda", "other", "bills")); @@ -254,21 +237,18 @@ class InterfaceActionsAuto extends DolibarrTriggers $object->actionmsg = $langs->transnoentities("InvoiceBackToDraftInDolibarr", $object->ref); $object->sendtoid = 0; - } elseif ($action == 'BILL_SENTBYMAIL') - { + } elseif ($action == 'BILL_SENTBYMAIL') { // Load translation files required by the page $langs->loadLangs(array("agenda", "other", "bills")); if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("InvoiceSentByEMail", $object->ref); - if (empty($object->actionmsg)) - { + if (empty($object->actionmsg)) { $object->actionmsg = $langs->transnoentities("InvoiceSentByEMail", $object->ref); } // Parameters $object->sendtoid defined by caller //$object->sendtoid=0; - } elseif ($action == 'BILL_PAYED') - { + } elseif ($action == 'BILL_PAYED') { // Load translation files required by the page $langs->loadLangs(array("agenda", "other", "bills")); @@ -277,8 +257,7 @@ class InterfaceActionsAuto extends DolibarrTriggers $object->actionmsg = $langs->transnoentities("InvoicePaidInDolibarr", $object->ref); $object->sendtoid = 0; - } elseif ($action == 'BILL_CANCEL') - { + } elseif ($action == 'BILL_CANCEL') { // Load translation files required by the page $langs->loadLangs(array("agenda", "other", "bills")); @@ -286,8 +265,7 @@ class InterfaceActionsAuto extends DolibarrTriggers $object->actionmsg = $langs->transnoentities("InvoiceCanceledInDolibarr", $object->ref); $object->sendtoid = 0; - } elseif ($action == 'FICHINTER_CREATE') - { + } elseif ($action == 'FICHINTER_CREATE') { // Load translation files required by the page $langs->loadLangs(array("agenda", "other", "interventions")); @@ -297,8 +275,7 @@ class InterfaceActionsAuto extends DolibarrTriggers $object->sendtoid = 0; $object->fk_element = 0; $object->elementtype = ''; - } elseif ($action == 'FICHINTER_VALIDATE') - { + } elseif ($action == 'FICHINTER_VALIDATE') { // Load translation files required by the page $langs->loadLangs(array("agenda", "other", "interventions")); @@ -308,8 +285,7 @@ class InterfaceActionsAuto extends DolibarrTriggers $object->sendtoid = 0; $object->fk_element = 0; $object->elementtype = ''; - } elseif ($action == 'FICHINTER_MODIFY') - { + } elseif ($action == 'FICHINTER_MODIFY') { // Load translation files required by the page $langs->loadLangs(array("agenda", "other", "interventions")); @@ -319,21 +295,18 @@ class InterfaceActionsAuto extends DolibarrTriggers $object->sendtoid = 0; $object->fk_element = 0; $object->elementtype = ''; - } elseif ($action == 'FICHINTER_SENTBYMAIL') - { + } elseif ($action == 'FICHINTER_SENTBYMAIL') { // Load translation files required by the page $langs->loadLangs(array("agenda", "other", "interventions")); if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("InterventionSentByEMail", $object->ref); - if (empty($object->actionmsg)) - { + if (empty($object->actionmsg)) { $object->actionmsg = $langs->transnoentities("InterventionSentByEMail", $object->ref); } // Parameters $object->sendtoid defined by caller //$object->sendtoid=0; - } elseif ($action == 'FICHINTER_CLASSIFY_BILLED') - { + } elseif ($action == 'FICHINTER_CLASSIFY_BILLED') { // Load translation files required by the page $langs->loadLangs(array("agenda", "other", "interventions")); @@ -341,8 +314,7 @@ class InterfaceActionsAuto extends DolibarrTriggers $object->actionmsg = $langs->transnoentities("InterventionClassifiedBilledInDolibarr", $object->ref); $object->sendtoid = 0; - } elseif ($action == 'FICHINTER_CLASSIFY_UNBILLED') - { + } elseif ($action == 'FICHINTER_CLASSIFY_UNBILLED') { // Load translation files required by the page $langs->loadLangs(array("agenda", "other", "interventions")); @@ -350,8 +322,7 @@ class InterfaceActionsAuto extends DolibarrTriggers $object->actionmsg = $langs->transnoentities("InterventionClassifiedUnbilledInDolibarr", $object->ref); $object->sendtoid = 0; - } elseif ($action == 'FICHINTER_DELETE') - { + } elseif ($action == 'FICHINTER_DELETE') { // Load translation files required by the page $langs->loadLangs(array("agenda", "other", "interventions")); @@ -361,62 +332,53 @@ class InterfaceActionsAuto extends DolibarrTriggers $object->sendtoid = 0; $object->fk_element = 0; $object->elementtype = ''; - } elseif ($action == 'SHIPPING_VALIDATE') - { + } elseif ($action == 'SHIPPING_VALIDATE') { // Load translation files required by the page $langs->loadLangs(array("agenda", "other", "sendings")); if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("ShippingValidated", ($object->newref ? $object->newref : $object->ref)); - if (empty($object->actionmsg)) - { + if (empty($object->actionmsg)) { $object->actionmsg = $langs->transnoentities("ShippingValidated", ($object->newref ? $object->newref : $object->ref)); } // Parameters $object->sendtoid defined by caller //$object->sendtoid=0; - } elseif ($action == 'SHIPPING_SENTBYMAIL') - { + } elseif ($action == 'SHIPPING_SENTBYMAIL') { // Load translation files required by the page $langs->loadLangs(array("agenda", "other", "sendings")); if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("ShippingSentByEMail", $object->ref); - if (empty($object->actionmsg)) - { + if (empty($object->actionmsg)) { $object->actionmsg = $langs->transnoentities("ShippingSentByEMail", $object->ref); } // Parameters $object->sendtoid defined by caller //$object->sendtoid=0; - } elseif ($action == 'RECEPTION_VALIDATE') - { + } elseif ($action == 'RECEPTION_VALIDATE') { $langs->load("agenda"); $langs->load("other"); $langs->load("receptions"); if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("ReceptionValidated", ($object->newref ? $object->newref : $object->ref)); - if (empty($object->actionmsg)) - { + if (empty($object->actionmsg)) { $object->actionmsg = $langs->transnoentities("ReceptionValidated", ($object->newref ? $object->newref : $object->ref)); } // Parameters $object->sendtoid defined by caller //$object->sendtoid=0; - } elseif ($action == 'RECEPTION_SENTBYMAIL') - { + } elseif ($action == 'RECEPTION_SENTBYMAIL') { $langs->load("agenda"); $langs->load("other"); $langs->load("receptions"); if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("ReceptionSentByEMail", $object->ref); - if (empty($object->actionmsg)) - { + if (empty($object->actionmsg)) { $object->actionmsg = $langs->transnoentities("ReceptionSentByEMail", $object->ref); } // Parameters $object->sendtoid defined by caller //$object->sendtoid=0; - } elseif ($action == 'PROPOSAL_SUPPLIER_VALIDATE') - { + } elseif ($action == 'PROPOSAL_SUPPLIER_VALIDATE') { // Load translation files required by the page $langs->loadLangs(array("agenda", "other", "propal")); @@ -424,21 +386,18 @@ class InterfaceActionsAuto extends DolibarrTriggers $object->actionmsg = $langs->transnoentities("PropalValidatedInDolibarr", ($object->newref ? $object->newref : $object->ref)); $object->sendtoid = 0; - } elseif ($action == 'PROPOSAL_SUPPLIER_SENTBYMAIL') - { + } elseif ($action == 'PROPOSAL_SUPPLIER_SENTBYMAIL') { // Load translation files required by the page $langs->loadLangs(array("agenda", "other", "propal")); if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("ProposalSentByEMail", $object->ref); - if (empty($object->actionmsg)) - { + if (empty($object->actionmsg)) { $object->actionmsg = $langs->transnoentities("ProposalSentByEMail", $object->ref); } // Parameters $object->sendtoid defined by caller //$object->sendtoid=0; - } elseif ($action == 'PROPOSAL_SUPPLIER_CLOSE_SIGNED') - { + } elseif ($action == 'PROPOSAL_SUPPLIER_CLOSE_SIGNED') { // Load translation files required by the page $langs->loadLangs(array("agenda", "other", "propal")); @@ -446,8 +405,7 @@ class InterfaceActionsAuto extends DolibarrTriggers $object->actionmsg = $langs->transnoentities("PropalClosedSignedInDolibarr", $object->ref); $object->sendtoid = 0; - } elseif ($action == 'PROPOSAL_SUPPLIER_CLOSE_REFUSED') - { + } elseif ($action == 'PROPOSAL_SUPPLIER_CLOSE_REFUSED') { // Load translation files required by the page $langs->loadLangs(array("agenda", "other", "propal")); @@ -455,8 +413,7 @@ class InterfaceActionsAuto extends DolibarrTriggers $object->actionmsg = $langs->transnoentities("PropalClosedRefusedInDolibarr", $object->ref); $object->sendtoid = 0; - } elseif ($action == 'ORDER_SUPPLIER_CREATE') - { + } elseif ($action == 'ORDER_SUPPLIER_CREATE') { // Load translation files required by the page $langs->loadLangs(array("agenda", "other", "orders")); @@ -464,8 +421,7 @@ class InterfaceActionsAuto extends DolibarrTriggers $object->actionmsg = $langs->transnoentities("OrderCreatedInDolibarr", ($object->newref ? $object->newref : $object->ref)); $object->sendtoid = 0; - } elseif ($action == 'ORDER_SUPPLIER_VALIDATE') - { + } elseif ($action == 'ORDER_SUPPLIER_VALIDATE') { // Load translation files required by the page $langs->loadLangs(array("agenda", "other", "orders")); @@ -473,8 +429,7 @@ class InterfaceActionsAuto extends DolibarrTriggers $object->actionmsg = $langs->transnoentities("OrderValidatedInDolibarr", ($object->newref ? $object->newref : $object->ref)); $object->sendtoid = 0; - } elseif ($action == 'ORDER_SUPPLIER_APPROVE') - { + } elseif ($action == 'ORDER_SUPPLIER_APPROVE') { // Load translation files required by the page $langs->loadLangs(array("agenda", "other", "orders")); @@ -482,8 +437,7 @@ class InterfaceActionsAuto extends DolibarrTriggers $object->actionmsg = $langs->transnoentities("OrderApprovedInDolibarr", $object->ref); $object->sendtoid = 0; - } elseif ($action == 'ORDER_SUPPLIER_REFUSE') - { + } elseif ($action == 'ORDER_SUPPLIER_REFUSE') { // Load translation files required by the page $langs->loadLangs(array("agenda", "other", "orders")); @@ -491,8 +445,7 @@ class InterfaceActionsAuto extends DolibarrTriggers $object->actionmsg = $langs->transnoentities("OrderRefusedInDolibarr", $object->ref); $object->sendtoid = 0; - } elseif ($action == 'ORDER_SUPPLIER_SUBMIT') - { + } elseif ($action == 'ORDER_SUPPLIER_SUBMIT') { // Load translation files required by the page $langs->loadLangs(array("agenda", "other", "orders")); @@ -500,8 +453,7 @@ class InterfaceActionsAuto extends DolibarrTriggers $object->actionmsg = $langs->transnoentities("SupplierOrderSubmitedInDolibarr", ($object->newref ? $object->newref : $object->ref)); $object->sendtoid = 0; - } elseif ($action == 'ORDER_SUPPLIER_RECEIVE') - { + } elseif ($action == 'ORDER_SUPPLIER_RECEIVE') { // Load translation files required by the page $langs->loadLangs(array("agenda", "other", "orders")); @@ -509,33 +461,28 @@ class InterfaceActionsAuto extends DolibarrTriggers $object->actionmsg = $langs->transnoentities("SupplierOrderReceivedInDolibarr", ($object->newref ? $object->newref : $object->ref)); $object->sendtoid = 0; - } elseif ($action == 'ORDER_SUPPLIER_SENTBYMAIL') - { + } elseif ($action == 'ORDER_SUPPLIER_SENTBYMAIL') { // Load translation files required by the page $langs->loadLangs(array("agenda", "other", "bills", "orders")); if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("SupplierOrderSentByEMail", $object->ref); - if (empty($object->actionmsg)) - { + if (empty($object->actionmsg)) { $object->actionmsg = $langs->transnoentities("SupplierOrderSentByEMail", $object->ref); } // Parameters $object->sendtoid defined by caller //$object->sendtoid=0; - } elseif ($action == 'ORDER_SUPPLIER_CLASSIFY_BILLED') - { + } elseif ($action == 'ORDER_SUPPLIER_CLASSIFY_BILLED') { // Load translation files required by the page $langs->loadLangs(array("agenda", "other", "bills", "orders")); if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("SupplierOrderClassifiedBilled", $object->ref); - if (empty($object->actionmsg)) - { + if (empty($object->actionmsg)) { $object->actionmsg = $langs->transnoentities("SupplierOrderClassifiedBilled", $object->ref); } $object->sendtoid = 0; - } elseif ($action == 'BILL_SUPPLIER_VALIDATE') - { + } elseif ($action == 'BILL_SUPPLIER_VALIDATE') { // Load translation files required by the page $langs->loadLangs(array("agenda", "other", "bills")); @@ -543,8 +490,7 @@ class InterfaceActionsAuto extends DolibarrTriggers $object->actionmsg = $langs->transnoentities("InvoiceValidatedInDolibarr", ($object->newref ? $object->newref : $object->ref)); $object->sendtoid = 0; - } elseif ($action == 'BILL_SUPPLIER_UNVALIDATE') - { + } elseif ($action == 'BILL_SUPPLIER_UNVALIDATE') { // Load translation files required by the page $langs->loadLangs(array("agenda", "other", "bills")); @@ -552,21 +498,18 @@ class InterfaceActionsAuto extends DolibarrTriggers $object->actionmsg = $langs->transnoentities("InvoiceBackToDraftInDolibarr", $object->ref); $object->sendtoid = 0; - } elseif ($action == 'BILL_SUPPLIER_SENTBYMAIL') - { + } elseif ($action == 'BILL_SUPPLIER_SENTBYMAIL') { // Load translation files required by the page $langs->loadLangs(array("agenda", "other", "bills", "orders")); if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("SupplierInvoiceSentByEMail", $object->ref); - if (empty($object->actionmsg)) - { + if (empty($object->actionmsg)) { $object->actionmsg = $langs->transnoentities("SupplierInvoiceSentByEMail", $object->ref); } // Parameters $object->sendtoid defined by caller //$object->sendtoid=0; - } elseif ($action == 'BILL_SUPPLIER_PAYED') - { + } elseif ($action == 'BILL_SUPPLIER_PAYED') { // Load translation files required by the page $langs->loadLangs(array("agenda", "other", "bills")); @@ -574,8 +517,7 @@ class InterfaceActionsAuto extends DolibarrTriggers $object->actionmsg = $langs->transnoentities("InvoicePaidInDolibarr", $object->ref); $object->sendtoid = 0; - } elseif ($action == 'BILL_SUPPLIER_CANCELED') - { + } elseif ($action == 'BILL_SUPPLIER_CANCELED') { // Load translation files required by the page $langs->loadLangs(array("agenda", "other", "bills")); @@ -586,8 +528,7 @@ class InterfaceActionsAuto extends DolibarrTriggers } // Members - elseif ($action == 'MEMBER_VALIDATE') - { + elseif ($action == 'MEMBER_VALIDATE') { // Load translation files required by the page $langs->loadLangs(array("agenda", "other", "members")); @@ -597,8 +538,7 @@ class InterfaceActionsAuto extends DolibarrTriggers $object->actionmsg .= "\n".$langs->transnoentities("Type").': '.$object->type; $object->sendtoid = 0; - } elseif ($action == 'MEMBER_MODIFY') - { + } elseif ($action == 'MEMBER_MODIFY') { // Load translation files required by the page $langs->loadLangs(array("agenda", "other", "members")); @@ -608,14 +548,12 @@ class InterfaceActionsAuto extends DolibarrTriggers $object->actionmsg .= "\n".$langs->transnoentities("Type").': '.$object->type; $object->sendtoid = 0; - } elseif ($action == 'MEMBER_SUBSCRIPTION_CREATE') - { + } elseif ($action == 'MEMBER_SUBSCRIPTION_CREATE') { // Load translation files required by the page $langs->loadLangs(array("agenda", "other", "members")); $member = $this->context['member']; - if (!is_object($member)) // This should not happen - { + if (!is_object($member)) { // This should not happen include_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; $member = new Adherent($this->db); $member->fetch($this->fk_adherent); @@ -630,14 +568,12 @@ class InterfaceActionsAuto extends DolibarrTriggers $object->sendtoid = 0; if ($object->fk_soc > 0) $object->socid = $object->fk_soc; - } elseif ($action == 'MEMBER_SUBSCRIPTION_MODIFY') - { + } elseif ($action == 'MEMBER_SUBSCRIPTION_MODIFY') { // Load translation files required by the page $langs->loadLangs(array("agenda", "other", "members")); $member = $this->context['member']; - if (!is_object($member)) // This should not happen - { + if (!is_object($member)) { // This should not happen include_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; $member = new Adherent($this->db); $member->fetch($this->fk_adherent); @@ -652,8 +588,7 @@ class InterfaceActionsAuto extends DolibarrTriggers $object->sendtoid = 0; if ($object->fk_soc > 0) $object->socid = $object->fk_soc; - } elseif ($action == 'MEMBER_SUBSCRIPTION_DELETE') - { + } elseif ($action == 'MEMBER_SUBSCRIPTION_DELETE') { // Load translation files required by the page $langs->loadLangs(array("agenda", "other", "members")); @@ -666,8 +601,7 @@ class InterfaceActionsAuto extends DolibarrTriggers $object->sendtoid = 0; if ($object->fk_soc > 0) $object->socid = $object->fk_soc; - } elseif ($action == 'MEMBER_RESILIATE') - { + } elseif ($action == 'MEMBER_RESILIATE') { // Load translation files required by the page $langs->loadLangs(array("agenda", "other", "members")); @@ -677,8 +611,7 @@ class InterfaceActionsAuto extends DolibarrTriggers $object->actionmsg .= "\n".$langs->transnoentities("Type").': '.$object->type; $object->sendtoid = 0; - } elseif ($action == 'MEMBER_DELETE') - { + } elseif ($action == 'MEMBER_DELETE') { // Load translation files required by the page $langs->loadLangs(array("agenda", "other", "members")); @@ -691,8 +624,7 @@ class InterfaceActionsAuto extends DolibarrTriggers } // Projects - elseif ($action == 'PROJECT_CREATE') - { + elseif ($action == 'PROJECT_CREATE') { // Load translation files required by the page $langs->loadLangs(array("agenda", "other", "projects")); @@ -701,8 +633,7 @@ class InterfaceActionsAuto extends DolibarrTriggers $object->actionmsg .= "\n".$langs->transnoentities("Project").': '.$object->ref; $object->sendtoid = 0; - } elseif ($action == 'PROJECT_VALIDATE') - { + } elseif ($action == 'PROJECT_VALIDATE') { // Load translation files required by the page $langs->loadLangs(array("agenda", "other", "projects")); @@ -711,8 +642,7 @@ class InterfaceActionsAuto extends DolibarrTriggers $object->actionmsg .= "\n".$langs->transnoentities("Project").': '.$object->ref; $object->sendtoid = 0; - } elseif ($action == 'PROJECT_MODIFY') - { + } elseif ($action == 'PROJECT_MODIFY') { // Load translation files required by the page $langs->loadLangs(array("agenda", "other", "projects")); @@ -724,8 +654,7 @@ class InterfaceActionsAuto extends DolibarrTriggers } // Project tasks - elseif ($action == 'TASK_CREATE') - { + elseif ($action == 'TASK_CREATE') { // Load translation files required by the page $langs->loadLangs(array("agenda", "other", "projects")); @@ -734,8 +663,7 @@ class InterfaceActionsAuto extends DolibarrTriggers $object->actionmsg .= "\n".$langs->transnoentities("Task").': '.$object->ref; $object->sendtoid = 0; - } elseif ($action == 'TASK_MODIFY') - { + } elseif ($action == 'TASK_MODIFY') { // Load translation files required by the page $langs->loadLangs(array("agenda", "other", "projects")); @@ -744,8 +672,7 @@ class InterfaceActionsAuto extends DolibarrTriggers $object->actionmsg .= "\n".$langs->transnoentities("Task").': '.$object->ref; $object->sendtoid = 0; - } elseif ($action == 'TASK_DELETE') - { + } elseif ($action == 'TASK_DELETE') { // Load translation files required by the page $langs->loadLangs(array("agenda", "other", "projects")); @@ -754,23 +681,20 @@ class InterfaceActionsAuto extends DolibarrTriggers $object->actionmsg .= "\n".$langs->transnoentities("Task").': '.$object->ref; $object->sendtoid = 0; - } elseif ($action == 'TICKET_ASSIGNED') - { + } elseif ($action == 'TICKET_ASSIGNED') { // Load translation files required by the page $langs->loadLangs(array("agenda", "other", "projects")); if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("TICKET_ASSIGNEDInDolibarr", $object->ref); $object->actionmsg = $langs->transnoentities("TICKET_ASSIGNEDInDolibarr", $object->ref); - if ($object->oldcopy->fk_user_assign > 0) - { + if ($object->oldcopy->fk_user_assign > 0) { $tmpuser = new User($this->db); $tmpuser->fetch($object->oldcopy->fk_user_assign); $object->actionmsg .= "\n".$langs->transnoentities("OldUser").': '.$tmpuser->getFullName($langs); } else { $object->actionmsg .= "\n".$langs->transnoentities("OldUser").': '.$langs->trans("None"); } - if ($object->fk_user_assign > 0) - { + if ($object->fk_user_assign > 0) { $tmpuser = new User($this->db); $tmpuser->fetch($object->fk_user_assign); $object->actionmsg .= "\n".$langs->transnoentities("NewUser").': '.$tmpuser->getFullName($langs); @@ -816,11 +740,9 @@ class InterfaceActionsAuto extends DolibarrTriggers // Add entry in event table $now = dol_now(); - if (isset($_SESSION['listofnames-'.$object->trackid])) - { + if (isset($_SESSION['listofnames-'.$object->trackid])) { $attachs = $_SESSION['listofnames-'.$object->trackid]; - if ($attachs && strpos($action, 'SENTBYMAIL')) - { + if ($attachs && strpos($action, 'SENTBYMAIL')) { $object->actionmsg = dol_concatdesc($object->actionmsg, "\n".$langs->transnoentities("AttachedFiles").': '.$attachs); } } @@ -830,8 +752,7 @@ class InterfaceActionsAuto extends DolibarrTriggers $societeforaction = new Societe($this->db); // Set contactforaction if there is only 1 contact. - if (is_array($object->sendtoid)) - { + if (is_array($object->sendtoid)) { if (count($object->sendtoid) == 1) $contactforaction->fetch(reset($object->sendtoid)); } else { if ($object->sendtoid > 0) $contactforaction->fetch($object->sendtoid); @@ -846,8 +767,7 @@ class InterfaceActionsAuto extends DolibarrTriggers $elementid = $object->id; // id of object $elementtype = $object->element; $elementmodule = $object->module; - if ($object->element == 'subscription') - { + if ($object->element == 'subscription') { $elementid = $object->fk_adherent; $elementtype = 'member'; } @@ -881,8 +801,7 @@ class InterfaceActionsAuto extends DolibarrTriggers // Object linked (if link is for thirdparty, contact, project it is a recording error. We should not have links in link table // for such objects because there is already a dedicated field into table llx_actioncomm or llx_actioncomm_resources. - if (!in_array($elementtype, array('societe', 'contact', 'project'))) - { + if (!in_array($elementtype, array('societe', 'contact', 'project'))) { $actioncomm->fk_element = $elementid; $actioncomm->elementtype = $elementtype.($elementmodule ? '@'.$elementmodule : ''); } @@ -901,8 +820,7 @@ class InterfaceActionsAuto extends DolibarrTriggers $ret = $actioncomm->create($user); // User creating action - if ($ret > 0 && $conf->global->MAIN_COPY_FILE_IN_EVENT_AUTO) - { + if ($ret > 0 && $conf->global->MAIN_COPY_FILE_IN_EVENT_AUTO) { if (is_array($object->attachedfiles) && array_key_exists('paths', $object->attachedfiles) && count($object->attachedfiles['paths']) > 0) { foreach ($object->attachedfiles['paths'] as $key=>$filespath) { $srcfile = $filespath; @@ -918,8 +836,7 @@ class InterfaceActionsAuto extends DolibarrTriggers unset($object->actionmsg); unset($object->actionmsg2); unset($object->actiontypecode); // When several action are called on same object, we must be sure to not reuse value of first action. - if ($ret > 0) - { + if ($ret > 0) { $_SESSION['LAST_ACTION_CREATED'] = $ret; return 1; } else { diff --git a/htdocs/core/triggers/interface_50_modBlockedlog_ActionsBlockedLog.class.php b/htdocs/core/triggers/interface_50_modBlockedlog_ActionsBlockedLog.class.php index 0800d66eea3..8409d96e5e0 100644 --- a/htdocs/core/triggers/interface_50_modBlockedlog_ActionsBlockedLog.class.php +++ b/htdocs/core/triggers/interface_50_modBlockedlog_ActionsBlockedLog.class.php @@ -30,19 +30,22 @@ require_once DOL_DOCUMENT_ROOT.'/core/triggers/dolibarrtriggers.class.php'; */ class InterfaceActionsBlockedLog extends DolibarrTriggers { - public $family = 'system'; - public $description = "Triggers of this module add action for BlockedLog module (Module of unalterable logs)."; + /** + * Constructor + * + * @param DoliDB $db Database handler + */ + public function __construct($db) + { + $this->db = $db; - /** - * Version of the trigger - * @var string - */ - public $version = self::VERSION_DOLIBARR; - - /** - * @var string Image of the trigger - */ - public $picto = 'technic'; + $this->name = preg_replace('/^Interface/i', '', get_class($this)); + $this->family = "system"; + $this->description = "Triggers of this module add action for BlockedLog module (Module of unalterable logs)."; + // 'development', 'experimental', 'dolibarr' or version + $this->version = self::VERSION_DOLIBARR; + $this->picto = 'technic'; + } /** * Function called on Dolibarr payment or invoice event. @@ -68,8 +71,7 @@ class InterfaceActionsBlockedLog extends DolibarrTriggers $b = new BlockedLog($this->db); // Tracked events - if (!in_array($action, array_keys($b->trackedevents))) - { + if (!in_array($action, array_keys($b->trackedevents))) { return 0; } @@ -84,15 +86,13 @@ class InterfaceActionsBlockedLog extends DolibarrTriggers || (in_array($object->element, array('facture', 'supplier_invoice')) && $action === 'DOC_DOWNLOAD' && $object->statut != 0) || (in_array($object->element, array('facture', 'supplier_invoice')) && $action === 'DOC_PREVIEW' && $object->statut != 0) || (!empty($conf->global->BLOCKEDLOG_ADD_ACTIONS_SUPPORTED) && in_array($action, explode(',', $conf->global->BLOCKEDLOG_ADD_ACTIONS_SUPPORTED))) - ) - { + ) { $qualified++; if (in_array($action, array( 'MEMBER_SUBSCRIPTION_CREATE', 'MEMBER_SUBSCRIPTION_MODIFY', 'MEMBER_SUBSCRIPTION_DELETE', 'DON_VALIDATE', 'DON_MODIFY', 'DON_DELETE'))) $amounts = (double) $object->amount; - elseif ($action == 'CASHCONTROL_VALIDATE') - { + elseif ($action == 'CASHCONTROL_VALIDATE') { $amounts = (double) $object->cash + (double) $object->cheque + (double) $object->card; } else $amounts = (double) $object->total_ttc; } @@ -103,8 +103,7 @@ class InterfaceActionsBlockedLog extends DolibarrTriggers $amounts= (double) $object->total_ttc; }*/ if ($action === 'PAYMENT_CUSTOMER_CREATE' || $action === 'PAYMENT_SUPPLIER_CREATE' || $action === 'DONATION_PAYMENT_CREATE' - || $action === 'PAYMENT_CUSTOMER_DELETE' || $action === 'PAYMENT_SUPPLIER_DELETE' || $action === 'DONATION_PAYMENT_DELETE') - { + || $action === 'PAYMENT_CUSTOMER_DELETE' || $action === 'PAYMENT_SUPPLIER_DELETE' || $action === 'DONATION_PAYMENT_DELETE') { $qualified++; $amounts = 0; if (!empty($object->amounts)) { @@ -112,23 +111,20 @@ class InterfaceActionsBlockedLog extends DolibarrTriggers $amounts += price2num($amount); } } - } elseif (strpos($action, 'PAYMENT') !== false && !in_array($action, array('PAYMENT_ADD_TO_BANK'))) - { + } elseif (strpos($action, 'PAYMENT') !== false && !in_array($action, array('PAYMENT_ADD_TO_BANK'))) { $qualified++; $amounts = (double) $object->amount; } // Another protection. // May be used when event is DOC_DOWNLOAD or DOC_PREVIEW and element is not an invoice - if (!$qualified) - { + if (!$qualified) { return 0; // not implemented action log } $result = $b->setObjectData($object, $action, $amounts, $user); // Set field date_object, ref_object, fk_object, element, object_data - if ($result < 0) - { + if ($result < 0) { $this->error = $b->error; $this->errors = $b->errors; return -1; @@ -136,8 +132,7 @@ class InterfaceActionsBlockedLog extends DolibarrTriggers $res = $b->create($user); - if ($res < 0) - { + if ($res < 0) { $this->error = $b->error; $this->errors = $b->errors; return -1; diff --git a/htdocs/core/triggers/interface_50_modLdap_Ldapsynchro.class.php b/htdocs/core/triggers/interface_50_modLdap_Ldapsynchro.class.php index 9c3987cbeb1..bed87b0377f 100644 --- a/htdocs/core/triggers/interface_50_modLdap_Ldapsynchro.class.php +++ b/htdocs/core/triggers/interface_50_modLdap_Ldapsynchro.class.php @@ -31,19 +31,22 @@ require_once DOL_DOCUMENT_ROOT.'/core/triggers/dolibarrtriggers.class.php'; */ class InterfaceLdapsynchro extends DolibarrTriggers { - public $family = 'ldap'; - public $description = "Triggers of this module allows to synchronize Dolibarr toward a LDAP database."; + /** + * Constructor + * + * @param DoliDB $db Database handler + */ + public function __construct($db) + { + $this->db = $db; - /** - * Version of the trigger - * @var string - */ - public $version = self::VERSION_DOLIBARR; - - /** - * @var string Image of the trigger - */ - public $picto = 'technic'; + $this->name = preg_replace('/^Interface/i', '', get_class($this)); + $this->family = "ldap"; + $this->description = "Triggers of this module allows to synchronize Dolibarr toward a LDAP database."; + // 'development', 'experimental', 'dolibarr' or version + $this->version = self::VERSION_DOLIBARR; + $this->picto = 'technic'; + } /** * Function called when a Dolibarrr business event is done. @@ -61,8 +64,7 @@ class InterfaceLdapsynchro extends DolibarrTriggers if (empty($conf->ldap->enabled)) return 0; // Module not active, we do nothing if (defined('DISABLE_LDAP_SYNCHRO')) return 0; // If constant defined, we do nothing - if (!function_exists('ldap_connect')) - { + if (!function_exists('ldap_connect')) { dol_syslog("Warning, module LDAP is enabled but LDAP functions not available in this PHP", LOG_WARNING); return 0; } @@ -73,16 +75,13 @@ class InterfaceLdapsynchro extends DolibarrTriggers $result = 0; // Users - if ($action == 'USER_CREATE') - { + if ($action == 'USER_CREATE') { dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); - if (!empty($conf->global->LDAP_SYNCHRO_ACTIVE) && $conf->global->LDAP_SYNCHRO_ACTIVE === 'dolibarr2ldap') - { + if (!empty($conf->global->LDAP_SYNCHRO_ACTIVE) && $conf->global->LDAP_SYNCHRO_ACTIVE === 'dolibarr2ldap') { $ldap = new Ldap(); $result = $ldap->connect_bind(); - if ($result > 0) - { + if ($result > 0) { $info = $object->_load_ldap_info(); $dn = $object->_load_ldap_dn($info); @@ -91,18 +90,14 @@ class InterfaceLdapsynchro extends DolibarrTriggers if ($result < 0) $this->error = "ErrorLDAP ".$ldap->error; } - } elseif ($action == 'USER_MODIFY') - { + } elseif ($action == 'USER_MODIFY') { dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); - if (!empty($conf->global->LDAP_SYNCHRO_ACTIVE) && $conf->global->LDAP_SYNCHRO_ACTIVE === 'dolibarr2ldap') - { + if (!empty($conf->global->LDAP_SYNCHRO_ACTIVE) && $conf->global->LDAP_SYNCHRO_ACTIVE === 'dolibarr2ldap') { $ldap = new Ldap(); $result = $ldap->connect_bind(); - if ($result > 0) - { - if (empty($object->oldcopy) || !is_object($object->oldcopy)) - { + if ($result > 0) { + if (empty($object->oldcopy) || !is_object($object->oldcopy)) { dol_syslog("Trigger ".$action." was called by a function that did not set previously the property ->oldcopy onto object", LOG_WARNING); $object->oldcopy = clone $object; } @@ -114,8 +109,7 @@ class InterfaceLdapsynchro extends DolibarrTriggers $container = $object->oldcopy->_load_ldap_dn($oldinfo, 1); $search = "(".$object->oldcopy->_load_ldap_dn($oldinfo, 2).")"; $records = $ldap->search($container, $search); - if (count($records) && $records['count'] == 0) - { + if (count($records) && $records['count'] == 0) { $olddn = ''; } @@ -129,18 +123,14 @@ class InterfaceLdapsynchro extends DolibarrTriggers if ($result < 0) $this->error = "ErrorLDAP ".$ldap->error; } - } elseif ($action == 'USER_NEW_PASSWORD') - { + } elseif ($action == 'USER_NEW_PASSWORD') { dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); - if (!empty($conf->global->LDAP_SYNCHRO_ACTIVE) && $conf->global->LDAP_SYNCHRO_ACTIVE === 'dolibarr2ldap') - { + if (!empty($conf->global->LDAP_SYNCHRO_ACTIVE) && $conf->global->LDAP_SYNCHRO_ACTIVE === 'dolibarr2ldap') { $ldap = new Ldap(); $result = $ldap->connect_bind(); - if ($result > 0) - { - if (empty($object->oldcopy) || !is_object($object->oldcopy)) - { + if ($result > 0) { + if (empty($object->oldcopy) || !is_object($object->oldcopy)) { dol_syslog("Trigger ".$action." was called by a function that did not set previously the property ->oldcopy onto object", LOG_WARNING); $object->oldcopy = clone $object; } @@ -152,8 +142,7 @@ class InterfaceLdapsynchro extends DolibarrTriggers $container = $object->oldcopy->_load_ldap_dn($oldinfo, 1); $search = "(".$object->oldcopy->_load_ldap_dn($oldinfo, 2).")"; $records = $ldap->search($container, $search); - if (count($records) && $records['count'] == 0) - { + if (count($records) && $records['count'] == 0) { $olddn = ''; } @@ -165,19 +154,15 @@ class InterfaceLdapsynchro extends DolibarrTriggers if ($result < 0) $this->error = "ErrorLDAP ".$ldap->error; } - } elseif ($action == 'USER_ENABLEDISABLE') - { + } elseif ($action == 'USER_ENABLEDISABLE') { dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); - } elseif ($action == 'USER_DELETE') - { + } elseif ($action == 'USER_DELETE') { dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); - if (!empty($conf->global->LDAP_SYNCHRO_ACTIVE) && $conf->global->LDAP_SYNCHRO_ACTIVE === 'dolibarr2ldap') - { + if (!empty($conf->global->LDAP_SYNCHRO_ACTIVE) && $conf->global->LDAP_SYNCHRO_ACTIVE === 'dolibarr2ldap') { $ldap = new Ldap(); $result = $ldap->connect_bind(); - if ($result > 0) - { + if ($result > 0) { $info = $object->_load_ldap_info(); $dn = $object->_load_ldap_dn($info); @@ -186,20 +171,16 @@ class InterfaceLdapsynchro extends DolibarrTriggers if ($result < 0) $this->error = "ErrorLDAP ".$ldap->error; } - } elseif ($action == 'USER_SETINGROUP') - { + } elseif ($action == 'USER_SETINGROUP') { dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); - if (!empty($conf->global->LDAP_SYNCHRO_ACTIVE) && $conf->global->LDAP_SYNCHRO_ACTIVE === 'dolibarr2ldap') - { + if (!empty($conf->global->LDAP_SYNCHRO_ACTIVE) && $conf->global->LDAP_SYNCHRO_ACTIVE === 'dolibarr2ldap') { $ldap = new Ldap(); $result = $ldap->connect_bind(); - if ($result > 0) - { + if ($result > 0) { // Must edit $object->newgroupid $usergroup = new UserGroup($this->db); - if ($object->newgroupid > 0) - { + if ($object->newgroupid > 0) { $usergroup->fetch($object->newgroupid); $oldinfo = $usergroup->_load_ldap_info(); @@ -209,8 +190,7 @@ class InterfaceLdapsynchro extends DolibarrTriggers $container = $usergroup->_load_ldap_dn($oldinfo, 1); $search = "(".$usergroup->_load_ldap_dn($oldinfo, 2).")"; $records = $ldap->search($container, $search); - if (count($records) && $records['count'] == 0) - { + if (count($records) && $records['count'] == 0) { $olddn = ''; } @@ -223,20 +203,16 @@ class InterfaceLdapsynchro extends DolibarrTriggers if ($result < 0) $this->error = "ErrorLDAP ".$ldap->error; } - } elseif ($action == 'USER_REMOVEFROMGROUP') - { + } elseif ($action == 'USER_REMOVEFROMGROUP') { dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); - if (!empty($conf->global->LDAP_SYNCHRO_ACTIVE) && $conf->global->LDAP_SYNCHRO_ACTIVE === 'dolibarr2ldap') - { + if (!empty($conf->global->LDAP_SYNCHRO_ACTIVE) && $conf->global->LDAP_SYNCHRO_ACTIVE === 'dolibarr2ldap') { $ldap = new Ldap(); $result = $ldap->connect_bind(); - if ($result > 0) - { + if ($result > 0) { // Must edit $object->newgroupid $usergroup = new UserGroup($this->db); - if ($object->oldgroupid > 0) - { + if ($object->oldgroupid > 0) { $usergroup->fetch($object->oldgroupid); $oldinfo = $usergroup->_load_ldap_info(); @@ -246,8 +222,7 @@ class InterfaceLdapsynchro extends DolibarrTriggers $container = $usergroup->_load_ldap_dn($oldinfo, 1); $search = "(".$usergroup->_load_ldap_dn($oldinfo, 2).")"; $records = $ldap->search($container, $search); - if (count($records) && $records['count'] == 0) - { + if (count($records) && $records['count'] == 0) { $olddn = ''; } @@ -263,16 +238,13 @@ class InterfaceLdapsynchro extends DolibarrTriggers } // Groupes - elseif ($action == 'USERGROUP_CREATE') - { + elseif ($action == 'USERGROUP_CREATE') { dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); - if (!empty($conf->global->LDAP_SYNCHRO_ACTIVE) && $conf->global->LDAP_SYNCHRO_ACTIVE === 'dolibarr2ldap') - { + if (!empty($conf->global->LDAP_SYNCHRO_ACTIVE) && $conf->global->LDAP_SYNCHRO_ACTIVE === 'dolibarr2ldap') { $ldap = new Ldap(); $result = $ldap->connect_bind(); - if ($result > 0) - { + if ($result > 0) { $info = $object->_load_ldap_info(); $dn = $object->_load_ldap_dn($info); @@ -286,18 +258,14 @@ class InterfaceLdapsynchro extends DolibarrTriggers if ($result < 0) $this->error = "ErrorLDAP ".$ldap->error; } - } elseif ($action == 'USERGROUP_MODIFY') - { + } elseif ($action == 'USERGROUP_MODIFY') { dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); - if (!empty($conf->global->LDAP_SYNCHRO_ACTIVE) && $conf->global->LDAP_SYNCHRO_ACTIVE === 'dolibarr2ldap') - { + if (!empty($conf->global->LDAP_SYNCHRO_ACTIVE) && $conf->global->LDAP_SYNCHRO_ACTIVE === 'dolibarr2ldap') { $ldap = new Ldap(); $result = $ldap->connect_bind(); - if ($result > 0) - { - if (empty($object->oldcopy) || !is_object($object->oldcopy)) - { + if ($result > 0) { + if (empty($object->oldcopy) || !is_object($object->oldcopy)) { dol_syslog("Trigger ".$action." was called by a function that did not set previously the property ->oldcopy onto object", LOG_WARNING); $object->oldcopy = clone $object; } @@ -309,8 +277,7 @@ class InterfaceLdapsynchro extends DolibarrTriggers $container = $object->oldcopy->_load_ldap_dn($oldinfo, 1); $search = "(".$object->oldcopy->_load_ldap_dn($oldinfo, 2).")"; $records = $ldap->search($container, $search); - if (count($records) && $records['count'] == 0) - { + if (count($records) && $records['count'] == 0) { $olddn = ''; } @@ -322,16 +289,13 @@ class InterfaceLdapsynchro extends DolibarrTriggers if ($result < 0) $this->error = "ErrorLDAP ".$ldap->error; } - } elseif ($action == 'USERGROUP_DELETE') - { + } elseif ($action == 'USERGROUP_DELETE') { dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); - if (!empty($conf->global->LDAP_SYNCHRO_ACTIVE) && $conf->global->LDAP_SYNCHRO_ACTIVE === 'dolibarr2ldap') - { + if (!empty($conf->global->LDAP_SYNCHRO_ACTIVE) && $conf->global->LDAP_SYNCHRO_ACTIVE === 'dolibarr2ldap') { $ldap = new Ldap(); $result = $ldap->connect_bind(); - if ($result > 0) - { + if ($result > 0) { $info = $object->_load_ldap_info(); $dn = $object->_load_ldap_dn($info); @@ -343,16 +307,13 @@ class InterfaceLdapsynchro extends DolibarrTriggers } // Contacts - elseif ($action == 'CONTACT_CREATE') - { + elseif ($action == 'CONTACT_CREATE') { dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); - if (!empty($conf->global->LDAP_CONTACT_ACTIVE)) - { + if (!empty($conf->global->LDAP_CONTACT_ACTIVE)) { $ldap = new Ldap(); $result = $ldap->connect_bind(); - if ($result > 0) - { + if ($result > 0) { $info = $object->_load_ldap_info(); $dn = $object->_load_ldap_dn($info); @@ -361,18 +322,14 @@ class InterfaceLdapsynchro extends DolibarrTriggers if ($result < 0) $this->error = "ErrorLDAP ".$ldap->error; } - } elseif ($action == 'CONTACT_MODIFY') - { + } elseif ($action == 'CONTACT_MODIFY') { dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); - if (!empty($conf->global->LDAP_CONTACT_ACTIVE)) - { + if (!empty($conf->global->LDAP_CONTACT_ACTIVE)) { $ldap = new Ldap(); $result = $ldap->connect_bind(); - if ($result > 0) - { - if (empty($object->oldcopy) || !is_object($object->oldcopy)) - { + if ($result > 0) { + if (empty($object->oldcopy) || !is_object($object->oldcopy)) { dol_syslog("Trigger ".$action." was called by a function that did not set previously the property ->oldcopy onto object", LOG_WARNING); $object->oldcopy = clone $object; } @@ -384,8 +341,7 @@ class InterfaceLdapsynchro extends DolibarrTriggers $container = $object->oldcopy->_load_ldap_dn($oldinfo, 1); $search = "(".$object->oldcopy->_load_ldap_dn($oldinfo, 2).")"; $records = $ldap->search($container, $search); - if (count($records) && $records['count'] == 0) - { + if (count($records) && $records['count'] == 0) { $olddn = ''; } @@ -397,16 +353,13 @@ class InterfaceLdapsynchro extends DolibarrTriggers if ($result < 0) $this->error = "ErrorLDAP ".$ldap->error; } - } elseif ($action == 'CONTACT_DELETE') - { + } elseif ($action == 'CONTACT_DELETE') { dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); - if (!empty($conf->global->LDAP_CONTACT_ACTIVE)) - { + if (!empty($conf->global->LDAP_CONTACT_ACTIVE)) { $ldap = new Ldap(); $result = $ldap->connect_bind(); - if ($result > 0) - { + if ($result > 0) { $info = $object->_load_ldap_info(); $dn = $object->_load_ldap_dn($info); @@ -418,26 +371,21 @@ class InterfaceLdapsynchro extends DolibarrTriggers } // Members - elseif ($action == 'MEMBER_CREATE') - { + elseif ($action == 'MEMBER_CREATE') { dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); - if (!empty($conf->global->LDAP_MEMBER_ACTIVE) && (string) $conf->global->LDAP_MEMBER_ACTIVE == '1') - { + if (!empty($conf->global->LDAP_MEMBER_ACTIVE) && (string) $conf->global->LDAP_MEMBER_ACTIVE == '1') { $ldap = new Ldap(); $result = $ldap->connect_bind(); - if ($result > 0) - { + if ($result > 0) { $info = $object->_load_ldap_info(); $dn = $object->_load_ldap_dn($info); $result = $ldap->add($dn, $info, $user); // For member type - if (!empty($conf->global->LDAP_MEMBER_TYPE_ACTIVE) && (string) $conf->global->LDAP_MEMBER_TYPE_ACTIVE == '1') - { - if ($object->typeid > 0) - { + if (!empty($conf->global->LDAP_MEMBER_TYPE_ACTIVE) && (string) $conf->global->LDAP_MEMBER_TYPE_ACTIVE == '1') { + if ($object->typeid > 0) { require_once DOL_DOCUMENT_ROOT."/adherents/class/adherent_type.class.php"; $membertype = new AdherentType($this->db); $membertype->fetch($object->typeid); @@ -450,8 +398,7 @@ class InterfaceLdapsynchro extends DolibarrTriggers $container = $membertype->_load_ldap_dn($oldinfo, 1); $search = "(".$membertype->_load_ldap_dn($oldinfo, 2).")"; $records = $ldap->search($container, $search); - if (count($records) && $records['count'] == 0) - { + if (count($records) && $records['count'] == 0) { $olddn = ''; } @@ -465,19 +412,15 @@ class InterfaceLdapsynchro extends DolibarrTriggers if ($result < 0) $this->error = "ErrorLDAP ".$ldap->error; } - } elseif ($action == 'MEMBER_VALIDATE') - { + } elseif ($action == 'MEMBER_VALIDATE') { dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); - if (!empty($conf->global->LDAP_MEMBER_ACTIVE) && (string) $conf->global->LDAP_MEMBER_ACTIVE == '1') - { + if (!empty($conf->global->LDAP_MEMBER_ACTIVE) && (string) $conf->global->LDAP_MEMBER_ACTIVE == '1') { // If status field is setup to be synchronized - if (!empty($conf->global->LDAP_FIELD_MEMBER_STATUS)) - { + if (!empty($conf->global->LDAP_FIELD_MEMBER_STATUS)) { $ldap = new Ldap(); $result = $ldap->connect_bind(); - if ($result > 0) - { + if ($result > 0) { $info = $object->_load_ldap_info(); $dn = $object->_load_ldap_dn($info); $olddn = $dn; // We know olddn=dn as we change only status @@ -488,23 +431,19 @@ class InterfaceLdapsynchro extends DolibarrTriggers if ($result < 0) $this->error = "ErrorLDAP ".$ldap->error; } } - } elseif ($action == 'MEMBER_SUBSCRIPTION') - { + } elseif ($action == 'MEMBER_SUBSCRIPTION') { dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); - if (!empty($conf->global->LDAP_MEMBER_ACTIVE) && (string) $conf->global->LDAP_MEMBER_ACTIVE == '1') - { + if (!empty($conf->global->LDAP_MEMBER_ACTIVE) && (string) $conf->global->LDAP_MEMBER_ACTIVE == '1') { // If subscriptions fields are setup to be synchronized if ($conf->global->LDAP_FIELD_MEMBER_FIRSTSUBSCRIPTION_DATE || $conf->global->LDAP_FIELD_MEMBER_FIRSTSUBSCRIPTION_AMOUNT || $conf->global->LDAP_FIELD_MEMBER_LASTSUBSCRIPTION_DATE || $conf->global->LDAP_FIELD_MEMBER_LASTSUBSCRIPTION_AMOUNT - || $conf->global->LDAP_FIELD_MEMBER_END_LASTSUBSCRIPTION) - { + || $conf->global->LDAP_FIELD_MEMBER_END_LASTSUBSCRIPTION) { $ldap = new Ldap(); $result = $ldap->connect_bind(); - if ($result > 0) - { + if ($result > 0) { $info = $object->_load_ldap_info(); $dn = $object->_load_ldap_dn($info); $olddn = $dn; // We know olddn=dn as we change only subscriptions @@ -515,18 +454,14 @@ class InterfaceLdapsynchro extends DolibarrTriggers if ($result < 0) $this->error = "ErrorLDAP ".$ldap->error; } } - } elseif ($action == 'MEMBER_MODIFY') - { + } elseif ($action == 'MEMBER_MODIFY') { dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); - if (!empty($conf->global->LDAP_MEMBER_ACTIVE) && (string) $conf->global->LDAP_MEMBER_ACTIVE == '1') - { + if (!empty($conf->global->LDAP_MEMBER_ACTIVE) && (string) $conf->global->LDAP_MEMBER_ACTIVE == '1') { $ldap = new Ldap(); $result = $ldap->connect_bind(); - if ($result > 0) - { - if (empty($object->oldcopy) || !is_object($object->oldcopy)) - { + if ($result > 0) { + if (empty($object->oldcopy) || !is_object($object->oldcopy)) { dol_syslog("Trigger ".$action." was called by a function that did not set previously the property ->oldcopy onto object", LOG_WARNING); $object->oldcopy = clone $object; } @@ -538,8 +473,7 @@ class InterfaceLdapsynchro extends DolibarrTriggers $container = $object->oldcopy->_load_ldap_dn($oldinfo, 1); $search = "(".$object->oldcopy->_load_ldap_dn($oldinfo, 2).")"; $records = $ldap->search($container, $search); - if (count($records) && $records['count'] == 0) - { + if (count($records) && $records['count'] == 0) { $olddn = ''; } @@ -551,8 +485,7 @@ class InterfaceLdapsynchro extends DolibarrTriggers $result = $ldap->update($dn, $info, $user, $olddn, $newrdn, $newparent); // For member type - if (!empty($conf->global->LDAP_MEMBER_TYPE_ACTIVE) && (string) $conf->global->LDAP_MEMBER_TYPE_ACTIVE == '1') - { + if (!empty($conf->global->LDAP_MEMBER_TYPE_ACTIVE) && (string) $conf->global->LDAP_MEMBER_TYPE_ACTIVE == '1') { require_once DOL_DOCUMENT_ROOT."/adherents/class/adherent_type.class.php"; /* @@ -569,8 +502,7 @@ class InterfaceLdapsynchro extends DolibarrTriggers $container = $newmembertype->_load_ldap_dn($oldinfo, 1); $search = "(".$newmembertype->_load_ldap_dn($oldinfo, 2).")"; $records = $ldap->search($container, $search); - if (count($records) && $records['count'] == 0) - { + if (count($records) && $records['count'] == 0) { $olddn = ''; } @@ -579,8 +511,7 @@ class InterfaceLdapsynchro extends DolibarrTriggers $result = $ldap->update($dn, $info, $user, $olddn); - if ($object->oldcopy->typeid != $object->typeid) - { + if ($object->oldcopy->typeid != $object->typeid) { /* * Remove member in old member type */ @@ -595,8 +526,7 @@ class InterfaceLdapsynchro extends DolibarrTriggers $container = $oldmembertype->_load_ldap_dn($oldinfo, 1); $search = "(".$oldmembertype->_load_ldap_dn($oldinfo, 2).")"; $records = $ldap->search($container, $search); - if (count($records) && $records['count'] == 0) - { + if (count($records) && $records['count'] == 0) { $olddn = ''; } @@ -608,24 +538,19 @@ class InterfaceLdapsynchro extends DolibarrTriggers } } - if ($result <= 0) - { + if ($result <= 0) { $this->errors[] = "ErrorLDAP ".$ldap->error; } } - } elseif ($action == 'MEMBER_NEW_PASSWORD') - { + } elseif ($action == 'MEMBER_NEW_PASSWORD') { dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); - if (!empty($conf->global->LDAP_MEMBER_ACTIVE) && (string) $conf->global->LDAP_MEMBER_ACTIVE == '1') - { + if (!empty($conf->global->LDAP_MEMBER_ACTIVE) && (string) $conf->global->LDAP_MEMBER_ACTIVE == '1') { // If password field is setup to be synchronized - if ($conf->global->LDAP_FIELD_PASSWORD || $conf->global->LDAP_FIELD_PASSWORD_CRYPTED) - { + if ($conf->global->LDAP_FIELD_PASSWORD || $conf->global->LDAP_FIELD_PASSWORD_CRYPTED) { $ldap = new Ldap(); $result = $ldap->connect_bind(); - if ($result > 0) - { + if ($result > 0) { $info = $object->_load_ldap_info(); $dn = $object->_load_ldap_dn($info); $olddn = $dn; // We know olddn=dn as we change only password @@ -633,25 +558,20 @@ class InterfaceLdapsynchro extends DolibarrTriggers $result = $ldap->update($dn, $info, $user, $olddn); } - if ($result <= 0) - { + if ($result <= 0) { $this->errors[] = "ErrorLDAP ".$ldap->error; } } } - } elseif ($action == 'MEMBER_RESILIATE') - { + } elseif ($action == 'MEMBER_RESILIATE') { dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); - if (!empty($conf->global->LDAP_MEMBER_ACTIVE) && (string) $conf->global->LDAP_MEMBER_ACTIVE == '1') - { + if (!empty($conf->global->LDAP_MEMBER_ACTIVE) && (string) $conf->global->LDAP_MEMBER_ACTIVE == '1') { // If status field is setup to be synchronized - if (!empty($conf->global->LDAP_FIELD_MEMBER_STATUS)) - { + if (!empty($conf->global->LDAP_FIELD_MEMBER_STATUS)) { $ldap = new Ldap(); $result = $ldap->connect_bind(); - if ($result > 0) - { + if ($result > 0) { $info = $object->_load_ldap_info(); $dn = $object->_load_ldap_dn($info); $olddn = $dn; // We know olddn=dn as we change only status @@ -659,32 +579,26 @@ class InterfaceLdapsynchro extends DolibarrTriggers $result = $ldap->update($dn, $info, $user, $olddn); } - if ($result <= 0) - { + if ($result <= 0) { $this->errors[] = "ErrorLDAP ".$ldap->error; } } } - } elseif ($action == 'MEMBER_DELETE') - { + } elseif ($action == 'MEMBER_DELETE') { dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); - if (!empty($conf->global->LDAP_MEMBER_ACTIVE) && (string) $conf->global->LDAP_MEMBER_ACTIVE == '1') - { + if (!empty($conf->global->LDAP_MEMBER_ACTIVE) && (string) $conf->global->LDAP_MEMBER_ACTIVE == '1') { $ldap = new Ldap(); $result = $ldap->connect_bind(); - if ($result > 0) - { + if ($result > 0) { $info = $object->_load_ldap_info(); $dn = $object->_load_ldap_dn($info); $result = $ldap->delete($dn); // For member type - if (!empty($conf->global->LDAP_MEMBER_TYPE_ACTIVE) && (string) $conf->global->LDAP_MEMBER_TYPE_ACTIVE == '1') - { - if ($object->typeid > 0) - { + if (!empty($conf->global->LDAP_MEMBER_TYPE_ACTIVE) && (string) $conf->global->LDAP_MEMBER_TYPE_ACTIVE == '1') { + if ($object->typeid > 0) { require_once DOL_DOCUMENT_ROOT."/adherents/class/adherent_type.class.php"; /* @@ -701,8 +615,7 @@ class InterfaceLdapsynchro extends DolibarrTriggers $container = $membertype->_load_ldap_dn($oldinfo, 1); $search = "(".$membertype->_load_ldap_dn($oldinfo, 2).")"; $records = $ldap->search($container, $search); - if (count($records) && $records['count'] == 0) - { + if (count($records) && $records['count'] == 0) { $olddn = ''; } @@ -714,24 +627,20 @@ class InterfaceLdapsynchro extends DolibarrTriggers } } - if ($result <= 0) - { + if ($result <= 0) { $this->errors[] = "ErrorLDAP ".$ldap->error; } } } // Members types - elseif ($action == 'MEMBER_TYPE_CREATE') - { + elseif ($action == 'MEMBER_TYPE_CREATE') { dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); - if (!empty($conf->global->LDAP_MEMBER_TYPE_ACTIVE) && (string) $conf->global->LDAP_MEMBER_TYPE_ACTIVE == '1') - { + if (!empty($conf->global->LDAP_MEMBER_TYPE_ACTIVE) && (string) $conf->global->LDAP_MEMBER_TYPE_ACTIVE == '1') { $ldap = new Ldap(); $result = $ldap->connect_bind(); - if ($result > 0) - { + if ($result > 0) { $info = $object->_load_ldap_info(); $dn = $object->_load_ldap_dn($info); @@ -743,23 +652,18 @@ class InterfaceLdapsynchro extends DolibarrTriggers $result = $ldap->add($dn, $info, $user); } - if ($result <= 0) - { + if ($result <= 0) { $this->errors[] = "ErrorLDAP ".$ldap->error; } } - } elseif ($action == 'MEMBER_TYPE_MODIFY') - { + } elseif ($action == 'MEMBER_TYPE_MODIFY') { dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); - if (!empty($conf->global->LDAP_MEMBER_TYPE_ACTIVE) && (string) $conf->global->LDAP_MEMBER_TYPE_ACTIVE == '1') - { + if (!empty($conf->global->LDAP_MEMBER_TYPE_ACTIVE) && (string) $conf->global->LDAP_MEMBER_TYPE_ACTIVE == '1') { $ldap = new Ldap(); $result = $ldap->connect_bind(); - if ($result > 0) - { - if (empty($object->oldcopy) || !is_object($object->oldcopy)) - { + if ($result > 0) { + if (empty($object->oldcopy) || !is_object($object->oldcopy)) { dol_syslog("Trigger ".$action." was called by a function that did not set previously the property ->oldcopy onto object", LOG_WARNING); $object->oldcopy = clone $object; } @@ -773,8 +677,7 @@ class InterfaceLdapsynchro extends DolibarrTriggers $container = $object->oldcopy->_load_ldap_dn($oldinfo, 1); $search = "(".$object->oldcopy->_load_ldap_dn($oldinfo, 2).")"; $records = $ldap->search($container, $search); - if (count($records) && $records['count'] == 0) - { + if (count($records) && $records['count'] == 0) { $olddn = ''; } @@ -790,24 +693,20 @@ class InterfaceLdapsynchro extends DolibarrTriggers $this->errors[] = "ErrorLDAP ".$ldap->error; } } - } elseif ($action == 'MEMBER_TYPE_DELETE') - { + } elseif ($action == 'MEMBER_TYPE_DELETE') { dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); - if (!empty($conf->global->LDAP_MEMBER_TYPE_ACTIVE) && (string) $conf->global->LDAP_MEMBER_TYPE_ACTIVE == '1') - { + if (!empty($conf->global->LDAP_MEMBER_TYPE_ACTIVE) && (string) $conf->global->LDAP_MEMBER_TYPE_ACTIVE == '1') { $ldap = new Ldap(); $result = $ldap->connect_bind(); - if ($result > 0) - { + if ($result > 0) { $info = $object->_load_ldap_info(); $dn = $object->_load_ldap_dn($info); $result = $ldap->delete($dn); } - if ($result <= 0) - { + if ($result <= 0) { $this->errors[] = "ErrorLDAP ".$ldap->error; } } diff --git a/htdocs/core/triggers/interface_50_modMailmanspip_Mailmanspipsynchro.class.php b/htdocs/core/triggers/interface_50_modMailmanspip_Mailmanspipsynchro.class.php index 59005b2f34d..e8766401219 100644 --- a/htdocs/core/triggers/interface_50_modMailmanspip_Mailmanspipsynchro.class.php +++ b/htdocs/core/triggers/interface_50_modMailmanspip_Mailmanspipsynchro.class.php @@ -29,19 +29,22 @@ require_once DOL_DOCUMENT_ROOT.'/core/triggers/dolibarrtriggers.class.php'; */ class InterfaceMailmanSpipsynchro extends DolibarrTriggers { - public $family = 'mailmanspip'; - public $description = "Triggers of this module allows to synchronize Mailman an Spip."; + /** + * Constructor + * + * @param DoliDB $db Database handler + */ + public function __construct($db) + { + $this->db = $db; - /** - * Version of the trigger - * @var string - */ - public $version = self::VERSION_DOLIBARR; - - /** - * @var string Image of the trigger - */ - public $picto = 'technic'; + $this->name = preg_replace('/^Interface/i', '', get_class($this)); + $this->family = "mailmanspip"; + $this->description = "Triggers of this module allows to synchronize Mailman an Spip."; + // 'development', 'experimental', 'dolibarr' or version + $this->version = self::VERSION_DOLIBARR; + $this->picto = 'technic'; + } /** * Function called when a Dolibarrr business event is done. @@ -61,13 +64,11 @@ class InterfaceMailmanSpipsynchro extends DolibarrTriggers require_once DOL_DOCUMENT_ROOT."/mailmanspip/class/mailmanspip.class.php"; require_once DOL_DOCUMENT_ROOT."/user/class/usergroup.class.php"; - if ($action == 'CATEGORY_LINK') - { + if ($action == 'CATEGORY_LINK') { dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); // We add subscription if we change category (new category may means more mailing-list to subscribe) - if (is_object($object->context['linkto']) && method_exists($object->context['linkto'], 'add_to_abo') && $object->context['linkto']->add_to_abo() < 0) - { + if (is_object($object->context['linkto']) && method_exists($object->context['linkto'], 'add_to_abo') && $object->context['linkto']->add_to_abo() < 0) { $this->error = $object->context['linkto']->error; $this->errors = $object->context['linkto']->errors; $return = -1; @@ -76,13 +77,11 @@ class InterfaceMailmanSpipsynchro extends DolibarrTriggers } return $return; - } elseif ($action == 'CATEGORY_UNLINK') - { + } elseif ($action == 'CATEGORY_UNLINK') { dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); // We remove subscription if we change category (lessw category may means less mailing-list to subscribe) - if (is_object($object->context['unlinkoff']) && method_exists($object->context['unlinkoff'], 'del_to_abo') && $object->context['unlinkoff']->del_to_abo() < 0) - { + if (is_object($object->context['unlinkoff']) && method_exists($object->context['unlinkoff'], 'del_to_abo') && $object->context['unlinkoff']->del_to_abo() < 0) { $this->error = $object->context['unlinkoff']->error; $this->errors = $object->context['unlinkoff']->errors; $return = -1; @@ -94,13 +93,11 @@ class InterfaceMailmanSpipsynchro extends DolibarrTriggers } // Members - elseif ($action == 'MEMBER_VALIDATE') - { + elseif ($action == 'MEMBER_VALIDATE') { dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); $return = 0; - if ($object->add_to_abo() < 0) - { + if ($object->add_to_abo() < 0) { $this->errors = $object->errors; if (!empty($object->error)) $this->errors[] = $object->error; $return = -1; @@ -109,28 +106,23 @@ class InterfaceMailmanSpipsynchro extends DolibarrTriggers } return $return; - } elseif ($action == 'MEMBER_MODIFY') - { + } elseif ($action == 'MEMBER_MODIFY') { dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); $return = 0; // Add user into some linked tools (mailman, spip, etc...) - if (($object->oldcopy->email != $object->email) || ($object->oldcopy->typeid != $object->typeid)) - { - if (is_object($object->oldcopy) && (($object->oldcopy->email != $object->email) || ($object->oldcopy->typeid != $object->typeid))) // If email has changed or if list has changed we delete mailman subscription for old email - { - if ($object->oldcopy->del_to_abo() < 0) - { + if (($object->oldcopy->email != $object->email) || ($object->oldcopy->typeid != $object->typeid)) { + if (is_object($object->oldcopy) && (($object->oldcopy->email != $object->email) || ($object->oldcopy->typeid != $object->typeid))) { // If email has changed or if list has changed we delete mailman subscription for old email + if ($object->oldcopy->del_to_abo() < 0) { $this->errors = $object->oldcopy->errors; if (!empty($object->oldcopy->error)) $this->errors[] = $object->oldcopy->error; $return = -1; - } else { + } else { $return = 1; - } + } } // We add subscription if new email or new type (new type may means more mailing-list to subscribe) - if ($object->add_to_abo() < 0) - { + if ($object->add_to_abo() < 0) { $this->errors = $object->errors; if (!empty($object->error)) $this->errors[] = $object->error; $return = -1; @@ -140,14 +132,12 @@ class InterfaceMailmanSpipsynchro extends DolibarrTriggers } return $return; - } elseif ($action == 'MEMBER_RESILIATE' || $action == 'MEMBER_DELETE') - { + } elseif ($action == 'MEMBER_RESILIATE' || $action == 'MEMBER_DELETE') { dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); $return = 0; // Remove from external tools (mailman, spip, etc...) - if ($object->del_to_abo() < 0) - { + if ($object->del_to_abo() < 0) { $this->errors = $object->errors; if (!empty($object->error)) $this->errors[] = $object->error; $return = -1; diff --git a/htdocs/core/triggers/interface_50_modNotification_Notification.class.php b/htdocs/core/triggers/interface_50_modNotification_Notification.class.php index a7157ea866a..a0b5638dbca 100644 --- a/htdocs/core/triggers/interface_50_modNotification_Notification.class.php +++ b/htdocs/core/triggers/interface_50_modNotification_Notification.class.php @@ -30,20 +30,6 @@ require_once DOL_DOCUMENT_ROOT.'/core/triggers/dolibarrtriggers.class.php'; */ class InterfaceNotification extends DolibarrTriggers { - public $family = 'notification'; - public $description = "Triggers of this module send email notifications according to Notification module setup."; - - /** - * Version of the trigger - * @var string - */ - public $version = self::VERSION_DOLIBARR; - - /** - * @var string Image of the trigger - */ - public $picto = 'email'; - // @todo Defined also into notify.class.php) public $listofmanagedevents = array( 'BILL_VALIDATE', @@ -63,6 +49,23 @@ class InterfaceNotification extends DolibarrTriggers 'HOLIDAY_APPROVE' ); + /** + * Constructor + * + * @param DoliDB $db Database handler + */ + public function __construct($db) + { + $this->db = $db; + + $this->name = preg_replace('/^Interface/i', '', get_class($this)); + $this->family = "notification"; + $this->description = "Triggers of this module send email notifications according to Notification module setup."; + // 'development', 'experimental', 'dolibarr' or version + $this->version = self::VERSION_DOLIBARR; + $this->picto = 'email'; + } + /** * Function called when a Dolibarrr business event is done. * All functions "runTrigger" are triggered if file is inside directory htdocs/core/triggers or htdocs/module/code/triggers (and declared) @@ -107,20 +110,17 @@ class InterfaceNotification extends DolibarrTriggers $sql .= $this->db->order("rang, elementtype, code"); dol_syslog("getListOfManagedEvents Get list of notifications", LOG_DEBUG); $resql = $this->db->query($sql); - if ($resql) - { + if ($resql) { $num = $this->db->num_rows($resql); $i = 0; - while ($i < $num) - { + while ($i < $num) { $obj = $this->db->fetch_object($resql); $qualified = 0; // Check is this event is supported by notification module if (in_array($obj->code, $this->listofmanagedevents)) $qualified = 1; // Check if module for this event is active - if ($qualified) - { + if ($qualified) { //print 'xx'.$obj->code; $element = $obj->elementtype; @@ -133,8 +133,7 @@ class InterfaceNotification extends DolibarrTriggers elseif (!in_array($element, array('order_supplier', 'invoice_supplier', 'withdraw', 'shipping', 'member', 'expensereport')) && empty($conf->$element->enabled)) $qualified = 0; } - if ($qualified) - { + if ($qualified) { $ret[] = array('rowid'=>$obj->rowid, 'code'=>$obj->code, 'label'=>$obj->label, 'description'=>$obj->description, 'elementtype'=>$obj->elementtype); } diff --git a/htdocs/core/triggers/interface_50_modTicket_TicketEmail.class.php b/htdocs/core/triggers/interface_50_modTicket_TicketEmail.class.php index d541f2e82d0..3743d044e44 100644 --- a/htdocs/core/triggers/interface_50_modTicket_TicketEmail.class.php +++ b/htdocs/core/triggers/interface_50_modTicket_TicketEmail.class.php @@ -30,11 +30,6 @@ require_once DOL_DOCUMENT_ROOT.'/core/triggers/dolibarrtriggers.class.php'; */ class InterfaceTicketEmail extends DolibarrTriggers { - /** - * @var DoliDB Database handler. - */ - public $db; - /** * Constructor * @@ -47,53 +42,10 @@ class InterfaceTicketEmail extends DolibarrTriggers $this->name = preg_replace('/^Interface/i', '', get_class($this)); $this->family = "ticket"; $this->description = "Triggers of the module ticket to send notifications to internal users and to third-parties"; - $this->version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' or version + $this->version = self::VERSION_DOLIBARR; // 'development', 'experimental', 'dolibarr' or version $this->picto = 'ticket'; } - /** - * Return name of trigger file - * - * @return string Name of trigger file - */ - public function getName() - { - return $this->name; - } - - /** - * Return description of trigger file - * - * @return string Description of trigger file - */ - public function getDesc() - { - return $this->description; - } - - /** - * Return version of trigger file - * - * @return string Version of trigger file - */ - public function getVersion() - { - global $langs; - $langs->load("admin"); - - if ($this->version == 'development') { - return $langs->trans("Development"); - } elseif ($this->version == 'experimental') { - return $langs->trans("Experimental"); - } elseif ($this->version == 'dolibarr') { - return DOL_VERSION; - } elseif ($this->version) { - return $this->version; - } else { - return $langs->trans("Unknown"); - } - } - /** * Function called when a Dolibarrr business event is done. * All functions "runTrigger" are triggered if file is inside directory htdocs/core/triggers @@ -115,16 +67,13 @@ class InterfaceTicketEmail extends DolibarrTriggers case 'TICKET_ASSIGNED': dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); - if ($object->fk_user_assign > 0 && $object->fk_user_assign != $user->id) - { + if ($object->fk_user_assign > 0 && $object->fk_user_assign != $user->id) { $userstat = new User($this->db); $res = $userstat->fetch($object->fk_user_assign); - if ($res > 0) - { + if ($res > 0) { // Send email to notification email - if (empty($conf->global->TICKET_DISABLE_ALL_MAILS)) - { + if (empty($conf->global->TICKET_DISABLE_ALL_MAILS)) { // Init to avoid errors $filepath = array(); $filename = array(); @@ -184,10 +133,8 @@ class InterfaceTicketEmail extends DolibarrTriggers // Send email to notification email $sendto = $conf->global->TICKET_NOTIFICATION_EMAIL_TO; - if (!empty($conf->global->TICKET_NOTIFICATION_EMAIL_TO) && empty($object->context['disableticketemail'])) - { - if ($sendto) - { + if (!empty($conf->global->TICKET_NOTIFICATION_EMAIL_TO) && empty($object->context['disableticketemail'])) { + if ($sendto) { // Init to avoid errors $filepath = array(); $filename = array(); @@ -248,8 +195,7 @@ class InterfaceTicketEmail extends DolibarrTriggers // Send email to customer - if (empty($conf->global->TICKET_DISABLE_CUSTOMER_MAILS) && empty($object->context['disableticketemail']) && $object->notify_tiers_at_create) - { + if (empty($conf->global->TICKET_DISABLE_CUSTOMER_MAILS) && empty($object->context['disableticketemail']) && $object->notify_tiers_at_create) { $sendto = ''; if (empty($user->socid) && empty($user->email)) { $object->fetch_thirdparty(); @@ -272,16 +218,13 @@ class InterfaceTicketEmail extends DolibarrTriggers $message_customer .= '
  • '.$langs->trans('Severity').' : '.$langs->getLabelFromKey($this->db, 'TicketSeverityShort'.$object->severity_code, 'c_ticket_severity', 'code', 'label', $object->severity_code).'
  • '; // Extrafields - foreach ($this->attributes[$object->table_element]['label'] as $key => $value) - { + foreach ($this->attributes[$object->table_element]['label'] as $key => $value) { $enabled = 1; - if ($enabled && isset($this->attributes[$object->table_element]['list'][$key])) - { + if ($enabled && isset($this->attributes[$object->table_element]['list'][$key])) { $enabled = dol_eval($this->attributes[$object->table_element]['list'][$key], 1); } $perms = 1; - if ($perms && isset($this->attributes[$object->table_element]['perms'][$key])) - { + if ($perms && isset($this->attributes[$object->table_element]['perms'][$key])) { $perms = dol_eval($this->attributes[$object->table_element]['perms'][$key], 1); } diff --git a/htdocs/core/triggers/interface_80_modStripe_Stripe.class.php b/htdocs/core/triggers/interface_80_modStripe_Stripe.class.php index 49bfae82247..25b7f57b6a5 100644 --- a/htdocs/core/triggers/interface_80_modStripe_Stripe.class.php +++ b/htdocs/core/triggers/interface_80_modStripe_Stripe.class.php @@ -35,11 +35,6 @@ require_once DOL_DOCUMENT_ROOT.'/core/triggers/dolibarrtriggers.class.php'; */ class InterfaceStripe extends DolibarrTriggers { - /** - * @var DoliDB Database handler. - */ - public $db; - /** * Constructor * @@ -52,31 +47,10 @@ class InterfaceStripe extends DolibarrTriggers $this->name = preg_replace('/^Interface/i', '', get_class($this)); $this->family = 'stripe'; $this->description = "Triggers of the module Stripe"; - $this->version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' or version + $this->version = self::VERSION_DOLIBARR; // 'development', 'experimental', 'dolibarr' or version $this->picto = 'stripe'; } - /** - * Trigger name - * - * @return string Name of trigger file - */ - public function getName() - { - return $this->name; - } - - - /** - * Trigger description - * - * @return string Description of trigger file - */ - public function getDesc() - { - return $this->description; - } - /** * Function called when a Dolibarrr business event is done. * All functions "runTrigger" are triggered if file @@ -104,8 +78,7 @@ class InterfaceStripe extends DolibarrTriggers $service = 'StripeTest'; $servicestatus = 0; - if (!empty($conf->global->STRIPE_LIVE) && !GETPOST('forcesandbox', 'alpha')) - { + if (!empty($conf->global->STRIPE_LIVE) && !GETPOST('forcesandbox', 'alpha')) { $service = 'StripeLive'; $servicestatus = 1; } @@ -118,8 +91,7 @@ class InterfaceStripe extends DolibarrTriggers if ($object->client != 0) { $customer = $stripe->customerStripe($object, $stripeacc, $servicestatus); // This make a network request - if ($customer) - { + if ($customer) { $namecleaned = $object->name ? $object->name : null; $vatcleaned = $object->tva_intra ? $object->tva_intra : null; // Example of valid numbers are 'FR12345678901' or 'FR12345678902' $desccleaned = $object->name_alias ? $object->name_alias : null; @@ -147,15 +119,13 @@ class InterfaceStripe extends DolibarrTriggers if ($desccleaned != $customer->description) $changerequested++; if (($customer->tax_exempt == 'exempt' && !$object->tva_assuj) || (!$customer->tax_exempt == 'exempt' && empty($object->tva_assuj))) $changerequested++; if (!isset($customer->tax_ids['data']) && !is_null($vatcleaned)) $changerequested++; - elseif (isset($customer->tax_ids['data'])) - { + elseif (isset($customer->tax_ids['data'])) { $taxinfo = reset($customer->tax_ids['data']); if (empty($taxinfo) && !empty($vatcleaned)) $changerequested++; if (isset($taxinfo->value) && $vatcleaned != $taxinfo->value) $changerequested++; } - if ($changerequested) - { + if ($changerequested) { /*if (! empty($object->email)) $customer->email = $object->email; $customer->description = $namecleaned; if (empty($taxinfo)) $customer->tax_info = array('type'=>'vat', 'tax_id'=>null); @@ -167,22 +137,17 @@ class InterfaceStripe extends DolibarrTriggers try { // Update Tax info on Stripe - if (!empty($conf->global->STRIPE_SAVE_TAX_IDS)) // We setup to save Tax info on Stripe side. Warning: This may result in error when saving customer - { - if (!empty($vatcleaned)) - { + if (!empty($conf->global->STRIPE_SAVE_TAX_IDS)) { // We setup to save Tax info on Stripe side. Warning: This may result in error when saving customer + if (!empty($vatcleaned)) { $isineec = isInEEC($object); - if ($object->country_code && $isineec) - { + if ($object->country_code && $isineec) { //$taxids = $customer->allTaxIds($customer->id); $customer->createTaxId($customer->id, array('type'=>'eu_vat', 'value'=>$vatcleaned)); } } else { $taxids = $customer->allTaxIds($customer->id); - if (is_array($taxids->data)) - { - foreach ($taxids->data as $taxidobj) - { + if (is_array($taxids->data)) { + foreach ($taxids->data as $taxidobj) { $customer->deleteTaxId($customer->id, $taxidobj->id); } } @@ -191,8 +156,7 @@ class InterfaceStripe extends DolibarrTriggers // Update Customer on Stripe $customer->save(); - } catch (Exception $e) - { + } catch (Exception $e) { //var_dump(\Stripe\Stripe::getApiVersion()); $this->errors[] = $e->getMessage(); $ok = -1; @@ -209,12 +173,10 @@ class InterfaceStripe extends DolibarrTriggers $stripeacc = $stripe->getStripeAccount($service); // No need of network access for this. May return '' if no Oauth defined. $customer = $stripe->customerStripe($object, $stripeacc, $servicestatus); - if ($customer) - { + if ($customer) { try { $customer->delete(); - } catch (Exception $e) - { + } catch (Exception $e) { dol_syslog("Failed to delete Stripe customer ".$e->getMessage(), LOG_WARNING); } } @@ -232,13 +194,11 @@ class InterfaceStripe extends DolibarrTriggers if ($action == 'COMPANYPAYMENTMODE_MODIFY' && $object->type == 'card') { dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); - if (!empty($object->stripe_card_ref)) - { + if (!empty($object->stripe_card_ref)) { $stripeacc = $stripe->getStripeAccount($service); // No need of network access for this. May return '' if no Oauth defined. $stripecu = $stripe->getStripeCustomerAccount($object->fk_soc); // No need of network access for this - if ($stripecu) - { + if ($stripecu) { // Get customer (required to get a card) if (empty($stripeacc)) { // If the Stripe connect account not set, we use common API usage $customer = \Stripe\Customer::retrieve($stripecu); @@ -246,15 +206,13 @@ class InterfaceStripe extends DolibarrTriggers $customer = \Stripe\Customer::retrieve($stripecu, array("stripe_account" => $stripeacc)); } - if ($customer) - { + if ($customer) { $card = $stripe->cardStripe($customer, $object, $stripeacc, $servicestatus); if ($card) { $card->metadata = array('dol_id'=>$object->id, 'dol_version'=>DOL_VERSION, 'dol_entity'=>$conf->entity, 'ipaddress'=>(empty($_SERVER['REMOTE_ADDR']) ? '' : $_SERVER['REMOTE_ADDR'])); try { $card->save(); - } catch (Exception $e) - { + } catch (Exception $e) { $ok = -1; $this->error = $e->getMessages(); } @@ -266,13 +224,11 @@ class InterfaceStripe extends DolibarrTriggers if ($action == 'COMPANYPAYMENTMODE_DELETE' && $object->type == 'card') { dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); - if (!empty($object->stripe_card_ref)) - { + if (!empty($object->stripe_card_ref)) { $stripeacc = $stripe->getStripeAccount($service); // No need of network access for this. May return '' if no Oauth defined. $stripecu = $stripe->getStripeCustomerAccount($object->fk_soc); // No need of network access for this - if ($stripecu) - { + if ($stripecu) { // Get customer (required to get a card) if (empty($stripeacc)) { // If the Stripe connect account not set, we use common API usage $customer = \Stripe\Customer::retrieve($stripecu); @@ -280,8 +236,7 @@ class InterfaceStripe extends DolibarrTriggers $customer = \Stripe\Customer::retrieve($stripecu, array("stripe_account" => $stripeacc)); } - if ($customer) - { + if ($customer) { $card = $stripe->cardStripe($customer, $object, $stripeacc, $servicestatus); if ($card) { if (method_exists($card, 'detach')) $card->detach(); diff --git a/htdocs/core/triggers/interface_90_modSociete_ContactRoles.class.php b/htdocs/core/triggers/interface_90_modSociete_ContactRoles.class.php index b51fd0a20b7..46cb7c56f17 100644 --- a/htdocs/core/triggers/interface_90_modSociete_ContactRoles.class.php +++ b/htdocs/core/triggers/interface_90_modSociete_ContactRoles.class.php @@ -33,23 +33,22 @@ require_once DOL_DOCUMENT_ROOT.'/core/triggers/dolibarrtriggers.class.php'; */ class InterfaceContactRoles extends DolibarrTriggers { + /** + * Constructor + * + * @param DoliDB $db Database handler + */ + public function __construct($db) + { + $this->db = $db; - public $family = 'agenda'; - - public $description = "Triggers of this module auto link contact to company."; - - /** - * Version of the trigger - * - * @var string - */ - public $version = self::VERSION_DOLIBARR; - - /** - * - * @var string Image of the trigger - */ - public $picto = 'action'; + $this->name = preg_replace('/^Interface/i', '', get_class($this)); + $this->family = "agenda"; + $this->description = "Triggers of this module auto link contact to company."; + // 'development', 'experimental', 'dolibarr' or version + $this->version = self::VERSION_DOLIBARR; + $this->picto = 'action'; + } /** * Function called when a Dolibarrr business event is done. diff --git a/htdocs/core/triggers/interface_99_modZapier_ZapierTriggers.class.php b/htdocs/core/triggers/interface_99_modZapier_ZapierTriggers.class.php index 62d84295915..95595863cb3 100644 --- a/htdocs/core/triggers/interface_99_modZapier_ZapierTriggers.class.php +++ b/htdocs/core/triggers/interface_99_modZapier_ZapierTriggers.class.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2017-2020 Frédéric France * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -39,11 +39,6 @@ require_once DOL_DOCUMENT_ROOT.'/core/triggers/dolibarrtriggers.class.php'; */ class InterfaceZapierTriggers extends DolibarrTriggers { - /** - * @var DoliDB Database handler - */ - protected $db; - /** * Constructor * @@ -57,31 +52,10 @@ class InterfaceZapierTriggers extends DolibarrTriggers $this->family = "technic"; $this->description = "Zapier triggers."; // 'development', 'experimental', 'dolibarr' or version - $this->version = 'development'; + $this->version = self::VERSION_DEVELOPMENT; $this->picto = 'zapier'; } - /** - * Trigger name - * - * @return string Name of trigger file - */ - public function getName() - { - return $this->name; - } - - /** - * Trigger description - * - * @return string Description of trigger file - */ - public function getDesc() - { - return $this->description; - } - - /** * Function called when a Dolibarrr business event is done. * All functions "runTrigger" are triggered if file @@ -96,7 +70,6 @@ class InterfaceZapierTriggers extends DolibarrTriggers */ public function runTrigger($action, $object, User $user, Translate $langs, Conf $conf) { - global $db; if (empty($conf->zapier->enabled)) { // Module not active, we do nothing return 0; @@ -403,7 +376,7 @@ function cleanObjectDatas($toclean) // Remove $db object property for object unset($toclean->db); - // Remove linkedObjects. We should already have linkedObjectIds that avoid huge responses + // Remove linkedObjects. We should already have linkedObjectsIds that avoid huge responses unset($toclean->linkedObjects); unset($toclean->lines); // should be ->lines diff --git a/htdocs/cron/admin/cron.php b/htdocs/cron/admin/cron.php index 5f87e640bce..8c2d42adfaa 100644 --- a/htdocs/cron/admin/cron.php +++ b/htdocs/cron/admin/cron.php @@ -105,7 +105,7 @@ print ''; print ''; -dol_fiche_end(); +print dol_get_fiche_end(); print '
    '; print ''; diff --git a/htdocs/cron/card.php b/htdocs/cron/card.php index bdb776a7100..dbe159f32d3 100644 --- a/htdocs/cron/card.php +++ b/htdocs/cron/card.php @@ -510,7 +510,7 @@ if (($action == "create") || ($action == "edit")) print ''; - dol_fiche_end(); + print dol_get_fiche_end(); print '
    '; print ''; @@ -693,7 +693,7 @@ if (($action == "create") || ($action == "edit")) print ''; print '
    '; - dol_fiche_end(); + print dol_get_fiche_end(); print "\n\n
    \n"; diff --git a/htdocs/datapolicy/admin/setup.php b/htdocs/datapolicy/admin/setup.php index f8c38bf5b6b..2d89bb09e3a 100644 --- a/htdocs/datapolicy/admin/setup.php +++ b/htdocs/datapolicy/admin/setup.php @@ -164,7 +164,7 @@ if ($action == 'edit') // Page end -dol_fiche_end(); +print dol_get_fiche_end(); llxFooter(); $db->close(); diff --git a/htdocs/datapolicy/admin/setupmail.php b/htdocs/datapolicy/admin/setupmail.php index 241dd9dace5..7076608898e 100644 --- a/htdocs/datapolicy/admin/setupmail.php +++ b/htdocs/datapolicy/admin/setupmail.php @@ -153,7 +153,7 @@ print '
    '; -dol_fiche_end(); +print dol_get_fiche_end(); print '

    '; diff --git a/htdocs/datapolicy/class/datapolicy.class.php b/htdocs/datapolicy/class/datapolicy.class.php index ff9abcf5dce..24490b9fb19 100644 --- a/htdocs/datapolicy/class/datapolicy.class.php +++ b/htdocs/datapolicy/class/datapolicy.class.php @@ -152,7 +152,7 @@ class DataPolicy * @param mixed $contact Contact * @return void */ - public function sendMailDataPolicyContact($contact) + public static function sendMailDataPolicyContact($contact) { global $langs, $conf, $db, $user; @@ -167,6 +167,7 @@ class DataPolicy } else { $l = $langs->defaultlang; } + // TODO Use a dolibarr email template $s = "DATAPOLICIESSUBJECT_".$l; $ma = "DATAPOLICIESCONTENT_".$l; $la = 'TXTLINKDATAPOLICIESACCEPT_'.$l; @@ -226,7 +227,7 @@ class DataPolicy * @param Societe $societe Object societe * @return void */ - public function sendMailDataPolicyCompany($societe) + public static function sendMailDataPolicyCompany($societe) { global $langs, $conf, $db, $user; @@ -242,6 +243,7 @@ class DataPolicy } else { $l = $langs->defaultlang; } + // TODO Use a dolibarr email template $s = "DATAPOLICIESSUBJECT_".$l; $ma = "DATAPOLICIESCONTENT_".$l; $la = 'TXTLINKDATAPOLICIESACCEPT_'.$l; @@ -264,10 +266,8 @@ class DataPolicy $actiontypecode = 'AC_EMAIL'; $actionmsg = $langs->transnoentities('MailSentBy').' '.$from.' '.$langs->transnoentities('To').' '.$sendto; - if ($message) - { - if ($sendtocc) - { + if ($message) { + if ($sendtocc) { $actionmsg .= dol_concatdesc($actionmsg, $langs->transnoentities('Bcc').": ".$sendtocc); } $actionmsg .= dol_concatdesc($actionmsg, $langs->transnoentities('MailTopic').": ".$subject); @@ -300,7 +300,7 @@ class DataPolicy * @param Adherent $adherent Member * @return void */ - public function sendMailDataPolicyAdherent($adherent) + public static function sendMailDataPolicyAdherent($adherent) { global $langs, $conf, $db, $user; @@ -310,9 +310,6 @@ class DataPolicy $sendto = $adherent->email; - // TODO Use a dolibarr email template - $s = 'TXTLINKDATAPOLICIESSUBJECT_'.$l; - $ma = 'TXTLINKDATAPOLICIESMESSAGE_'.$l; $code = md5($adherent->email); if (!empty($adherent->default_lang)) { @@ -320,6 +317,9 @@ class DataPolicy } else { $l = $langs->defaultlang; } + // TODO Use a dolibarr email template + $s = 'TXTLINKDATAPOLICIESSUBJECT_'.$l; + $ma = 'TXTLINKDATAPOLICIESMESSAGE_'.$l; $la = 'TXTLINKDATAPOLICIESACCEPT_'.$l; $lr = 'TXTLINKDATAPOLICIESREFUSE_'.$l; diff --git a/htdocs/delivery/card.php b/htdocs/delivery/card.php index 3510fd2a4f2..65172c88372 100644 --- a/htdocs/delivery/card.php +++ b/htdocs/delivery/card.php @@ -74,6 +74,8 @@ include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be includ // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $hookmanager->initHooks(array('deliverycard', 'globalcard')); +$error = 0; + /* * Actions @@ -86,19 +88,17 @@ if ($action == 'add') { $db->begin(); - $object->date_livraison = time(); - $object->note = GETPOST("note", 'restricthtml'); - $object->note_private = GETPOST("note", 'restricthtml'); - $object->commande_id = GETPOST("commande_id", 'int'); + $object->date_delivery = dol_now(); + $object->note = GETPOST("note", 'restricthtml'); + $object->note_private = GETPOST("note", 'restricthtml'); + $object->commande_id = GETPOST("commande_id", 'int'); $object->fk_incoterms = GETPOST('incoterm_id', 'int'); - if (!$conf->expedition_bon->enabled && !empty($conf->stock->enabled)) - { + if (!$conf->expedition_bon->enabled && !empty($conf->stock->enabled)) { $expedition->entrepot_id = GETPOST('entrepot_id'); } - // On boucle sur chaque ligne de commande pour completer objet livraison - // avec qte a livrer + // We loop on each line of order to complete object delivery with qty to delivery $commande = new Commande($db); $commande->fetch($object->commande_id); $commande->fetch_lines(); @@ -107,15 +107,15 @@ if ($action == 'add') { $qty = "qtyl".$i; $idl = "idl".$i; - if ($_POST[$qty] > 0) + $qtytouse = price2num(GETPOST($qty)); + if ($qtytouse > 0) { - $object->addline($_POST[$idl], $_POST[$qty]); + $object->addline(GETPOST($idl), price2num($qtytouse)); } } $ret = $object->create($user); - if ($ret > 0) - { + if ($ret > 0) { $db->commit(); header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); exit; @@ -123,7 +123,6 @@ if ($action == 'add') setEventMessages($object->error, $object->errors, 'errors'); $db->rollback(); - $_GET["commande_id"] = $_POST["commande_id"]; $action = 'create'; } } elseif ($action == 'confirm_valid' && $confirm == 'yes' && @@ -168,10 +167,10 @@ if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->expeditio } } -if ($action == 'setdate_livraison' && $user->rights->expedition->delivery->creer) +if ($action == 'setdate_delivery' && $user->rights->expedition->delivery->creer) { $datedelivery = dol_mktime(GETPOST('liv_hour', 'int'), GETPOST('liv_min', 'int'), 0, GETPOST('liv_month', 'int'), GETPOST('liv_day', 'int'), GETPOST('liv_year', 'int')); - $result = $object->set_delivery_date($user, $datedelivery); + $result = $object->setDeliveryDate($user, $datedelivery); if ($result < 0) { $mesg = '
    '.$object->error.'
    '; @@ -181,7 +180,7 @@ if ($action == 'setdate_livraison' && $user->rights->expedition->delivery->creer // Set incoterm elseif ($action == 'set_incoterms' && !empty($conf->incoterm->enabled)) { - $result = $object->setIncoterms(GETPOST('incoterm_id', 'int'), GETPOST('location_incoterms', 'alpha')); + $result = $object->setIncoterms((int) GETPOST('incoterm_id', 'int'), GETPOST('location_incoterms', 'alpha')); } // Update extrafields @@ -434,15 +433,15 @@ if ($action == 'create') // Create. Seems to no be used print $langs->trans('DateReceived'); print ''; - if ($action != 'editdate_livraison') print 'id.'">'.img_edit($langs->trans('SetDeliveryDate'), 1).''; + if ($action != 'editdate_delivery') print 'id.'">'.img_edit($langs->trans('SetDeliveryDate'), 1).''; print ''; print ''; - if ($action == 'editdate_livraison') + if ($action == 'editdate_delivery') { - print ''; + print ''; print ''; - print ''; - print $form->selectDate($object->date_delivery ? $object->date_delivery : -1, 'liv_', 1, 1, '', "setdate_livraison", 1, 1); + print ''; + print $form->selectDate($object->date_delivery ? $object->date_delivery : -1, 'liv_', 1, 1, '', "setdate_delivery", 1, 1); print ''; print ''; } else { @@ -629,7 +628,7 @@ if ($action == 'create') // Create. Seems to no be used print "\n"; - dol_fiche_end(); + print dol_get_fiche_end(); //if ($object->statut == 0) // only if draft // print '
    '; diff --git a/htdocs/delivery/class/delivery.class.php b/htdocs/delivery/class/delivery.class.php index bd6ef948c6c..4d498d70357 100644 --- a/htdocs/delivery/class/delivery.class.php +++ b/htdocs/delivery/class/delivery.class.php @@ -67,8 +67,19 @@ class Delivery extends CommonObject */ public $picto = 'sending'; - public $draft; - public $socid; + /** + * @var int draft status + */ + public $draft; + + /** + * @var int thirdparty id + */ + public $socid; + + /** + * @var string ref custome + */ public $ref_customer; /** @@ -86,7 +97,9 @@ class Delivery extends CommonObject */ public $date_valid; - + /** + * @var string model pdf + */ public $model_pdf; @@ -529,13 +542,12 @@ class Delivery extends CommonObject $num = count($expedition->lines); for ($i = 0; $i < $num; $i++) { - $line = new DeliveryLigne($this->db); + $line = new DeliveryLine($this->db); $line->origin_line_id = $expedition->lines[$i]->origin_line_id; - $line->libelle = $expedition->lines[$i]->libelle; + $line->label = $expedition->lines[$i]->label; $line->description = $expedition->lines[$i]->description; $line->qty = $expedition->lines[$i]->qty_shipped; $line->fk_product = $expedition->lines[$i]->fk_product; - $line->ref = $expedition->lines[$i]->ref; $this->lines[$i] = $line; } @@ -548,7 +560,7 @@ class Delivery extends CommonObject $this->date_delivery = $expedition->date_delivery; $this->fk_delivery_address = $expedition->fk_delivery_address; $this->socid = $expedition->socid; - $this->ref_customer = $expedition->ref_customer; + $this->ref_customer = $expedition->ref_customer; //Incoterms $this->fk_incoterms = $expedition->fk_incoterms; @@ -573,7 +585,7 @@ class Delivery extends CommonObject if ($id > 0 && !$error && empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && is_array($array_options) && count($array_options) > 0) // For avoid conflicts if trigger used { - $line = new DeliveryLigne($this->db); + $line = new DeliveryLine($this->db); $line->array_options = $array_options; $line->id = $id; $result = $line->insertExtraFields(); @@ -600,7 +612,7 @@ class Delivery extends CommonObject public function addline($origin_id, $qty) { $num = count($this->lines); - $line = new DeliveryLigne($this->db); + $line = new DeliveryLine($this->db); $line->origin_id = $origin_id; $line->qty = $qty; @@ -776,7 +788,7 @@ class Delivery extends CommonObject $i = 0; while ($i < $num) { - $line = new DeliveryLigne($this->db); + $line = new DeliveryLine($this->db); $obj = $this->db->fetch_object($resql); @@ -914,7 +926,7 @@ class Delivery extends CommonObject $this->note_private = 'Private note'; $i = 0; - $line = new DeliveryLigne($this->db); + $line = new DeliveryLine($this->db); $line->fk_product = $prodids[0]; $line->qty_asked = 10; $line->qty_shipped = 9; @@ -939,11 +951,11 @@ class Delivery extends CommonObject // Get the linked object $this->fetchObjectLinked('', '', $this->id, $this->element); - //var_dump($this->linkedObjectIds); + //var_dump($this->linkedObjectsIds); // Get the product ref and qty in source $sqlSourceLine = "SELECT st.rowid, st.description, st.qty"; $sqlSourceLine .= ", p.ref, p.label"; - $sqlSourceLine .= " FROM ".MAIN_DB_PREFIX.$this->linkedObjectIds[0]['type']."det as st"; + $sqlSourceLine .= " FROM ".MAIN_DB_PREFIX.$this->linkedObjectsIds[0]['type']."det as st"; $sqlSourceLine .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON st.fk_product = p.rowid"; $sqlSourceLine .= " WHERE fk_".$this->linked_object[0]['type']." = ".$this->linked_object[0]['linkid']; @@ -999,24 +1011,22 @@ class Delivery extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** + /** * Set the planned delivery date * * @param User $user Objet utilisateur qui modifie * @param integer $delivery_date Delivery date * @return int <0 if KO, >0 if OK */ - public function set_delivery_date($user, $delivery_date) + public function setDeliveryDate($user, $delivery_date) { - // phpcs:enable if ($user->rights->expedition->creer) { $sql = "UPDATE ".MAIN_DB_PREFIX."delivery"; $sql .= " SET date_delivery = ".($delivery_date ? "'".$this->db->idate($delivery_date)."'" : 'null'); $sql .= " WHERE rowid = ".$this->id; - dol_syslog(get_class($this)."::set_delivery_date", LOG_DEBUG); + dol_syslog(get_class($this)."::setDeliveryDate", LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) { @@ -1086,13 +1096,23 @@ class Delivery extends CommonObject /** * Management class of delivery note lines */ -class DeliveryLigne extends CommonObjectLine +class DeliveryLine extends CommonObjectLine { /** * @var DoliDB Database handler. */ public $db; + /** + * @var string ID to identify managed object + */ + public $element = 'deliverydet'; + + /** + * @var string Name of table without prefix where object is stored + */ + public $table_element = 'deliverydet'; + // From llx_expeditiondet public $qty; public $qty_asked; @@ -1122,19 +1142,11 @@ class DeliveryLigne extends CommonObjectLine */ public $libelle; + public $origin_line_id; + public $product_ref; public $product_label; - /** - * @var string ID to identify managed object - */ - public $element = 'deliverydet'; - - /** - * @var string Name of table without prefix where object is stored - */ - public $table_element = 'deliverydet'; - /** * Constructor * diff --git a/htdocs/don/admin/donation_extrafields.php b/htdocs/don/admin/donation_extrafields.php index d210f4399bc..6062d4fca26 100644 --- a/htdocs/don/admin/donation_extrafields.php +++ b/htdocs/don/admin/donation_extrafields.php @@ -70,7 +70,7 @@ print dol_get_fiche_head($head, 'attributes', $langs->trans("Donations"), -1, 'p require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php'; -dol_fiche_end(); +print dol_get_fiche_end(); // Buttons diff --git a/htdocs/don/card.php b/htdocs/don/card.php index 48af083a5fb..51252e480da 100644 --- a/htdocs/don/card.php +++ b/htdocs/don/card.php @@ -452,7 +452,7 @@ if ($action == 'create') print ''; print "\n"; - dol_fiche_end(); + print dol_get_fiche_end(); print '
    '; print ''; @@ -583,7 +583,7 @@ if (!empty($id) && $action == 'edit') print "\n"; - dol_fiche_end(); + print dol_get_fiche_end(); print '
       
    '; @@ -775,7 +775,7 @@ if (!empty($id) && $action != 'edit') print '
    '; - dol_fiche_end(); + print dol_get_fiche_end(); $remaintopay = $object->amount - $totalpaid; diff --git a/htdocs/don/class/don.class.php b/htdocs/don/class/don.class.php index b0e802ccc5e..8d5d22482b8 100644 --- a/htdocs/don/class/don.class.php +++ b/htdocs/don/class/don.class.php @@ -6,7 +6,7 @@ * Copyright (C) 2015-2017 Alexandre Spangaro * Copyright (C) 2016 Juanjo Menent * Copyright (C) 2019 Thibault FOUCART - * Copyright (C) 2019 Frédéric France + * Copyright (C) 2019-2020 Frédéric France * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -97,6 +97,10 @@ class Don extends CommonObject * @var string Email */ public $email; + + /** + * @var int 0 or 1 + */ public $public; /** @@ -111,7 +115,11 @@ class Don extends CommonObject public $num_payment; public $date_valid; - public $modepaymentid = 0; + + /** + * @var int payment mode id + */ + public $modepaymentid = 0; /** * @var array Array of status label @@ -230,7 +238,7 @@ class Don extends CommonObject $this->socid = 1; $this->date = $now; $this->date_valid = $now; - $this->amount = 100; + $this->amount = 100.90; $this->public = 1; $this->societe = 'The Company'; $this->address = 'Twist road'; @@ -239,7 +247,8 @@ class Don extends CommonObject $this->note_private = 'Private note'; $this->note_public = 'Public note'; $this->email = 'email@email.com'; - $this->note = ''; + $this->phone = '0123456789'; + $this->phone_mobile = '0606060606'; $this->statut = 1; } @@ -392,17 +401,17 @@ class Don extends CommonObject $sql .= ", '".$this->db->escape($this->address)."'"; $sql .= ", '".$this->db->escape($this->zip)."'"; $sql .= ", '".$this->db->escape($this->town)."'"; - $sql .= ", ".($this->country_id > 0 ? $this->country_id : '0'); - $sql .= ", ".((int) $this->public); - $sql .= ", ".($this->fk_project > 0 ? $this->fk_project : "null"); + $sql .= ", ".(int) ($this->country_id > 0 ? $this->country_id : 0); + $sql .= ", ".(int) $this->public; + $sql .= ", ".($this->fk_project > 0 ? (int) $this->fk_project : "null"); $sql .= ", ".(!empty($this->note_private) ? ("'".$this->db->escape($this->note_private)."'") : "NULL"); $sql .= ", ".(!empty($this->note_public) ? ("'".$this->db->escape($this->note_public)."'") : "NULL"); $sql .= ", ".$user->id; $sql .= ", null"; $sql .= ", '".$this->db->idate($this->date)."'"; - $sql .= ", '".$this->db->escape($this->email)."'"; - $sql .= ", '".$this->db->escape($this->phone)."'"; - $sql .= ", '".$this->db->escape($this->phone_mobile)."'"; + $sql .= ", '".$this->db->escape(trim($this->email))."'"; + $sql .= ", '".$this->db->escape(trim($this->phone))."'"; + $sql .= ", '".$this->db->escape(trim($this->phone_mobile))."'"; $sql .= ")"; $resql = $this->db->query($sql); @@ -426,13 +435,9 @@ class Don extends CommonObject // Update extrafield if (!$error) { - if (!$error) - { - $result = $this->insertExtraFields(); - if ($result < 0) - { - $error++; - } + $result = $this->insertExtraFields(); + if ($result < 0) { + $error++; } } @@ -490,9 +495,9 @@ class Don extends CommonObject $sql .= ",note_public=".(!empty($this->note_public) ? ("'".$this->db->escape($this->note_public)."'") : "NULL"); $sql .= ",datedon='".$this->db->idate($this->date)."'"; $sql .= ",date_valid=".($this->date_valid ? "'".$this->db->idate($this->date)."'" : "null"); - $sql .= ",email='".$this->db->escape($this->email)."'"; - $sql .= ",phone='".$this->db->escape($this->phone)."'"; - $sql .= ",phone_mobile='".$this->db->escape($this->phone_mobile)."'"; + $sql .= ",email='".$this->db->escape(trim($this->email))."'"; + $sql .= ",phone='".$this->db->escape(trim($this->phone))."'"; + $sql .= ",phone_mobile='".$this->db->escape(trim($this->phone_mobile))."'"; $sql .= ",fk_statut=".$this->statut; $sql .= " WHERE rowid = ".$this->id; @@ -511,13 +516,10 @@ class Don extends CommonObject // Update extrafield if (!$error) { - if (!$error) + $result = $this->insertExtraFields(); + if ($result < 0) { - $result = $this->insertExtraFields(); - if ($result < 0) - { - $error++; - } + $error++; } } @@ -555,18 +557,14 @@ class Don extends CommonObject $this->db->begin(); - if (!$error) - { - if (!$notrigger) - { - // Call trigger - $result = $this->call_trigger('DON_DELETE', $user); + if (!$error && !$notrigger) { + // Call trigger + $result = $this->call_trigger('DON_DELETE', $user); - if ($result < 0) { - $error++; - } - // End call triggers + if ($result < 0) { + $error++; } + // End call triggers } // Delete donation @@ -687,7 +685,7 @@ class Don extends CommonObject $this->note_private = $obj->note_private; $this->note_public = $obj->note_public; $this->model_pdf = $obj->model_pdf; - $this->modelpdf = $obj->model_pdf; // deprecated + $this->modelpdf = $obj->model_pdf; // deprecated // Retrieve all extrafield // fetch optionals attributes and labels diff --git a/htdocs/don/document.php b/htdocs/don/document.php index 4b7a7f052dc..4067c9a0500 100644 --- a/htdocs/don/document.php +++ b/htdocs/don/document.php @@ -179,7 +179,7 @@ if ($object->id) print '
    '; - dol_fiche_end(); + print dol_get_fiche_end(); $modulepart = 'don'; $permission = $user->rights->don->lire; diff --git a/htdocs/don/info.php b/htdocs/don/info.php index ead0f354646..f60b8380939 100644 --- a/htdocs/don/info.php +++ b/htdocs/don/info.php @@ -120,7 +120,7 @@ print ''; print '
    '; -dol_fiche_end(); +print dol_get_fiche_end(); llxFooter(); $db->close(); diff --git a/htdocs/don/note.php b/htdocs/don/note.php index ff25b704dd3..1e5e2667b31 100644 --- a/htdocs/don/note.php +++ b/htdocs/don/note.php @@ -131,7 +131,7 @@ if ($id > 0 || !empty($ref)) $cssclass = "titlefield"; include DOL_DOCUMENT_ROOT.'/core/tpl/notes.tpl.php'; - dol_fiche_end(); + print dol_get_fiche_end(); } llxFooter(); diff --git a/htdocs/don/payment/card.php b/htdocs/don/payment/card.php index 15146932055..fa97965ca4d 100644 --- a/htdocs/don/payment/card.php +++ b/htdocs/don/payment/card.php @@ -203,7 +203,7 @@ if ($resql) print '
    '; -dol_fiche_end(); +print dol_get_fiche_end(); /* diff --git a/htdocs/don/payment/payment.php b/htdocs/don/payment/payment.php index d8f373cbd37..e7985ded1ff 100644 --- a/htdocs/don/payment/payment.php +++ b/htdocs/don/payment/payment.php @@ -231,7 +231,7 @@ if ($action == 'create') print ''; - dol_fiche_end(); + print dol_get_fiche_end(); /* * List of payments on donation diff --git a/htdocs/don/stats/index.php b/htdocs/don/stats/index.php index 998de2b7793..eed3108c3db 100644 --- a/htdocs/don/stats/index.php +++ b/htdocs/don/stats/index.php @@ -296,7 +296,7 @@ print ''; print '
    '; print '
    '; -dol_fiche_end(); +print dol_get_fiche_end(); diff --git a/htdocs/ecm/class/ecmfiles.class.php b/htdocs/ecm/class/ecmfiles.class.php index b0c1df8316f..daa14aa365f 100644 --- a/htdocs/ecm/class/ecmfiles.class.php +++ b/htdocs/ecm/class/ecmfiles.class.php @@ -307,7 +307,7 @@ class EcmFiles extends CommonObject * @param string $relativepath Relative path of file from document directory. Example: 'path/path2/file' or 'path/path2/*' * @param string $hashoffile Hash of file content. Take the first one found if same file is at different places. This hash will also change if file content is changed. * @param string $hashforshare Hash of file sharing. - * @param string $src_object_type src_object_type to search + * @param string $src_object_type src_object_type to search (value of object->table_element) * @param string $src_object_id src_object_id to search * @return int <0 if KO, 0 if not found, >0 if OK */ diff --git a/htdocs/ecm/dir_add_card.php b/htdocs/ecm/dir_add_card.php index d63ef0397fe..53f02cede7a 100644 --- a/htdocs/ecm/dir_add_card.php +++ b/htdocs/ecm/dir_add_card.php @@ -251,7 +251,7 @@ if ($action == 'create') print ''; - dol_fiche_end(); + print dol_get_fiche_end(); print '
    '; print ''; diff --git a/htdocs/ecm/dir_card.php b/htdocs/ecm/dir_card.php index 9a084da6cc9..8c1c0162692 100644 --- a/htdocs/ecm/dir_card.php +++ b/htdocs/ecm/dir_card.php @@ -448,7 +448,7 @@ if ($action == 'edit') print ''; } -dol_fiche_end(); +print dol_get_fiche_end(); diff --git a/htdocs/ecm/file_card.php b/htdocs/ecm/file_card.php index 69cac4d1449..145e28c5e59 100644 --- a/htdocs/ecm/file_card.php +++ b/htdocs/ecm/file_card.php @@ -388,7 +388,7 @@ print '
    '; print ajax_autoselect('downloadinternallink'); print ajax_autoselect('downloadlink'); -dol_fiche_end(); +print dol_get_fiche_end(); if ($action == 'edit') { diff --git a/htdocs/ecm/index.php b/htdocs/ecm/index.php index eb65d9a997b..f1716c5020e 100644 --- a/htdocs/ecm/index.php +++ b/htdocs/ecm/index.php @@ -335,7 +335,7 @@ $module = 'ecm'; include DOL_DOCUMENT_ROOT.'/core/tpl/filemanager.tpl.php'; // End of page -dol_fiche_end(); +print dol_get_fiche_end(); llxFooter(); diff --git a/htdocs/ecm/index_auto.php b/htdocs/ecm/index_auto.php index f3708fbe6df..4ee3c1fcc82 100644 --- a/htdocs/ecm/index_auto.php +++ b/htdocs/ecm/index_auto.php @@ -466,7 +466,7 @@ if (!empty($conf->use_javascript_ajax) && empty($conf->global->MAIN_ECM_DISABLE_ } -dol_fiche_end(); +print dol_get_fiche_end(); llxFooter(); diff --git a/htdocs/expedition/card.php b/htdocs/expedition/card.php index a2e1c3a26db..77e25704a6b 100644 --- a/htdocs/expedition/card.php +++ b/htdocs/expedition/card.php @@ -479,7 +479,7 @@ if (empty($reshook)) $datedelivery = dol_mktime(GETPOST('liv_hour', 'int'), GETPOST('liv_min', 'int'), 0, GETPOST('liv_month', 'int'), GETPOST('liv_day', 'int'), GETPOST('liv_year', 'int')); $object->fetch($id); - $result = $object->set_delivery_date($user, $datedelivery); + $result = $object->setDeliveryDate($user, $datedelivery); if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); @@ -1030,7 +1030,7 @@ if ($action == 'create') print ""; - dol_fiche_end(); + print dol_get_fiche_end(); // Shipment lines @@ -2403,7 +2403,7 @@ if ($action == 'create') } - dol_fiche_end(); + print dol_get_fiche_end(); $object->fetchObjectLinked($object->id, $object->element); diff --git a/htdocs/expedition/class/expedition.class.php b/htdocs/expedition/class/expedition.class.php index ccc67a1c256..6ac3b4a5290 100644 --- a/htdocs/expedition/class/expedition.class.php +++ b/htdocs/expedition/class/expedition.class.php @@ -1957,24 +1957,37 @@ class Expedition extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** + * Set delivery date + * + * @param User $user Object user that modify + * @param int $delivery_date Delivery date + * @return int <0 if ko, >0 if ok + * @deprecated Use setDeliveryDate + */ + public function set_date_livraison($user, $delivery_date) + { + // phpcs:enable + return $this->setDeliveryDate($user, $delivery_date); + } + + /** * Set the planned delivery date * * @param User $user Objet user that modify * @param integer $delivery_date Date of delivery * @return int <0 if KO, >0 if OK */ - public function set_delivery_date($user, $delivery_date) + public function setDeliveryDate($user, $delivery_date) { - // phpcs:enable if ($user->rights->expedition->creer) { $sql = "UPDATE ".MAIN_DB_PREFIX."expedition"; $sql .= " SET date_delivery = ".($delivery_date ? "'".$this->db->idate($delivery_date)."'" : 'null'); $sql .= " WHERE rowid = ".$this->id; - dol_syslog(get_class($this)."::set_delivery_date", LOG_DEBUG); + dol_syslog(get_class($this)."::setDeliveryDate", LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) { diff --git a/htdocs/expedition/contact.php b/htdocs/expedition/contact.php index d2adaadf484..536f0a239ef 100644 --- a/htdocs/expedition/contact.php +++ b/htdocs/expedition/contact.php @@ -250,7 +250,7 @@ if ($id > 0 || !empty($ref)) print '
    '; - dol_fiche_end(); + print dol_get_fiche_end(); // Lines of contacts echo '
    '; diff --git a/htdocs/expedition/document.php b/htdocs/expedition/document.php index ede667279e6..fffad537b6e 100644 --- a/htdocs/expedition/document.php +++ b/htdocs/expedition/document.php @@ -169,7 +169,7 @@ if ($id > 0 || !empty($ref)) { print "\n"; - dol_fiche_end(); + print dol_get_fiche_end(); $modulepart = 'expedition'; $permission = $user->rights->expedition->creer; diff --git a/htdocs/expedition/note.php b/htdocs/expedition/note.php index 64aa415c4ce..71de26fa3cf 100644 --- a/htdocs/expedition/note.php +++ b/htdocs/expedition/note.php @@ -148,7 +148,7 @@ if ($id > 0 || !empty($ref)) $cssclass = 'titlefield'; include DOL_DOCUMENT_ROOT.'/core/tpl/notes.tpl.php'; - dol_fiche_end(); + print dol_get_fiche_end(); } // End of page diff --git a/htdocs/expedition/shipment.php b/htdocs/expedition/shipment.php index 31d6fcaed02..4d4dd365c5f 100644 --- a/htdocs/expedition/shipment.php +++ b/htdocs/expedition/shipment.php @@ -108,7 +108,7 @@ if (empty($reshook)) $datedelivery = dol_mktime(GETPOST('liv_hour', 'int'), GETPOST('liv_min', 'int'), 0, GETPOST('liv_month', 'int'), GETPOST('liv_day', 'int'), GETPOST('liv_year', 'int')); $object->fetch($id); - $result = $object->set_delivery_date($user, $datedelivery); + $result = $object->setDeliveryDate($user, $datedelivery); if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); diff --git a/htdocs/expedition/stats/index.php b/htdocs/expedition/stats/index.php index d500a97ab71..8fa04c27c25 100644 --- a/htdocs/expedition/stats/index.php +++ b/htdocs/expedition/stats/index.php @@ -305,7 +305,7 @@ print ''; print ''; print '
    '; -dol_fiche_end(); +print dol_get_fiche_end(); diff --git a/htdocs/expensereport/card.php b/htdocs/expensereport/card.php index c0896151284..63b2977336c 100644 --- a/htdocs/expensereport/card.php +++ b/htdocs/expensereport/card.php @@ -1483,7 +1483,7 @@ if ($action == 'create') print ''; print ''; - dol_fiche_end(); + print dol_get_fiche_end(); print '
    '; print ''; @@ -1616,7 +1616,7 @@ if ($action == 'create') print ''; - dol_fiche_end(); + print dol_get_fiche_end(); print '
    '; print ''; @@ -2543,7 +2543,7 @@ if ($action == 'create') print ''; - dol_fiche_end(); + print dol_get_fiche_end(); } // end edit or not edit } // end of if result else { diff --git a/htdocs/expensereport/class/expensereport.class.php b/htdocs/expensereport/class/expensereport.class.php index d91893223b0..d4dd0a9cb2e 100644 --- a/htdocs/expensereport/class/expensereport.class.php +++ b/htdocs/expensereport/class/expensereport.class.php @@ -1083,30 +1083,51 @@ class ExpenseReport extends CommonObject { global $user, $langs, $conf; - if (!$rowid) $rowid = $this->id; + $rowid = $this->id; - $sql = 'DELETE FROM '.MAIN_DB_PREFIX.$this->table_element_line.' WHERE '.$this->fk_element.' = '.$rowid; - if ($this->db->query($sql)) - { - $sql = 'DELETE FROM '.MAIN_DB_PREFIX.$this->table_element.' WHERE rowid = '.$rowid; - $resql = $this->db->query($sql); - if ($resql) - { - $this->db->commit(); - return 1; - } else { - $this->error = $this->db->error()." sql=".$sql; - dol_syslog(get_class($this)."::delete ".$this->error, LOG_ERR); - $this->db->rollback(); - return -6; - } - } else { - $this->error = $this->db->error()." sql=".$sql; - dol_syslog(get_class($this)."::delete ".$this->error, LOG_ERR); - $this->db->rollback(); - return -4; - } - } + $error = 0; + + // Delete lines + $sql = 'DELETE FROM '.MAIN_DB_PREFIX.$this->table_element_line.' WHERE '.$this->fk_element.' = '.$rowid; + if (!$error && !$this->db->query($sql)) + { + $this->error = $this->db->error()." sql=".$sql; + dol_syslog(get_class($this)."::delete ".$this->error, LOG_ERR); + $error++; + } + + // Delete llx_ecm_files + if (!$error) { + $sql = 'DELETE FROM '.MAIN_DB_PREFIX."ecm_files WHERE src_object_type = '".$this->db->escape($this->table_element.(empty($this->module) ? '' : '@'.$this->module))."' AND src_object_id = ".$this->id; + $resql = $this->db->query($sql); + if (!$resql) + { + $this->error = $this->db->lasterror(); + $this->errors[] = $this->error; + $error++; + } + } + + // Delete main record + if (!$error) { + $sql = 'DELETE FROM '.MAIN_DB_PREFIX.$this->table_element.' WHERE rowid = '.$rowid; + $resql = $this->db->query($sql); + if (!$resql) + { + $this->error = $this->db->error()." sql=".$sql; + dol_syslog(get_class($this)."::delete ".$this->error, LOG_ERR); + } + } + + // Commit or rollback + if ($error) { + $this->db->rollback(); + return -1; + } else { + $this->db->commit(); + return 1; + } + } /** * Set to status validate diff --git a/htdocs/expensereport/document.php b/htdocs/expensereport/document.php index 531140e1b2a..c61c55a04fd 100644 --- a/htdocs/expensereport/document.php +++ b/htdocs/expensereport/document.php @@ -142,7 +142,7 @@ if ($object->id) print '
    '; - dol_fiche_end(); + print dol_get_fiche_end(); $modulepart = 'expensereport'; diff --git a/htdocs/expensereport/info.php b/htdocs/expensereport/info.php index 00510e4e5fd..53d1531f4b9 100644 --- a/htdocs/expensereport/info.php +++ b/htdocs/expensereport/info.php @@ -98,7 +98,7 @@ if ($id > 0 || !empty($ref)) print '
    '; - dol_fiche_end(); + print dol_get_fiche_end(); } // End of page diff --git a/htdocs/expensereport/list.php b/htdocs/expensereport/list.php index 0186bd08103..574a0382fcb 100644 --- a/htdocs/expensereport/list.php +++ b/htdocs/expensereport/list.php @@ -345,7 +345,7 @@ if ($resql) dol_banner_tab($fuser, 'id', $linkback, $user->rights->user->user->lire || $user->admin); - dol_fiche_end(); + print dol_get_fiche_end(); if ($action != 'edit') { diff --git a/htdocs/expensereport/note.php b/htdocs/expensereport/note.php index 31667d74a4e..ebb66ce42fd 100644 --- a/htdocs/expensereport/note.php +++ b/htdocs/expensereport/note.php @@ -108,7 +108,7 @@ if ($id > 0 || !empty($ref)) print ''; - dol_fiche_end(); + print dol_get_fiche_end(); } // End of page diff --git a/htdocs/expensereport/payment/card.php b/htdocs/expensereport/payment/card.php index 4a5099cc03a..6662b1054f4 100644 --- a/htdocs/expensereport/payment/card.php +++ b/htdocs/expensereport/payment/card.php @@ -152,7 +152,7 @@ print ''; print ''; -dol_fiche_end(); +print dol_get_fiche_end(); /* diff --git a/htdocs/expensereport/payment/info.php b/htdocs/expensereport/payment/info.php index 281e760684d..a654c77b6cd 100644 --- a/htdocs/expensereport/payment/info.php +++ b/htdocs/expensereport/payment/info.php @@ -75,7 +75,7 @@ print ''; print ''; -dol_fiche_end(); +print dol_get_fiche_end(); // End of page llxFooter(); diff --git a/htdocs/expensereport/payment/payment.php b/htdocs/expensereport/payment/payment.php index 68c43a99ad1..19f979d0f16 100644 --- a/htdocs/expensereport/payment/payment.php +++ b/htdocs/expensereport/payment/payment.php @@ -80,11 +80,11 @@ if ($action == 'add_payment') setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Date")), null, 'errors'); $error++; } - if (!empty($conf->banque->enabled) && !($accountid > 0)) - { - setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("AccountToDebit")), null, 'errors'); - $error++; - } + if (!empty($conf->banque->enabled) && !($accountid > 0)) + { + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("AccountToDebit")), null, 'errors'); + $error++; + } if (!$error) { @@ -101,67 +101,67 @@ if ($action == 'add_payment') } } - if (count($amounts) <= 0) - { - $error++; - $errmsg = 'ErrorNoPaymentDefined'; - } + if (count($amounts) <= 0) + { + $error++; + $errmsg = 'ErrorNoPaymentDefined'; + } - if (!$error) - { - $db->begin(); + if (!$error) + { + $db->begin(); - // Create a line of payments - $payment = new PaymentExpenseReport($db); - $payment->fk_expensereport = $expensereport->id; - $payment->datepaid = $datepaid; - $payment->amounts = $amounts; // Tableau de montant - $payment->total = $total; - $payment->fk_typepayment = GETPOST("fk_typepayment", 'int'); - $payment->num_payment = GETPOST("num_payment", 'alphanothtml'); - $payment->note_public = GETPOST("note_public", 'restricthtml'); + // Create a line of payments + $payment = new PaymentExpenseReport($db); + $payment->fk_expensereport = $expensereport->id; + $payment->datepaid = $datepaid; + $payment->amounts = $amounts; // Tableau de montant + $payment->total = $total; + $payment->fk_typepayment = GETPOST("fk_typepayment", 'int'); + $payment->num_payment = GETPOST("num_payment", 'alphanothtml'); + $payment->note_public = GETPOST("note_public", 'restricthtml'); - if (!$error) - { - $paymentid = $payment->create($user); - if ($paymentid < 0) - { - setEventMessages($payment->error, $payment->errors, 'errors'); - $error++; - } - } + if (!$error) + { + $paymentid = $payment->create($user); + if ($paymentid < 0) + { + setEventMessages($payment->error, $payment->errors, 'errors'); + $error++; + } + } - if (!$error) - { - $result = $payment->addPaymentToBank($user, 'payment_expensereport', '(ExpenseReportPayment)', $accountid, '', ''); - if (!$result > 0) - { - setEventMessages($payment->error, $payment->errors, 'errors'); - $error++; - } - } + if (!$error) + { + $result = $payment->addPaymentToBank($user, 'payment_expensereport', '(ExpenseReportPayment)', $accountid, '', ''); + if (!$result > 0) + { + setEventMessages($payment->error, $payment->errors, 'errors'); + $error++; + } + } - if (!$error) { - $payment->fetch($paymentid); - if ($expensereport->total_ttc - $payment->amount == 0) { - $result = $expensereport->set_paid($expensereport->id, $user); - if (!$result > 0) { - setEventMessages($payment->error, $payment->errors, 'errors'); - $error++; - } - } - } + if (!$error) { + $payment->fetch($paymentid); + if ($expensereport->total_ttc - $payment->amount == 0) { + $result = $expensereport->set_paid($expensereport->id, $user); + if (!$result > 0) { + setEventMessages($payment->error, $payment->errors, 'errors'); + $error++; + } + } + } - if (!$error) - { - $db->commit(); - $loc = DOL_URL_ROOT.'/expensereport/card.php?id='.$id; - header('Location: '.$loc); - exit; - } else { - $db->rollback(); - } - } + if (!$error) + { + $db->commit(); + $loc = DOL_URL_ROOT.'/expensereport/card.php?id='.$id; + header('Location: '.$loc); + exit; + } else { + $db->rollback(); + } + } } $action = 'create'; @@ -194,9 +194,9 @@ if ($action == 'create' || empty($action)) var amount = $(this).data("value"); document.getElementById($(this).data(\'rowid\')).value = amount ; });'; - print "\t});\n"; - print "\n"; - } + print "\t});\n"; + print "\n"; + } print load_fiche_titre($langs->trans("DoPayment")); @@ -206,17 +206,17 @@ if ($action == 'create' || empty($action)) print ''; print ''; - print dol_get_fiche_head(null, '0', '', -1); + print dol_get_fiche_head(null, '0', '', -1); - $linkback = ''; - // $linkback = '' . $langs->trans("BackToList") . ''; + $linkback = ''; + // $linkback = '' . $langs->trans("BackToList") . ''; - dol_banner_tab($expensereport, 'ref', $linkback, 1, 'ref', 'ref', ''); + dol_banner_tab($expensereport, 'ref', $linkback, 1, 'ref', 'ref', ''); - print '
    '; - print '
    '; + print '
    '; + print '
    '; - print ''."\n"; + print '
    '."\n"; print ''; print ''; @@ -224,7 +224,7 @@ if ($action == 'create' || empty($action)) $sql = "SELECT sum(p.amount) as total"; $sql .= " FROM ".MAIN_DB_PREFIX."payment_expensereport as p, ".MAIN_DB_PREFIX."expensereport as e"; $sql .= " WHERE p.fk_expensereport = e.rowid AND p.fk_expensereport = ".$id; - $sql .= ' AND e.entity IN ('.getEntity('expensereport').')'; + $sql .= ' AND e.entity IN ('.getEntity('expensereport').')'; $resql = $db->query($sql); if ($resql) { @@ -239,7 +239,7 @@ if ($action == 'create' || empty($action)) print ''; - dol_fiche_end(); + print dol_get_fiche_end(); print dol_get_fiche_head(); @@ -259,11 +259,11 @@ if ($action == 'create' || empty($action)) if (!empty($conf->banque->enabled)) { - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; } // Number @@ -279,7 +279,7 @@ if ($action == 'create' || empty($action)) print '
    '.$langs->trans("Period").''.get_date_range($expensereport->date_debut, $expensereport->date_fin, "", $langs, 0).'
    '.$langs->trans("Amount").''.price($expensereport->total_ttc, 0, $outputlangs, 1, -1, -1, $conf->currency).'
    '.$langs->trans('AccountToDebit').''; - $form->select_comptes(GETPOSTISSET("accountid") ? GETPOST("accountid", "int") : $expensereport->accountid, "accountid", 0, '', 2); // Show open bank account list - print '
    '.$langs->trans('AccountToDebit').''; + $form->select_comptes(GETPOSTISSET("accountid") ? GETPOST("accountid", "int") : $expensereport->accountid, "accountid", 0, '', 2); // Show open bank account list + print '
    '; - dol_fiche_end(); + print dol_get_fiche_end(); print '
    '; diff --git a/htdocs/expensereport/stats/index.php b/htdocs/expensereport/stats/index.php index b789fc57345..de6c0b961d6 100644 --- a/htdocs/expensereport/stats/index.php +++ b/htdocs/expensereport/stats/index.php @@ -301,7 +301,7 @@ print '
    '; print '
    '; -dol_fiche_end(); +print dol_get_fiche_end(); // End of page llxFooter(); diff --git a/htdocs/exports/export.php b/htdocs/exports/export.php index 412167c55f2..64d94eda3b9 100644 --- a/htdocs/exports/export.php +++ b/htdocs/exports/export.php @@ -516,7 +516,7 @@ if ($step == 2 && $datatoexport) print ''; print ''; - dol_fiche_end(); + print dol_get_fiche_end(); print '
    '; diff --git a/htdocs/fichinter/admin/fichinter_extrafields.php b/htdocs/fichinter/admin/fichinter_extrafields.php index 84dfeb7cfd3..0fa5a930f05 100644 --- a/htdocs/fichinter/admin/fichinter_extrafields.php +++ b/htdocs/fichinter/admin/fichinter_extrafields.php @@ -73,7 +73,7 @@ print dol_get_fiche_head($head, 'attributes', $langs->trans("Interventions"), -1 require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php'; -dol_fiche_end(); +print dol_get_fiche_end(); // Buttons diff --git a/htdocs/fichinter/admin/fichinterdet_extrafields.php b/htdocs/fichinter/admin/fichinterdet_extrafields.php index 5a13bdb4b32..4593de914e3 100644 --- a/htdocs/fichinter/admin/fichinterdet_extrafields.php +++ b/htdocs/fichinter/admin/fichinterdet_extrafields.php @@ -74,7 +74,7 @@ print dol_get_fiche_head($head, 'attributesdet', $langs->trans("Interventions"), require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php'; -dol_fiche_end(); +print dol_get_fiche_end(); // Buttons diff --git a/htdocs/fichinter/card-rec.php b/htdocs/fichinter/card-rec.php index 0a4bbfe922f..31f65be4263 100644 --- a/htdocs/fichinter/card-rec.php +++ b/htdocs/fichinter/card-rec.php @@ -417,7 +417,7 @@ if ($action == 'create') { print "\n"; - dol_fiche_end(); + print dol_get_fiche_end(); print '
    '; print '     '; @@ -438,7 +438,7 @@ if ($action == 'create') { print ''; print ''; - dol_fiche_end(); + print dol_get_fiche_end(); print '
    '; print ''; diff --git a/htdocs/fichinter/card.php b/htdocs/fichinter/card.php index 720e6fe71f3..da1de06cc16 100644 --- a/htdocs/fichinter/card.php +++ b/htdocs/fichinter/card.php @@ -1012,7 +1012,7 @@ if ($action == 'create') print ''; } - dol_fiche_end(); + print dol_get_fiche_end(); print '
    '; print ''; @@ -1053,7 +1053,7 @@ if ($action == 'create') print ''; print ''; - dol_fiche_end(); + print dol_get_fiche_end(); print '
    '; print ''; @@ -1588,7 +1588,7 @@ if ($action == 'create') print ''."\n"; } - dol_fiche_end(); + print dol_get_fiche_end(); print "\n"; diff --git a/htdocs/fichinter/contact.php b/htdocs/fichinter/contact.php index 8dd498d5242..3f0b965b094 100644 --- a/htdocs/fichinter/contact.php +++ b/htdocs/fichinter/contact.php @@ -169,7 +169,7 @@ if ($id > 0 || !empty($ref)) dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref, '', 0, '', '', 1); - dol_fiche_end(); + print dol_get_fiche_end(); print '
    '; diff --git a/htdocs/fichinter/document.php b/htdocs/fichinter/document.php index e28345534d7..8da827132a2 100644 --- a/htdocs/fichinter/document.php +++ b/htdocs/fichinter/document.php @@ -163,7 +163,7 @@ if ($object->id) print '
    '; - dol_fiche_end(); + print dol_get_fiche_end(); $modulepart = 'ficheinter'; $permission = $user->rights->ficheinter->creer; diff --git a/htdocs/fichinter/info.php b/htdocs/fichinter/info.php index 320a29f4171..a53c69b77bd 100644 --- a/htdocs/fichinter/info.php +++ b/htdocs/fichinter/info.php @@ -124,7 +124,7 @@ print ''; print '
    '; -dol_fiche_end(); +print dol_get_fiche_end(); llxFooter(); $db->close(); diff --git a/htdocs/fichinter/note.php b/htdocs/fichinter/note.php index fd18040d037..b634d7092bf 100644 --- a/htdocs/fichinter/note.php +++ b/htdocs/fichinter/note.php @@ -125,7 +125,7 @@ if ($id > 0 || !empty($ref)) print '
    '; - dol_fiche_end(); + print dol_get_fiche_end(); } llxFooter(); diff --git a/htdocs/fichinter/stats/index.php b/htdocs/fichinter/stats/index.php index 45d4c2c2c7d..0e4872637b8 100644 --- a/htdocs/fichinter/stats/index.php +++ b/htdocs/fichinter/stats/index.php @@ -320,7 +320,7 @@ print ''; print '
    '; print '
    '; -dol_fiche_end(); +print dol_get_fiche_end(); llxFooter(); diff --git a/htdocs/fourn/card.php b/htdocs/fourn/card.php index e6a1a6a5a8c..563f46329f5 100644 --- a/htdocs/fourn/card.php +++ b/htdocs/fourn/card.php @@ -767,7 +767,7 @@ if ($object->id > 0) print ''; print '
    '; - dol_fiche_end(); + print dol_get_fiche_end(); /* diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index ba9f79a3c99..383e5ba4d07 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -2258,6 +2258,21 @@ class CommandeFournisseur extends CommonOrder } // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Set delivery date + * + * @param User $user Object user that modify + * @param int $delivery_date Delivery date + * @param int $notrigger 1=Does not execute triggers, 0= execute triggers + * @return int <0 if ko, >0 if ok + * @deprecated Use setDeliveryDate + */ + public function set_date_livraison($user, $delivery_date, $notrigger = 0) + { + // phpcs:enable + return $this->setDeliveryDate($user, $delivery_date, $notrigger); + } + /** * Set the planned delivery date * @@ -2266,9 +2281,8 @@ class CommandeFournisseur extends CommonOrder * @param int $notrigger 1=Does not execute triggers, 0= execute triggers * @return int <0 if KO, >0 if OK */ - public function set_delivery_date($user, $delivery_date, $notrigger = 0) + public function setDeliveryDate($user, $delivery_date, $notrigger = 0) { - // phpcs:enable if ($user->rights->fournisseur->commande->creer) { $error = 0; diff --git a/htdocs/fourn/commande/card.php b/htdocs/fourn/commande/card.php index e5ddc3b1b75..42817e2ea28 100644 --- a/htdocs/fourn/commande/card.php +++ b/htdocs/fourn/commande/card.php @@ -203,7 +203,7 @@ if (empty($reshook)) // date of delivery if ($action == 'setdate_livraison' && $usercancreate) { - $result = $object->set_delivery_date($user, $datelivraison); + $result = $object->setDeliveryDate($user, $datelivraison); if ($result < 0) setEventMessages($object->error, $object->errors, 'errors'); } @@ -1199,7 +1199,7 @@ if (empty($reshook)) $result = $srcobject->fetch($object->origin_id); if ($result > 0) { - $object->set_delivery_date($user, $srcobject->date_livraison); + $object->setDeliveryDate($user, $srcobject->date_livraison); $object->set_id_projet($user, $srcobject->fk_project); $lines = $srcobject->lines; @@ -1765,7 +1765,7 @@ if ($action == 'create') // Bouton "Create Draft" print "\n"; - dol_fiche_end(); + print dol_get_fiche_end(); print '
    '; print ''; @@ -2339,7 +2339,7 @@ if ($action == 'create') print '
    '; print ''; - dol_fiche_end(); + print dol_get_fiche_end(); /** * Boutons actions diff --git a/htdocs/fourn/commande/contact.php b/htdocs/fourn/commande/contact.php index 45178a656ba..3dc9a68d814 100644 --- a/htdocs/fourn/commande/contact.php +++ b/htdocs/fourn/commande/contact.php @@ -182,7 +182,7 @@ if ($id > 0 || !empty($ref)) dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref, '', 0, '', '', 1); - dol_fiche_end(); + print dol_get_fiche_end(); // Contacts lines include DOL_DOCUMENT_ROOT.'/core/tpl/contacts.tpl.php'; diff --git a/htdocs/fourn/commande/dispatch.php b/htdocs/fourn/commande/dispatch.php index 6f6678b57de..8b735f6b6d8 100644 --- a/htdocs/fourn/commande/dispatch.php +++ b/htdocs/fourn/commande/dispatch.php @@ -1080,7 +1080,7 @@ if ($id > 0 || !empty($ref)) { print ''; } - dol_fiche_end(); + print dol_get_fiche_end(); // traitement entrepot par défaut print ''."\n"; print ''."\n"; } - // jQuery Timepicker - if (!empty($conf->global->MAIN_USE_JQUERY_TIMEPICKER) || defined('REQUIRE_JQUERY_TIMEPICKER')) { - print ''."\n"; - print ''."\n"; - } - if (!defined('DISABLE_SELECT2') && (!empty($conf->global->MAIN_USE_JQUERY_MULTISELECT) || defined('REQUIRE_JQUERY_MULTISELECT'))) { - // jQuery plugin "mutiselect", "multiple-select", "select2", ... - $tmpplugin = empty($conf->global->MAIN_USE_JQUERY_MULTISELECT) ?constant('REQUIRE_JQUERY_MULTISELECT') : $conf->global->MAIN_USE_JQUERY_MULTISELECT; - print ''."\n"; // We include full because we need the support of containerCssClass - } - if (! defined('DISABLE_MULTISELECT')) // jQuery plugin "mutiselect" to select with checkboxes. Can be removed once we have an enhanced search tool - { - print ''."\n"; - } + // jQuery Timepicker + if (!empty($conf->global->MAIN_USE_JQUERY_TIMEPICKER) || defined('REQUIRE_JQUERY_TIMEPICKER')) { + print ''."\n"; + print ''."\n"; + } + if (!defined('DISABLE_SELECT2') && (!empty($conf->global->MAIN_USE_JQUERY_MULTISELECT) || defined('REQUIRE_JQUERY_MULTISELECT'))) { + // jQuery plugin "mutiselect", "multiple-select", "select2", ... + $tmpplugin = empty($conf->global->MAIN_USE_JQUERY_MULTISELECT) ?constant('REQUIRE_JQUERY_MULTISELECT') : $conf->global->MAIN_USE_JQUERY_MULTISELECT; + print ''."\n"; // We include full because we need the support of containerCssClass + } + if (! defined('DISABLE_MULTISELECT')) // jQuery plugin "mutiselect" to select with checkboxes. Can be removed once we have an enhanced search tool + { + print ''."\n"; + } } - if (!$disablejs && !empty($conf->use_javascript_ajax)) { - // CKEditor - if ((!empty($conf->fckeditor->enabled) && (empty($conf->global->FCKEDITOR_EDITORNAME) || $conf->global->FCKEDITOR_EDITORNAME == 'ckeditor') && !defined('DISABLE_CKEDITOR')) || defined('FORCE_CKEDITOR')) - { - print ''."\n"; - $pathckeditor = DOL_URL_ROOT.'/includes/ckeditor/ckeditor/'; - $jsckeditor = 'ckeditor.js'; - if (constant('JS_CKEDITOR')) { - // To use external ckeditor 4 js lib - $pathckeditor = constant('JS_CKEDITOR'); - } - print ''."\n"; - print ''."\n"; - print ''."\n"; - } + if (!$disablejs && !empty($conf->use_javascript_ajax)) { + // CKEditor + if ((!empty($conf->fckeditor->enabled) && (empty($conf->global->FCKEDITOR_EDITORNAME) || $conf->global->FCKEDITOR_EDITORNAME == 'ckeditor') && !defined('DISABLE_CKEDITOR')) || defined('FORCE_CKEDITOR')) + { + print ''."\n"; + $pathckeditor = DOL_URL_ROOT.'/includes/ckeditor/ckeditor/'; + $jsckeditor = 'ckeditor.js'; + if (constant('JS_CKEDITOR')) { + // To use external ckeditor 4 js lib + $pathckeditor = constant('JS_CKEDITOR'); + } + print ''."\n"; + print ''."\n"; + print ''."\n"; + } - // Browser notifications (if NOREQUIREMENU is on, it is mostly a page for popup, so we do not enable notif too. We hide also for public pages). - if (!defined('NOBROWSERNOTIF') && !defined('NOREQUIREMENU') && !defined('NOLOGIN')) - { - $enablebrowsernotif = false; - if (!empty($conf->agenda->enabled) && !empty($conf->global->AGENDA_REMINDER_BROWSER)) $enablebrowsernotif = true; - if ($conf->browser->layout == 'phone') $enablebrowsernotif = false; - if ($enablebrowsernotif) - { - print ''."\n"; - print ''."\n"; - } - } + // Browser notifications (if NOREQUIREMENU is on, it is mostly a page for popup, so we do not enable notif too. We hide also for public pages). + if (!defined('NOBROWSERNOTIF') && !defined('NOREQUIREMENU') && !defined('NOLOGIN')) + { + $enablebrowsernotif = false; + if (!empty($conf->agenda->enabled) && !empty($conf->global->AGENDA_REMINDER_BROWSER)) $enablebrowsernotif = true; + if ($conf->browser->layout == 'phone') $enablebrowsernotif = false; + if ($enablebrowsernotif) + { + print ''."\n"; + print ''."\n"; + } + } - // Global js function - print ''."\n"; - print ''."\n"; + // Global js function + print ''."\n"; + print ''."\n"; - // JS forced by modules (relative url starting with /) - if (!empty($conf->modules_parts['js'])) // $conf->modules_parts['js'] is array('module'=>array('file1','file2')) - { - $arrayjs = (array) $conf->modules_parts['js']; - foreach ($arrayjs as $modjs => $filesjs) - { - $filesjs = (array) $filesjs; // To be sure filejs is an array - foreach ($filesjs as $jsfile) - { - // jsfile is a relative path - print ''."\n".''."\n"; - } - } - } - // JS forced by page in top_htmlhead (relative url starting with /) - if (is_array($arrayofjs)) - { - print ''."\n"; - foreach ($arrayofjs as $jsfile) - { - if (preg_match('/^(http|\/\/)/i', $jsfile)) - { - print ''."\n"; - } else { - print ''."\n"; - } - } - } - } + // JS forced by modules (relative url starting with /) + if (!empty($conf->modules_parts['js'])) // $conf->modules_parts['js'] is array('module'=>array('file1','file2')) + { + $arrayjs = (array) $conf->modules_parts['js']; + foreach ($arrayjs as $modjs => $filesjs) + { + $filesjs = (array) $filesjs; // To be sure filejs is an array + foreach ($filesjs as $jsfile) + { + // jsfile is a relative path + print ''."\n".''."\n"; + } + } + } + // JS forced by page in top_htmlhead (relative url starting with /) + if (is_array($arrayofjs)) + { + print ''."\n"; + foreach ($arrayofjs as $jsfile) + { + if (preg_match('/^(http|\/\/)/i', $jsfile)) + { + print ''."\n"; + } else { + print ''."\n"; + } + } + } + } - if (!empty($head)) print $head."\n"; - if (!empty($conf->global->MAIN_HTML_HEADER)) print $conf->global->MAIN_HTML_HEADER."\n"; + if (!empty($head)) print $head."\n"; + if (!empty($conf->global->MAIN_HTML_HEADER)) print $conf->global->MAIN_HTML_HEADER."\n"; - $parameters = array(); - $result = $hookmanager->executeHooks('addHtmlHeader', $parameters); // Note that $action and $object may have been modified by some hooks - print $hookmanager->resPrint; // Replace Title to show + $parameters = array(); + $result = $hookmanager->executeHooks('addHtmlHeader', $parameters); // Note that $action and $object may have been modified by some hooks + print $hookmanager->resPrint; // Replace Title to show - print "\n\n"; - } + print "\n\n"; + } - $conf->headerdone = 1; // To tell header was output + $conf->headerdone = 1; // To tell header was output } @@ -1589,6 +1589,7 @@ function top_menu($head, $title = '', $target = '', $disablejs = 0, $disablehead if (!empty($conf->global->MAIN_FEATURES_LEVEL)) $appli .= "
    ".$langs->trans("LevelOfFeature").': '.$conf->global->MAIN_FEATURES_LEVEL; $logouttext = ''; + $logouthtmltext = ''; if (empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { //$logouthtmltext=$appli.'
    '; @@ -1758,99 +1759,99 @@ function top_menu($head, $title = '', $target = '', $disablejs = 0, $disablehead */ function top_menu_user($hideloginname = 0, $urllogout = '') { - global $langs, $conf, $db, $hookmanager, $user; - global $dolibarr_main_authentication, $dolibarr_main_demo; - global $menumanager; + global $langs, $conf, $db, $hookmanager, $user; + global $dolibarr_main_authentication, $dolibarr_main_demo; + global $menumanager; - $userImage = $userDropDownImage = ''; - if (!empty($user->photo)) - { - $userImage = Form::showphoto('userphoto', $user, 0, 0, 0, 'photouserphoto userphoto', 'small', 0, 1); - $userDropDownImage = Form::showphoto('userphoto', $user, 0, 0, 0, 'dropdown-user-image', 'small', 0, 1); - } else { - $nophoto = '/public/theme/common/user_anonymous.png'; - if ($user->gender == 'man') $nophoto = '/public/theme/common/user_man.png'; - if ($user->gender == 'woman') $nophoto = '/public/theme/common/user_woman.png'; + $userImage = $userDropDownImage = ''; + if (!empty($user->photo)) + { + $userImage = Form::showphoto('userphoto', $user, 0, 0, 0, 'photouserphoto userphoto', 'small', 0, 1); + $userDropDownImage = Form::showphoto('userphoto', $user, 0, 0, 0, 'dropdown-user-image', 'small', 0, 1); + } else { + $nophoto = '/public/theme/common/user_anonymous.png'; + if ($user->gender == 'man') $nophoto = '/public/theme/common/user_man.png'; + if ($user->gender == 'woman') $nophoto = '/public/theme/common/user_woman.png'; - $userImage = 'No photo'; - $userDropDownImage = 'No photo'; - } + $userImage = 'No photo'; + $userDropDownImage = 'No photo'; + } - $dropdownBody = ''; - $dropdownBody .= ' '.$langs->trans("ShowMoreInfos").''; - $dropdownBody .= '
    '; + $dropdownBody = ''; + $dropdownBody .= ' '.$langs->trans("ShowMoreInfos").''; + $dropdownBody .= '
    '; - // login infos - if (!empty($user->admin)) { - $dropdownBody .= '
    '.$langs->trans("Administrator").': '.yn($user->admin); - } - if (!empty($user->socid)) // Add thirdparty for external users - { - $thirdpartystatic = new Societe($db); - $thirdpartystatic->fetch($user->socid); - $companylink = ' '.$thirdpartystatic->getNomUrl(2); // picto only of company - $company = ' ('.$langs->trans("Company").': '.$thirdpartystatic->name.')'; - } - $type = ($user->socid ? $langs->trans("External").$company : $langs->trans("Internal")); - $dropdownBody .= '
    '.$langs->trans("Type").': '.$type; - $dropdownBody .= '
    '.$langs->trans("Status").': '.$user->getLibStatut(0); - $dropdownBody .= '
    '; + // login infos + if (!empty($user->admin)) { + $dropdownBody .= '
    '.$langs->trans("Administrator").': '.yn($user->admin); + } + if (!empty($user->socid)) // Add thirdparty for external users + { + $thirdpartystatic = new Societe($db); + $thirdpartystatic->fetch($user->socid); + $companylink = ' '.$thirdpartystatic->getNomUrl(2); // picto only of company + $company = ' ('.$langs->trans("Company").': '.$thirdpartystatic->name.')'; + } + $type = ($user->socid ? $langs->trans("External").$company : $langs->trans("Internal")); + $dropdownBody .= '
    '.$langs->trans("Type").': '.$type; + $dropdownBody .= '
    '.$langs->trans("Status").': '.$user->getLibStatut(0); + $dropdownBody .= '
    '; - $dropdownBody .= '
    '.$langs->trans("Session").''; - $dropdownBody .= '
    '.$langs->trans("IPAddress").': '.dol_escape_htmltag($_SERVER["REMOTE_ADDR"]); - if (!empty($conf->global->MAIN_MODULE_MULTICOMPANY)) $dropdownBody .= '
    '.$langs->trans("ConnectedOnMultiCompany").': '.$conf->entity.' (user entity '.$user->entity.')'; - $dropdownBody .= '
    '.$langs->trans("AuthenticationMode").': '.$_SESSION["dol_authmode"].(empty($dolibarr_main_demo) ? '' : ' (demo)'); - $dropdownBody .= '
    '.$langs->trans("ConnectedSince").': '.dol_print_date($user->datelastlogin, "dayhour", 'tzuser'); - $dropdownBody .= '
    '.$langs->trans("PreviousConnexion").': '.dol_print_date($user->datepreviouslogin, "dayhour", 'tzuser'); - $dropdownBody .= '
    '.$langs->trans("CurrentTheme").': '.$conf->theme; - $dropdownBody .= '
    '.$langs->trans("CurrentMenuManager").': '.$menumanager->name; - $langFlag = picto_from_langcode($langs->getDefaultLang()); - $dropdownBody .= '
    '.$langs->trans("CurrentUserLanguage").': '.($langFlag ? $langFlag.' ' : '').$langs->getDefaultLang(); - $dropdownBody .= '
    '.$langs->trans("Browser").': '.$conf->browser->name.($conf->browser->version ? ' '.$conf->browser->version : '').' ('.dol_escape_htmltag($_SERVER['HTTP_USER_AGENT']).')'; - $dropdownBody .= '
    '.$langs->trans("Layout").': '.$conf->browser->layout; - $dropdownBody .= '
    '.$langs->trans("Screen").': '.$_SESSION['dol_screenwidth'].' x '.$_SESSION['dol_screenheight']; - if ($conf->browser->layout == 'phone') $dropdownBody .= '
    '.$langs->trans("Phone").': '.$langs->trans("Yes"); - if (!empty($_SESSION["disablemodules"])) $dropdownBody .= '
    '.$langs->trans("DisabledModules").':
    '.join(', ', explode(',', $_SESSION["disablemodules"])); - $dropdownBody .= '
    '; + $dropdownBody .= '
    '.$langs->trans("Session").''; + $dropdownBody .= '
    '.$langs->trans("IPAddress").': '.dol_escape_htmltag($_SERVER["REMOTE_ADDR"]); + if (!empty($conf->global->MAIN_MODULE_MULTICOMPANY)) $dropdownBody .= '
    '.$langs->trans("ConnectedOnMultiCompany").': '.$conf->entity.' (user entity '.$user->entity.')'; + $dropdownBody .= '
    '.$langs->trans("AuthenticationMode").': '.$_SESSION["dol_authmode"].(empty($dolibarr_main_demo) ? '' : ' (demo)'); + $dropdownBody .= '
    '.$langs->trans("ConnectedSince").': '.dol_print_date($user->datelastlogin, "dayhour", 'tzuser'); + $dropdownBody .= '
    '.$langs->trans("PreviousConnexion").': '.dol_print_date($user->datepreviouslogin, "dayhour", 'tzuser'); + $dropdownBody .= '
    '.$langs->trans("CurrentTheme").': '.$conf->theme; + $dropdownBody .= '
    '.$langs->trans("CurrentMenuManager").': '.$menumanager->name; + $langFlag = picto_from_langcode($langs->getDefaultLang()); + $dropdownBody .= '
    '.$langs->trans("CurrentUserLanguage").': '.($langFlag ? $langFlag.' ' : '').$langs->getDefaultLang(); + $dropdownBody .= '
    '.$langs->trans("Browser").': '.$conf->browser->name.($conf->browser->version ? ' '.$conf->browser->version : '').' ('.dol_escape_htmltag($_SERVER['HTTP_USER_AGENT']).')'; + $dropdownBody .= '
    '.$langs->trans("Layout").': '.$conf->browser->layout; + $dropdownBody .= '
    '.$langs->trans("Screen").': '.$_SESSION['dol_screenwidth'].' x '.$_SESSION['dol_screenheight']; + if ($conf->browser->layout == 'phone') $dropdownBody .= '
    '.$langs->trans("Phone").': '.$langs->trans("Yes"); + if (!empty($_SESSION["disablemodules"])) $dropdownBody .= '
    '.$langs->trans("DisabledModules").':
    '.join(', ', explode(',', $_SESSION["disablemodules"])); + $dropdownBody .= '
    '; - // Execute hook - $parameters = array('user'=>$user, 'langs' => $langs); - $result = $hookmanager->executeHooks('printTopRightMenuLoginDropdownBody', $parameters); // Note that $action and $object may have been modified by some hooks - if (is_numeric($result)) - { - if ($result == 0) { - $dropdownBody .= $hookmanager->resPrint; // add - } else { - $dropdownBody = $hookmanager->resPrint; // replace - } - } + // Execute hook + $parameters = array('user'=>$user, 'langs' => $langs); + $result = $hookmanager->executeHooks('printTopRightMenuLoginDropdownBody', $parameters); // Note that $action and $object may have been modified by some hooks + if (is_numeric($result)) + { + if ($result == 0) { + $dropdownBody .= $hookmanager->resPrint; // add + } else { + $dropdownBody = $hookmanager->resPrint; // replace + } + } - if (empty($urllogout)) { - $urllogout = DOL_URL_ROOT.'/user/logout.php'; - } - $logoutLink = ' '.$langs->trans("Logout").''; - $profilLink = ' '.$langs->trans("Card").''; + if (empty($urllogout)) { + $urllogout = DOL_URL_ROOT.'/user/logout.php'; + } + $logoutLink = ' '.$langs->trans("Logout").''; + $profilLink = ' '.$langs->trans("Card").''; - $profilName = $user->getFullName($langs).' ('.$user->login.')'; + $profilName = $user->getFullName($langs).' ('.$user->login.')'; - if (!empty($user->admin)) { - $profilName = ' '.$profilName; - } + if (!empty($user->admin)) { + $profilName = ' '.$profilName; + } - // Define version to show - $appli = constant('DOL_APPLICATION_TITLE'); - if (!empty($conf->global->MAIN_APPLICATION_TITLE)) - { - $appli = $conf->global->MAIN_APPLICATION_TITLE; - if (preg_match('/\d\.\d/', $appli)) - { - if (!preg_match('/'.preg_quote(DOL_VERSION).'/', $appli)) $appli .= " (".DOL_VERSION.")"; // If new title contains a version that is different than core - } else $appli .= " ".DOL_VERSION; - } else $appli .= " ".DOL_VERSION; + // Define version to show + $appli = constant('DOL_APPLICATION_TITLE'); + if (!empty($conf->global->MAIN_APPLICATION_TITLE)) + { + $appli = $conf->global->MAIN_APPLICATION_TITLE; + if (preg_match('/\d\.\d/', $appli)) + { + if (!preg_match('/'.preg_quote(DOL_VERSION).'/', $appli)) $appli .= " (".DOL_VERSION.")"; // If new title contains a version that is different than core + } else $appli .= " ".DOL_VERSION; + } else $appli .= " ".DOL_VERSION; - if (empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { - $btnUser = ' + if (empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { + $btnUser = ' '; - } else { - $btnUser = ' + } else { + $btnUser = ' '; - } + } - if (!defined('JS_JQUERY_DISABLE_DROPDOWN') && !empty($conf->use_javascript_ajax)) // This may be set by some pages that use different jquery version to avoid errors - { - $btnUser .= ' + if (!defined('JS_JQUERY_DISABLE_DROPDOWN') && !empty($conf->use_javascript_ajax)) // This may be set by some pages that use different jquery version to avoid errors + { + $btnUser .= ' '; - } + } - return $btnUser; + return $btnUser; } /** @@ -2159,24 +2160,24 @@ function top_menu_quickadd() */ function top_menu_bookmark() { - global $langs, $conf, $db, $user; + global $langs, $conf, $db, $user; $html = ''; - // Define $bookmarks + // Define $bookmarks if (empty($conf->bookmark->enabled) || empty($user->rights->bookmark->lire)) return $html; if (!defined('JS_JQUERY_DISABLE_DROPDOWN') && !empty($conf->use_javascript_ajax)) // This may be set by some pages that use different jquery version to avoid errors - { - include_once DOL_DOCUMENT_ROOT.'/bookmarks/bookmarks.lib.php'; - $langs->load("bookmarks"); + { + include_once DOL_DOCUMENT_ROOT.'/bookmarks/bookmarks.lib.php'; + $langs->load("bookmarks"); - if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { - $html .= ''; - } else { - $html .= ' + if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { + $html .= ''; + } else { + $html .= ' '; - $html .= ' + $html .= ' '; - } - } - return $html; + } + } + return $html; } /** @@ -2233,51 +2234,51 @@ function top_menu_bookmark() */ function top_menu_search() { - global $langs, $conf, $db, $user, $hookmanager; + global $langs, $conf, $db, $user, $hookmanager; $html = ''; - $usedbyinclude = 1; - $arrayresult = null; - include DOL_DOCUMENT_ROOT.'/core/ajax/selectsearchbox.php'; // This set $arrayresult + $usedbyinclude = 1; + $arrayresult = null; + include DOL_DOCUMENT_ROOT.'/core/ajax/selectsearchbox.php'; // This set $arrayresult - $defaultAction = ''; - $buttonList = ''; + $defaultAction = ''; + $buttonList = ''; - $searchInput = ''; + $searchInput = ''; - $dropDownHtml = ''; + $dropDownHtml .= ''; - $html .= ' + $html .= ' '; - $html .= ' + $html .= ' '; - return $html; + return $html; } /** @@ -2385,44 +2386,44 @@ function left_menu($menu_array_before, $helppagename = '', $notused = '', $menu_ if (!is_object($form)) $form = new Form($db); $selected = -1; - if (empty($conf->global->MAIN_USE_TOP_MENU_SEARCH_DROPDOWN)) { - $usedbyinclude = 1; - $arrayresult = null; - include DOL_DOCUMENT_ROOT.'/core/ajax/selectsearchbox.php'; // This set $arrayresult + if (empty($conf->global->MAIN_USE_TOP_MENU_SEARCH_DROPDOWN)) { + $usedbyinclude = 1; + $arrayresult = null; + include DOL_DOCUMENT_ROOT.'/core/ajax/selectsearchbox.php'; // This set $arrayresult - if ($conf->use_javascript_ajax && empty($conf->global->MAIN_USE_OLD_SEARCH_FORM)) { - $searchform .= $form->selectArrayFilter('searchselectcombo', $arrayresult, $selected, '', 1, 0, (empty($conf->global->MAIN_SEARCHBOX_CONTENT_LOADED_BEFORE_KEY) ? 1 : 0), 'vmenusearchselectcombo', 1, $langs->trans("Search"), 1); - } else { - if (is_array($arrayresult)) { - foreach ($arrayresult as $key => $val) { - $searchform .= printSearchForm($val['url'], $val['url'], $val['label'], 'maxwidth125', 'sall', $val['shortcut'], 'searchleft'.$key, $val['img']); - } - } - } + if ($conf->use_javascript_ajax && empty($conf->global->MAIN_USE_OLD_SEARCH_FORM)) { + $searchform .= $form->selectArrayFilter('searchselectcombo', $arrayresult, $selected, '', 1, 0, (empty($conf->global->MAIN_SEARCHBOX_CONTENT_LOADED_BEFORE_KEY) ? 1 : 0), 'vmenusearchselectcombo', 1, $langs->trans("Search"), 1); + } else { + if (is_array($arrayresult)) { + foreach ($arrayresult as $key => $val) { + $searchform .= printSearchForm($val['url'], $val['url'], $val['label'], 'maxwidth125', 'sall', $val['shortcut'], 'searchleft'.$key, $val['img']); + } + } + } - // Execute hook printSearchForm - $parameters = array('searchform' => $searchform); - $reshook = $hookmanager->executeHooks('printSearchForm', $parameters); // Note that $action and $object may have been modified by some hooks - if (empty($reshook)) { - $searchform .= $hookmanager->resPrint; - } else $searchform = $hookmanager->resPrint; + // Execute hook printSearchForm + $parameters = array('searchform' => $searchform); + $reshook = $hookmanager->executeHooks('printSearchForm', $parameters); // Note that $action and $object may have been modified by some hooks + if (empty($reshook)) { + $searchform .= $hookmanager->resPrint; + } else $searchform = $hookmanager->resPrint; - // Force special value for $searchform - if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER) || empty($conf->use_javascript_ajax)) { - $urltosearch = DOL_URL_ROOT.'/core/search_page.php?showtitlebefore=1'; - $searchform = '
    '; - } elseif ($conf->use_javascript_ajax && !empty($conf->global->MAIN_USE_OLD_SEARCH_FORM)) { - $searchform = '
    '; - $searchform .= '' . "\n"; - $searchform .= '
    '; - } - } + $searchform .= ''; + } + } // Left column print ''."\n"; @@ -2473,37 +2474,37 @@ function left_menu($menu_array_before, $helppagename = '', $notused = '', $menu_ { require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; - $bugbaseurl = 'https://github.com/Dolibarr/dolibarr/issues/new?labels=Bug'; + $bugbaseurl = 'https://github.com/Dolibarr/dolibarr/issues/new?labels=Bug'; $bugbaseurl .= '&title='; $bugbaseurl .= urlencode("Bug: "); - $bugbaseurl .= '&body='; - $bugbaseurl .= urlencode("# Instructions\n"); - $bugbaseurl .= urlencode("*This is a template to help you report good issues. You may use [Github Markdown](https://help.github.com/articles/getting-started-with-writing-and-formatting-on-github/) syntax to format your issue report.*\n"); - $bugbaseurl .= urlencode("*Please:*\n"); - $bugbaseurl .= urlencode("- *replace the bracket enclosed texts with meaningful information*\n"); - $bugbaseurl .= urlencode("- *remove any unused sub-section*\n"); - $bugbaseurl .= urlencode("\n"); - $bugbaseurl .= urlencode("\n"); - $bugbaseurl .= urlencode("# Bug\n"); - $bugbaseurl .= urlencode("[*Short description*]\n"); - $bugbaseurl .= urlencode("\n"); - $bugbaseurl .= urlencode("## Environment\n"); - $bugbaseurl .= urlencode("- **Version**: ".DOL_VERSION."\n"); - $bugbaseurl .= urlencode("- **OS**: ".php_uname('s')."\n"); - $bugbaseurl .= urlencode("- **Web server**: ".$_SERVER["SERVER_SOFTWARE"]."\n"); - $bugbaseurl .= urlencode("- **PHP**: ".php_sapi_name().' '.phpversion()."\n"); - $bugbaseurl .= urlencode("- **Database**: ".$db::LABEL.' '.$db->getVersion()."\n"); - $bugbaseurl .= urlencode("- **URL(s)**: ".$_SERVER["REQUEST_URI"]."\n"); - $bugbaseurl .= urlencode("\n"); - $bugbaseurl .= urlencode("## Expected and actual behavior\n"); - $bugbaseurl .= urlencode("[*Verbose description*]\n"); - $bugbaseurl .= urlencode("\n"); - $bugbaseurl .= urlencode("## Steps to reproduce the behavior\n"); - $bugbaseurl .= urlencode("[*Verbose description*]\n"); - $bugbaseurl .= urlencode("\n"); - $bugbaseurl .= urlencode("## [Attached files](https://help.github.com/articles/issue-attachments) (Screenshots, screencasts, dolibarr.log, debugging informations…)\n"); - $bugbaseurl .= urlencode("[*Files*]\n"); - $bugbaseurl .= urlencode("\n"); + $bugbaseurl .= '&body='; + $bugbaseurl .= urlencode("# Instructions\n"); + $bugbaseurl .= urlencode("*This is a template to help you report good issues. You may use [Github Markdown](https://help.github.com/articles/getting-started-with-writing-and-formatting-on-github/) syntax to format your issue report.*\n"); + $bugbaseurl .= urlencode("*Please:*\n"); + $bugbaseurl .= urlencode("- *replace the bracket enclosed texts with meaningful information*\n"); + $bugbaseurl .= urlencode("- *remove any unused sub-section*\n"); + $bugbaseurl .= urlencode("\n"); + $bugbaseurl .= urlencode("\n"); + $bugbaseurl .= urlencode("# Bug\n"); + $bugbaseurl .= urlencode("[*Short description*]\n"); + $bugbaseurl .= urlencode("\n"); + $bugbaseurl .= urlencode("## Environment\n"); + $bugbaseurl .= urlencode("- **Version**: ".DOL_VERSION."\n"); + $bugbaseurl .= urlencode("- **OS**: ".php_uname('s')."\n"); + $bugbaseurl .= urlencode("- **Web server**: ".$_SERVER["SERVER_SOFTWARE"]."\n"); + $bugbaseurl .= urlencode("- **PHP**: ".php_sapi_name().' '.phpversion()."\n"); + $bugbaseurl .= urlencode("- **Database**: ".$db::LABEL.' '.$db->getVersion()."\n"); + $bugbaseurl .= urlencode("- **URL(s)**: ".$_SERVER["REQUEST_URI"]."\n"); + $bugbaseurl .= urlencode("\n"); + $bugbaseurl .= urlencode("## Expected and actual behavior\n"); + $bugbaseurl .= urlencode("[*Verbose description*]\n"); + $bugbaseurl .= urlencode("\n"); + $bugbaseurl .= urlencode("## Steps to reproduce the behavior\n"); + $bugbaseurl .= urlencode("[*Verbose description*]\n"); + $bugbaseurl .= urlencode("\n"); + $bugbaseurl .= urlencode("## [Attached files](https://help.github.com/articles/issue-attachments) (Screenshots, screencasts, dolibarr.log, debugging informations…)\n"); + $bugbaseurl .= urlencode("[*Files*]\n"); + $bugbaseurl .= urlencode("\n"); // Execute hook printBugtrackInfo @@ -2562,35 +2563,35 @@ function main_area($title = '') if (!empty($conf->global->MAIN_ONLY_LOGIN_ALLOWED)) print info_admin($langs->trans("WarningYouAreInMaintenanceMode", $conf->global->MAIN_ONLY_LOGIN_ALLOWED)); - // Permit to add user company information on each printed document by set SHOW_SOCINFO_ON_PRINT - if (!empty($conf->global->SHOW_SOCINFO_ON_PRINT) && GETPOST('optioncss', 'aZ09') == 'print' && empty(GETPOST('disable_show_socinfo_on_print', 'az09'))) - { - global $hookmanager; - $hookmanager->initHooks(array('showsocinfoonprint')); - $parameters = array(); - $reshook = $hookmanager->executeHooks('showSocinfoOnPrint', $parameters); - if (empty($reshook)) - { - print ''."\n"; - print '
    '."\n"; - print ''."\n"; - print ''; - print ''."\n"; - print ''."\n"; - print ''."\n"; - if (!empty($conf->global->MAIN_INFO_SOCIETE_TEL)) print ''; - if (!empty($conf->global->MAIN_INFO_SOCIETE_MAIL)) print ''; - if (!empty($conf->global->MAIN_INFO_SOCIETE_WEB)) print ''; - print ''; - print '
    '; - if ($conf->global->MAIN_SHOW_LOGO && empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER) && !empty($conf->global->MAIN_INFO_SOCIETE_LOGO)) { - print ''; - } - print '
    '.dol_escape_htmltag($conf->global->MAIN_INFO_SOCIETE_NOM).'
    '.dol_escape_htmltag($conf->global->MAIN_INFO_SOCIETE_ADDRESS).'
    '.dol_escape_htmltag($conf->global->MAIN_INFO_SOCIETE_ZIP).' '.dol_escape_htmltag($conf->global->MAIN_INFO_SOCIETE_TOWN).'
    '.$langs->trans("Phone").' : '.dol_escape_htmltag($conf->global->MAIN_INFO_SOCIETE_TEL).'
    '.$langs->trans("Email").' : '.dol_escape_htmltag($conf->global->MAIN_INFO_SOCIETE_MAIL).'
    '.$langs->trans("Web").' : '.dol_escape_htmltag($conf->global->MAIN_INFO_SOCIETE_WEB).'
    '."\n"; - print '
    '."\n"; - print ''."\n"; - } - } + // Permit to add user company information on each printed document by set SHOW_SOCINFO_ON_PRINT + if (!empty($conf->global->SHOW_SOCINFO_ON_PRINT) && GETPOST('optioncss', 'aZ09') == 'print' && empty(GETPOST('disable_show_socinfo_on_print', 'az09'))) + { + global $hookmanager; + $hookmanager->initHooks(array('showsocinfoonprint')); + $parameters = array(); + $reshook = $hookmanager->executeHooks('showSocinfoOnPrint', $parameters); + if (empty($reshook)) + { + print ''."\n"; + print '
    '."\n"; + print ''."\n"; + print ''; + print ''."\n"; + print ''."\n"; + print ''."\n"; + if (!empty($conf->global->MAIN_INFO_SOCIETE_TEL)) print ''; + if (!empty($conf->global->MAIN_INFO_SOCIETE_MAIL)) print ''; + if (!empty($conf->global->MAIN_INFO_SOCIETE_WEB)) print ''; + print ''; + print '
    '; + if ($conf->global->MAIN_SHOW_LOGO && empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER) && !empty($conf->global->MAIN_INFO_SOCIETE_LOGO)) { + print ''; + } + print '
    '.dol_escape_htmltag($conf->global->MAIN_INFO_SOCIETE_NOM).'
    '.dol_escape_htmltag($conf->global->MAIN_INFO_SOCIETE_ADDRESS).'
    '.dol_escape_htmltag($conf->global->MAIN_INFO_SOCIETE_ZIP).' '.dol_escape_htmltag($conf->global->MAIN_INFO_SOCIETE_TOWN).'
    '.$langs->trans("Phone").' : '.dol_escape_htmltag($conf->global->MAIN_INFO_SOCIETE_TEL).'
    '.$langs->trans("Email").' : '.dol_escape_htmltag($conf->global->MAIN_INFO_SOCIETE_MAIL).'
    '.$langs->trans("Web").' : '.dol_escape_htmltag($conf->global->MAIN_INFO_SOCIETE_WEB).'
    '."\n"; + print '
    '."\n"; + print ''."\n"; + } + } } @@ -2905,5 +2906,5 @@ if (!function_exists("llxFooter")) print "\n"; print "\n"; - } + } } diff --git a/htdocs/margin/admin/margin.php b/htdocs/margin/admin/margin.php index 466c40a4e49..d9c470b7acd 100644 --- a/htdocs/margin/admin/margin.php +++ b/htdocs/margin/admin/margin.php @@ -249,7 +249,7 @@ print ''; print ''; -dol_fiche_end(); +print dol_get_fiche_end(); print '
    '; diff --git a/htdocs/margin/agentMargins.php b/htdocs/margin/agentMargins.php index 220715e6f72..8518d6f8415 100644 --- a/htdocs/margin/agentMargins.php +++ b/htdocs/margin/agentMargins.php @@ -130,7 +130,7 @@ print '"; -dol_fiche_end(); +print dol_get_fiche_end(); print ''; diff --git a/htdocs/margin/checkMargins.php b/htdocs/margin/checkMargins.php index 22d23967ebd..a123ead3672 100644 --- a/htdocs/margin/checkMargins.php +++ b/htdocs/margin/checkMargins.php @@ -178,7 +178,7 @@ print ''; print ''; print ""; -dol_fiche_end(); +print dol_get_fiche_end(); $arrayfields = array(); diff --git a/htdocs/margin/customerMargins.php b/htdocs/margin/customerMargins.php index 1a8a253994b..709e7925597 100644 --- a/htdocs/margin/customerMargins.php +++ b/htdocs/margin/customerMargins.php @@ -193,7 +193,7 @@ if (!empty($conf->global->DISPLAY_MARK_RATES)) { print ""; -dol_fiche_end(); +print dol_get_fiche_end(); print ''; diff --git a/htdocs/margin/productMargins.php b/htdocs/margin/productMargins.php index 7deeffe92bd..56129ef3873 100644 --- a/htdocs/margin/productMargins.php +++ b/htdocs/margin/productMargins.php @@ -170,7 +170,7 @@ if (!empty($conf->global->DISPLAY_MARK_RATES)) { print ""; -dol_fiche_end(); +print dol_get_fiche_end(); print ''; diff --git a/htdocs/margin/tabs/productMargins.php b/htdocs/margin/tabs/productMargins.php index a8ec93df400..cecaaae1ac2 100644 --- a/htdocs/margin/tabs/productMargins.php +++ b/htdocs/margin/tabs/productMargins.php @@ -126,7 +126,7 @@ if ($id > 0 || !empty($ref)) print ''; print '
    '; - dol_fiche_end(); + print dol_get_fiche_end(); if ($user->rights->facture->lire) { diff --git a/htdocs/margin/tabs/thirdpartyMargins.php b/htdocs/margin/tabs/thirdpartyMargins.php index a31f6007062..57ccf2ee589 100644 --- a/htdocs/margin/tabs/thirdpartyMargins.php +++ b/htdocs/margin/tabs/thirdpartyMargins.php @@ -138,7 +138,7 @@ if ($socid > 0) print ''; print '
    '; - dol_fiche_end(); + print dol_get_fiche_end(); print '
    '; diff --git a/htdocs/modulebuilder/admin/setup.php b/htdocs/modulebuilder/admin/setup.php index 112ed71ea82..220ecd1b5b1 100644 --- a/htdocs/modulebuilder/admin/setup.php +++ b/htdocs/modulebuilder/admin/setup.php @@ -194,7 +194,7 @@ print ''; print '
    '; if (GETPOST('withtab', 'alpha')) { - dol_fiche_end(); + print dol_get_fiche_end(); } print '
    '; diff --git a/htdocs/modulebuilder/index.php b/htdocs/modulebuilder/index.php index 347202215b7..97539472de2 100644 --- a/htdocs/modulebuilder/index.php +++ b/htdocs/modulebuilder/index.php @@ -1989,7 +1989,7 @@ if ($module == 'initmodule') else print ''.$langs->trans("ErrorFileNotFound", $pathtochangelog).''; } - dol_fiche_end(); + print dol_get_fiche_end(); } else { // Edit text file $fullpathoffile = dol_buildpath($file, 0, 1); // Description - level 2 @@ -2011,7 +2011,7 @@ if ($module == 'initmodule') $doleditor = new DolEditor('editfilecontent', $content, '', '300', 'Full', 'In', true, false, 'ace', 0, '99%', ''); print $doleditor->Create(1, '', false, $langs->trans("File").' : '.$file, (GETPOST('format', 'aZ09') ?GETPOST('format', 'aZ09') : 'html')); - dol_fiche_end(); + print dol_get_fiche_end(); print '
    '; print ''; @@ -2812,7 +2812,7 @@ if ($module == 'initmodule') } } - dol_fiche_end(); // Level 3 + print dol_get_fiche_end(); // Level 3 } if ($tab == 'menus') @@ -3696,12 +3696,12 @@ if ($module == 'initmodule') if ($tab != 'description') { - dol_fiche_end(); + print dol_get_fiche_end(); } } } -dol_fiche_end(); // End modules +print dol_get_fiche_end(); // End modules // End of page llxFooter(); diff --git a/htdocs/modulebuilder/template/admin/about.php b/htdocs/modulebuilder/template/admin/about.php index df122c43268..518920592f4 100644 --- a/htdocs/modulebuilder/template/admin/about.php +++ b/htdocs/modulebuilder/template/admin/about.php @@ -82,6 +82,6 @@ $tmpmodule = new modMyModule($db); print $tmpmodule->getDescLong(); // Page end -dol_fiche_end(); +print dol_get_fiche_end(); llxFooter(); $db->close(); diff --git a/htdocs/modulebuilder/template/admin/myobject_extrafields.php b/htdocs/modulebuilder/template/admin/myobject_extrafields.php index 65353f905e6..2d6a02f7ddf 100644 --- a/htdocs/modulebuilder/template/admin/myobject_extrafields.php +++ b/htdocs/modulebuilder/template/admin/myobject_extrafields.php @@ -74,7 +74,7 @@ print dol_get_fiche_head($head, 'myobject_extrafields', $langs->trans("MyObjectE require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php'; -dol_fiche_end(); +print dol_get_fiche_end(); // Buttons diff --git a/htdocs/modulebuilder/template/admin/setup.php b/htdocs/modulebuilder/template/admin/setup.php index 77eed6681e3..e1cf7ed1f2a 100644 --- a/htdocs/modulebuilder/template/admin/setup.php +++ b/htdocs/modulebuilder/template/admin/setup.php @@ -518,7 +518,7 @@ if (empty($setupnotempty)) { } // Page end -dol_fiche_end(); +print dol_get_fiche_end(); llxFooter(); $db->close(); diff --git a/htdocs/modulebuilder/template/core/modules/mymodule/doc/doc_generic_myobject_odt.modules.php b/htdocs/modulebuilder/template/core/modules/mymodule/doc/doc_generic_myobject_odt.modules.php index d585815e805..69a4bc09b68 100644 --- a/htdocs/modulebuilder/template/core/modules/mymodule/doc/doc_generic_myobject_odt.modules.php +++ b/htdocs/modulebuilder/template/core/modules/mymodule/doc/doc_generic_myobject_odt.modules.php @@ -316,7 +316,7 @@ class doc_generic_myobject_odt extends ModelePDFMyObject '__FROM_EMAIL__' => $this->emetteur->email, '__TOTAL_TTC__' => $object->total_ttc, '__TOTAL_HT__' => $object->total_ht, - '__TOTAL_VAT__' => $object->total_vat + '__TOTAL_VAT__' => $object->total_tva ); complete_substitutions_array($substitutionarray, $langs, $object); // Call the ODTSubstitution hook diff --git a/htdocs/modulebuilder/template/core/triggers/interface_99_modMyModule_MyModuleTriggers.class.php b/htdocs/modulebuilder/template/core/triggers/interface_99_modMyModule_MyModuleTriggers.class.php index be6d42047ce..4c661f42a24 100644 --- a/htdocs/modulebuilder/template/core/triggers/interface_99_modMyModule_MyModuleTriggers.class.php +++ b/htdocs/modulebuilder/template/core/triggers/interface_99_modMyModule_MyModuleTriggers.class.php @@ -40,11 +40,6 @@ require_once DOL_DOCUMENT_ROOT.'/core/triggers/dolibarrtriggers.class.php'; */ class InterfaceMyModuleTriggers extends DolibarrTriggers { - /** - * @var DoliDB Database handler - */ - protected $db; - /** * Constructor * @@ -106,7 +101,7 @@ class InterfaceMyModuleTriggers extends DolibarrTriggers // For example : COMPANY_CREATE => public function companyCreate($action, $object, User $user, Translate $langs, Conf $conf) $methodName = lcfirst(str_replace(' ', '', ucwords(str_replace('_', ' ', strtolower($action))))); $callback = array($this, $methodName); - if (is_callable($callback)){ + if (is_callable($callback)) { dol_syslog( "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id ); diff --git a/htdocs/modulebuilder/template/myobject_agenda.php b/htdocs/modulebuilder/template/myobject_agenda.php index 43253c90362..8db58b7ad4e 100644 --- a/htdocs/modulebuilder/template/myobject_agenda.php +++ b/htdocs/modulebuilder/template/myobject_agenda.php @@ -215,7 +215,7 @@ if ($object->id > 0) print ''; - dol_fiche_end(); + print dol_get_fiche_end(); diff --git a/htdocs/modulebuilder/template/myobject_card.php b/htdocs/modulebuilder/template/myobject_card.php index 685253385fb..04ea8b40d07 100644 --- a/htdocs/modulebuilder/template/myobject_card.php +++ b/htdocs/modulebuilder/template/myobject_card.php @@ -231,7 +231,7 @@ if ($action == 'create') print ''."\n"; - dol_fiche_end(); + print dol_get_fiche_end(); print '
    '; print ''; @@ -268,7 +268,7 @@ if (($id || $ref) && $action == 'edit') print ''; - dol_fiche_end(); + print dol_get_fiche_end(); print '
    '; print '   '; @@ -396,7 +396,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print '
    '; - dol_fiche_end(); + print dol_get_fiche_end(); /* diff --git a/htdocs/modulebuilder/template/myobject_document.php b/htdocs/modulebuilder/template/myobject_document.php index 6a417e32372..b2158ac34ad 100644 --- a/htdocs/modulebuilder/template/myobject_document.php +++ b/htdocs/modulebuilder/template/myobject_document.php @@ -207,7 +207,7 @@ if ($object->id) print '
    '; - dol_fiche_end(); + print dol_get_fiche_end(); $modulepart = 'mymodule'; //$permission = $user->rights->mymodule->myobject->write; diff --git a/htdocs/modulebuilder/template/myobject_note.php b/htdocs/modulebuilder/template/myobject_note.php index e83531b2445..f56585497ea 100644 --- a/htdocs/modulebuilder/template/myobject_note.php +++ b/htdocs/modulebuilder/template/myobject_note.php @@ -175,7 +175,7 @@ if ($id > 0 || !empty($ref)) print '
    '; - dol_fiche_end(); + print dol_get_fiche_end(); } // End of page diff --git a/htdocs/mrp/class/mo.class.php b/htdocs/mrp/class/mo.class.php index 0d623988a3f..cf4b4ccddd1 100644 --- a/htdocs/mrp/class/mo.class.php +++ b/htdocs/mrp/class/mo.class.php @@ -987,7 +987,7 @@ class Mo extends CommonObject $result = ''; - $label = img_picto('', $this->picto).' '.$langs->trans("MO").''; + $label = img_picto('', $this->picto).' '.$langs->trans("ManufacturingOrder").''; $label .= '
    '; $label .= ''.$langs->trans('Ref').': '.$this->ref; if (isset($this->status)) { diff --git a/htdocs/mrp/index.php b/htdocs/mrp/index.php index d4359dcae90..b7b96319a16 100644 --- a/htdocs/mrp/index.php +++ b/htdocs/mrp/index.php @@ -96,7 +96,7 @@ if ($conf->use_javascript_ajax) print '
    '; print ''; - print ''."\n"; + print '' . "\n"; $listofstatus = array(0, 1, 2, 3, 9); foreach ($listofstatus as $status) { diff --git a/htdocs/mrp/lib/mrp_mo.lib.php b/htdocs/mrp/lib/mrp_mo.lib.php index f203633584e..eb61c42e83d 100644 --- a/htdocs/mrp/lib/mrp_mo.lib.php +++ b/htdocs/mrp/lib/mrp_mo.lib.php @@ -37,7 +37,7 @@ function moPrepareHead($object) $head = array(); $head[$h][0] = DOL_URL_ROOT.'/mrp/mo_card.php?id='.$object->id; - $head[$h][1] = $langs->trans("MO"); + $head[$h][1] = $langs->trans("ManufacturingOrder"); $head[$h][2] = 'card'; $h++; diff --git a/htdocs/mrp/mo_agenda.php b/htdocs/mrp/mo_agenda.php index e6892e949e5..bae3f52430e 100644 --- a/htdocs/mrp/mo_agenda.php +++ b/htdocs/mrp/mo_agenda.php @@ -131,7 +131,7 @@ if ($object->id > 0) $head = moPrepareHead($object); - print dol_get_fiche_head($head, 'agenda', $langs->trans("MO"), -1, $object->picto); + print dol_get_fiche_head($head, 'agenda', $langs->trans("ManufacturingOrder"), -1, $object->picto); // Object card // ------------------------------------------------------------ @@ -185,7 +185,7 @@ if ($object->id > 0) print ''; - dol_fiche_end(); + print dol_get_fiche_end(); diff --git a/htdocs/mrp/mo_card.php b/htdocs/mrp/mo_card.php index 19adf082458..84484956df8 100644 --- a/htdocs/mrp/mo_card.php +++ b/htdocs/mrp/mo_card.php @@ -230,7 +230,7 @@ if ($action == 'create') print '
    '.$langs->trans("Statistics").' - '.$langs->trans("MO").'
    ' . $langs->trans("Statistics") . ' - ' . $langs->trans("ManufacturingOrder") . '
    '."\n"; - dol_fiche_end(); + print dol_get_fiche_end(); ?> '; - print ''."\n"; + print ''."\n"; } if (!empty($conf->global->MEMBER_NEWFORM_AMOUNT) || !empty($conf->global->MEMBER_NEWFORM_PAYONLINE)) { - // $conf->global->MEMBER_NEWFORM_SHOWAMOUNT is an amount - $amount = 0; - if (!empty($conf->global->MEMBER_NEWFORM_AMOUNT)) { - $amount = $conf->global->MEMBER_NEWFORM_AMOUNT; - } + // $conf->global->MEMBER_NEWFORM_SHOWAMOUNT is an amount + $amount = 0; + if (!empty($conf->global->MEMBER_NEWFORM_AMOUNT)) { + $amount = $conf->global->MEMBER_NEWFORM_AMOUNT; + } - if (!empty($conf->global->MEMBER_NEWFORM_PAYONLINE)) { - $amount = GETPOST('amount') ?GETPOST('amount') : $conf->global->MEMBER_NEWFORM_AMOUNT; - } - // $conf->global->MEMBER_NEWFORM_PAYONLINE is 'paypal', 'paybox' or 'stripe' - print ''.$langs->trans("Subscription").''; - if (!empty($conf->global->MEMBER_NEWFORM_EDITAMOUNT)) { - print ''; - } else { - print ''; - print ''; - } - print ' '.$langs->trans("Currency".$conf->currency); - print ''; + if (!empty($conf->global->MEMBER_NEWFORM_PAYONLINE)) { + $amount = GETPOST('amount') ?GETPOST('amount') : $conf->global->MEMBER_NEWFORM_AMOUNT; + } + // $conf->global->MEMBER_NEWFORM_PAYONLINE is 'paypal', 'paybox' or 'stripe' + print ''.$langs->trans("Subscription").''; + if (!empty($conf->global->MEMBER_NEWFORM_EDITAMOUNT)) { + print ''; + } else { + print ''; + print ''; + } + print ' '.$langs->trans("Currency".$conf->currency); + print ''; } print "\n"; -dol_fiche_end(); +print dol_get_fiche_end(); // Save print '
    '; print ''; if (!empty($backtopage)) { - print '     '; + print '     '; } print '
    '; diff --git a/htdocs/public/onlinesign/newonlinesign.php b/htdocs/public/onlinesign/newonlinesign.php index 7c58d0ef944..1291035760f 100644 --- a/htdocs/public/onlinesign/newonlinesign.php +++ b/htdocs/public/onlinesign/newonlinesign.php @@ -64,11 +64,11 @@ if (empty($source)) $source = 'proposal'; if (!$action) { - if ($source && !$ref) - { - print $langs->trans('ErrorBadParameters')." - ref missing"; - exit; - } + if ($source && !$ref) + { + print $langs->trans('ErrorBadParameters')." - ref missing"; + exit; + } } @@ -83,18 +83,18 @@ $SECUREKEY = GETPOST("securekey"); // Secure key if (!empty($source)) { - $urlok .= 'source='.urlencode($source).'&'; - $urlko .= 'source='.urlencode($source).'&'; + $urlok .= 'source='.urlencode($source).'&'; + $urlko .= 'source='.urlencode($source).'&'; } if (!empty($REF)) { - $urlok .= 'ref='.urlencode($REF).'&'; - $urlko .= 'ref='.urlencode($REF).'&'; + $urlok .= 'ref='.urlencode($REF).'&'; + $urlko .= 'ref='.urlencode($REF).'&'; } if (!empty($SECUREKEY)) { - $urlok .= 'securekey='.urlencode($SECUREKEY).'&'; - $urlko .= 'securekey='.urlencode($SECUREKEY).'&'; + $urlok .= 'securekey='.urlencode($SECUREKEY).'&'; + $urlko .= 'securekey='.urlencode($SECUREKEY).'&'; } if (!empty($entity)) { @@ -114,7 +114,7 @@ $creditor = $mysoc->name; if ($action == 'dosign') { - // TODO + // TODO } @@ -134,12 +134,12 @@ llxHeader($head, $langs->trans("OnlineSignature"), '', '', 0, 0, '', '', '', 'on // Check link validity for param 'source' if (!empty($source) && in_array($ref, array('member_ref', 'contractline_ref', 'invoice_ref', 'order_ref', ''))) { - $langs->load("errors"); - dol_print_error_email('BADREFINONLINESIGNFORM', $langs->trans("ErrorBadLinkSourceSetButBadValueForRef", $source, $ref)); - // End of page - llxFooter(); - $db->close(); - exit; + $langs->load("errors"); + dol_print_error_email('BADREFINONLINESIGNFORM', $langs->trans("ErrorBadLinkSourceSetButBadValueForRef", $source, $ref)); + // End of page + llxFooter(); + $db->close(); + exit; } print ''."\n"; @@ -194,16 +194,16 @@ if ($urllogo) $text = ''; if (!empty($conf->global->ONLINE_SIGN_NEWFORM_TEXT)) { - $langs->load("members"); - $reg = array(); - if (preg_match('/^\((.*)\)$/', $conf->global->ONLINE_SIGN_NEWFORM_TEXT, $reg)) $text .= $langs->trans($reg[1])."
    \n"; - else $text .= $conf->global->ONLINE_SIGN_NEWFORM_TEXT."
    \n"; - $text = '
    '.$text.'
    '."\n"; + $langs->load("members"); + $reg = array(); + if (preg_match('/^\((.*)\)$/', $conf->global->ONLINE_SIGN_NEWFORM_TEXT, $reg)) $text .= $langs->trans($reg[1])."
    \n"; + else $text .= $conf->global->ONLINE_SIGN_NEWFORM_TEXT."
    \n"; + $text = '
    '.$text.'
    '."\n"; } if (empty($text)) { - $text .= '
    '.$langs->trans("WelcomeOnOnlineSignaturePage", $mysoc->name).''."\n"; - $text .= ''.$langs->trans("ThisScreenAllowsYouToSignDocFrom", $creditor).'

    '."\n"; + $text .= '
    '.$langs->trans("WelcomeOnOnlineSignaturePage", $mysoc->name).''."\n"; + $text .= ''.$langs->trans("ThisScreenAllowsYouToSignDocFrom", $creditor).'

    '."\n"; } print $text; @@ -237,9 +237,9 @@ if ($source == 'proposal') // Creditor print ''.$langs->trans("Creditor"); - print ''.$creditor.''; - print ''; - print ''."\n"; + print ''.$creditor.''; + print ''; + print ''."\n"; // Debitor @@ -266,13 +266,13 @@ print ''."\n"; print "\n"; if ($action != 'dosign') { - if ($found && !$error) { - // We are in a management option and no error - } else { - dol_print_error_email('ERRORNEWONLINESIGN'); - } + if ($found && !$error) { + // We are in a management option and no error + } else { + dol_print_error_email('ERRORNEWONLINESIGN'); + } } else { - // Print + // Print } print ''."\n"; diff --git a/htdocs/public/payment/newpayment.php b/htdocs/public/payment/newpayment.php index c188dd1db7a..90ded9e8008 100644 --- a/htdocs/public/payment/newpayment.php +++ b/htdocs/public/payment/newpayment.php @@ -50,6 +50,10 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/payments.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; require_once DOL_DOCUMENT_ROOT.'/societe/class/societeaccount.class.php'; +// Hook to be used by external payment modules (ie Payzen, ...) +include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; +$hookmanager = new HookManager($db); +$hookmanager->initHooks(array('newpayment')); // Load translation files $langs->loadLangs(array("main", "other", "dict", "bills", "companies", "errors", "paybox", "paypal", "stripe")); // File with generic data @@ -202,6 +206,12 @@ if ((empty($paymentmethod) || $paymentmethod == 'stripe') && !empty($conf->strip // Initialize $validpaymentmethod $validpaymentmethod = getValidOnlinePaymentMethods($paymentmethod); +// This hook is used to push to $validpaymentmethod by external payment modules (ie Payzen, ...) +$parameters = [ + 'paymentmethod' => $paymentmethod, + 'validpaymentmethod' => &$validpaymentmethod +]; +$reshook = $hookmanager->executeHooks('doValidatePayment', $parameters, $object, $action); // Check security token $valid = true; @@ -407,42 +417,42 @@ if ($action == 'charge' && !empty($conf->stripe->enabled)) dol_syslog("POST vatnumber = ".$vatnumber, LOG_DEBUG, 0, '_stripe'); $error = 0; - $errormessage = ''; + $errormessage = ''; - // When using the Charge API architecture - if (empty($conf->global->STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION)) - { - try { - $metadata = array( - 'dol_version' => DOL_VERSION, - 'dol_entity' => $conf->entity, - 'dol_company' => $mysoc->name, // Usefull when using multicompany - 'dol_tax_num' => $vatnumber, - 'ipaddress'=> getUserRemoteIP() - ); + // When using the Charge API architecture + if (empty($conf->global->STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION)) + { + try { + $metadata = array( + 'dol_version' => DOL_VERSION, + 'dol_entity' => $conf->entity, + 'dol_company' => $mysoc->name, // Usefull when using multicompany + 'dol_tax_num' => $vatnumber, + 'ipaddress'=> getUserRemoteIP() + ); - if (!empty($thirdparty_id)) $metadata["dol_thirdparty_id"] = $thirdparty_id; + if (!empty($thirdparty_id)) $metadata["dol_thirdparty_id"] = $thirdparty_id; - if ($thirdparty_id > 0) - { - dol_syslog("Search existing Stripe customer profile for thirdparty_id=".$thirdparty_id, LOG_DEBUG, 0, '_stripe'); + if ($thirdparty_id > 0) + { + dol_syslog("Search existing Stripe customer profile for thirdparty_id=".$thirdparty_id, LOG_DEBUG, 0, '_stripe'); - $service = 'StripeTest'; - $servicestatus = 0; - if (!empty($conf->global->STRIPE_LIVE) && !GETPOST('forcesandbox', 'int')) - { - $service = 'StripeLive'; - $servicestatus = 1; - } + $service = 'StripeTest'; + $servicestatus = 0; + if (!empty($conf->global->STRIPE_LIVE) && !GETPOST('forcesandbox', 'int')) + { + $service = 'StripeLive'; + $servicestatus = 1; + } - $thirdparty = new Societe($db); - $thirdparty->fetch($thirdparty_id); + $thirdparty = new Societe($db); + $thirdparty->fetch($thirdparty_id); - // Create Stripe customer - include_once DOL_DOCUMENT_ROOT.'/stripe/class/stripe.class.php'; - $stripe = new Stripe($db); - $stripeacc = $stripe->getStripeAccount($service); - $customer = $stripe->customerStripe($thirdparty, $stripeacc, $servicestatus, 1); + // Create Stripe customer + include_once DOL_DOCUMENT_ROOT.'/stripe/class/stripe.class.php'; + $stripe = new Stripe($db); + $stripeacc = $stripe->getStripeAccount($service); + $customer = $stripe->customerStripe($thirdparty, $stripeacc, $servicestatus, 1); if (empty($customer)) { $error++; @@ -451,51 +461,51 @@ if ($action == 'charge' && !empty($conf->stripe->enabled)) $action = ''; } - // Create Stripe card from Token - if (!$error) - { - if ($savesource) { - $card = $customer->sources->create(array("source" => $stripeToken, "metadata" => $metadata)); - } else { - $card = $stripeToken; - } + // Create Stripe card from Token + if (!$error) + { + if ($savesource) { + $card = $customer->sources->create(array("source" => $stripeToken, "metadata" => $metadata)); + } else { + $card = $stripeToken; + } - if (empty($card)) - { - $error++; - dol_syslog('Failed to create card record', LOG_WARNING, 0, '_stripe'); - setEventMessages('Failed to create card record', null, 'errors'); - $action = ''; - } else { - if (!empty($FULLTAG)) $metadata["FULLTAG"] = $FULLTAG; - if (!empty($dol_id)) $metadata["dol_id"] = $dol_id; - if (!empty($dol_type)) $metadata["dol_type"] = $dol_type; + if (empty($card)) + { + $error++; + dol_syslog('Failed to create card record', LOG_WARNING, 0, '_stripe'); + setEventMessages('Failed to create card record', null, 'errors'); + $action = ''; + } else { + if (!empty($FULLTAG)) $metadata["FULLTAG"] = $FULLTAG; + if (!empty($dol_id)) $metadata["dol_id"] = $dol_id; + if (!empty($dol_type)) $metadata["dol_type"] = $dol_type; - dol_syslog("Create charge on card ".$card->id, LOG_DEBUG, 0, '_stripe'); - $charge = \Stripe\Charge::create(array( - 'amount' => price2num($amountstripe, 'MU'), - 'currency' => $currency, - 'capture' => true, // Charge immediatly - 'description' => 'Stripe payment: '.$FULLTAG.' ref='.$ref, - 'metadata' => $metadata, - 'customer' => $customer->id, - 'source' => $card, - 'statement_descriptor_suffix' => dol_trunc($FULLTAG, 10, 'right', 'UTF-8', 1), // 22 chars that appears on bank receipt (company + description) - ), array("idempotency_key" => "$FULLTAG", "stripe_account" => "$stripeacc")); - // Return $charge = array('id'=>'ch_XXXX', 'status'=>'succeeded|pending|failed', 'failure_code'=>, 'failure_message'=>...) - if (empty($charge)) - { - $error++; - dol_syslog('Failed to charge card', LOG_WARNING, 0, '_stripe'); - setEventMessages('Failed to charge card', null, 'errors'); - $action = ''; - } - } - } - } else { - $vatcleaned = $vatnumber ? $vatnumber : null; + dol_syslog("Create charge on card ".$card->id, LOG_DEBUG, 0, '_stripe'); + $charge = \Stripe\Charge::create(array( + 'amount' => price2num($amountstripe, 'MU'), + 'currency' => $currency, + 'capture' => true, // Charge immediatly + 'description' => 'Stripe payment: '.$FULLTAG.' ref='.$ref, + 'metadata' => $metadata, + 'customer' => $customer->id, + 'source' => $card, + 'statement_descriptor_suffix' => dol_trunc($FULLTAG, 10, 'right', 'UTF-8', 1), // 22 chars that appears on bank receipt (company + description) + ), array("idempotency_key" => "$FULLTAG", "stripe_account" => "$stripeacc")); + // Return $charge = array('id'=>'ch_XXXX', 'status'=>'succeeded|pending|failed', 'failure_code'=>, 'failure_message'=>...) + if (empty($charge)) + { + $error++; + dol_syslog('Failed to charge card', LOG_WARNING, 0, '_stripe'); + setEventMessages('Failed to charge card', null, 'errors'); + $action = ''; + } + } + } + } else { + $vatcleaned = $vatnumber ? $vatnumber : null; - /*$taxinfo = array('type'=>'vat'); + /*$taxinfo = array('type'=>'vat'); if ($vatcleaned) { $taxinfo["tax_id"] = $vatcleaned; @@ -504,18 +514,18 @@ if ($action == 'charge' && !empty($conf->stripe->enabled)) if (empty($vatcleaned)) $taxinfo=null; */ - dol_syslog("Create anonymous customer card profile", LOG_DEBUG, 0, '_stripe'); + dol_syslog("Create anonymous customer card profile", LOG_DEBUG, 0, '_stripe'); - $customer = \Stripe\Customer::create(array( - 'email' => $email, - 'description' => ($email ? 'Anonymous customer for '.$email : 'Anonymous customer'), - 'metadata' => $metadata, - 'source' => $stripeToken // source can be a token OR array('object'=>'card', 'exp_month'=>xx, 'exp_year'=>xxxx, 'number'=>xxxxxxx, 'cvc'=>xxx, 'name'=>'Cardholder's full name', zip ?) - )); - // Return $customer = array('id'=>'cus_XXXX', ...) + $customer = \Stripe\Customer::create(array( + 'email' => $email, + 'description' => ($email ? 'Anonymous customer for '.$email : 'Anonymous customer'), + 'metadata' => $metadata, + 'source' => $stripeToken // source can be a token OR array('object'=>'card', 'exp_month'=>xx, 'exp_year'=>xxxx, 'number'=>xxxxxxx, 'cvc'=>xxx, 'name'=>'Cardholder's full name', zip ?) + )); + // Return $customer = array('id'=>'cus_XXXX', ...) - // Create the VAT record in Stripe - /* We don't know country of customer, so we can't create tax + // Create the VAT record in Stripe + /* We don't know country of customer, so we can't create tax if (! empty($conf->global->STRIPE_SAVE_TAX_IDS)) // We setup to save Tax info on Stripe side. Warning: This may result in error when saving customer { if (! empty($vatcleaned)) @@ -529,145 +539,145 @@ if ($action == 'charge' && !empty($conf->stripe->enabled)) } }*/ - if (!empty($FULLTAG)) $metadata["FULLTAG"] = $FULLTAG; - if (!empty($dol_id)) $metadata["dol_id"] = $dol_id; - if (!empty($dol_type)) $metadata["dol_type"] = $dol_type; + if (!empty($FULLTAG)) $metadata["FULLTAG"] = $FULLTAG; + if (!empty($dol_id)) $metadata["dol_id"] = $dol_id; + if (!empty($dol_type)) $metadata["dol_type"] = $dol_type; - // The customer was just created with a source, so we can make a charge - // with no card defined, the source just used for customer creation will be used. - dol_syslog("Create charge", LOG_DEBUG, 0, '_stripe'); - $charge = \Stripe\Charge::create(array( - 'customer' => $customer->id, - 'amount' => price2num($amountstripe, 'MU'), - 'currency' => $currency, - 'capture' => true, // Charge immediatly - 'description' => 'Stripe payment: '.$FULLTAG.' ref='.$ref, - 'metadata' => $metadata, - 'statement_descriptor' => dol_trunc($FULLTAG, 10, 'right', 'UTF-8', 1), // 22 chars that appears on bank receipt (company + description) - ), array("idempotency_key" => "$FULLTAG", "stripe_account" => "$stripeacc")); - // Return $charge = array('id'=>'ch_XXXX', 'status'=>'succeeded|pending|failed', 'failure_code'=>, 'failure_message'=>...) - if (empty($charge)) - { - $error++; - dol_syslog('Failed to charge card', LOG_WARNING, 0, '_stripe'); - setEventMessages('Failed to charge card', null, 'errors'); - $action = ''; - } - } - } catch (\Stripe\Error\Card $e) { - // Since it's a decline, \Stripe\Error\Card will be caught - $body = $e->getJsonBody(); - $err = $body['error']; + // The customer was just created with a source, so we can make a charge + // with no card defined, the source just used for customer creation will be used. + dol_syslog("Create charge", LOG_DEBUG, 0, '_stripe'); + $charge = \Stripe\Charge::create(array( + 'customer' => $customer->id, + 'amount' => price2num($amountstripe, 'MU'), + 'currency' => $currency, + 'capture' => true, // Charge immediatly + 'description' => 'Stripe payment: '.$FULLTAG.' ref='.$ref, + 'metadata' => $metadata, + 'statement_descriptor' => dol_trunc($FULLTAG, 10, 'right', 'UTF-8', 1), // 22 chars that appears on bank receipt (company + description) + ), array("idempotency_key" => "$FULLTAG", "stripe_account" => "$stripeacc")); + // Return $charge = array('id'=>'ch_XXXX', 'status'=>'succeeded|pending|failed', 'failure_code'=>, 'failure_message'=>...) + if (empty($charge)) + { + $error++; + dol_syslog('Failed to charge card', LOG_WARNING, 0, '_stripe'); + setEventMessages('Failed to charge card', null, 'errors'); + $action = ''; + } + } + } catch (\Stripe\Error\Card $e) { + // Since it's a decline, \Stripe\Error\Card will be caught + $body = $e->getJsonBody(); + $err = $body['error']; - print('Status is:'.$e->getHttpStatus()."\n"); - print('Type is:'.$err['type']."\n"); - print('Code is:'.$err['code']."\n"); - // param is '' in this case - print('Param is:'.$err['param']."\n"); - print('Message is:'.$err['message']."\n"); + print('Status is:'.$e->getHttpStatus()."\n"); + print('Type is:'.$err['type']."\n"); + print('Code is:'.$err['code']."\n"); + // param is '' in this case + print('Param is:'.$err['param']."\n"); + print('Message is:'.$err['message']."\n"); - $error++; - $errormessage = "ErrorCard ".$e->getMessage()." err=".var_export($err, true); - dol_syslog($errormessage, LOG_WARNING, 0, '_stripe'); - setEventMessages($e->getMessage(), null, 'errors'); - $action = ''; - } catch (\Stripe\Error\RateLimit $e) { - // Too many requests made to the API too quickly - $error++; - $errormessage = "ErrorRateLimit ".$e->getMessage(); - dol_syslog($errormessage, LOG_WARNING, 0, '_stripe'); - setEventMessages($e->getMessage(), null, 'errors'); - $action = ''; - } catch (\Stripe\Error\InvalidRequest $e) { - // Invalid parameters were supplied to Stripe's API - $error++; - $errormessage = "ErrorInvalidRequest ".$e->getMessage(); - dol_syslog($errormessage, LOG_WARNING, 0, '_stripe'); - setEventMessages($e->getMessage(), null, 'errors'); - $action = ''; - } catch (\Stripe\Error\Authentication $e) { - // Authentication with Stripe's API failed - // (maybe you changed API keys recently) - $error++; - $errormessage = "ErrorAuthentication ".$e->getMessage(); - dol_syslog($errormessage, LOG_WARNING, 0, '_stripe'); - setEventMessages($e->getMessage(), null, 'errors'); - $action = ''; - } catch (\Stripe\Error\ApiConnection $e) { - // Network communication with Stripe failed - $error++; - $errormessage = "ErrorApiConnection ".$e->getMessage(); - dol_syslog($errormessage, LOG_WARNING, 0, '_stripe'); - setEventMessages($e->getMessage(), null, 'errors'); - $action = ''; - } catch (\Stripe\Error\Base $e) { - // Display a very generic error to the user, and maybe send - // yourself an email - $error++; - $errormessage = "ErrorBase ".$e->getMessage(); - dol_syslog($errormessage, LOG_WARNING, 0, '_stripe'); - setEventMessages($e->getMessage(), null, 'errors'); - $action = ''; - } catch (Exception $e) { - // Something else happened, completely unrelated to Stripe - $error++; - $errormessage = "ErrorException ".$e->getMessage(); - dol_syslog($errormessage, LOG_WARNING, 0, '_stripe'); - setEventMessages($e->getMessage(), null, 'errors'); - $action = ''; - } - } + $error++; + $errormessage = "ErrorCard ".$e->getMessage()." err=".var_export($err, true); + dol_syslog($errormessage, LOG_WARNING, 0, '_stripe'); + setEventMessages($e->getMessage(), null, 'errors'); + $action = ''; + } catch (\Stripe\Error\RateLimit $e) { + // Too many requests made to the API too quickly + $error++; + $errormessage = "ErrorRateLimit ".$e->getMessage(); + dol_syslog($errormessage, LOG_WARNING, 0, '_stripe'); + setEventMessages($e->getMessage(), null, 'errors'); + $action = ''; + } catch (\Stripe\Error\InvalidRequest $e) { + // Invalid parameters were supplied to Stripe's API + $error++; + $errormessage = "ErrorInvalidRequest ".$e->getMessage(); + dol_syslog($errormessage, LOG_WARNING, 0, '_stripe'); + setEventMessages($e->getMessage(), null, 'errors'); + $action = ''; + } catch (\Stripe\Error\Authentication $e) { + // Authentication with Stripe's API failed + // (maybe you changed API keys recently) + $error++; + $errormessage = "ErrorAuthentication ".$e->getMessage(); + dol_syslog($errormessage, LOG_WARNING, 0, '_stripe'); + setEventMessages($e->getMessage(), null, 'errors'); + $action = ''; + } catch (\Stripe\Error\ApiConnection $e) { + // Network communication with Stripe failed + $error++; + $errormessage = "ErrorApiConnection ".$e->getMessage(); + dol_syslog($errormessage, LOG_WARNING, 0, '_stripe'); + setEventMessages($e->getMessage(), null, 'errors'); + $action = ''; + } catch (\Stripe\Error\Base $e) { + // Display a very generic error to the user, and maybe send + // yourself an email + $error++; + $errormessage = "ErrorBase ".$e->getMessage(); + dol_syslog($errormessage, LOG_WARNING, 0, '_stripe'); + setEventMessages($e->getMessage(), null, 'errors'); + $action = ''; + } catch (Exception $e) { + // Something else happened, completely unrelated to Stripe + $error++; + $errormessage = "ErrorException ".$e->getMessage(); + dol_syslog($errormessage, LOG_WARNING, 0, '_stripe'); + setEventMessages($e->getMessage(), null, 'errors'); + $action = ''; + } + } - // When using the PaymentIntent API architecture - if (!empty($conf->global->STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION)) - { - $service = 'StripeTest'; - $servicestatus = 0; - if (!empty($conf->global->STRIPE_LIVE) && !GETPOST('forcesandbox', 'int')) - { - $service = 'StripeLive'; - $servicestatus = 1; - } - include_once DOL_DOCUMENT_ROOT.'/stripe/class/stripe.class.php'; - $stripe = new Stripe($db); - $stripeacc = $stripe->getStripeAccount($service); + // When using the PaymentIntent API architecture + if (!empty($conf->global->STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION)) + { + $service = 'StripeTest'; + $servicestatus = 0; + if (!empty($conf->global->STRIPE_LIVE) && !GETPOST('forcesandbox', 'int')) + { + $service = 'StripeLive'; + $servicestatus = 1; + } + include_once DOL_DOCUMENT_ROOT.'/stripe/class/stripe.class.php'; + $stripe = new Stripe($db); + $stripeacc = $stripe->getStripeAccount($service); - // We go here if $conf->global->STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION is set. - // In such a case, payment is always ok when we call the "charge" action. - $paymentintent_id = GETPOST("paymentintent_id", "alpha"); + // We go here if $conf->global->STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION is set. + // In such a case, payment is always ok when we call the "charge" action. + $paymentintent_id = GETPOST("paymentintent_id", "alpha"); - // Force to use the correct API key - global $stripearrayofkeysbyenv; - \Stripe\Stripe::setApiKey($stripearrayofkeysbyenv[$servicestatus]['secret_key']); + // Force to use the correct API key + global $stripearrayofkeysbyenv; + \Stripe\Stripe::setApiKey($stripearrayofkeysbyenv[$servicestatus]['secret_key']); - try { - if (empty($stripeacc)) { // If the Stripe connect account not set, we use common API usage - $paymentintent = \Stripe\PaymentIntent::retrieve($paymentintent_id); - } else { - $paymentintent = \Stripe\PaymentIntent::retrieve($paymentintent_id, array("stripe_account" => $stripeacc)); - } - } catch (Exception $e) - { - $error++; - $errormessage = "CantRetrievePaymentIntent ".$e->getMessage(); - dol_syslog($errormessage, LOG_WARNING, 0, '_stripe'); - setEventMessages($e->getMessage(), null, 'errors'); - $action = ''; - } + try { + if (empty($stripeacc)) { // If the Stripe connect account not set, we use common API usage + $paymentintent = \Stripe\PaymentIntent::retrieve($paymentintent_id); + } else { + $paymentintent = \Stripe\PaymentIntent::retrieve($paymentintent_id, array("stripe_account" => $stripeacc)); + } + } catch (Exception $e) + { + $error++; + $errormessage = "CantRetrievePaymentIntent ".$e->getMessage(); + dol_syslog($errormessage, LOG_WARNING, 0, '_stripe'); + setEventMessages($e->getMessage(), null, 'errors'); + $action = ''; + } - if ($paymentintent->status != 'succeeded') - { - $error++; - $errormessage = "StatusOfRetrievedIntent is not succeeded: ".$paymentintent->status; - dol_syslog($errormessage, LOG_WARNING, 0, '_stripe'); - setEventMessages($paymentintent->status, null, 'errors'); - $action = ''; - } else { - // TODO We can alse record the payment mode into llx_societe_rib with stripe $paymentintent->payment_method - // Note that with other old Stripe architecture (using Charge API), the payment mode was not recorded, so it is not mandatory to do it here. - //dol_syslog("Create payment_method for ".$paymentintent->payment_method, LOG_DEBUG, 0, '_stripe'); - } - } + if ($paymentintent->status != 'succeeded') + { + $error++; + $errormessage = "StatusOfRetrievedIntent is not succeeded: ".$paymentintent->status; + dol_syslog($errormessage, LOG_WARNING, 0, '_stripe'); + setEventMessages($paymentintent->status, null, 'errors'); + $action = ''; + } else { + // TODO We can alse record the payment mode into llx_societe_rib with stripe $paymentintent->payment_method + // Note that with other old Stripe architecture (using Charge API), the payment mode was not recorded, so it is not mandatory to do it here. + //dol_syslog("Create payment_method for ".$paymentintent->payment_method, LOG_DEBUG, 0, '_stripe'); + } + } $remoteip = getUserRemoteIP(); @@ -717,8 +727,8 @@ if ($source && in_array($ref, array('member_ref', 'contractline_ref', 'invoice_r $langs->load("errors"); dol_print_error_email('BADREFINPAYMENTFORM', $langs->trans("ErrorBadLinkSourceSetButBadValueForRef", $source, $ref)); // End of page - llxFooter(); - $db->close(); + llxFooter(); + $db->close(); exit; } @@ -1384,9 +1394,9 @@ if ($source == 'membersubscription') print ''."\n"; if ($object->datefin > 0) { - print ''.$langs->trans("DateEndSubscription"); - print ''.dol_print_date($member->datefin, 'day'); - print ''."\n"; + print ''.$langs->trans("DateEndSubscription"); + print ''.dol_print_date($member->datefin, 'day'); + print ''."\n"; } if ($member->last_subscription_date || $member->last_subscription_amount) @@ -1641,6 +1651,12 @@ if ($action != 'dopayment') { if ($found && !$error) // We are in a management option and no error { + // Check status of the object (Invoice) to verify if it is paid by external payment modules (ie Payzen, ...) + $parameters = [ + 'source' => $source, + 'object' => $object + ]; + $reshook = $hookmanager->executeHooks('doCheckStatus', $parameters, $object, $action); if ($source == 'order' && $object->billed) { print '

    '.$langs->trans("OrderBilled").''; @@ -1651,16 +1667,21 @@ if ($action != 'dopayment') { print '

    '.$langs->trans("DonationPaid").''; } else { - // Membership can be paid and we still allow to make renewal - if ($source == 'membersubscription' && $object->datefin > dol_now()) - { - $langs->load("members"); - print '
    '.$langs->trans("MembershipPaid", dol_print_date($object->datefin, 'day')).'
    '; - print '
    '.$langs->trans("PaymentWillBeRecordedForNextPeriod").'
    '; - } + // Membership can be paid and we still allow to make renewal + if ($source == 'membersubscription' && $object->datefin > dol_now()) + { + $langs->load("members"); + print '
    '.$langs->trans("MembershipPaid", dol_print_date($object->datefin, 'day')).'
    '; + print '
    '.$langs->trans("PaymentWillBeRecordedForNextPeriod").'
    '; + } // Buttons for all payments registration methods + // This hook is used to add Button to newpayment.php for external payment modules (ie Payzen, ...) + $parameters = [ + 'paymentmethod' => $paymentmethod + ]; + $reshook = $hookmanager->executeHooks('doAddButton', $parameters, $object, $action); if ((empty($paymentmethod) || $paymentmethod == 'paybox') && !empty($conf->paybox->enabled)) { print '
    '; @@ -1841,48 +1862,48 @@ if (preg_match('/^dopayment/', $action)) // If we choosed/click on the payment //if (empty($conf->global->STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION) || ! empty($paymentintent)) //{ - print ' + print ' '; - print '
    '; - if (!empty($conf->global->STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION)) - { - print '
    '; - } + if (!empty($conf->global->STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION)) + { + print '
    '; + } - print '
    '; - print ''; + print '
    '; + print ''; - if (!empty($conf->global->STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION)) - { - print '
    '; - } + if (!empty($conf->global->STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION)) + { + print '
    '; + } - print '
    + print '
    '; - print ' + print '
    '; - print '
    '; - print ''; - print ''; + print '
    '; + print ''; + print ''; - print '
    '; + print ''; + print ''; //} if (!empty($conf->global->STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION)) { - if (empty($paymentintent)) - { - print '
    '.$langs->trans("Error").'
    '; - } else { - print ''; - //$_SESSION["paymentintent_id"] = $paymentintent->id; - } + if (empty($paymentintent)) + { + print '
    '.$langs->trans("Error").'
    '; + } else { + print ''; + //$_SESSION["paymentintent_id"] = $paymentintent->id; + } } print ''."\n"; @@ -1895,71 +1916,71 @@ if (preg_match('/^dopayment/', $action)) // If we choosed/click on the payment print info_admin($langs->trans("ErrorModuleSetupNotComplete", $langs->transnoentitiesnoconv("Stripe")), 0, 0, 'error'); } else { print ''; - print ''."\n"; - print ''."\n"; + print ''."\n"; + print ''."\n"; - // Code to ask the credit card. This use the default "API version". No way to force API version when using JS code. - print ''; + print ''; } } + // This hook is used to show the embedded form to make payments with external payment modules (ie Payzen, ...) + $parameters = [ + 'paymentmethod' => $paymentmethod, + 'amount' => price2num(GETPOST("newamount"), 'MT'), + 'tag' => GETPOST("tag", 'alpha'), + 'dopayment' => GETPOST('dopayment', 'alpha') + ]; + $reshook = $hookmanager->executeHooks('doPayment', $parameters, $object, $action); } diff --git a/htdocs/public/recruitment/index.php b/htdocs/public/recruitment/index.php index a5be30aab49..504ecadfc71 100644 --- a/htdocs/public/recruitment/index.php +++ b/htdocs/public/recruitment/index.php @@ -22,15 +22,15 @@ */ if (!defined('NOCSRFCHECK')) { - define('NOCSRFCHECK', '1'); + define('NOCSRFCHECK', '1'); } // Do not check anti CSRF attack test if (!defined('NOREQUIREMENU')) { - define('NOREQUIREMENU', '1'); + define('NOREQUIREMENU', '1'); } // If there is no need to load and show top and left menu if (!defined("NOLOGIN")) { - define("NOLOGIN", '1'); + define("NOLOGIN", '1'); } if (!defined('NOIPCHECK')) define('NOIPCHECK', '1'); // Do not check IP defined into conf $dolibarr_main_restrict_ip if (!defined('NOBROWSERNOTIF')) define('NOBROWSERNOTIF', '1'); diff --git a/htdocs/public/ticket/create_ticket.php b/htdocs/public/ticket/create_ticket.php index 91ce8993bef..bd7b5416efb 100644 --- a/htdocs/public/ticket/create_ticket.php +++ b/htdocs/public/ticket/create_ticket.php @@ -69,7 +69,7 @@ $parameters = array( // Note that $action and $object may have been modified by some hooks $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); if ($reshook < 0) { - setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); } // Add file in email form if (empty($reshook) && GETPOST('addfile', 'alpha') && !GETPOST('add', 'alpha')) { diff --git a/htdocs/reception/card.php b/htdocs/reception/card.php index 450dc1ebd57..12eeb364cde 100644 --- a/htdocs/reception/card.php +++ b/htdocs/reception/card.php @@ -425,7 +425,7 @@ if (empty($reshook)) $datedelivery = dol_mktime(GETPOST('liv_hour', 'int'), GETPOST('liv_min', 'int'), 0, GETPOST('liv_month', 'int'), GETPOST('liv_day', 'int'), GETPOST('liv_year', 'int')); $object->fetch($id); - $result = $object->set_delivery_date($user, $datedelivery); + $result = $object->setDeliveryDate($user, $datedelivery); if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); @@ -873,7 +873,7 @@ if ($action == 'create') print ""; - dol_fiche_end(); + print dol_get_fiche_end(); // Reception lines @@ -1949,7 +1949,7 @@ if ($action == 'create') } - dol_fiche_end(); + print dol_get_fiche_end(); $object->fetchObjectLinked($object->id, $object->element); @@ -2176,7 +2176,7 @@ if ($action == 'create') } // Show form print $formmail->get_form(); - dol_fiche_end(); + print dol_get_fiche_end(); } } diff --git a/htdocs/reception/class/reception.class.php b/htdocs/reception/class/reception.class.php index 0a2458f57a6..25690279f71 100644 --- a/htdocs/reception/class/reception.class.php +++ b/htdocs/reception/class/reception.class.php @@ -1018,12 +1018,12 @@ class Reception extends CommonObject if (!empty($resql)) { $this->lines = array(); - while ($obj = $resql->fetch_object()) { + while ($obj = $this->db->fetch_object($resql)) { $line = new CommandeFournisseurDispatch($this->db); $line->fetch($obj->rowid); $line->fetch_product(); $sql_commfourndet = 'SELECT qty, ref, label, tva_tx, vat_src_code, subprice, multicurrency_subprice, remise_percent FROM llx_commande_fournisseurdet WHERE rowid='.$line->fk_commandefourndet; - $resql_commfourndet = $db->query($sql_commfourndet); + $resql_commfourndet = $this->db->query($sql_commfourndet); if (!empty($resql_commfourndet)) { $obj = $this->db->fetch_object($resql_commfourndet); $line->qty_asked = $obj->qty; @@ -1219,15 +1219,14 @@ class Reception extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** + /** * Set the planned delivery date * * @param User $user Objet utilisateur qui modifie * @param integer $delivery_date Delivery date * @return int <0 if KO, >0 if OK */ - public function set_delivery_date($user, $delivery_date) + public function setDeliveryDate($user, $delivery_date) { // phpcs:enable if ($user->rights->reception->creer) @@ -1236,7 +1235,7 @@ class Reception extends CommonObject $sql .= " SET date_delivery = ".($delivery_date ? "'".$this->db->idate($delivery_date)."'" : 'null'); $sql .= " WHERE rowid = ".$this->id; - dol_syslog(get_class($this)."::set_delivery_date", LOG_DEBUG); + dol_syslog(get_class($this)."::setDeliveryDate", LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) { diff --git a/htdocs/reception/contact.php b/htdocs/reception/contact.php index 1b5d26c80ee..8d4dcd49a9e 100644 --- a/htdocs/reception/contact.php +++ b/htdocs/reception/contact.php @@ -252,7 +252,7 @@ if ($id > 0 || !empty($ref)) print '
    '; - dol_fiche_end(); + print dol_get_fiche_end(); // Lines of contacts echo '
    '; diff --git a/htdocs/reception/note.php b/htdocs/reception/note.php index 1faea564844..2bbbfad60f5 100644 --- a/htdocs/reception/note.php +++ b/htdocs/reception/note.php @@ -155,7 +155,7 @@ if ($id > 0 || !empty($ref)) $cssclass = 'titlefield'; include DOL_DOCUMENT_ROOT.'/core/tpl/notes.tpl.php'; - dol_fiche_end(); + print dol_get_fiche_end(); } diff --git a/htdocs/reception/stats/index.php b/htdocs/reception/stats/index.php index 62df437b26e..ce1486cf5c0 100644 --- a/htdocs/reception/stats/index.php +++ b/htdocs/reception/stats/index.php @@ -301,7 +301,7 @@ print ''; print '
    '; print '
    '; -dol_fiche_end(); +print dol_get_fiche_end(); diff --git a/htdocs/recruitment/admin/candidature_extrafields.php b/htdocs/recruitment/admin/candidature_extrafields.php index 573e40f2850..1d9e567da9d 100644 --- a/htdocs/recruitment/admin/candidature_extrafields.php +++ b/htdocs/recruitment/admin/candidature_extrafields.php @@ -69,7 +69,7 @@ print dol_get_fiche_head($head, 'candidature_extrafields', '', -1, ''); require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php'; -dol_fiche_end(); +print dol_get_fiche_end(); // Buttons diff --git a/htdocs/recruitment/admin/jobposition_extrafields.php b/htdocs/recruitment/admin/jobposition_extrafields.php index 9a4b12ed8b7..af7a7c316a7 100644 --- a/htdocs/recruitment/admin/jobposition_extrafields.php +++ b/htdocs/recruitment/admin/jobposition_extrafields.php @@ -69,7 +69,7 @@ print dol_get_fiche_head($head, 'jobposition_extrafields', '', -1, ''); require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php'; -dol_fiche_end(); +print dol_get_fiche_end(); // Buttons diff --git a/htdocs/recruitment/admin/public_interface.php b/htdocs/recruitment/admin/public_interface.php index 88862782825..02bb78562d3 100644 --- a/htdocs/recruitment/admin/public_interface.php +++ b/htdocs/recruitment/admin/public_interface.php @@ -165,7 +165,7 @@ if (!empty($conf->global->RECRUITMENT_ENABLE_PUBLIC_INTERFACE)) { } */ -dol_fiche_end(); +print dol_get_fiche_end(); print ''; diff --git a/htdocs/recruitment/admin/setup.php b/htdocs/recruitment/admin/setup.php index c6194478a20..5accf86c5c4 100644 --- a/htdocs/recruitment/admin/setup.php +++ b/htdocs/recruitment/admin/setup.php @@ -517,7 +517,7 @@ if (empty($setupnotempty)) { } // Page end -dol_fiche_end(); +print dol_get_fiche_end(); llxFooter(); $db->close(); diff --git a/htdocs/recruitment/admin/setup_candidatures.php b/htdocs/recruitment/admin/setup_candidatures.php index 47c3ec9def8..78b6130bd5e 100644 --- a/htdocs/recruitment/admin/setup_candidatures.php +++ b/htdocs/recruitment/admin/setup_candidatures.php @@ -517,7 +517,7 @@ if (empty($setupnotempty)) { } // Page end -dol_fiche_end(); +print dol_get_fiche_end(); llxFooter(); $db->close(); diff --git a/htdocs/recruitment/class/recruitmentjobposition.class.php b/htdocs/recruitment/class/recruitmentjobposition.class.php index 6e27164ba23..ffe2a1373e8 100644 --- a/htdocs/recruitment/class/recruitmentjobposition.class.php +++ b/htdocs/recruitment/class/recruitmentjobposition.class.php @@ -57,7 +57,7 @@ class RecruitmentJobPosition extends CommonObject */ public $isextrafieldmanaged = 1; - /** + /** * @var string String with name of icon for recruitmentjobposition. Must be the part after the 'object_' into object_recruitmentjobposition.png */ public $picto = 'recruitmentjobposition'; @@ -126,30 +126,30 @@ class RecruitmentJobPosition extends CommonObject ); public $rowid; - /** - * @var string ref - */ + /** + * @var string ref + */ public $ref; public $entity; - /** - * @var string label - */ + /** + * @var string label + */ public $label; public $qty; public $fk_soc; public $fk_project; public $fk_user_recruiter; - /** - * @var string recruiter email - */ - public $email_recruiter; + /** + * @var string recruiter email + */ + public $email_recruiter; - /** - * @var string suggested remuneration - */ - public $remuneration_suggested; + /** + * @var string suggested remuneration + */ + public $remuneration_suggested; public $fk_user_supervisor; public $fk_establishment; diff --git a/htdocs/recruitment/core/modules/recruitment/doc/doc_generic_recruitmentjobposition_odt.modules.php b/htdocs/recruitment/core/modules/recruitment/doc/doc_generic_recruitmentjobposition_odt.modules.php index eedc3fbc7c8..6e9788c2e9f 100644 --- a/htdocs/recruitment/core/modules/recruitment/doc/doc_generic_recruitmentjobposition_odt.modules.php +++ b/htdocs/recruitment/core/modules/recruitment/doc/doc_generic_recruitmentjobposition_odt.modules.php @@ -316,7 +316,7 @@ class doc_generic_recruitmentjobposition_odt extends ModelePDFRecruitmentJobPosi '__FROM_EMAIL__' => $this->emetteur->email, '__TOTAL_TTC__' => $object->total_ttc, '__TOTAL_HT__' => $object->total_ht, - '__TOTAL_VAT__' => $object->total_vat + '__TOTAL_VAT__' => $object->total_tva ); complete_substitutions_array($substitutionarray, $langs, $object); // Call the ODTSubstitution hook diff --git a/htdocs/recruitment/recruitmentcandidature_agenda.php b/htdocs/recruitment/recruitmentcandidature_agenda.php index 79357cd0eb5..c125a14c647 100644 --- a/htdocs/recruitment/recruitmentcandidature_agenda.php +++ b/htdocs/recruitment/recruitmentcandidature_agenda.php @@ -195,7 +195,7 @@ if ($object->id > 0) print ''; - dol_fiche_end(); + print dol_get_fiche_end(); diff --git a/htdocs/recruitment/recruitmentcandidature_card.php b/htdocs/recruitment/recruitmentcandidature_card.php index 7d06ce4e342..380b3da7729 100644 --- a/htdocs/recruitment/recruitmentcandidature_card.php +++ b/htdocs/recruitment/recruitmentcandidature_card.php @@ -231,7 +231,7 @@ if ($action == 'create') print ''."\n"; - dol_fiche_end(); + print dol_get_fiche_end(); print '
    '; print ''; @@ -268,7 +268,7 @@ if (($id || $ref) && $action == 'edit') print ''; - dol_fiche_end(); + print dol_get_fiche_end(); print '
    '; print '   '; @@ -396,7 +396,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print '
    '; - dol_fiche_end(); + print dol_get_fiche_end(); /* diff --git a/htdocs/recruitment/recruitmentcandidature_document.php b/htdocs/recruitment/recruitmentcandidature_document.php index c051ee1f223..cd8e24118fc 100644 --- a/htdocs/recruitment/recruitmentcandidature_document.php +++ b/htdocs/recruitment/recruitmentcandidature_document.php @@ -186,7 +186,7 @@ if ($object->id) print '
    '; - dol_fiche_end(); + print dol_get_fiche_end(); $modulepart = 'recruitment'; $permission = $user->rights->recruitment->recruitmentjobposition->write; diff --git a/htdocs/recruitment/recruitmentcandidature_note.php b/htdocs/recruitment/recruitmentcandidature_note.php index 16931c34d92..c0673b35c52 100644 --- a/htdocs/recruitment/recruitmentcandidature_note.php +++ b/htdocs/recruitment/recruitmentcandidature_note.php @@ -155,7 +155,7 @@ if ($id > 0 || !empty($ref)) print '
    '; - dol_fiche_end(); + print dol_get_fiche_end(); } // End of page diff --git a/htdocs/recruitment/recruitmentjobposition_agenda.php b/htdocs/recruitment/recruitmentjobposition_agenda.php index 43f9a2990c3..4e9a717f4fe 100644 --- a/htdocs/recruitment/recruitmentjobposition_agenda.php +++ b/htdocs/recruitment/recruitmentjobposition_agenda.php @@ -195,7 +195,7 @@ if ($object->id > 0) print ''; - dol_fiche_end(); + print dol_get_fiche_end(); diff --git a/htdocs/recruitment/recruitmentjobposition_candidature.php b/htdocs/recruitment/recruitmentjobposition_candidature.php index e5870f8b76c..dbafdb3a423 100644 --- a/htdocs/recruitment/recruitmentjobposition_candidature.php +++ b/htdocs/recruitment/recruitmentjobposition_candidature.php @@ -214,7 +214,7 @@ if ($action == 'create') print ''."\n"; - dol_fiche_end(); + print dol_get_fiche_end(); print '
    '; print ''; @@ -251,7 +251,7 @@ if (($id || $ref) && $action == 'edit') print ''; - dol_fiche_end(); + print dol_get_fiche_end(); print '
    '; print '   '; @@ -382,7 +382,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print '
    '; - dol_fiche_end(); + print dol_get_fiche_end(); /* diff --git a/htdocs/recruitment/recruitmentjobposition_card.php b/htdocs/recruitment/recruitmentjobposition_card.php index bb9d5235a35..35edbefcec7 100644 --- a/htdocs/recruitment/recruitmentjobposition_card.php +++ b/htdocs/recruitment/recruitmentjobposition_card.php @@ -242,7 +242,7 @@ if ($action == 'create') print ''."\n"; - dol_fiche_end(); + print dol_get_fiche_end(); print '
    '; print ''; @@ -279,7 +279,7 @@ if (($id || $ref) && $action == 'edit') print ''; - dol_fiche_end(); + print dol_get_fiche_end(); print '
    '; print '   '; @@ -412,7 +412,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print '
    '; - dol_fiche_end(); + print dol_get_fiche_end(); /* diff --git a/htdocs/recruitment/recruitmentjobposition_document.php b/htdocs/recruitment/recruitmentjobposition_document.php index 7cdaf187a18..c05f1adce6f 100644 --- a/htdocs/recruitment/recruitmentjobposition_document.php +++ b/htdocs/recruitment/recruitmentjobposition_document.php @@ -186,7 +186,7 @@ if ($object->id) print '
    '; - dol_fiche_end(); + print dol_get_fiche_end(); $modulepart = 'recruitment'; $permission = $user->rights->recruitment->recruitmentjobposition->write; diff --git a/htdocs/recruitment/recruitmentjobposition_note.php b/htdocs/recruitment/recruitmentjobposition_note.php index 8b9e0c4a7a9..96154272fcf 100644 --- a/htdocs/recruitment/recruitmentjobposition_note.php +++ b/htdocs/recruitment/recruitmentjobposition_note.php @@ -155,7 +155,7 @@ if ($id > 0 || !empty($ref)) print '
    '; - dol_fiche_end(); + print dol_get_fiche_end(); } // End of page diff --git a/htdocs/resource/agenda.php b/htdocs/resource/agenda.php index ffc8fd50137..0e20a896190 100644 --- a/htdocs/resource/agenda.php +++ b/htdocs/resource/agenda.php @@ -148,7 +148,7 @@ if ($object->id > 0) print '
    '; - dol_fiche_end(); + print dol_get_fiche_end(); if (!empty($conf->agenda->enabled) && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read))) { diff --git a/htdocs/resource/card.php b/htdocs/resource/card.php index c9c060c1cff..5bf2619c171 100644 --- a/htdocs/resource/card.php +++ b/htdocs/resource/card.php @@ -265,7 +265,7 @@ if ($action == 'create' || $object->fetch($id, $ref) > 0) print ''; - dol_fiche_end(); + print dol_get_fiche_end(); print '
    '; print ''; @@ -340,7 +340,7 @@ if ($action == 'create' || $object->fetch($id, $ref) > 0) print '

    '; - dol_fiche_end(); + print dol_get_fiche_end(); } diff --git a/htdocs/resource/class/dolresource.class.php b/htdocs/resource/class/dolresource.class.php index d392375fdd0..ef4252f41df 100644 --- a/htdocs/resource/class/dolresource.class.php +++ b/htdocs/resource/class/dolresource.class.php @@ -52,8 +52,8 @@ class Dolresource extends CommonObject public $mandatory; /** - * @var int ID - */ + * @var int ID + */ public $fk_user_create; public $type_label; @@ -63,75 +63,75 @@ class Dolresource extends CommonObject public $oldcopy; - /** - * Constructor - * - * @param DoliDb $db Database handler - */ - public function __construct($db) - { - $this->db = $db; - } + /** + * Constructor + * + * @param DoliDb $db Database handler + */ + public function __construct($db) + { + $this->db = $db; + } - /** - * Create object into database - * - * @param User $user User that creates - * @param int $notrigger 0=launch triggers after, 1=disable triggers - * @return int <0 if KO, Id of created object if OK - */ - public function create($user, $notrigger = 0) - { - global $conf, $langs, $hookmanager; - $error = 0; + /** + * Create object into database + * + * @param User $user User that creates + * @param int $notrigger 0=launch triggers after, 1=disable triggers + * @return int <0 if KO, Id of created object if OK + */ + public function create($user, $notrigger = 0) + { + global $conf, $langs, $hookmanager; + $error = 0; - // Clean parameters + // Clean parameters - if (isset($this->ref)) $this->ref = trim($this->ref); - if (isset($this->description)) $this->description = trim($this->description); - if (!is_numeric($this->country_id)) $this->country_id = 0; - if (isset($this->fk_code_type_resource)) $this->fk_code_type_resource = trim($this->fk_code_type_resource); - if (isset($this->note_public)) $this->note_public = trim($this->note_public); - if (isset($this->note_private)) $this->note_private = trim($this->note_private); + if (isset($this->ref)) $this->ref = trim($this->ref); + if (isset($this->description)) $this->description = trim($this->description); + if (!is_numeric($this->country_id)) $this->country_id = 0; + if (isset($this->fk_code_type_resource)) $this->fk_code_type_resource = trim($this->fk_code_type_resource); + if (isset($this->note_public)) $this->note_public = trim($this->note_public); + if (isset($this->note_private)) $this->note_private = trim($this->note_private); - // Insert request - $sql = "INSERT INTO ".MAIN_DB_PREFIX.$this->table_element."("; - $sql .= "entity,"; - $sql .= "ref,"; - $sql .= "description,"; - $sql .= "fk_country,"; - $sql .= "fk_code_type_resource,"; - $sql .= "note_public,"; - $sql .= "note_private"; - $sql .= ") VALUES ("; - $sql .= $conf->entity.", "; - $sql .= " ".(!isset($this->ref) ? 'NULL' : "'".$this->db->escape($this->ref)."'").","; - $sql .= " ".(!isset($this->description) ? 'NULL' : "'".$this->db->escape($this->description)."'").","; - $sql .= " ".($this->country_id > 0 ? $this->country_id : 'null').","; - $sql .= " ".(!isset($this->fk_code_type_resource) ? 'NULL' : "'".$this->db->escape($this->fk_code_type_resource)."'").","; - $sql .= " ".(!isset($this->note_public) ? 'NULL' : "'".$this->db->escape($this->note_public)."'").","; - $sql .= " ".(!isset($this->note_private) ? 'NULL' : "'".$this->db->escape($this->note_private)."'"); - $sql .= ")"; + // Insert request + $sql = "INSERT INTO ".MAIN_DB_PREFIX.$this->table_element."("; + $sql .= "entity,"; + $sql .= "ref,"; + $sql .= "description,"; + $sql .= "fk_country,"; + $sql .= "fk_code_type_resource,"; + $sql .= "note_public,"; + $sql .= "note_private"; + $sql .= ") VALUES ("; + $sql .= $conf->entity.", "; + $sql .= " ".(!isset($this->ref) ? 'NULL' : "'".$this->db->escape($this->ref)."'").","; + $sql .= " ".(!isset($this->description) ? 'NULL' : "'".$this->db->escape($this->description)."'").","; + $sql .= " ".($this->country_id > 0 ? $this->country_id : 'null').","; + $sql .= " ".(!isset($this->fk_code_type_resource) ? 'NULL' : "'".$this->db->escape($this->fk_code_type_resource)."'").","; + $sql .= " ".(!isset($this->note_public) ? 'NULL' : "'".$this->db->escape($this->note_public)."'").","; + $sql .= " ".(!isset($this->note_private) ? 'NULL' : "'".$this->db->escape($this->note_private)."'"); + $sql .= ")"; - $this->db->begin(); + $this->db->begin(); - dol_syslog(get_class($this)."::create", LOG_DEBUG); - $resql = $this->db->query($sql); - if (!$resql) { - $error++; $this->errors[] = "Error ".$this->db->lasterror(); - } + dol_syslog(get_class($this)."::create", LOG_DEBUG); + $resql = $this->db->query($sql); + if (!$resql) { + $error++; $this->errors[] = "Error ".$this->db->lasterror(); + } - if (!$error) - { - $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX.$this->table_element); - } + if (!$error) + { + $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX.$this->table_element); + } - if (!$error) - { - $action = 'create'; + if (!$error) + { + $action = 'create'; - // Actions on extra fields + // Actions on extra fields if (!$error) { $result = $this->insertExtraFields(); @@ -139,100 +139,100 @@ class Dolresource extends CommonObject { $error++; } - } - } + } + } - if (!$error && !$notrigger) - { - // Call trigger - $result = $this->call_trigger('RESOURCE_CREATE', $user); - if ($result < 0) $error++; - // End call triggers - } + if (!$error && !$notrigger) + { + // Call trigger + $result = $this->call_trigger('RESOURCE_CREATE', $user); + if ($result < 0) $error++; + // End call triggers + } - // Commit or rollback - if ($error) - { - foreach ($this->errors as $errmsg) - { - dol_syslog(get_class($this)."::create ".$errmsg, LOG_ERR); - $this->error .= ($this->error ? ', '.$errmsg : $errmsg); - } - $this->db->rollback(); - return -1 * $error; - } else { - $this->db->commit(); - return $this->id; - } - } + // Commit or rollback + if ($error) + { + foreach ($this->errors as $errmsg) + { + dol_syslog(get_class($this)."::create ".$errmsg, LOG_ERR); + $this->error .= ($this->error ? ', '.$errmsg : $errmsg); + } + $this->db->rollback(); + return -1 * $error; + } else { + $this->db->commit(); + return $this->id; + } + } - /** - * Load object in memory from database - * - * @param int $id Id of object - * @param string $ref Ref of object - * @return int <0 if KO, >0 if OK - */ - public function fetch($id, $ref = '') - { - global $langs; - $sql = "SELECT"; - $sql .= " t.rowid,"; - $sql .= " t.entity,"; - $sql .= " t.ref,"; - $sql .= " t.description,"; + /** + * Load object in memory from database + * + * @param int $id Id of object + * @param string $ref Ref of object + * @return int <0 if KO, >0 if OK + */ + public function fetch($id, $ref = '') + { + global $langs; + $sql = "SELECT"; + $sql .= " t.rowid,"; + $sql .= " t.entity,"; + $sql .= " t.ref,"; + $sql .= " t.description,"; $sql .= " t.fk_country,"; - $sql .= " t.fk_code_type_resource,"; - $sql .= " t.note_public,"; - $sql .= " t.note_private,"; - $sql .= " t.tms,"; - $sql .= " ty.label as type_label"; - $sql .= " FROM ".MAIN_DB_PREFIX.$this->table_element." as t"; - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_type_resource as ty ON ty.code=t.fk_code_type_resource"; - if ($id) $sql .= " WHERE t.rowid = ".$this->db->escape($id); - else $sql .= " WHERE t.ref = '".$this->db->escape($ref)."'"; + $sql .= " t.fk_code_type_resource,"; + $sql .= " t.note_public,"; + $sql .= " t.note_private,"; + $sql .= " t.tms,"; + $sql .= " ty.label as type_label"; + $sql .= " FROM ".MAIN_DB_PREFIX.$this->table_element." as t"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_type_resource as ty ON ty.code=t.fk_code_type_resource"; + if ($id) $sql .= " WHERE t.rowid = ".$this->db->escape($id); + else $sql .= " WHERE t.ref = '".$this->db->escape($ref)."'"; - dol_syslog(get_class($this)."::fetch", LOG_DEBUG); - $resql = $this->db->query($sql); - if ($resql) - { - if ($this->db->num_rows($resql)) - { - $obj = $this->db->fetch_object($resql); + dol_syslog(get_class($this)."::fetch", LOG_DEBUG); + $resql = $this->db->query($sql); + if ($resql) + { + if ($this->db->num_rows($resql)) + { + $obj = $this->db->fetch_object($resql); - $this->id = $obj->rowid; - $this->entity = $obj->entity; - $this->ref = $obj->ref; - $this->description = $obj->description; - $this->country_id = $obj->fk_country; - $this->fk_code_type_resource = $obj->fk_code_type_resource; - $this->note_public = $obj->note_public; - $this->note_private = $obj->note_private; - $this->type_label = $obj->type_label; + $this->id = $obj->rowid; + $this->entity = $obj->entity; + $this->ref = $obj->ref; + $this->description = $obj->description; + $this->country_id = $obj->fk_country; + $this->fk_code_type_resource = $obj->fk_code_type_resource; + $this->note_public = $obj->note_public; + $this->note_private = $obj->note_private; + $this->type_label = $obj->type_label; - // Retrieve all extrafield - // fetch optionals attributes and labels - $this->fetch_optionals(); - } - $this->db->free($resql); + // Retrieve all extrafield + // fetch optionals attributes and labels + $this->fetch_optionals(); + } + $this->db->free($resql); - return $this->id; - } else { - $this->error = "Error ".$this->db->lasterror(); - dol_syslog(get_class($this)."::fetch ".$this->error, LOG_ERR); - return -1; - } - } + return $this->id; + } else { + $this->error = "Error ".$this->db->lasterror(); + dol_syslog(get_class($this)."::fetch ".$this->error, LOG_ERR); + return -1; + } + } - /** - * Update object into database - * - * @param User $user User that modifies - * @param int $notrigger 0=launch triggers after, 1=disable triggers - * @return int <0 if KO, >0 if OK - */ - public function update($user = null, $notrigger = 0) + /** + * Update object into database + * + * @param User $user User that modifies + * @param int $notrigger 0=launch triggers after, 1=disable triggers + * @return int <0 if KO, >0 if OK + */ + public function update($user = null, $notrigger = 0) { global $conf, $langs, $hookmanager; $error = 0; @@ -241,7 +241,7 @@ class Dolresource extends CommonObject if (isset($this->ref)) $this->ref = trim($this->ref); if (isset($this->fk_code_type_resource)) $this->fk_code_type_resource = trim($this->fk_code_type_resource); if (isset($this->description)) $this->description = trim($this->description); - if (!is_numeric($this->country_id)) $this->country_id = 0; + if (!is_numeric($this->country_id)) $this->country_id = 0; if (empty($this->oldcopy)) { @@ -327,19 +327,19 @@ class Dolresource extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Load object in memory from database - * - * @param int $id id object - * @return int <0 if KO, >0 if OK - */ - public function fetch_element_resource($id) - { - // phpcs:enable - global $langs; - $sql = "SELECT"; - $sql .= " t.rowid,"; + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Load object in memory from database + * + * @param int $id id object + * @return int <0 if KO, >0 if OK + */ + public function fetch_element_resource($id) + { + // phpcs:enable + global $langs; + $sql = "SELECT"; + $sql .= " t.rowid,"; $sql .= " t.resource_id,"; $sql .= " t.resource_type,"; $sql .= " t.element_id,"; @@ -349,24 +349,24 @@ class Dolresource extends CommonObject $sql .= " t.fk_user_create,"; $sql .= " t.tms"; $sql .= " FROM ".MAIN_DB_PREFIX."element_resources as t"; - $sql .= " WHERE t.rowid = ".$this->db->escape($id); + $sql .= " WHERE t.rowid = ".$this->db->escape($id); - dol_syslog(get_class($this)."::fetch", LOG_DEBUG); - $resql = $this->db->query($sql); - if ($resql) - { - if ($this->db->num_rows($resql)) - { - $obj = $this->db->fetch_object($resql); + dol_syslog(get_class($this)."::fetch", LOG_DEBUG); + $resql = $this->db->query($sql); + if ($resql) + { + if ($this->db->num_rows($resql)) + { + $obj = $this->db->fetch_object($resql); - $this->id = $obj->rowid; - $this->resource_id = $obj->resource_id; - $this->resource_type = $obj->resource_type; - $this->element_id = $obj->element_id; - $this->element_type = $obj->element_type; - $this->busy = $obj->busy; - $this->mandatory = $obj->mandatory; - $this->fk_user_create = $obj->fk_user_create; + $this->id = $obj->rowid; + $this->resource_id = $obj->resource_id; + $this->resource_type = $obj->resource_type; + $this->element_id = $obj->element_id; + $this->element_type = $obj->element_type; + $this->busy = $obj->busy; + $this->mandatory = $obj->mandatory; + $this->fk_user_create = $obj->fk_user_create; if ($obj->resource_id && $obj->resource_type) { $this->objresource = fetchObjectByElement($obj->resource_id, $obj->resource_type); @@ -374,27 +374,27 @@ class Dolresource extends CommonObject if ($obj->element_id && $obj->element_type) { $this->objelement = fetchObjectByElement($obj->element_id, $obj->element_type); } - } - $this->db->free($resql); + } + $this->db->free($resql); - return $this->id; - } else { - $this->error = "Error ".$this->db->lasterror(); - return -1; - } - } + return $this->id; + } else { + $this->error = "Error ".$this->db->lasterror(); + return -1; + } + } - /** - * Delete a resource object - * - * @param int $rowid Id of resource line to delete - * @param int $notrigger Disable all triggers - * @return int >0 if OK, <0 if KO - */ - public function delete($rowid, $notrigger = 0) + /** + * Delete a resource object + * + * @param int $rowid Id of resource line to delete + * @param int $notrigger Disable all triggers + * @return int >0 if OK, <0 if KO + */ + public function delete($rowid, $notrigger = 0) { global $user, $langs, $conf; - require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; + require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; $error = 0; @@ -467,108 +467,108 @@ class Dolresource extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Load resource objects into $this->lines - * - * @param string $sortorder sort order - * @param string $sortfield sort field - * @param int $limit limit page - * @param int $offset page - * @param array $filter filter output - * @return int <0 if KO, >0 if OK - */ - public function fetch_all($sortorder, $sortfield, $limit, $offset, $filter = '') - { - // phpcs:enable - global $conf; - - require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; - $extrafields = new ExtraFields($this->db); - - $sql = "SELECT "; - $sql .= " t.rowid,"; - $sql .= " t.entity,"; - $sql .= " t.ref,"; - $sql .= " t.description,"; - $sql .= " t.fk_code_type_resource,"; - $sql .= " t.tms,"; - // Add fields from extrafields - if (!empty($extrafields->attributes[$this->table_element]['label'])) - foreach ($extrafields->attributes[$this->table_element]['label'] as $key => $val) $sql .= ($extrafields->attributes[$this->table_element]['type'][$key] != 'separate' ? "ef.".$key.' as options_'.$key.', ' : ''); - $sql .= " ty.label as type_label"; - $sql .= " FROM ".MAIN_DB_PREFIX.$this->table_element." as t"; - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_type_resource as ty ON ty.code=t.fk_code_type_resource"; - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$this->table_element."_extrafields as ef ON ef.fk_object=t.rowid"; - $sql .= " WHERE t.entity IN (".getEntity('resource').")"; - // Manage filter - if (!empty($filter)) { - foreach ($filter as $key => $value) { - if (strpos($key, 'date')) { - $sql .= ' AND '.$key.' = \''.$this->db->idate($value).'\''; - } elseif (strpos($key, 'ef.') !== false) { - $sql .= $value; - } else { - $sql .= ' AND '.$key.' LIKE \'%'.$this->db->escape($value).'%\''; - } - } - } - $sql .= $this->db->order($sortfield, $sortorder); - $this->num_all = 0; - if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) - { - $result = $this->db->query($sql); - $this->num_all = $this->db->num_rows($result); - } - if ($limit) $sql .= $this->db->plimit($limit, $offset); - dol_syslog(get_class($this)."::fetch_all", LOG_DEBUG); - - $this->lines = array(); - $resql = $this->db->query($sql); - if ($resql) - { - $num = $this->db->num_rows($resql); - if ($num) - { - while ($obj = $this->db->fetch_object($resql)) - { - $line = new Dolresource($this->db); - $line->id = $obj->rowid; - $line->ref = $obj->ref; - $line->description = $obj->description; - $line->country_id = $obj->fk_country; - $line->fk_code_type_resource = $obj->fk_code_type_resource; - $line->type_label = $obj->type_label; - - // fetch optionals attributes and labels - - $line->fetch_optionals(); - - $this->lines[] = $line; - } - $this->db->free($resql); - } - return $num; - } else { - $this->error = $this->db->lasterror(); - return -1; - } - } - - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Load all objects into $this->lines - * - * @param string $sortorder sort order + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Load resource objects into $this->lines + * + * @param string $sortorder sort order * @param string $sortfield sort field * @param int $limit limit page * @param int $offset page * @param array $filter filter output * @return int <0 if KO, >0 if OK - */ - public function fetch_all_resources($sortorder, $sortfield, $limit, $offset, $filter = '') - { - // phpcs:enable + */ + public function fetch_all($sortorder, $sortfield, $limit, $offset, $filter = '') + { + // phpcs:enable + global $conf; + + require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; + $extrafields = new ExtraFields($this->db); + + $sql = "SELECT "; + $sql .= " t.rowid,"; + $sql .= " t.entity,"; + $sql .= " t.ref,"; + $sql .= " t.description,"; + $sql .= " t.fk_code_type_resource,"; + $sql .= " t.tms,"; + // Add fields from extrafields + if (!empty($extrafields->attributes[$this->table_element]['label'])) + foreach ($extrafields->attributes[$this->table_element]['label'] as $key => $val) $sql .= ($extrafields->attributes[$this->table_element]['type'][$key] != 'separate' ? "ef.".$key.' as options_'.$key.', ' : ''); + $sql .= " ty.label as type_label"; + $sql .= " FROM ".MAIN_DB_PREFIX.$this->table_element." as t"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_type_resource as ty ON ty.code=t.fk_code_type_resource"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$this->table_element."_extrafields as ef ON ef.fk_object=t.rowid"; + $sql .= " WHERE t.entity IN (".getEntity('resource').")"; + // Manage filter + if (!empty($filter)) { + foreach ($filter as $key => $value) { + if (strpos($key, 'date')) { + $sql .= ' AND '.$key.' = \''.$this->db->idate($value).'\''; + } elseif (strpos($key, 'ef.') !== false) { + $sql .= $value; + } else { + $sql .= ' AND '.$key.' LIKE \'%'.$this->db->escape($value).'%\''; + } + } + } + $sql .= $this->db->order($sortfield, $sortorder); + $this->num_all = 0; + if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) + { + $result = $this->db->query($sql); + $this->num_all = $this->db->num_rows($result); + } + if ($limit) $sql .= $this->db->plimit($limit, $offset); + dol_syslog(get_class($this)."::fetch_all", LOG_DEBUG); + + $this->lines = array(); + $resql = $this->db->query($sql); + if ($resql) + { + $num = $this->db->num_rows($resql); + if ($num) + { + while ($obj = $this->db->fetch_object($resql)) + { + $line = new Dolresource($this->db); + $line->id = $obj->rowid; + $line->ref = $obj->ref; + $line->description = $obj->description; + $line->country_id = $obj->fk_country; + $line->fk_code_type_resource = $obj->fk_code_type_resource; + $line->type_label = $obj->type_label; + + // fetch optionals attributes and labels + + $line->fetch_optionals(); + + $this->lines[] = $line; + } + $this->db->free($resql); + } + return $num; + } else { + $this->error = $this->db->lasterror(); + return -1; + } + } + + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Load all objects into $this->lines + * + * @param string $sortorder sort order + * @param string $sortfield sort field + * @param int $limit limit page + * @param int $offset page + * @param array $filter filter output + * @return int <0 if KO, >0 if OK + */ + public function fetch_all_resources($sortorder, $sortfield, $limit, $offset, $filter = '') + { + // phpcs:enable global $conf; $sql = "SELECT "; $sql .= " t.rowid,"; @@ -593,7 +593,7 @@ class Dolresource extends CommonObject } } } - $sql .= $this->db->order($sortfield, $sortorder); + $sql .= $this->db->order($sortfield, $sortorder); if ($limit) $sql .= $this->db->plimit($limit + 1, $offset); dol_syslog(get_class($this)."::fetch_all", LOG_DEBUG); @@ -619,7 +619,7 @@ class Dolresource extends CommonObject $line->objresource = fetchObjectByElement($obj->resource_id, $obj->resource_type); if ($obj->element_id && $obj->element_type) $line->objelement = fetchObjectByElement($obj->element_id, $obj->element_type); - $this->lines[] = $line; + $this->lines[] = $line; } $this->db->free($resql); } @@ -628,119 +628,119 @@ class Dolresource extends CommonObject $this->error = $this->db->lasterror(); return -1; } - } + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Load all objects into $this->lines - * - * @param string $sortorder sort order - * @param string $sortfield sort field - * @param int $limit limit page - * @param int $offset page - * @param array $filter filter output - * @return int <0 if KO, >0 if OK - */ - public function fetch_all_used($sortorder, $sortfield, $limit, $offset = 1, $filter = '') - { - // phpcs:enable - global $conf; + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Load all objects into $this->lines + * + * @param string $sortorder sort order + * @param string $sortfield sort field + * @param int $limit limit page + * @param int $offset page + * @param array $filter filter output + * @return int <0 if KO, >0 if OK + */ + public function fetch_all_used($sortorder, $sortfield, $limit, $offset = 1, $filter = '') + { + // phpcs:enable + global $conf; - if (!$sortorder) $sortorder = "ASC"; - if (!$sortfield) $sortfield = "t.rowid"; + if (!$sortorder) $sortorder = "ASC"; + if (!$sortfield) $sortfield = "t.rowid"; - $sql = "SELECT "; - $sql .= " t.rowid,"; - $sql .= " t.resource_id,"; - $sql .= " t.resource_type,"; - $sql .= " t.element_id,"; - $sql .= " t.element_type,"; - $sql .= " t.busy,"; - $sql .= " t.mandatory,"; - $sql .= " t.fk_user_create,"; - $sql .= " t.tms"; - $sql .= ' FROM '.MAIN_DB_PREFIX.'element_resources as t '; - $sql .= " WHERE t.entity IN (".getEntity('resource').")"; + $sql = "SELECT "; + $sql .= " t.rowid,"; + $sql .= " t.resource_id,"; + $sql .= " t.resource_type,"; + $sql .= " t.element_id,"; + $sql .= " t.element_type,"; + $sql .= " t.busy,"; + $sql .= " t.mandatory,"; + $sql .= " t.fk_user_create,"; + $sql .= " t.tms"; + $sql .= ' FROM '.MAIN_DB_PREFIX.'element_resources as t '; + $sql .= " WHERE t.entity IN (".getEntity('resource').")"; - //Manage filter - if (!empty($filter)) { - foreach ($filter as $key => $value) { - if (strpos($key, 'date')) { - $sql .= ' AND '.$key.' = \''.$this->db->idate($value).'\''; - } else { - $sql .= ' AND '.$key.' LIKE \'%'.$this->db->escape($value).'%\''; - } - } - } - $sql .= $this->db->order($sortfield, $sortorder); - if ($limit) $sql .= $this->db->plimit($limit + 1, $offset); - dol_syslog(get_class($this)."::fetch_all", LOG_DEBUG); + //Manage filter + if (!empty($filter)) { + foreach ($filter as $key => $value) { + if (strpos($key, 'date')) { + $sql .= ' AND '.$key.' = \''.$this->db->idate($value).'\''; + } else { + $sql .= ' AND '.$key.' LIKE \'%'.$this->db->escape($value).'%\''; + } + } + } + $sql .= $this->db->order($sortfield, $sortorder); + if ($limit) $sql .= $this->db->plimit($limit + 1, $offset); + dol_syslog(get_class($this)."::fetch_all", LOG_DEBUG); - $resql = $this->db->query($sql); - if ($resql) - { - $num = $this->db->num_rows($resql); - if ($num) - { - $this->lines = array(); - while ($obj = $this->db->fetch_object($resql)) - { - $line = new Dolresource($this->db); - $line->id = $obj->rowid; - $line->resource_id = $obj->resource_id; - $line->resource_type = $obj->resource_type; - $line->element_id = $obj->element_id; - $line->element_type = $obj->element_type; - $line->busy = $obj->busy; - $line->mandatory = $obj->mandatory; - $line->fk_user_create = $obj->fk_user_create; + $resql = $this->db->query($sql); + if ($resql) + { + $num = $this->db->num_rows($resql); + if ($num) + { + $this->lines = array(); + while ($obj = $this->db->fetch_object($resql)) + { + $line = new Dolresource($this->db); + $line->id = $obj->rowid; + $line->resource_id = $obj->resource_id; + $line->resource_type = $obj->resource_type; + $line->element_id = $obj->element_id; + $line->element_type = $obj->element_type; + $line->busy = $obj->busy; + $line->mandatory = $obj->mandatory; + $line->fk_user_create = $obj->fk_user_create; - $this->lines[] = fetchObjectByElement($obj->resource_id, $obj->resource_type); - } - $this->db->free($resql); - } - return $num; - } else { - $this->error = $this->db->lasterror(); - return -1; - } - } + $this->lines[] = fetchObjectByElement($obj->resource_id, $obj->resource_type); + } + $this->db->free($resql); + } + return $num; + } else { + $this->error = $this->db->lasterror(); + return -1; + } + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Fetch all resources available, declared by modules - * Load available resource in array $this->available_resources - * - * @return int number of available resources declared by modules - * @deprecated, remplaced by hook getElementResources - * @see getElementResources() - */ - public function fetch_all_available() - { - // phpcs:enable - global $conf; + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Fetch all resources available, declared by modules + * Load available resource in array $this->available_resources + * + * @return int number of available resources declared by modules + * @deprecated, remplaced by hook getElementResources + * @see getElementResources() + */ + public function fetch_all_available() + { + // phpcs:enable + global $conf; - if (!empty($conf->modules_parts['resources'])) - { - $this->available_resources = (array) $conf->modules_parts['resources']; + if (!empty($conf->modules_parts['resources'])) + { + $this->available_resources = (array) $conf->modules_parts['resources']; - return count($this->available_resources); - } - return 0; - } + return count($this->available_resources); + } + return 0; + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Update element resource into database - * - * @param User $user User that modifies - * @param int $notrigger 0=launch triggers after, 1=disable triggers - * @return int <0 if KO, >0 if OK - */ - public function update_element_resource($user = null, $notrigger = 0) - { - // phpcs:enable - global $conf, $langs; + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Update element resource into database + * + * @param User $user User that modifies + * @param int $notrigger 0=launch triggers after, 1=disable triggers + * @return int <0 if KO, >0 if OK + */ + public function update_element_resource($user = null, $notrigger = 0) + { + // phpcs:enable + global $conf, $langs; $error = 0; // Clean parameters @@ -751,8 +751,8 @@ class Dolresource extends CommonObject if (isset($this->busy)) $this->busy = trim($this->busy); if (isset($this->mandatory)) $this->mandatory = trim($this->mandatory); - // Update request - $sql = "UPDATE ".MAIN_DB_PREFIX."element_resources SET"; + // Update request + $sql = "UPDATE ".MAIN_DB_PREFIX."element_resources SET"; $sql .= " resource_id=".(isset($this->resource_id) ? "'".$this->db->escape($this->resource_id)."'" : "null").","; $sql .= " resource_type=".(isset($this->resource_type) ? "'".$this->db->escape($this->resource_type)."'" : "null").","; $sql .= " element_id=".(isset($this->element_id) ? $this->element_id : "null").","; @@ -761,32 +761,32 @@ class Dolresource extends CommonObject $sql .= " mandatory=".(isset($this->mandatory) ? $this->mandatory : "null").","; $sql .= " tms=".(dol_strlen($this->tms) != 0 ? "'".$this->db->idate($this->tms)."'" : 'null').""; - $sql .= " WHERE rowid=".$this->id; + $sql .= " WHERE rowid=".$this->id; $this->db->begin(); dol_syslog(get_class($this)."::update", LOG_DEBUG); - $resql = $this->db->query($sql); - if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); } + $resql = $this->db->query($sql); + if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); } if (!$error) { if (!$notrigger) { - // Call trigger - $result = $this->call_trigger('RESOURCE_MODIFY', $user); - if ($result < 0) $error++; - // End call triggers - } + // Call trigger + $result = $this->call_trigger('RESOURCE_MODIFY', $user); + if ($result < 0) $error++; + // End call triggers + } } - // Commit or rollback + // Commit or rollback if ($error) { foreach ($this->errors as $errmsg) { - dol_syslog(get_class($this)."::update ".$errmsg, LOG_ERR); - $this->error .= ($this->error ? ', '.$errmsg : $errmsg); + dol_syslog(get_class($this)."::update ".$errmsg, LOG_ERR); + $this->error .= ($this->error ? ', '.$errmsg : $errmsg); } $this->db->rollback(); return -1 * $error; @@ -794,201 +794,201 @@ class Dolresource extends CommonObject $this->db->commit(); return 1; } - } + } - /** - * Return an array with resources linked to the element - * - * @param string $element Element - * @param int $element_id Id - * @param string $resource_type Type - * @return array Aray of resources - */ - public function getElementResources($element, $element_id, $resource_type = '') - { - $resources = array(); + /** + * Return an array with resources linked to the element + * + * @param string $element Element + * @param int $element_id Id + * @param string $resource_type Type + * @return array Aray of resources + */ + public function getElementResources($element, $element_id, $resource_type = '') + { + $resources = array(); - // Links beetween objects are stored in this table - $sql = 'SELECT rowid, resource_id, resource_type, busy, mandatory'; - $sql .= ' FROM '.MAIN_DB_PREFIX.'element_resources'; - $sql .= " WHERE element_id=".$element_id." AND element_type='".$this->db->escape($element)."'"; - if ($resource_type) - $sql .= " AND resource_type LIKE '%".$this->db->escape($resource_type)."%'"; - $sql .= ' ORDER BY resource_type'; + // Links beetween objects are stored in this table + $sql = 'SELECT rowid, resource_id, resource_type, busy, mandatory'; + $sql .= ' FROM '.MAIN_DB_PREFIX.'element_resources'; + $sql .= " WHERE element_id=".$element_id." AND element_type='".$this->db->escape($element)."'"; + if ($resource_type) + $sql .= " AND resource_type LIKE '%".$this->db->escape($resource_type)."%'"; + $sql .= ' ORDER BY resource_type'; - dol_syslog(get_class($this)."::getElementResources", LOG_DEBUG); + dol_syslog(get_class($this)."::getElementResources", LOG_DEBUG); - $resources = array(); - $resql = $this->db->query($sql); - if ($resql) - { - $num = $this->db->num_rows($resql); - $i = 0; - while ($i < $num) - { - $obj = $this->db->fetch_object($resql); + $resources = array(); + $resql = $this->db->query($sql); + if ($resql) + { + $num = $this->db->num_rows($resql); + $i = 0; + while ($i < $num) + { + $obj = $this->db->fetch_object($resql); - $resources[$i] = array( - 'rowid' => $obj->rowid, - 'resource_id' => $obj->resource_id, - 'resource_type'=>$obj->resource_type, - 'busy'=>$obj->busy, - 'mandatory'=>$obj->mandatory - ); - $i++; - } - } + $resources[$i] = array( + 'rowid' => $obj->rowid, + 'resource_id' => $obj->resource_id, + 'resource_type'=>$obj->resource_type, + 'busy'=>$obj->busy, + 'mandatory'=>$obj->mandatory + ); + $i++; + } + } - return $resources; - } + return $resources; + } - /** - * Return an int number of resources linked to the element - * - * @param string $element Element type - * @param int $element_id Element id - * @return int Nb of resources loaded - */ - public function fetchElementResources($element, $element_id) - { - $resources = $this->getElementResources($element, $element_id); - $i = 0; - foreach ($resources as $nb => $resource) { - $this->lines[$i] = fetchObjectByElement($resource['resource_id'], $resource['resource_type']); - $i++; - } - return $i; - } + /** + * Return an int number of resources linked to the element + * + * @param string $element Element type + * @param int $element_id Element id + * @return int Nb of resources loaded + */ + public function fetchElementResources($element, $element_id) + { + $resources = $this->getElementResources($element, $element_id); + $i = 0; + foreach ($resources as $nb => $resource) { + $this->lines[$i] = fetchObjectByElement($resource['resource_id'], $resource['resource_type']); + $i++; + } + return $i; + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Load in cache resource type code (setup in dictionary) - * - * @return int Number of lines loaded, 0 if already loaded, <0 if KO - */ - public function load_cache_code_type_resource() - { - // phpcs:enable - global $langs; + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Load in cache resource type code (setup in dictionary) + * + * @return int Number of lines loaded, 0 if already loaded, <0 if KO + */ + public function load_cache_code_type_resource() + { + // phpcs:enable + global $langs; - if (is_array($this->cache_code_type_resource) && count($this->cache_code_type_resource)) return 0; // Cache deja charge + if (is_array($this->cache_code_type_resource) && count($this->cache_code_type_resource)) return 0; // Cache deja charge - $sql = "SELECT rowid, code, label, active"; - $sql .= " FROM ".MAIN_DB_PREFIX."c_type_resource"; - $sql .= " WHERE active > 0"; - $sql .= " ORDER BY rowid"; - dol_syslog(get_class($this)."::load_cache_code_type_resource", LOG_DEBUG); - $resql = $this->db->query($sql); - if ($resql) - { - $num = $this->db->num_rows($resql); - $i = 0; - while ($i < $num) - { - $obj = $this->db->fetch_object($resql); - // Si traduction existe, on l'utilise, sinon on prend le libelle par defaut - $label = ($langs->trans("ResourceTypeShort".$obj->code) != ("ResourceTypeShort".$obj->code) ? $langs->trans("ResourceTypeShort".$obj->code) : ($obj->label != '-' ? $obj->label : '')); - $this->cache_code_type_resource[$obj->rowid]['code'] = $obj->code; - $this->cache_code_type_resource[$obj->rowid]['label'] = $label; - $this->cache_code_type_resource[$obj->rowid]['active'] = $obj->active; - $i++; - } - return $num; - } else { - dol_print_error($this->db); - return -1; - } - } + $sql = "SELECT rowid, code, label, active"; + $sql .= " FROM ".MAIN_DB_PREFIX."c_type_resource"; + $sql .= " WHERE active > 0"; + $sql .= " ORDER BY rowid"; + dol_syslog(get_class($this)."::load_cache_code_type_resource", LOG_DEBUG); + $resql = $this->db->query($sql); + if ($resql) + { + $num = $this->db->num_rows($resql); + $i = 0; + while ($i < $num) + { + $obj = $this->db->fetch_object($resql); + // Si traduction existe, on l'utilise, sinon on prend le libelle par defaut + $label = ($langs->trans("ResourceTypeShort".$obj->code) != ("ResourceTypeShort".$obj->code) ? $langs->trans("ResourceTypeShort".$obj->code) : ($obj->label != '-' ? $obj->label : '')); + $this->cache_code_type_resource[$obj->rowid]['code'] = $obj->code; + $this->cache_code_type_resource[$obj->rowid]['label'] = $label; + $this->cache_code_type_resource[$obj->rowid]['active'] = $obj->active; + $i++; + } + return $num; + } else { + dol_print_error($this->db); + return -1; + } + } - /** - * Return clicable link of object (with eventually picto) - * - * @param int $withpicto Add picto into link - * @param string $option Where point the link ('compta', 'expedition', 'document', ...) - * @param string $get_params Parametres added to url - * @param int $notooltip 1=Disable tooltip - * @param string $morecss Add more css on link - * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking - * @return string String with URL - */ - public function getNomUrl($withpicto = 0, $option = '', $get_params = '', $notooltip = 0, $morecss = '', $save_lastsearch_value = -1) - { - global $conf, $langs; + /** + * Return clicable link of object (with eventually picto) + * + * @param int $withpicto Add picto into link + * @param string $option Where point the link ('compta', 'expedition', 'document', ...) + * @param string $get_params Parametres added to url + * @param int $notooltip 1=Disable tooltip + * @param string $morecss Add more css on link + * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking + * @return string String with URL + */ + public function getNomUrl($withpicto = 0, $option = '', $get_params = '', $notooltip = 0, $morecss = '', $save_lastsearch_value = -1) + { + global $conf, $langs; - $result = ''; - $label = img_picto('', $this->picto).' '.$langs->trans("Resource").''; - $label .= '
    '; - $label .= ''.$langs->trans('Ref').': '.$this->ref; - /*if (isset($this->status)) { + $result = ''; + $label = img_picto('', $this->picto).' '.$langs->trans("Resource").''; + $label .= '
    '; + $label .= ''.$langs->trans('Ref').': '.$this->ref; + /*if (isset($this->status)) { $label.= '
    ' . $langs->trans("Status").": ".$this->getLibStatut(5); }*/ - if (isset($this->type_label)) { - $label .= '
    '.$langs->trans("ResourceType").": ".$this->type_label; - } + if (isset($this->type_label)) { + $label .= '
    '.$langs->trans("ResourceType").": ".$this->type_label; + } - $url = DOL_URL_ROOT.'/resource/card.php?id='.$this->id; + $url = DOL_URL_ROOT.'/resource/card.php?id='.$this->id; - if ($option != 'nolink') - { - // Add param to save lastsearch_values or not - $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0); - if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values = 1; - if ($add_save_lastsearch_values) $url .= '&save_lastsearch_values=1'; - } + if ($option != 'nolink') + { + // Add param to save lastsearch_values or not + $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0); + if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values = 1; + if ($add_save_lastsearch_values) $url .= '&save_lastsearch_values=1'; + } - $linkclose = ''; - if (empty($notooltip)) - { - if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) - { - $label = $langs->trans("ShowMyObject"); - $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"'; - } - $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"'; - $linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"'; - } else $linkclose = ($morecss ? ' class="'.$morecss.'"' : ''); + $linkclose = ''; + if (empty($notooltip)) + { + if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) + { + $label = $langs->trans("ShowMyObject"); + $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"'; + } + $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"'; + $linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"'; + } else $linkclose = ($morecss ? ' class="'.$morecss.'"' : ''); - $linkstart = ''; - $linkend = ''; - /*$linkstart = ''; + $linkstart = ''; + $linkend = ''; + /*$linkstart = ''; $linkend = '';*/ - $result .= $linkstart; - if ($withpicto) $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1); - if ($withpicto != 2) $result .= $this->ref; - $result .= $linkend; + $result .= $linkstart; + if ($withpicto) $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1); + if ($withpicto != 2) $result .= $this->ref; + $result .= $linkend; - return $result; - } + return $result; + } - /** - * Retourne le libelle du status d'un user (actif, inactif) - * - * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto - * @return string Label of status - */ - public function getLibStatut($mode = 0) - { - return $this->LibStatut($this->status, $mode); - } + /** + * Retourne le libelle du status d'un user (actif, inactif) + * + * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto + * @return string Label of status + */ + public function getLibStatut($mode = 0) + { + return $this->LibStatut($this->status, $mode); + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Return the status - * - * @param int $status Id status - * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 5=Long label + Picto - * @return string Label of status - */ - public static function LibStatut($status, $mode = 0) - { - // phpcs:enable - global $langs; + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Return the status + * + * @param int $status Id status + * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 5=Long label + Picto + * @return string Label of status + */ + public static function LibStatut($status, $mode = 0) + { + // phpcs:enable + global $langs; - return ''; - } + return ''; + } } diff --git a/htdocs/resource/contact.php b/htdocs/resource/contact.php index 5bc7b528c2a..afce3dd9947 100644 --- a/htdocs/resource/contact.php +++ b/htdocs/resource/contact.php @@ -147,7 +147,7 @@ if ($id > 0 || !empty($ref)) print ''; print '
    '; - dol_fiche_end(); + print dol_get_fiche_end(); print '
    '; diff --git a/htdocs/resource/document.php b/htdocs/resource/document.php index aade0a035a7..1287a35f98e 100644 --- a/htdocs/resource/document.php +++ b/htdocs/resource/document.php @@ -130,7 +130,7 @@ if ($object->id > 0) print '
    '; - dol_fiche_end(); + print dol_get_fiche_end(); $modulepart = 'dolresource'; $permission = $user->rights->resource->write; diff --git a/htdocs/resource/element_resource.php b/htdocs/resource/element_resource.php index 40836072684..0acf3359f86 100644 --- a/htdocs/resource/element_resource.php +++ b/htdocs/resource/element_resource.php @@ -427,7 +427,7 @@ if (!$ret) { print ''; - dol_fiche_end(); + print dol_get_fiche_end(); } } @@ -460,7 +460,7 @@ if (!$ret) { print ''; - dol_fiche_end(); + print dol_get_fiche_end(); $object = $savobject; } @@ -527,7 +527,7 @@ if (!$ret) { dol_banner_tab($fichinter, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref, '&element='.$element, 0, '', '', 1); - dol_fiche_end(); + print dol_get_fiche_end(); } } @@ -551,7 +551,7 @@ if (!$ret) { if ($user->socid && !in_array('product', explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL))) $shownav = 0; dol_banner_tab($product, 'ref', '', $shownav, 'ref', 'ref', '', '&element='.$element); - dol_fiche_end(); + print dol_get_fiche_end(); } } diff --git a/htdocs/resource/note.php b/htdocs/resource/note.php index 520589d0f5f..385fb9f190a 100644 --- a/htdocs/resource/note.php +++ b/htdocs/resource/note.php @@ -97,7 +97,7 @@ if ($id > 0 || !empty($ref)) $cssclass = 'titlefield'; include DOL_DOCUMENT_ROOT.'/core/tpl/notes.tpl.php'; - dol_fiche_end(); + print dol_get_fiche_end(); } // End of page diff --git a/htdocs/salaries/admin/salaries.php b/htdocs/salaries/admin/salaries.php index fa68f9ca720..7948c09e4b4 100644 --- a/htdocs/salaries/admin/salaries.php +++ b/htdocs/salaries/admin/salaries.php @@ -122,7 +122,7 @@ print ''; print "\n"; -//dol_fiche_end(); +//print dol_get_fiche_end(); print '
    '; diff --git a/htdocs/salaries/admin/salaries_extrafields.php b/htdocs/salaries/admin/salaries_extrafields.php index 19cd1435ccb..1d85e51be7a 100644 --- a/htdocs/salaries/admin/salaries_extrafields.php +++ b/htdocs/salaries/admin/salaries_extrafields.php @@ -73,7 +73,7 @@ print dol_get_fiche_head($head, 'attributes', $langs->trans("Salaries"), -1, 'us require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php'; -dol_fiche_end(); +print dol_get_fiche_end(); // Buttons diff --git a/htdocs/salaries/card.php b/htdocs/salaries/card.php index 63cda8c241d..5ab944c687a 100644 --- a/htdocs/salaries/card.php +++ b/htdocs/salaries/card.php @@ -351,7 +351,7 @@ if ($action == 'create') print ''; - dol_fiche_end(); + print dol_get_fiche_end(); print '
    '; print ''; @@ -473,7 +473,7 @@ if ($id) print '
    '; - dol_fiche_end(); + print dol_get_fiche_end(); /* diff --git a/htdocs/salaries/class/paymentsalary.class.php b/htdocs/salaries/class/paymentsalary.class.php index 1d46981d8d3..4f5209eb123 100644 --- a/htdocs/salaries/class/paymentsalary.class.php +++ b/htdocs/salaries/class/paymentsalary.class.php @@ -31,668 +31,668 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php'; */ class PaymentSalary extends CommonObject { - /** - * @var string ID to identify managed object - */ - public $element = 'payment_salary'; - - /** - * @var string Name of table without prefix where object is stored - */ - public $table_element = 'payment_salary'; - - /** - * @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png - */ - public $picto = 'payment'; - - public $tms; - - /** - * @var int User ID - */ - public $fk_user; - - public $datep; - public $datev; - public $amount; - - /** - * @var int ID - */ - public $fk_project; - - public $type_payment; - public $num_payment; - - /** - * @var string salary payments label - */ - public $label; - - public $datesp; - public $dateep; - - /** - * @var int ID - */ - public $fk_bank; - - /** - * @var int ID - */ - public $fk_user_author; - - /** - * @var int ID - */ - public $fk_user_modif; - - - /** - * Constructor - * - * @param DoliDB $db Database handler - */ - public function __construct($db) - { - $this->db = $db; - $this->element = 'payment_salary'; - $this->table_element = 'payment_salary'; - } - - /** - * Update database - * - * @param User $user User that modify - * @param int $notrigger 0=no, 1=yes (no update trigger) - * @return int <0 if KO, >0 if OK - */ - public function update($user = null, $notrigger = 0) - { - global $conf, $langs; - - $error = 0; - - // Clean parameters - $this->amount = trim($this->amount); - $this->label = trim($this->label); - $this->note = trim($this->note); - - // Check parameters - if (empty($this->fk_user) || $this->fk_user < 0) - { - $this->error = 'ErrorBadParameter'; - return -1; - } - - $this->db->begin(); - - // Update request - $sql = "UPDATE ".MAIN_DB_PREFIX."payment_salary SET"; - - $sql .= " tms='".$this->db->idate($this->tms)."',"; - $sql .= " fk_user=".$this->fk_user.","; - $sql .= " datep='".$this->db->idate($this->datep)."',"; - $sql .= " datev='".$this->db->idate($this->datev)."',"; - $sql .= " amount=".price2num($this->amount).","; - $sql .= " fk_projet=".((int) $this->fk_project).","; - $sql .= " fk_typepayment=".$this->fk_typepayment."',"; - $sql .= " num_payment='".$this->db->escape($this->num_payment)."',"; - $sql .= " label='".$this->db->escape($this->label)."',"; - $sql .= " datesp='".$this->db->idate($this->datesp)."',"; - $sql .= " dateep='".$this->db->idate($this->dateep)."',"; - $sql .= " note='".$this->db->escape($this->note)."',"; - $sql .= " fk_bank=".($this->fk_bank > 0 ? (int) $this->fk_bank : "null").","; - $sql .= " fk_user_author=".((int) $this->fk_user_author).","; - $sql .= " fk_user_modif=".($this->fk_user_modif > 0 ? (int) $this->fk_user_modif : 'null'); - - $sql .= " WHERE rowid=".$this->id; - - dol_syslog(get_class($this)."::update", LOG_DEBUG); - $resql = $this->db->query($sql); - if (!$resql) - { - $this->error = "Error ".$this->db->lasterror(); - return -1; - } - - // Update extrafield - if (!$error) - { - if (!$error) - { - $result = $this->insertExtraFields(); - if ($result < 0) - { - $error++; - } - } - } - - if (!$notrigger) - { - // Call trigger - $result = $this->call_trigger('PAYMENT_SALARY_MODIFY', $user); - if ($result < 0) $error++; - // End call triggers - } - - if (!$error) - { - $this->db->commit(); - return 1; - } else { - $this->db->rollback(); - return -1; - } - } - - - /** - * Load object in memory from database - * - * @param int $id id object - * @param User $user User that load - * @return int <0 if KO, >0 if OK - */ - public function fetch($id, $user = null) - { - global $langs; - $sql = "SELECT"; - $sql .= " s.rowid,"; - - $sql .= " s.tms,"; - $sql .= " s.fk_user,"; - $sql .= " s.datep,"; - $sql .= " s.datev,"; - $sql .= " s.amount,"; - $sql .= " s.fk_projet as fk_project,"; - $sql .= " s.fk_typepayment,"; - $sql .= " s.num_payment,"; - $sql .= " s.label,"; - $sql .= " s.datesp,"; - $sql .= " s.dateep,"; - $sql .= " s.note,"; - $sql .= " s.fk_bank,"; - $sql .= " s.fk_user_author,"; - $sql .= " s.fk_user_modif,"; - $sql .= " b.fk_account,"; - $sql .= " b.fk_type,"; - $sql .= " b.rappro"; - - $sql .= " FROM ".MAIN_DB_PREFIX."payment_salary as s"; - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."bank as b ON s.fk_bank = b.rowid"; - $sql .= " WHERE s.rowid = ".$id; - - dol_syslog(get_class($this)."::fetch", LOG_DEBUG); - $resql = $this->db->query($sql); - if ($resql) - { - if ($this->db->num_rows($resql)) - { - $obj = $this->db->fetch_object($resql); - - $this->id = $obj->rowid; - $this->ref = $obj->rowid; - $this->tms = $this->db->jdate($obj->tms); - $this->fk_user = $obj->fk_user; - $this->datep = $this->db->jdate($obj->datep); - $this->datev = $this->db->jdate($obj->datev); - $this->amount = $obj->amount; - $this->fk_project = $obj->fk_project; - $this->type_payement = $obj->fk_typepayment; - $this->num_payment = $obj->num_payment; - $this->label = $obj->label; - $this->datesp = $this->db->jdate($obj->datesp); - $this->dateep = $this->db->jdate($obj->dateep); - $this->note = $obj->note; - $this->fk_bank = $obj->fk_bank; - $this->fk_user_author = $obj->fk_user_author; - $this->fk_user_modif = $obj->fk_user_modif; - $this->fk_account = $obj->fk_account; - $this->fk_type = $obj->fk_type; - $this->rappro = $obj->rappro; - - // Retrieve all extrafield - // fetch optionals attributes and labels - $this->fetch_optionals(); - } - $this->db->free($resql); - - return 1; - } else { - $this->error = "Error ".$this->db->lasterror(); - return -1; - } - } - - - /** - * Delete object in database - * - * @param User $user User that delete - * @return int <0 if KO, >0 if OK - */ - public function delete($user) - { - global $conf, $langs; - - $error = 0; - - // Call trigger - $result = $this->call_trigger('PAYMENT_SALARY_DELETE', $user); - if ($result < 0) return -1; - // End call triggers - - // Delete donation - if (!$error) - { - $sql = "DELETE FROM ".MAIN_DB_PREFIX."payment_salary_extrafields"; - $sql .= " WHERE fk_object=".$this->id; - - $resql = $this->db->query($sql); - if (!$resql) - { - $this->errors[] = $this->db->lasterror(); - $error++; - } - } - - $sql = "DELETE FROM ".MAIN_DB_PREFIX."payment_salary"; - $sql .= " WHERE rowid=".$this->id; - - dol_syslog(get_class($this)."::delete", LOG_DEBUG); - $resql = $this->db->query($sql); - if (!$resql) - { - $this->error = "Error ".$this->db->lasterror(); - return -1; - } - - return 1; - } - - - /** - * Initialise an instance with random values. - * Used to build previews or test instances. - * id must be 0 if object instance is a specimen. - * - * @return void - */ - public function initAsSpecimen() - { - $this->id = 0; - - $this->tms = ''; - $this->fk_user = ''; - $this->datep = ''; - $this->datev = ''; - $this->amount = ''; - $this->label = ''; - $this->datesp = ''; - $this->dateep = ''; - $this->note = ''; - $this->fk_bank = ''; - $this->fk_user_author = ''; - $this->fk_user_modif = ''; - } - - /** - * Create in database - * - * @param User $user User that create - * @return int <0 if KO, >0 if OK - */ - public function create($user) - { - global $conf, $langs; - - $error = 0; - $now = dol_now(); - - // Clean parameters - $this->amount = price2num(trim($this->amount)); - $this->label = trim($this->label); - $this->note = trim($this->note); - $this->fk_bank = trim($this->fk_bank); - $this->fk_user_author = trim($this->fk_user_author); - $this->fk_user_modif = trim($this->fk_user_modif); - - // Check parameters - if (!$this->label) - { - $this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentities("Label")); - return -3; - } - if ($this->fk_user < 0 || $this->fk_user == '') - { - $this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentities("Employee")); - return -4; - } - if ($this->amount < 0 || $this->amount == '') - { - $this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentities("Amount")); - return -5; - } - if (!empty($conf->banque->enabled) && (empty($this->accountid) || $this->accountid <= 0)) - { - $this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentities("Account")); - return -6; - } - if (!empty($conf->banque->enabled) && (empty($this->type_payment) || $this->type_payment <= 0)) - { - $this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentities("PaymentMode")); - return -7; - } - - $this->db->begin(); - - // Insert into llx_payment_salary - $sql = "INSERT INTO ".MAIN_DB_PREFIX."payment_salary (fk_user"; - $sql .= ", datep"; - $sql .= ", datev"; - $sql .= ", amount"; - $sql .= ", fk_projet"; - $sql .= ", salary"; - $sql .= ", fk_typepayment"; - $sql .= ", num_payment"; - if ($this->note) $sql .= ", note"; - $sql .= ", label"; - $sql .= ", datesp"; - $sql .= ", dateep"; - $sql .= ", fk_user_author"; - $sql .= ", datec"; - $sql .= ", fk_bank"; - $sql .= ", entity"; - $sql .= ") "; - $sql .= " VALUES ("; - $sql .= "'".$this->db->escape($this->fk_user)."'"; - $sql .= ", '".$this->db->idate($this->datep)."'"; - $sql .= ", '".$this->db->idate($this->datev)."'"; - $sql .= ", ".$this->amount; - $sql .= ", ".($this->fk_project > 0 ? $this->fk_project : 0); - $sql .= ", ".($this->salary > 0 ? $this->salary : "null"); - $sql .= ", ".$this->db->escape($this->type_payment); - $sql .= ", '".$this->db->escape($this->num_payment)."'"; - if ($this->note) $sql .= ", '".$this->db->escape($this->note)."'"; - $sql .= ", '".$this->db->escape($this->label)."'"; - $sql .= ", '".$this->db->idate($this->datesp)."'"; - $sql .= ", '".$this->db->idate($this->dateep)."'"; - $sql .= ", '".$this->db->escape($user->id)."'"; - $sql .= ", '".$this->db->idate($now)."'"; - $sql .= ", NULL"; - $sql .= ", ".$conf->entity; - $sql .= ")"; - - dol_syslog(get_class($this)."::create", LOG_DEBUG); - $result = $this->db->query($sql); - if ($result) - { - $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."payment_salary"); - - if ($this->id > 0) - { - if (!empty($conf->banque->enabled) && !empty($this->amount)) - { - // Insert into llx_bank - require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; - - $acc = new Account($this->db); - $result = $acc->fetch($this->accountid); - if ($result <= 0) dol_print_error($this->db); - - // Update extrafield - if (!$error) { - if (!$error) - { - $result = $this->insertExtraFields(); - if ($result < 0) - { - $error++; - } - } - } - - // Insert payment into llx_bank - // Add link 'payment_salary' in bank_url between payment and bank transaction - $bank_line_id = $acc->addline( - $this->datep, - $this->type_payment, - $this->label, - -abs($this->amount), - $this->num_payment, - '', - $user, - '', - '', - '', - $this->datev - ); - - // Update fk_bank into llx_paiement. - // So we know the payment which has generate the banking ecriture - if ($bank_line_id > 0) - { - $this->update_fk_bank($bank_line_id); - } else { - $this->error = $acc->error; - $error++; - } - - if (!$error) - { - // Add link 'payment_salary' in bank_url between payment and bank transaction - $url = DOL_URL_ROOT.'/salaries/card.php?id='; - - $result = $acc->add_url_line($bank_line_id, $this->id, $url, "(SalaryPayment)", "payment_salary"); - if ($result <= 0) - { - $this->error = $acc->error; - $error++; - } - } - - $fuser = new User($this->db); - $fuser->fetch($this->fk_user); - - // Add link 'user' in bank_url between operation and bank transaction - $result = $acc->add_url_line( - $bank_line_id, - $this->fk_user, - DOL_URL_ROOT.'/user/card.php?id=', - $fuser->getFullName($langs), - // $langs->trans("SalaryPayment").' '.$fuser->getFullName($langs).' '.dol_print_date($this->datesp,'dayrfc').' '.dol_print_date($this->dateep,'dayrfc'), - 'user' - ); - - if ($result <= 0) - { - $this->error = $acc->error; - $error++; - } - } - - // Call trigger - $result = $this->call_trigger('PAYMENT_SALARY_CREATE', $user); - if ($result < 0) $error++; - // End call triggers - } else $error++; - - if (!$error) - { - $this->db->commit(); - return $this->id; - } else { - $this->db->rollback(); - return -2; - } - } else { - $this->error = $this->db->error(); - $this->db->rollback(); - return -1; - } - } - - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Update link between payment salary and line generate into llx_bank - * - * @param int $id_bank Id bank account - * @return int <0 if KO, >0 if OK - */ - public function update_fk_bank($id_bank) - { - // phpcs:enable - $sql = 'UPDATE '.MAIN_DB_PREFIX.'payment_salary SET fk_bank = '.$id_bank; - $sql .= ' WHERE rowid = '.$this->id; - $result = $this->db->query($sql); - if ($result) - { - return 1; - } else { - dol_print_error($this->db); - return -1; - } - } - - - /** - * Send name clicable (with possibly the picto) - * - * @param int $withpicto 0=No picto, 1=Include picto into link, 2=Only picto - * @param string $option link option - * @param int $notooltip 1=Disable tooltip - * @param string $morecss Add more css on link - * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking - * @return string Chaine with URL - */ - public function getNomUrl($withpicto = 0, $option = '', $notooltip = 0, $morecss = '', $save_lastsearch_value = -1) - { - global $db, $conf, $langs, $hookmanager; - global $dolibarr_main_authentication, $dolibarr_main_demo; - global $menumanager; - - if (!empty($conf->dol_no_mouse_hover)) $notooltip = 1; // Force disable tooltips - - $result = ''; - - $label = ''.$langs->trans("ShowSalaryPayment").''; - $label .= '
    '; - $label .= ''.$langs->trans('Ref').': '.$this->ref; - - $url = DOL_URL_ROOT.'/salaries/card.php?id='.$this->id; - - if ($option != 'nolink') - { - // Add param to save lastsearch_values or not - $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0); - if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values = 1; - if ($add_save_lastsearch_values) $url .= '&save_lastsearch_values=1'; - } - - $linkclose = ''; - if (empty($notooltip)) - { - if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) - { - $label = $langs->trans("ShowMyObject"); - $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"'; - } - $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"'; - $linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"'; - - /* + /** + * @var string ID to identify managed object + */ + public $element = 'payment_salary'; + + /** + * @var string Name of table without prefix where object is stored + */ + public $table_element = 'payment_salary'; + + /** + * @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png + */ + public $picto = 'payment'; + + public $tms; + + /** + * @var int User ID + */ + public $fk_user; + + public $datep; + public $datev; + public $amount; + + /** + * @var int ID + */ + public $fk_project; + + public $type_payment; + public $num_payment; + + /** + * @var string salary payments label + */ + public $label; + + public $datesp; + public $dateep; + + /** + * @var int ID + */ + public $fk_bank; + + /** + * @var int ID + */ + public $fk_user_author; + + /** + * @var int ID + */ + public $fk_user_modif; + + + /** + * Constructor + * + * @param DoliDB $db Database handler + */ + public function __construct($db) + { + $this->db = $db; + $this->element = 'payment_salary'; + $this->table_element = 'payment_salary'; + } + + /** + * Update database + * + * @param User $user User that modify + * @param int $notrigger 0=no, 1=yes (no update trigger) + * @return int <0 if KO, >0 if OK + */ + public function update($user = null, $notrigger = 0) + { + global $conf, $langs; + + $error = 0; + + // Clean parameters + $this->amount = trim($this->amount); + $this->label = trim($this->label); + $this->note = trim($this->note); + + // Check parameters + if (empty($this->fk_user) || $this->fk_user < 0) + { + $this->error = 'ErrorBadParameter'; + return -1; + } + + $this->db->begin(); + + // Update request + $sql = "UPDATE ".MAIN_DB_PREFIX."payment_salary SET"; + + $sql .= " tms='".$this->db->idate($this->tms)."',"; + $sql .= " fk_user=".$this->fk_user.","; + $sql .= " datep='".$this->db->idate($this->datep)."',"; + $sql .= " datev='".$this->db->idate($this->datev)."',"; + $sql .= " amount=".price2num($this->amount).","; + $sql .= " fk_projet=".((int) $this->fk_project).","; + $sql .= " fk_typepayment=".$this->fk_typepayment."',"; + $sql .= " num_payment='".$this->db->escape($this->num_payment)."',"; + $sql .= " label='".$this->db->escape($this->label)."',"; + $sql .= " datesp='".$this->db->idate($this->datesp)."',"; + $sql .= " dateep='".$this->db->idate($this->dateep)."',"; + $sql .= " note='".$this->db->escape($this->note)."',"; + $sql .= " fk_bank=".($this->fk_bank > 0 ? (int) $this->fk_bank : "null").","; + $sql .= " fk_user_author=".((int) $this->fk_user_author).","; + $sql .= " fk_user_modif=".($this->fk_user_modif > 0 ? (int) $this->fk_user_modif : 'null'); + + $sql .= " WHERE rowid=".$this->id; + + dol_syslog(get_class($this)."::update", LOG_DEBUG); + $resql = $this->db->query($sql); + if (!$resql) + { + $this->error = "Error ".$this->db->lasterror(); + return -1; + } + + // Update extrafield + if (!$error) + { + if (!$error) + { + $result = $this->insertExtraFields(); + if ($result < 0) + { + $error++; + } + } + } + + if (!$notrigger) + { + // Call trigger + $result = $this->call_trigger('PAYMENT_SALARY_MODIFY', $user); + if ($result < 0) $error++; + // End call triggers + } + + if (!$error) + { + $this->db->commit(); + return 1; + } else { + $this->db->rollback(); + return -1; + } + } + + + /** + * Load object in memory from database + * + * @param int $id id object + * @param User $user User that load + * @return int <0 if KO, >0 if OK + */ + public function fetch($id, $user = null) + { + global $langs; + $sql = "SELECT"; + $sql .= " s.rowid,"; + + $sql .= " s.tms,"; + $sql .= " s.fk_user,"; + $sql .= " s.datep,"; + $sql .= " s.datev,"; + $sql .= " s.amount,"; + $sql .= " s.fk_projet as fk_project,"; + $sql .= " s.fk_typepayment,"; + $sql .= " s.num_payment,"; + $sql .= " s.label,"; + $sql .= " s.datesp,"; + $sql .= " s.dateep,"; + $sql .= " s.note,"; + $sql .= " s.fk_bank,"; + $sql .= " s.fk_user_author,"; + $sql .= " s.fk_user_modif,"; + $sql .= " b.fk_account,"; + $sql .= " b.fk_type,"; + $sql .= " b.rappro"; + + $sql .= " FROM ".MAIN_DB_PREFIX."payment_salary as s"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."bank as b ON s.fk_bank = b.rowid"; + $sql .= " WHERE s.rowid = ".$id; + + dol_syslog(get_class($this)."::fetch", LOG_DEBUG); + $resql = $this->db->query($sql); + if ($resql) + { + if ($this->db->num_rows($resql)) + { + $obj = $this->db->fetch_object($resql); + + $this->id = $obj->rowid; + $this->ref = $obj->rowid; + $this->tms = $this->db->jdate($obj->tms); + $this->fk_user = $obj->fk_user; + $this->datep = $this->db->jdate($obj->datep); + $this->datev = $this->db->jdate($obj->datev); + $this->amount = $obj->amount; + $this->fk_project = $obj->fk_project; + $this->type_payement = $obj->fk_typepayment; + $this->num_payment = $obj->num_payment; + $this->label = $obj->label; + $this->datesp = $this->db->jdate($obj->datesp); + $this->dateep = $this->db->jdate($obj->dateep); + $this->note = $obj->note; + $this->fk_bank = $obj->fk_bank; + $this->fk_user_author = $obj->fk_user_author; + $this->fk_user_modif = $obj->fk_user_modif; + $this->fk_account = $obj->fk_account; + $this->fk_type = $obj->fk_type; + $this->rappro = $obj->rappro; + + // Retrieve all extrafield + // fetch optionals attributes and labels + $this->fetch_optionals(); + } + $this->db->free($resql); + + return 1; + } else { + $this->error = "Error ".$this->db->lasterror(); + return -1; + } + } + + + /** + * Delete object in database + * + * @param User $user User that delete + * @return int <0 if KO, >0 if OK + */ + public function delete($user) + { + global $conf, $langs; + + $error = 0; + + // Call trigger + $result = $this->call_trigger('PAYMENT_SALARY_DELETE', $user); + if ($result < 0) return -1; + // End call triggers + + // Delete donation + if (!$error) + { + $sql = "DELETE FROM ".MAIN_DB_PREFIX."payment_salary_extrafields"; + $sql .= " WHERE fk_object=".$this->id; + + $resql = $this->db->query($sql); + if (!$resql) + { + $this->errors[] = $this->db->lasterror(); + $error++; + } + } + + $sql = "DELETE FROM ".MAIN_DB_PREFIX."payment_salary"; + $sql .= " WHERE rowid=".$this->id; + + dol_syslog(get_class($this)."::delete", LOG_DEBUG); + $resql = $this->db->query($sql); + if (!$resql) + { + $this->error = "Error ".$this->db->lasterror(); + return -1; + } + + return 1; + } + + + /** + * Initialise an instance with random values. + * Used to build previews or test instances. + * id must be 0 if object instance is a specimen. + * + * @return void + */ + public function initAsSpecimen() + { + $this->id = 0; + + $this->tms = ''; + $this->fk_user = ''; + $this->datep = ''; + $this->datev = ''; + $this->amount = ''; + $this->label = ''; + $this->datesp = ''; + $this->dateep = ''; + $this->note = ''; + $this->fk_bank = ''; + $this->fk_user_author = ''; + $this->fk_user_modif = ''; + } + + /** + * Create in database + * + * @param User $user User that create + * @return int <0 if KO, >0 if OK + */ + public function create($user) + { + global $conf, $langs; + + $error = 0; + $now = dol_now(); + + // Clean parameters + $this->amount = price2num(trim($this->amount)); + $this->label = trim($this->label); + $this->note = trim($this->note); + $this->fk_bank = trim($this->fk_bank); + $this->fk_user_author = trim($this->fk_user_author); + $this->fk_user_modif = trim($this->fk_user_modif); + + // Check parameters + if (!$this->label) + { + $this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentities("Label")); + return -3; + } + if ($this->fk_user < 0 || $this->fk_user == '') + { + $this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentities("Employee")); + return -4; + } + if ($this->amount < 0 || $this->amount == '') + { + $this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentities("Amount")); + return -5; + } + if (!empty($conf->banque->enabled) && (empty($this->accountid) || $this->accountid <= 0)) + { + $this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentities("Account")); + return -6; + } + if (!empty($conf->banque->enabled) && (empty($this->type_payment) || $this->type_payment <= 0)) + { + $this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentities("PaymentMode")); + return -7; + } + + $this->db->begin(); + + // Insert into llx_payment_salary + $sql = "INSERT INTO ".MAIN_DB_PREFIX."payment_salary (fk_user"; + $sql .= ", datep"; + $sql .= ", datev"; + $sql .= ", amount"; + $sql .= ", fk_projet"; + $sql .= ", salary"; + $sql .= ", fk_typepayment"; + $sql .= ", num_payment"; + if ($this->note) $sql .= ", note"; + $sql .= ", label"; + $sql .= ", datesp"; + $sql .= ", dateep"; + $sql .= ", fk_user_author"; + $sql .= ", datec"; + $sql .= ", fk_bank"; + $sql .= ", entity"; + $sql .= ") "; + $sql .= " VALUES ("; + $sql .= "'".$this->db->escape($this->fk_user)."'"; + $sql .= ", '".$this->db->idate($this->datep)."'"; + $sql .= ", '".$this->db->idate($this->datev)."'"; + $sql .= ", ".$this->amount; + $sql .= ", ".($this->fk_project > 0 ? $this->fk_project : 0); + $sql .= ", ".($this->salary > 0 ? $this->salary : "null"); + $sql .= ", ".$this->db->escape($this->type_payment); + $sql .= ", '".$this->db->escape($this->num_payment)."'"; + if ($this->note) $sql .= ", '".$this->db->escape($this->note)."'"; + $sql .= ", '".$this->db->escape($this->label)."'"; + $sql .= ", '".$this->db->idate($this->datesp)."'"; + $sql .= ", '".$this->db->idate($this->dateep)."'"; + $sql .= ", '".$this->db->escape($user->id)."'"; + $sql .= ", '".$this->db->idate($now)."'"; + $sql .= ", NULL"; + $sql .= ", ".$conf->entity; + $sql .= ")"; + + dol_syslog(get_class($this)."::create", LOG_DEBUG); + $result = $this->db->query($sql); + if ($result) + { + $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."payment_salary"); + + if ($this->id > 0) + { + if (!empty($conf->banque->enabled) && !empty($this->amount)) + { + // Insert into llx_bank + require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; + + $acc = new Account($this->db); + $result = $acc->fetch($this->accountid); + if ($result <= 0) dol_print_error($this->db); + + // Update extrafield + if (!$error) { + if (!$error) + { + $result = $this->insertExtraFields(); + if ($result < 0) + { + $error++; + } + } + } + + // Insert payment into llx_bank + // Add link 'payment_salary' in bank_url between payment and bank transaction + $bank_line_id = $acc->addline( + $this->datep, + $this->type_payment, + $this->label, + -abs($this->amount), + $this->num_payment, + '', + $user, + '', + '', + '', + $this->datev + ); + + // Update fk_bank into llx_paiement. + // So we know the payment which has generate the banking ecriture + if ($bank_line_id > 0) + { + $this->update_fk_bank($bank_line_id); + } else { + $this->error = $acc->error; + $error++; + } + + if (!$error) + { + // Add link 'payment_salary' in bank_url between payment and bank transaction + $url = DOL_URL_ROOT.'/salaries/card.php?id='; + + $result = $acc->add_url_line($bank_line_id, $this->id, $url, "(SalaryPayment)", "payment_salary"); + if ($result <= 0) + { + $this->error = $acc->error; + $error++; + } + } + + $fuser = new User($this->db); + $fuser->fetch($this->fk_user); + + // Add link 'user' in bank_url between operation and bank transaction + $result = $acc->add_url_line( + $bank_line_id, + $this->fk_user, + DOL_URL_ROOT.'/user/card.php?id=', + $fuser->getFullName($langs), + // $langs->trans("SalaryPayment").' '.$fuser->getFullName($langs).' '.dol_print_date($this->datesp,'dayrfc').' '.dol_print_date($this->dateep,'dayrfc'), + 'user' + ); + + if ($result <= 0) + { + $this->error = $acc->error; + $error++; + } + } + + // Call trigger + $result = $this->call_trigger('PAYMENT_SALARY_CREATE', $user); + if ($result < 0) $error++; + // End call triggers + } else $error++; + + if (!$error) + { + $this->db->commit(); + return $this->id; + } else { + $this->db->rollback(); + return -2; + } + } else { + $this->error = $this->db->error(); + $this->db->rollback(); + return -1; + } + } + + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Update link between payment salary and line generate into llx_bank + * + * @param int $id_bank Id bank account + * @return int <0 if KO, >0 if OK + */ + public function update_fk_bank($id_bank) + { + // phpcs:enable + $sql = 'UPDATE '.MAIN_DB_PREFIX.'payment_salary SET fk_bank = '.$id_bank; + $sql .= ' WHERE rowid = '.$this->id; + $result = $this->db->query($sql); + if ($result) + { + return 1; + } else { + dol_print_error($this->db); + return -1; + } + } + + + /** + * Send name clicable (with possibly the picto) + * + * @param int $withpicto 0=No picto, 1=Include picto into link, 2=Only picto + * @param string $option link option + * @param int $notooltip 1=Disable tooltip + * @param string $morecss Add more css on link + * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking + * @return string Chaine with URL + */ + public function getNomUrl($withpicto = 0, $option = '', $notooltip = 0, $morecss = '', $save_lastsearch_value = -1) + { + global $db, $conf, $langs, $hookmanager; + global $dolibarr_main_authentication, $dolibarr_main_demo; + global $menumanager; + + if (!empty($conf->dol_no_mouse_hover)) $notooltip = 1; // Force disable tooltips + + $result = ''; + + $label = ''.$langs->trans("ShowSalaryPayment").''; + $label .= '
    '; + $label .= ''.$langs->trans('Ref').': '.$this->ref; + + $url = DOL_URL_ROOT.'/salaries/card.php?id='.$this->id; + + if ($option != 'nolink') + { + // Add param to save lastsearch_values or not + $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0); + if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values = 1; + if ($add_save_lastsearch_values) $url .= '&save_lastsearch_values=1'; + } + + $linkclose = ''; + if (empty($notooltip)) + { + if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) + { + $label = $langs->trans("ShowMyObject"); + $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"'; + } + $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"'; + $linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"'; + + /* $hookmanager->initHooks(array('myobjectdao')); $parameters=array('id'=>$this->id); $reshook=$hookmanager->executeHooks('getnomurltooltip',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks if ($reshook > 0) $linkclose = $hookmanager->resPrint; */ - } else $linkclose = ($morecss ? ' class="'.$morecss.'"' : ''); + } else $linkclose = ($morecss ? ' class="'.$morecss.'"' : ''); - $linkstart = ''; - $linkend = ''; + $linkstart = ''; + $linkend = ''; - $result .= $linkstart; - if ($withpicto) $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1); - if ($withpicto != 2) $result .= $this->ref; - $result .= $linkend; - //if ($withpicto != 2) $result.=(($addlabel && $this->label) ? $sep . dol_trunc($this->label, ($addlabel > 1 ? $addlabel : 0)) : ''); + $result .= $linkstart; + if ($withpicto) $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1); + if ($withpicto != 2) $result .= $this->ref; + $result .= $linkend; + //if ($withpicto != 2) $result.=(($addlabel && $this->label) ? $sep . dol_trunc($this->label, ($addlabel > 1 ? $addlabel : 0)) : ''); - global $action, $hookmanager; - $hookmanager->initHooks(array('salarypayment')); - $parameters = array('id'=>$this->id, 'getnomurl'=>$result); - $reshook = $hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks - if ($reshook > 0) $result = $hookmanager->resPrint; - else $result .= $hookmanager->resPrint; + global $action, $hookmanager; + $hookmanager->initHooks(array('salarypayment')); + $parameters = array('id'=>$this->id, 'getnomurl'=>$result); + $reshook = $hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + if ($reshook > 0) $result = $hookmanager->resPrint; + else $result .= $hookmanager->resPrint; - return $result; - } + return $result; + } - /** - * Information on record - * - * @param int $id Id of record - * @return void - */ - public function info($id) - { - $sql = 'SELECT ps.rowid, ps.datec, ps.fk_user_author'; - $sql .= ' FROM '.MAIN_DB_PREFIX.'payment_salary as ps'; - $sql .= ' WHERE ps.rowid = '.$id; + /** + * Information on record + * + * @param int $id Id of record + * @return void + */ + public function info($id) + { + $sql = 'SELECT ps.rowid, ps.datec, ps.fk_user_author'; + $sql .= ' FROM '.MAIN_DB_PREFIX.'payment_salary as ps'; + $sql .= ' WHERE ps.rowid = '.$id; - dol_syslog(get_class($this).'::info', LOG_DEBUG); - $result = $this->db->query($sql); + dol_syslog(get_class($this).'::info', LOG_DEBUG); + $result = $this->db->query($sql); - if ($result) - { - if ($this->db->num_rows($result)) - { - $obj = $this->db->fetch_object($result); - $this->id = $obj->rowid; - if ($obj->fk_user_author) - { - $cuser = new User($this->db); - $cuser->fetch($obj->fk_user_author); - $this->user_creation = $cuser; - } - $this->date_creation = $this->db->jdate($obj->datec); - } - $this->db->free($result); - } else { - dol_print_error($this->db); - } - } + if ($result) + { + if ($this->db->num_rows($result)) + { + $obj = $this->db->fetch_object($result); + $this->id = $obj->rowid; + if ($obj->fk_user_author) + { + $cuser = new User($this->db); + $cuser->fetch($obj->fk_user_author); + $this->user_creation = $cuser; + } + $this->date_creation = $this->db->jdate($obj->datec); + } + $this->db->free($result); + } else { + dol_print_error($this->db); + } + } - /** - * Retourne le libelle du statut d'une facture (brouillon, validee, abandonnee, payee) - * - * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto - * @return string Libelle - */ - public function getLibStatut($mode = 0) - { - return $this->LibStatut($this->statut, $mode); - } + /** + * Retourne le libelle du statut d'une facture (brouillon, validee, abandonnee, payee) + * + * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto + * @return string Libelle + */ + public function getLibStatut($mode = 0) + { + return $this->LibStatut($this->statut, $mode); + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Renvoi le libelle d'un statut donne - * - * @param int $status Statut - * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto - * @return string Libelle du statut - */ - public function LibStatut($status, $mode = 0) - { - // phpcs:enable - global $langs; // TODO Renvoyer le libelle anglais et faire traduction a affichage + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Renvoi le libelle d'un statut donne + * + * @param int $status Statut + * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto + * @return string Libelle du statut + */ + public function LibStatut($status, $mode = 0) + { + // phpcs:enable + global $langs; // TODO Renvoyer le libelle anglais et faire traduction a affichage - $langs->load('compta'); - /*if ($mode == 0) + $langs->load('compta'); + /*if ($mode == 0) { if ($status == 0) return $langs->trans('ToValidate'); if ($status == 1) return $langs->trans('Validated'); @@ -727,6 +727,6 @@ class PaymentSalary extends CommonObject if ($status == 0) return $langs->trans('ToValidate').' '.img_picto($langs->trans('ToValidate'),'statut1'); if ($status == 1) return $langs->trans('Validated').' '.img_picto($langs->trans('Validated'),'statut4'); }*/ - return ''; - } + return ''; + } } diff --git a/htdocs/salaries/document.php b/htdocs/salaries/document.php index 9c5f065fcf5..6cc482f1304 100644 --- a/htdocs/salaries/document.php +++ b/htdocs/salaries/document.php @@ -122,7 +122,7 @@ if ($object->id) print ''; - dol_fiche_end(); + print dol_get_fiche_end(); $modulepart = 'salaries'; $permission = $user->rights->salaries->write; diff --git a/htdocs/salaries/info.php b/htdocs/salaries/info.php index 6a98f42d2f0..9461bae867e 100644 --- a/htdocs/salaries/info.php +++ b/htdocs/salaries/info.php @@ -77,7 +77,7 @@ print ''; print ''; -dol_fiche_end(); +print dol_get_fiche_end(); // End of page llxFooter(); diff --git a/htdocs/salaries/stats/index.php b/htdocs/salaries/stats/index.php index 6cd554b54df..1f0598f4245 100644 --- a/htdocs/salaries/stats/index.php +++ b/htdocs/salaries/stats/index.php @@ -270,7 +270,7 @@ print ''; print '
    '; -dol_fiche_end(); +print dol_get_fiche_end(); // End of page llxFooter(); diff --git a/htdocs/societe/admin/contact_extrafields.php b/htdocs/societe/admin/contact_extrafields.php index a02327067d4..a52bf52332b 100644 --- a/htdocs/societe/admin/contact_extrafields.php +++ b/htdocs/societe/admin/contact_extrafields.php @@ -73,7 +73,7 @@ print dol_get_fiche_head($head, 'attributes_contacts', $langs->trans("ThirdParti require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php'; -dol_fiche_end(); +print dol_get_fiche_end(); // Buttons diff --git a/htdocs/societe/admin/societe.php b/htdocs/societe/admin/societe.php index 45224226070..94241f58278 100644 --- a/htdocs/societe/admin/societe.php +++ b/htdocs/societe/admin/societe.php @@ -852,7 +852,7 @@ print ''; print ''; -dol_fiche_end(); +print dol_get_fiche_end(); // End of page llxFooter(); diff --git a/htdocs/societe/admin/societe_extrafields.php b/htdocs/societe/admin/societe_extrafields.php index 3511f5afb2b..16d88142588 100644 --- a/htdocs/societe/admin/societe_extrafields.php +++ b/htdocs/societe/admin/societe_extrafields.php @@ -73,7 +73,7 @@ print dol_get_fiche_head($head, 'attributes', $langs->trans("ThirdParties"), -1, require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php'; -dol_fiche_end(); +print dol_get_fiche_end(); // Buttons diff --git a/htdocs/societe/agenda.php b/htdocs/societe/agenda.php index 41fa2100535..f55ef8613a0 100644 --- a/htdocs/societe/agenda.php +++ b/htdocs/societe/agenda.php @@ -126,7 +126,7 @@ if ($socid > 0) print ''; - dol_fiche_end(); + print dol_get_fiche_end(); diff --git a/htdocs/societe/canvas/company/tpl/card_view.tpl.php b/htdocs/societe/canvas/company/tpl/card_view.tpl.php index d1d5f4918fe..c56e7f9223c 100644 --- a/htdocs/societe/canvas/company/tpl/card_view.tpl.php +++ b/htdocs/societe/canvas/company/tpl/card_view.tpl.php @@ -235,7 +235,7 @@ for ($i = 1; $i <= 4; $i++) { - +
    rights->societe->creer) { ?> diff --git a/htdocs/societe/canvas/individual/tpl/card_view.tpl.php b/htdocs/societe/canvas/individual/tpl/card_view.tpl.php index 31e733c94ff..0ee2f271312 100644 --- a/htdocs/societe/canvas/individual/tpl/card_view.tpl.php +++ b/htdocs/societe/canvas/individual/tpl/card_view.tpl.php @@ -178,7 +178,7 @@ if ($this->control->tpl['action_delete']) echo $this->control->tpl['action_delet - +
    rights->societe->creer) { ?> diff --git a/htdocs/societe/card.php b/htdocs/societe/card.php index 7c3ea2d5d84..d0c43ff9bd6 100644 --- a/htdocs/societe/card.php +++ b/htdocs/societe/card.php @@ -1537,7 +1537,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) print ''."\n"; - dol_fiche_end(); + print dol_get_fiche_end(); print '
    '; print ''; @@ -2182,7 +2182,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) print ''; print '
    '; - dol_fiche_end(); + print dol_get_fiche_end(); print '
    '; print ''; @@ -2599,7 +2599,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) print '
    '; print '
    '; - dol_fiche_end(); + print dol_get_fiche_end(); /* diff --git a/htdocs/societe/consumption.php b/htdocs/societe/consumption.php index 90b6dae53c4..5ee31ea4f1c 100644 --- a/htdocs/societe/consumption.php +++ b/htdocs/societe/consumption.php @@ -170,7 +170,7 @@ print ''; print '
    '; -dol_fiche_end(); +print dol_get_fiche_end(); print '
    '; diff --git a/htdocs/societe/contact.php b/htdocs/societe/contact.php index 850a69d0ab2..3dbc8617b16 100644 --- a/htdocs/societe/contact.php +++ b/htdocs/societe/contact.php @@ -150,7 +150,7 @@ $linkback = ''.dol_substr($langs->trans("Prospect"), 0, 1).''; + $s .= ''.dol_substr($langs->trans("Prospect"), 0, 1).''; } if (($obj->client == 1 || $obj->client == 3) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) { - $s .= ''.dol_substr($langs->trans("Customer"), 0, 1).''; + $s .= ''.dol_substr($langs->trans("Customer"), 0, 1).''; } if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled)) && $obj->fournisseur) { - $s .= ''.dol_substr($langs->trans("Supplier"), 0, 1).''; + $s .= ''.dol_substr($langs->trans("Supplier"), 0, 1).''; } print $s; print ''; diff --git a/htdocs/societe/list.php b/htdocs/societe/list.php index 50c740e7be3..c48a0c4be3c 100644 --- a/htdocs/societe/list.php +++ b/htdocs/societe/list.php @@ -610,8 +610,8 @@ if (!empty($type)) if ($type == 'f') $label = 'NewSupplier'; } -if ($contextpage = 'poslist' && $type == 't' && ( !empty($conf->global->PRODUIT_MULTIPRICES) || !empty($conf->global->PRODUIT_CUSTOMER_PRICES) || !empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES))) { - print get_htmloutput_mesg(img_warning('default') . ' ' . $langs->trans("BecarefullChangeThirdpartyBeforeAddProductToInvoice"), '', 'warning', 1); +if ($contextpage = 'poslist' && $type == 't' && (!empty($conf->global->PRODUIT_MULTIPRICES) || !empty($conf->global->PRODUIT_CUSTOMER_PRICES) || !empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES))) { + print get_htmloutput_mesg(img_warning('default').' '.$langs->trans("BecarefullChangeThirdpartyBeforeAddProductToInvoice"), '', 'warning', 1); } // Show the new button only when this page is not opend from the Extended POS (pop-up window) @@ -1257,13 +1257,13 @@ while ($i < min($num, $limit)) { // Prospect status print '
    '; - print '
    ' . $companystatic->LibProspCommStatut($obj->stcomm_id, 2, $prospectstatic->cacheprospectstatus[$obj->stcomm_id]['label'], $obj->stcomm_picto); + print '
    '.$companystatic->LibProspCommStatut($obj->stcomm_id, 2, $prospectstatic->cacheprospectstatus[$obj->stcomm_id]['label'], $obj->stcomm_picto); print '
    -
    '; foreach ($prospectstatic->cacheprospectstatus as $key => $val) { $titlealt = 'default'; if (!empty($val['code']) && !in_array($val['code'], array('ST_NO', 'ST_NEVER', 'ST_TODO', 'ST_PEND', 'ST_DONE'))) $titlealt = $val['label']; - if ($obj->stcomm_id != $val['id']) print '' . img_action($titlealt, $val['code'], $val['picto']) . ''; + if ($obj->stcomm_id != $val['id']) print ''.img_action($titlealt, $val['code'], $val['picto']).''; } print '
    '; if (!$i) $totalarray['nbfield']++; diff --git a/htdocs/societe/note.php b/htdocs/societe/note.php index d18040e9626..258cde20bd0 100644 --- a/htdocs/societe/note.php +++ b/htdocs/societe/note.php @@ -121,7 +121,7 @@ if ($object->id > 0) //print '
    '; include DOL_DOCUMENT_ROOT.'/core/tpl/notes.tpl.php'; - dol_fiche_end(); + print dol_get_fiche_end(); } else { $langs->load("errors"); print $langs->trans("ErrorRecordNotFound"); diff --git a/htdocs/societe/notify/card.php b/htdocs/societe/notify/card.php index 5f38743215f..9a16c1aa1be 100644 --- a/htdocs/societe/notify/card.php +++ b/htdocs/societe/notify/card.php @@ -199,7 +199,7 @@ if ($result > 0) print '
    '; - dol_fiche_end(); + print dol_get_fiche_end(); print "\n"; diff --git a/htdocs/societe/paymentmodes.php b/htdocs/societe/paymentmodes.php index 1473d6397af..761365e1280 100644 --- a/htdocs/societe/paymentmodes.php +++ b/htdocs/societe/paymentmodes.php @@ -912,7 +912,7 @@ if ($socid && $action != 'edit' && $action != 'create' && $action != 'editcard' print ''; print ''; - dol_fiche_end(); + print dol_get_fiche_end(); print '
    '; @@ -1686,7 +1686,7 @@ if ($socid && $action == 'edit' && $user->rights->societe->creer) } - dol_fiche_end(); + print dol_get_fiche_end(); print '
    '; print ''; @@ -1733,7 +1733,7 @@ if ($socid && $action == 'editcard' && $user->rights->societe->creer) print ''; print '
    '; - dol_fiche_end(); + print dol_get_fiche_end(); print '
    '; print ''; @@ -1847,7 +1847,7 @@ if ($socid && $action == 'create' && $user->rights->societe->creer) print '
    '; - dol_fiche_end(); + print dol_get_fiche_end(); dol_set_focus('#label'); @@ -1897,7 +1897,7 @@ if ($socid && $action == 'createcard' && $user->rights->societe->creer) print ''; - dol_fiche_end(); + print dol_get_fiche_end(); dol_set_focus('#label'); diff --git a/htdocs/societe/price.php b/htdocs/societe/price.php index 8a65b56b2bf..e1584415086 100644 --- a/htdocs/societe/price.php +++ b/htdocs/societe/price.php @@ -233,7 +233,7 @@ print ''; print ''; -dol_fiche_end(); +print dol_get_fiche_end(); diff --git a/htdocs/societe/project.php b/htdocs/societe/project.php index 258b9043044..c4272dc014c 100644 --- a/htdocs/societe/project.php +++ b/htdocs/societe/project.php @@ -116,7 +116,7 @@ if ($socid) print ''; - dol_fiche_end(); + print dol_get_fiche_end(); $params = ''; diff --git a/htdocs/societe/website.php b/htdocs/societe/website.php index e5041b3ce20..b80f782cc40 100644 --- a/htdocs/societe/website.php +++ b/htdocs/societe/website.php @@ -231,7 +231,7 @@ print ''; print ''; -dol_fiche_end(); +print dol_get_fiche_end(); $newcardbutton = ''; if (!empty($conf->website->enabled)) { diff --git a/htdocs/stripe/admin/stripe.php b/htdocs/stripe/admin/stripe.php index 2cc80871679..ed8214aa0cc 100644 --- a/htdocs/stripe/admin/stripe.php +++ b/htdocs/stripe/admin/stripe.php @@ -462,7 +462,7 @@ print ''; print ''; -dol_fiche_end(); +print dol_get_fiche_end(); print '
    '; diff --git a/htdocs/supplier_proposal/admin/supplier_proposal_extrafields.php b/htdocs/supplier_proposal/admin/supplier_proposal_extrafields.php index 67312eb382e..a4b6e175224 100644 --- a/htdocs/supplier_proposal/admin/supplier_proposal_extrafields.php +++ b/htdocs/supplier_proposal/admin/supplier_proposal_extrafields.php @@ -68,7 +68,7 @@ print dol_get_fiche_head($head, 'attributes', $langs->trans("CommRequests"), -1, require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php'; -dol_fiche_end(); +print dol_get_fiche_end(); // Buttons diff --git a/htdocs/supplier_proposal/admin/supplier_proposaldet_extrafields.php b/htdocs/supplier_proposal/admin/supplier_proposaldet_extrafields.php index 4af017711c7..65c646bbdbf 100644 --- a/htdocs/supplier_proposal/admin/supplier_proposaldet_extrafields.php +++ b/htdocs/supplier_proposal/admin/supplier_proposaldet_extrafields.php @@ -73,7 +73,7 @@ print dol_get_fiche_head($head, 'attributeslines', $langs->trans("CommRequests") require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php'; -dol_fiche_end(); +print dol_get_fiche_end(); // Buttons diff --git a/htdocs/supplier_proposal/card.php b/htdocs/supplier_proposal/card.php index c364d3c63f4..4d676382c8b 100644 --- a/htdocs/supplier_proposal/card.php +++ b/htdocs/supplier_proposal/card.php @@ -229,7 +229,7 @@ if (empty($reshook)) else setEventMessages($langs->trans($object->error), null, 'errors'); } } elseif ($action == 'setdate_livraison' && $usercancreate) { - $result = $object->set_delivery_date($user, dol_mktime(12, 0, 0, $_POST['liv_month'], $_POST['liv_day'], $_POST['liv_year'])); + $result = $object->setDeliveryDate($user, dol_mktime(12, 0, 0, $_POST['liv_month'], $_POST['liv_day'], $_POST['liv_year'])); if ($result < 0) dol_print_error($db, $object->error); } @@ -1350,7 +1350,7 @@ if ($action == 'create') if (!empty($conf->global->SUPPLIER_PROPOSAL_CLONE_ON_CREATE_PAGE)) print ''; - dol_fiche_end(); + print dol_get_fiche_end(); print '
    '; print ''; @@ -1804,7 +1804,7 @@ if ($action == 'create') print '
    '; print "\n"; - dol_fiche_end(); + print dol_get_fiche_end(); if ($action == 'statut') { diff --git a/htdocs/supplier_proposal/class/supplier_proposal.class.php b/htdocs/supplier_proposal/class/supplier_proposal.class.php index cf18491e493..bb8387c55e3 100644 --- a/htdocs/supplier_proposal/class/supplier_proposal.class.php +++ b/htdocs/supplier_proposal/class/supplier_proposal.class.php @@ -1507,6 +1507,20 @@ class SupplierProposal extends CommonObject } // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Set delivery date + * + * @param User $user Object user that modify + * @param int $delivery_date Delivery date + * @return int <0 if ko, >0 if ok + * @deprecated Use setDeliveryDate + */ + public function set_date_livraison($user, $delivery_date) + { + // phpcs:enable + return $this->setDeliveryDate($user, $delivery_date); + } + /** * Set delivery date * @@ -1514,9 +1528,8 @@ class SupplierProposal extends CommonObject * @param int $delivery_date Delivery date * @return int <0 if ko, >0 if ok */ - public function set_delivery_date($user, $delivery_date) + public function setDeliveryDate($user, $delivery_date) { - // phpcs:enable if (!empty($user->rights->supplier_proposal->creer)) { $sql = "UPDATE ".MAIN_DB_PREFIX."supplier_proposal "; @@ -1529,7 +1542,7 @@ class SupplierProposal extends CommonObject return 1; } else { $this->error = $this->db->error(); - dol_syslog(get_class($this)."::set_delivery_date Erreur SQL"); + dol_syslog(get_class($this)."::setDeliveryDate Erreur SQL"); return -1; } } diff --git a/htdocs/supplier_proposal/contact.php b/htdocs/supplier_proposal/contact.php index b79e054368b..dd4f5b800a1 100644 --- a/htdocs/supplier_proposal/contact.php +++ b/htdocs/supplier_proposal/contact.php @@ -183,7 +183,7 @@ if ($id > 0 || !empty($ref)) dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref, '', 0, '', '', 1); - dol_fiche_end(); + print dol_get_fiche_end(); // Contacts lines include DOL_DOCUMENT_ROOT.'/core/tpl/contacts.tpl.php'; diff --git a/htdocs/supplier_proposal/document.php b/htdocs/supplier_proposal/document.php index ddf7249d121..c74491001e7 100644 --- a/htdocs/supplier_proposal/document.php +++ b/htdocs/supplier_proposal/document.php @@ -159,7 +159,7 @@ if ($object->id > 0) print ''; - dol_fiche_end(); + print dol_get_fiche_end(); $modulepart = 'supplier_proposal'; $permission = $user->rights->supplier_proposal->creer; diff --git a/htdocs/supplier_proposal/info.php b/htdocs/supplier_proposal/info.php index b0c189aff92..b7972881851 100644 --- a/htdocs/supplier_proposal/info.php +++ b/htdocs/supplier_proposal/info.php @@ -122,7 +122,7 @@ print ''; print ''; -dol_fiche_end(); +print dol_get_fiche_end(); // End of page llxFooter(); diff --git a/htdocs/supplier_proposal/note.php b/htdocs/supplier_proposal/note.php index 0496b1b5c9d..b4a33d76878 100644 --- a/htdocs/supplier_proposal/note.php +++ b/htdocs/supplier_proposal/note.php @@ -139,7 +139,7 @@ if ($id > 0 || !empty($ref)) print ''; - dol_fiche_end(); + print dol_get_fiche_end(); } } } diff --git a/htdocs/takepos/index.php b/htdocs/takepos/index.php index 8e6eb397c55..a30ccc2935f 100644 --- a/htdocs/takepos/index.php +++ b/htdocs/takepos/index.php @@ -888,6 +888,20 @@ if (empty($conf->global->TAKEPOS_HIDE_HEAD_BAR)) { + + +
    diff --git a/htdocs/takepos/invoice.php b/htdocs/takepos/invoice.php index 3a67c81d4ba..8975c7426c3 100644 --- a/htdocs/takepos/invoice.php +++ b/htdocs/takepos/invoice.php @@ -271,6 +271,154 @@ if ($action == 'valid' && $user->rights->facture->creer) } } +if ($action == 'creditnote') +{ + $creditnote = new Facture($db); + $creditnote->socid = $invoice->socid; + $creditnote->date = dol_now(); + $creditnote->type = Facture::TYPE_CREDIT_NOTE; + $creditnote->fk_facture_source = $placeid; + $creditnote->remise_absolue = $invoice->remise_absolue; + $creditnote->remise_percent = $invoice->remise_percent; + $creditnote->create($user); + + foreach ($invoice->lines as $line) + { + // Extrafields + if (method_exists($line, 'fetch_optionals')) { + // load extrafields + $line->fetch_optionals(); + } + // Reset fk_parent_line for no child products and special product + if (($line->product_type != 9 && empty($line->fk_parent_line)) || $line->product_type == 9) { + $fk_parent_line = 0; + } + if ($invoice->type == Facture::TYPE_SITUATION) + { + $source_fk_prev_id = $line->fk_prev_id; // temporary storing situation invoice fk_prev_id + $line->fk_prev_id = $line->id; // The new line of the new credit note we are creating must be linked to the situation invoice line it is created from + if (!empty($invoice->tab_previous_situation_invoice)) + { + // search the last standard invoice in cycle and the possible credit note between this last and invoice + // TODO Move this out of loop of $invoice->lines + $tab_jumped_credit_notes = array(); + $lineIndex = count($invoice->tab_previous_situation_invoice) - 1; + $searchPreviousInvoice = true; + while ($searchPreviousInvoice) + { + if ($invoice->tab_previous_situation_invoice[$lineIndex]->type == Facture::TYPE_SITUATION || $lineIndex < 1) + { + $searchPreviousInvoice = false; // find, exit; + break; + } else { + if ($invoice->tab_previous_situation_invoice[$lineIndex]->type == Facture::TYPE_CREDIT_NOTE) { + $tab_jumped_credit_notes[$lineIndex] = $invoice->tab_previous_situation_invoice[$lineIndex]->id; + } + $lineIndex--; // go to previous invoice in cycle + } + } + + $maxPrevSituationPercent = 0; + foreach ($invoice->tab_previous_situation_invoice[$lineIndex]->lines as $prevLine) + { + if ($prevLine->id == $source_fk_prev_id) + { + $maxPrevSituationPercent = max($maxPrevSituationPercent, $prevLine->situation_percent); + + //$line->subprice = $line->subprice - $prevLine->subprice; + $line->total_ht = $line->total_ht - $prevLine->total_ht; + $line->total_tva = $line->total_tva - $prevLine->total_tva; + $line->total_ttc = $line->total_ttc - $prevLine->total_ttc; + $line->total_localtax1 = $line->total_localtax1 - $prevLine->total_localtax1; + $line->total_localtax2 = $line->total_localtax2 - $prevLine->total_localtax2; + + $line->multicurrency_subprice = $line->multicurrency_subprice - $prevLine->multicurrency_subprice; + $line->multicurrency_total_ht = $line->multicurrency_total_ht - $prevLine->multicurrency_total_ht; + $line->multicurrency_total_tva = $line->multicurrency_total_tva - $prevLine->multicurrency_total_tva; + $line->multicurrency_total_ttc = $line->multicurrency_total_ttc - $prevLine->multicurrency_total_ttc; + } + } + + // prorata + $line->situation_percent = $maxPrevSituationPercent - $line->situation_percent; + + //print 'New line based on invoice id '.$invoice->tab_previous_situation_invoice[$lineIndex]->id.' fk_prev_id='.$source_fk_prev_id.' will be fk_prev_id='.$line->fk_prev_id.' '.$line->total_ht.' '.$line->situation_percent.'
    '; + + // If there is some credit note between last situation invoice and invoice used for credit note generation (note: credit notes are stored as delta) + $maxPrevSituationPercent = 0; + foreach ($tab_jumped_credit_notes as $index => $creditnoteid) { + foreach ($invoice->tab_previous_situation_invoice[$index]->lines as $prevLine) + { + if ($prevLine->fk_prev_id == $source_fk_prev_id) + { + $maxPrevSituationPercent = $prevLine->situation_percent; + + $line->total_ht -= $prevLine->total_ht; + $line->total_tva -= $prevLine->total_tva; + $line->total_ttc -= $prevLine->total_ttc; + $line->total_localtax1 -= $prevLine->total_localtax1; + $line->total_localtax2 -= $prevLine->total_localtax2; + + $line->multicurrency_subprice -= $prevLine->multicurrency_subprice; + $line->multicurrency_total_ht -= $prevLine->multicurrency_total_ht; + $line->multicurrency_total_tva -= $prevLine->multicurrency_total_tva; + $line->multicurrency_total_ttc -= $prevLine->multicurrency_total_ttc; + } + } + } + + // prorata + $line->situation_percent += $maxPrevSituationPercent; + + //print 'New line based on invoice id '.$invoice->tab_previous_situation_invoice[$lineIndex]->id.' fk_prev_id='.$source_fk_prev_id.' will be fk_prev_id='.$line->fk_prev_id.' '.$line->total_ht.' '.$line->situation_percent.'
    '; + } + } + + $line->fk_facture = $creditnote->id; + $line->fk_parent_line = $fk_parent_line; + + $line->subprice = -$line->subprice; // invert price for object + $line->pa_ht = $line->pa_ht; // we choosed to have buy/cost price always positive, so no revert of sign here + $line->total_ht = -$line->total_ht; + $line->total_tva = -$line->total_tva; + $line->total_ttc = -$line->total_ttc; + $line->total_localtax1 = -$line->total_localtax1; + $line->total_localtax2 = -$line->total_localtax2; + + $line->multicurrency_subprice = -$line->multicurrency_subprice; + $line->multicurrency_total_ht = -$line->multicurrency_total_ht; + $line->multicurrency_total_tva = -$line->multicurrency_total_tva; + $line->multicurrency_total_ttc = -$line->multicurrency_total_ttc; + + $result = $line->insert(0, 1); // When creating credit note with same lines than source, we must ignore error if discount alreayd linked + + $creditnote->lines[] = $line; // insert new line in current object + + // Defined the new fk_parent_line + if ($result > 0 && $line->product_type == 9) { + $fk_parent_line = $result; + } + } + $creditnote->update_price(1); + + $constantforkey = 'CASHDESK_NO_DECREASE_STOCK'.$_SESSION["takeposterminal"]; + if (!empty($conf->stock->enabled) && $conf->global->$constantforkey != "1") { + $savconst = $conf->global->STOCK_CALCULATE_ON_BILL; + $conf->global->STOCK_CALCULATE_ON_BILL = 1; + $constantforkey = 'CASHDESK_ID_WAREHOUSE'.$_SESSION["takeposterminal"]; + dol_syslog("Validate invoice with stock change into warehouse defined into constant ".$constantforkey." = ".$conf->global->$constantforkey); + $batch_rule = 0; + if (!empty($conf->productbatch->enabled) && !empty($conf->global->CASHDESK_FORCE_DECREASE_STOCK)) { + require_once DOL_DOCUMENT_ROOT.'/product/class/productbatch.class.php'; + $batch_rule = Productbatch::BATCH_RULE_SELLBY_EATBY_DATES_FIRST; + } + $res = $creditnote->validate($user, '', $conf->global->$constantforkey, 0, $batch_rule); + $conf->global->STOCK_CALCULATE_ON_BILL = $savconst; + } else { + $res = $creditnote->validate($user); + } +} + if ($action == 'history') { $placeid = (int) GETPOST('placeid', 'int'); @@ -785,6 +933,11 @@ function DolibarrTakeposPrinting(id) { }); } +function CreditNote() { + $("#poslines").load("invoice.php?action=creditnote&invoiceid="+placeid, function() { + }); +} + $( document ).ready(function() { console.log("Set customer info and sales in header"); @@ -1162,6 +1315,10 @@ if ($placeid > 0) print ''; +if ($action == "valid" || $action == "history"){ + print ''; +} + if ($action == "search") { diff --git a/htdocs/takepos/smpcb.php b/htdocs/takepos/smpcb.php index f138438a707..1e02e9bc591 100644 --- a/htdocs/takepos/smpcb.php +++ b/htdocs/takepos/smpcb.php @@ -40,7 +40,7 @@ if (GETPOSTISSET('status')) { if (GETPOST('smp-status')) { print ''; print ''; - print ' + print ' The HTML5 Herald diff --git a/htdocs/theme/eldy/info-box.inc.php b/htdocs/theme/eldy/info-box.inc.php index 9bbc4101065..b037cfdc851 100644 --- a/htdocs/theme/eldy/info-box.inc.php +++ b/htdocs/theme/eldy/info-box.inc.php @@ -435,19 +435,20 @@ if (GETPOSTISSET('THEME_SATURATE_RATIO')) $conf->global->THEME_SATURATE_RATIO = min-width: 350px; max-width: 350px; } + @media only screen and (max-width: 1740px) { .info-box-module { min-width: 315px; max-width: 315px; } } + @media only screen and (max-width: 767px) { .info-box-module { min-width: 260px; } } - .info-box-module .info-box-content { height: 98px; } @@ -463,9 +464,18 @@ if (GETPOSTISSET('THEME_SATURATE_RATIO')) $conf->global->THEME_SATURATE_RATIO = margin: 0 0 0 0px !important; width: 100% !important; } - .info-box-module { width: 100%; max-width: unset; } + .info-box-sm .info-box-icon { + width: 60px; + } + .info-box-sm .info-box-content { + margin-left: 60px; + } + .info-box { + border: 1px solid #e0e0e0; + } +} } diff --git a/htdocs/theme/md/info-box.inc.php b/htdocs/theme/md/info-box.inc.php index 9b4b0618dd9..a784a1ec7d9 100644 --- a/htdocs/theme/md/info-box.inc.php +++ b/htdocs/theme/md/info-box.inc.php @@ -473,6 +473,12 @@ if (GETPOSTISSET('THEME_SATURATE_RATIO')) $conf->global->THEME_SATURATE_RATIO = min-width: 350px; max-width: 350px; } + +.info-box-module .info-box-content { + height: 6.3em; +} + + @media only screen and (max-width: 1740px) { .info-box-module { min-width: 315px; @@ -483,8 +489,11 @@ if (GETPOSTISSET('THEME_SATURATE_RATIO')) $conf->global->THEME_SATURATE_RATIO = .info-box-module { min-width: 260px; } + .info-box-sm .info-box-icon { + width: 60px; + } + .info-box-sm .info-box-content { + margin-left: 60px; + } } -.info-box-module .info-box-content { - height: 6.3em; -} diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php index 0be0b85bbbc..295eccc4e17 100644 --- a/htdocs/theme/md/style.css.php +++ b/htdocs/theme/md/style.css.php @@ -1299,6 +1299,7 @@ table[summary="list_of_modules"] .fa-cog { body { font-size: ; } + div.refidno { font-size: !important; } @@ -1306,6 +1307,17 @@ table[summary="list_of_modules"] .fa-cog { .login_vertical_align { padding-left: 0; } + .login_table input#username, .login_table input#password, .login_table input#securitycode { + margin-left: 5px !important; + } + div#login_left, div#login_right { + min-width: 150px !important; + padding-left: 5px !important; + padding-right: 5px !important; + } + .login_table div#login_right .tdinputlogin, .login_table div#login_right .tdinputlogin input { + min-width: 150px !important; + } .divmainbodylarge { margin-left: 20px; margin-right: 20px; } @@ -2335,10 +2347,12 @@ form#login { } .login_table .tdinputlogin { background-color: #fff; - border: 2px solid #ccc; min-width: 220px; border-radius: 2px; } +.login_table .tdinputlogin { + border-bottom: 1px solid #ccc; +} .login_table .tdinputlogin .fa { padding-left: 10px; width: 14px; diff --git a/htdocs/ticket/agenda.php b/htdocs/ticket/agenda.php index e94fc85d004..e7f7ff0434d 100644 --- a/htdocs/ticket/agenda.php +++ b/htdocs/ticket/agenda.php @@ -138,7 +138,7 @@ if ($socid > 0) { dol_banner_tab($object->thirdparty, 'socid', '', ($user->socid ? 0 : 1), 'rowid', 'nom'); - dol_fiche_end(); + print dol_get_fiche_end(); } if (!$user->socid && $conf->global->TICKET_LIMIT_VIEW_ASSIGNED_ONLY) { @@ -220,7 +220,7 @@ $linkback = ''.$langs dol_banner_tab($object, 'ref', $linkback, ($user->socid ? 0 : 1), 'ref', 'ref', $morehtmlref, '', 0, '', '', 1); -dol_fiche_end(); +print dol_get_fiche_end(); print '
    '; diff --git a/htdocs/ticket/card.php b/htdocs/ticket/card.php index fa82b304fef..63ff1b8cc09 100644 --- a/htdocs/ticket/card.php +++ b/htdocs/ticket/card.php @@ -717,7 +717,7 @@ if ($action == 'create' || $action == 'presend') print ''; print '
    '; - dol_fiche_end(); + print dol_get_fiche_end(); print '
    '; print ''; @@ -832,7 +832,7 @@ elseif (empty($action) || $action == 'view' || $action == 'addlink' || $action = dol_banner_tab($object->thirdparty, 'socid', '', ($user->socid ? 0 : 1), 'rowid', 'nom'); - dol_fiche_end(); + print dol_get_fiche_end(); } if (!$user->socid && $conf->global->TICKET_LIMIT_VIEW_ASSIGNED_ONLY) { @@ -1242,7 +1242,7 @@ elseif (empty($action) || $action == 'view' || $action == 'addlink' || $action = print '
    '; print '
    '; - dol_fiche_end(); + print dol_get_fiche_end(); // Buttons for actions diff --git a/htdocs/ticket/class/ticket.class.php b/htdocs/ticket/class/ticket.class.php index 391bd4dce2d..4cd7fed23d8 100644 --- a/htdocs/ticket/class/ticket.class.php +++ b/htdocs/ticket/class/ticket.class.php @@ -157,13 +157,13 @@ class Ticket extends CommonObject */ public $severity_label; - /** + /** * Email from user */ public $email_from; /** - * @var int Création date + * @var int Creation date */ public $datec = ''; @@ -1515,6 +1515,8 @@ class Ticket extends CommonObject $conf->global->MAIN_MAIL_AUTOCOPY_TO = ''; } include_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php'; + $sendtocc = ''; + $deliveryreceipt = 0; $mailfile = new CMailFile($subject, $info_sendto['email'], $from, $message, $filepath, $mimetype, $filename, $sendtocc, '', $deliveryreceipt, 0); if ($mailfile->error || $mailfile->errors) { setEventMessages($mailfile->error, $mailfile->errors, 'errors'); diff --git a/htdocs/ticket/contact.php b/htdocs/ticket/contact.php index 070c673d158..0212efec1ef 100644 --- a/htdocs/ticket/contact.php +++ b/htdocs/ticket/contact.php @@ -130,7 +130,7 @@ if ($id > 0 || !empty($track_id) || !empty($ref)) { $head = societe_prepare_head($object->thirdparty); print dol_get_fiche_head($head, 'ticket', $langs->trans("ThirdParty"), 0, 'company'); dol_banner_tab($object->thirdparty, 'socid', '', ($user->socid ? 0 : 1), 'rowid', 'nom'); - dol_fiche_end(); + print dol_get_fiche_end(); } if (!$user->socid && $conf->global->TICKET_LIMIT_VIEW_ASSIGNED_ONLY) { @@ -213,7 +213,7 @@ if ($id > 0 || !empty($track_id) || !empty($ref)) { dol_banner_tab($object, 'ref', $linkback, ($user->socid ? 0 : 1), 'ref', 'ref', $morehtmlref, $param, 0, '', '', 1, ''); - dol_fiche_end(); + print dol_get_fiche_end(); //print '
    '; diff --git a/htdocs/ticket/document.php b/htdocs/ticket/document.php index c007229fab9..b0fed0558fd 100644 --- a/htdocs/ticket/document.php +++ b/htdocs/ticket/document.php @@ -96,7 +96,7 @@ if ($object->id) $head = societe_prepare_head($object->thirdparty); print dol_get_fiche_head($head, 'ticket', $langs->trans("ThirdParty"), 0, 'company'); dol_banner_tab($object->thirdparty, 'socid', '', ($user->socid ? 0 : 1), 'rowid', 'nom'); - dol_fiche_end(); + print dol_get_fiche_end(); } if (!$user->socid && $conf->global->TICKET_LIMIT_VIEW_ASSIGNED_ONLY) { @@ -179,7 +179,7 @@ if ($object->id) dol_banner_tab($object, 'ref', $linkback, ($user->socid ? 0 : 1), 'ref', 'ref', $morehtmlref, '', 0, '', '', 1); - dol_fiche_end(); + print dol_get_fiche_end(); // Build file list $filearray = dol_dir_list($upload_dir, "files", 0, '', '\.meta$', $sortfield, (strtolower($sortorder) == 'desc' ? SORT_DESC : SORT_ASC), 1); diff --git a/htdocs/ticket/list.php b/htdocs/ticket/list.php index d441bd147b9..7b456e70f02 100644 --- a/htdocs/ticket/list.php +++ b/htdocs/ticket/list.php @@ -459,7 +459,7 @@ if ($socid && !$projectid && !$project_ref && $user->rights->societe->lire) { print ''; print ''; - dol_fiche_end(); + print dol_get_fiche_end(); } } @@ -521,7 +521,7 @@ if ($projectid > 0 || $project_ref) { print ""; print ''; - dol_fiche_end(); + print dol_get_fiche_end(); $object = $savobject; } else { diff --git a/htdocs/ticket/messaging.php b/htdocs/ticket/messaging.php index a013e2bc27e..5dfe9f5bbae 100644 --- a/htdocs/ticket/messaging.php +++ b/htdocs/ticket/messaging.php @@ -137,7 +137,7 @@ if ($socid > 0) { dol_banner_tab($object->thirdparty, 'socid', '', ($user->socid ? 0 : 1), 'rowid', 'nom'); - dol_fiche_end(); + print dol_get_fiche_end(); } if (!$user->socid && $conf->global->TICKET_LIMIT_VIEW_ASSIGNED_ONLY) { @@ -219,7 +219,7 @@ $linkback = '
    '.$langs dol_banner_tab($object, 'ref', $linkback, ($user->socid ? 0 : 1), 'ref', 'ref', $morehtmlref, '', 0, '', '', 1); -dol_fiche_end(); +print dol_get_fiche_end(); print '
    '; diff --git a/htdocs/ticket/stats/index.php b/htdocs/ticket/stats/index.php index 18a18bcd6a0..4ef8f18264f 100644 --- a/htdocs/ticket/stats/index.php +++ b/htdocs/ticket/stats/index.php @@ -316,7 +316,7 @@ print ''; print ''; print '
    '; -dol_fiche_end(); +print dol_get_fiche_end(); // End of page llxFooter(); diff --git a/htdocs/user/admin/group_extrafields.php b/htdocs/user/admin/group_extrafields.php index 9107be76acd..fd71d43d4f0 100644 --- a/htdocs/user/admin/group_extrafields.php +++ b/htdocs/user/admin/group_extrafields.php @@ -75,7 +75,7 @@ print dol_get_fiche_head($head, 'attributes_group', $langs->trans("MenuUsersAndG require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php'; -dol_fiche_end(); +print dol_get_fiche_end(); // Buttons diff --git a/htdocs/user/admin/user_extrafields.php b/htdocs/user/admin/user_extrafields.php index b30b340a727..9de70eab1a8 100644 --- a/htdocs/user/admin/user_extrafields.php +++ b/htdocs/user/admin/user_extrafields.php @@ -74,7 +74,7 @@ print dol_get_fiche_head($head, 'attributes', $langs->trans("MenuUsersAndGroups" require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php'; -dol_fiche_end(); +print dol_get_fiche_end(); // Buttons diff --git a/htdocs/user/agenda_extsites.php b/htdocs/user/agenda_extsites.php index cc2c331049b..b6aad8fb6db 100644 --- a/htdocs/user/agenda_extsites.php +++ b/htdocs/user/agenda_extsites.php @@ -218,7 +218,7 @@ print '
    '; print "trans("Save")."\">"; print "
    "; -dol_fiche_end(); +print dol_get_fiche_end(); print "\n"; diff --git a/htdocs/user/bank.php b/htdocs/user/bank.php index 5618177a35b..9d8f53f67ff 100644 --- a/htdocs/user/bank.php +++ b/htdocs/user/bank.php @@ -497,7 +497,7 @@ if ($action != 'edit' && $action != 'create') // If not bank account yet, $acco print ''; print '
    '; - dol_fiche_end(); + print dol_get_fiche_end(); // List of bank accounts (Currently only one bank account possible for each employee) @@ -661,7 +661,7 @@ if ($id && ($action == 'edit' || $action == 'create') && $user->rights->user->us //print ''; - dol_fiche_end(); + print dol_get_fiche_end(); print '
    '; print ''; diff --git a/htdocs/user/card.php b/htdocs/user/card.php index d1ae9ec46f7..d41fdd7359d 100644 --- a/htdocs/user/card.php +++ b/htdocs/user/card.php @@ -1262,7 +1262,7 @@ if ($action == 'create' || $action == 'adduserldap') print "\n"; - dol_fiche_end(); + print dol_get_fiche_end(); print '
    '; print ''; @@ -1823,7 +1823,7 @@ if ($action == 'create' || $action == 'adduserldap') print '
    '; - dol_fiche_end(); + print dol_get_fiche_end(); /* @@ -2753,7 +2753,7 @@ if ($action == 'create' || $action == 'adduserldap') print ''; - dol_fiche_end(); + print dol_get_fiche_end(); print '
    '; print ''; diff --git a/htdocs/user/clicktodial.php b/htdocs/user/clicktodial.php index 8e4dcfeed17..d91b5a7d480 100644 --- a/htdocs/user/clicktodial.php +++ b/htdocs/user/clicktodial.php @@ -180,7 +180,7 @@ if ($id > 0) print "\n"; } - dol_fiche_end(); + print dol_get_fiche_end(); if ($action == 'edit') { diff --git a/htdocs/user/document.php b/htdocs/user/document.php index 7cedd43320a..17a7fc90446 100644 --- a/htdocs/user/document.php +++ b/htdocs/user/document.php @@ -163,7 +163,7 @@ if ($object->id) print ''; print '
    '; - dol_fiche_end(); + print dol_get_fiche_end(); $modulepart = 'user'; diff --git a/htdocs/user/group/card.php b/htdocs/user/group/card.php index 3a7abd5364b..6e216506db1 100644 --- a/htdocs/user/group/card.php +++ b/htdocs/user/group/card.php @@ -283,7 +283,7 @@ if ($action == 'create') print "\n"; - dol_fiche_end(); + print dol_get_fiche_end(); print '
    '; print ''; @@ -370,7 +370,7 @@ else { print '
    '; - dol_fiche_end(); + print dol_get_fiche_end(); /* @@ -546,7 +546,7 @@ else { print ''; - dol_fiche_end(); + print dol_get_fiche_end(); print '
    '; print '   '; diff --git a/htdocs/user/group/ldap.php b/htdocs/user/group/ldap.php index accfde675eb..bf394ceacaf 100644 --- a/htdocs/user/group/ldap.php +++ b/htdocs/user/group/ldap.php @@ -144,7 +144,7 @@ print "\n"; print '
    '; -dol_fiche_end(); +print dol_get_fiche_end(); /* diff --git a/htdocs/user/group/perms.php b/htdocs/user/group/perms.php index 10de5b9309e..badf3840582 100644 --- a/htdocs/user/group/perms.php +++ b/htdocs/user/group/perms.php @@ -374,7 +374,7 @@ if ($object->id > 0) $reshook = $hookmanager->executeHooks('insertExtraFooter', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); - dol_fiche_end(); + print dol_get_fiche_end(); } // End of page diff --git a/htdocs/user/info.php b/htdocs/user/info.php index 487398630ce..f38d9ef2162 100644 --- a/htdocs/user/info.php +++ b/htdocs/user/info.php @@ -88,7 +88,7 @@ dol_print_object_info($object); print '
    '; -dol_fiche_end(); +print dol_get_fiche_end(); // End of page llxFooter(); diff --git a/htdocs/user/ldap.php b/htdocs/user/ldap.php index 5b8c09968b8..44c7f553d11 100644 --- a/htdocs/user/ldap.php +++ b/htdocs/user/ldap.php @@ -147,7 +147,7 @@ print ''; print '
    '; -dol_fiche_end(); +print dol_get_fiche_end(); /* * Barre d'actions diff --git a/htdocs/user/note.php b/htdocs/user/note.php index 0651485d72a..929d30a8d07 100644 --- a/htdocs/user/note.php +++ b/htdocs/user/note.php @@ -128,7 +128,7 @@ if ($id) print ""; print '
    '; - dol_fiche_end(); + print dol_get_fiche_end(); if ($action == 'edit') { diff --git a/htdocs/user/notify/card.php b/htdocs/user/notify/card.php index 07411dbc39e..3c7395fe1e8 100644 --- a/htdocs/user/notify/card.php +++ b/htdocs/user/notify/card.php @@ -168,7 +168,7 @@ if ($result > 0) print ''; - dol_fiche_end(); + print dol_get_fiche_end(); print "\n"; diff --git a/htdocs/user/param_ihm.php b/htdocs/user/param_ihm.php index b05ed814342..67c1755f2da 100644 --- a/htdocs/user/param_ihm.php +++ b/htdocs/user/param_ihm.php @@ -316,7 +316,7 @@ if ($action == 'edit') // Theme showSkins($object, (($user->admin || empty($dolibarr_main_demo)) ? 1 : 0), true); - dol_fiche_end(); + print dol_get_fiche_end(); print '
    '; @@ -386,7 +386,7 @@ if ($action == 'edit') // Skin showSkins($object, 0, true); - dol_fiche_end(); + print dol_get_fiche_end(); print '
    '; diff --git a/htdocs/user/perms.php b/htdocs/user/perms.php index b5ec6c8fc9b..14eb986f902 100644 --- a/htdocs/user/perms.php +++ b/htdocs/user/perms.php @@ -458,7 +458,7 @@ $reshook = $hookmanager->executeHooks('insertExtraFooter', $parameters, $object, if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); -dol_fiche_end(); +print dol_get_fiche_end(); // End of page llxFooter(); diff --git a/htdocs/variants/card.php b/htdocs/variants/card.php index 7f78eabf5f7..e55082abee1 100644 --- a/htdocs/variants/card.php +++ b/htdocs/variants/card.php @@ -176,7 +176,7 @@ if ($action != 'edit') { print '
    '; } -dol_fiche_end(); +print dol_get_fiche_end(); if ($action == 'edit') { print '
    '; diff --git a/htdocs/variants/combinations.php b/htdocs/variants/combinations.php index 096072b9fc7..ec059a0b23b 100644 --- a/htdocs/variants/combinations.php +++ b/htdocs/variants/combinations.php @@ -406,7 +406,7 @@ if (!empty($id) || !empty($ref)) print '
    '; print '
    '; - dol_fiche_end(); + print dol_get_fiche_end(); $listofvariantselected = ''; @@ -434,7 +434,7 @@ if (!empty($id) || !empty($ref)) } } $listofvariantselected .= '
    '; - //dol_fiche_end(); + //print dol_get_fiche_end(); } else { $title = $langs->trans('EditProductCombination'); } @@ -699,7 +699,7 @@ if (!empty($id) || !empty($ref))
    diff --git a/htdocs/variants/create.php b/htdocs/variants/create.php index e822327266f..ce00ac51a1a 100644 --- a/htdocs/variants/create.php +++ b/htdocs/variants/create.php @@ -89,7 +89,7 @@ print '';
    '; diff --git a/htdocs/variants/create_val.php b/htdocs/variants/create_val.php index 7b14bcbdde9..60c7a9032b7 100644 --- a/htdocs/variants/create_val.php +++ b/htdocs/variants/create_val.php @@ -106,7 +106,7 @@ print '
    '; '; -dol_fiche_end(); +print dol_get_fiche_end(); print '
    '; @@ -134,7 +134,7 @@ print dol_get_fiche_head(); '; print ''; diff --git a/htdocs/variants/generator.php b/htdocs/variants/generator.php index 60b9cec6f8b..e145d8ec41a 100644 --- a/htdocs/variants/generator.php +++ b/htdocs/variants/generator.php @@ -161,7 +161,7 @@ if (!empty($id) || !empty($ref)) { dol_banner_tab($object, 'ref', $linkback, ($user->socid ? 0 : 1), 'ref', '', '', '', 0, '', '', 1); - dol_fiche_end(); + print dol_get_fiche_end(); } print load_fiche_titre($langs->trans('ProductCombinationGenerator')); diff --git a/htdocs/webservices/server_actioncomm.php b/htdocs/webservices/server_actioncomm.php index d3a59962d88..7864c93243f 100644 --- a/htdocs/webservices/server_actioncomm.php +++ b/htdocs/webservices/server_actioncomm.php @@ -39,11 +39,11 @@ dol_syslog("Call ActionComm webservices interfaces"); // Enable and test if module web services is enabled if (empty($conf->global->MAIN_MODULE_WEBSERVICES)) { - $langs->load("admin"); - dol_syslog("Call Dolibarr webservices interfaces with module webservices disabled"); - print $langs->trans("WarningModuleNotActive", 'WebServices').'.

    '; - print $langs->trans("ToActivateModule"); - exit; + $langs->load("admin"); + dol_syslog("Call Dolibarr webservices interfaces with module webservices disabled"); + print $langs->trans("WarningModuleNotActive", 'WebServices').'.

    '; + print $langs->trans("ToActivateModule"); + exit; } // Create the soap Object @@ -57,36 +57,36 @@ $server->wsdl->schemaTargetNamespace = $ns; // Define WSDL Authentication object $server->wsdl->addComplexType( - 'authentication', - 'complexType', - 'struct', - 'all', - '', - array( - 'dolibarrkey' => array('name'=>'dolibarrkey', 'type'=>'xsd:string'), - 'sourceapplication' => array('name'=>'sourceapplication', 'type'=>'xsd:string'), - 'login' => array('name'=>'login', 'type'=>'xsd:string'), - 'password' => array('name'=>'password', 'type'=>'xsd:string'), - 'entity' => array('name'=>'entity', 'type'=>'xsd:string'), - ) + 'authentication', + 'complexType', + 'struct', + 'all', + '', + array( + 'dolibarrkey' => array('name'=>'dolibarrkey', 'type'=>'xsd:string'), + 'sourceapplication' => array('name'=>'sourceapplication', 'type'=>'xsd:string'), + 'login' => array('name'=>'login', 'type'=>'xsd:string'), + 'password' => array('name'=>'password', 'type'=>'xsd:string'), + 'entity' => array('name'=>'entity', 'type'=>'xsd:string'), + ) ); // Define WSDL Return object $server->wsdl->addComplexType( - 'result', - 'complexType', - 'struct', - 'all', - '', - array( - 'result_code' => array('name'=>'result_code', 'type'=>'xsd:string'), - 'result_label' => array('name'=>'result_label', 'type'=>'xsd:string'), - ) + 'result', + 'complexType', + 'struct', + 'all', + '', + array( + 'result_code' => array('name'=>'result_code', 'type'=>'xsd:string'), + 'result_label' => array('name'=>'result_label', 'type'=>'xsd:string'), + ) ); $actioncomm_fields = array( - 'id' => array('name'=>'id', 'type'=>'xsd:string'), + 'id' => array('name'=>'id', 'type'=>'xsd:string'), 'ref' => array('name'=>'ref', 'type'=>'xsd:string'), 'ref_ext' => array('name'=>'ref_ext', 'type'=>'xsd:string'), 'type_id' => array('name'=>'type_id', 'type'=>'xsd:string'), @@ -137,11 +137,11 @@ if (is_array($extrafield_array)) $actioncomm_fields = array_merge($actioncomm_fi // Define other specific objects $server->wsdl->addComplexType( - 'actioncomm', - 'complexType', - 'struct', - 'all', - '', + 'actioncomm', + 'complexType', + 'struct', + 'all', + '', $actioncomm_fields ); @@ -165,12 +165,12 @@ $server->wsdl->addComplexType( 'sequence', '', array( - 'actioncommtype' => array( - 'name' => 'actioncommtype', - 'type' => 'tns:actioncommtype', - 'minOccurs' => '0', - 'maxOccurs' => 'unbounded' - ) + 'actioncommtype' => array( + 'name' => 'actioncommtype', + 'type' => 'tns:actioncommtype', + 'minOccurs' => '0', + 'maxOccurs' => 'unbounded' + ) ) ); @@ -199,16 +199,16 @@ $server->register( // Register WSDL $server->register( - 'getActionComm', - // Entry values - array('authentication'=>'tns:authentication', 'id'=>'xsd:string'), - // Exit values - array('result'=>'tns:result', 'actioncomm'=>'tns:actioncomm'), - $ns, - $ns.'#getActionComm', - $styledoc, - $styleuse, - 'WS to get actioncomm' + 'getActionComm', + // Entry values + array('authentication'=>'tns:authentication', 'id'=>'xsd:string'), + // Exit values + array('result'=>'tns:result', 'actioncomm'=>'tns:actioncomm'), + $ns, + $ns.'#getActionComm', + $styledoc, + $styleuse, + 'WS to get actioncomm' ); // Register WSDL @@ -251,100 +251,100 @@ $server->register( */ function getActionComm($authentication, $id) { - global $db, $conf, $langs; + global $db, $conf, $langs; - dol_syslog("Function: getActionComm login=".$authentication['login']." id=".$id); + dol_syslog("Function: getActionComm login=".$authentication['login']." id=".$id); - if ($authentication['entity']) $conf->entity = $authentication['entity']; + if ($authentication['entity']) $conf->entity = $authentication['entity']; - // Init and check authentication - $objectresp = array(); - $errorcode = ''; $errorlabel = ''; - $error = 0; - $fuser = check_authentication($authentication, $error, $errorcode, $errorlabel); - // Check parameters - if ($error || (!$id)) - { - $error++; - $errorcode = 'BAD_PARAMETERS'; $errorlabel = "Parameter id, ref and ref_ext can't be both provided. You must choose one or other but not both."; - } + // Init and check authentication + $objectresp = array(); + $errorcode = ''; $errorlabel = ''; + $error = 0; + $fuser = check_authentication($authentication, $error, $errorcode, $errorlabel); + // Check parameters + if ($error || (!$id)) + { + $error++; + $errorcode = 'BAD_PARAMETERS'; $errorlabel = "Parameter id, ref and ref_ext can't be both provided. You must choose one or other but not both."; + } - if (!$error) - { - $fuser->getrights(); + if (!$error) + { + $fuser->getrights(); - if ($fuser->rights->agenda->allactions->read) - { - $actioncomm = new ActionComm($db); - $result = $actioncomm->fetch($id); - if ($result > 0) - { - $actioncomm_result_fields = array( + if ($fuser->rights->agenda->allactions->read) + { + $actioncomm = new ActionComm($db); + $result = $actioncomm->fetch($id); + if ($result > 0) + { + $actioncomm_result_fields = array( 'id' => $actioncomm->id, 'ref'=> $actioncomm->ref, - 'ref_ext'=> $actioncomm->ref_ext, - 'type_id'=> $actioncomm->type_id, - 'type_code'=> $actioncomm->type_code, - 'type'=> $actioncomm->type, - 'label'=> $actioncomm->label, - 'datep'=> dol_print_date($actioncomm->datep, 'dayhourrfc'), - 'datef'=> dol_print_date($actioncomm->datef, 'dayhourrfc'), - 'datec'=> dol_print_date($actioncomm->datec, 'dayhourrfc'), - 'datem'=> dol_print_date($actioncomm->datem, 'dayhourrfc'), - 'note'=> $actioncomm->note_private, - 'percentage'=> $actioncomm->percentage, - 'author'=> $actioncomm->authorid, - 'usermod'=> $actioncomm->usermodid, - 'userownerid'=> $actioncomm->userownerid, - 'priority'=> $actioncomm->priority, - 'fulldayevent'=> $actioncomm->fulldayevent, - 'location'=> $actioncomm->location, - 'socid'=> $actioncomm->socid, - 'contactid'=> $actioncomm->contact_id, - 'projectid'=> $actioncomm->fk_project, - 'fk_element'=> $actioncomm->fk_element, - 'elementtype'=> $actioncomm->elementtype - ); + 'ref_ext'=> $actioncomm->ref_ext, + 'type_id'=> $actioncomm->type_id, + 'type_code'=> $actioncomm->type_code, + 'type'=> $actioncomm->type, + 'label'=> $actioncomm->label, + 'datep'=> dol_print_date($actioncomm->datep, 'dayhourrfc'), + 'datef'=> dol_print_date($actioncomm->datef, 'dayhourrfc'), + 'datec'=> dol_print_date($actioncomm->datec, 'dayhourrfc'), + 'datem'=> dol_print_date($actioncomm->datem, 'dayhourrfc'), + 'note'=> $actioncomm->note_private, + 'percentage'=> $actioncomm->percentage, + 'author'=> $actioncomm->authorid, + 'usermod'=> $actioncomm->usermodid, + 'userownerid'=> $actioncomm->userownerid, + 'priority'=> $actioncomm->priority, + 'fulldayevent'=> $actioncomm->fulldayevent, + 'location'=> $actioncomm->location, + 'socid'=> $actioncomm->socid, + 'contactid'=> $actioncomm->contact_id, + 'projectid'=> $actioncomm->fk_project, + 'fk_element'=> $actioncomm->fk_element, + 'elementtype'=> $actioncomm->elementtype + ); - $elementtype = 'actioncomm'; + $elementtype = 'actioncomm'; - // Retrieve all extrafield for actioncomm - // fetch optionals attributes and labels - $extrafields = new ExtraFields($db); - $extrafields->fetch_name_optionals_label($elementtype, true); - //Get extrafield values - $actioncomm->fetch_optionals(); + // Retrieve all extrafield for actioncomm + // fetch optionals attributes and labels + $extrafields = new ExtraFields($db); + $extrafields->fetch_name_optionals_label($elementtype, true); + //Get extrafield values + $actioncomm->fetch_optionals(); - if (is_array($extrafields->attributes[$elementtype]['label']) && count($extrafields->attributes[$elementtype]['label'])) - { - foreach ($extrafields->attributes[$elementtype]['label'] as $key=>$label) - { - $actioncomm_result_fields = array_merge($actioncomm_result_fields, array('options_'.$key => $actioncomm->array_options['options_'.$key])); - } - } + if (is_array($extrafields->attributes[$elementtype]['label']) && count($extrafields->attributes[$elementtype]['label'])) + { + foreach ($extrafields->attributes[$elementtype]['label'] as $key=>$label) + { + $actioncomm_result_fields = array_merge($actioncomm_result_fields, array('options_'.$key => $actioncomm->array_options['options_'.$key])); + } + } - // Create - $objectresp = array( - 'result'=>array('result_code'=>'OK', 'result_label'=>''), - 'actioncomm'=>$actioncomm_result_fields); - } - else { - $error++; - $errorcode = 'NOT_FOUND'; $errorlabel = 'Object not found for id='.$id.' nor ref='.$ref.' nor ref_ext='.$ref_ext; - } - } - else { - $error++; - $errorcode = 'PERMISSION_DENIED'; $errorlabel = 'User does not have permission for this request'; - } - } + // Create + $objectresp = array( + 'result'=>array('result_code'=>'OK', 'result_label'=>''), + 'actioncomm'=>$actioncomm_result_fields); + } + else { + $error++; + $errorcode = 'NOT_FOUND'; $errorlabel = 'Object not found for id='.$id.' nor ref='.$ref.' nor ref_ext='.$ref_ext; + } + } + else { + $error++; + $errorcode = 'PERMISSION_DENIED'; $errorlabel = 'User does not have permission for this request'; + } + } - if ($error) - { - $objectresp = array('result'=>array('result_code' => $errorcode, 'result_label' => $errorlabel)); - } + if ($error) + { + $objectresp = array('result'=>array('result_code' => $errorcode, 'result_label' => $errorlabel)); + } - return $objectresp; + return $objectresp; } @@ -384,8 +384,8 @@ function getListActionCommType($authentication) } $objectresp = array( - 'result'=>array('result_code'=>'OK', 'result_label'=>''), - 'actioncommtypes'=>$resultarray); + 'result'=>array('result_code'=>'OK', 'result_label'=>''), + 'actioncommtypes'=>$resultarray); } else { $error++; $errorcode = 'NOT_FOUND'; $errorlabel = 'Object not found for id='.$id.' nor ref='.$ref.' nor ref_ext='.$ref_ext; diff --git a/htdocs/webservices/server_contact.php b/htdocs/webservices/server_contact.php index c4818d050f6..9abc7b6088f 100644 --- a/htdocs/webservices/server_contact.php +++ b/htdocs/webservices/server_contact.php @@ -35,11 +35,11 @@ dol_syslog("Call Contact webservices interfaces"); // Enable and test if module web services is enabled if (empty($conf->global->MAIN_MODULE_WEBSERVICES)) { - $langs->load("admin"); - dol_syslog("Call Dolibarr webservices interfaces with module webservices disabled"); - print $langs->trans("WarningModuleNotActive", 'WebServices').'.

    '; - print $langs->trans("ToActivateModule"); - exit; + $langs->load("admin"); + dol_syslog("Call Dolibarr webservices interfaces with module webservices disabled"); + print $langs->trans("WarningModuleNotActive", 'WebServices').'.

    '; + print $langs->trans("ToActivateModule"); + exit; } // Create the soap Object @@ -53,31 +53,31 @@ $server->wsdl->schemaTargetNamespace = $ns; // Define WSDL Authentication object $server->wsdl->addComplexType( - 'authentication', - 'complexType', - 'struct', - 'all', - '', - array( - 'dolibarrkey' => array('name'=>'dolibarrkey', 'type'=>'xsd:string'), - 'sourceapplication' => array('name'=>'sourceapplication', 'type'=>'xsd:string'), - 'login' => array('name'=>'login', 'type'=>'xsd:string'), - 'password' => array('name'=>'password', 'type'=>'xsd:string'), - 'entity' => array('name'=>'entity', 'type'=>'xsd:string'), - ) + 'authentication', + 'complexType', + 'struct', + 'all', + '', + array( + 'dolibarrkey' => array('name'=>'dolibarrkey', 'type'=>'xsd:string'), + 'sourceapplication' => array('name'=>'sourceapplication', 'type'=>'xsd:string'), + 'login' => array('name'=>'login', 'type'=>'xsd:string'), + 'password' => array('name'=>'password', 'type'=>'xsd:string'), + 'entity' => array('name'=>'entity', 'type'=>'xsd:string'), + ) ); // Define WSDL Return object $server->wsdl->addComplexType( - 'result', - 'complexType', - 'struct', - 'all', - '', - array( - 'result_code' => array('name'=>'result_code', 'type'=>'xsd:string'), - 'result_label' => array('name'=>'result_label', 'type'=>'xsd:string'), - ) + 'result', + 'complexType', + 'struct', + 'all', + '', + array( + 'result_code' => array('name'=>'result_code', 'type'=>'xsd:string'), + 'result_label' => array('name'=>'result_label', 'type'=>'xsd:string'), + ) ); $contact_fields = array( @@ -142,11 +142,11 @@ if (is_array($extrafield_array)) $contact_fields = array_merge($contact_fields, // Define other specific objects $server->wsdl->addComplexType( - 'contact', - 'complexType', - 'struct', - 'all', - '', + 'contact', + 'complexType', + 'struct', + 'all', + '', $contact_fields ); @@ -179,16 +179,16 @@ $styleuse = 'encoded'; // encoded/literal/literal wrapped // Register WSDL $server->register( - 'getContact', - // Entry values - array('authentication'=>'tns:authentication', 'id'=>'xsd:string', 'ref_ext'=>'xsd:string'), - // Exit values - array('result'=>'tns:result', 'contact'=>'tns:contact'), - $ns, - $ns.'#getContact', - $styledoc, - $styleuse, - 'WS to get a contact' + 'getContact', + // Entry values + array('authentication'=>'tns:authentication', 'id'=>'xsd:string', 'ref_ext'=>'xsd:string'), + // Exit values + array('result'=>'tns:result', 'contact'=>'tns:contact'), + $ns, + $ns.'#getContact', + $styledoc, + $styleuse, + 'WS to get a contact' ); // Register WSDL @@ -243,113 +243,113 @@ $server->register( */ function getContact($authentication, $id, $ref_ext) { - global $db, $conf, $langs; + global $db, $conf, $langs; - dol_syslog("Function: getContact login=".$authentication['login']." id=".$id." ref_ext=".$ref_ext); + dol_syslog("Function: getContact login=".$authentication['login']." id=".$id." ref_ext=".$ref_ext); - if ($authentication['entity']) $conf->entity = $authentication['entity']; + if ($authentication['entity']) $conf->entity = $authentication['entity']; - // Init and check authentication - $objectresp = array(); - $errorcode = ''; $errorlabel = ''; - $error = 0; - $fuser = check_authentication($authentication, $error, $errorcode, $errorlabel); - // Check parameters - if (!$error && ($id && $ref_ext)) - { - $error++; - $errorcode = 'BAD_PARAMETERS'; $errorlabel = "Parameter id and ref_ext can't be both provided. You must choose one or other but not both."; - } + // Init and check authentication + $objectresp = array(); + $errorcode = ''; $errorlabel = ''; + $error = 0; + $fuser = check_authentication($authentication, $error, $errorcode, $errorlabel); + // Check parameters + if (!$error && ($id && $ref_ext)) + { + $error++; + $errorcode = 'BAD_PARAMETERS'; $errorlabel = "Parameter id and ref_ext can't be both provided. You must choose one or other but not both."; + } - if (!$error) - { - $fuser->getrights(); + if (!$error) + { + $fuser->getrights(); - $contact = new Contact($db); - $result = $contact->fetch($id, 0, $ref_ext); - if ($result > 0) - { - // Only internal user who have contact read permission - // Or for external user who have contact read permission, with restrict on societe_id - if ( - $fuser->rights->societe->contact->lire && !$fuser->societe_id - || ($fuser->rights->societe->contact->lire && ($fuser->societe_id == $contact->socid)) - ) { - $contact_result_fields = array( - 'id' => $contact->id, - 'ref_ext' => $contact->ref_ext, - 'lastname' => $contact->lastname, - 'firstname' => $contact->firstname, - 'address' => $contact->address, - 'zip' => $contact->zip, - 'town' => $contact->town, - 'state_id' => $contact->state_id, - 'state_code' => $contact->state_code, - 'state' => $contact->state, - 'country_id' => $contact->country_id, - 'country_code' => $contact->country_code, - 'country' => $contact->country, - 'socid' => $contact->socid, - 'status' => $contact->statut, - 'phone_pro' => $contact->phone_pro, - 'fax' => $contact->fax, - 'phone_perso' => $contact->phone_perso, - 'phone_mobile' => $contact->phone_mobile, - 'code' => $contact->code, - 'email' => $contact->email, - 'birthday' => $contact->birthday, - 'default_lang' => $contact->default_lang, - 'note' => $contact->note, - 'ref_facturation' => $contact->ref_facturation, - 'ref_contrat' => $contact->ref_contrat, - 'ref_commande' => $contact->ref_commande, - 'ref_propal' => $contact->ref_propal, - 'user_id' => $contact->user_id, - 'user_login' => $contact->user_login, - 'civility_id' => $contact->civility_id, - 'poste' => $contact->poste - ); + $contact = new Contact($db); + $result = $contact->fetch($id, 0, $ref_ext); + if ($result > 0) + { + // Only internal user who have contact read permission + // Or for external user who have contact read permission, with restrict on societe_id + if ( + $fuser->rights->societe->contact->lire && !$fuser->societe_id + || ($fuser->rights->societe->contact->lire && ($fuser->societe_id == $contact->socid)) + ) { + $contact_result_fields = array( + 'id' => $contact->id, + 'ref_ext' => $contact->ref_ext, + 'lastname' => $contact->lastname, + 'firstname' => $contact->firstname, + 'address' => $contact->address, + 'zip' => $contact->zip, + 'town' => $contact->town, + 'state_id' => $contact->state_id, + 'state_code' => $contact->state_code, + 'state' => $contact->state, + 'country_id' => $contact->country_id, + 'country_code' => $contact->country_code, + 'country' => $contact->country, + 'socid' => $contact->socid, + 'status' => $contact->statut, + 'phone_pro' => $contact->phone_pro, + 'fax' => $contact->fax, + 'phone_perso' => $contact->phone_perso, + 'phone_mobile' => $contact->phone_mobile, + 'code' => $contact->code, + 'email' => $contact->email, + 'birthday' => $contact->birthday, + 'default_lang' => $contact->default_lang, + 'note' => $contact->note, + 'ref_facturation' => $contact->ref_facturation, + 'ref_contrat' => $contact->ref_contrat, + 'ref_commande' => $contact->ref_commande, + 'ref_propal' => $contact->ref_propal, + 'user_id' => $contact->user_id, + 'user_login' => $contact->user_login, + 'civility_id' => $contact->civility_id, + 'poste' => $contact->poste + ); - $elementtype = 'socpeople'; + $elementtype = 'socpeople'; - //Retrieve all extrafield for thirdsparty - // fetch optionals attributes and labels - $extrafields = new ExtraFields($db); - $extrafields->fetch_name_optionals_label($elementtype, true); - //Get extrafield values - $contact->fetch_optionals(); + //Retrieve all extrafield for thirdsparty + // fetch optionals attributes and labels + $extrafields = new ExtraFields($db); + $extrafields->fetch_name_optionals_label($elementtype, true); + //Get extrafield values + $contact->fetch_optionals(); - if (is_array($extrafields->attributes[$elementtype]['label']) && count($extrafields->attributes[$elementtype]['label'])) - { - foreach ($extrafields->attributes[$elementtype]['label'] as $key=>$label) - { - $contact_result_fields = array_merge($contact_result_fields, array('options_'.$key => $contact->array_options['options_'.$key])); - } - } + if (is_array($extrafields->attributes[$elementtype]['label']) && count($extrafields->attributes[$elementtype]['label'])) + { + foreach ($extrafields->attributes[$elementtype]['label'] as $key=>$label) + { + $contact_result_fields = array_merge($contact_result_fields, array('options_'.$key => $contact->array_options['options_'.$key])); + } + } - // Create - $objectresp = array( - 'result'=>array('result_code'=>'OK', 'result_label'=>''), - 'contact'=>$contact_result_fields - ); - } - else { - $error++; - $errorcode = 'PERMISSION_DENIED'; $errorlabel = 'User does not have permission for this request'; - } - } - else { - $error++; - $errorcode = 'NOT_FOUND'; $errorlabel = 'Object not found for id='.$id.' nor ref_ext='.$ref_ext; - } - } + // Create + $objectresp = array( + 'result'=>array('result_code'=>'OK', 'result_label'=>''), + 'contact'=>$contact_result_fields + ); + } + else { + $error++; + $errorcode = 'PERMISSION_DENIED'; $errorlabel = 'User does not have permission for this request'; + } + } + else { + $error++; + $errorcode = 'NOT_FOUND'; $errorlabel = 'Object not found for id='.$id.' nor ref_ext='.$ref_ext; + } + } - if ($error) - { - $objectresp = array('result'=>array('result_code' => $errorcode, 'result_label' => $errorlabel)); - } + if ($error) + { + $objectresp = array('result'=>array('result_code' => $errorcode, 'result_label' => $errorlabel)); + } - return $objectresp; + return $objectresp; } @@ -623,11 +623,11 @@ function updateContact($authentication, $contact) $error++; $errorcode = 'KO'; $errorlabel = "Contact id or ref_ext is mandatory."; } // Check parameters - if (!$error && ($id && $ref_ext)) - { - $error++; - $errorcode = 'BAD_PARAMETERS'; $errorlabel = "Parameter id and ref_ext can't be all provided. You must choose one of them."; - } + if (!$error && ($id && $ref_ext)) + { + $error++; + $errorcode = 'BAD_PARAMETERS'; $errorlabel = "Parameter id and ref_ext can't be all provided. You must choose one of them."; + } if (!$error) { diff --git a/htdocs/webservices/server_productorservice.php b/htdocs/webservices/server_productorservice.php index d7fbe8283ed..224b2f00fa7 100644 --- a/htdocs/webservices/server_productorservice.php +++ b/htdocs/webservices/server_productorservice.php @@ -44,11 +44,11 @@ $langs->load("main"); // Enable and test if module web services is enabled if (empty($conf->global->MAIN_MODULE_WEBSERVICES)) { - $langs->load("admin"); - dol_syslog("Call Dolibarr webservices interfaces with module webservices disabled"); - print $langs->trans("WarningModuleNotActive", 'WebServices').'.

    '; - print $langs->trans("ToActivateModule"); - exit; + $langs->load("admin"); + dol_syslog("Call Dolibarr webservices interfaces with module webservices disabled"); + print $langs->trans("WarningModuleNotActive", 'WebServices').'.

    '; + print $langs->trans("ToActivateModule"); + exit; } // Create the soap Object @@ -62,72 +62,72 @@ $server->wsdl->schemaTargetNamespace = $ns; // Define WSDL Authentication object $server->wsdl->addComplexType( - 'authentication', - 'complexType', - 'struct', - 'all', - '', - array( - 'dolibarrkey' => array('name'=>'dolibarrkey', 'type'=>'xsd:string'), - 'sourceapplication' => array('name'=>'sourceapplication', 'type'=>'xsd:string'), - 'login' => array('name'=>'login', 'type'=>'xsd:string'), - 'password' => array('name'=>'password', 'type'=>'xsd:string'), - 'entity' => array('name'=>'entity', 'type'=>'xsd:string') - ) + 'authentication', + 'complexType', + 'struct', + 'all', + '', + array( + 'dolibarrkey' => array('name'=>'dolibarrkey', 'type'=>'xsd:string'), + 'sourceapplication' => array('name'=>'sourceapplication', 'type'=>'xsd:string'), + 'login' => array('name'=>'login', 'type'=>'xsd:string'), + 'password' => array('name'=>'password', 'type'=>'xsd:string'), + 'entity' => array('name'=>'entity', 'type'=>'xsd:string') + ) ); // Define WSDL Return object $server->wsdl->addComplexType( - 'result', - 'complexType', - 'struct', - 'all', - '', - array( - 'result_code' => array('name'=>'result_code', 'type'=>'xsd:string'), - 'result_label' => array('name'=>'result_label', 'type'=>'xsd:string') - ) + 'result', + 'complexType', + 'struct', + 'all', + '', + array( + 'result_code' => array('name'=>'result_code', 'type'=>'xsd:string'), + 'result_label' => array('name'=>'result_label', 'type'=>'xsd:string') + ) ); $productorservice_fields = array( - 'id' => array('name'=>'id', 'type'=>'xsd:string'), - 'ref' => array('name'=>'ref', 'type'=>'xsd:string'), - 'ref_ext' => array('name'=>'ref_ext', 'type'=>'xsd:string'), - 'type' => array('name'=>'type', 'type'=>'xsd:string'), - 'label' => array('name'=>'label', 'type'=>'xsd:string'), - 'description' => array('name'=>'description', 'type'=>'xsd:string'), - 'date_creation' => array('name'=>'date_creation', 'type'=>'xsd:dateTime'), - 'date_modification' => array('name'=>'date_modification', 'type'=>'xsd:dateTime'), - 'note' => array('name'=>'note', 'type'=>'xsd:string'), - 'status_tobuy' => array('name'=>'status_tobuy', 'type'=>'xsd:string'), - 'status_tosell' => array('name'=>'status_tosell', 'type'=>'xsd:string'), - 'barcode' => array('name'=>'barcode', 'type'=>'xsd:string'), - 'barcode_type' => array('name'=>'barcode_type', 'type'=>'xsd:string'), - 'country_id' => array('name'=>'country_id', 'type'=>'xsd:string'), - 'country_code' => array('name'=>'country_code', 'type'=>'xsd:string'), - 'customcode' => array('name'=>'customcode', 'type'=>'xsd:string'), + 'id' => array('name'=>'id', 'type'=>'xsd:string'), + 'ref' => array('name'=>'ref', 'type'=>'xsd:string'), + 'ref_ext' => array('name'=>'ref_ext', 'type'=>'xsd:string'), + 'type' => array('name'=>'type', 'type'=>'xsd:string'), + 'label' => array('name'=>'label', 'type'=>'xsd:string'), + 'description' => array('name'=>'description', 'type'=>'xsd:string'), + 'date_creation' => array('name'=>'date_creation', 'type'=>'xsd:dateTime'), + 'date_modification' => array('name'=>'date_modification', 'type'=>'xsd:dateTime'), + 'note' => array('name'=>'note', 'type'=>'xsd:string'), + 'status_tobuy' => array('name'=>'status_tobuy', 'type'=>'xsd:string'), + 'status_tosell' => array('name'=>'status_tosell', 'type'=>'xsd:string'), + 'barcode' => array('name'=>'barcode', 'type'=>'xsd:string'), + 'barcode_type' => array('name'=>'barcode_type', 'type'=>'xsd:string'), + 'country_id' => array('name'=>'country_id', 'type'=>'xsd:string'), + 'country_code' => array('name'=>'country_code', 'type'=>'xsd:string'), + 'customcode' => array('name'=>'customcode', 'type'=>'xsd:string'), - 'price_net' => array('name'=>'price_net', 'type'=>'xsd:string'), - 'price' => array('name'=>'price', 'type'=>'xsd:string'), - 'price_min_net' => array('name'=>'price_min_net', 'type'=>'xsd:string'), - 'price_min' => array('name'=>'price_min', 'type'=>'xsd:string'), + 'price_net' => array('name'=>'price_net', 'type'=>'xsd:string'), + 'price' => array('name'=>'price', 'type'=>'xsd:string'), + 'price_min_net' => array('name'=>'price_min_net', 'type'=>'xsd:string'), + 'price_min' => array('name'=>'price_min', 'type'=>'xsd:string'), - 'price_base_type' => array('name'=>'price_base_type', 'type'=>'xsd:string'), + 'price_base_type' => array('name'=>'price_base_type', 'type'=>'xsd:string'), - 'vat_rate' => array('name'=>'vat_rate', 'type'=>'xsd:string'), - 'vat_npr' => array('name'=>'vat_npr', 'type'=>'xsd:string'), - 'localtax1_tx' => array('name'=>'localtax1_tx', 'type'=>'xsd:string'), - 'localtax2_tx' => array('name'=>'localtax2_tx', 'type'=>'xsd:string'), + 'vat_rate' => array('name'=>'vat_rate', 'type'=>'xsd:string'), + 'vat_npr' => array('name'=>'vat_npr', 'type'=>'xsd:string'), + 'localtax1_tx' => array('name'=>'localtax1_tx', 'type'=>'xsd:string'), + 'localtax2_tx' => array('name'=>'localtax2_tx', 'type'=>'xsd:string'), - 'stock_alert' => array('name'=>'stock_alert', 'type'=>'xsd:string'), - 'stock_real' => array('name'=>'stock_real', 'type'=>'xsd:string'), - 'stock_pmp' => array('name'=>'stock_pmp', 'type'=>'xsd:string'), - 'warehouse_ref' => array('name'=>'warehouse_ref', 'type'=>'xsd:string'), // Used only for create or update to set which warehouse to use for stock correction if stock_real differs from database + 'stock_alert' => array('name'=>'stock_alert', 'type'=>'xsd:string'), + 'stock_real' => array('name'=>'stock_real', 'type'=>'xsd:string'), + 'stock_pmp' => array('name'=>'stock_pmp', 'type'=>'xsd:string'), + 'warehouse_ref' => array('name'=>'warehouse_ref', 'type'=>'xsd:string'), // Used only for create or update to set which warehouse to use for stock correction if stock_real differs from database - 'canvas' => array('name'=>'canvas', 'type'=>'xsd:string'), - 'import_key' => array('name'=>'import_key', 'type'=>'xsd:string'), + 'canvas' => array('name'=>'canvas', 'type'=>'xsd:string'), + 'import_key' => array('name'=>'import_key', 'type'=>'xsd:string'), - 'dir' => array('name'=>'dir', 'type'=>'xsd:string'), - 'images' => array('name'=>'images', 'type'=>'tns:ImagesArray') + 'dir' => array('name'=>'dir', 'type'=>'xsd:string'), + 'images' => array('name'=>'images', 'type'=>'tns:ImagesArray') ); @@ -158,12 +158,12 @@ if (is_array($extrafield_array)) $productorservice_fields = array_merge($product // Define other specific objects $server->wsdl->addComplexType( - 'product', - 'complexType', - 'struct', - 'all', - '', - $productorservice_fields + 'product', + 'complexType', + 'struct', + 'all', + '', + $productorservice_fields ); @@ -206,33 +206,33 @@ $server->wsdl->addComplexType( // Define other specific objects $server->wsdl->addComplexType( - 'filterproduct', - 'complexType', - 'struct', - 'all', - '', - array( - //'limit' => array('name'=>'limit','type'=>'xsd:string'), + 'filterproduct', + 'complexType', + 'struct', + 'all', + '', + array( + //'limit' => array('name'=>'limit','type'=>'xsd:string'), 'type' => array('name'=>'type', 'type'=>'xsd:string'), - 'status_tobuy' => array('name'=>'status_tobuy', 'type'=>'xsd:string'), - 'status_tosell' => array('name'=>'status_tosell', 'type'=>'xsd:string'), - ) + 'status_tobuy' => array('name'=>'status_tobuy', 'type'=>'xsd:string'), + 'status_tosell' => array('name'=>'status_tosell', 'type'=>'xsd:string'), + ) ); $server->wsdl->addComplexType( - 'ProductsArray2', - 'complexType', - 'array', - 'sequence', - '', - array( - 'product' => array( - 'name' => 'product', - 'type' => 'tns:product', - 'minOccurs' => '0', - 'maxOccurs' => 'unbounded' - ) - ) + 'ProductsArray2', + 'complexType', + 'array', + 'sequence', + '', + array( + 'product' => array( + 'name' => 'product', + 'type' => 'tns:product', + 'minOccurs' => '0', + 'maxOccurs' => 'unbounded' + ) + ) ); @@ -247,72 +247,72 @@ $styleuse = 'encoded'; // encoded/literal/literal wrapped // Register WSDL $server->register( - 'getProductOrService', - // Entry values - array('authentication'=>'tns:authentication', 'id'=>'xsd:string', 'ref'=>'xsd:string', 'ref_ext'=>'xsd:string', 'lang'=>'xsd:string'), - // Exit values - array('result'=>'tns:result', 'product'=>'tns:product'), - $ns, - $ns.'#getProductOrService', - $styledoc, - $styleuse, - 'WS to get product or service' + 'getProductOrService', + // Entry values + array('authentication'=>'tns:authentication', 'id'=>'xsd:string', 'ref'=>'xsd:string', 'ref_ext'=>'xsd:string', 'lang'=>'xsd:string'), + // Exit values + array('result'=>'tns:result', 'product'=>'tns:product'), + $ns, + $ns.'#getProductOrService', + $styledoc, + $styleuse, + 'WS to get product or service' ); // Register WSDL $server->register( - 'createProductOrService', - // Entry values - array('authentication'=>'tns:authentication', 'product'=>'tns:product'), - // Exit values - array('result'=>'tns:result', 'id'=>'xsd:string'), - $ns, - $ns.'#createProductOrService', - $styledoc, - $styleuse, - 'WS to create a product or service' + 'createProductOrService', + // Entry values + array('authentication'=>'tns:authentication', 'product'=>'tns:product'), + // Exit values + array('result'=>'tns:result', 'id'=>'xsd:string'), + $ns, + $ns.'#createProductOrService', + $styledoc, + $styleuse, + 'WS to create a product or service' ); // Register WSDL $server->register( - 'updateProductOrService', - // Entry values - array('authentication'=>'tns:authentication', 'product'=>'tns:product'), - // Exit values - array('result'=>'tns:result', 'id'=>'xsd:string'), - $ns, - $ns.'#updateProductOrService', - $styledoc, - $styleuse, - 'WS to update a product or service' + 'updateProductOrService', + // Entry values + array('authentication'=>'tns:authentication', 'product'=>'tns:product'), + // Exit values + array('result'=>'tns:result', 'id'=>'xsd:string'), + $ns, + $ns.'#updateProductOrService', + $styledoc, + $styleuse, + 'WS to update a product or service' ); // Register WSDL $server->register( - 'deleteProductOrService', - // Entry values - array('authentication'=>'tns:authentication', 'listofid'=>'xsd:string'), - // Exit values - array('result'=>'tns:result', 'nbdeleted'=>'xsd:int'), - $ns, - $ns.'#deleteProductOrService', - $styledoc, - $styleuse, - 'WS to delete a product or service' + 'deleteProductOrService', + // Entry values + array('authentication'=>'tns:authentication', 'listofid'=>'xsd:string'), + // Exit values + array('result'=>'tns:result', 'nbdeleted'=>'xsd:int'), + $ns, + $ns.'#deleteProductOrService', + $styledoc, + $styleuse, + 'WS to delete a product or service' ); // Register WSDL $server->register( - 'getListOfProductsOrServices', - // Entry values - array('authentication'=>'tns:authentication', 'filterproduct'=>'tns:filterproduct'), - // Exit values - array('result'=>'tns:result', 'products'=>'tns:ProductsArray2'), - $ns, - $ns.'#getListOfProductsOrServices', - $styledoc, - $styleuse, - 'WS to get list of all products or services id and ref' + 'getListOfProductsOrServices', + // Entry values + array('authentication'=>'tns:authentication', 'filterproduct'=>'tns:filterproduct'), + // Exit values + array('result'=>'tns:result', 'products'=>'tns:ProductsArray2'), + $ns, + $ns.'#getListOfProductsOrServices', + $styledoc, + $styleuse, + 'WS to get list of all products or services id and ref' ); // Register WSDL @@ -342,131 +342,131 @@ $server->register( */ function getProductOrService($authentication, $id = '', $ref = '', $ref_ext = '', $lang = '') { - global $db, $conf, $langs; + global $db, $conf, $langs; - dol_syslog("Function: getProductOrService login=".$authentication['login']." id=".$id." ref=".$ref." ref_ext=".$ref_ext); + dol_syslog("Function: getProductOrService login=".$authentication['login']." id=".$id." ref=".$ref." ref_ext=".$ref_ext); - $langcode = ($lang ? $lang : (empty($conf->global->MAIN_LANG_DEFAULT) ? 'auto' : $conf->global->MAIN_LANG_DEFAULT)); - $langs->setDefaultLang($langcode); + $langcode = ($lang ? $lang : (empty($conf->global->MAIN_LANG_DEFAULT) ? 'auto' : $conf->global->MAIN_LANG_DEFAULT)); + $langs->setDefaultLang($langcode); - if ($authentication['entity']) $conf->entity = $authentication['entity']; + if ($authentication['entity']) $conf->entity = $authentication['entity']; - // Init and check authentication - $objectresp = array(); - $errorcode = ''; $errorlabel = ''; - $error = 0; - $fuser = check_authentication($authentication, $error, $errorcode, $errorlabel); - // Check parameters - if (!$error && (($id && $ref) || ($id && $ref_ext) || ($ref && $ref_ext))) - { - $error++; - $errorcode = 'BAD_PARAMETERS'; $errorlabel = "Parameter id, ref and ref_ext can't be both provided. You must choose one or other but not both."; - } + // Init and check authentication + $objectresp = array(); + $errorcode = ''; $errorlabel = ''; + $error = 0; + $fuser = check_authentication($authentication, $error, $errorcode, $errorlabel); + // Check parameters + if (!$error && (($id && $ref) || ($id && $ref_ext) || ($ref && $ref_ext))) + { + $error++; + $errorcode = 'BAD_PARAMETERS'; $errorlabel = "Parameter id, ref and ref_ext can't be both provided. You must choose one or other but not both."; + } - if (!$error) - { - $langcode = ($lang ? $lang : (empty($conf->global->MAIN_LANG_DEFAULT) ? 'auto' : $conf->global->MAIN_LANG_DEFAULT)); - $langs->setDefaultLang($langcode); + if (!$error) + { + $langcode = ($lang ? $lang : (empty($conf->global->MAIN_LANG_DEFAULT) ? 'auto' : $conf->global->MAIN_LANG_DEFAULT)); + $langs->setDefaultLang($langcode); - $fuser->getrights(); + $fuser->getrights(); - $nbmax = 10; - if ($fuser->rights->produit->lire || $fuser->rights->service->lire) - { - $product = new Product($db); - $result = $product->fetch($id, $ref, $ref_ext); + $nbmax = 10; + if ($fuser->rights->produit->lire || $fuser->rights->service->lire) + { + $product = new Product($db); + $result = $product->fetch($id, $ref, $ref_ext); - if ($result > 0) - { - $product->load_stock(); + if ($result > 0) + { + $product->load_stock(); - $dir = (!empty($conf->product->dir_output) ? $conf->product->dir_output : $conf->service->dir_output); - $pdir = get_exdir($product->id, 2, 0, 0, $product, 'product').$product->ref."/"; - $dir = $dir.'/'.$pdir; + $dir = (!empty($conf->product->dir_output) ? $conf->product->dir_output : $conf->service->dir_output); + $pdir = get_exdir($product->id, 2, 0, 0, $product, 'product').$product->ref."/"; + $dir = $dir.'/'.$pdir; - if (!empty($product->multilangs[$langs->defaultlang]["label"])) $product->label = $product->multilangs[$langs->defaultlang]["label"]; - if (!empty($product->multilangs[$langs->defaultlang]["description"])) $product->description = $product->multilangs[$langs->defaultlang]["description"]; - if (!empty($product->multilangs[$langs->defaultlang]["note"])) $product->note = $product->multilangs[$langs->defaultlang]["note"]; + if (!empty($product->multilangs[$langs->defaultlang]["label"])) $product->label = $product->multilangs[$langs->defaultlang]["label"]; + if (!empty($product->multilangs[$langs->defaultlang]["description"])) $product->description = $product->multilangs[$langs->defaultlang]["description"]; + if (!empty($product->multilangs[$langs->defaultlang]["note"])) $product->note = $product->multilangs[$langs->defaultlang]["note"]; - $productorservice_result_fields = array( - 'id' => $product->id, - 'ref' => $product->ref, - 'ref_ext' => $product->ref_ext, - 'label' => $product->label, - 'description' => $product->description, - 'date_creation' => dol_print_date($product->date_creation, 'dayhourrfc'), - 'date_modification' => dol_print_date($product->date_modification, 'dayhourrfc'), - 'note' => $product->note, - 'status_tosell' => $product->status, - 'status_tobuy' => $product->status_buy, - 'type' => $product->type, - 'barcode' => $product->barcode, - 'barcode_type' => $product->barcode_type, - 'country_id' => $product->country_id > 0 ? $product->country_id : '', - 'country_code' => $product->country_code, - 'custom_code' => $product->customcode, + $productorservice_result_fields = array( + 'id' => $product->id, + 'ref' => $product->ref, + 'ref_ext' => $product->ref_ext, + 'label' => $product->label, + 'description' => $product->description, + 'date_creation' => dol_print_date($product->date_creation, 'dayhourrfc'), + 'date_modification' => dol_print_date($product->date_modification, 'dayhourrfc'), + 'note' => $product->note, + 'status_tosell' => $product->status, + 'status_tobuy' => $product->status_buy, + 'type' => $product->type, + 'barcode' => $product->barcode, + 'barcode_type' => $product->barcode_type, + 'country_id' => $product->country_id > 0 ? $product->country_id : '', + 'country_code' => $product->country_code, + 'custom_code' => $product->customcode, - 'price_net' => $product->price, - 'price' => $product->price_ttc, - 'price_min_net' => $product->price_min, - 'price_min' => $product->price_min_ttc, - 'price_base_type' => $product->price_base_type, - 'vat_rate' => $product->tva_tx, - //! French VAT NPR - 'vat_npr' => $product->tva_npr, - //! Spanish local taxes - 'localtax1_tx' => $product->localtax1_tx, - 'localtax2_tx' => $product->localtax2_tx, + 'price_net' => $product->price, + 'price' => $product->price_ttc, + 'price_min_net' => $product->price_min, + 'price_min' => $product->price_min_ttc, + 'price_base_type' => $product->price_base_type, + 'vat_rate' => $product->tva_tx, + //! French VAT NPR + 'vat_npr' => $product->tva_npr, + //! Spanish local taxes + 'localtax1_tx' => $product->localtax1_tx, + 'localtax2_tx' => $product->localtax2_tx, - 'stock_real' => $product->stock_reel, - 'stock_virtual' => $product->stock_theorique, - 'stock_alert' => $product->seuil_stock_alerte, - 'pmp' => $product->pmp, - 'import_key' => $product->import_key, - 'dir' => $pdir, - 'images' => $product->liste_photos($dir, $nbmax) - ); + 'stock_real' => $product->stock_reel, + 'stock_virtual' => $product->stock_theorique, + 'stock_alert' => $product->seuil_stock_alerte, + 'pmp' => $product->pmp, + 'import_key' => $product->import_key, + 'dir' => $pdir, + 'images' => $product->liste_photos($dir, $nbmax) + ); - $elementtype = 'product'; + $elementtype = 'product'; - //Retrieve all extrafield for thirdsparty - // fetch optionals attributes and labels - $extrafields = new ExtraFields($db); - $extrafields->fetch_name_optionals_label($elementtype, true); - //Get extrafield values - $product->fetch_optionals(); + //Retrieve all extrafield for thirdsparty + // fetch optionals attributes and labels + $extrafields = new ExtraFields($db); + $extrafields->fetch_name_optionals_label($elementtype, true); + //Get extrafield values + $product->fetch_optionals(); - if (is_array($extrafields->attributes[$elementtype]['label']) && count($extrafields->attributes[$elementtype]['label'])) - { - foreach ($extrafields->attributes[$elementtype]['label'] as $key=>$label) - { - $productorservice_result_fields = array_merge($productorservice_result_fields, array('options_'.$key => $product->array_options['options_'.$key])); - } - } + if (is_array($extrafields->attributes[$elementtype]['label']) && count($extrafields->attributes[$elementtype]['label'])) + { + foreach ($extrafields->attributes[$elementtype]['label'] as $key=>$label) + { + $productorservice_result_fields = array_merge($productorservice_result_fields, array('options_'.$key => $product->array_options['options_'.$key])); + } + } - // Create - $objectresp = array( - 'result'=>array('result_code'=>'OK', 'result_label'=>''), - 'product'=>$productorservice_result_fields - ); - } - else { - $error++; - $errorcode = 'NOT_FOUND'; $errorlabel = 'Object not found for id='.$id.' nor ref='.$ref.' nor ref_ext='.$ref_ext; - } - } - else { - $error++; - $errorcode = 'PERMISSION_DENIED'; $errorlabel = 'User does not have permission for this request'; - } - } + // Create + $objectresp = array( + 'result'=>array('result_code'=>'OK', 'result_label'=>''), + 'product'=>$productorservice_result_fields + ); + } + else { + $error++; + $errorcode = 'NOT_FOUND'; $errorlabel = 'Object not found for id='.$id.' nor ref='.$ref.' nor ref_ext='.$ref_ext; + } + } + else { + $error++; + $errorcode = 'PERMISSION_DENIED'; $errorlabel = 'User does not have permission for this request'; + } + } - if ($error) - { - $objectresp = array('result'=>array('result_code' => $errorcode, 'result_label' => $errorlabel)); - } + if ($error) + { + $objectresp = array('result'=>array('result_code' => $errorcode, 'result_label' => $errorlabel)); + } //var_dump($objectresp);exit; - return $objectresp; + return $objectresp; } @@ -479,54 +479,54 @@ function getProductOrService($authentication, $id = '', $ref = '', $ref_ext = '' */ function createProductOrService($authentication, $product) { - global $db, $conf, $langs; + global $db, $conf, $langs; - $now = dol_now(); + $now = dol_now(); - dol_syslog("Function: createProductOrService login=".$authentication['login']); + dol_syslog("Function: createProductOrService login=".$authentication['login']); - if ($authentication['entity']) $conf->entity = $authentication['entity']; + if ($authentication['entity']) $conf->entity = $authentication['entity']; - // Init and check authentication - $objectresp = array(); - $errorcode = ''; $errorlabel = ''; - $error = 0; - $fuser = check_authentication($authentication, $error, $errorcode, $errorlabel); - // Check parameters - if ($product['price_net'] > 0) $product['price_base_type'] = 'HT'; - if ($product['price'] > 0) $product['price_base_type'] = 'TTC'; + // Init and check authentication + $objectresp = array(); + $errorcode = ''; $errorlabel = ''; + $error = 0; + $fuser = check_authentication($authentication, $error, $errorcode, $errorlabel); + // Check parameters + if ($product['price_net'] > 0) $product['price_base_type'] = 'HT'; + if ($product['price'] > 0) $product['price_base_type'] = 'TTC'; - if ($product['price_net'] > 0 && $product['price'] > 0) - { - $error++; $errorcode = 'KO'; $errorlabel = "You must choose between price or price_net to provide price."; - } + if ($product['price_net'] > 0 && $product['price'] > 0) + { + $error++; $errorcode = 'KO'; $errorlabel = "You must choose between price or price_net to provide price."; + } - if ($product['barcode'] && !$product['barcode_type']) - { - $error++; $errorcode = 'KO'; $errorlabel = "You must set a barcode type when setting a barcode."; - } + if ($product['barcode'] && !$product['barcode_type']) + { + $error++; $errorcode = 'KO'; $errorlabel = "You must set a barcode type when setting a barcode."; + } - if (!$error) - { - include_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; + if (!$error) + { + include_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; - $newobject = new Product($db); - $newobject->ref = $product['ref']; - $newobject->ref_ext = $product['ref_ext']; - $newobject->type = $product['type']; - $newobject->label = $product['label']; - $newobject->description = $product['description']; - $newobject->note_public = $product['note_public']; - $newobject->note_private = $product['note_private']; - $newobject->status = $product['status_tosell']; - $newobject->status_buy = $product['status_tobuy']; - $newobject->price = $product['price_net']; - $newobject->price_ttc = $product['price']; - $newobject->tva_tx = $product['vat_rate']; - $newobject->price_base_type = $product['price_base_type']; - $newobject->date_creation = $now; + $newobject = new Product($db); + $newobject->ref = $product['ref']; + $newobject->ref_ext = $product['ref_ext']; + $newobject->type = $product['type']; + $newobject->label = $product['label']; + $newobject->description = $product['description']; + $newobject->note_public = $product['note_public']; + $newobject->note_private = $product['note_private']; + $newobject->status = $product['status_tosell']; + $newobject->status_buy = $product['status_tobuy']; + $newobject->price = $product['price_net']; + $newobject->price_ttc = $product['price']; + $newobject->tva_tx = $product['vat_rate']; + $newobject->price_base_type = $product['price_base_type']; + $newobject->date_creation = $now; if ($product['barcode']) { @@ -534,16 +534,16 @@ function createProductOrService($authentication, $product) $newobject->barcode_type = $product['barcode_type']; } - $newobject->stock_reel = $product['stock_real']; - $newobject->pmp = $product['pmp']; - $newobject->seuil_stock_alert = $product['stock_alert']; + $newobject->stock_reel = $product['stock_real']; + $newobject->pmp = $product['pmp']; + $newobject->seuil_stock_alert = $product['stock_alert']; - $newobject->country_id = $product['country_id']; - if ($product['country_code']) $newobject->country_id = getCountry($product['country_code'], 3); - $newobject->customcode = $product['customcode']; + $newobject->country_id = $product['country_id']; + if ($product['country_code']) $newobject->country_id = getCountry($product['country_code'], 3); + $newobject->customcode = $product['customcode']; - $newobject->canvas = $product['canvas']; - /*foreach($product['lines'] as $line) + $newobject->canvas = $product['canvas']; + /*foreach($product['lines'] as $line) { $newline=new FactureLigne($db); $newline->type=$line['type']; @@ -556,13 +556,13 @@ function createProductOrService($authentication, $product) $newline->qty=$line['qty']; $newline->fk_product=$line['product_id']; }*/ - //var_dump($product['ref_ext']); - //var_dump($product['lines'][0]['type']); + //var_dump($product['ref_ext']); + //var_dump($product['lines'][0]['type']); - $elementtype = 'product'; + $elementtype = 'product'; - $extrafields = new ExtraFields($db); - $extrafields->fetch_name_optionals_label($elementtype, true); + $extrafields = new ExtraFields($db); + $extrafields->fetch_name_optionals_label($elementtype, true); if (is_array($extrafields->attributes[$elementtype]['label']) && count($extrafields->attributes[$elementtype]['label'])) { foreach ($extrafields->attributes[$elementtype]['label'] as $key=>$label) @@ -572,17 +572,17 @@ function createProductOrService($authentication, $product) } } - $db->begin(); + $db->begin(); - $result = $newobject->create($fuser, 0); - if ($result <= 0) - { - $error++; - } + $result = $newobject->create($fuser, 0); + if ($result <= 0) + { + $error++; + } - if (!$error) - { - // Update stock if stock count is provided and differs from database after creation or update + if (!$error) + { + // Update stock if stock count is provided and differs from database after creation or update if (isset($product['stock_real']) && $product['stock_real'] != '' && !empty($conf->global->stock->enabled)) { include_once DOL_DOCUMENT_ROOT.'/product/stock/class/entrepot.class.php'; @@ -619,25 +619,25 @@ function createProductOrService($authentication, $product) } } - if (!$error) - { - $db->commit(); - $objectresp = array('result'=>array('result_code'=>'OK', 'result_label'=>''), 'id'=>$newobject->id, 'ref'=>$newobject->ref); - } - else { - $db->rollback(); - $error++; - $errorcode = 'KO'; - $errorlabel = $newobject->error; - } - } + if (!$error) + { + $db->commit(); + $objectresp = array('result'=>array('result_code'=>'OK', 'result_label'=>''), 'id'=>$newobject->id, 'ref'=>$newobject->ref); + } + else { + $db->rollback(); + $error++; + $errorcode = 'KO'; + $errorlabel = $newobject->error; + } + } - if ($error) - { - $objectresp = array('result'=>array('result_code' => $errorcode, 'result_label' => $errorlabel)); - } + if ($error) + { + $objectresp = array('result'=>array('result_code' => $errorcode, 'result_label' => $errorlabel)); + } - return $objectresp; + return $objectresp; } @@ -714,21 +714,6 @@ function updateProductOrService($authentication, $product) $newobject->customcode = $product['customcode']; $newobject->canvas = $product['canvas']; - /*foreach($product['lines'] as $line) - { - $newline=new FactureLigne($db); - $newline->type=$line['type']; - $newline->desc=$line['desc']; - $newline->fk_product=$line['fk_product']; - $newline->total_ht=$line['total_net']; - $newline->total_vat=$line['total_vat']; - $newline->total_ttc=$line['total']; - $newline->vat=$line['vat_rate']; - $newline->qty=$line['qty']; - $newline->fk_product=$line['product_id']; - }*/ - //var_dump($product['ref_ext']); - //var_dump($product['lines'][0]['type']); $elementtype = 'product'; @@ -743,15 +728,15 @@ function updateProductOrService($authentication, $product) } } - $db->begin(); + $db->begin(); - $result = $newobject->update($newobject->id, $fuser); - if ($result <= 0) - { - $error++; - } - else { - // Update stock if stock count is provided and differs from database after creation or update + $result = $newobject->update($newobject->id, $fuser); + if ($result <= 0) + { + $error++; + } + else { + // Update stock if stock count is provided and differs from database after creation or update if (isset($product['stock_real']) && $product['stock_real'] != '' && !empty($conf->global->stock->enabled)) { include_once DOL_DOCUMENT_ROOT.'/product/stock/class/entrepot.class.php'; @@ -786,47 +771,47 @@ function updateProductOrService($authentication, $product) } } } - } + } - if (!$error) - { - if ($newobject->price_base_type == 'HT') - { - $result = $newobject->updatePrice($newobject->price, $newobject->price_base_type, $fuser); - if ($result <= 0) - { - $error++; - } - } - elseif ($newobject->price_base_type == 'TTC') - { - $result = $newobject->updatePrice($newobject->price_ttc, $newobject->price_base_type); - if ($result <= 0) - { - $error++; - } - } - } + if (!$error) + { + if ($newobject->price_base_type == 'HT') + { + $result = $newobject->updatePrice($newobject->price, $newobject->price_base_type, $fuser); + if ($result <= 0) + { + $error++; + } + } + elseif ($newobject->price_base_type == 'TTC') + { + $result = $newobject->updatePrice($newobject->price_ttc, $newobject->price_base_type); + if ($result <= 0) + { + $error++; + } + } + } - if (!$error) - { - $db->commit(); - $objectresp = array('result'=>array('result_code'=>'OK', 'result_label'=>''), 'id'=>$newobject->id, 'ref'=>$newobject->ref); - } - else { - $db->rollback(); - $error++; - $errorcode = 'KO'; - $errorlabel = $newobject->error; - } - } + if (!$error) + { + $db->commit(); + $objectresp = array('result'=>array('result_code'=>'OK', 'result_label'=>''), 'id'=>$newobject->id, 'ref'=>$newobject->ref); + } + else { + $db->rollback(); + $error++; + $errorcode = 'KO'; + $errorlabel = $newobject->error; + } + } - if ($error) - { - $objectresp = array('result'=>array('result_code' => $errorcode, 'result_label' => $errorlabel)); - } + if ($error) + { + $objectresp = array('result'=>array('result_code' => $errorcode, 'result_label' => $errorlabel)); + } - return $objectresp; + return $objectresp; } @@ -839,87 +824,87 @@ function updateProductOrService($authentication, $product) */ function deleteProductOrService($authentication, $listofidstring) { - global $db, $conf, $langs; + global $db, $conf, $langs; - dol_syslog("Function: deleteProductOrService login=".$authentication['login']); + dol_syslog("Function: deleteProductOrService login=".$authentication['login']); - if ($authentication['entity']) $conf->entity = $authentication['entity']; + if ($authentication['entity']) $conf->entity = $authentication['entity']; - // Init and check authentication - $objectresp = array(); - $errorcode = ''; $errorlabel = ''; - $error = 0; - $fuser = check_authentication($authentication, $error, $errorcode, $errorlabel); + // Init and check authentication + $objectresp = array(); + $errorcode = ''; $errorlabel = ''; + $error = 0; + $fuser = check_authentication($authentication, $error, $errorcode, $errorlabel); // User must be defined to user authenticated - global $user; - $user = $fuser; + global $user; + $user = $fuser; - $listofid = explode(',', trim($listofidstring)); - $listofiddeleted = array(); + $listofid = explode(',', trim($listofidstring)); + $listofiddeleted = array(); - // Check parameters - if (count($listofid) == 0 || empty($listofid[0])) - { - $error++; $errorcode = 'KO'; $errorlabel = "List of Id of products or services to delete are required."; - } + // Check parameters + if (count($listofid) == 0 || empty($listofid[0])) + { + $error++; $errorcode = 'KO'; $errorlabel = "List of Id of products or services to delete are required."; + } - if (!$error) - { - $firsterror = ''; + if (!$error) + { + $firsterror = ''; $db->begin(); - foreach ($listofid as $key => $id) + foreach ($listofid as $key => $id) { - $newobject = new Product($db); - $result = $newobject->fetch($id); + $newobject = new Product($db); + $result = $newobject->fetch($id); - if ($result == 0) - { - $error++; - $firsterror = 'Product or service with id '.$id.' not found'; - break; - } - else { - $result = $newobject->delete($user); - if ($result <= 0) - { - $error++; - $firsterror = $newobject->error; - break; - } + if ($result == 0) + { + $error++; + $firsterror = 'Product or service with id '.$id.' not found'; + break; + } + else { + $result = $newobject->delete($user); + if ($result <= 0) + { + $error++; + $firsterror = $newobject->error; + break; + } - $listofiddeleted[] = $id; + $listofiddeleted[] = $id; } } - if (!$error) - { - $db->commit(); - //$objectresp=array('result'=>array('result_code'=>'OK', 'result_label'=>''), 'listofid'=>$listofiddeleted); - $objectresp = array('result'=>array('result_code'=>'OK', 'result_label'=>''), 'nbdeleted'=>count($listofiddeleted)); - } - else { - $db->rollback(); - $error++; - $errorcode = 'KO'; - $errorlabel = $firsterror; + if (!$error) + { + $db->commit(); + //$objectresp=array('result'=>array('result_code'=>'OK', 'result_label'=>''), 'listofid'=>$listofiddeleted); + $objectresp = array('result'=>array('result_code'=>'OK', 'result_label'=>''), 'nbdeleted'=>count($listofiddeleted)); } - } + else { + $db->rollback(); + $error++; + $errorcode = 'KO'; + $errorlabel = $firsterror; + } + } - if ($error) - { - //$objectresp = array('result'=>array('result_code' => $errorcode, 'result_label' => $errorlabel), 'listofid'=>$listofiddeleted); - $objectresp = array('result'=>array('result_code' => $errorcode, 'result_label' => $errorlabel), 'nbdeleted'=>0); - } - elseif (count($listofiddeleted) == 0) - { + if ($error) + { + //$objectresp = array('result'=>array('result_code' => $errorcode, 'result_label' => $errorlabel), 'listofid'=>$listofiddeleted); + $objectresp = array('result'=>array('result_code' => $errorcode, 'result_label' => $errorlabel), 'nbdeleted'=>0); + } + elseif (count($listofiddeleted) == 0) + { //$objectresp=array('result'=>array('result_code'=>'NOT_FOUND', 'result_label'=>'No product or service with id '.join(',',$listofid).' found'), 'listofid'=>$listofiddeleted); $objectresp = array('result'=>array('result_code'=>'NOT_FOUND', 'result_label'=>'No product or service with id '.join(',', $listofid).' found'), 'nbdeleted'=>0); - } + } - return $objectresp; + return $objectresp; } @@ -932,65 +917,65 @@ function deleteProductOrService($authentication, $listofidstring) */ function getListOfProductsOrServices($authentication, $filterproduct) { - global $db, $conf, $langs; + global $db, $conf, $langs; - dol_syslog("Function: getListOfProductsOrServices login=".$authentication['login']); + dol_syslog("Function: getListOfProductsOrServices login=".$authentication['login']); - if ($authentication['entity']) $conf->entity = $authentication['entity']; + if ($authentication['entity']) $conf->entity = $authentication['entity']; - // Init and check authentication - $objectresp = array(); - $arrayproducts = array(); - $errorcode = ''; $errorlabel = ''; - $error = 0; - $fuser = check_authentication($authentication, $error, $errorcode, $errorlabel); - // Check parameters + // Init and check authentication + $objectresp = array(); + $arrayproducts = array(); + $errorcode = ''; $errorlabel = ''; + $error = 0; + $fuser = check_authentication($authentication, $error, $errorcode, $errorlabel); + // Check parameters - if (!$error) - { - $sql = "SELECT rowid, ref, ref_ext"; - $sql .= " FROM ".MAIN_DB_PREFIX."product"; - $sql .= " WHERE entity=".$conf->entity; - foreach ($filterproduct as $key => $val) - { - if ($key == 'type' && $val >= 0) $sql .= " AND fk_product_type = ".$db->escape($val); - if ($key == 'status_tosell') $sql .= " AND tosell = ".$db->escape($val); - if ($key == 'status_tobuy') $sql .= " AND tobuy = ".$db->escape($val); - } + if (!$error) + { + $sql = "SELECT rowid, ref, ref_ext"; + $sql .= " FROM ".MAIN_DB_PREFIX."product"; + $sql .= " WHERE entity=".$conf->entity; + foreach ($filterproduct as $key => $val) + { + if ($key == 'type' && $val >= 0) $sql .= " AND fk_product_type = ".$db->escape($val); + if ($key == 'status_tosell') $sql .= " AND tosell = ".$db->escape($val); + if ($key == 'status_tobuy') $sql .= " AND tobuy = ".$db->escape($val); + } $resql = $db->query($sql); - if ($resql) - { - $num = $db->num_rows($resql); + if ($resql) + { + $num = $db->num_rows($resql); - $i = 0; - while ($i < $num) - { - $obj = $db->fetch_object($resql); - $arrayproducts[] = array('id'=>$obj->rowid, 'ref'=>$obj->ref, 'ref_ext'=>$obj->ref_ext); - $i++; - } - } - else { - $error++; - $errorcode = $db->lasterrno(); - $errorlabel = $db->lasterror(); - } - } + $i = 0; + while ($i < $num) + { + $obj = $db->fetch_object($resql); + $arrayproducts[] = array('id'=>$obj->rowid, 'ref'=>$obj->ref, 'ref_ext'=>$obj->ref_ext); + $i++; + } + } + else { + $error++; + $errorcode = $db->lasterrno(); + $errorlabel = $db->lasterror(); + } + } - if ($error) - { - $objectresp = array( + if ($error) + { + $objectresp = array( 'result'=>array('result_code' => $errorcode, 'result_label' => $errorlabel), - 'products'=>$arrayproducts - ); - } else { - $objectresp = array( + 'products'=>$arrayproducts + ); + } else { + $objectresp = array( 'result'=>array('result_code' => 'OK', 'result_label' => ''), - 'products'=>$arrayproducts - ); - } + 'products'=>$arrayproducts + ); + } - return $objectresp; + return $objectresp; } @@ -1065,34 +1050,34 @@ function getProductsForCategory($authentication, $id, $lang = '') $dir = $dir.'/'.$pdir; $products[] = array( - 'id' => $tmpproduct->id, + 'id' => $tmpproduct->id, 'ref' => $tmpproduct->ref, 'ref_ext' => $tmpproduct->ref_ext, - 'label' => !empty($tmpproduct->multilangs[$langs->defaultlang]["label"]) ? $tmpproduct->multilangs[$langs->defaultlang]["label"] : $tmpproduct->label, - 'description' => !empty($tmpproduct->multilangs[$langs->defaultlang]["description"]) ? $tmpproduct->multilangs[$langs->defaultlang]["description"] : $tmpproduct->description, - 'date_creation' => dol_print_date($tmpproduct->date_creation, 'dayhourrfc'), - 'date_modification' => dol_print_date($tmpproduct->date_modification, 'dayhourrfc'), - 'note' => !empty($tmpproduct->multilangs[$langs->defaultlang]["note"]) ? $tmpproduct->multilangs[$langs->defaultlang]["note"] : $tmpproduct->note, - 'status_tosell' => $tmpproduct->status, - 'status_tobuy' => $tmpproduct->status_buy, - 'type' => $tmpproduct->type, - 'barcode' => $tmpproduct->barcode, - 'barcode_type' => $tmpproduct->barcode_type, - 'country_id' => $tmpproduct->country_id > 0 ? $tmpproduct->country_id : '', - 'country_code' => $tmpproduct->country_code, - 'custom_code' => $tmpproduct->customcode, + 'label' => !empty($tmpproduct->multilangs[$langs->defaultlang]["label"]) ? $tmpproduct->multilangs[$langs->defaultlang]["label"] : $tmpproduct->label, + 'description' => !empty($tmpproduct->multilangs[$langs->defaultlang]["description"]) ? $tmpproduct->multilangs[$langs->defaultlang]["description"] : $tmpproduct->description, + 'date_creation' => dol_print_date($tmpproduct->date_creation, 'dayhourrfc'), + 'date_modification' => dol_print_date($tmpproduct->date_modification, 'dayhourrfc'), + 'note' => !empty($tmpproduct->multilangs[$langs->defaultlang]["note"]) ? $tmpproduct->multilangs[$langs->defaultlang]["note"] : $tmpproduct->note, + 'status_tosell' => $tmpproduct->status, + 'status_tobuy' => $tmpproduct->status_buy, + 'type' => $tmpproduct->type, + 'barcode' => $tmpproduct->barcode, + 'barcode_type' => $tmpproduct->barcode_type, + 'country_id' => $tmpproduct->country_id > 0 ? $tmpproduct->country_id : '', + 'country_code' => $tmpproduct->country_code, + 'custom_code' => $tmpproduct->customcode, - 'price_net' => $tmpproduct->price, - 'price' => $tmpproduct->price_ttc, - 'vat_rate' => $tmpproduct->tva_tx, + 'price_net' => $tmpproduct->price, + 'price' => $tmpproduct->price_ttc, + 'vat_rate' => $tmpproduct->tva_tx, 'price_base_type' => $tmpproduct->price_base_type, - 'stock_real' => $tmpproduct->stock_reel, - 'stock_alert' => $tmpproduct->seuil_stock_alerte, - 'pmp' => $tmpproduct->pmp, - 'import_key' => $tmpproduct->import_key, - 'dir' => $pdir, + 'stock_real' => $tmpproduct->stock_reel, + 'stock_alert' => $tmpproduct->seuil_stock_alerte, + 'pmp' => $tmpproduct->pmp, + 'import_key' => $tmpproduct->import_key, + 'dir' => $pdir, 'images' => $tmpproduct->liste_photos($dir, $nbmax) ); diff --git a/htdocs/website/index.php b/htdocs/website/index.php index 91ccccf0de6..dc3407b8f21 100644 --- a/htdocs/website/index.php +++ b/htdocs/website/index.php @@ -3150,7 +3150,7 @@ if ($action == 'editcss') print ''; - dol_fiche_end(); + print dol_get_fiche_end(); print ''; @@ -3240,7 +3240,7 @@ if ($action == 'createsite') //print ''; - //dol_fiche_end(); + //print dol_get_fiche_end(); print ''; @@ -3271,7 +3271,7 @@ if ($action == 'importsite') showWebsiteTemplates($website); - dol_fiche_end(); + print dol_get_fiche_end(); print ''; @@ -3684,7 +3684,7 @@ if ($action == 'editmeta' || $action == 'createcontainer') } //print ''; - //dol_fiche_end(); + //print dol_get_fiche_end(); print ''; diff --git a/htdocs/website/websiteaccount_card.php b/htdocs/website/websiteaccount_card.php index f450c190907..332ef81e9af 100644 --- a/htdocs/website/websiteaccount_card.php +++ b/htdocs/website/websiteaccount_card.php @@ -151,7 +151,7 @@ if ($action == 'create') print ''."\n"; - dol_fiche_end(); + print dol_get_fiche_end(); print '
    '; print ''; @@ -184,7 +184,7 @@ if (($id || $ref) && $action == 'edit') print ''; - dol_fiche_end(); + print dol_get_fiche_end(); print '
    '; print '   '; @@ -293,7 +293,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print '

    '; - dol_fiche_end(); + print dol_get_fiche_end(); // Buttons for actions diff --git a/htdocs/zapier/admin/about.php b/htdocs/zapier/admin/about.php index 12bc0071158..e67ba8861a2 100644 --- a/htdocs/zapier/admin/about.php +++ b/htdocs/zapier/admin/about.php @@ -71,6 +71,6 @@ $tmpmodule = new modZapier($db); print $tmpmodule->getDescLong(); // Page end -dol_fiche_end(); +print dol_get_fiche_end(); llxFooter(); $db->close(); diff --git a/htdocs/zapier/admin/setup.php b/htdocs/zapier/admin/setup.php index 2d6a779f44b..8f126a3e75d 100644 --- a/htdocs/zapier/admin/setup.php +++ b/htdocs/zapier/admin/setup.php @@ -117,7 +117,7 @@ if ($action == 'edit') { // Page end -dol_fiche_end(); +print dol_get_fiche_end(); llxFooter(); $db->close(); diff --git a/htdocs/zapier/class/api_zapier.class.php b/htdocs/zapier/class/api_zapier.class.php index 76c610fa2cd..5ad97434d07 100644 --- a/htdocs/zapier/class/api_zapier.class.php +++ b/htdocs/zapier/class/api_zapier.class.php @@ -34,241 +34,241 @@ require_once DOL_DOCUMENT_ROOT.'/zapier/class/hook.class.php'; */ class ZapierApi extends DolibarrApi { - /** - * @var array $FIELDS Mandatory fields, checked when create and update object - */ - static $FIELDS = array( - 'url', - ); + /** + * @var array $FIELDS Mandatory fields, checked when create and update object + */ + static $FIELDS = array( + 'url', + ); - /** - * @var Hook $hook {@type Hook} - */ - public $hook; + /** + * @var Hook $hook {@type Hook} + */ + public $hook; - /** - * Constructor - * - * @url GET / - * - */ - public function __construct() - { - global $db, $conf; - $this->db = $db; - $this->hook = new Hook($this->db); - } + /** + * Constructor + * + * @url GET / + * + */ + public function __construct() + { + global $db, $conf; + $this->db = $db; + $this->hook = new Hook($this->db); + } - /** - * Get properties of a hook object - * - * Return an array with hook informations - * - * @param int $id ID of hook - * @return array|mixed data without useless information - * - * @url GET /hooks/{id} - * @throws RestException - */ - public function get($id) - { - if (!DolibarrApiAccess::$user->rights->zapier->read) { - throw new RestException(401); - } + /** + * Get properties of a hook object + * + * Return an array with hook informations + * + * @param int $id ID of hook + * @return array|mixed data without useless information + * + * @url GET /hooks/{id} + * @throws RestException + */ + public function get($id) + { + if (!DolibarrApiAccess::$user->rights->zapier->read) { + throw new RestException(401); + } - $result = $this->hook->fetch($id); - if (!$result) { - throw new RestException(404, 'Hook not found'); - } + $result = $this->hook->fetch($id); + if (!$result) { + throw new RestException(404, 'Hook not found'); + } - if (!DolibarrApi::_checkAccessToResource('hook', $this->hook->id)) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); - } + if (!DolibarrApi::_checkAccessToResource('hook', $this->hook->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } - return $this->_cleanObjectDatas($this->hook); - } + return $this->_cleanObjectDatas($this->hook); + } - /** - * Get list of possibles choices for module - * - * Return an array with hook informations - * @param integer $id ID - * - * @return array|mixed data - * - * @url GET /getmoduleschoices/ - * @throws RestException - */ - public function getModulesChoices($id) - { - if (!DolibarrApiAccess::$user->rights->zapier->read) { - throw new RestException(401); - } - $arraychoices = array( - 'invoices' => 'Invoices', - 'orders' => 'Orders', - 'thirdparties' => 'Thirparties', - 'contacts' => 'Contacts', - ); - // $result = $this->hook->fetch($id); - // if (! $result ) { - // throw new RestException(404, 'Hook not found'); - // } + /** + * Get list of possibles choices for module + * + * Return an array with hook informations + * @param integer $id ID + * + * @return array|mixed data + * + * @url GET /getmoduleschoices/ + * @throws RestException + */ + public function getModulesChoices($id) + { + if (!DolibarrApiAccess::$user->rights->zapier->read) { + throw new RestException(401); + } + $arraychoices = array( + 'invoices' => 'Invoices', + 'orders' => 'Orders', + 'thirdparties' => 'Thirparties', + 'contacts' => 'Contacts', + ); + // $result = $this->hook->fetch($id); + // if (! $result ) { + // throw new RestException(404, 'Hook not found'); + // } - // if (! DolibarrApi::_checkAccessToResource('hook', $this->hook->id)) { - // throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); - // } + // if (! DolibarrApi::_checkAccessToResource('hook', $this->hook->id)) { + // throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + // } - return $arraychoices; - } + return $arraychoices; + } - /** - * List hooks - * - * Get a list of hooks - * - * @param string $sortfield Sort field - * @param string $sortorder Sort order - * @param int $limit Limit for list - * @param int $page Page number - * @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.ref:like:'SO-%') and (t.date_creation:<:'20160101')" - * @return array Array of order objects - * - * @throws RestException - * - * @url GET /hooks/ - */ - public function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $sqlfilters = '') - { - global $db, $conf; + /** + * List hooks + * + * Get a list of hooks + * + * @param string $sortfield Sort field + * @param string $sortorder Sort order + * @param int $limit Limit for list + * @param int $page Page number + * @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.ref:like:'SO-%') and (t.date_creation:<:'20160101')" + * @return array Array of order objects + * + * @throws RestException + * + * @url GET /hooks/ + */ + public function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $sqlfilters = '') + { + global $db, $conf; - $obj_ret = array(); + $obj_ret = array(); - $socid = DolibarrApiAccess::$user->socid ? DolibarrApiAccess::$user->socid : ''; + $socid = DolibarrApiAccess::$user->socid ? DolibarrApiAccess::$user->socid : ''; - // Set to 1 if there is a field socid in table of object - $restrictonsocid = 0; + // Set to 1 if there is a field socid in table of object + $restrictonsocid = 0; - // If the internal user must only see his customers, force searching by him - $search_sale = 0; - if ($restrictonsocid && !DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) { - $search_sale = DolibarrApiAccess::$user->id; - } + // If the internal user must only see his customers, force searching by him + $search_sale = 0; + if ($restrictonsocid && !DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) { + $search_sale = DolibarrApiAccess::$user->id; + } - $sql = "SELECT t.rowid"; - if ($restrictonsocid && (!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) { - // We need these fields in order to filter by sale (including the case where the user can only see his prospects) - $sql .= ", sc.fk_soc, sc.fk_user"; - } - $sql .= " FROM ".MAIN_DB_PREFIX."hook_mytable as t"; + $sql = "SELECT t.rowid"; + if ($restrictonsocid && (!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) { + // We need these fields in order to filter by sale (including the case where the user can only see his prospects) + $sql .= ", sc.fk_soc, sc.fk_user"; + } + $sql .= " FROM ".MAIN_DB_PREFIX."hook_mytable as t"; - if ($restrictonsocid && (!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; // We need this table joined to the select in order to filter by sale - $sql .= " WHERE 1 = 1"; + if ($restrictonsocid && (!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; // We need this table joined to the select in order to filter by sale + $sql .= " WHERE 1 = 1"; - // Example of use $mode - //if ($mode == 1) $sql.= " AND s.client IN (1, 3)"; - //if ($mode == 2) $sql.= " AND s.client IN (2, 3)"; + // Example of use $mode + //if ($mode == 1) $sql.= " AND s.client IN (1, 3)"; + //if ($mode == 2) $sql.= " AND s.client IN (2, 3)"; - $tmpobject = new Hook($this->db); - if ($tmpobject->ismultientitymanaged) { - $sql .= ' AND t.entity IN ('.getEntity('hook').')'; - } - if ($restrictonsocid && (!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) { - $sql .= " AND t.fk_soc = sc.fk_soc"; - } - if ($restrictonsocid && $socid) { - $sql .= " AND t.fk_soc = ".$socid; - } - if ($restrictonsocid && $search_sale > 0) { - // Join for the needed table to filter by sale - $sql .= " AND t.rowid = sc.fk_soc"; - } - // Insert sale filter - if ($restrictonsocid && $search_sale > 0) { - $sql .= " AND sc.fk_user = ".$search_sale; - } - if ($sqlfilters) { - if (!DolibarrApi::_checkFilters($sqlfilters)) { - throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); - } - $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; - $sql .= " AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; - } + $tmpobject = new Hook($this->db); + if ($tmpobject->ismultientitymanaged) { + $sql .= ' AND t.entity IN ('.getEntity('hook').')'; + } + if ($restrictonsocid && (!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) { + $sql .= " AND t.fk_soc = sc.fk_soc"; + } + if ($restrictonsocid && $socid) { + $sql .= " AND t.fk_soc = ".$socid; + } + if ($restrictonsocid && $search_sale > 0) { + // Join for the needed table to filter by sale + $sql .= " AND t.rowid = sc.fk_soc"; + } + // Insert sale filter + if ($restrictonsocid && $search_sale > 0) { + $sql .= " AND sc.fk_user = ".$search_sale; + } + if ($sqlfilters) { + if (!DolibarrApi::_checkFilters($sqlfilters)) { + throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); + } + $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; + $sql .= " AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; + } - $sql .= $this->db->order($sortfield, $sortorder); - if ($limit) { - if ($page < 0) { - $page = 0; - } - $offset = $limit * $page; + $sql .= $this->db->order($sortfield, $sortorder); + if ($limit) { + if ($page < 0) { + $page = 0; + } + $offset = $limit * $page; - $sql .= $this->db->plimit($limit + 1, $offset); - } + $sql .= $this->db->plimit($limit + 1, $offset); + } - $result = $this->db->query($sql); - $i = 0; - if ($result) { - $num = $this->db->num_rows($result); - while ($i < $num) { - $obj = $this->db->fetch_object($result); - $hook_static = new Hook($this->db); - if ($hook_static->fetch($obj->rowid)) { - $obj_ret[] = $this->_cleanObjectDatas($hook_static); - } - $i++; - } - } else { - throw new RestException(503, 'Error when retrieve hook list'); - } - if (!count($obj_ret)) { - throw new RestException(404, 'No hook found'); - } - return $obj_ret; - } + $result = $this->db->query($sql); + $i = 0; + if ($result) { + $num = $this->db->num_rows($result); + while ($i < $num) { + $obj = $this->db->fetch_object($result); + $hook_static = new Hook($this->db); + if ($hook_static->fetch($obj->rowid)) { + $obj_ret[] = $this->_cleanObjectDatas($hook_static); + } + $i++; + } + } else { + throw new RestException(503, 'Error when retrieve hook list'); + } + if (!count($obj_ret)) { + throw new RestException(404, 'No hook found'); + } + return $obj_ret; + } - /** - * Create hook object - * - * @param array $request_data Request datas - * @return int ID of hook - * - * @url POST /hook/ - */ - public function post($request_data = null) - { - if (!DolibarrApiAccess::$user->rights->zapier->write) { - throw new RestException(401); - } - // Check mandatory fields - $fields = array( - 'url', - ); - $result = $this->validate($request_data, $fields); + /** + * Create hook object + * + * @param array $request_data Request datas + * @return int ID of hook + * + * @url POST /hook/ + */ + public function post($request_data = null) + { + if (!DolibarrApiAccess::$user->rights->zapier->write) { + throw new RestException(401); + } + // Check mandatory fields + $fields = array( + 'url', + ); + $result = $this->validate($request_data, $fields); - foreach ($request_data as $field => $value) { - $this->hook->$field = $value; - } - $this->hook->fk_user = DolibarrApiAccess::$user->id; - // on crée le hook dans la base - if (!$this->hook->create(DolibarrApiAccess::$user)) { - throw new RestException(500, "Error creating Hook", array_merge(array($this->hook->error), $this->hook->errors)); - } - return array( - 'id' => $this->hook->id, - ); - } + foreach ($request_data as $field => $value) { + $this->hook->$field = $value; + } + $this->hook->fk_user = DolibarrApiAccess::$user->id; + // on crée le hook dans la base + if (!$this->hook->create(DolibarrApiAccess::$user)) { + throw new RestException(500, "Error creating Hook", array_merge(array($this->hook->error), $this->hook->errors)); + } + return array( + 'id' => $this->hook->id, + ); + } - // /** - // * Update hook - // * - // * @param int $id Id of hook to update - // * @param array $request_data Datas - // * @return int - // * - // * @url PUT /hooks/{id} - // */ - /*public function put($id, $request_data = null) + // /** + // * Update hook + // * + // * @param int $id Id of hook to update + // * @param array $request_data Datas + // * @return int + // * + // * @url PUT /hooks/{id} + // */ + /*public function put($id, $request_data = null) { if (! DolibarrApiAccess::$user->rights->zapier->write) { throw new RestException(401); @@ -297,80 +297,80 @@ class ZapierApi extends DolibarrApi } }*/ - /** - * Delete hook - * - * @param int $id Hook ID - * @return array - * - * @url DELETE /hook/{id} - */ - public function delete($id) - { - if (!DolibarrApiAccess::$user->rights->zapier->delete) { - throw new RestException(401); - } - $result = $this->hook->fetch($id); - if (!$result) { - throw new RestException(404, 'Hook not found'); - } + /** + * Delete hook + * + * @param int $id Hook ID + * @return array + * + * @url DELETE /hook/{id} + */ + public function delete($id) + { + if (!DolibarrApiAccess::$user->rights->zapier->delete) { + throw new RestException(401); + } + $result = $this->hook->fetch($id); + if (!$result) { + throw new RestException(404, 'Hook not found'); + } - if (!DolibarrApi::_checkAccessToResource('hook', $this->hook->id)) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); - } + if (!DolibarrApi::_checkAccessToResource('hook', $this->hook->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } - if (!$this->hook->delete(DolibarrApiAccess::$user)) { - throw new RestException(500, 'Error when deleting Hook : '.$this->hook->error); - } + if (!$this->hook->delete(DolibarrApiAccess::$user)) { + throw new RestException(500, 'Error when deleting Hook : '.$this->hook->error); + } - return array( - 'success' => array( - 'code' => 200, - 'message' => 'Hook deleted' - ) - ); - } + return array( + 'success' => array( + 'code' => 200, + 'message' => 'Hook deleted' + ) + ); + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore - /** - * Clean sensible object datas - * - * @param object $object Object to clean - * @return array Array of cleaned object properties - */ - public function _cleanObjectDatas($object) - { - // phpcs:disable - $object = parent::_cleanObjectDatas($object); + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore + /** + * Clean sensible object datas + * + * @param object $object Object to clean + * @return array Array of cleaned object properties + */ + public function _cleanObjectDatas($object) + { + // phpcs:disable + $object = parent::_cleanObjectDatas($object); - /*unset($object->note); + /*unset($object->note); unset($object->address); unset($object->barcode_type); unset($object->barcode_type_code); unset($object->barcode_type_label); unset($object->barcode_type_coder);*/ - return $object; - } + return $object; + } - /** - * Validate fields before create or update object - * - * @param array $data Array of data to validate - * @param array $fields Array of fields needed - * @return array - * - * @throws RestException - */ - private function validate($data, $fields) - { - $hook = array(); - foreach ($fields as $field) { - if (!isset($data[$field])) { - throw new RestException(400, $field." field missing"); - } - $hook[$field] = $data[$field]; - } - return $hook; - } + /** + * Validate fields before create or update object + * + * @param array $data Array of data to validate + * @param array $fields Array of fields needed + * @return array + * + * @throws RestException + */ + private function validate($data, $fields) + { + $hook = array(); + foreach ($fields as $field) { + if (!isset($data[$field])) { + throw new RestException(400, $field." field missing"); + } + $hook[$field] = $data[$field]; + } + return $hook; + } } diff --git a/htdocs/zapier/hook_agenda.php b/htdocs/zapier/hook_agenda.php index 87382c82aa9..e70adb3e1a3 100644 --- a/htdocs/zapier/hook_agenda.php +++ b/htdocs/zapier/hook_agenda.php @@ -181,7 +181,7 @@ if ($object->id > 0) { print '
    '; - dol_fiche_end(); + print dol_get_fiche_end(); diff --git a/htdocs/zapier/hook_card.php b/htdocs/zapier/hook_card.php index e7c1cc087e6..ab081f1cf58 100644 --- a/htdocs/zapier/hook_card.php +++ b/htdocs/zapier/hook_card.php @@ -160,7 +160,7 @@ if ($action == 'create') { print ''."\n"; - dol_fiche_end(); + print dol_get_fiche_end(); print '
    '; print ''; @@ -193,7 +193,7 @@ if (($id || $ref) && $action == 'edit') { print ''; - dol_fiche_end(); + print dol_get_fiche_end(); print '
    '; print '   '; @@ -315,7 +315,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print '

    '; - dol_fiche_end(); + print dol_get_fiche_end(); // Buttons for actions diff --git a/htdocs/zapier/hook_document.php b/htdocs/zapier/hook_document.php index 5bfb18491ca..e3b421ea1e2 100644 --- a/htdocs/zapier/hook_document.php +++ b/htdocs/zapier/hook_document.php @@ -129,7 +129,7 @@ if ($object->id) { print '
    '; - dol_fiche_end(); + print dol_get_fiche_end(); } else { accessforbidden('', 0, 0); } diff --git a/htdocs/zapier/hook_list.php b/htdocs/zapier/hook_list.php index 9e987d88322..8450ec3e0d8 100644 --- a/htdocs/zapier/hook_list.php +++ b/htdocs/zapier/hook_list.php @@ -53,8 +53,8 @@ $sortfield = GETPOST('sortfield', 'aZ09comma'); $sortorder = GETPOST('sortorder', 'aZ09comma'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : (int) GETPOST("page", 'int'); if (empty($page) || $page == -1 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha') || (empty($toselect) && $massaction === '0')) { - // If $page is not defined, or '' or -1 or if we click on clear filters or if we select empty mass action - $page = 0; + // If $page is not defined, or '' or -1 or if we click on clear filters or if we select empty mass action + $page = 0; } $offset = $limit * $page; $pageprev = $page - 1; @@ -76,19 +76,19 @@ $search_array_options = $extrafields->getOptionalsFromPost($object->table_elemen // Default sort order (if not yet defined by previous GETPOST) if (!$sortfield) { - // Set here default search field. By default 1st field in definition. - $sortfield = "t.".key($object->fields); + // Set here default search field. By default 1st field in definition. + $sortfield = "t.".key($object->fields); } if (!$sortorder) { - $sortorder = "ASC"; + $sortorder = "ASC"; } // Security check $socid = 0; if ($user->socid > 0) { - // Protection if external user - //$socid = $user->socid; - accessforbidden(); + // Protection if external user + //$socid = $user->socid; + accessforbidden(); } //$result = restrictedArea($user, 'zapier', $id, ''); @@ -96,27 +96,27 @@ if ($user->socid > 0) { $search_all = GETPOST("search_all", 'alpha'); $search = array(); foreach ($object->fields as $key => $val) { - if (GETPOST('search_'.$key, 'alpha')) $search[$key] = GETPOST('search_'.$key, 'alpha'); + if (GETPOST('search_'.$key, 'alpha')) $search[$key] = GETPOST('search_'.$key, 'alpha'); } // List of fields to search into when doing a "search in all" $fieldstosearchall = array(); foreach ($object->fields as $key => $val) { - if ($val['searchall']) $fieldstosearchall['t.'.$key] = $val['label']; + if ($val['searchall']) $fieldstosearchall['t.'.$key] = $val['label']; } // Definition of fields for list $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'], 'position'=>$val['position']); + // 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'], 'position'=>$val['position']); } // Extra fields if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label']) > 0) { - foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) { - if (!empty($extrafields->attributes[$object->table_element]['list'][$key])) - $arrayfields["ef.".$key] = array('label'=>$extrafields->attributes[$object->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key] < 0) ? 0 : 1), 'position'=>$extrafields->attributes[$object->table_element]['pos'][$key], 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key]) != 3 && $extrafields->attributes[$object->table_element]['perms'][$key])); - } + foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) { + if (!empty($extrafields->attributes[$object->table_element]['list'][$key])) + $arrayfields["ef.".$key] = array('label'=>$extrafields->attributes[$object->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key] < 0) ? 0 : 1), 'position'=>$extrafields->attributes[$object->table_element]['pos'][$key], 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key]) != 3 && $extrafields->attributes[$object->table_element]['perms'][$key])); + } } $object->fields = dol_sort_array($object->fields, 'position'); $arrayfields = dol_sort_array($arrayfields, 'position'); @@ -128,11 +128,11 @@ $arrayfields = dol_sort_array($arrayfields, 'position'); */ if (GETPOST('cancel', 'alpha')) { - $action = 'list'; - $massaction = ''; + $action = 'list'; + $massaction = ''; } if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { - $massaction = ''; + $massaction = ''; } $parameters = array(); @@ -140,30 +140,30 @@ $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); if (empty($reshook)) { - // Selection of new fields - include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; + // Selection of new fields + include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; - // Purge search criteria - if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { - // All tests are required to be compatible with all browsers - foreach ($object->fields as $key => $val) { - $search[$key] = ''; - } - $toselect = ''; - $search_array_options = array(); - } - if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha') - || GETPOST('button_search_x', 'alpha') || GETPOST('button_search.x', 'alpha') || GETPOST('button_search', 'alpha')) { - $massaction = ''; // Protection to avoid mass action if we force a new search during a mass action confirmation - } + // Purge search criteria + if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { + // All tests are required to be compatible with all browsers + foreach ($object->fields as $key => $val) { + $search[$key] = ''; + } + $toselect = ''; + $search_array_options = array(); + } + if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha') + || GETPOST('button_search_x', 'alpha') || GETPOST('button_search.x', 'alpha') || GETPOST('button_search', 'alpha')) { + $massaction = ''; // Protection to avoid mass action if we force a new search during a mass action confirmation + } - // Mass actions - $objectclass = 'Hook'; - $objectlabel = 'Hook'; - $permissiontoread = $user->rights->zapier->read; - $permissiontodelete = $user->rights->zapier->delete; - $uploaddir = $conf->zapier->dir_output; - include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; + // Mass actions + $objectclass = 'Hook'; + $objectlabel = 'Hook'; + $permissiontoread = $user->rights->zapier->read; + $permissiontodelete = $user->rights->zapier->delete; + $uploaddir = $conf->zapier->dir_output; + include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; } @@ -185,13 +185,13 @@ $title = $langs->trans('ListOf', $langs->transnoentitiesnoconv("Hooks")); // -------------------------------------------------------------------- $sql = 'SELECT '; foreach ($object->fields as $key => $val) { - $sql .= 't.'.$key.', '; + $sql .= 't.'.$key.', '; } // Add fields from extrafields if (!empty($extrafields->attributes[$object->table_element]['label'])) { - foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) { - $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? "ef.".$key.' as options_'.$key.', ' : ''); - } + foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) { + $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? "ef.".$key.' as options_'.$key.', ' : ''); + } } // Add fields from hooks $parameters = array(); @@ -201,21 +201,21 @@ $sql = preg_replace('/, $/', '', $sql); $sql .= " FROM ".MAIN_DB_PREFIX.$object->table_element." as t"; if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (t.rowid = ef.fk_object)"; if ($object->ismultientitymanaged == 1) { - $sql .= " WHERE t.entity IN (".getEntity($object->element).")"; + $sql .= " WHERE t.entity IN (".getEntity($object->element).")"; } else { - $sql .= " WHERE 1 = 1"; + $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)); - } + 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)); + } } if ($search_all) { - $sql .= natural_search(array_keys($fieldstosearchall), $search_all); + $sql .= natural_search(array_keys($fieldstosearchall), $search_all); } // Add where from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php'; @@ -245,35 +245,35 @@ $sql .= $db->order($sortfield, $sortorder); // Count total nb of records $nbtotalofrecords = ''; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { - $resql = $db->query($sql); - $nbtotalofrecords = $db->num_rows($resql); - if (($page * $limit) > $nbtotalofrecords) { - // if total of record found is smaller than page * limit, goto and load page 0 - $page = 0; - $offset = 0; - } + $resql = $db->query($sql); + $nbtotalofrecords = $db->num_rows($resql); + if (($page * $limit) > $nbtotalofrecords) { + // if total of record found is smaller than page * limit, goto and load page 0 + $page = 0; + $offset = 0; + } } // if total of record found is smaller than limit, no need to do paging and to restart another select with limits set. if (is_numeric($nbtotalofrecords) && $limit > $nbtotalofrecords) { - $num = $nbtotalofrecords; + $num = $nbtotalofrecords; } else { - $sql .= $db->plimit($limit + 1, $offset); + $sql .= $db->plimit($limit + 1, $offset); - $resql = $db->query($sql); - if (!$resql) { - dol_print_error($db); - exit; - } + $resql = $db->query($sql); + if (!$resql) { + dol_print_error($db); + exit; + } - $num = $db->num_rows($resql); + $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) { - $obj = $db->fetch_object($resql); - $id = $obj->rowid; - header("Location: ".dol_buildpath('/zapierfordolibarr/hook_card.php', 1).'?id='.$id); - exit; + $obj = $db->fetch_object($resql); + $id = $obj->rowid; + header("Location: ".dol_buildpath('/zapierfordolibarr/hook_card.php', 1).'?id='.$id); + exit; } @@ -303,13 +303,13 @@ $param = ''; if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage); if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit); foreach ($search as $key => $val) { - if (is_array($search[$key]) && count($search[$key])) { - foreach ($search[$key] as $skey) { - $param .= '&search_'.$key.'[]='.urlencode($skey); - } - } else { - $param .= '&search_'.$key.'='.urlencode($search[$key]); - } + if (is_array($search[$key]) && count($search[$key])) { + foreach ($search[$key] as $skey) { + $param .= '&search_'.$key.'[]='.urlencode($skey); + } + } else { + $param .= '&search_'.$key.'='.urlencode($search[$key]); + } } if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss); // Add $param from extra fields @@ -317,8 +317,8 @@ 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->zapier->delete) $arrayofmassactions['predelete'] = ''.$langs->trans("Delete"); if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete'))) $arrayofmassactions = array(); @@ -337,9 +337,9 @@ print ''; $newcardbutton = ''; //if ($user->rights->zapier->creer) //{ - $newcardbutton = '
    '.$langs->trans('New').''; - $newcardbutton .= ''; - $newcardbutton .= ''; + $newcardbutton = ''.$langs->trans('New').''; + $newcardbutton .= ''; + $newcardbutton .= ''; //} //else //{ @@ -358,8 +358,8 @@ $trackid = 'xxxx'.$object->id; include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php'; if ($sall) { - foreach ($fieldstosearchall as $key => $val) $fieldstosearchall[$key] = $langs->trans($val); - print '
    '.$langs->trans("FilterOnInto", $sall).join(', ', $fieldstosearchall).'
    '; + foreach ($fieldstosearchall as $key => $val) $fieldstosearchall[$key] = $langs->trans($val); + print '
    '.$langs->trans("FilterOnInto", $sall).join(', ', $fieldstosearchall).'
    '; } $moreforfilter = ''; @@ -373,9 +373,9 @@ if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint; else $moreforfilter = $hookmanager->resPrint; if (!empty($moreforfilter)) { - print '
    '; - print $moreforfilter; - print '
    '; + print '
    '; + print $moreforfilter; + print '
    '; } $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; @@ -390,22 +390,22 @@ print ''; foreach ($object->fields as $key => $val) { - $cssforfield = ''; - if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) { - $cssforfield .= ($cssforfield ? ' ' : '').'center'; - } - if (in_array($val['type'], array('timestamp'))) { - $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; - } - if (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real'))) { - $cssforfield .= ($cssforfield ? ' ' : '').'right'; - } - if ($key == 'status') { - $cssforfield .= ($cssforfield ? ' ' : '').'center'; - } - if (!empty($arrayfields['t.'.$key]['checked'])) { - print ''; - } + $cssforfield = ''; + if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) { + $cssforfield .= ($cssforfield ? ' ' : '').'center'; + } + if (in_array($val['type'], array('timestamp'))) { + $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; + } + if (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real'))) { + $cssforfield .= ($cssforfield ? ' ' : '').'right'; + } + if ($key == 'status') { + $cssforfield .= ($cssforfield ? ' ' : '').'center'; + } + if (!empty($arrayfields['t.'.$key]['checked'])) { + print ''; + } } // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php'; @@ -426,25 +426,25 @@ print ''."\n"; // -------------------------------------------------------------------- print ''; foreach ($object->fields as $key => $val) { - $cssforfield = ''; - if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'center'; - if (in_array($val['type'], array('timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; - if (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real'))) $cssforfield .= ($cssforfield ? ' ' : '').'right'; - if ($key == 'status') { - $cssforfield .= ($cssforfield ? ' ' : '').'center'; - } - if (!empty($arrayfields['t.'.$key]['checked'])) { - print getTitleFieldOfList($arrayfields['t.'.$key]['label'], 0, $_SERVER['PHP_SELF'], 't.'.$key, '', $param, ($cssforfield ? 'class="'.$cssforfield.'"' : ''), $sortfield, $sortorder, ($cssforfield ? $cssforfield.' ' : ''))."\n"; - } + $cssforfield = ''; + if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'center'; + if (in_array($val['type'], array('timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; + if (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real'))) $cssforfield .= ($cssforfield ? ' ' : '').'right'; + if ($key == 'status') { + $cssforfield .= ($cssforfield ? ' ' : '').'center'; + } + if (!empty($arrayfields['t.'.$key]['checked'])) { + print getTitleFieldOfList($arrayfields['t.'.$key]['label'], 0, $_SERVER['PHP_SELF'], 't.'.$key, '', $param, ($cssforfield ? 'class="'.$cssforfield.'"' : ''), $sortfield, $sortorder, ($cssforfield ? $cssforfield.' ' : ''))."\n"; + } } // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; // Hook fields $parameters = array( - 'arrayfields' => $arrayfields, - 'param' => $param, - 'sortfield' => $sortfield, - 'sortorder' => $sortorder, + '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; @@ -456,12 +456,12 @@ print ''."\n"; // Detect if we need a fetch on each output line $needToFetchEachLine = 0; if (is_array($extrafields->attributes[$object->table_element]['computed']) && count($extrafields->attributes[$object->table_element]['computed']) > 0) { - foreach ($extrafields->attributes[$object->table_element]['computed'] as $key => $val) { - if (preg_match('/\$object/', $val)) { - // There is at least one compute field that use $object - $needToFetchEachLine++; - } - } + foreach ($extrafields->attributes[$object->table_element]['computed'] as $key => $val) { + if (preg_match('/\$object/', $val)) { + // There is at least one compute field that use $object + $needToFetchEachLine++; + } + } } @@ -470,71 +470,71 @@ if (is_array($extrafields->attributes[$object->table_element]['computed']) && co $i = 0; $totalarray = array(); while ($i < min($num, $limit)) { - $obj = $db->fetch_object($resql); - if (empty($obj)) { - break; // Should not happen - } + $obj = $db->fetch_object($resql); + if (empty($obj)) { + break; // Should not happen + } - // Store properties in $object - $object->id = $obj->rowid; - foreach ($object->fields as $key => $val) { - if (isset($obj->$key)) $object->$key = $obj->$key; - } + // Store properties in $object + $object->id = $obj->rowid; + foreach ($object->fields as $key => $val) { + if (isset($obj->$key)) $object->$key = $obj->$key; + } - // Show here line of result - print ''; - foreach ($object->fields as $key => $val) { - $cssforfield = ''; - if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) { - $cssforfield .= ($cssforfield ? ' ' : '').'center'; - } elseif ($key == 'status') { - $cssforfield .= ($cssforfield ? ' ' : '').'center'; - } + // Show here line of result + print ''; + foreach ($object->fields as $key => $val) { + $cssforfield = ''; + if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) { + $cssforfield .= ($cssforfield ? ' ' : '').'center'; + } elseif ($key == 'status') { + $cssforfield .= ($cssforfield ? ' ' : '').'center'; + } - if (in_array($val['type'], array('timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; - elseif ($key == 'ref') $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; + if (in_array($val['type'], array('timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; + elseif ($key == 'ref') $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; - if (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real'))) $cssforfield .= ($cssforfield ? ' ' : '').'right'; + if (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real'))) $cssforfield .= ($cssforfield ? ' ' : '').'right'; - if (!empty($arrayfields['t.'.$key]['checked'])) { - print ''; - if ($key == 'status') print $object->getLibStatut(5); - elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) print $object->showOutputField($val, $key, $db->jdate($obj->$key), ''); - else print $object->showOutputField($val, $key, $obj->$key, ''); - print ''; - if (!$i) $totalarray['nbfield']++; - if (!empty($val['isameasure'])) { - if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 't.'.$key; - $totalarray['val']['t.'.$key] += $obj->$key; - } - } - } - // Extra fields - include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; - // Fields from hook - $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray); - $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object); // Note that $action and $object may have been modified by hook - print $hookmanager->resPrint; - // Action column - print ''; - if (!$i) $totalarray['nbfield']++; + if (!empty($arrayfields['t.'.$key]['checked'])) { + print ''; + if ($key == 'status') print $object->getLibStatut(5); + elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) print $object->showOutputField($val, $key, $db->jdate($obj->$key), ''); + else print $object->showOutputField($val, $key, $obj->$key, ''); + print ''; + if (!$i) $totalarray['nbfield']++; + if (!empty($val['isameasure'])) { + if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 't.'.$key; + $totalarray['val']['t.'.$key] += $obj->$key; + } + } + } + // Extra fields + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; + // Fields from hook + $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray); + $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; + // Action column + print ''; + if (!$i) $totalarray['nbfield']++; - print ''; + print ''; - $i++; + $i++; } // Show total line @@ -543,21 +543,21 @@ include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php'; // If no record found if ($num == 0) { - $colspan = 1; - foreach ($arrayfields as $key => $val) { - if (!empty($val['checked'])) { - $colspan++; - } - } - print ''; + $colspan = 1; + foreach ($arrayfields as $key => $val) { + if (!empty($val['checked'])) { + $colspan++; + } + } + print ''; } $db->free($resql); $parameters = array( - 'arrayfields' => $arrayfields, - 'sql' => $sql, + 'arrayfields' => $arrayfields, + 'sql' => $sql, ); $reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; @@ -568,23 +568,23 @@ print ''."\n"; print ''."\n"; if (in_array('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords)) { - $hidegeneratedfilelistifempty = 1; - if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) { - $hidegeneratedfilelistifempty = 0; - } + $hidegeneratedfilelistifempty = 1; + if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) { + $hidegeneratedfilelistifempty = 0; + } - require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; - $formfile = new FormFile($db); + require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; + $formfile = new FormFile($db); - // Show list of available documents - $urlsource = $_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder; - $urlsource .= str_replace('&', '&', $param); + // Show list of available documents + $urlsource = $_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder; + $urlsource .= str_replace('&', '&', $param); - $filedir = $diroutputmassaction; - $genallowed = $user->rights->zapier->read; - $delallowed = $user->rights->zapier->create; + $filedir = $diroutputmassaction; + $genallowed = $user->rights->zapier->read; + $delallowed = $user->rights->zapier->create; - print $formfile->showdocuments('massfilesarea_zapier', '', $filedir, $urlsource, 0, $delallowed, '', 1, 1, 0, 48, 1, $param, $title, '', '', '', null, $hidegeneratedfilelistifempty); + print $formfile->showdocuments('massfilesarea_zapier', '', $filedir, $urlsource, 0, $delallowed, '', 1, 1, 0, 48, 1, $param, $title, '', '', '', null, $hidegeneratedfilelistifempty); } // End of page diff --git a/htdocs/zapier/hook_note.php b/htdocs/zapier/hook_note.php index 273b609741e..da0484160a3 100644 --- a/htdocs/zapier/hook_note.php +++ b/htdocs/zapier/hook_note.php @@ -143,7 +143,7 @@ if ($id > 0 || !empty($ref)) { print ''; - dol_fiche_end(); + print dol_get_fiche_end(); } // End of page diff --git a/scripts/accountancy/export-thirdpartyaccount.php b/scripts/accountancy/export-thirdpartyaccount.php index ba4fe922ab9..4dc22193262 100755 --- a/scripts/accountancy/export-thirdpartyaccount.php +++ b/scripts/accountancy/export-thirdpartyaccount.php @@ -25,6 +25,10 @@ * \brief Page to detect empty accounting account */ +if (!defined('NOSESSION')) define('NOSESSION', '1'); + +$path = __DIR__.'/'; + require_once $path."../../htdocs/master.inc.php"; require_once DOL_DOCUMENT_ROOT.'/core/lib/report.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; diff --git a/scripts/bank/export-bank-receipts.php b/scripts/bank/export-bank-receipts.php index 4f2a256275a..609791232ad 100755 --- a/scripts/bank/export-bank-receipts.php +++ b/scripts/bank/export-bank-receipts.php @@ -22,6 +22,9 @@ * \ingroup bank * \brief Script file to export bank receipts into Excel files */ + +if (!defined('NOSESSION')) define('NOSESSION', '1'); + $sapi_type = php_sapi_name(); $script_file = basename(__FILE__); $path = __DIR__.'/'; diff --git a/scripts/company/export-contacts-xls-example.php b/scripts/company/export-contacts-xls-example.php index 07262b83c0e..445a17a7d30 100755 --- a/scripts/company/export-contacts-xls-example.php +++ b/scripts/company/export-contacts-xls-example.php @@ -23,6 +23,9 @@ * \ingroup company * \brief Script file to export contacts into an Excel file */ + +if (!defined('NOSESSION')) define('NOSESSION', '1'); + $sapi_type = php_sapi_name(); $script_file = basename(__FILE__); $path = __DIR__.'/'; diff --git a/scripts/company/sync_contacts_dolibarr2ldap.php b/scripts/company/sync_contacts_dolibarr2ldap.php index caaa762dea5..8e5274fb69a 100755 --- a/scripts/company/sync_contacts_dolibarr2ldap.php +++ b/scripts/company/sync_contacts_dolibarr2ldap.php @@ -23,6 +23,9 @@ * \ingroup ldap company * \brief Script to update all contacts from Dolibarr into a LDAP database */ + +if (!defined('NOSESSION')) define('NOSESSION', '1'); + $sapi_type = php_sapi_name(); $script_file = basename(__FILE__); $path = __DIR__.'/'; diff --git a/scripts/contracts/email_expire_services_to_customers.php b/scripts/contracts/email_expire_services_to_customers.php index ae449484e7b..5c98dc2913b 100755 --- a/scripts/contracts/email_expire_services_to_customers.php +++ b/scripts/contracts/email_expire_services_to_customers.php @@ -24,6 +24,9 @@ * \ingroup facture * \brief Script to send a mail to customers with services to expire */ + +if (!defined('NOSESSION')) define('NOSESSION', '1'); + $sapi_type = php_sapi_name(); $script_file = basename(__FILE__); $path = __DIR__.'/'; diff --git a/scripts/contracts/email_expire_services_to_representatives.php b/scripts/contracts/email_expire_services_to_representatives.php index 06cb67c99e9..eec151376ee 100755 --- a/scripts/contracts/email_expire_services_to_representatives.php +++ b/scripts/contracts/email_expire_services_to_representatives.php @@ -24,6 +24,9 @@ * \ingroup contracts * \brief Script to send a mail to dolibarr users linked to companies with services to expire */ + +if (!defined('NOSESSION')) define('NOSESSION', '1'); + $sapi_type = php_sapi_name(); $script_file = basename(__FILE__); $path = __DIR__.'/'; diff --git a/scripts/cron/cron_run_jobs.php b/scripts/cron/cron_run_jobs.php index 9058577aa21..e7b830c5ae6 100755 --- a/scripts/cron/cron_run_jobs.php +++ b/scripts/cron/cron_run_jobs.php @@ -30,7 +30,7 @@ if (!defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); if (!defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1'); if (!defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); if (!defined('NOLOGIN')) define('NOLOGIN', '1'); - +if (!defined('NOSESSION')) define('NOSESSION', '1'); $sapi_type = php_sapi_name(); $script_file = basename(__FILE__); diff --git a/scripts/emailings/mailing-send.php b/scripts/emailings/mailing-send.php index 7cde66db687..6719fb2164f 100755 --- a/scripts/emailings/mailing-send.php +++ b/scripts/emailings/mailing-send.php @@ -25,6 +25,9 @@ * \ingroup mailing * \brief Script d'envoi d'un mailing prepare et valide */ + +if (!defined('NOSESSION')) define('NOSESSION', '1'); + $sapi_type = php_sapi_name(); $script_file = basename(__FILE__); $path = __DIR__.'/'; diff --git a/scripts/invoices/email_unpaid_invoices_to_customers.php b/scripts/invoices/email_unpaid_invoices_to_customers.php index 5617751b58b..9b59fcab6f7 100755 --- a/scripts/invoices/email_unpaid_invoices_to_customers.php +++ b/scripts/invoices/email_unpaid_invoices_to_customers.php @@ -24,6 +24,9 @@ * \ingroup facture * \brief Script to send a mail to customers with unpaid invoices */ + +if (!defined('NOSESSION')) define('NOSESSION', '1'); + $sapi_type = php_sapi_name(); $script_file = basename(__FILE__); $path = __DIR__.'/'; diff --git a/scripts/invoices/email_unpaid_invoices_to_representatives.php b/scripts/invoices/email_unpaid_invoices_to_representatives.php index 9bdd37ca599..d401894363d 100755 --- a/scripts/invoices/email_unpaid_invoices_to_representatives.php +++ b/scripts/invoices/email_unpaid_invoices_to_representatives.php @@ -24,6 +24,9 @@ * \ingroup facture * \brief Script to send a mail to dolibarr users linked to companies with unpaid invoices */ + +if (!defined('NOSESSION')) define('NOSESSION', '1'); + $sapi_type = php_sapi_name(); $script_file = basename(__FILE__); $path = __DIR__.'/'; diff --git a/scripts/invoices/rebuild_merge_pdf.php b/scripts/invoices/rebuild_merge_pdf.php index fa54bac9da8..22c55eeeb99 100755 --- a/scripts/invoices/rebuild_merge_pdf.php +++ b/scripts/invoices/rebuild_merge_pdf.php @@ -22,6 +22,9 @@ * \ingroup facture * \brief Script to rebuild PDF and merge PDF files into one */ + +if (!defined('NOSESSION')) define('NOSESSION', '1'); + $sapi_type = php_sapi_name(); $script_file = basename(__FILE__); $path = __DIR__.'/'; diff --git a/scripts/members/sync_members_dolibarr2ldap.php b/scripts/members/sync_members_dolibarr2ldap.php index 7b91a651b34..f0edb2fb8f3 100755 --- a/scripts/members/sync_members_dolibarr2ldap.php +++ b/scripts/members/sync_members_dolibarr2ldap.php @@ -23,6 +23,9 @@ * \ingroup ldap member * \brief Script de mise a jour des adherents dans LDAP depuis base Dolibarr */ + +if (!defined('NOSESSION')) define('NOSESSION', '1'); + $sapi_type = php_sapi_name(); $script_file = basename(__FILE__); $path = __DIR__.'/'; @@ -40,7 +43,7 @@ require_once DOL_DOCUMENT_ROOT."/adherents/class/adherent.class.php"; $langs->load("main"); // Global variables -$version = DOL_VERSION; +$version = constant('DOL_VERSION'); $error = 0; $confirmed = 0; diff --git a/scripts/members/sync_members_ldap2dolibarr.php b/scripts/members/sync_members_ldap2dolibarr.php index 4166772cb10..21a5075326c 100755 --- a/scripts/members/sync_members_ldap2dolibarr.php +++ b/scripts/members/sync_members_ldap2dolibarr.php @@ -23,6 +23,9 @@ * \ingroup ldap member * \brief Script de mise a jour des adherents dans Dolibarr depuis LDAP */ + +if (!defined('NOSESSION')) define('NOSESSION', '1'); + $sapi_type = php_sapi_name(); $script_file = basename(__FILE__); $path = __DIR__.'/'; @@ -42,7 +45,7 @@ require_once DOL_DOCUMENT_ROOT."/adherents/class/subscription.class.php"; $langs->loadLangs(array("main", "errors")); // Global variables -$version = DOL_VERSION; +$version = constant('DOL_VERSION'); $error = 0; $forcecommit = 0; $confirmed = 0; diff --git a/scripts/members/sync_members_types_dolibarr2ldap.php b/scripts/members/sync_members_types_dolibarr2ldap.php index a07ec0a1ff3..0a22469ec80 100755 --- a/scripts/members/sync_members_types_dolibarr2ldap.php +++ b/scripts/members/sync_members_types_dolibarr2ldap.php @@ -24,6 +24,9 @@ * \ingroup ldap core * \brief Script de mise a jour des types de membres dans LDAP depuis base Dolibarr */ + +if (!defined('NOSESSION')) define('NOSESSION', '1'); + $sapi_type = php_sapi_name(); $script_file = basename(__FILE__); $path = __DIR__.'/'; @@ -38,6 +41,7 @@ if (!isset($argv[1]) || !$argv[1]) { print "Usage: ".$script_file." now\n"; exit(-1); } + $now = $argv[1]; require_once $path."../../htdocs/master.inc.php"; @@ -45,7 +49,7 @@ require_once DOL_DOCUMENT_ROOT."/core/class/ldap.class.php"; require_once DOL_DOCUMENT_ROOT."/adherents/class/adherent_type.class.php"; // Global variables -$version = DOL_VERSION; +$version = constant('DOL_VERSION'); $error = 0; /* diff --git a/scripts/members/sync_members_types_ldap2dolibarr.php b/scripts/members/sync_members_types_ldap2dolibarr.php index 547b2664070..f24faf9b76a 100755 --- a/scripts/members/sync_members_types_ldap2dolibarr.php +++ b/scripts/members/sync_members_types_ldap2dolibarr.php @@ -25,6 +25,9 @@ * \ingroup ldap member * \brief Script to update members types into Dolibarr from LDAP */ + +if (!defined('NOSESSION')) define('NOSESSION', '1'); + $sapi_type = php_sapi_name(); $script_file = basename(__FILE__); $path = __DIR__.'/'; @@ -43,7 +46,7 @@ require_once DOL_DOCUMENT_ROOT."/adherents/class/adherent_type.class.php"; $langs->loadLangs(array("main", "errors")); // Global variables -$version = DOL_VERSION; +$version = constant('DOL_VERSION'); $error = 0; $forcecommit = 0; $confirmed = 0; diff --git a/scripts/product/migrate_picture_path.php b/scripts/product/migrate_picture_path.php index 8e452ba13b2..849eca44514 100755 --- a/scripts/product/migrate_picture_path.php +++ b/scripts/product/migrate_picture_path.php @@ -23,6 +23,9 @@ * \ingroup scripts * \brief Migrate pictures from old system prior to 3.7 to new path for 3.7+ */ + +if (!defined('NOSESSION')) define('NOSESSION', '1'); + $sapi_type = php_sapi_name(); $script_file = basename(__FILE__); $path = __DIR__.'/'; diff --git a/scripts/product/regenerate_thumbs.php b/scripts/product/regenerate_thumbs.php index 8434bdd9097..0d8c6380eb3 100755 --- a/scripts/product/regenerate_thumbs.php +++ b/scripts/product/regenerate_thumbs.php @@ -23,6 +23,9 @@ * \ingroup scripts * \brief Migrate pictures from old system prior to 3.7 to new path for 3.7+ */ + +if (!defined('NOSESSION')) define('NOSESSION', '1'); + $sapi_type = php_sapi_name(); $script_file = basename(__FILE__); $path = __DIR__.'/'; diff --git a/scripts/user/migrate_picture_path.php b/scripts/user/migrate_picture_path.php index c80097bb36b..795d03b710d 100755 --- a/scripts/user/migrate_picture_path.php +++ b/scripts/user/migrate_picture_path.php @@ -23,6 +23,9 @@ * \ingroup scripts * \brief Migrate pictures from old system prior to 3.7 to new path for 3.7+ */ + +if (!defined('NOSESSION')) define('NOSESSION', '1'); + $sapi_type = php_sapi_name(); $script_file = basename(__FILE__); $path = __DIR__.'/'; diff --git a/scripts/user/sync_groups_dolibarr2ldap.php b/scripts/user/sync_groups_dolibarr2ldap.php index c52a0151887..eb229c3d4ed 100755 --- a/scripts/user/sync_groups_dolibarr2ldap.php +++ b/scripts/user/sync_groups_dolibarr2ldap.php @@ -23,6 +23,9 @@ * \ingroup ldap core * \brief Script de mise a jour des groupes dans LDAP depuis base Dolibarr */ + +if (!defined('NOSESSION')) define('NOSESSION', '1'); + $sapi_type = php_sapi_name(); $script_file = basename(__FILE__); $path = __DIR__.'/'; diff --git a/scripts/user/sync_groups_ldap2dolibarr.php b/scripts/user/sync_groups_ldap2dolibarr.php index 28c580dce63..5432ded78ee 100755 --- a/scripts/user/sync_groups_ldap2dolibarr.php +++ b/scripts/user/sync_groups_ldap2dolibarr.php @@ -24,6 +24,9 @@ * \ingroup ldap member * \brief Script to update groups into Dolibarr from LDAP */ + +if (!defined('NOSESSION')) define('NOSESSION', '1'); + $sapi_type = php_sapi_name(); $script_file = basename(__FILE__); $path = __DIR__.'/'; diff --git a/scripts/user/sync_users_dolibarr2ldap.php b/scripts/user/sync_users_dolibarr2ldap.php index 5d36bcf44be..4f6fd00d1c7 100755 --- a/scripts/user/sync_users_dolibarr2ldap.php +++ b/scripts/user/sync_users_dolibarr2ldap.php @@ -23,6 +23,9 @@ * \ingroup ldap core * \brief Script de mise a jour des users dans LDAP depuis base Dolibarr */ + +if (!defined('NOSESSION')) define('NOSESSION', '1'); + $sapi_type = php_sapi_name(); $script_file = basename(__FILE__); $path = __DIR__.'/'; diff --git a/scripts/user/sync_users_ldap2dolibarr.php b/scripts/user/sync_users_ldap2dolibarr.php index c8502cd1f14..375cb2f43ba 100755 --- a/scripts/user/sync_users_ldap2dolibarr.php +++ b/scripts/user/sync_users_ldap2dolibarr.php @@ -23,6 +23,9 @@ * \ingroup ldap member * \brief Script to update users into Dolibarr from LDAP */ + +if (!defined('NOSESSION')) define('NOSESSION', '1'); + $sapi_type = php_sapi_name(); $script_file = basename(__FILE__); $path = __DIR__.'/'; diff --git a/scripts/website/migrate-news-joomla2dolibarr.php b/scripts/website/migrate-news-joomla2dolibarr.php index b4399ba0885..dfd92a19acf 100755 --- a/scripts/website/migrate-news-joomla2dolibarr.php +++ b/scripts/website/migrate-news-joomla2dolibarr.php @@ -22,6 +22,8 @@ * \brief Migrate news from a Joomla databse into a Dolibarr website */ +if (!defined('NOSESSION')) define('NOSESSION', '1'); + $sapi_type = php_sapi_name(); $script_file = basename(__FILE__); $path = __DIR__.'/'; diff --git a/scripts/website/regenerate-pages.php b/scripts/website/regenerate-pages.php index dfd49c1fe29..a50db09708d 100755 --- a/scripts/website/regenerate-pages.php +++ b/scripts/website/regenerate-pages.php @@ -22,6 +22,8 @@ * \brief Regenerate all pages of a web site */ +if (!defined('NOSESSION')) define('NOSESSION', '1'); + $sapi_type = php_sapi_name(); $script_file = basename(__FILE__); $path = __DIR__.'/'; diff --git a/scripts/withdrawals/build_withdrawal_file.php b/scripts/withdrawals/build_withdrawal_file.php index d6ffe710a90..5ae7ba70bf4 100755 --- a/scripts/withdrawals/build_withdrawal_file.php +++ b/scripts/withdrawals/build_withdrawal_file.php @@ -23,6 +23,9 @@ * \ingroup prelevement * \brief Script de prelevement */ + +if (!defined('NOSESSION')) define('NOSESSION', '1'); + $sapi_type = php_sapi_name(); $script_file = basename(__FILE__); $path = __DIR__.'/'; @@ -40,7 +43,7 @@ require_once DOL_DOCUMENT_ROOT."/societe/class/societe.class.php"; require_once DOL_DOCUMENT_ROOT."/compta/paiement/class/paiement.class.php"; // Global variables -$version = DOL_VERSION; +$version = constant('DOL_VERSION'); $error = 0; /* diff --git a/test/phpunit/PaypalTest.php b/test/phpunit/PaypalTest.php index 47d8341f501..19774a11c09 100644 --- a/test/phpunit/PaypalTest.php +++ b/test/phpunit/PaypalTest.php @@ -146,7 +146,7 @@ class PaypalTest extends PHPUnit\Framework\TestCase $urltotest=getPaypalPaymentUrl(0, 'free'); print "urltotest=".$urltotest."\n"; - $result=getURLContent($urltotest, 'GET'); + $result=getURLContent($urltotest, 'GET', '', 1, array(), array('http', 'https'), 2); print __METHOD__." result=".$result."\n"; $this->assertLessThanOrEqual($result, 0); diff --git a/test/phpunit/RestAPIDocumentTest.php b/test/phpunit/RestAPIDocumentTest.php index 65b8c206c9d..06094904bd9 100644 --- a/test/phpunit/RestAPIDocumentTest.php +++ b/test/phpunit/RestAPIDocumentTest.php @@ -120,7 +120,7 @@ class RestAPIDocumentTest extends PHPUnit\Framework\TestCase $password = 'admin'; $url = $this->api_url.'/login?login='.$login.'&password='.$password; // Call the API login method to save api_key for this test class - $result = getURLContent($url, 'GET', '', 1, array()); + $result = getURLContent($url, 'GET', '', 1, array(), array('http', 'https'), 2); echo __METHOD__.' result = '.var_export($result, true)."\n"; echo __METHOD__.' curl_error_no: '.$result['curl_error_no']."\n"; $this->assertEquals($result['curl_error_no'], ''); @@ -171,7 +171,7 @@ class RestAPIDocumentTest extends PHPUnit\Framework\TestCase 'fileencoding'=>"" ); - $result = getURLContent($url, 'POST', $data, 1); + $result = getURLContent($url, 'POST', $data, 1,array(), array('http', 'https'), 2); echo __METHOD__.' Result for sending document: '.var_export($result, true)."\n"; echo __METHOD__.' curl_error_no: '.$result['curl_error_no']."\n"; $object = json_decode($result['content'], true); @@ -192,7 +192,7 @@ class RestAPIDocumentTest extends PHPUnit\Framework\TestCase 'fileencoding'=>"" ); - $result2 = getURLContent($url, 'POST', $data, 1); + $result2 = getURLContent($url, 'POST', $data, 1, array(), array('http', 'https'), 2); echo __METHOD__.' Result for sending document: '.var_export($result2, true)."\n"; echo __METHOD__.' curl_error_no: '.$result2['curl_error_no']."\n"; $object2 = json_decode($result2['content'], true); diff --git a/test/phpunit/RestAPIUserTest.php b/test/phpunit/RestAPIUserTest.php index 9d49d10af73..a937bdbd9f8 100644 --- a/test/phpunit/RestAPIUserTest.php +++ b/test/phpunit/RestAPIUserTest.php @@ -125,7 +125,7 @@ class RestAPIUserTest extends PHPUnit\Framework\TestCase $password='admin'; $url=$this->api_url.'/login?login='.$login.'&password='.$password; // Call the API login method to save api_key for this test class - $result=getURLContent($url, 'GET', '', 1, array()); + $result=getURLContent($url, 'GET', '', 1, array(), array('http', 'https'), 2); print __METHOD__." result = ".var_export($result, true)."\n"; print __METHOD__." curl_error_no: ".$result['curl_error_no']."\n"; $this->assertEquals($result['curl_error_no'], ''); @@ -163,7 +163,7 @@ class RestAPIUserTest extends PHPUnit\Framework\TestCase //$addheaders=array('Content-Type: application/json'); print __METHOD__." Request GET url=".$url."\n"; - $result=getURLContent($url, 'GET', '', 1, array()); + $result=getURLContent($url, 'GET', '', 1, array(), array('http', 'https'), 2); //print __METHOD__." Result for unexisting user: ".var_export($result, true)."\n"; print __METHOD__." curl_error_no: ".$result['curl_error_no']."\n"; $this->assertEquals($result['curl_error_no'], ''); @@ -174,7 +174,7 @@ class RestAPIUserTest extends PHPUnit\Framework\TestCase $url = $this->api_url.'/users/1?api_key='.$this->api_key; print __METHOD__." Request GET url=".$url."\n"; - $result=getURLContent($url, 'GET', '', 1, array()); + $result=getURLContent($url, 'GET', '', 1, array(), array('http', 'https'), 2); //print __METHOD__." Result for existing user user: ".var_export($result, true)."\n"; print __METHOD__." curl_error_no: ".$result['curl_error_no']."\n"; $this->assertEquals($result['curl_error_no'], ''); @@ -203,7 +203,7 @@ class RestAPIUserTest extends PHPUnit\Framework\TestCase $body = json_encode($bodyobj); print __METHOD__." Request POST url=".$url."\n"; - $result=getURLContent($url, 'POST', $body, 1, $addheaders); + $result=getURLContent($url, 'POST', $body, 1, $addheaders, array('http', 'https'), 2); //print __METHOD__." Result for creating incomplete user".var_export($result, true)."\n"; print __METHOD__." curl_error_no: ".$result['curl_error_no']."\n"; $this->assertEquals($result['curl_error_no'], ''); @@ -221,7 +221,7 @@ class RestAPIUserTest extends PHPUnit\Framework\TestCase ); $body = json_encode($bodyobj); print __METHOD__." Request POST url=".$url."\n"; - $result=getURLContent($url, 'POST', $body, 1, $addheaders); + $result=getURLContent($url, 'POST', $body, 1, $addheaders, array('http', 'https'), 2); print __METHOD__." Result code for creating user ".var_export($result, true)."\n"; print __METHOD__." curl_error_no: ".$result['curl_error_no']."\n"; $this->assertEquals($result['curl_error_no'], ''); @@ -231,7 +231,7 @@ class RestAPIUserTest extends PHPUnit\Framework\TestCase // attempt to create duplicated user print __METHOD__." Request POST url=".$url."\n"; - $result=getURLContent($url, 'POST', $body, 1, $addheaders); + $result=getURLContent($url, 'POST', $body, 1, $addheaders, array('http', 'https'), 2); //print __METHOD__." Result for creating duplicate user".var_export($result, true)."\n"; print __METHOD__." curl_error_no: ".$result['curl_error_no']."\n"; $this->assertEquals($result['curl_error_no'], ''); diff --git a/test/phpunit/SecurityTest.php b/test/phpunit/SecurityTest.php index 4430b377b26..bc3595a8cfa 100644 --- a/test/phpunit/SecurityTest.php +++ b/test/phpunit/SecurityTest.php @@ -383,4 +383,59 @@ class SecurityTest extends PHPUnit\Framework\TestCase $result=restrictedArea($user, 'societe'); $this->assertEquals(1, $result); } + + + /** + * testGetRandomPassword + * + * @return number + */ + public function testGetURLContent() + { + global $conf; + include_once DOL_DOCUMENT_ROOT.'/core/lib/geturl.lib.php'; + + $url = 'ftp://mydomain.com'; + $tmp = getURLContent($url); + print __METHOD__." url=".$url."\n"; + $this->assertGreaterThan(0, strpos($tmp['curl_error_msg'], 'not supported')); // Test error if return does not contains 'not supported' + + $url = 'https://www.dolibarr.fr'; // This is a redirect 301 page + $tmp = getURLContent($url, 'GET', '', 0); // We do NOT follow + print __METHOD__." url=".$url."\n"; + $this->assertEquals(301, $tmp['http_code'], 'GET url 301 without following -> 301'); + + $url = 'https://www.dolibarr.fr'; // This is a redirect 301 page + $tmp = getURLContent($url); // We DO follow + print __METHOD__." url=".$url."\n"; + $this->assertEquals(200, $tmp['http_code'], 'GET url 301 with following -> 200'); // Test error if return does not contains 'not supported' + + $url = 'http://localhost'; + $tmp = getURLContent($url, 'GET', '', 0, array(), array('http', 'https'), 0); // Only external URL + print __METHOD__." url=".$url."\n"; + $this->assertEquals(400, $tmp['http_code'], 'GET url to '.$url.' that resolves to a local URL'); // Test we receive an error because localtest.me is not an external URL + + $url = 'http://127.0.0.1'; + $tmp = getURLContent($url, 'GET', '', 0, array(), array('http', 'https'), 0); // Only external URL + print __METHOD__." url=".$url."\n"; + $this->assertEquals(400, $tmp['http_code'], 'GET url to '.$url.' that is a local URL'); // Test we receive an error because localtest.me is not an external URL + + $url = 'https://169.254.0.1'; + $tmp = getURLContent($url, 'GET', '', 0, array(), array('http', 'https'), 0); // Only external URL + print __METHOD__." url=".$url."\n"; + $this->assertEquals(400, $tmp['http_code'], 'GET url to '.$url.' that is a local URL'); // Test we receive an error because localtest.me is not an external URL + + $url = 'http://[::1]'; + $tmp = getURLContent($url, 'GET', '', 0, array(), array('http', 'https'), 0); // Only external URL + print __METHOD__." url=".$url."\n"; + $this->assertEquals(400, $tmp['http_code'], 'GET url to '.$url.' that is a local URL'); // Test we receive an error because localtest.me is not an external URL + + /*$url = 'localtest.me'; + $tmp = getURLContent($url, 'GET', '', 0, array(), array('http', 'https'), 0); // Only external URL + print __METHOD__." url=".$url."\n"; + $this->assertEquals(400, $tmp['http_code'], 'GET url to '.$url.' that resolves to a local URL'); // Test we receive an error because localtest.me is not an external URL + */ + + return 0; + } }
    '; - if ($massactionbutton || $massaction) { - // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined - $selected = 0; - if (in_array($obj->rowid, $arrayofselected)) $selected = 1; - print ''; - } - print ''; + if ($massactionbutton || $massaction) { + // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined + $selected = 0; + if (in_array($obj->rowid, $arrayofselected)) $selected = 1; + print ''; + } + print '
    '.$langs->trans("NoRecordFound").'
    '.$langs->trans("NoRecordFound").'