diff --git a/htdocs/admin/mailing.php b/htdocs/admin/mailing.php index ab4b747e21c..6a166078bfc 100644 --- a/htdocs/admin/mailing.php +++ b/htdocs/admin/mailing.php @@ -127,7 +127,8 @@ print ''.$langs->trans("Example").''; print "\n"; print ''; -print $langs->trans("MailingEMailFrom").''; +$help = img_help(1, $langs->trans("EMailHelpMsgSPFDKIM")); +print $langs->trans("MailingEMailFrom").' '.$help.''; print ''; if (!empty($conf->global->MAILING_EMAIL_FROM) && !isValidEmail($conf->global->MAILING_EMAIL_FROM)) { print ' '.img_warning($langs->trans("BadEMail")); diff --git a/htdocs/admin/mails.php b/htdocs/admin/mails.php index dfa0bccb06b..035830a0878 100644 --- a/htdocs/admin/mails.php +++ b/htdocs/admin/mails.php @@ -599,7 +599,8 @@ if ($action == 'edit') { print ''.$langs->trans("OtherOptions").''; // From - print ''.$langs->trans("MAIN_MAIL_EMAIL_FROM", ini_get('sendmail_from') ?ini_get('sendmail_from') : $langs->transnoentities("Undefined")).''; + $help = img_help(1, $langs->trans("EMailHelpMsgSPFDKIM")); + print ''.$langs->trans("MAIN_MAIL_EMAIL_FROM", ini_get('sendmail_from') ?ini_get('sendmail_from') : $langs->transnoentities("Undefined")).' '.$help.''; print ''; @@ -820,7 +821,8 @@ if ($action == 'edit') { print ''.$langs->trans("OtherOptions").''; // From - print ''.$langs->trans("MAIN_MAIL_EMAIL_FROM", ini_get('sendmail_from') ?ini_get('sendmail_from') : $langs->transnoentities("Undefined")).''; + $help = img_help(1, $langs->trans("EMailHelpMsgSPFDKIM")); + print ''.$langs->trans("MAIN_MAIL_EMAIL_FROM", ini_get('sendmail_from') ?ini_get('sendmail_from') : $langs->transnoentities("Undefined")).' '.$help.''; print ''.$conf->global->MAIN_MAIL_EMAIL_FROM; if (empty($conf->global->MAIN_MAIL_EMAIL_FROM)) { print img_warning($langs->trans("Mandatory")); diff --git a/htdocs/compta/tva/card.php b/htdocs/compta/tva/card.php index ae2ddac9da0..e7c7678b818 100644 --- a/htdocs/compta/tva/card.php +++ b/htdocs/compta/tva/card.php @@ -75,17 +75,6 @@ $hookmanager->initHooks(array('taxvatcard', 'globalcard')); // Fetch optionals attributes and labels $extrafields->fetch_name_optionals_label($object->table_element); -$search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); - -// Initialize array of search criterias -$search_all = GETPOST("search_all", 'alpha'); -$search = array(); -foreach ($object->fields as $key => $val) { - if (GETPOST('search_'.$key, 'alpha')) { - $search[$key] = GETPOST('search_'.$key, 'alpha'); - } -} - if (empty($action) && empty($id) && empty($ref)) { $action = 'view'; } diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php index 7fde0005b7c..feb27715da2 100644 --- a/htdocs/core/class/extrafields.class.php +++ b/htdocs/core/class/extrafields.class.php @@ -2074,14 +2074,21 @@ class ExtraFields $visibility = 1; if (isset($this->attributes[$object->table_element]['list'][$key])) { // 'list' is option for visibility - $visibility = dol_eval($this->attributes[$object->table_element]['list'][$key], 1, 1, '1'); + $visibility = intval(dol_eval($this->attributes[$object->table_element]['list'][$key], 1, 1, '1')); } $perms = 1; if (isset($this->attributes[$object->table_element]['perms'][$key])) { $perms = dol_eval($this->attributes[$object->table_element]['perms'][$key], 1, 1, '1'); } - if (empty($enabled)) { + if (empty($enabled) + || ( + $onlykey === '@GETPOSTISSET' + && in_array($this->attributes[$object->table_element]['type'][$key], array('boolean', 'chkbxlst')) + && in_array(abs($enabled), array(2, 5)) + && ! GETPOSTISSET('options_' . $key) // Update hidden checkboxes and multiselect only if they are provided + ) + ) { continue; } if (empty($visibility)) { diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 0a1f5f16d6d..b104509a0c8 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -2453,9 +2453,10 @@ class Form * @param string $morecss Add more css on select * @param string $nooutput No print, return the output into a string * @param int $forcecombo Force to use combo box + * @param array $TProducts Add filter on a defined product * @return void|string */ - public function select_bom($selected = '', $htmlname = 'bom_id', $limit = 0, $status = 1, $type = 1, $showempty = '1', $morecss = '', $nooutput = '', $forcecombo = 0) + public function select_bom($selected = '', $htmlname = 'bom_id', $limit = 0, $status = 1, $type = 0, $showempty = '1', $morecss = '', $nooutput = '', $forcecombo = 0, $TProducts = []) { // phpcs:enable global $conf, $user, $langs, $db; @@ -2477,8 +2478,9 @@ class Form $sql.= ' FROM '.MAIN_DB_PREFIX.'bom_bom as b'; $sql.= ' WHERE b.entity IN ('.getEntity('bom').')'; if (!empty($status)) $sql.= ' AND status = '. (int) $status; - if (!empty($type)) $sql.= ' AND status = '. (int) $type; - if (!empty($limit)) $sql.= 'LIMIT '. (int) $limit; + if (!empty($type)) $sql.= ' AND bomtype = '. (int) $type; + if (!empty($TProducts)) $sql .= ' AND fk_product IN ('.$this->db->sanitize(implode(',', $TProducts)).')'; + if (!empty($limit)) $sql.= ' LIMIT '. (int) $limit; $resql = $db->query($sql); if ($resql) { if ($showempty) { @@ -2489,8 +2491,9 @@ class Form while ($obj = $db->fetch_object($resql)) { $product = new Product($db); $res = $product->fetch($obj->fk_product); - if ($obj->rowid == $selected) $out .= ''; - $out .= ''; + $out .= ''; } } else { $error++; diff --git a/htdocs/core/lib/admin.lib.php b/htdocs/core/lib/admin.lib.php index 0ea8b49d04a..2ce3094f41b 100644 --- a/htdocs/core/lib/admin.lib.php +++ b/htdocs/core/lib/admin.lib.php @@ -1724,15 +1724,13 @@ function form_constantes($tableau, $strictw3c = 0, $helptext = '', $text = 'Valu print ''; - } - if ($const == 'ADHERENT_MAILMAN_UNSUB_URL') { + } elseif ($const == 'ADHERENT_MAILMAN_UNSUB_URL') { print '. '.$langs->trans("Example").': '.img_down().'
'; print ''; //print 'http://lists.example.com/cgi-bin/mailman/admin/%LISTE%/members/remove?adminpw=%MAILMAN_ADMINPW%&unsubscribees=%EMAIL%'; - } - if ($const == 'ADHERENT_MAILMAN_LISTS') { + } elseif ($const == 'ADHERENT_MAILMAN_LISTS') { print '. '.$langs->trans("Example").': '.img_down().'
'; print ''; //print 'http://lists.example.com/cgi-bin/mailman/admin/%LISTE%/members/remove?adminpw=%MAILMAN_ADMINPW%&unsubscribees=%EMAIL%'; + } elseif ($const == 'ADHERENT_MAIL_FROM') { + print ' '.img_help(1, $langs->trans("EMailHelpMsgSPFDKIM")); } print "\n"; diff --git a/htdocs/core/lib/project.lib.php b/htdocs/core/lib/project.lib.php index d427f87189a..aa70df1c393 100644 --- a/htdocs/core/lib/project.lib.php +++ b/htdocs/core/lib/project.lib.php @@ -1241,13 +1241,14 @@ function projectLinesPerAction(&$inc, $parent, $fuser, $lines, &$level, &$projec print convertSecondToTime($lines[$i]->timespent_duration, 'allhourmin'); - $modeinput = 'hours'; + // Comment for avoid unnecessary multiple calculation + /*$modeinput = 'hours'; print ''; + print '';*/ print ''; @@ -1628,13 +1629,14 @@ function projectLinesPerDay(&$inc, $parent, $fuser, $lines, &$level, &$projectsr //$tableCell.=' '; print $tableCell; - $modeinput = 'hours'; + // Comment for avoid unnecessary multiple calculation + /*$modeinput = 'hours'; print ''; + print '';*/ print ''; diff --git a/htdocs/core/lib/security.lib.php b/htdocs/core/lib/security.lib.php index 0d0a0de3e0d..0ef7a568f18 100644 --- a/htdocs/core/lib/security.lib.php +++ b/htdocs/core/lib/security.lib.php @@ -391,6 +391,11 @@ function restrictedArea(User $user, $features, $objectid = 0, $tableandshare = ' return 1; } + // To avoid access forbidden with numeric ref + if ($dbt_select != 'rowid' && $dbt_select != 'id') { + $objectid = "'".$objectid."'"; + } + // Features/modules to check $featuresarray = array($features); if (preg_match('/&/', $features)) { diff --git a/htdocs/core/modules/modProduct.class.php b/htdocs/core/modules/modProduct.class.php index 1ca960860d3..940c4fb2f9a 100644 --- a/htdocs/core/modules/modProduct.class.php +++ b/htdocs/core/modules/modProduct.class.php @@ -658,16 +658,7 @@ class modProduct extends DolibarrModules } // End add extra fields $this->import_fieldshidden_array[$r] = array('extra.fk_object'=>'lastrowid-'.MAIN_DB_PREFIX.'product'); // aliastable.field => ('user->id' or 'lastrowid-'.tableparent) - $this->import_regex_array[$r] = array( - 'p.ref'=>'[^ ]', - 'p.price_base_type' => 'HT|TTC', - 'p.tosell'=>'^[0|1]$', - 'p.tobuy'=>'^[0|1]$', - 'p.fk_product_type'=>'^[0|1]$', - 'p.datec'=>'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$', - 'p.recuperableonly' => '^[0|1]$', - 'p.finished' => '^[0|1]$' - ); + // field order as per structure of table llx_product $import_sample = array( 'p.ref' => "ref:PREF123456", diff --git a/htdocs/core/tpl/notes.tpl.php b/htdocs/core/tpl/notes.tpl.php index a81c95251f4..2a0f3d654d7 100644 --- a/htdocs/core/tpl/notes.tpl.php +++ b/htdocs/core/tpl/notes.tpl.php @@ -29,6 +29,9 @@ $module = $object->element; $note_public = 'note_public'; $note_private = 'note_private'; +if ($module == "product") { + $module = ($object->type == Product::TYPE_SERVICE ? 'service' : 'product'); +} $colwidth = (isset($colwidth) ? $colwidth : (empty($cssclass) ? '25' : '')); // Set $permission from the $permissionnote var defined on calling page $permission = (isset($permissionnote) ? $permissionnote : (isset($permission) ? $permission : (isset($user->rights->$module->create) ? $user->rights->$module->create : (isset($user->rights->$module->creer) ? $user->rights->$module->creer : 0)))); @@ -60,37 +63,39 @@ if (!empty($conf->global->MAIN_AUTO_TIMESTAMP_IN_PRIVATE_NOTES)) { // Special cases if ($module == 'propal') { - $permission = $user->rights->propal->creer; + $permission = $user->hasRight("propal", "creer"); } elseif ($module == 'supplier_proposal') { - $permission = $user->rights->supplier_proposal->creer; + $permission = $user->hasRight("supplier_proposal", "creer"); } elseif ($module == 'fichinter') { - $permission = $user->rights->ficheinter->creer; + $permission = $user->hasRight("ficheinter", "creer"); } elseif ($module == 'project') { - $permission = $user->rights->projet->creer; + $permission = $user->hasRight("projet", "creer"); } elseif ($module == 'project_task') { - $permission = $user->rights->projet->creer; + $permission = $user->hasRight("projet", "creer"); } elseif ($module == 'invoice_supplier') { if (empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) { - $permission = $user->rights->fournisseur->facture->creer; + $permission = $user->hasRight("fournisseur", "facture", "creer"); } else { - $permission = $user->rights->supplier_invoice->creer; + $permission = $user->hasRight("supplier_invoice", "creer"); } } elseif ($module == 'order_supplier') { if (empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) { - $permission = $user->rights->fournisseur->commande->creer; + $permission = $user->hasRight("fournisseur", "commande", "creer"); } else { - $permission = $user->rights->supplier_order->creer; + $permission = $user->hasRight("supplier_order", "creer"); } } elseif ($module == 'societe') { - $permission = $user->rights->societe->creer; + $permission = $user->hasRight("societe", "creer"); } elseif ($module == 'contact') { - $permission = $user->rights->societe->creer; + $permission = $user->hasRight("societe", "creer"); } elseif ($module == 'shipping') { - $permission = $user->rights->expedition->creer; + $permission = $user->hasRight("expedition", "creer"); } elseif ($module == 'product') { - $permission = $user->rights->produit->creer; + $permission = $user->hasRight("produit", "creer"); +} elseif ($module == 'service') { + $permission = $user->hasRight("service", "creer"); } elseif ($module == 'ecmfiles') { - $permission = $user->rights->ecm->setup; + $permission = $user->hasRight("ecm", "setup"); } elseif ($module == 'user') { $permission = $user->hasRight("user", "self", "write"); } diff --git a/htdocs/expensereport/card.php b/htdocs/expensereport/card.php index 4bb9bf378ee..33ec1fede7b 100644 --- a/htdocs/expensereport/card.php +++ b/htdocs/expensereport/card.php @@ -418,7 +418,7 @@ if (empty($reshook)) { // FROM $expediteur = new User($db); $expediteur->fetch($object->fk_user_author); - $emailFrom = $expediteur->email; + $emailFrom = $conf->global->MAIN_MAIL_EMAIL_FROM; if ($emailTo && $emailFrom) { $filename = array(); $filedir = array(); $mimetype = array(); @@ -525,7 +525,7 @@ if (empty($reshook)) { // FROM $expediteur = new User($db); $expediteur->fetch($object->fk_user_author); - $emailFrom = $expediteur->email; + $emailFrom = $conf->global->MAIN_MAIL_EMAIL_FROM; if ($emailFrom && $emailTo) { $filename = array(); $filedir = array(); $mimetype = array(); @@ -641,7 +641,7 @@ if (empty($reshook)) { // FROM $expediteur = new User($db); $expediteur->fetch($object->fk_user_approve > 0 ? $object->fk_user_approve : $object->fk_user_validator); - $emailFrom = $expediteur->email; + $emailFrom = $conf->global->MAIN_MAIL_EMAIL_FROM; if ($emailFrom && $emailTo) { $filename = array(); $filedir = array(); $mimetype = array(); @@ -749,7 +749,7 @@ if (empty($reshook)) { // FROM $expediteur = new User($db); $expediteur->fetch($object->fk_user_refuse); - $emailFrom = $expediteur->email; + $emailFrom = $conf->global->MAIN_MAIL_EMAIL_FROM; if ($emailFrom && $emailTo) { $filename = array(); $filedir = array(); $mimetype = array(); @@ -863,7 +863,7 @@ if (empty($reshook)) { // FROM $expediteur = new User($db); $expediteur->fetch($object->fk_user_cancel); - $emailFrom = $expediteur->email; + $emailFrom = $conf->global->MAIN_MAIL_EMAIL_FROM; if ($emailFrom && $emailTo) { $filename = array(); $filedir = array(); $mimetype = array(); @@ -1043,7 +1043,7 @@ if (empty($reshook)) { // FROM $expediteur = new User($db); $expediteur->fetch($user->id); - $emailFrom = $expediteur->email; + $emailFrom = $conf->global->MAIN_MAIL_EMAIL_FROM; if ($emailFrom && $emailTo) { $filename = array(); $filedir = array(); $mimetype = array(); diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 90ca6c15362..0555906768c 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -292,6 +292,7 @@ MAIN_MAIL_SMTP_SERVER=SMTP/SMTPS Host (default value in php.ini: %s) MAIN_MAIL_SMTP_PORT_NotAvailableOnLinuxLike=SMTP/SMTPS Port (Not defined into PHP on Unix-like systems) MAIN_MAIL_SMTP_SERVER_NotAvailableOnLinuxLike=SMTP/SMTPS Host (Not defined into PHP on Unix-like systems) MAIN_MAIL_EMAIL_FROM=Sender email for automatic emails (default value in php.ini: %s) +EMailHelpMsgSPFDKIM=To prevent Dolibarr emails to be classified as spam, make sure that the server is authorized to send e-mails from this address by SPF and DKIM configuration MAIN_MAIL_ERRORS_TO=Email used for error returns emails (fields 'Errors-To' in emails sent) MAIN_MAIL_AUTOCOPY_TO= Copy (Bcc) all sent emails to MAIN_DISABLE_ALL_MAILS=Disable all email sending (for test purposes or demos) diff --git a/htdocs/langs/en_US/dict.lang b/htdocs/langs/en_US/dict.lang index 0524cf1ca18..00ab5a05f24 100644 --- a/htdocs/langs/en_US/dict.lang +++ b/htdocs/langs/en_US/dict.lang @@ -250,7 +250,9 @@ CountryMF=Saint Martin ##### Civilities ##### CivilityMME=Mrs. +CivilityMMEShort=Mrs. CivilityMR=Mr. +CivilityMRShort=Mr. CivilityMLE=Ms. CivilityMTRE=Master CivilityDR=Doctor diff --git a/htdocs/product/class/api_products.class.php b/htdocs/product/class/api_products.class.php index 91a55b4ca30..e234f4dba8e 100644 --- a/htdocs/product/class/api_products.class.php +++ b/htdocs/product/class/api_products.class.php @@ -1014,7 +1014,7 @@ class Products extends DolibarrApi throw new RestException(401); } - $sql = "SELECT t.rowid, t.ref, t.ref_ext, t.label, t.rang, t.entity"; + $sql = "SELECT t.rowid, t.ref, t.ref_ext, t.label, t.position, t.entity"; $sql .= " FROM ".$this->db->prefix()."product_attribute as t"; $sql .= ' WHERE t.entity IN ('.getEntity('product').')'; @@ -1051,7 +1051,7 @@ class Products extends DolibarrApi $tmp->ref = $result->ref; $tmp->ref_ext = $result->ref_ext; $tmp->label = $result->label; - $tmp->rang = $result->rang; + $tmp->position = $result->position; $tmp->entity = $result->entity; $return[] = $this->_cleanObjectDatas($tmp); @@ -1088,7 +1088,7 @@ class Products extends DolibarrApi throw new RestException(404, "Product attribute not found"); } - $fields = ["id", "ref", "ref_ext", "label", "rang", "entity"]; + $fields = ["id", "ref", "ref_ext", "label", "position", "entity"]; foreach ($prodattr as $field => $value) { if (!in_array($field, $fields)) { diff --git a/htdocs/projet/activity/perday.php b/htdocs/projet/activity/perday.php index 0854dceee67..14e77adc331 100644 --- a/htdocs/projet/activity/perday.php +++ b/htdocs/projet/activity/perday.php @@ -795,12 +795,12 @@ print ''; print ''; -$modeinput = 'hours'; - -if ($conf->use_javascript_ajax) { +if (!empty($conf->use_javascript_ajax)) { + $modeinput = 'hours'; print "\n\n"; print ''; } diff --git a/htdocs/projet/class/project.class.php b/htdocs/projet/class/project.class.php index c5dcf0d4bb4..96e1b3afc08 100644 --- a/htdocs/projet/class/project.class.php +++ b/htdocs/projet/class/project.class.php @@ -926,7 +926,7 @@ class Project extends CommonObject } // Fetch tasks - $this->getLinesArray($user); + $this->getLinesArray($user, 0); // Delete tasks $ret = $this->deleteTasks($user); @@ -2300,14 +2300,15 @@ class Project extends CommonObject /** * Create an array of tasks of current project * - * @param User $user Object user we want project allowed to - * @return int >0 if OK, <0 if KO + * @param User $user Object user we want project allowed to + * @param int $loadRoleMode 1= will test Roles on task; 0 used in delete project action + * @return int >0 if OK, <0 if KO */ - public function getLinesArray($user) + public function getLinesArray($user, $loadRoleMode = 1) { require_once DOL_DOCUMENT_ROOT.'/projet/class/task.class.php'; $taskstatic = new Task($this->db); - $this->lines = $taskstatic->getTasksArray(0, $user, $this->id, 0, 0); + $this->lines = $taskstatic->getTasksArray(0, $user, $this->id, 0, 0, '', '-1', '', 0, 0, array(), 0, array(), 0, $loadRoleMode); } } diff --git a/htdocs/projet/class/task.class.php b/htdocs/projet/class/task.class.php index 48b0b63e31a..b751d8d1e8e 100644 --- a/htdocs/projet/class/task.class.php +++ b/htdocs/projet/class/task.class.php @@ -811,9 +811,10 @@ class Task extends CommonObjectLine * @param int $includebilltime Calculate also the time to bill and billed * @param array $search_array_options Array of search * @param int $loadextras Fetch all Extrafields on each task + * @param int $loadRoleMode 1= will test Roles on task; 0 used in delete project action * @return array Array of tasks */ - public function getTasksArray($usert = null, $userp = null, $projectid = 0, $socid = 0, $mode = 0, $filteronproj = '', $filteronprojstatus = '-1', $morewherefilter = '', $filteronprojuser = 0, $filterontaskuser = 0, $extrafields = array(), $includebilltime = 0, $search_array_options = array(), $loadextras = 0) + public function getTasksArray($usert = null, $userp = null, $projectid = 0, $socid = 0, $mode = 0, $filteronproj = '', $filteronprojstatus = '-1', $morewherefilter = '', $filteronprojuser = 0, $filterontaskuser = 0, $extrafields = array(), $includebilltime = 0, $search_array_options = array(), $loadextras = 0, $loadRoleMode = 1) { global $conf, $hookmanager; @@ -968,14 +969,16 @@ class Task extends CommonObjectLine $obj = $this->db->fetch_object($resql); - if ((!$obj->public) && (is_object($userp))) { // If not public project and we ask a filter on project owned by a user - if (!$this->getUserRolesForProjectsOrTasks($userp, 0, $obj->projectid, 0)) { - $error++; + if ($loadRoleMode) { + if ((!$obj->public) && (is_object($userp))) { // If not public project and we ask a filter on project owned by a user + if (!$this->getUserRolesForProjectsOrTasks($userp, 0, $obj->projectid, 0)) { + $error++; + } } - } - if (is_object($usert)) { // If we ask a filter on a user affected to a task - if (!$this->getUserRolesForProjectsOrTasks(0, $usert, $obj->projectid, $obj->taskid)) { - $error++; + if (is_object($usert)) { // If we ask a filter on a user affected to a task + if (!$this->getUserRolesForProjectsOrTasks(0, $usert, $obj->projectid, $obj->taskid)) { + $error++; + } } } diff --git a/htdocs/public/payment/newpayment.php b/htdocs/public/payment/newpayment.php index 0a70c6c5204..018d233ade2 100644 --- a/htdocs/public/payment/newpayment.php +++ b/htdocs/public/payment/newpayment.php @@ -2358,7 +2358,17 @@ if (preg_match('/^dopayment/', $action)) { // If we choosed/click on the payme // Code for payment with option STRIPE_USE_NEW_CHECKOUT set // Create a Stripe client. + var stripe = Stripe(''); + + var stripe = Stripe('', { stripeAccount: '' }); + // Create an instance of Elements var elements = stripe.elements(); @@ -2401,9 +2411,19 @@ if (preg_match('/^dopayment/', $action)) { // If we choosed/click on the payme } elseif (!empty($conf->global->STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION)) { ?> // Code for payment with option STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION set to 1 or 2 - + // Create a Stripe client. + var stripe = Stripe(''); + + var stripe = Stripe('', { stripeAccount: '' }); + db); $result = $invoice->list_replacable_invoices($id); if ($result < 0) { - throw new RestException(405, $this->thirdparty->error); + throw new RestException(405, $invoice->error); } return $result; @@ -1137,7 +1137,7 @@ class Thirdparties extends DolibarrApi $invoice = new Facture($this->db); $result = $invoice->list_qualified_avoir_invoices($id); if ($result < 0) { - throw new RestException(405, $this->thirdparty->error); + throw new RestException(405, $invoice->error); } return $result; @@ -1176,10 +1176,9 @@ class Thirdparties extends DolibarrApi $sql .= " WHERE fk_soc = ".((int) $id); } - $result = $this->db->query($sql); - if ($result->num_rows == 0) { + if ($this->db->num_rows($result) == 0) { throw new RestException(404, 'Account not found'); } @@ -1421,7 +1420,7 @@ class Thirdparties extends DolibarrApi if ($result > 0) { return array("success" => $result); } else { - throw new RestException(500, 'Error generating the document '.$this->error); + throw new RestException(500, 'Error generating the document '.$this->company->error); } } diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index 66f7cb6ee79..8ffe95731de 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -1474,7 +1474,7 @@ class Societe extends CommonObject $sql .= ",fk_effectif = ".($this->effectif_id > 0 ? ((int) $this->effectif_id) : "null"); if (isset($this->stcomm_id)) { - $sql .= ",fk_stcomm=".($this->stcomm_id > 0 ? ((int) $this->stcomm_id) : "0"); + $sql .= ",fk_stcomm=".(int) $this->stcomm_id; } if (isset($this->typent_id)) { $sql .= ",fk_typent = ".($this->typent_id > 0 ? ((int) $this->typent_id) : "0");