Merge pull request #14727 from Dolibarr/scrutinizer-patch-16

Scrutinizer Auto-Fixes
This commit is contained in:
Laurent Destailleur 2020-09-14 04:32:59 +02:00 committed by GitHub
commit cde58c6908
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
19 changed files with 471 additions and 471 deletions

View File

@ -385,8 +385,8 @@ foreach ($list_binding as $key)
if ($key == 'ACCOUNTING_DATE_START_BINDING') { if ($key == 'ACCOUNTING_DATE_START_BINDING') {
print $form->selectDate(($conf->global->$key ? $db->idate($conf->global->$key) : -1), $key, 0, 0, 1); print $form->selectDate(($conf->global->$key ? $db->idate($conf->global->$key) : -1), $key, 0, 0, 1);
} elseif ($key == 'ACCOUNTING_DEFAULT_PERIOD_ON_TRANSFER') { } elseif ($key == 'ACCOUNTING_DEFAULT_PERIOD_ON_TRANSFER') {
$array=array(0=>$langs->trans("PreviousMonth"), 1=>$langs->trans("CurrentMonth"), 2=>$langs->trans("Fiscalyear")); $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)); print $form->selectarray($key, $array, (isset($conf->global->ACCOUNTING_DEFAULT_PERIOD_ON_TRANSFER) ? $conf->global->ACCOUNTING_DEFAULT_PERIOD_ON_TRANSFER : 0));
} else { } else {
print '<input type="text" class="maxwidth100" id="'.$key.'" name="'.$key.'" value="'.$conf->global->$key.'">'; print '<input type="text" class="maxwidth100" id="'.$key.'" name="'.$key.'" value="'.$conf->global->$key.'">';
} }

View File

