diff --git a/htdocs/accountancy/admin/index.php b/htdocs/accountancy/admin/index.php index 3c98c59c0c6..f37ff79a1fa 100644 --- a/htdocs/accountancy/admin/index.php +++ b/htdocs/accountancy/admin/index.php @@ -385,8 +385,8 @@ foreach ($list_binding as $key) if ($key == 'ACCOUNTING_DATE_START_BINDING') { print $form->selectDate(($conf->global->$key ? $db->idate($conf->global->$key) : -1), $key, 0, 0, 1); } elseif ($key == 'ACCOUNTING_DEFAULT_PERIOD_ON_TRANSFER') { - $array=array(0=>$langs->trans("PreviousMonth"), 1=>$langs->trans("CurrentMonth"), 2=>$langs->trans("Fiscalyear")); - print $form->selectarray($key, $array, (isset($conf->global->ACCOUNTING_DEFAULT_PERIOD_ON_TRANSFER)?$conf->global->ACCOUNTING_DEFAULT_PERIOD_ON_TRANSFER:0)); + $array = array(0=>$langs->trans("PreviousMonth"), 1=>$langs->trans("CurrentMonth"), 2=>$langs->trans("Fiscalyear")); + print $form->selectarray($key, $array, (isset($conf->global->ACCOUNTING_DEFAULT_PERIOD_ON_TRANSFER) ? $conf->global->ACCOUNTING_DEFAULT_PERIOD_ON_TRANSFER : 0)); } else { print ''; } diff --git a/htdocs/admin/system/modules.php b/htdocs/admin/system/modules.php index 34b89e911f6..cdaa8974e24 100644 --- a/htdocs/admin/system/modules.php +++ b/htdocs/admin/system/modules.php @@ -32,13 +32,13 @@ if (!$user->admin) { // Load translation files required by the page $langs->loadLangs(array("install", "other", "admin")); -$optioncss = GETPOST('optioncss', 'alpha'); +$optioncss = GETPOST('optioncss', 'alpha'); $contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'moduleoverview'; $search_name = GETPOST("search_name", 'alpha'); -$search_id = GETPOST("search_id", 'alpha'); -$search_version = GETPOST("search_version", 'alpha'); -$search_permission = GETPOST("search_permission", 'alpha'); +$search_id = GETPOST("search_id", 'alpha'); +$search_version = GETPOST("search_version", 'alpha'); +$search_permission = GETPOST("search_permission", 'alpha'); $sortfield = GETPOST("sortfield", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha'); @@ -126,9 +126,9 @@ foreach ($modulesdir as $dir) { foreach ($modules as $key=>$module) { $newModule = new stdClass(); - $newModule->name = $module->getName(); - $newModule->version = $module->getVersion(); - $newModule->id = $key; + $newModule->name = $module->getName(); + $newModule->version = $module->getVersion(); + $newModule->id = $key; $alt = $module->name.' - '.$modules_files[$key]; @@ -260,13 +260,13 @@ print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $ print ''; // sort list -if ($sortfield == "name" && $sortorder == "asc") usort($moduleList, function (stdClass $a, stdClass $b) { +if ($sortfield == "name" && $sortorder == "asc") usort($moduleList, function(stdClass $a, stdClass $b) { return strcasecmp($a->name, $b->name); }); -if ($sortfield == "name" && $sortorder == "desc") usort($moduleList, function (stdClass $a, stdClass $b) { +if ($sortfield == "name" && $sortorder == "desc") usort($moduleList, function(stdClass $a, stdClass $b) { return strcasecmp($b->name, $a->name); }); -if ($sortfield == "version" && $sortorder == "asc") usort($moduleList, function (stdClass $a, stdClass $b) { +if ($sortfield == "version" && $sortorder == "asc") usort($moduleList, function(stdClass $a, stdClass $b) { return strcasecmp($a->version, $b->version); }); -if ($sortfield == "version" && $sortorder == "desc") usort($moduleList, function (stdClass $a, stdClass $b) { +if ($sortfield == "version" && $sortorder == "desc") usort($moduleList, function(stdClass $a, stdClass $b) { return strcasecmp($b->version, $a->version); }); if ($sortfield == "id" && $sortorder == "asc") usort($moduleList, "compareIdAsc"); if ($sortfield == "id" && $sortorder == "desc") usort($moduleList, "compareIdDesc"); @@ -298,7 +298,7 @@ foreach ($moduleList as $module) { $idperms .= ($idperms ? ", " : "").$permission; $translationKey = "Permission".$permission; - if (! empty($conf->global->MAIN_SHOW_PERMISSION)) { + if (!empty($conf->global->MAIN_SHOW_PERMISSION)) { if (empty($langs->tab_translate[$translationKey])) { $tooltip = 'Missing translation (key '.$translationkey.' not found in admin.lang)'; $idperms .= ' Warning'; diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php index 43fcfd98d8d..dc82c0cfaa4 100644 --- a/htdocs/comm/action/class/actioncomm.class.php +++ b/htdocs/comm/action/class/actioncomm.class.php @@ -1995,7 +1995,7 @@ class ActionComm extends CommonObject $formmail = new FormMail($this->db); $actionCommReminder = new ActionCommReminder($this->db); - while ($obj = $this->db->fetch_object($resql)){ + while ($obj = $this->db->fetch_object($resql)) { $res = $actionCommReminder->fetch($obj->id); if ($res < 0) { $error++; @@ -2055,7 +2055,7 @@ class ActionComm extends CommonObject { $errorsMsg[] = "Failed to update status of ActionComm Reminder"; $error++; - break; // This is to avoid to have this error on all the selected email. If we fails here for one record, it may fails for others. We must solve first. + break; // This is to avoid to have this error on all the selected email. If we fails here for one record, it may fails for others. We must solve first. } else { $nbMailSend++; } diff --git a/htdocs/commande/class/api_orders.class.php b/htdocs/commande/class/api_orders.class.php index 75f9457b45f..f62c00ee81b 100644 --- a/htdocs/commande/class/api_orders.class.php +++ b/htdocs/commande/class/api_orders.class.php @@ -475,16 +475,16 @@ class Orders extends DolibarrApi */ public function getContacts($id, $type = '') { - if (! DolibarrApiAccess::$user->rights->commande->lire) { + if (!DolibarrApiAccess::$user->rights->commande->lire) { throw new RestException(401); } $result = $this->commande->fetch($id); - if ( ! $result ) { + if (!$result) { throw new RestException(404, 'Order not found'); } - if ( ! DolibarrApi::_checkAccessToResource('commande', $this->commande->id)) { + if (!DolibarrApi::_checkAccessToResource('commande', $this->commande->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } @@ -556,16 +556,16 @@ class Orders extends DolibarrApi */ public function deleteContact($id, $rowid) { - if (! DolibarrApiAccess::$user->rights->commande->creer) { + if (!DolibarrApiAccess::$user->rights->commande->creer) { throw new RestException(401); } $result = $this->commande->fetch($id); - if (! $result) { + if (!$result) { throw new RestException(404, 'Order not found'); } - if (! DolibarrApi::_checkAccessToResource('commande', $this->commande->id)) { + if (!DolibarrApi::_checkAccessToResource('commande', $this->commande->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } diff --git a/htdocs/compta/bank/various_payment/list.php b/htdocs/compta/bank/various_payment/list.php index e7fc86ba8ee..cfecfecffa5 100644 --- a/htdocs/compta/bank/various_payment/list.php +++ b/htdocs/compta/bank/various_payment/list.php @@ -134,18 +134,18 @@ $fieldstosearchall = array( // Definition of fields for lists $arrayfields = array( - 'ref' =>array('label'=>"Ref", 'checked'=>1, 'position'=>100), - 'label' =>array('label'=>"Label", 'checked'=>1, 'position'=>110), - 'datep' =>array('label'=>"DatePayment", 'checked'=>1, 'position'=>120), - 'datev' =>array('label'=>"DateValue", 'checked'=>1, 'position'=>130), - 'type' =>array('label'=>"PaymentMode", 'checked'=>1, 'position'=>140), - 'project' =>array('label'=>"Project", 'checked'=>1, 'position'=>200, "enabled"=>!empty($conf->projet->enabled)), - 'bank' =>array('label'=>"BankAccount", 'checked'=>1, 'position'=>300, "enabled"=>!empty($conf->banque->enabled)), - 'entry' =>array('label'=>"BankTransactionLine", 'checked'=>1, 'position'=>310, "enabled"=>!empty($conf->banque->enabled)), - 'account' =>array('label'=>"AccountAccountingShort", 'checked'=>1, 'position'=>400, "enabled"=>!empty($conf->accounting->enabled)), - 'subledger' =>array('label'=>"SubledgerAccount", 'checked'=>1, 'position'=>410, "enabled"=>!empty($conf->accounting->enabled)), - 'debit' =>array('label'=>"Debit", 'checked'=>1, 'position'=>500), - 'credit' =>array('label'=>"Credit", 'checked'=>1, 'position'=>510), + 'ref' =>array('label'=>"Ref", 'checked'=>1, 'position'=>100), + 'label' =>array('label'=>"Label", 'checked'=>1, 'position'=>110), + 'datep' =>array('label'=>"DatePayment", 'checked'=>1, 'position'=>120), + 'datev' =>array('label'=>"DateValue", 'checked'=>1, 'position'=>130), + 'type' =>array('label'=>"PaymentMode", 'checked'=>1, 'position'=>140), + 'project' =>array('label'=>"Project", 'checked'=>1, 'position'=>200, "enabled"=>!empty($conf->projet->enabled)), + 'bank' =>array('label'=>"BankAccount", 'checked'=>1, 'position'=>300, "enabled"=>!empty($conf->banque->enabled)), + 'entry' =>array('label'=>"BankTransactionLine", 'checked'=>1, 'position'=>310, "enabled"=>!empty($conf->banque->enabled)), + 'account' =>array('label'=>"AccountAccountingShort", 'checked'=>1, 'position'=>400, "enabled"=>!empty($conf->accounting->enabled)), + 'subledger' =>array('label'=>"SubledgerAccount", 'checked'=>1, 'position'=>410, "enabled"=>!empty($conf->accounting->enabled)), + 'debit' =>array('label'=>"Debit", 'checked'=>1, 'position'=>500), + 'credit' =>array('label'=>"Credit", 'checked'=>1, 'position'=>510), ); $arrayfields = dol_sort_array($arrayfields, 'position'); @@ -168,13 +168,13 @@ if (empty($reshook)) { */ $form = new Form($db); -if ($arrayfields['account']['checked'] || $arrayfields['subledger']['checked']) $formaccounting = new FormAccounting($db); -if ($arrayfields['bank']['checked'] && !empty($conf->accounting->enabled)) $accountingjournal = new AccountingJournal($db); +if ($arrayfields['account']['checked'] || $arrayfields['subledger']['checked']) $formaccounting = new FormAccounting($db); +if ($arrayfields['bank']['checked'] && !empty($conf->accounting->enabled)) $accountingjournal = new AccountingJournal($db); if ($arrayfields['ref']['checked']) $variousstatic = new PaymentVarious($db); if ($arrayfields['bank']['checked']) $accountstatic = new Account($db); -if ($arrayfields['project']['checked']) $proj = new Project($db); -if ($arrayfields['entry']['checked']) $bankline = new AccountLine($db); -if ($arrayfields['account']['checked']) $accountingaccount = new AccountingAccount($db); +if ($arrayfields['project']['checked']) $proj = new Project($db); +if ($arrayfields['entry']['checked']) $bankline = new AccountLine($db); +if ($arrayfields['account']['checked']) $accountingaccount = new AccountingAccount($db); $sql = "SELECT v.rowid, v.sens, v.amount, v.label, v.datep as datep, v.datev as datev, v.fk_typepayment as type, v.num_payment, v.fk_bank, v.accountancy_code, v.subledger_account, v.fk_projet as fk_project,"; $sql .= " ba.rowid as bid, ba.ref as bref, ba.number as bnumber, ba.account_number as bank_account_number, ba.fk_accountancy_journal as accountancy_journal, ba.label as blabel,"; diff --git a/htdocs/compta/facture/class/api_invoices.class.php b/htdocs/compta/facture/class/api_invoices.class.php index fe8ca7d42d3..1828493d89f 100644 --- a/htdocs/compta/facture/class/api_invoices.class.php +++ b/htdocs/compta/facture/class/api_invoices.class.php @@ -28,96 +28,96 @@ require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; */ class Invoices extends DolibarrApi { - /** - * - * @var array $FIELDS Mandatory fields, checked when create and update object - */ - static $FIELDS = array( - 'socid', - ); + /** + * + * @var array $FIELDS Mandatory fields, checked when create and update object + */ + static $FIELDS = array( + 'socid', + ); - /** - * @var Facture $invoice {@type Facture} - */ - public $invoice; + /** + * @var Facture $invoice {@type Facture} + */ + public $invoice; - /** - * Constructor - */ - public function __construct() - { - global $db, $conf; - $this->db = $db; - $this->invoice = new Facture($this->db); - } - - /** - * Get properties of a invoice object - * - * Return an array with invoice informations - * - * @param int $id ID of invoice - * @param int $contact_list 0:Return array contains all properties, 1:Return array contains just id - * @return array|mixed data without useless information - * - * @throws RestException - */ - public function get($id, $contact_list = 1) + /** + * Constructor + */ + public function __construct() { - return $this->_fetch($id, '', '', $contact_list); + global $db, $conf; + $this->db = $db; + $this->invoice = new Facture($this->db); } - /** - * Get properties of an invoice object by ref - * - * Return an array with invoice informations - * - * @param string $ref Ref of object - * @param int $contact_list 0: Returned array of contacts/addresses contains all properties, 1: Return array contains just id - * @return array|mixed data without useless information - * - * @url GET ref/{ref} - * - * @throws RestException - */ - public function getByRef($ref, $contact_list = 1) - { - return $this->_fetch('', $ref, '', $contact_list); - } + /** + * Get properties of a invoice object + * + * Return an array with invoice informations + * + * @param int $id ID of invoice + * @param int $contact_list 0:Return array contains all properties, 1:Return array contains just id + * @return array|mixed data without useless information + * + * @throws RestException + */ + public function get($id, $contact_list = 1) + { + return $this->_fetch($id, '', '', $contact_list); + } - /** - * Get properties of an invoice object by ref_ext - * - * Return an array with invoice informations - * - * @param string $ref_ext External reference of object - * @param int $contact_list 0: Returned array of contacts/addresses contains all properties, 1: Return array contains just id - * @return array|mixed data without useless information - * - * @url GET ref_ext/{ref_ext} - * - * @throws RestException - */ - public function getByRefExt($ref_ext, $contact_list = 1) - { - return $this->_fetch('', '', $ref_ext, $contact_list); - } + /** + * Get properties of an invoice object by ref + * + * Return an array with invoice informations + * + * @param string $ref Ref of object + * @param int $contact_list 0: Returned array of contacts/addresses contains all properties, 1: Return array contains just id + * @return array|mixed data without useless information + * + * @url GET ref/{ref} + * + * @throws RestException + */ + public function getByRef($ref, $contact_list = 1) + { + return $this->_fetch('', $ref, '', $contact_list); + } - /** - * Get properties of an invoice object - * - * Return an array with invoice informations - * - * @param int $id ID of order + /** + * Get properties of an invoice object by ref_ext + * + * Return an array with invoice informations + * + * @param string $ref_ext External reference of object + * @param int $contact_list 0: Returned array of contacts/addresses contains all properties, 1: Return array contains just id + * @return array|mixed data without useless information + * + * @url GET ref_ext/{ref_ext} + * + * @throws RestException + */ + public function getByRefExt($ref_ext, $contact_list = 1) + { + return $this->_fetch('', '', $ref_ext, $contact_list); + } + + /** + * Get properties of an invoice object + * + * Return an array with invoice informations + * + * @param int $id ID of order * @param string $ref Ref of object * @param string $ref_ext External reference of object - * @param int $contact_list 0: Returned array of contacts/addresses contains all properties, 1: Return array contains just id - * @return array|mixed data without useless information - * - * @throws RestException - */ - private function _fetch($id, $ref = '', $ref_ext = '', $contact_list = 1) - { + * @param int $contact_list 0: Returned array of contacts/addresses contains all properties, 1: Return array contains just id + * @return array|mixed data without useless information + * + * @throws RestException + */ + private function _fetch($id, $ref = '', $ref_ext = '', $contact_list = 1) + { if (!DolibarrApiAccess::$user->rights->facture->lire) { throw new RestException(401); } @@ -142,138 +142,138 @@ class Invoices extends DolibarrApi $this->invoice->fetchObjectLinked(); return $this->_cleanObjectDatas($this->invoice); - } + } - /** - * List invoices - * - * Get a list of invoices - * - * @param string $sortfield Sort field - * @param string $sortorder Sort order - * @param int $limit Limit for list - * @param int $page Page number - * @param string $thirdparty_ids Thirdparty ids to filter orders of (example '1' or '1,2,3') {@pattern /^[0-9,]*$/i} - * @param string $status Filter by invoice status : draft | unpaid | paid | cancelled - * @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 invoice objects - * + /** + * List invoices + * + * Get a list of invoices + * + * @param string $sortfield Sort field + * @param string $sortorder Sort order + * @param int $limit Limit for list + * @param int $page Page number + * @param string $thirdparty_ids Thirdparty ids to filter orders of (example '1' or '1,2,3') {@pattern /^[0-9,]*$/i} + * @param string $status Filter by invoice status : draft | unpaid | paid | cancelled + * @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 invoice objects + * * @throws RestException 404 Not found * @throws RestException 503 Error - */ - public function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $thirdparty_ids = '', $status = '', $sqlfilters = '') - { - global $db, $conf; + */ + public function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $thirdparty_ids = '', $status = '', $sqlfilters = '') + { + global $db, $conf; - $obj_ret = array(); + $obj_ret = array(); - // case of external user, $thirdparty_ids param is ignored and replaced by user's socid - $socids = DolibarrApiAccess::$user->socid ? DolibarrApiAccess::$user->socid : $thirdparty_ids; + // case of external user, $thirdparty_ids param is ignored and replaced by user's socid + $socids = DolibarrApiAccess::$user->socid ? DolibarrApiAccess::$user->socid : $thirdparty_ids; - // If the internal user must only see his customers, force searching by him - $search_sale = 0; - if (!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) $search_sale = DolibarrApiAccess::$user->id; + // If the internal user must only see his customers, force searching by him + $search_sale = 0; + if (!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) $search_sale = DolibarrApiAccess::$user->id; - $sql = "SELECT t.rowid"; - if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) $sql .= ", sc.fk_soc, sc.fk_user"; // We need these fields in order to filter by sale (including the case where the user can only see his prospects) - $sql .= " FROM ".MAIN_DB_PREFIX."facture as t"; + $sql = "SELECT t.rowid"; + if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) $sql .= ", sc.fk_soc, sc.fk_user"; // We need these fields in order to filter by sale (including the case where the user can only see his prospects) + $sql .= " FROM ".MAIN_DB_PREFIX."facture as t"; - if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; // We need this table joined to the select in order to filter by sale + if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; // We need this table joined to the select in order to filter by sale - $sql .= ' WHERE t.entity IN ('.getEntity('invoice').')'; - if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) $sql .= " AND t.fk_soc = sc.fk_soc"; - if ($socids) $sql .= " AND t.fk_soc IN (".$socids.")"; + $sql .= ' WHERE t.entity IN ('.getEntity('invoice').')'; + if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) $sql .= " AND t.fk_soc = sc.fk_soc"; + if ($socids) $sql .= " AND t.fk_soc IN (".$socids.")"; - if ($search_sale > 0) $sql .= " AND t.rowid = sc.fk_soc"; // Join for the needed table to filter by sale + if ($search_sale > 0) $sql .= " AND t.rowid = sc.fk_soc"; // Join for the needed table to filter by sale // Filter by status - if ($status == 'draft') $sql .= " AND t.fk_statut IN (0)"; - if ($status == 'unpaid') $sql .= " AND t.fk_statut IN (1)"; - if ($status == 'paid') $sql .= " AND t.fk_statut IN (2)"; - if ($status == 'cancelled') $sql .= " AND t.fk_statut IN (3)"; - // Insert sale filter - if ($search_sale > 0) - { - $sql .= " AND sc.fk_user = ".$search_sale; - } - // Add sql filters - if ($sqlfilters) - { - if (!DolibarrApi::_checkFilters($sqlfilters)) - { - throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); - } - $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; - $sql .= " AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; - } + if ($status == 'draft') $sql .= " AND t.fk_statut IN (0)"; + if ($status == 'unpaid') $sql .= " AND t.fk_statut IN (1)"; + if ($status == 'paid') $sql .= " AND t.fk_statut IN (2)"; + if ($status == 'cancelled') $sql .= " AND t.fk_statut IN (3)"; + // Insert sale filter + if ($search_sale > 0) + { + $sql .= " AND sc.fk_user = ".$search_sale; + } + // Add sql filters + if ($sqlfilters) + { + if (!DolibarrApi::_checkFilters($sqlfilters)) + { + throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); + } + $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; + $sql .= " AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; + } - $sql .= $db->order($sortfield, $sortorder); - if ($limit) - { - if ($page < 0) - { - $page = 0; - } - $offset = $limit * $page; + $sql .= $db->order($sortfield, $sortorder); + if ($limit) + { + if ($page < 0) + { + $page = 0; + } + $offset = $limit * $page; - $sql .= $db->plimit($limit + 1, $offset); - } + $sql .= $db->plimit($limit + 1, $offset); + } - $result = $db->query($sql); - if ($result) - { - $i = 0; - $num = $db->num_rows($result); - $min = min($num, ($limit <= 0 ? $num : $limit)); - while ($i < $min) - { - $obj = $db->fetch_object($result); - $invoice_static = new Facture($db); - if ($invoice_static->fetch($obj->rowid)) - { - // Get payment details - $invoice_static->totalpaid = $invoice_static->getSommePaiement(); - $invoice_static->totalcreditnotes = $invoice_static->getSumCreditNotesUsed(); - $invoice_static->totaldeposits = $invoice_static->getSumDepositsUsed(); - $invoice_static->remaintopay = price2num($invoice_static->total_ttc - $invoice_static->totalpaid - $invoice_static->totalcreditnotes - $invoice_static->totaldeposits, 'MT'); + $result = $db->query($sql); + if ($result) + { + $i = 0; + $num = $db->num_rows($result); + $min = min($num, ($limit <= 0 ? $num : $limit)); + while ($i < $min) + { + $obj = $db->fetch_object($result); + $invoice_static = new Facture($db); + if ($invoice_static->fetch($obj->rowid)) + { + // Get payment details + $invoice_static->totalpaid = $invoice_static->getSommePaiement(); + $invoice_static->totalcreditnotes = $invoice_static->getSumCreditNotesUsed(); + $invoice_static->totaldeposits = $invoice_static->getSumDepositsUsed(); + $invoice_static->remaintopay = price2num($invoice_static->total_ttc - $invoice_static->totalpaid - $invoice_static->totalcreditnotes - $invoice_static->totaldeposits, 'MT'); // Add external contacts ids $invoice_static->contacts_ids = $invoice_static->liste_contact(-1, 'external', 1); - $obj_ret[] = $this->_cleanObjectDatas($invoice_static); - } - $i++; - } - } else { - throw new RestException(503, 'Error when retrieve invoice list : '.$db->lasterror()); - } - if (!count($obj_ret)) { - throw new RestException(404, 'No invoice found'); - } + $obj_ret[] = $this->_cleanObjectDatas($invoice_static); + } + $i++; + } + } else { + throw new RestException(503, 'Error when retrieve invoice list : '.$db->lasterror()); + } + if (!count($obj_ret)) { + throw new RestException(404, 'No invoice found'); + } return $obj_ret; - } + } - /** - * Create invoice object - * - * @param array $request_data Request datas - * @return int ID of invoice - */ - public function post($request_data = null) - { - if (!DolibarrApiAccess::$user->rights->facture->creer) { + /** + * Create invoice object + * + * @param array $request_data Request datas + * @return int ID of invoice + */ + public function post($request_data = null) + { + if (!DolibarrApiAccess::$user->rights->facture->creer) { throw new RestException(401, "Insuffisant rights"); } - // Check mandatory fields - $result = $this->_validate($request_data); + // Check mandatory fields + $result = $this->_validate($request_data); - foreach ($request_data as $field => $value) { - $this->invoice->$field = $value; - } - if (!array_key_exists('date', $request_data)) { - $this->invoice->date = dol_now(); - } - /* We keep lines as an array + foreach ($request_data as $field => $value) { + $this->invoice->$field = $value; + } + if (!array_key_exists('date', $request_data)) { + $this->invoice->date = dol_now(); + } + /* We keep lines as an array if (isset($request_data["lines"])) { $lines = array(); foreach ($request_data["lines"] as $line) { @@ -282,154 +282,154 @@ class Invoices extends DolibarrApi $this->invoice->lines = $lines; }*/ - if ($this->invoice->create(DolibarrApiAccess::$user, 0, (empty($request_data["date_lim_reglement"]) ? 0 : $request_data["date_lim_reglement"])) < 0) { - throw new RestException(500, "Error creating invoice", array_merge(array($this->invoice->error), $this->invoice->errors)); - } - return $this->invoice->id; - } + if ($this->invoice->create(DolibarrApiAccess::$user, 0, (empty($request_data["date_lim_reglement"]) ? 0 : $request_data["date_lim_reglement"])) < 0) { + throw new RestException(500, "Error creating invoice", array_merge(array($this->invoice->error), $this->invoice->errors)); + } + return $this->invoice->id; + } - /** - * Create an invoice using an existing order. - * - * - * @param int $orderid Id of the order - * - * @url POST /createfromorder/{orderid} - * - * @return int - * @throws RestException 400 - * @throws RestException 401 - * @throws RestException 404 - * @throws RestException 405 - */ - public function createInvoiceFromOrder($orderid) - { + /** + * Create an invoice using an existing order. + * + * + * @param int $orderid Id of the order + * + * @url POST /createfromorder/{orderid} + * + * @return int + * @throws RestException 400 + * @throws RestException 401 + * @throws RestException 404 + * @throws RestException 405 + */ + public function createInvoiceFromOrder($orderid) + { - require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; + require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; - if (!DolibarrApiAccess::$user->rights->commande->lire) { - throw new RestException(401); - } - if (!DolibarrApiAccess::$user->rights->facture->creer) { - throw new RestException(401); - } - if (empty($orderid)) { - throw new RestException(400, 'Order ID is mandatory'); - } + if (!DolibarrApiAccess::$user->rights->commande->lire) { + throw new RestException(401); + } + if (!DolibarrApiAccess::$user->rights->facture->creer) { + throw new RestException(401); + } + if (empty($orderid)) { + throw new RestException(400, 'Order ID is mandatory'); + } - $order = new Commande($this->db); - $result = $order->fetch($orderid); - if (!$result) { - throw new RestException(404, 'Order not found'); - } + $order = new Commande($this->db); + $result = $order->fetch($orderid); + if (!$result) { + throw new RestException(404, 'Order not found'); + } - $result = $this->invoice->createFromOrder($order, DolibarrApiAccess::$user); - if ($result < 0) { - throw new RestException(405, $this->invoice->error); - } - $this->invoice->fetchObjectLinked(); - return $this->_cleanObjectDatas($this->invoice); - } + $result = $this->invoice->createFromOrder($order, DolibarrApiAccess::$user); + if ($result < 0) { + throw new RestException(405, $this->invoice->error); + } + $this->invoice->fetchObjectLinked(); + return $this->_cleanObjectDatas($this->invoice); + } - /** - * Get lines of an invoice - * - * @param int $id Id of invoice - * - * @url GET {id}/lines - * - * @return int - */ - public function getLines($id) - { - if (!DolibarrApiAccess::$user->rights->facture->lire) { - throw new RestException(401); - } + /** + * Get lines of an invoice + * + * @param int $id Id of invoice + * + * @url GET {id}/lines + * + * @return int + */ + public function getLines($id) + { + if (!DolibarrApiAccess::$user->rights->facture->lire) { + throw new RestException(401); + } - $result = $this->invoice->fetch($id); - if (!$result) { - throw new RestException(404, 'Invoice not found'); - } + $result = $this->invoice->fetch($id); + if (!$result) { + throw new RestException(404, 'Invoice not found'); + } - if (!DolibarrApi::_checkAccessToResource('facture', $this->invoice->id)) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); - } - $this->invoice->getLinesArray(); - $result = array(); - foreach ($this->invoice->lines as $line) { - array_push($result, $this->_cleanObjectDatas($line)); - } - return $result; - } + if (!DolibarrApi::_checkAccessToResource('facture', $this->invoice->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } + $this->invoice->getLinesArray(); + $result = array(); + foreach ($this->invoice->lines as $line) { + array_push($result, $this->_cleanObjectDatas($line)); + } + return $result; + } - /** - * Update a line to a given invoice - * - * @param int $id Id of invoice to update - * @param int $lineid Id of line to update - * @param array $request_data InvoiceLine data - * - * @url PUT {id}/lines/{lineid} - * - * @return array - * - * @throws RestException 304 - * @throws RestException 401 - * @throws RestException 404 Invoice not found - */ - public function putLine($id, $lineid, $request_data = null) - { - if (!DolibarrApiAccess::$user->rights->facture->creer) { - throw new RestException(401); - } + /** + * Update a line to a given invoice + * + * @param int $id Id of invoice to update + * @param int $lineid Id of line to update + * @param array $request_data InvoiceLine data + * + * @url PUT {id}/lines/{lineid} + * + * @return array + * + * @throws RestException 304 + * @throws RestException 401 + * @throws RestException 404 Invoice not found + */ + public function putLine($id, $lineid, $request_data = null) + { + if (!DolibarrApiAccess::$user->rights->facture->creer) { + throw new RestException(401); + } - $result = $this->invoice->fetch($id); - if (!$result) { - throw new RestException(404, 'Invoice not found'); - } + $result = $this->invoice->fetch($id); + if (!$result) { + throw new RestException(404, 'Invoice not found'); + } - if (!DolibarrApi::_checkAccessToResource('facture', $this->invoice->id)) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); - } - $request_data = (object) $request_data; - $updateRes = $this->invoice->updateline( - $lineid, - $request_data->desc, - $request_data->subprice, - $request_data->qty, - $request_data->remise_percent, - $request_data->date_start, - $request_data->date_end, - $request_data->tva_tx, - $request_data->localtax1_tx, - $request_data->localtax2_tx, - 'HT', - $request_data->info_bits, - $request_data->product_type, - $request_data->fk_parent_line, - 0, - $request_data->fk_fournprice, - $request_data->pa_ht, - $request_data->label, - $request_data->special_code, - $request_data->array_options, - $request_data->situation_percent, - $request_data->fk_unit, - $request_data->multicurrency_subprice, - 0, - $request_data->ref_ext - ); + if (!DolibarrApi::_checkAccessToResource('facture', $this->invoice->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } + $request_data = (object) $request_data; + $updateRes = $this->invoice->updateline( + $lineid, + $request_data->desc, + $request_data->subprice, + $request_data->qty, + $request_data->remise_percent, + $request_data->date_start, + $request_data->date_end, + $request_data->tva_tx, + $request_data->localtax1_tx, + $request_data->localtax2_tx, + 'HT', + $request_data->info_bits, + $request_data->product_type, + $request_data->fk_parent_line, + 0, + $request_data->fk_fournprice, + $request_data->pa_ht, + $request_data->label, + $request_data->special_code, + $request_data->array_options, + $request_data->situation_percent, + $request_data->fk_unit, + $request_data->multicurrency_subprice, + 0, + $request_data->ref_ext + ); - if ($updateRes > 0) { - $result = $this->get($id); - unset($result->line); - return $this->_cleanObjectDatas($result); - } else { - throw new RestException(304, $this->invoice->error); - } - } + if ($updateRes > 0) { + $result = $this->get($id); + unset($result->line); + return $this->_cleanObjectDatas($result); + } else { + throw new RestException(304, $this->invoice->error); + } + } - /** + /** * Add a contact type of given invoice * * @param int $id Id of invoice to update @@ -440,39 +440,39 @@ class Invoices extends DolibarrApi * * @return int * - * @throws RestException 401 - * @throws RestException 404 + * @throws RestException 401 + * @throws RestException 404 */ - public function postContact($id, $contactid, $type) - { - if (!DolibarrApiAccess::$user->rights->facture->creer) { - throw new RestException(401); - } + public function postContact($id, $contactid, $type) + { + if (!DolibarrApiAccess::$user->rights->facture->creer) { + throw new RestException(401); + } - $result = $this->invoice->fetch($id); + $result = $this->invoice->fetch($id); if (!$result) { throw new RestException(404, 'Invoice not found'); } - if (!in_array($type, array('BILLING', 'SHIPPING', 'CUSTOMER'), true)) { - throw new RestException(500, 'Availables types: BILLING, SHIPPING OR CUSTOMER'); - } + if (!in_array($type, array('BILLING', 'SHIPPING', 'CUSTOMER'), true)) { + throw new RestException(500, 'Availables types: BILLING, SHIPPING OR CUSTOMER'); + } - if (!DolibarrApi::_checkAccessToResource('invoice', $this->invoice->id)) { + if (!DolibarrApi::_checkAccessToResource('invoice', $this->invoice->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } - $result = $this->invoice->add_contact($contactid, $type, 'external'); + $result = $this->invoice->add_contact($contactid, $type, 'external'); - if (!$result) { - throw new RestException(500, 'Error when added the contact'); - } + if (!$result) { + throw new RestException(500, 'Error when added the contact'); + } - return $this->_cleanObjectDatas($this->invoice); - } + return $this->_cleanObjectDatas($this->invoice); + } - /** + /** * Delete a contact type of given invoice * * @param int $id Id of invoice to update diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index d47caa3b92a..5110b1194e5 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -5160,15 +5160,15 @@ class FactureLigne extends CommonInvoiceLine $this->db->begin(); - // Update line in database - $sql = "UPDATE ".MAIN_DB_PREFIX."facturedet SET"; - $sql .= " description='".$this->db->escape($this->desc)."'"; - $sql .= ", ref_ext='".$this->db->escape($this->ref_ext)."'"; - $sql .= ", label=".(!empty($this->label) ? "'".$this->db->escape($this->label)."'" : "null"); - $sql .= ", subprice=".price2num($this->subprice).""; - $sql .= ", remise_percent=".price2num($this->remise_percent).""; - if ($this->fk_remise_except) $sql .= ", fk_remise_except=".$this->fk_remise_except; - else $sql .= ", fk_remise_except=null"; + // Update line in database + $sql = "UPDATE ".MAIN_DB_PREFIX."facturedet SET"; + $sql .= " description='".$this->db->escape($this->desc)."'"; + $sql .= ", ref_ext='".$this->db->escape($this->ref_ext)."'"; + $sql .= ", label=".(!empty($this->label) ? "'".$this->db->escape($this->label)."'" : "null"); + $sql .= ", subprice=".price2num($this->subprice).""; + $sql .= ", remise_percent=".price2num($this->remise_percent).""; + if ($this->fk_remise_except) $sql .= ", fk_remise_except=".$this->fk_remise_except; + else $sql .= ", fk_remise_except=null"; $sql .= ", vat_src_code = '".(empty($this->vat_src_code) ? '' : $this->db->escape($this->vat_src_code))."'"; $sql .= ", tva_tx=".price2num($this->tva_tx).""; $sql .= ", localtax1_tx=".price2num($this->localtax1_tx).""; diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php index f08516812be..ddf811cfc77 100644 --- a/htdocs/core/class/extrafields.class.php +++ b/htdocs/core/class/extrafields.class.php @@ -1231,7 +1231,7 @@ class ExtraFields } else { if (!$notrans) { $translabel = $langs->trans($obj->{$InfoFieldList[1]}); - $labeltoshow =$translabel; + $labeltoshow = $translabel; } if (empty($labeltoshow)) $labeltoshow = '(not defined)'; diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 9b450925a42..3350507e543 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -7993,18 +7993,18 @@ class Form include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php'; $formmail = new FormMail($db); - $result = $formmail->fetchAllEMailTemplate($modelType, $user, $langs); + $result = $formmail->fetchAllEMailTemplate($modelType, $user, $langs); if ($default) $TModels[0] = $langs->trans('DefaultMailModel'); if ($result > 0) { - foreach ($formmail->lines_model as $model){ + foreach ($formmail->lines_model as $model) { $TModels[$model->id] = $model->label; } } $retstring .= 'ref . '] '.$langs->trans('TicketNewMessage').'" />'; + print 'ref.'] '.$langs->trans('TicketNewMessage').'" />'; print ''; // Destinataires @@ -987,7 +987,7 @@ class FormTicket } // MESSAGE - $defaultmessage=""; + $defaultmessage = ""; if (is_object($arraydefaultmessage) && $arraydefaultmessage->content) { $defaultmessage = $arraydefaultmessage->content; } diff --git a/htdocs/core/class/menubase.class.php b/htdocs/core/class/menubase.class.php index ea84e5ab76e..4d949f4f7d8 100644 --- a/htdocs/core/class/menubase.class.php +++ b/htdocs/core/class/menubase.class.php @@ -709,7 +709,7 @@ class Menubase $tabMenu[$b]['mainmenu'] = $menu['mainmenu']; $tabMenu[$b]['leftmenu'] = $menu['leftmenu']; $tabMenu[$b]['perms'] = $perms; - $tabMenu[$b]['langs'] = $menu['langs']; // Note that this should not be used, lang file should be already loaded. + $tabMenu[$b]['langs'] = $menu['langs']; // Note that this should not be used, lang file should be already loaded. $tabMenu[$b]['enabled'] = $enabled; $tabMenu[$b]['type'] = $menu['type']; $tabMenu[$b]['fk_mainmenu'] = $menu['fk_mainmenu']; diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 57941a4fb2d..fe684d2100e 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -6187,15 +6187,15 @@ function getCommonSubstitutionArray($outputlangs, $onlykey = 0, $exclude = null, foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $label) { $substitutionarray['__EXTRAFIELD_'.strtoupper($key).'__'] = $object->array_options['options_'.$key]; if ($extrafields->attributes[$object->table_element]['type'][$key] == 'date') { - $substitutionarray['__EXTRAFIELD_' . strtoupper($key) . '__'] = dol_print_date($object->array_options['options_' . $key], 'day'); - $substitutionarray['__EXTRAFIELD_' . strtoupper($key) . '_LOCALE__'] = dol_print_date($object->array_options['options_' . $key], 'day', 'tzserver', $outputlangs); - $substitutionarray['__EXTRAFIELD_' . strtoupper($key) . '_RFC__'] = dol_print_date($object->array_options['options_' . $key], 'dayrfc'); + $substitutionarray['__EXTRAFIELD_'.strtoupper($key).'__'] = dol_print_date($object->array_options['options_'.$key], 'day'); + $substitutionarray['__EXTRAFIELD_'.strtoupper($key).'_LOCALE__'] = dol_print_date($object->array_options['options_'.$key], 'day', 'tzserver', $outputlangs); + $substitutionarray['__EXTRAFIELD_'.strtoupper($key).'_RFC__'] = dol_print_date($object->array_options['options_'.$key], 'dayrfc'); } elseif ($extrafields->attributes[$object->table_element]['type'][$key] == 'datetime') { $datetime = $object->array_options['options_'.$key]; - $substitutionarray['__EXTRAFIELD_' . strtoupper($key) . '__'] = ($datetime != "0000-00-00 00:00:00" ? dol_print_date($datetime, 'dayhour') : ''); - $substitutionarray['__EXTRAFIELD_' . strtoupper($key) . '_LOCALE__'] = ($datetime != "0000-00-00 00:00:00" ? dol_print_date($datetime, 'dayhour', 'tzserver', $outputlangs) : ''); - $substitutionarray['__EXTRAFIELD_' . strtoupper($key) . '_DAY_LOCALE__'] = ($datetime != "0000-00-00 00:00:00" ? dol_print_date($datetime, 'day', 'tzserver', $outputlangs) : ''); - $substitutionarray['__EXTRAFIELD_' . strtoupper($key) . '_RFC__'] = ($datetime != "0000-00-00 00:00:00" ? dol_print_date($datetime, 'dayhourrfc') : ''); + $substitutionarray['__EXTRAFIELD_'.strtoupper($key).'__'] = ($datetime != "0000-00-00 00:00:00" ? dol_print_date($datetime, 'dayhour') : ''); + $substitutionarray['__EXTRAFIELD_'.strtoupper($key).'_LOCALE__'] = ($datetime != "0000-00-00 00:00:00" ? dol_print_date($datetime, 'dayhour', 'tzserver', $outputlangs) : ''); + $substitutionarray['__EXTRAFIELD_'.strtoupper($key).'_DAY_LOCALE__'] = ($datetime != "0000-00-00 00:00:00" ? dol_print_date($datetime, 'day', 'tzserver', $outputlangs) : ''); + $substitutionarray['__EXTRAFIELD_'.strtoupper($key).'_RFC__'] = ($datetime != "0000-00-00 00:00:00" ? dol_print_date($datetime, 'dayhourrfc') : ''); } } } diff --git a/htdocs/core/modules/member/doc/pdf_standard.class.php b/htdocs/core/modules/member/doc/pdf_standard.class.php index 1d391846339..e6fd6d04091 100644 --- a/htdocs/core/modules/member/doc/pdf_standard.class.php +++ b/htdocs/core/modules/member/doc/pdf_standard.class.php @@ -42,12 +42,12 @@ class pdf_standard extends CommonStickerGenerator * @param array $param Associative array containing label content and optional parameters * @return void */ - public function addSticker(&$pdf, $outputlangs, $param) - { + public function addSticker(&$pdf, $outputlangs, $param) + { // use this method in future refactoring } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Output a sticker on page at position _COUNTX, _COUNTY (_COUNTX and _COUNTY start from 0) * - __LOGO__ is replace with company logo @@ -65,7 +65,7 @@ class pdf_standard extends CommonStickerGenerator */ public function Add_PDF_card(&$pdf, $textleft, $header, $footer, $outputlangs, $textright = '', $idmember = 0, $photo = '') { - // phpcs:enable + // phpcs:enable global $db, $mysoc, $conf, $langs; global $forceimgscalewidth, $forceimgscaleheight; @@ -229,7 +229,7 @@ class pdf_standard extends CommonStickerGenerator } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Function to build PDF on disk, then output on HTTP stream. * @@ -311,14 +311,14 @@ class pdf_standard extends CommonStickerGenerator $this->Tformat = $_Avery_Labels[$this->code]; if (empty($this->Tformat)) { dol_print_error('', 'ErrorBadTypeForCard'.$this->code); exit; } $this->type = 'pdf'; - // standard format or custom - if ($this->Tformat['paper-size'] != 'custom') { - $this->format = $this->Tformat['paper-size']; - } else { - //custom - $resolution = array($this->Tformat['custom_x'], $this->Tformat['custom_y']); - $this->format = $resolution; - } + // standard format or custom + if ($this->Tformat['paper-size'] != 'custom') { + $this->format = $this->Tformat['paper-size']; + } else { + //custom + $resolution = array($this->Tformat['custom_x'], $this->Tformat['custom_y']); + $this->format = $resolution; + } if (!is_object($outputlangs)) $outputlangs = $langs; // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO @@ -339,13 +339,13 @@ class pdf_standard extends CommonStickerGenerator $filename = 'tmp_cards.pdf'; if (is_object($object)) { - $outputdir = $conf->adherent->dir_output; - $dir = $outputdir."/".get_exdir(0, 0, 0, 0, $object, 'member'); - $file = $dir.'/'.$filename; + $outputdir = $conf->adherent->dir_output; + $dir = $outputdir."/".get_exdir(0, 0, 0, 0, $object, 'member'); + $file = $dir.'/'.$filename; } else { - $outputdir = $conf->adherent->dir_temp; - $dir = $outputdir; - $file = $dir.'/'.$filename; + $outputdir = $conf->adherent->dir_temp; + $dir = $outputdir; + $file = $dir.'/'.$filename; } //var_dump($file);exit; @@ -416,22 +416,22 @@ class pdf_standard extends CommonStickerGenerator // Output to http stream if (empty($nooutput)) { - clearstatcache(); + clearstatcache(); - $attachment = true; - if (!empty($conf->global->MAIN_DISABLE_FORCE_SAVEAS)) $attachment = false; - $type = dol_mimetype($filename); + $attachment = true; + if (!empty($conf->global->MAIN_DISABLE_FORCE_SAVEAS)) $attachment = false; + $type = dol_mimetype($filename); - //if ($encoding) header('Content-Encoding: '.$encoding); - if ($type) header('Content-Type: '.$type); - if ($attachment) header('Content-Disposition: attachment; filename="'.$filename.'"'); - else header('Content-Disposition: inline; filename="'.$filename.'"'); + //if ($encoding) header('Content-Encoding: '.$encoding); + if ($type) header('Content-Type: '.$type); + if ($attachment) header('Content-Disposition: attachment; filename="'.$filename.'"'); + else header('Content-Disposition: inline; filename="'.$filename.'"'); - // Ajout directives pour resoudre bug IE - header('Cache-Control: Public, must-revalidate'); - header('Pragma: public'); + // Ajout directives pour resoudre bug IE + header('Cache-Control: Public, must-revalidate'); + header('Pragma: public'); - readfile($file); + readfile($file); } return 1; diff --git a/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php b/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php index a8a7a674ed7..386bedad910 100644 --- a/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php +++ b/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php @@ -791,16 +791,16 @@ class InterfaceActionsAuto extends DolibarrTriggers $object->actionmsg2 = $langs->transnoentities($action."InDolibarr", ($object->newref ? $object->newref : $object->ref)); } else { // generic translation key $tmp = explode('_', $action); - $object->actionmsg2 = $langs->transnoentities($tmp[count($tmp)-1]."InDolibarr", ($object->newref ? $object->newref : $object->ref)); + $object->actionmsg2 = $langs->transnoentities($tmp[count($tmp) - 1]."InDolibarr", ($object->newref ? $object->newref : $object->ref)); } } - if (empty($object->actionmsg)) { + if (empty($object->actionmsg)) { $langs->loadLangs(array("agenda", "other")); if ($langs->transnoentities($action."InDolibarr", ($object->newref ? $object->newref : $object->ref)) != $action."InDolibarr") { // specific translation key $object->actionmsg = $langs->transnoentities($action."InDolibarr", ($object->newref ? $object->newref : $object->ref)); } else { // generic translation key $tmp = explode('_', $action); - $object->actionmsg = $langs->transnoentities($tmp[count($tmp)-1]."InDolibarr", ($object->newref ? $object->newref : $object->ref)); + $object->actionmsg = $langs->transnoentities($tmp[count($tmp) - 1]."InDolibarr", ($object->newref ? $object->newref : $object->ref)); } } @@ -843,7 +843,7 @@ class InterfaceActionsAuto extends DolibarrTriggers $projectid = isset($object->fk_project) ? $object->fk_project : 0; if ($object->element == 'project') $projectid = $object->id; - $elementid = $object->id; // id of object + $elementid = $object->id; // id of object $elementtype = $object->element; $elementmodule = $object->module; if ($object->element == 'subscription') diff --git a/htdocs/debugbar/class/autoloader.php b/htdocs/debugbar/class/autoloader.php index 91606babb84..721febdd13c 100644 --- a/htdocs/debugbar/class/autoloader.php +++ b/htdocs/debugbar/class/autoloader.php @@ -4,7 +4,7 @@ * Simple autoloader, so we don't need Composer just for this. */ -spl_autoload_register(function ($class) { +spl_autoload_register(function($class) { if (preg_match('/^DebugBar/', $class)) { $file = DOL_DOCUMENT_ROOT.'/includes/maximebf/debugbar/src/'.str_replace('\\', DIRECTORY_SEPARATOR, $class).'.php'; //var_dump($class.' - '.file_exists($file).' - '.$file); diff --git a/htdocs/emailcollector/class/emailcollector.class.php b/htdocs/emailcollector/class/emailcollector.class.php index be53ebefaeb..4b84a97fde0 100644 --- a/htdocs/emailcollector/class/emailcollector.class.php +++ b/htdocs/emailcollector/class/emailcollector.class.php @@ -299,8 +299,8 @@ class EmailCollector extends CommonObject // Load source object $object->fetchCommon($fromid); - $object->fetchFilters(); // Rules - $object->fetchActions(); // Operations + $object->fetchFilters(); // Rules + $object->fetchActions(); // Operations // Reset some properties unset($object->id); @@ -979,7 +979,7 @@ class EmailCollector extends CommonObject { if (empty($rule['status'])) continue; - if ($rule['type'] == 'to') { + if ($rule['type'] == 'to') { $tmprulevaluearray = explode('*', $rule['rulevalue']); if (count($tmprulevaluearray) >= 2) { foreach ($tmprulevaluearray as $tmprulevalue) { @@ -1163,7 +1163,7 @@ class EmailCollector extends CommonObject if (!empty($headers['References']) && preg_match('/@'.preg_quote($host, '/').'/', $headers['References'])) { $nbemailprocessed++; - continue; // Exclude email + continue; // Exclude email } } @@ -1171,7 +1171,7 @@ class EmailCollector extends CommonObject if (empty($headers['In-Reply-To'])) { $nbemailprocessed++; - continue; // Exclude email + continue; // Exclude email } // Note: we can have // Message-ID=A, In-Reply-To=B, References=B and message can BE an answer or NOT (a transfer rewriten) @@ -1182,7 +1182,7 @@ class EmailCollector extends CommonObject if (!$isanswer) { $nbemailprocessed++; - continue; // Exclude email + continue; // Exclude email } } if ($searchfilterisnotanswer > 0) { @@ -1196,7 +1196,7 @@ class EmailCollector extends CommonObject //if ($headers['In-Reply-To'] != $headers['Message-ID'] && !empty($headers['References']) && strpos($headers['References'], $headers['Message-ID']) !== false) $isanswer = 1; if ($isanswer) { $nbemailprocessed++; - continue; // Exclude email + continue; // Exclude email } } } @@ -1702,7 +1702,7 @@ class EmailCollector extends CommonObject if (!in_array($fk_element_type, array('societe', 'contact', 'project', 'user'))) { $actioncomm->fk_element = $fk_element_id; - $actioncomm->elementid = $fk_element_id; + $actioncomm->elementid = $fk_element_id; $actioncomm->elementtype = $fk_element_type; if (is_object($objectemail) && $objectemail->module) { $actioncomm->elementtype .= '@'.$objectemail->module; diff --git a/htdocs/fourn/class/api_supplier_invoices.class.php b/htdocs/fourn/class/api_supplier_invoices.class.php index 4f41c7cf734..00171264ddb 100644 --- a/htdocs/fourn/class/api_supplier_invoices.class.php +++ b/htdocs/fourn/class/api_supplier_invoices.class.php @@ -454,7 +454,7 @@ class SupplierInvoices extends DolibarrApi $paiement->multicurrency_amounts = $multicurrency_amounts; // Array with all payments dispatching $paiement->paiementid = $payment_mode_id; $paiement->paiementcode = dol_getIdFromCode($this->db, $payment_mode_id, 'c_paiement', 'id', 'code', 1); - $paiement->oper = $paiement->paiementcode; // For backward compatibility + $paiement->oper = $paiement->paiementcode; // For backward compatibility $paiement->num_payment = $num_payment; $paiement->note_public = $comment; diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php index b824796155e..f94cadbca9c 100644 --- a/htdocs/fourn/class/fournisseur.facture.class.php +++ b/htdocs/fourn/class/fournisseur.facture.class.php @@ -696,13 +696,13 @@ class FactureFournisseur extends CommonInvoice $this->author = $obj->fk_user_author; $this->fk_user_valid = $obj->fk_user_valid; $this->fk_facture_source = $obj->fk_facture_source; - $this->fk_project = $obj->fk_project; + $this->fk_project = $obj->fk_project; $this->cond_reglement_id = $obj->fk_cond_reglement; $this->cond_reglement_code = $obj->cond_reglement_code; - $this->cond_reglement = $obj->cond_reglement_libelle; + $this->cond_reglement = $obj->cond_reglement_libelle; $this->cond_reglement_doc = $obj->cond_reglement_libelle; $this->fk_account = $obj->fk_account; - $this->mode_reglement_id = $obj->fk_mode_reglement; + $this->mode_reglement_id = $obj->fk_mode_reglement; $this->mode_reglement_code = $obj->mode_reglement_code; $this->mode_reglement = $obj->mode_reglement_libelle; $this->date_echeance = $this->db->jdate($obj->date_lim_reglement); diff --git a/htdocs/stripe/class/stripe.class.php b/htdocs/stripe/class/stripe.class.php index 6d412ae6f0a..961011b51e0 100644 --- a/htdocs/stripe/class/stripe.class.php +++ b/htdocs/stripe/class/stripe.class.php @@ -354,13 +354,13 @@ class Stripe extends CommonObject // That's why we can comment the part of code to retreive a payment intent with object id (never mind if we cumulate payment intent with old ones that will not be used) $sql = "SELECT pi.ext_payment_id, pi.entity, pi.fk_facture, pi.sourcetype, pi.ext_payment_site"; - $sql.= " FROM " . MAIN_DB_PREFIX . "prelevement_facture_demande as pi"; - $sql.= " WHERE pi.fk_facture = " . $object->id; - $sql.= " AND pi.sourcetype = '" . $object->element . "'"; - $sql.= " AND pi.entity IN (".getEntity('societe').")"; - $sql.= " AND pi.ext_payment_site = '" . $service . "'"; + $sql .= " FROM ".MAIN_DB_PREFIX."prelevement_facture_demande as pi"; + $sql .= " WHERE pi.fk_facture = ".$object->id; + $sql .= " AND pi.sourcetype = '".$object->element."'"; + $sql .= " AND pi.entity IN (".getEntity('societe').")"; + $sql .= " AND pi.ext_payment_site = '".$service."'"; - dol_syslog(get_class($this) . "::getPaymentIntent search stripe payment intent for object id = ".$object->id, LOG_DEBUG); + dol_syslog(get_class($this)."::getPaymentIntent search stripe payment intent for object id = ".$object->id, LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) { $num = $this->db->num_rows($resql); @@ -369,7 +369,7 @@ class Stripe extends CommonObject $obj = $this->db->fetch_object($resql); $intent = $obj->ext_payment_id; - dol_syslog(get_class($this) . "::getPaymentIntent found existing payment intent record"); + dol_syslog(get_class($this)."::getPaymentIntent found existing payment intent record"); // Force to use the correct API key global $stripearrayofkeysbyenv; @@ -403,8 +403,8 @@ class Stripe extends CommonObject // list of payment method types $paymentmethodtypes = array("card"); - if (!empty($conf->global->STRIPE_SEPA_DIRECT_DEBIT) ) $paymentmethodtypes[] = "sepa_debit"; //&& ($object->thirdparty->isInEEC()) - if (!empty($conf->global->STRIPE_IDEAL) ) $paymentmethodtypes[] = "ideal"; //&& ($object->thirdparty->isInEEC()) + if (!empty($conf->global->STRIPE_SEPA_DIRECT_DEBIT)) $paymentmethodtypes[] = "sepa_debit"; //&& ($object->thirdparty->isInEEC()) + if (!empty($conf->global->STRIPE_IDEAL)) $paymentmethodtypes[] = "ideal"; //&& ($object->thirdparty->isInEEC()) $dataforintent = array( "confirm" => $confirmnow, // Do not confirm immediatly during creation of intent diff --git a/htdocs/ticket/card.php b/htdocs/ticket/card.php index 2e2f6f46f73..fcf1013d982 100644 --- a/htdocs/ticket/card.php +++ b/htdocs/ticket/card.php @@ -312,10 +312,10 @@ if (empty($reshook)) { if (!empty($backtopage)) { $url = $backtopage; } else { - $url = 'card.php?track_id=' . $object->track_id; + $url = 'card.php?track_id='.$object->track_id; } - header('Location: ' . $url); + header('Location: '.$url); exit(); } } @@ -657,10 +657,10 @@ if ($action == 'create' || $action == 'presend') $head = ticket_prepare_head($object); - print '
'; - print ''; + print ''; + print ''; print ''; - print ''; + print ''; dol_fiche_head($head, 'card', $langs->trans('Ticket'), 0, 'ticket'); @@ -668,28 +668,28 @@ if ($action == 'create' || $action == 'presend') print ''; // Type - print ''; // Severity - print ''; // Group - print ''; // Subject - print ''; // Other attributes $parameters = array('colspan' => ' colspan="3"', 'colspanvalue' => '3'); - $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; if (empty($reshook)) { print $object->showOptionals($extrafields, 'edit'); @@ -701,9 +701,9 @@ if ($action == 'create' || $action == 'presend') dol_fiche_end(); print '
'; - print ''; + print ''; print '     '; - print ''; + print ''; print '
'; print ''; @@ -1250,7 +1250,7 @@ elseif (empty($action) || $action == 'view' || $action == 'addlink' || $action = } if ($user->rights->ticket->write && $object->fk_statut < Ticket::STATUS_CLOSED) { - print '
' . $langs->trans('Modify') . '
'; + print '
'.$langs->trans('Modify').'
'; } // Close ticket if statut is read
'; + print '
'; $formticket->selectTypesTickets((GETPOST('type_code') ? GETPOST('type_code') : $object->type_code), 'type_code', '', '2'); print '
'; + print '
'; $formticket->selectSeveritiesTickets((GETPOST('severity_code') ? GETPOST('severity_code') : $object->severity_code), 'severity_code', '', '2'); print '
'; + print '
'; $formticket->selectGroupTickets((GETPOST('category_code') ? GETPOST('category_code') : $object->category_code), 'category_code', '', '2'); print '
'; - print ''; + print '
'; + print ''; print '