@ -32,13 +32,13 @@ if (!$user->admin) {
// Load translation files required by the page // Load translation files required by the page
$langs->loadLangs(array("install", "other", "admin")); $langs->loadLangs(array("install", "other", "admin"));
$optioncss = GETPOST('optioncss', 'alpha'); $optioncss = GETPOST('optioncss', 'alpha');
$contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'moduleoverview'; $contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'moduleoverview';
$search_name = GETPOST("search_name", 'alpha'); $search_name = GETPOST("search_name", 'alpha');
$search_id = GETPOST("search_id", 'alpha'); $search_id = GETPOST("search_id", 'alpha');
$search_version = GETPOST("search_version", 'alpha'); $search_version = GETPOST("search_version", 'alpha');
$search_permission = GETPOST("search_permission", 'alpha'); $search_permission = GETPOST("search_permission", 'alpha');
$sortfield = GETPOST("sortfield", 'alpha'); $sortfield = GETPOST("sortfield", 'alpha');
$sortorder = GETPOST("sortorder", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha');
@ -126,9 +126,9 @@ foreach ($modulesdir as $dir) {
foreach ($modules as $key=>$module) { foreach ($modules as $key=>$module) {
$newModule = new stdClass(); $newModule = new stdClass();
$newModule->name = $module->getName(); $newModule->name = $module->getName();
$newModule->version = $module->getVersion(); $newModule->version = $module->getVersion();
$newModule->id = $key; $newModule->id = $key;
$alt = $module->name.' - '.$modules_files[$key]; $alt = $module->name.' - '.$modules_files[$key];
@ -298,7 +298,7 @@ foreach ($moduleList as $module) {
$idperms .= ($idperms ? ", " : "").$permission; $idperms .= ($idperms ? ", " : "").$permission;
$translationKey = "Permission".$permission; $translationKey = "Permission".$permission;
if (! empty($conf->global->MAIN_SHOW_PERMISSION)) { if (!empty($conf->global->MAIN_SHOW_PERMISSION)) {
if (empty($langs->tab_translate[$translationKey])) { if (empty($langs->tab_translate[$translationKey])) {
$tooltip = 'Missing translation (key '.$translationkey.' not found in admin.lang)'; $tooltip = 'Missing translation (key '.$translationkey.' not found in admin.lang)';
$idperms .= ' <img src="../../theme/eldy/img/warning.png" alt="Warning" title="'.$tooltip.'">'; $idperms .= ' <img src="../../theme/eldy/img/warning.png" alt="Warning" title="'.$tooltip.'">';

View File

@ -1995,7 +1995,7 @@ class ActionComm extends CommonObject
$formmail = new FormMail($this->db); $formmail = new FormMail($this->db);
$actionCommReminder = new ActionCommReminder($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); $res = $actionCommReminder->fetch($obj->id);
if ($res < 0) { if ($res < 0) {
$error++; $error++;
@ -2055,7 +2055,7 @@ class ActionComm extends CommonObject
{ {
$errorsMsg[] = "Failed to update status of ActionComm Reminder"; $errorsMsg[] = "Failed to update status of ActionComm Reminder";
$error++; $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 { } else {
$nbMailSend++; $nbMailSend++;
} }

View File

@ -475,16 +475,16 @@ class Orders extends DolibarrApi
*/ */
public function getContacts($id, $type = '') public function getContacts($id, $type = '')
{ {
if (! DolibarrApiAccess::$user->rights->commande->lire) { if (!DolibarrApiAccess::$user->rights->commande->lire) {
throw new RestException(401); throw new RestException(401);
} }
$result = $this->commande->fetch($id); $result = $this->commande->fetch($id);
if ( ! $result ) { if (!$result) {
throw new RestException(404, 'Order not found'); 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); 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) public function deleteContact($id, $rowid)
{ {
if (! DolibarrApiAccess::$user->rights->commande->creer) { if (!DolibarrApiAccess::$user->rights->commande->creer) {
throw new RestException(401); throw new RestException(401);
} }
$result = $this->commande->fetch($id); $result = $this->commande->fetch($id);
if (! $result) { if (!$result) {
throw new RestException(404, 'Order not found'); 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); throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
} }

View File

@ -134,18 +134,18 @@ $fieldstosearchall = array(
// Definition of fields for lists // Definition of fields for lists
$arrayfields = array( $arrayfields = array(
'ref' =>array('label'=>"Ref", 'checked'=>1, 'position'=>100), 'ref' =>array('label'=>"Ref", 'checked'=>1, 'position'=>100),
'label' =>array('label'=>"Label", 'checked'=>1, 'position'=>110), 'label' =>array('label'=>"Label", 'checked'=>1, 'position'=>110),
'datep' =>array('label'=>"DatePayment", 'checked'=>1, 'position'=>120), 'datep' =>array('label'=>"DatePayment", 'checked'=>1, 'position'=>120),
'datev' =>array('label'=>"DateValue", 'checked'=>1, 'position'=>130), 'datev' =>array('label'=>"DateValue", 'checked'=>1, 'position'=>130),
'type' =>array('label'=>"PaymentMode", 'checked'=>1, 'position'=>140), 'type' =>array('label'=>"PaymentMode", 'checked'=>1, 'position'=>140),
'project' =>array('label'=>"Project", 'checked'=>1, 'position'=>200, "enabled"=>!empty($conf->projet->enabled)), '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)), '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)), '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)), '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)), 'subledger' =>array('label'=>"SubledgerAccount", 'checked'=>1, 'position'=>410, "enabled"=>!empty($conf->accounting->enabled)),
'debit' =>array('label'=>"Debit", 'checked'=>1, 'position'=>500), 'debit' =>array('label'=>"Debit", 'checked'=>1, 'position'=>500),
'credit' =>array('label'=>"Credit", 'checked'=>1, 'position'=>510), 'credit' =>array('label'=>"Credit", 'checked'=>1, 'position'=>510),
); );
$arrayfields = dol_sort_array($arrayfields, 'position'); $arrayfields = dol_sort_array($arrayfields, 'position');
@ -168,13 +168,13 @@ if (empty($reshook)) {
*/ */
$form = new Form($db); $form = new Form($db);
if ($arrayfields['account']['checked'] || $arrayfields['subledger']['checked']) $formaccounting = new FormAccounting($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['bank']['checked'] && !empty($conf->accounting->enabled)) $accountingjournal = new AccountingJournal($db);
if ($arrayfields['ref']['checked']) $variousstatic = new PaymentVarious($db); if ($arrayfields['ref']['checked']) $variousstatic = new PaymentVarious($db);
if ($arrayfields['bank']['checked']) $accountstatic = new Account($db); if ($arrayfields['bank']['checked']) $accountstatic = new Account($db);
if ($arrayfields['project']['checked']) $proj = new Project($db); if ($arrayfields['project']['checked']) $proj = new Project($db);
if ($arrayfields['entry']['checked']) $bankline = new AccountLine($db); if ($arrayfields['entry']['checked']) $bankline = new AccountLine($db);
if ($arrayfields['account']['checked']) $accountingaccount = new AccountingAccount($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 = "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,"; $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,";

View File

@ -28,96 +28,96 @@ require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
*/ */
class Invoices extends DolibarrApi class Invoices extends DolibarrApi
{ {
/** /**
* *
* @var array $FIELDS Mandatory fields, checked when create and update object * @var array $FIELDS Mandatory fields, checked when create and update object
*/ */
static $FIELDS = array( static $FIELDS = array(
'socid', 'socid',
); );
/** /**
* @var Facture $invoice {@type Facture} * @var Facture $invoice {@type Facture}
*/ */
public $invoice; public $invoice;
/** /**
* Constructor * Constructor
*/ */
public function __construct() 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)
{ {
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 * Get properties of a invoice object
* *
* Return an array with invoice informations * Return an array with invoice informations
* *
* @param string $ref Ref of object * @param int $id ID of invoice
* @param int $contact_list 0: Returned array of contacts/addresses contains all properties, 1: Return array contains just id * @param int $contact_list 0:Return array contains all properties, 1:Return array contains just id
* @return array|mixed data without useless information * @return array|mixed data without useless information
* *
* @url GET ref/{ref} * @throws RestException
* */
* @throws RestException public function get($id, $contact_list = 1)
*/ {
public function getByRef($ref, $contact_list = 1) return $this->_fetch($id, '', '', $contact_list);
{ }
return $this->_fetch('', $ref, '', $contact_list);
}
/** /**
* Get properties of an invoice object by ref_ext * Get properties of an invoice object by ref
* *
* Return an array with invoice informations * Return an array with invoice informations
* *
* @param string $ref_ext External reference of object * @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 * @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 * @return array|mixed data without useless information
* *
* @url GET ref_ext/{ref_ext} * @url GET ref/{ref}
* *
* @throws RestException * @throws RestException
*/ */
public function getByRefExt($ref_ext, $contact_list = 1) public function getByRef($ref, $contact_list = 1)
{ {
return $this->_fetch('', '', $ref_ext, $contact_list); return $this->_fetch('', $ref, '', $contact_list);
} }
/** /**
* Get properties of an invoice object * Get properties of an invoice object by ref_ext
* *
* Return an array with invoice informations * Return an array with invoice informations
* *
* @param int $id ID of order * @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 Ref of object
* @param string $ref_ext External reference 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 * @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 * @return array|mixed data without useless information
* *
* @throws RestException * @throws RestException
*/ */
private function _fetch($id, $ref = '', $ref_ext = '', $contact_list = 1) private function _fetch($id, $ref = '', $ref_ext = '', $contact_list = 1)
{ {
if (!DolibarrApiAccess::$user->rights->facture->lire) { if (!DolibarrApiAccess::$user->rights->facture->lire) {
throw new RestException(401); throw new RestException(401);
} }
@ -142,138 +142,138 @@ class Invoices extends DolibarrApi
$this->invoice->fetchObjectLinked(); $this->invoice->fetchObjectLinked();
return $this->_cleanObjectDatas($this->invoice); return $this->_cleanObjectDatas($this->invoice);
} }
/** /**
* List invoices * List invoices
* *
* Get a list of invoices * Get a list of invoices
* *
* @param string $sortfield Sort field * @param string $sortfield Sort field
* @param string $sortorder Sort order * @param string $sortorder Sort order
* @param int $limit Limit for list * @param int $limit Limit for list
* @param int $page Page number * @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 $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 $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')" * @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 * @return array Array of invoice objects
* *
* @throws RestException 404 Not found * @throws RestException 404 Not found
* @throws RestException 503 Error * @throws RestException 503 Error
*/ */
public function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $thirdparty_ids = '', $status = '', $sqlfilters = '') public function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $thirdparty_ids = '', $status = '', $sqlfilters = '')
{ {
global $db, $conf; global $db, $conf;
$obj_ret = array(); $obj_ret = array();
// case of external user, $thirdparty_ids param is ignored and replaced by user's socid // case of external user, $thirdparty_ids param is ignored and replaced by user's socid
$socids = DolibarrApiAccess::$user->socid ? DolibarrApiAccess::$user->socid : $thirdparty_ids; $socids = DolibarrApiAccess::$user->socid ? DolibarrApiAccess::$user->socid : $thirdparty_ids;
// If the internal user must only see his customers, force searching by him // If the internal user must only see his customers, force searching by him
$search_sale = 0; $search_sale = 0;
if (!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) $search_sale = DolibarrApiAccess::$user->id; if (!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) $search_sale = DolibarrApiAccess::$user->id;
$sql = "SELECT t.rowid"; $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) 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 .= " 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').')'; $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 ((!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 ($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 // Filter by status
if ($status == 'draft') $sql .= " AND t.fk_statut IN (0)"; if ($status == 'draft') $sql .= " AND t.fk_statut IN (0)";
if ($status == 'unpaid') $sql .= " AND t.fk_statut IN (1)"; if ($status == 'unpaid') $sql .= " AND t.fk_statut IN (1)";
if ($status == 'paid') $sql .= " AND t.fk_statut IN (2)"; if ($status == 'paid') $sql .= " AND t.fk_statut IN (2)";
if ($status == 'cancelled') $sql .= " AND t.fk_statut IN (3)"; if ($status == 'cancelled') $sql .= " AND t.fk_statut IN (3)";
// Insert sale filter // Insert sale filter
if ($search_sale > 0) if ($search_sale > 0)
{ {
$sql .= " AND sc.fk_user = ".$search_sale; $sql .= " AND sc.fk_user = ".$search_sale;
} }
// Add sql filters // Add sql filters
if ($sqlfilters) if ($sqlfilters)
{ {
if (!DolibarrApi::_checkFilters($sqlfilters)) if (!DolibarrApi::_checkFilters($sqlfilters))
{ {
throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters);
} }
$regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
$sql .= " AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; $sql .= " AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")";
} }
$sql .= $db->order($sortfield, $sortorder); $sql .= $db->order($sortfield, $sortorder);
if ($limit) if ($limit)
{ {
if ($page < 0) if ($page < 0)
{ {
$page = 0; $page = 0;
} }
$offset = $limit * $page; $offset = $limit * $page;
$sql .= $db->plimit($limit + 1, $offset); $sql .= $db->plimit($limit + 1, $offset);
} }
$result = $db->query($sql); $result = $db->query($sql);
if ($result) if ($result)
{ {
$i = 0; $i = 0;
$num = $db->num_rows($result); $num = $db->num_rows($result);
$min = min($num, ($limit <= 0 ? $num : $limit)); $min = min($num, ($limit <= 0 ? $num : $limit));
while ($i < $min) while ($i < $min)
{ {
$obj = $db->fetch_object($result); $obj = $db->fetch_object($result);
$invoice_static = new Facture($db); $invoice_static = new Facture($db);
if ($invoice_static->fetch($obj->rowid)) if ($invoice_static->fetch($obj->rowid))
{ {
// Get payment details // Get payment details
$invoice_static->totalpaid = $invoice_static->getSommePaiement(); $invoice_static->totalpaid = $invoice_static->getSommePaiement();
$invoice_static->totalcreditnotes = $invoice_static->getSumCreditNotesUsed(); $invoice_static->totalcreditnotes = $invoice_static->getSumCreditNotesUsed();
$invoice_static->totaldeposits = $invoice_static->getSumDepositsUsed(); $invoice_static->totaldeposits = $invoice_static->getSumDepositsUsed();
$invoice_static->remaintopay = price2num($invoice_static->total_ttc - $invoice_static->totalpaid - $invoice_static->totalcreditnotes - $invoice_static->totaldeposits, 'MT'); $invoice_static->remaintopay = price2num($invoice_static->total_ttc - $invoice_static->totalpaid - $invoice_static->totalcreditnotes - $invoice_static->totaldeposits, 'MT');
// Add external contacts ids // Add external contacts ids
$invoice_static->contacts_ids = $invoice_static->liste_contact(-1, 'external', 1); $invoice_static->contacts_ids = $invoice_static->liste_contact(-1, 'external', 1);
$obj_ret[] = $this->_cleanObjectDatas($invoice_static); $obj_ret[] = $this->_cleanObjectDatas($invoice_static);
} }
$i++; $i++;
} }
} else { } else {
throw new RestException(503, 'Error when retrieve invoice list : '.$db->lasterror()); throw new RestException(503, 'Error when retrieve invoice list : '.$db->lasterror());
} }
if (!count($obj_ret)) { if (!count($obj_ret)) {
throw new RestException(404, 'No invoice found'); throw new RestException(404, 'No invoice found');
} }
return $obj_ret; return $obj_ret;
} }
/** /**
* Create invoice object * Create invoice object
* *
* @param array $request_data Request datas * @param array $request_data Request datas
* @return int ID of invoice * @return int ID of invoice
*/ */
public function post($request_data = null) public function post($request_data = null)
{ {
if (!DolibarrApiAccess::$user->rights->facture->creer) { if (!DolibarrApiAccess::$user->rights->facture->creer) {
throw new RestException(401, "Insuffisant rights"); throw new RestException(401, "Insuffisant rights");
} }
// Check mandatory fields // Check mandatory fields
$result = $this->_validate($request_data); $result = $this->_validate($request_data);
foreach ($request_data as $field => $value) { foreach ($request_data as $field => $value) {
$this->invoice->$field = $value; $this->invoice->$field = $value;
} }
if (!array_key_exists('date', $request_data)) { if (!array_key_exists('date', $request_data)) {
$this->invoice->date = dol_now(); $this->invoice->date = dol_now();
} }
/* We keep lines as an array /* We keep lines as an array
if (isset($request_data["lines"])) { if (isset($request_data["lines"])) {
$lines = array(); $lines = array();
foreach ($request_data["lines"] as $line) { foreach ($request_data["lines"] as $line) {
@ -282,154 +282,154 @@ class Invoices extends DolibarrApi
$this->invoice->lines = $lines; $this->invoice->lines = $lines;
}*/ }*/
if ($this->invoice->create(DolibarrApiAccess::$user, 0, (empty($request_data["date_lim_reglement"]) ? 0 : $request_data["date_lim_reglement"])) < 0) { 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)); throw new RestException(500, "Error creating invoice", array_merge(array($this->invoice->error), $this->invoice->errors));
} }
return $this->invoice->id; return $this->invoice->id;
} }
/** /**
* Create an invoice using an existing order. * Create an invoice using an existing order.
* *
* *
* @param int $orderid Id of the order * @param int $orderid Id of the order
* *
* @url POST /createfromorder/{orderid} * @url POST /createfromorder/{orderid}
* *
* @return int * @return int
* @throws RestException 400 * @throws RestException 400
* @throws RestException 401 * @throws RestException 401
* @throws RestException 404 * @throws RestException 404
* @throws RestException 405 * @throws RestException 405
*/ */
public function createInvoiceFromOrder($orderid) 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) { if (!DolibarrApiAccess::$user->rights->commande->lire) {
throw new RestException(401); throw new RestException(401);
} }
if (!DolibarrApiAccess::$user->rights->facture->creer) { if (!DolibarrApiAccess::$user->rights->facture->creer) {
throw new RestException(401); throw new RestException(401);
} }
if (empty($orderid)) { if (empty($orderid)) {
throw new RestException(400, 'Order ID is mandatory'); throw new RestException(400, 'Order ID is mandatory');
} }
$order = new Commande($this->db); $order = new Commande($this->db);
$result = $order->fetch($orderid); $result = $order->fetch($orderid);
if (!$result) { if (!$result) {
throw new RestException(404, 'Order not found'); throw new RestException(404, 'Order not found');
} }
$result = $this->invoice->createFromOrder($order, DolibarrApiAccess::$user); $result = $this->invoice->createFromOrder($order, DolibarrApiAccess::$user);
if ($result < 0) { if ($result < 0) {
throw new RestException(405, $this->invoice->error); throw new RestException(405, $this->invoice->error);
} }
$this->invoice->fetchObjectLinked(); $this->invoice->fetchObjectLinked();
return $this->_cleanObjectDatas($this->invoice); return $this->_cleanObjectDatas($this->invoice);
} }
/** /**
* Get lines of an invoice * Get lines of an invoice
* *
* @param int $id Id of invoice * @param int $id Id of invoice
* *
* @url GET {id}/lines * @url GET {id}/lines
* *
* @return int * @return int
*/ */
public function getLines($id) public function getLines($id)
{ {
if (!DolibarrApiAccess::$user->rights->facture->lire) { if (!DolibarrApiAccess::$user->rights->facture->lire) {
throw new RestException(401); throw new RestException(401);
} }
$result = $this->invoice->fetch($id); $result = $this->invoice->fetch($id);
if (!$result) { if (!$result) {
throw new RestException(404, 'Invoice not found'); throw new RestException(404, 'Invoice not found');
} }
if (!DolibarrApi::_checkAccessToResource('facture', $this->invoice->id)) { if (!DolibarrApi::_checkAccessToResource('facture', $this->invoice->id)) {
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
} }
$this->invoice->getLinesArray(); $this->invoice->getLinesArray();
$result = array(); $result = array();
foreach ($this->invoice->lines as $line) { foreach ($this->invoice->lines as $line) {
array_push($result, $this->_cleanObjectDatas($line)); array_push($result, $this->_cleanObjectDatas($line));
} }
return $result; return $result;
} }
/** /**
* Update a line to a given invoice * Update a line to a given invoice
* *
* @param int $id Id of invoice to update * @param int $id Id of invoice to update
* @param int $lineid Id of line to update * @param int $lineid Id of line to update
* @param array $request_data InvoiceLine data * @param array $request_data InvoiceLine data
* *
* @url PUT {id}/lines/{lineid} * @url PUT {id}/lines/{lineid}
* *
* @return array * @return array
* *
* @throws RestException 304 * @throws RestException 304
* @throws RestException 401 * @throws RestException 401
* @throws RestException 404 Invoice not found * @throws RestException 404 Invoice not found
*/ */
public function putLine($id, $lineid, $request_data = null) public function putLine($id, $lineid, $request_data = null)
{ {
if (!DolibarrApiAccess::$user->rights->facture->creer) { if (!DolibarrApiAccess::$user->rights->facture->creer) {
throw new RestException(401); throw new RestException(401);
} }
$result = $this->invoice->fetch($id); $result = $this->invoice->fetch($id);
if (!$result) { if (!$result) {
throw new RestException(404, 'Invoice not found'); throw new RestException(404, 'Invoice not found');
} }
if (!DolibarrApi::_checkAccessToResource('facture', $this->invoice->id)) { if (!DolibarrApi::_checkAccessToResource('facture', $this->invoice->id)) {
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
} }
$request_data = (object) $request_data; $request_data = (object) $request_data;
$updateRes = $this->invoice->updateline( $updateRes = $this->invoice->updateline(
$lineid, $lineid,
$request_data->desc, $request_data->desc,
$request_data->subprice, $request_data->subprice,
$request_data->qty, $request_data->qty,
$request_data->remise_percent, $request_data->remise_percent,
$request_data->date_start, $request_data->date_start,
$request_data->date_end, $request_data->date_end,
$request_data->tva_tx, $request_data->tva_tx,
$request_data->localtax1_tx, $request_data->localtax1_tx,
$request_data->localtax2_tx, $request_data->localtax2_tx,
'HT', 'HT',
$request_data->info_bits, $request_data->info_bits,
$request_data->product_type, $request_data->product_type,
$request_data->fk_parent_line, $request_data->fk_parent_line,
0, 0,
$request_data->fk_fournprice, $request_data->fk_fournprice,
$request_data->pa_ht, $request_data->pa_ht,
$request_data->label, $request_data->label,
$request_data->special_code, $request_data->special_code,
$request_data->array_options, $request_data->array_options,
$request_data->situation_percent, $request_data->situation_percent,
$request_data->fk_unit, $request_data->fk_unit,
$request_data->multicurrency_subprice, $request_data->multicurrency_subprice,
0, 0,
$request_data->ref_ext $request_data->ref_ext
); );
if ($updateRes > 0) { if ($updateRes > 0) {
$result = $this->get($id); $result = $this->get($id);
unset($result->line); unset($result->line);
return $this->_cleanObjectDatas($result); return $this->_cleanObjectDatas($result);
} else { } else {
throw new RestException(304, $this->invoice->error); throw new RestException(304, $this->invoice->error);
} }
} }
/** /**
* Add a contact type of given invoice * Add a contact type of given invoice
* *
* @param int $id Id of invoice to update * @param int $id Id of invoice to update
@ -440,39 +440,39 @@ class Invoices extends DolibarrApi
* *
* @return int * @return int
* *
* @throws RestException 401 * @throws RestException 401
* @throws RestException 404 * @throws RestException 404
*/ */
public function postContact($id, $contactid, $type) public function postContact($id, $contactid, $type)
{ {
if (!DolibarrApiAccess::$user->rights->facture->creer) { if (!DolibarrApiAccess::$user->rights->facture->creer) {
throw new RestException(401); throw new RestException(401);
} }
$result = $this->invoice->fetch($id); $result = $this->invoice->fetch($id);
if (!$result) { if (!$result) {
throw new RestException(404, 'Invoice not found'); throw new RestException(404, 'Invoice not found');
} }
if (!in_array($type, array('BILLING', 'SHIPPING', 'CUSTOMER'), true)) { if (!in_array($type, array('BILLING', 'SHIPPING', 'CUSTOMER'), true)) {
throw new RestException(500, 'Availables types: BILLING, SHIPPING OR CUSTOMER'); 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); 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) { if (!$result) {
throw new RestException(500, 'Error when added the contact'); 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 * Delete a contact type of given invoice
* *
* @param int $id Id of invoice to update * @param int $id Id of invoice to update

View File

@ -5160,15 +5160,15 @@ class FactureLigne extends CommonInvoiceLine
$this->db->begin(); $this->db->begin();
// Update line in database // Update line in database
$sql = "UPDATE ".MAIN_DB_PREFIX."facturedet SET"; $sql = "UPDATE ".MAIN_DB_PREFIX."facturedet SET";
$sql .= " description='".$this->db->escape($this->desc)."'"; $sql .= " description='".$this->db->escape($this->desc)."'";
$sql .= ", ref_ext='".$this->db->escape($this->ref_ext)."'"; $sql .= ", ref_ext='".$this->db->escape($this->ref_ext)."'";
$sql .= ", label=".(!empty($this->label) ? "'".$this->db->escape($this->label)."'" : "null"); $sql .= ", label=".(!empty($this->label) ? "'".$this->db->escape($this->label)."'" : "null");
$sql .= ", subprice=".price2num($this->subprice).""; $sql .= ", subprice=".price2num($this->subprice)."";
$sql .= ", remise_percent=".price2num($this->remise_percent).""; $sql .= ", remise_percent=".price2num($this->remise_percent)."";
if ($this->fk_remise_except) $sql .= ", fk_remise_except=".$this->fk_remise_except; if ($this->fk_remise_except) $sql .= ", fk_remise_except=".$this->fk_remise_except;
else $sql .= ", fk_remise_except=null"; else $sql .= ", fk_remise_except=null";
$sql .= ", vat_src_code = '".(empty($this->vat_src_code) ? '' : $this->db->escape($this->vat_src_code))."'"; $sql .= ", vat_src_code = '".(empty($this->vat_src_code) ? '' : $this->db->escape($this->vat_src_code))."'";
$sql .= ", tva_tx=".price2num($this->tva_tx).""; $sql .= ", tva_tx=".price2num($this->tva_tx)."";
$sql .= ", localtax1_tx=".price2num($this->localtax1_tx).""; $sql .= ", localtax1_tx=".price2num($this->localtax1_tx)."";

View File

@ -1231,7 +1231,7 @@ class ExtraFields
} else { } else {
if (!$notrans) { if (!$notrans) {
$translabel = $langs->trans($obj->{$InfoFieldList[1]}); $translabel = $langs->trans($obj->{$InfoFieldList[1]});
$labeltoshow =$translabel; $labeltoshow = $translabel;
} }
if (empty($labeltoshow)) $labeltoshow = '(not defined)'; if (empty($labeltoshow)) $labeltoshow = '(not defined)';

View File

@ -7993,18 +7993,18 @@ class Form
include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php'; include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php';
$formmail = new FormMail($db); $formmail = new FormMail($db);
$result = $formmail->fetchAllEMailTemplate($modelType, $user, $langs); $result = $formmail->fetchAllEMailTemplate($modelType, $user, $langs);
if ($default) $TModels[0] = $langs->trans('DefaultMailModel'); if ($default) $TModels[0] = $langs->trans('DefaultMailModel');
if ($result > 0) { if ($result > 0) {
foreach ($formmail->lines_model as $model){ foreach ($formmail->lines_model as $model) {
$TModels[$model->id] = $model->label; $TModels[$model->id] = $model->label;
} }
} }
$retstring .= '<select class="flat" id="select_'.$prefix.'model_mail" name="'.$prefix.'model_mail">'; $retstring .= '<select class="flat" id="select_'.$prefix.'model_mail" name="'.$prefix.'model_mail">';
foreach ($TModels as $id_model=>$label_model){ foreach ($TModels as $id_model=>$label_model) {
$retstring .= '<option value="'.$id_model.'"'; $retstring .= '<option value="'.$id_model.'"';
$retstring .= ">".$label_model."</option>"; $retstring .= ">".$label_model."</option>";
} }

View File

@ -920,7 +920,7 @@ class FormTicket
// Subject // Subject
print '<tr class="email_line"><td class="titlefieldcreate">'.$langs->trans('Subject').'</td>'; print '<tr class="email_line"><td class="titlefieldcreate">'.$langs->trans('Subject').'</td>';
print '<td><input type="text" class="text minwidth500" name="subject" value="[' . $conf->global->MAIN_INFO_SOCIETE_NOM . ' - ' . $langs->trans("Ticket") . ' ' . $this->ref . '] '.$langs->trans('TicketNewMessage').'" />'; print '<td><input type="text" class="text minwidth500" name="subject" value="['.$conf->global->MAIN_INFO_SOCIETE_NOM.' - '.$langs->trans("Ticket").' '.$this->ref.'] '.$langs->trans('TicketNewMessage').'" />';
print '</td></tr>'; print '</td></tr>';
// Destinataires // Destinataires
@ -987,7 +987,7 @@ class FormTicket
} }
// MESSAGE // MESSAGE
$defaultmessage=""; $defaultmessage = "";
if (is_object($arraydefaultmessage) && $arraydefaultmessage->content) { if (is_object($arraydefaultmessage) && $arraydefaultmessage->content) {
$defaultmessage = $arraydefaultmessage->content; $defaultmessage = $arraydefaultmessage->content;
} }

View File

@ -709,7 +709,7 @@ class Menubase
$tabMenu[$b]['mainmenu'] = $menu['mainmenu']; $tabMenu[$b]['mainmenu'] = $menu['mainmenu'];
$tabMenu[$b]['leftmenu'] = $menu['leftmenu']; $tabMenu[$b]['leftmenu'] = $menu['leftmenu'];
$tabMenu[$b]['perms'] = $perms; $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]['enabled'] = $enabled;
$tabMenu[$b]['type'] = $menu['type']; $tabMenu[$b]['type'] = $menu['type'];
$tabMenu[$b]['fk_mainmenu'] = $menu['fk_mainmenu']; $tabMenu[$b]['fk_mainmenu'] = $menu['fk_mainmenu'];

View File

@ -6187,15 +6187,15 @@ function getCommonSubstitutionArray($outputlangs, $onlykey = 0, $exclude = null,
foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $label) { foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $label) {
$substitutionarray['__EXTRAFIELD_'.strtoupper($key).'__'] = $object->array_options['options_'.$key]; $substitutionarray['__EXTRAFIELD_'.strtoupper($key).'__'] = $object->array_options['options_'.$key];
if ($extrafields->attributes[$object->table_element]['type'][$key] == 'date') { 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).'__'] = 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).'_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).'_RFC__'] = dol_print_date($object->array_options['options_'.$key], 'dayrfc');
} elseif ($extrafields->attributes[$object->table_element]['type'][$key] == 'datetime') { } elseif ($extrafields->attributes[$object->table_element]['type'][$key] == 'datetime') {
$datetime = $object->array_options['options_'.$key]; $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).'__'] = ($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).'_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).'_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).'_RFC__'] = ($datetime != "0000-00-00 00:00:00" ? dol_print_date($datetime, 'dayhourrfc') : '');
} }
} }
} }

View File

@ -42,12 +42,12 @@ class pdf_standard extends CommonStickerGenerator
* @param array $param Associative array containing label content and optional parameters * @param array $param Associative array containing label content and optional parameters
* @return void * @return void
*/ */
public function addSticker(&$pdf, $outputlangs, $param) public function addSticker(&$pdf, $outputlangs, $param)
{ {
// use this method in future refactoring // 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) * Output a sticker on page at position _COUNTX, _COUNTY (_COUNTX and _COUNTY start from 0)
* - __LOGO__ is replace with company logo * - __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 = '') public function Add_PDF_card(&$pdf, $textleft, $header, $footer, $outputlangs, $textright = '', $idmember = 0, $photo = '')
{ {
// phpcs:enable // phpcs:enable
global $db, $mysoc, $conf, $langs; global $db, $mysoc, $conf, $langs;
global $forceimgscalewidth, $forceimgscaleheight; 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. * 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]; $this->Tformat = $_Avery_Labels[$this->code];
if (empty($this->Tformat)) { dol_print_error('', 'ErrorBadTypeForCard'.$this->code); exit; } if (empty($this->Tformat)) { dol_print_error('', 'ErrorBadTypeForCard'.$this->code); exit; }
$this->type = 'pdf'; $this->type = 'pdf';
// standard format or custom // standard format or custom
if ($this->Tformat['paper-size'] != 'custom') { if ($this->Tformat['paper-size'] != 'custom') {
$this->format = $this->Tformat['paper-size']; $this->format = $this->Tformat['paper-size'];
} else { } else {
//custom //custom
$resolution = array($this->Tformat['custom_x'], $this->Tformat['custom_y']); $resolution = array($this->Tformat['custom_x'], $this->Tformat['custom_y']);
$this->format = $resolution; $this->format = $resolution;
} }
if (!is_object($outputlangs)) $outputlangs = $langs; 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 // 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'; $filename = 'tmp_cards.pdf';
if (is_object($object)) if (is_object($object))
{ {
$outputdir = $conf->adherent->dir_output; $outputdir = $conf->adherent->dir_output;
$dir = $outputdir."/".get_exdir(0, 0, 0, 0, $object, 'member'); $dir = $outputdir."/".get_exdir(0, 0, 0, 0, $object, 'member');
$file = $dir.'/'.$filename; $file = $dir.'/'.$filename;
} else { } else {
$outputdir = $conf->adherent->dir_temp; $outputdir = $conf->adherent->dir_temp;
$dir = $outputdir; $dir = $outputdir;
$file = $dir.'/'.$filename; $file = $dir.'/'.$filename;
} }
//var_dump($file);exit; //var_dump($file);exit;
@ -416,22 +416,22 @@ class pdf_standard extends CommonStickerGenerator
// Output to http stream // Output to http stream
if (empty($nooutput)) if (empty($nooutput))
{ {
clearstatcache(); clearstatcache();
$attachment = true; $attachment = true;
if (!empty($conf->global->MAIN_DISABLE_FORCE_SAVEAS)) $attachment = false; if (!empty($conf->global->MAIN_DISABLE_FORCE_SAVEAS)) $attachment = false;
$type = dol_mimetype($filename); $type = dol_mimetype($filename);
//if ($encoding) header('Content-Encoding: '.$encoding); //if ($encoding) header('Content-Encoding: '.$encoding);
if ($type) header('Content-Type: '.$type); if ($type) header('Content-Type: '.$type);
if ($attachment) header('Content-Disposition: attachment; filename="'.$filename.'"'); if ($attachment) header('Content-Disposition: attachment; filename="'.$filename.'"');
else header('Content-Disposition: inline; filename="'.$filename.'"'); else header('Content-Disposition: inline; filename="'.$filename.'"');
// Ajout directives pour resoudre bug IE // Ajout directives pour resoudre bug IE
header('Cache-Control: Public, must-revalidate'); header('Cache-Control: Public, must-revalidate');
header('Pragma: public'); header('Pragma: public');
readfile($file); readfile($file);
} }
return 1; return 1;

View File

@ -791,16 +791,16 @@ class InterfaceActionsAuto extends DolibarrTriggers
$object->actionmsg2 = $langs->transnoentities($action."InDolibarr", ($object->newref ? $object->newref : $object->ref)); $object->actionmsg2 = $langs->transnoentities($action."InDolibarr", ($object->newref ? $object->newref : $object->ref));
} else { // generic translation key } else { // generic translation key
$tmp = explode('_', $action); $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")); $langs->loadLangs(array("agenda", "other"));
if ($langs->transnoentities($action."InDolibarr", ($object->newref ? $object->newref : $object->ref)) != $action."InDolibarr") { // specific translation key 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)); $object->actionmsg = $langs->transnoentities($action."InDolibarr", ($object->newref ? $object->newref : $object->ref));
} else { // generic translation key } else { // generic translation key
$tmp = explode('_', $action); $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; $projectid = isset($object->fk_project) ? $object->fk_project : 0;
if ($object->element == 'project') $projectid = $object->id; if ($object->element == 'project') $projectid = $object->id;
$elementid = $object->id; // id of object $elementid = $object->id; // id of object
$elementtype = $object->element; $elementtype = $object->element;
$elementmodule = $object->module; $elementmodule = $object->module;
if ($object->element == 'subscription') if ($object->element == 'subscription')

View File

@ -299,8 +299,8 @@ class EmailCollector extends CommonObject
// Load source object // Load source object
$object->fetchCommon($fromid); $object->fetchCommon($fromid);
$object->fetchFilters(); // Rules $object->fetchFilters(); // Rules
$object->fetchActions(); // Operations $object->fetchActions(); // Operations
// Reset some properties // Reset some properties
unset($object->id); unset($object->id);
@ -979,7 +979,7 @@ class EmailCollector extends CommonObject
{ {
if (empty($rule['status'])) continue; if (empty($rule['status'])) continue;
if ($rule['type'] == 'to') { if ($rule['type'] == 'to') {
$tmprulevaluearray = explode('*', $rule['rulevalue']); $tmprulevaluearray = explode('*', $rule['rulevalue']);
if (count($tmprulevaluearray) >= 2) { if (count($tmprulevaluearray) >= 2) {
foreach ($tmprulevaluearray as $tmprulevalue) { foreach ($tmprulevaluearray as $tmprulevalue) {
@ -1163,7 +1163,7 @@ class EmailCollector extends CommonObject
if (!empty($headers['References']) && preg_match('/@'.preg_quote($host, '/').'/', $headers['References'])) if (!empty($headers['References']) && preg_match('/@'.preg_quote($host, '/').'/', $headers['References']))
{ {
$nbemailprocessed++; $nbemailprocessed++;
continue; // Exclude email continue; // Exclude email
} }
} }
@ -1171,7 +1171,7 @@ class EmailCollector extends CommonObject
if (empty($headers['In-Reply-To'])) if (empty($headers['In-Reply-To']))
{ {
$nbemailprocessed++; $nbemailprocessed++;
continue; // Exclude email continue; // Exclude email
} }
// Note: we can have // Note: we can have
// Message-ID=A, In-Reply-To=B, References=B and message can BE an answer or NOT (a transfer rewriten) // 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) { if (!$isanswer) {
$nbemailprocessed++; $nbemailprocessed++;
continue; // Exclude email continue; // Exclude email
} }
} }
if ($searchfilterisnotanswer > 0) { 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 ($headers['In-Reply-To'] != $headers['Message-ID'] && !empty($headers['References']) && strpos($headers['References'], $headers['Message-ID']) !== false) $isanswer = 1;
if ($isanswer) { if ($isanswer) {
$nbemailprocessed++; $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'))) if (!in_array($fk_element_type, array('societe', 'contact', 'project', 'user')))
{ {
$actioncomm->fk_element = $fk_element_id; $actioncomm->fk_element = $fk_element_id;
$actioncomm->elementid = $fk_element_id; $actioncomm->elementid = $fk_element_id;
$actioncomm->elementtype = $fk_element_type; $actioncomm->elementtype = $fk_element_type;
if (is_object($objectemail) && $objectemail->module) { if (is_object($objectemail) && $objectemail->module) {
$actioncomm->elementtype .= '@'.$objectemail->module; $actioncomm->elementtype .= '@'.$objectemail->module;

View File

@ -454,7 +454,7 @@ class SupplierInvoices extends DolibarrApi
$paiement->multicurrency_amounts = $multicurrency_amounts; // Array with all payments dispatching $paiement->multicurrency_amounts = $multicurrency_amounts; // Array with all payments dispatching
$paiement->paiementid = $payment_mode_id; $paiement->paiementid = $payment_mode_id;
$paiement->paiementcode = dol_getIdFromCode($this->db, $payment_mode_id, 'c_paiement', 'id', 'code', 1); $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->num_payment = $num_payment;
$paiement->note_public = $comment; $paiement->note_public = $comment;

View File

@ -696,13 +696,13 @@ class FactureFournisseur extends CommonInvoice
$this->author = $obj->fk_user_author; $this->author = $obj->fk_user_author;
$this->fk_user_valid = $obj->fk_user_valid; $this->fk_user_valid = $obj->fk_user_valid;
$this->fk_facture_source = $obj->fk_facture_source; $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_id = $obj->fk_cond_reglement;
$this->cond_reglement_code = $obj->cond_reglement_code; $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->cond_reglement_doc = $obj->cond_reglement_libelle;
$this->fk_account = $obj->fk_account; $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_code = $obj->mode_reglement_code;
$this->mode_reglement = $obj->mode_reglement_libelle; $this->mode_reglement = $obj->mode_reglement_libelle;
$this->date_echeance = $this->db->jdate($obj->date_lim_reglement); $this->date_echeance = $this->db->jdate($obj->date_lim_reglement);

View File

@ -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) // 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 = "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 .= " FROM ".MAIN_DB_PREFIX."prelevement_facture_demande as pi";
$sql.= " WHERE pi.fk_facture = " . $object->id; $sql .= " WHERE pi.fk_facture = ".$object->id;
$sql.= " AND pi.sourcetype = '" . $object->element . "'"; $sql .= " AND pi.sourcetype = '".$object->element."'";
$sql.= " AND pi.entity IN (".getEntity('societe').")"; $sql .= " AND pi.entity IN (".getEntity('societe').")";
$sql.= " AND pi.ext_payment_site = '" . $service . "'"; $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); $resql = $this->db->query($sql);
if ($resql) { if ($resql) {
$num = $this->db->num_rows($resql); $num = $this->db->num_rows($resql);
@ -369,7 +369,7 @@ class Stripe extends CommonObject
$obj = $this->db->fetch_object($resql); $obj = $this->db->fetch_object($resql);
$intent = $obj->ext_payment_id; $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 // Force to use the correct API key
global $stripearrayofkeysbyenv; global $stripearrayofkeysbyenv;
@ -403,8 +403,8 @@ class Stripe extends CommonObject
// list of payment method types // list of payment method types
$paymentmethodtypes = array("card"); $paymentmethodtypes = array("card");
if (!empty($conf->global->STRIPE_SEPA_DIRECT_DEBIT) ) $paymentmethodtypes[] = "sepa_debit"; //&& ($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()) if (!empty($conf->global->STRIPE_IDEAL)) $paymentmethodtypes[] = "ideal"; //&& ($object->thirdparty->isInEEC())
$dataforintent = array( $dataforintent = array(
"confirm" => $confirmnow, // Do not confirm immediatly during creation of intent "confirm" => $confirmnow, // Do not confirm immediatly during creation of intent

View File

@ -312,10 +312,10 @@ if (empty($reshook)) {
if (!empty($backtopage)) { if (!empty($backtopage)) {
$url = $backtopage; $url = $backtopage;
} else { } else {
$url = 'card.php?track_id=' . $object->track_id; $url = 'card.php?track_id='.$object->track_id;
} }
header('Location: ' . $url); header('Location: '.$url);
exit(); exit();
} }
} }
@ -657,10 +657,10 @@ if ($action == 'create' || $action == 'presend')
$head = ticket_prepare_head($object); $head = ticket_prepare_head($object);
print '<form method="POST" name="form_ticket" id="form_edit_ticket" action="' . $_SERVER['PHP_SELF'] . '?track_id=' . $object->track_id . '">'; print '<form method="POST" name="form_ticket" id="form_edit_ticket" action="'.$_SERVER['PHP_SELF'].'?track_id='.$object->track_id.'">';
print '<input type="hidden" name="token" value="' . newToken() . '">'; print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="action" value="update">'; print '<input type="hidden" name="action" value="update">';
print '<input type="hidden" name="tack_id" value="' . $object->track_id . '">'; print '<input type="hidden" name="tack_id" value="'.$object->track_id.'">';
dol_fiche_head($head, 'card', $langs->trans('Ticket'), 0, 'ticket'); dol_fiche_head($head, 'card', $langs->trans('Ticket'), 0, 'ticket');
@ -668,28 +668,28 @@ if ($action == 'create' || $action == 'presend')
print '<table class="border" width="100%">'; print '<table class="border" width="100%">';
// Type // Type
print '<tr><td class="titlefield"><span class="fieldrequired"><label for="selecttype_code">' . $langs->trans("TicketTypeRequest") . '</span></label></td><td>'; print '<tr><td class="titlefield"><span class="fieldrequired"><label for="selecttype_code">'.$langs->trans("TicketTypeRequest").'</span></label></td><td>';
$formticket->selectTypesTickets((GETPOST('type_code') ? GETPOST('type_code') : $object->type_code), 'type_code', '', '2'); $formticket->selectTypesTickets((GETPOST('type_code') ? GETPOST('type_code') : $object->type_code), 'type_code', '', '2');
print '</td></tr>'; print '</td></tr>';
// Severity // Severity
print '<tr><td><span class="fieldrequired"><label for="selectseverity_code">' . $langs->trans("TicketSeverity") . '</span></label></td><td>'; print '<tr><td><span class="fieldrequired"><label for="selectseverity_code">'.$langs->trans("TicketSeverity").'</span></label></td><td>';
$formticket->selectSeveritiesTickets((GETPOST('severity_code') ? GETPOST('severity_code') : $object->severity_code), 'severity_code', '', '2'); $formticket->selectSeveritiesTickets((GETPOST('severity_code') ? GETPOST('severity_code') : $object->severity_code), 'severity_code', '', '2');
print '</td></tr>'; print '</td></tr>';
// Group // Group
print '<tr><td><span class="fieldrequired"><label for="selectcategory_code">' . $langs->trans("TicketGroup") . '</span></label></td><td>'; print '<tr><td><span class="fieldrequired"><label for="selectcategory_code">'.$langs->trans("TicketGroup").'</span></label></td><td>';
$formticket->selectGroupTickets((GETPOST('category_code') ? GETPOST('category_code') : $object->category_code), 'category_code', '', '2'); $formticket->selectGroupTickets((GETPOST('category_code') ? GETPOST('category_code') : $object->category_code), 'category_code', '', '2');
print '</td></tr>'; print '</td></tr>';
// Subject // Subject
print '<tr><td><label for="subject"><span class="fieldrequired">' . $langs->trans("Subject") . '</span></label></td><td>'; print '<tr><td><label for="subject"><span class="fieldrequired">'.$langs->trans("Subject").'</span></label></td><td>';
print '<input class="text" size="50" id="subject" name="subject" value="' . (GETPOST('subject', 'alpha') ? GETPOST('subject', 'alpha') : $object->subject) . '" />'; print '<input class="text" size="50" id="subject" name="subject" value="'.(GETPOST('subject', 'alpha') ? GETPOST('subject', 'alpha') : $object->subject).'" />';
print '</td></tr>'; print '</td></tr>';
// Other attributes // Other attributes
$parameters = array('colspan' => ' colspan="3"', 'colspanvalue' => '3'); $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; print $hookmanager->resPrint;
if (empty($reshook)) { if (empty($reshook)) {
print $object->showOptionals($extrafields, 'edit'); print $object->showOptionals($extrafields, 'edit');
@ -701,9 +701,9 @@ if ($action == 'create' || $action == 'presend')
dol_fiche_end(); dol_fiche_end();
print '<div class="center">'; print '<div class="center">';
print '<input type="submit" class="button" name="save" value="' . $langs->trans('Save') . '">'; print '<input type="submit" class="button" name="save" value="'.$langs->trans('Save').'">';
print ' &nbsp; &nbsp; '; print ' &nbsp; &nbsp; ';
print '<input type="submit" class="button" name="cancel" value="' . $langs->trans('Cancel') . '">'; print '<input type="submit" class="button" name="cancel" value="'.$langs->trans('Cancel').'">';
print '</div>'; print '</div>';
print '</form>'; print '</form>';
@ -1250,7 +1250,7 @@ elseif (empty($action) || $action == 'view' || $action == 'addlink' || $action =
} }
if ($user->rights->ticket->write && $object->fk_statut < Ticket::STATUS_CLOSED) { if ($user->rights->ticket->write && $object->fk_statut < Ticket::STATUS_CLOSED) {
print '<div class="inline-block divButAction"><a class="butAction" href="' . $_SERVER["PHP_SELF"] . '?track_id=' . $object->track_id . '&action=edit">' . $langs->trans('Modify') . '</a></div>'; print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?track_id='.$object->track_id.'&action=edit">'.$langs->trans('Modify').'</a></div>';
} }
// Close ticket if statut is read // Close ticket if statut is read