Merge branch 'develop' of git@github.com:Dolibarr/dolibarr.git into fix_php_8.0

This commit is contained in:
Regis Houssin 2020-12-29 17:12:18 +01:00
commit acabb045fb
38 changed files with 1201 additions and 1094 deletions

View File

@ -55,8 +55,7 @@ ONLY vulnerabilities discovered, when the following setup on test platform is us
* $dolibarr_nocsrfcheck must be kept to the value 0 into conf.php (this is the default value)
* $dolibarr_main_force_https must be set to something else than 0.
* The constant MAIN_SECURITY_CSRF_WITH_TOKEN must be set to 1 into backoffice menu Home - Setup - Other (this protection should be set to 1 soon by default)
* The module DebugBar must NOT be enabled (by default, this module is not enabled. This is a developer tool)
* The module ModuleBuilder must NOT be enabled (by default, this module is not enabled. This is a developer tool)
* The module DebugBar and ModuleBuilder must NOT be enabled (by default, this module is not enabled. This is a developer tool)
* ONLY security reports on modules provided by default and with the "stable" status are valid (troubles into "experimental", "developement" or external modules are not valid vulnerabilities).
* The root of web server must link to htdocs and the documents directory must be outside of the web server root (this is the default when using the default installer but may differs with external installer).
* The web server setup must be done so only the documents directory is in write mode. The root directory called htdocs must be readonly.

View File

@ -467,7 +467,7 @@ if (!empty($sortfield)) {
// Export into a file with format defined into setup (FEC, CSV, ...)
// Must be after definition of $sql
if ($action == 'export_file' && $user->rights->accounting->mouvements->export) {
if ($action == 'export_fileconfirm' && $user->rights->accounting->mouvements->export) {
// TODO Replace the fetchAll + ->export later that consume too much memory on large export with the query($sql) and loop on each line to export them.
$result = $object->fetchAll($sortorder, $sortfield, 0, 0, $filter, 'AND', $conf->global->ACCOUNTING_REEXPORT);
@ -495,6 +495,7 @@ if ($action == 'export_file' && $user->rights->accounting->mouvements->export) {
$sql = " UPDATE ".MAIN_DB_PREFIX."accounting_bookkeeping";
$sql .= " SET date_export = '".$db->idate($now)."'";
$sql .= " , date_validated = '".$db->idate($now)."'";
$sql .= " WHERE rowid = ".$movement->id;
dol_syslog("/accountancy/bookeeping/list.php Function export_file Specify movements as exported sql=".$sql, LOG_DEBUG);
@ -566,7 +567,25 @@ if (is_numeric($nbtotalofrecords) && $limit > $nbtotalofrecords)
llxHeader('', $title_page);
if ($action == 'export_file') {
$form_question = array();
$form_question['notifiedexportdate'] = array(
'name' => 'notifiedexportdate',
'type' => 'checkbox',
'label' => $langs->trans('NotifiedExportDate'),
'value' => (!empty($conf->global->ACCOUNTING_DEFAULT_NOT_NOTIFIED_EXPORT_DATE) ? 'false' : 'true'),
);
$form_question['notifiedvalidationdate'] = array(
'name' => 'notifiedvalidationdate',
'type' => 'checkbox', // We don't use select here, the journal_array is already a select html component
'label' => $langs->trans('NotifiedValidationDate'),
'value' => (!empty($conf->global->ACCOUNTING_DEFAULT_NOT_NOTIFIED_VALIDATION_DATE) ? 'false' : 'true'),
);
$formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?'.$param, $langs->trans("ExportFilteredList").' ('.$listofformat[$formatexportset].')', $langs->trans('ConfirmExportFile'), 'export_fileconfirm', $form_question, '', 1, 300);
print $formconfirm;
}
if ($action == 'delmouv') {
$formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?mvt_num='.GETPOST('mvt_num').$param, $langs->trans('DeleteMvt'), $langs->trans('ConfirmDeleteMvtPartial'), 'delmouvconfirm', '', 0, 1);
print $formconfirm;

View File

@ -840,17 +840,19 @@ class AccountancyExport
print "DateLet".$separator;
print "ValidDate".$separator;
print "Montantdevise".$separator;
print "Idevise";
print "Idevise".$separator;
print "DateLimitReglmt";
print $end_line;
foreach ($objectLines as $line) {
if ($line->debit == 0 && $line->credit == 0) {
if ($line->debit == 0 && $line->credit == 0) {
unset($array[$line]);
} else {
$date_creation = dol_print_date($line->date_creation, '%Y%m%d');
$date_document = dol_print_date($line->doc_date, '%Y%m%d');
$date_lettering = dol_print_date($line->date_lettering, '%Y%m%d');
$date_validation = dol_print_date($line->date_validated, '%Y%m%d');
$date_creation = dol_print_date($line->date_creation, '%Y%m%d');
$date_document = dol_print_date($line->doc_date, '%Y%m%d');
$date_lettering = dol_print_date($line->date_lettering, '%Y%m%d');
$date_validation = dol_print_date($line->date_validated, '%Y%m%d');
$date_limit_payment = dol_print_date($line->date_lim_reglement, '%Y%m%d');
// FEC:JournalCode
print $line->code_journal.$separator;
@ -865,13 +867,13 @@ class AccountancyExport
print $date_document.$separator;
// FEC:CompteNum
print $line->numero_compte.$separator;
print length_accountg($line->numero_compte).$separator;
// FEC:CompteLib
print dol_string_unaccent($line->label_compte).$separator;
// FEC:CompAuxNum
print $line->subledger_account.$separator;
print length_accounta($line->subledger_account).$separator;
// FEC:CompAuxLib
print dol_string_unaccent($line->subledger_label).$separator;
@ -880,7 +882,7 @@ class AccountancyExport
print $line->doc_ref.$separator;
// FEC:PieceDate
print dol_string_unaccent($date_creation).$separator;
print $date_creation.$separator;
// FEC:EcritureLib
print dol_string_unaccent($line->label_operation).$separator;
@ -904,7 +906,10 @@ class AccountancyExport
print $line->multicurrency_amount.$separator;
// FEC:Idevise
print $line->multicurrency_code;
print $line->multicurrency_code.$separator;
// FEC_suppl:DateLimitReglmt
print $date_limit_payment;
print $end_line;
}
@ -939,7 +944,8 @@ class AccountancyExport
print "DateLet".$separator;
print "ValidDate".$separator;
print "Montantdevise".$separator;
print "Idevise";
print "Idevise".$separator;
print "DateLimitReglmt";
print $end_line;
foreach ($objectLines as $line) {
@ -950,6 +956,7 @@ class AccountancyExport
$date_document = dol_print_date($line->doc_date, '%Y%m%d');
$date_lettering = dol_print_date($line->date_lettering, '%Y%m%d');
$date_validation = dol_print_date($line->date_validated, '%Y%m%d');
$date_limit_payment = dol_print_date($line->date_lim_reglement, '%Y%m%d');
// FEC:JournalCode
print $line->code_journal . $separator;
@ -964,13 +971,13 @@ class AccountancyExport
print $date_creation . $separator;
// FEC:CompteNum
print $line->numero_compte . $separator;
print length_accountg($line->numero_compte) . $separator;
// FEC:CompteLib
print dol_string_unaccent($line->label_compte) . $separator;
// FEC:CompAuxNum
print $line->subledger_account . $separator;
print length_accounta($line->subledger_account) . $separator;
// FEC:CompAuxLib
print dol_string_unaccent($line->subledger_label) . $separator;
@ -1003,7 +1010,10 @@ class AccountancyExport
print $line->multicurrency_amount . $separator;
// FEC:Idevise
print $line->multicurrency_code;
print $line->multicurrency_code . $separator;
// FEC_suppl:DateLimitReglmt
print $date_limit_payment;
print $end_line;
}

View File

@ -187,14 +187,14 @@ print '<td class="center">&nbsp;</td>'."\n";
print '<td class="right">'."\n";
if (empty($conf->global->AGENDA_REMINDER_BROWSER)) {
if (! getIsHTTPS()) {
if (!isHTTPS()) {
$langs->load("errors");
print img_warning($langs->trans("WarningAvailableOnlyForHTTPSServers"), '', 'valignmiddle size15x').' ';
}
print '<a class="valignmiddle" href="'.$_SERVER['PHP_SELF'].'?action=set_AGENDA_REMINDER_BROWSER&amp;token='.newToken().'">'.img_picto($langs->trans('Disabled'), 'switch_off').'</a>';
print '</td></tr>'."\n";
} else {
if (! getIsHTTPS()) {
if (!isHTTPS()) {
$langs->load("errors");
print img_warning($langs->trans("WarningAvailableOnlyForHTTPSServers"), '', 'valignmiddle size15x').' ';
}

View File

@ -475,24 +475,22 @@ print load_fiche_titre($langs->trans("ModulesSetup"), '', 'title_setup');
if ($mode == 'common' || $mode == 'commonkanban') {
$desc = $langs->trans("ModulesDesc", '{picto}');
$desc = str_replace('{picto}', img_picto('', 'switch_off'), $desc);
print '<span class="opacitymedium hideonsmartphone">'.$desc."<br></span>\n";
print '<span class="opacitymedium hideonsmartphone">'.$desc."<br><br></span>\n";
}
if ($mode == 'marketplace') {
print '<span class="opacitymedium hideonsmartphone">'.$langs->trans("ModulesMarketPlaceDesc")."<br></span>\n";
print '<span class="opacitymedium hideonsmartphone">'.$langs->trans("ModulesMarketPlaceDesc")."<br><br></span>\n";
}
if ($mode == 'deploy') {
print '<span class="opacitymedium hideonsmartphone">'.$langs->trans("ModulesDeployDesc", $langs->transnoentitiesnoconv("AvailableModules"))."<br></span>\n";
print '<span class="opacitymedium hideonsmartphone">'.$langs->trans("ModulesDeployDesc", $langs->transnoentitiesnoconv("AvailableModules"))."<br><br></span>\n";
}
if ($mode == 'develop') {
print '<span class="opacitymedium hideonsmartphone">'.$langs->trans("ModulesDevelopDesc")."<br></span>\n";
print '<span class="opacitymedium hideonsmartphone">'.$langs->trans("ModulesDevelopDesc")."<br><br></span>\n";
}
$head = modules_prepare_head();
print "<br>\n";
if ($mode == 'common' || $mode == 'commonkanban') {
dol_set_focus('#search_keyword');

View File

@ -1146,6 +1146,8 @@ class Categorie extends CommonObject
// First build full array $motherof
//$this->load_motherof(); // Disabled because already done by caller of build_path_from_id_categ
// $this->cats[$id_categ] is supposed to be already an array. We just want to complete it with property fullpath and fulllabel
// Define fullpath and fulllabel
$this->cats[$id_categ]['fullpath'] = '_'.$id_categ;
$this->cats[$id_categ]['fulllabel'] = $this->cats[$id_categ]['label'];

View File

@ -131,8 +131,8 @@ if (GETPOST('exportcsv', 'int'))
header('Content-Disposition: attachment;filename='.$completefilename);
// List of selected targets
$sql = "SELECT mc.rowid, mc.lastname, mc.firstname, mc.email, mc.other, mc.statut, mc.date_envoi, mc.tms,";
$sql .= " mc.source_url, mc.source_id, mc.source_type, mc.error_text";
$sql = "SELECT mc.rowid, mc.lastname, mc.firstname, mc.email, mc.other, mc.statut as status, mc.date_envoi, mc.tms,";
$sql .= " mc.source_id, mc.source_type, mc.error_text";
$sql .= " FROM ".MAIN_DB_PREFIX."mailing_cibles as mc";
$sql .= " WHERE mc.fk_mailing=".$object->id;
$sql .= $db->order($sortfield, $sortorder);
@ -146,16 +146,16 @@ if (GETPOST('exportcsv', 'int'))
while ($obj = $db->fetch_object($resql))
{
print $obj->rowid.$sep;
print $obj->lastname.$sep;
print $obj->firstname.$sep;
print '"'.$obj->lastname.'"'.$sep;
print '"'.$obj->firstname.'"'.$sep;
print $obj->email.$sep;
print $obj->other.$sep;
print $obj->date_envoi.$sep;
print $obj->tms.$sep;
print $obj->source_url.$sep;
print $obj->source_id.$sep;
print $obj->source_type.$sep;
print $obj->error_text.$sep;
print $obj->source_id.$sep;
print $obj->date_envoi.$sep;
print $obj->status.$sep;
print '"'.$obj->error_text.'"'.$sep;
print "\n";
}
@ -499,7 +499,7 @@ if ($object->fetch($id) >= 0)
// Fix/update nbemail on emailing record if it differs (may happen if user edit lines from database directly)
if (empty($asearchcriteriahasbeenset)) {
if ($nbtotalofrecords != $object->email) {
if ($nbtotalofrecords != $object->nbemail) {
dol_syslog("We found a difference in nb of record in target table and the property ->nbemail, we fix ->nbemail");
//print "nbemail=".$object->nbemail." nbtotalofrecords=".$nbtotalofrecords;
$resultrefresh = $object->refreshNbOfTargets();

View File

@ -619,12 +619,15 @@ class Mailing extends CommonObject
if (! $resqlupdate) {
$this->error = $this->db->lasterror();
return -1;
} else {
$this->nbemail = (int) $nbforupdate;
}
}
} else {
$this->error = $this->db->lasterror();
return -1;
}
return 1;
}

View File

@ -1584,6 +1584,8 @@ if ($resql)
{
print '<td class="right nowrap">'.price($marginInfo['total_margin']).'</td>';
if (!$i) $totalarray['nbfield']++;
if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'total_margin';
$totalarray['val']['total_margin'] += $marginInfo['total_margin'];
}
// Total margin rate
if (!empty($arrayfields['total_margin_rate']['checked']))

View File

@ -42,6 +42,9 @@ class box_scheduled_jobs extends ModeleBoxes
*/
public $db;
/**
* @var string params
*/
public $param;
public $info_box_head = array();
@ -101,9 +104,11 @@ class box_scheduled_jobs extends ModeleBoxes
if (dol_eval($objp->test, 1, 1)) {
$nextrun = $this->db->jdate($objp->datenextrun);
if (empty($nextrun)) $nextrun = $this->db->jdate($objp->datestart);
if (empty($nextrun)) {
$nextrun = $this->db->jdate($objp->datestart);
}
if ($line == 0 || ($nextrun < $cronstatic->datenextrun && (empty($objp->nbrun) || empty($objp->maxrun) || $objp->nbrun < $obj->maxrun))) {
if ($line == 0 || ($nextrun < $cronstatic->datenextrun && (empty($objp->nbrun) || empty($objp->maxrun) || $objp->nbrun < $objp->maxrun))) {
$cronstatic->id = $objp->rowid;
$cronstatic->ref = $objp->rowid;
$cronstatic->label = $langs->trans($objp->label);

View File

@ -129,7 +129,7 @@ class Notify
if (is_array($listofnotiftodo)) {
$i = 0;
foreach ($listofnotiftodo as $key => $val) {
foreach ($listofnotiftodo as $val) {
if ($i) {
$texte .= ', ';
} else {

View File

@ -2909,7 +2909,7 @@ function getUserRemoteIP()
*
* @return boolean True if user is using HTTPS
*/
function getIsHTTPS()
function isHTTPS()
{
$isSecure = false;
if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') {
@ -3032,7 +3032,7 @@ function dol_print_address($address, $htmlid, $element, $id, $noprint = 0, $char
/**
* Return true if email syntax is ok.
*
* @param string $address email (Ex: "toto@examle.com", "John Do <johndo@example.com>")
* @param string $address email (Ex: "toto@examle.com". Long form "John Do <johndo@example.com>" will be false)
* @param int $acceptsupervisorkey If 1, the special string '__SUPERVISOREMAIL__' is also accepted as valid
* @return boolean true if email syntax is OK, false if KO or empty string
* @see isValidMXRecord()
@ -7123,9 +7123,9 @@ function dol_sort_array(&$array, $index, $order = 'asc', $natsort = 0, $case_sen
foreach (array_keys($array) as $key)
{
if (is_object($array[$key])) {
$temp[$key] = $array[$key]->$index;
$temp[$key] = empty($array[$key]->$index) ? 0 : $array[$key]->$index;
} else {
$temp[$key] = $array[$key][$index];
$temp[$key] = empty($array[$key][$index]) ? 0 : $array[$key][$index];
}
}

View File

@ -1252,7 +1252,7 @@ function check_value($mask, $value)
//print "masktri=".$masktri." maskcounter=".$maskcounter." maskwithonlyymcode=".$maskwithonlyymcode." maskwithnocode=".$maskwithnocode." maskraz=".$maskraz." maskoffset=".$maskoffset."<br>\n";
if (function_exists('mb_strrpos')) {
$posnumstart = mb_strrpos($maskwithnocode, $maskcounter, 'UTF-8');
$posnumstart = mb_strrpos($maskwithnocode, $maskcounter, 0, 'UTF-8');
}
else {
$posnumstart = strrpos($maskwithnocode, $maskcounter);

View File

@ -29,7 +29,7 @@
* @param array $authentication Array with authentication informations ('login'=>,'password'=>,'entity'=>,'dolibarrkey'=>)
* @param int $error Number of errors
* @param string $errorcode Error string code
* @param string $errorlabel Error string label
* @param string $errorlabel Error string label
* @return User Return user object identified by login/pass/entity into authentication array
*/
function check_authentication($authentication, &$error, &$errorcode, &$errorlabel)

View File

@ -162,7 +162,6 @@ class mailing_xinputfile extends MailingTargets
if (!empty($buffer))
{
//print 'xx'.dol_strlen($buffer).empty($buffer)."<br>\n";
$id = $cpt;
if (isValidEMail($email))
{
if ($old <> $email)

View File

@ -212,8 +212,8 @@ class mod_codeclient_elephant extends ModeleThirdPartyCode
// Get Mask value
$mask = '';
if ($type == 0) $mask = $conf->global->COMPANY_ELEPHANT_MASK_CUSTOMER;
if ($type == 1) $mask = $conf->global->COMPANY_ELEPHANT_MASK_SUPPLIER;
if ($type == 0) $mask = empty($conf->global->COMPANY_ELEPHANT_MASK_CUSTOMER) ? '' : $conf->global->COMPANY_ELEPHANT_MASK_CUSTOMER;
if ($type == 1) $mask = empty($conf->global->COMPANY_ELEPHANT_MASK_SUPPLIER) ? '' : $conf->global->COMPANY_ELEPHANT_MASK_SUPPLIER;
if (!$mask)
{
$this->error = 'NotConfigured';

View File

@ -157,6 +157,8 @@ class mod_codecompta_digitaria extends ModeleAccountancyCode
$i = 0;
$this->code = '';
$disponibility = 0;
if (is_object($societe))
{
dol_syslog("mod_codecompta_digitaria::get_code search code for type=".$type." & company=".(!empty($societe->name) ? $societe->name : ''));
@ -216,8 +218,7 @@ class mod_codecompta_digitaria extends ModeleAccountancyCode
}
}
if ($disponibility == 0)
{
if ($disponibility == 0) {
return 0; // return ok
} else {
return -1; // return ko

View File

@ -345,7 +345,7 @@ class EcmDirectory extends CommonObject
$sql .= " t.date_c as date_c,";
$sql .= " t.tms as date_m";
$sql .= " FROM ".MAIN_DB_PREFIX."ecm_directories as t";
$sql .= " WHERE t.rowid = ".$id;
$sql .= " WHERE t.rowid = ".((int) $id);
dol_syslog(get_class($this)."::fetch", LOG_DEBUG);
$resql = $this->db->query($sql);

View File

@ -54,7 +54,7 @@ $pagenext = $page + 1;
if (!$sortorder) $sortorder = "ASC";
if (!$sortfield) $sortfield = "name";
$section = GETPOST("section", 'alpha') ?GETPOST("section", 'alpha') : GETPOST("relativedir", 'alpha');
$section = GETPOST("section", 'alpha') ? GETPOST("section", 'alpha') : GETPOST("relativedir", 'alpha');
if (!$section)
{
dol_print_error('', "ErrorSectionParamNotDefined");
@ -66,15 +66,15 @@ $ecmdir = new EcmDirectory($db);
if ($module == 'ecm')
{
// $section should be an int except if it is dir not yet created into EcmDirectory
$result = $ecmdir->fetch($section);
if (!$result > 0)
{
dol_print_error($db, $ecmdir->error);
exit;
if ($result > 0) {
$relativepath = $ecmdir->getRelativePath();
$upload_dir = $conf->ecm->dir_output.'/'.$relativepath;
} else {
$relativepath = $section;
$upload_dir = $conf->ecm->dir_output.'/'.$relativepath;
}
$relativepath = $ecmdir->getRelativePath();
$upload_dir = $conf->ecm->dir_output.'/'.$relativepath;
} else // For example $module == 'medias'
{
$relativepath = $section;
@ -143,28 +143,23 @@ if ($action == 'confirm_deletefile' && $confirm == 'yes')
}
// Remove dir
if ($action == 'confirm_deletedir' && $confirm == 'yes')
{
if ($action == 'confirm_deletedir' && $confirm == 'yes') {
$backtourl = DOL_URL_ROOT."/ecm/index.php";
if ($module == 'medias')
{
if ($module == 'medias') {
$backtourl = DOL_URL_ROOT."/website/index.php?file_manager=1";
}
$deletedirrecursive = (GETPOST('deletedirrecursive', 'alpha') == 'on' ? 1 : 0);
if ($module == 'ecm')
{
if ($module == 'ecm' && $ecmdir->id > 0) { // If manual ECM and directory is indexed into database
// Fetch was already done
$result = $ecmdir->delete($user, 'all', $deletedirrecursive);
if ($result <= 0)
{
if ($result <= 0) {
$langs->load('errors');
setEventMessages($langs->trans($ecmdir->error, $ecmdir->label), null, 'errors');
}
} else {
if ($deletedirrecursive)
{
if ($deletedirrecursive) {
$resbool = dol_delete_dir_recursive($upload_dir, 0, 1);
} else {
$resbool = dol_delete_dir($upload_dir, 1);
@ -176,8 +171,7 @@ if ($action == 'confirm_deletedir' && $confirm == 'yes')
$result = 0;
}
}
if ($result > 0)
{
if ($result > 0) {
header("Location: ".$backtourl);
exit;
}
@ -269,10 +263,9 @@ if ($action == 'update' && !GETPOST('cancel', 'alpha'))
}
/*******************************************************************
* View
********************************************************************/
/*
* View
*/
$form = new Form($db);
@ -281,9 +274,7 @@ $extrafields = new ExtraFields($db);
// fetch optionals attributes and labels
$extrafields->fetch_name_optionals_label($object->table_element);
if ($module == 'ecm')
{
if ($module == 'ecm' && $ecmdir->id > 0) {
$object->fetch($ecmdir->id);
}
@ -323,24 +314,27 @@ if ($module == 'ecm')
$result = 1;
$i = 0;
$tmpecmdir = new EcmDirectory($db); // Need to create a new one
$tmpecmdir->fetch($ecmdir->id);
while ($tmpecmdir && $result > 0)
{
$tmpecmdir->ref = $tmpecmdir->label;
if ($i == 0 && $action == 'edit')
if ($ecmdir->id > 0) {
$tmpecmdir->fetch($ecmdir->id);
while ($tmpecmdir && $result > 0)
{
$s = '<input type="text" name="label" class="minwidth300" maxlength="32" value="'.$tmpecmdir->label.'">';
} else $s = $tmpecmdir->getNomUrl(1).$s;
if ($tmpecmdir->fk_parent)
{
$s = ' -> '.$s;
$result = $tmpecmdir->fetch($tmpecmdir->fk_parent);
} else {
$tmpecmdir = 0;
$tmpecmdir->ref = $tmpecmdir->label;
if ($i == 0 && $action == 'edit')
{
$s = '<input type="text" name="label" class="minwidth300" maxlength="32" value="'.$tmpecmdir->label.'">';
} else $s = $tmpecmdir->getNomUrl(1).$s;
if ($tmpecmdir->fk_parent)
{
$s = ' -> '.$s;
$result = $tmpecmdir->fetch($tmpecmdir->fk_parent);
} else {
$tmpecmdir = 0;
}
$i++;
}
$i++;
} else {
$s .= join(' -> ', explode('/', $section));
}
$morehtmlref = '<a href="'.DOL_URL_ROOT.'/ecm/index.php">'.$langs->trans("ECMRoot").'</a> -> '.$s;
}
if ($module == 'medias')
@ -393,9 +387,11 @@ if ($module == 'ecm')
print '</td></tr>';
print '<tr><td class="titlefield">'.$langs->trans("ECMCreationUser").'</td><td>';
$userecm = new User($db);
$userecm->fetch($ecmdir->fk_user_c);
print $userecm->getNomUrl(1);
if ($ecmdir->fk_user_c > 0) {
$userecm = new User($db);
$userecm->fetch($ecmdir->fk_user_c);
print $userecm->getNomUrl(1);
}
print '</td></tr>';
}
print '<tr><td class="titlefield">'.$langs->trans("ECMCreationDate").'</td><td>';

View File

@ -6125,7 +6125,7 @@ class wsdl extends nusoap_base {
$rows = sizeof($value);
$contents = '';
foreach($value as $k => $v) {
$this->debug("serializing array element: $k, $v of type: $typeDef[arrayType]");
$this->debug("serializing array element: $k of type: ".$typeDef['arrayType']);
//if (strpos($typeDef['arrayType'], ':') ) {
if (!in_array($typeDef['arrayType'],$this->typemap['http://www.w3.org/2001/XMLSchema'])) {
$contents .= $this->serializeType('item', $typeDef['arrayType'], $v, $use);

View File

@ -41,7 +41,7 @@ CREATE TABLE llx_accounting_bookkeeping
multicurrency_code varchar(255), -- FEC:Idevise
lettering_code varchar(255), -- FEC:EcritureLet
date_lettering datetime, -- FEC:DateLet
date_lim_reglement datetime DEFAULT NULL, -- | date limite de reglement
date_lim_reglement datetime DEFAULT NULL, -- FEC_suppl:DateLimitReglmt | payment deadline
fk_user_author integer NOT NULL, -- | user creating
fk_user_modif integer, -- | user making last change
date_creation datetime, -- FEC:EcritureDate | creation date

View File

@ -2395,7 +2395,7 @@ class Product extends CommonObject
public function load_stats_mo($socid = 0)
{
// phpcs:enable
global $user, $hookmanager;
global $user, $hookmanager, $action;
$error = 0;
@ -2408,7 +2408,7 @@ class Product extends CommonObject
$sql .= " SUM(mp.qty) as qty";
$sql .= " FROM ".MAIN_DB_PREFIX."mrp_mo as c";
$sql .= " INNER JOIN ".MAIN_DB_PREFIX."mrp_production as mp ON mp.fk_mo=c.rowid";
if (!$user->rights->societe->client->voir && !$socid) {
if (empty($user->rights->societe->client->voir) && !$socid) {
$sql .= "INNER JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON sc.fk_soc=c.fk_soc AND sc.fk_user = ".$user->id;
}
$sql .= " WHERE ";
@ -2527,14 +2527,14 @@ class Product extends CommonObject
$sql .= " FROM ".MAIN_DB_PREFIX."propaldet as pd";
$sql .= ", ".MAIN_DB_PREFIX."propal as p";
$sql .= ", ".MAIN_DB_PREFIX."societe as s";
if (!$user->rights->societe->client->voir && !$socid) {
if (empty($user->rights->societe->client->voir) && !$socid) {
$sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
}
$sql .= " WHERE p.rowid = pd.fk_propal";
$sql .= " AND p.fk_soc = s.rowid";
$sql .= " AND p.entity IN (".getEntity('propal').")";
$sql .= " AND pd.fk_product = ".$this->id;
if (!$user->rights->societe->client->voir && !$socid) {
if (empty($user->rights->societe->client->voir) && !$socid) {
$sql .= " AND p.fk_soc = sc.fk_soc AND sc.fk_user = ".$user->id;
}
//$sql.= " AND pr.fk_statut != 0";
@ -2593,23 +2593,26 @@ class Product extends CommonObject
public function load_stats_proposal_supplier($socid = 0)
{
// phpcs:enable
global $conf, $user, $hookmanager;
global $conf, $user, $hookmanager, $action;
$sql = "SELECT COUNT(DISTINCT p.fk_soc) as nb_suppliers, COUNT(DISTINCT p.rowid) as nb,";
$sql .= " COUNT(pd.rowid) as nb_rows, SUM(pd.qty) as qty";
$sql .= " FROM ".MAIN_DB_PREFIX."supplier_proposaldet as pd";
$sql .= ", ".MAIN_DB_PREFIX."supplier_proposal as p";
$sql .= ", ".MAIN_DB_PREFIX."societe as s";
if (!$user->rights->societe->client->voir && !$socid) { $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
if (empty($user->rights->societe->client->voir) && !$socid) {
$sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
}
$sql .= " WHERE p.rowid = pd.fk_supplier_proposal";
$sql .= " AND p.fk_soc = s.rowid";
$sql .= " AND p.entity IN (".getEntity('supplier_proposal').")";
$sql .= " AND pd.fk_product = ".$this->id;
if (!$user->rights->societe->client->voir && !$socid) { $sql .= " AND p.fk_soc = sc.fk_soc AND sc.fk_user = ".$user->id;
if (empty($user->rights->societe->client->voir) && !$socid) {
$sql .= " AND p.fk_soc = sc.fk_soc AND sc.fk_user = ".$user->id;
}
//$sql.= " AND pr.fk_statut != 0";
if ($socid > 0) { $sql .= " AND p.fk_soc = ".$socid;
if ($socid > 0) {
$sql .= " AND p.fk_soc = ".$socid;
}
$result = $this->db->query($sql);
@ -2665,7 +2668,7 @@ class Product extends CommonObject
$sql .= " AND c.fk_soc = ".$socid;
}
if ($filtrestatut <> '') {
$sql .= " AND c.fk_statut in (".$filtrestatut.")";
$sql .= " AND c.fk_statut in (".$this->db->sanitize($filtrestatut).")";
}
$result = $this->db->query($sql);
@ -2744,28 +2747,28 @@ class Product extends CommonObject
public function load_stats_commande_fournisseur($socid = 0, $filtrestatut = '', $forVirtualStock = 0)
{
// phpcs:enable
global $conf, $user, $hookmanager;
global $conf, $user, $hookmanager, $action;
$sql = "SELECT COUNT(DISTINCT c.fk_soc) as nb_suppliers, COUNT(DISTINCT c.rowid) as nb,";
$sql .= " COUNT(cd.rowid) as nb_rows, SUM(cd.qty) as qty";
$sql .= " FROM ".MAIN_DB_PREFIX."commande_fournisseurdet as cd";
$sql .= ", ".MAIN_DB_PREFIX."commande_fournisseur as c";
$sql .= ", ".MAIN_DB_PREFIX."societe as s";
if (!$user->rights->societe->client->voir && !$socid && !$forVirtualStock) {
if (empty($user->rights->societe->client->voir) && !$socid && !$forVirtualStock) {
$sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
}
$sql .= " WHERE c.rowid = cd.fk_commande";
$sql .= " AND c.fk_soc = s.rowid";
$sql .= " AND c.entity IN (".getEntity($forVirtualStock && !empty($conf->global->STOCK_CALCULATE_VIRTUAL_STOCK_TRANSVERSE_MODE) ? 'stock' : 'supplier_order').")";
$sql .= " AND cd.fk_product = ".$this->id;
if (!$user->rights->societe->client->voir && !$socid && !$forVirtualStock) {
if (empty($user->rights->societe->client->voir) && !$socid && !$forVirtualStock) {
$sql .= " AND c.fk_soc = sc.fk_soc AND sc.fk_user = ".$user->id;
}
if ($socid > 0) {
$sql .= " AND c.fk_soc = ".$socid;
}
if ($filtrestatut != '') {
$sql .= " AND c.fk_statut in (".$filtrestatut.")"; // Peut valoir 0
$sql .= " AND c.fk_statut in (".$this->db->sanitize($filtrestatut).")"; // Peut valoir 0
}
$result = $this->db->query($sql);
@ -2809,7 +2812,7 @@ class Product extends CommonObject
$sql .= ", ".MAIN_DB_PREFIX."commande as c";
$sql .= ", ".MAIN_DB_PREFIX."expedition as e";
$sql .= ", ".MAIN_DB_PREFIX."societe as s";
if (!$user->rights->societe->client->voir && !$socid && !$forVirtualStock) {
if (empty($user->rights->societe->client->voir) && !$socid && !$forVirtualStock) {
$sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
}
$sql .= " WHERE e.rowid = ed.fk_expedition";
@ -2818,16 +2821,16 @@ class Product extends CommonObject
$sql .= " AND e.entity IN (".getEntity($forVirtualStock && !empty($conf->global->STOCK_CALCULATE_VIRTUAL_STOCK_TRANSVERSE_MODE) ? 'stock' : 'expedition').")";
$sql .= " AND ed.fk_origin_line = cd.rowid";
$sql .= " AND cd.fk_product = ".$this->id;
if (!$user->rights->societe->client->voir && !$socid && !$forVirtualStock) {
if (empty($user->rights->societe->client->voir) && !$socid && !$forVirtualStock) {
$sql .= " AND e.fk_soc = sc.fk_soc AND sc.fk_user = ".$user->id;
}
if ($socid > 0) {
$sql .= " AND e.fk_soc = ".$socid;
}
if ($filtrestatut <> '') {
$sql .= " AND c.fk_statut in (".$filtrestatut.")";
$sql .= " AND c.fk_statut IN (".$this->db->sanitize($filtrestatut).")";
}
if (!empty($filterShipmentStatus)) $sql .= " AND e.fk_statut IN (".$filterShipmentStatus.")";
if (!empty($filterShipmentStatus)) $sql .= " AND e.fk_statut IN (".$this->db->sanitize($filterShipmentStatus).")";
$result = $this->db->query($sql);
if ($result) {
@ -2881,24 +2884,28 @@ class Product extends CommonObject
public function load_stats_reception($socid = 0, $filtrestatut = '', $forVirtualStock = 0)
{
// phpcs:enable
global $conf, $user, $hookmanager;
global $conf, $user, $hookmanager, $action;
$sql = "SELECT COUNT(DISTINCT cf.fk_soc) as nb_suppliers, COUNT(DISTINCT cf.rowid) as nb,";
$sql .= " COUNT(fd.rowid) as nb_rows, SUM(fd.qty) as qty";
$sql .= " FROM ".MAIN_DB_PREFIX."commande_fournisseur_dispatch as fd";
$sql .= ", ".MAIN_DB_PREFIX."commande_fournisseur as cf";
$sql .= ", ".MAIN_DB_PREFIX."societe as s";
if (!$user->rights->societe->client->voir && !$socid && !$forVirtualStock) { $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
if (empty($user->rights->societe->client->voir) && !$socid && !$forVirtualStock) {
$sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
}
$sql .= " WHERE cf.rowid = fd.fk_commande";
$sql .= " AND cf.fk_soc = s.rowid";
$sql .= " AND cf.entity IN (".getEntity($forVirtualStock && !empty($conf->global->STOCK_CALCULATE_VIRTUAL_STOCK_TRANSVERSE_MODE) ? 'stock' : 'supplier_order').")";
$sql .= " AND fd.fk_product = ".$this->id;
if (!$user->rights->societe->client->voir && !$socid && !$forVirtualStock) { $sql .= " AND cf.fk_soc = sc.fk_soc AND sc.fk_user = ".$user->id;
if (empty($user->rights->societe->client->voir) && !$socid && !$forVirtualStock) {
$sql .= " AND cf.fk_soc = sc.fk_soc AND sc.fk_user = ".$user->id;
}
if ($socid > 0) { $sql .= " AND cf.fk_soc = ".$socid;
if ($socid > 0) {
$sql .= " AND cf.fk_soc = ".$socid;
}
if ($filtrestatut <> '') { $sql .= " AND cf.fk_statut in (".$filtrestatut.")";
if ($filtrestatut <> '') {
$sql .= " AND cf.fk_statut IN (".$this->db->sanitize($filtrestatut).")";
}
$result = $this->db->query($sql);
@ -2939,20 +2946,20 @@ class Product extends CommonObject
$sql .= " FROM ".MAIN_DB_PREFIX."mrp_production as mp";
$sql .= ", ".MAIN_DB_PREFIX."mrp_mo as m";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = m.fk_soc";
if (!$user->rights->societe->client->voir && !$socid && !$forVirtualStock) {
if (empty($user->rights->societe->client->voir) && !$socid && !$forVirtualStock) {
$sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
}
$sql .= " WHERE m.rowid = mp.fk_mo";
$sql .= " AND m.entity IN (".getEntity($forVirtualStock && !empty($conf->global->STOCK_CALCULATE_VIRTUAL_STOCK_TRANSVERSE_MODE) ? 'stock' : 'mrp').")";
$sql .= " AND mp.fk_product = ".$this->id;
if (!$user->rights->societe->client->voir && !$socid && !$forVirtualStock) {
if (empty($user->rights->societe->client->voir) && !$socid && !$forVirtualStock) {
$sql .= " AND m.fk_soc = sc.fk_soc AND sc.fk_user = ".$user->id;
}
if ($socid > 0) {
$sql .= " AND m.fk_soc = ".$socid;
}
if ($filtrestatut <> '') {
$sql .= " AND m.status in (".$filtrestatut.")";
$sql .= " AND m.status IN (".$this->db->sanitize($filtrestatut).")";
}
$sql .= " GROUP BY role";
@ -3026,14 +3033,14 @@ class Product extends CommonObject
$sql .= " FROM ".MAIN_DB_PREFIX."contratdet as cd";
$sql .= ", ".MAIN_DB_PREFIX."contrat as c";
$sql .= ", ".MAIN_DB_PREFIX."societe as s";
if (!$user->rights->societe->client->voir && !$socid) {
if (empty($user->rights->societe->client->voir) && !$socid) {
$sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
}
$sql .= " WHERE c.rowid = cd.fk_contrat";
$sql .= " AND c.fk_soc = s.rowid";
$sql .= " AND c.entity IN (".getEntity('contract').")";
$sql .= " AND cd.fk_product = ".$this->id;
if (!$user->rights->societe->client->voir && !$socid) {
if (empty($user->rights->societe->client->voir) && !$socid) {
$sql .= " AND c.fk_soc = sc.fk_soc AND sc.fk_user = ".$user->id;
}
//$sql.= " AND c.statut != 0";
@ -3098,14 +3105,14 @@ class Product extends CommonObject
$sql .= " FROM ".MAIN_DB_PREFIX."facturedet as fd";
$sql .= ", ".MAIN_DB_PREFIX."facture as f";
$sql .= ", ".MAIN_DB_PREFIX."societe as s";
if (!$user->rights->societe->client->voir && !$socid) {
if (empty($user->rights->societe->client->voir) && !$socid) {
$sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
}
$sql .= " WHERE f.rowid = fd.fk_facture";
$sql .= " AND f.fk_soc = s.rowid";
$sql .= " AND f.entity IN (".getEntity('invoice').")";
$sql .= " AND fd.fk_product = ".$this->id;
if (!$user->rights->societe->client->voir && !$socid) {
if (empty($user->rights->societe->client->voir) && !$socid) {
$sql .= " AND f.fk_soc = sc.fk_soc AND sc.fk_user = ".$user->id;
}
//$sql.= " AND f.fk_statut != 0";
@ -3163,21 +3170,21 @@ class Product extends CommonObject
public function load_stats_facture_fournisseur($socid = 0)
{
// phpcs:enable
global $conf, $user, $hookmanager;
global $conf, $user, $hookmanager, $action;
$sql = "SELECT COUNT(DISTINCT f.fk_soc) as nb_suppliers, COUNT(DISTINCT f.rowid) as nb,";
$sql .= " COUNT(fd.rowid) as nb_rows, SUM(fd.qty) as qty";
$sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn_det as fd";
$sql .= ", ".MAIN_DB_PREFIX."facture_fourn as f";
$sql .= ", ".MAIN_DB_PREFIX."societe as s";
if (!$user->rights->societe->client->voir && !$socid) {
if (empty($user->rights->societe->client->voir) && !$socid) {
$sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
}
$sql .= " WHERE f.rowid = fd.fk_facture_fourn";
$sql .= " AND f.fk_soc = s.rowid";
$sql .= " AND f.entity IN (".getEntity('facture_fourn').")";
$sql .= " AND fd.fk_product = ".$this->id;
if (!$user->rights->societe->client->voir && !$socid) {
if (empty($user->rights->societe->client->voir) && !$socid) {
$sql .= " AND f.fk_soc = sc.fk_soc AND sc.fk_user = ".$user->id;
}
//$sql.= " AND f.fk_statut != 0";
@ -3302,7 +3309,7 @@ class Product extends CommonObject
if ($filteronproducttype >= 0) {
$sql .= ", ".MAIN_DB_PREFIX."product as p";
}
if (!$user->rights->societe->client->voir && !$socid) {
if (empty($user->rights->societe->client->voir) && !$socid) {
$sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
}
$sql .= " WHERE f.rowid = d.fk_facture";
@ -3312,11 +3319,11 @@ class Product extends CommonObject
$sql .= " AND d.fk_product > 0";
}
if ($filteronproducttype >= 0) {
$sql .= " AND p.rowid = d.fk_product AND p.fk_product_type =".$filteronproducttype;
$sql .= " AND p.rowid = d.fk_product AND p.fk_product_type = ".((int) $filteronproducttype);
}
$sql .= " AND f.fk_soc = s.rowid";
$sql .= " AND f.entity IN (".getEntity('invoice').")";
if (!$user->rights->societe->client->voir && !$socid) {
if (empty($user->rights->societe->client->voir) && !$socid) {
$sql .= " AND f.fk_soc = sc.fk_soc AND sc.fk_user = ".$user->id;
}
if ($socid > 0) {
@ -3355,7 +3362,7 @@ class Product extends CommonObject
if ($filteronproducttype >= 0) {
$sql .= ", ".MAIN_DB_PREFIX."product as p";
}
if (!$user->rights->societe->client->voir && !$socid) {
if (empty($user->rights->societe->client->voir) && !$socid) {
$sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
}
$sql .= " WHERE f.rowid = d.fk_facture_fourn";
@ -3365,11 +3372,11 @@ class Product extends CommonObject
$sql .= " AND d.fk_product > 0";
}
if ($filteronproducttype >= 0) {
$sql .= " AND p.rowid = d.fk_product AND p.fk_product_type =".$filteronproducttype;
$sql .= " AND p.rowid = d.fk_product AND p.fk_product_type = ".((int) $filteronproducttype);
}
$sql .= " AND f.fk_soc = s.rowid";
$sql .= " AND f.entity IN (".getEntity('facture_fourn').")";
if (!$user->rights->societe->client->voir && !$socid) {
if (empty($user->rights->societe->client->voir) && !$socid) {
$sql .= " AND f.fk_soc = sc.fk_soc AND sc.fk_user = ".$user->id;
}
if ($socid > 0) {
@ -3406,7 +3413,7 @@ class Product extends CommonObject
if ($filteronproducttype >= 0) {
$sql .= ", ".MAIN_DB_PREFIX."product as prod";
}
if (!$user->rights->societe->client->voir && !$socid) {
if (empty($user->rights->societe->client->voir) && !$socid) {
$sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
}
$sql .= " WHERE p.rowid = d.fk_propal";
@ -3416,11 +3423,11 @@ class Product extends CommonObject
$sql .= " AND d.fk_product > 0";
}
if ($filteronproducttype >= 0) {
$sql .= " AND prod.rowid = d.fk_product AND prod.fk_product_type =".$filteronproducttype;
$sql .= " AND prod.rowid = d.fk_product AND prod.fk_product_type = ".((int) $filteronproducttype);
}
$sql .= " AND p.fk_soc = s.rowid";
$sql .= " AND p.entity IN (".getEntity('propal').")";
if (!$user->rights->societe->client->voir && !$socid) {
if (empty($user->rights->societe->client->voir) && !$socid) {
$sql .= " AND p.fk_soc = sc.fk_soc AND sc.fk_user = ".$user->id;
}
if ($socid > 0) {
@ -3458,7 +3465,7 @@ class Product extends CommonObject
if ($filteronproducttype >= 0) {
$sql .= ", ".MAIN_DB_PREFIX."product as prod";
}
if (!$user->rights->societe->client->voir && !$socid) {
if (empty($user->rights->societe->client->voir) && !$socid) {
$sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
}
$sql .= " WHERE p.rowid = d.fk_supplier_proposal";
@ -3468,11 +3475,11 @@ class Product extends CommonObject
$sql .= " AND d.fk_product > 0";
}
if ($filteronproducttype >= 0) {
$sql .= " AND prod.rowid = d.fk_product AND prod.fk_product_type =".$filteronproducttype;
$sql .= " AND prod.rowid = d.fk_product AND prod.fk_product_type = ".((int) $filteronproducttype);
}
$sql .= " AND p.fk_soc = s.rowid";
$sql .= " AND p.entity IN (".getEntity('supplier_proposal').")";
if (!$user->rights->societe->client->voir && !$socid) {
if (empty($user->rights->societe->client->voir) && !$socid) {
$sql .= " AND p.fk_soc = sc.fk_soc AND sc.fk_user = ".$user->id;
}
if ($socid > 0) {
@ -3509,7 +3516,7 @@ class Product extends CommonObject
if ($filteronproducttype >= 0) {
$sql .= ", ".MAIN_DB_PREFIX."product as p";
}
if (!$user->rights->societe->client->voir && !$socid) {
if (empty($user->rights->societe->client->voir) && !$socid) {
$sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
}
$sql .= " WHERE c.rowid = d.fk_commande";
@ -3519,11 +3526,11 @@ class Product extends CommonObject
$sql .= " AND d.fk_product > 0";
}
if ($filteronproducttype >= 0) {
$sql .= " AND p.rowid = d.fk_product AND p.fk_product_type =".$filteronproducttype;
$sql .= " AND p.rowid = d.fk_product AND p.fk_product_type = ".((int) $filteronproducttype);
}
$sql .= " AND c.fk_soc = s.rowid";
$sql .= " AND c.entity IN (".getEntity('commande').")";
if (!$user->rights->societe->client->voir && !$socid) {
if (empty($user->rights->societe->client->voir) && !$socid) {
$sql .= " AND c.fk_soc = sc.fk_soc AND sc.fk_user = ".$user->id;
}
if ($socid > 0) {
@ -3560,7 +3567,7 @@ class Product extends CommonObject
if ($filteronproducttype >= 0) {
$sql .= ", ".MAIN_DB_PREFIX."product as p";
}
if (!$user->rights->societe->client->voir && !$socid) {
if (empty($user->rights->societe->client->voir) && !$socid) {
$sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
}
$sql .= " WHERE c.rowid = d.fk_commande";
@ -3570,11 +3577,11 @@ class Product extends CommonObject
$sql .= " AND d.fk_product > 0";
}
if ($filteronproducttype >= 0) {
$sql .= " AND p.rowid = d.fk_product AND p.fk_product_type =".$filteronproducttype;
$sql .= " AND p.rowid = d.fk_product AND p.fk_product_type = ".((int) $filteronproducttype);
}
$sql .= " AND c.fk_soc = s.rowid";
$sql .= " AND c.entity IN (".getEntity('supplier_order').")";
if (!$user->rights->societe->client->voir && !$socid) {
if (empty($user->rights->societe->client->voir) && !$socid) {
$sql .= " AND c.fk_soc = sc.fk_soc AND sc.fk_user = ".$user->id;
}
if ($socid > 0) {
@ -3611,7 +3618,7 @@ class Product extends CommonObject
if ($filteronproducttype >= 0) {
$sql .= ", ".MAIN_DB_PREFIX."product as p";
}
if (!$user->rights->societe->client->voir && !$socid) {
if (empty($user->rights->societe->client->voir) && !$socid) {
$sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
}
@ -3624,11 +3631,11 @@ class Product extends CommonObject
$sql .= " AND d.fk_product > 0";
}
if ($filteronproducttype >= 0) {
$sql .= " AND p.rowid = d.fk_product AND p.fk_product_type =".$filteronproducttype;
$sql .= " AND p.rowid = d.fk_product AND p.fk_product_type = ".((int) $filteronproducttype);
}
$sql .= " AND c.fk_soc = s.rowid";
if (!$user->rights->societe->client->voir && !$socid) {
if (empty($user->rights->societe->client->voir) && !$socid) {
$sql .= " AND c.fk_soc = sc.fk_soc AND sc.fk_user = ".$user->id;
}
if ($socid > 0) {
@ -3665,7 +3672,7 @@ class Product extends CommonObject
if ($filteronproducttype >= 0) {
$sql .= ", ".MAIN_DB_PREFIX."product as p";
}
if (!$user->rights->societe->client->voir && !$socid) {
if (empty($user->rights->societe->client->voir) && !$socid) {
$sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
}
@ -3678,10 +3685,10 @@ class Product extends CommonObject
$sql .= " AND d.fk_product > 0";
}
if ($filteronproducttype >= 0) {
$sql .= " AND p.rowid = d.fk_product AND p.fk_product_type =".$filteronproducttype;
$sql .= " AND p.rowid = d.fk_product AND p.fk_product_type = ".((int) $filteronproducttype);
}
if (!$user->rights->societe->client->voir && !$socid) {
if (empty($user->rights->societe->client->voir) && !$socid) {
$sql .= " AND d.fk_soc = sc.fk_soc AND sc.fk_user = ".$user->id;
}
if ($socid > 0) {

View File

@ -533,9 +533,6 @@ if ($resql)
//'builddoc'=>$langs->trans("PDFMerge"),
//'presend'=>$langs->trans("SendByMail"),
);
$rightskey = 'produit';
if ($type == Product::TYPE_SERVICE) $rightskey = 'service';
if ($user->rights->{$rightskey}->supprimer) $arrayofmassactions['predelete'] = "<span class='fa fa-trash paddingrightonly'></span>".$langs->trans("Delete");
if (in_array($massaction, array('presend', 'predelete'))) $arrayofmassactions = array();
$massactionbutton = $form->selectMassAction('', $arrayofmassactions);

View File

@ -109,7 +109,7 @@ if ($object->id > 0) {
$permissiontoread = $user->rights->societe->lire;
$permissiontoadd = $user->rights->societe->creer; // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php
$permissiontodelete = $user->rights->societe->delete || ($permissiontoadd && isset($object->status) && $object->status == 0);
$permissiontodelete = $user->rights->societe->supprimer || ($permissiontoadd && isset($object->status) && $object->status == 0);
$permissionnote = $user->rights->societe->creer; // Used by the include of actions_setnotes.inc.php
$permissiondellink = $user->rights->societe->creer; // Used by the include of actions_dellink.inc.php
$upload_dir = $conf->societe->multidir_output[isset($object->entity) ? $object->entity : 1];
@ -1355,7 +1355,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action))
print '<td'.($conf->browser->layout == 'phone' ? ' colspan="3"' : '').'>'.img_picto('', 'object_phoning_fax').' <input type="text" name="fax" id="fax" class="maxwidth200 widthcentpercentminusx" value="'.(GETPOSTISSET('fax') ?GETPOST('fax', 'alpha') : $object->fax).'"></td></tr>';
// Email / Web
print '<tr><td>'.$form->editfieldkey('EMail', 'email', '', $object, 0, 'string', '', $conf->global->SOCIETE_EMAIL_MANDATORY).'</td>';
print '<tr><td>'.$form->editfieldkey('EMail', 'email', '', $object, 0, 'string', '', empty($conf->global->SOCIETE_EMAIL_MANDATORY) ? '' : $conf->global->SOCIETE_EMAIL_MANDATORY).'</td>';
print '<td colspan="3">'.img_picto('', 'object_email').' <input type="text" class="maxwidth500 widthcentpercentminusx" name="email" id="email" value="'.$object->email.'"></td></tr>';
print '<tr><td>'.$form->editfieldkey('Web', 'url', '', $object, 0).'</td>';
print '<td colspan="3">'.img_picto('', 'globe').' <input type="text" class="maxwidth500 widthcentpercentminusx" name="url" id="url" value="'.$object->url.'"></td></tr>';
@ -1366,7 +1366,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action))
print '<tr>';
print '<td><label for="'.$value['label'].'">'.$form->editfieldkey($value['label'], $key, '', $object, 0).'</label></td>';
print '<td colspan="3">';
print '<input type="text" name="'.$key.'" id="'.$key.'" class="minwidth100" maxlength="80" value="'.dol_escape_htmltag(GETPOSTISSET($key) ?GETPOST($key, 'alphanohtml') : $object->socialnetworks[$key]).'">';
print '<input type="text" name="'.$key.'" id="'.$key.'" class="minwidth100" maxlength="80" value="'.dol_escape_htmltag(GETPOSTISSET($key) ? GETPOST($key, 'alphanohtml') : (empty($object->socialnetworks[$key]) ? '' : $object->socialnetworks[$key])).'">';
print '</td>';
print '</tr>';
} elseif (!empty($object->socialnetworks[$key])) {

File diff suppressed because it is too large Load Diff

View File

@ -35,7 +35,7 @@
--oddevencolor: #202020;
--colorboxstatsborder: #e0e0e0;
--dolgraphbg: rgba(255,255,255,0);
--fieldrequiredcolor: #804000;
--fieldrequiredcolor: #700040;
--colortextbacktab: #<?php print $colortextbacktab; ?>;
--colorboxiconbg: #eee;
--refidnocolor:#444;

View File

@ -2418,6 +2418,7 @@ class User extends CommonObject
}
$result = ''; $label = '';
$companylink = '';
if (!empty($this->photo)) {
$label .= '<div class="photointooltip">';

View File

@ -288,7 +288,7 @@ $server->register(
*/
function getInvoice($authentication, $id = '', $ref = '', $ref_ext = '')
{
global $db, $conf, $langs;
global $db, $conf;
dol_syslog("Function: getInvoice login=".$authentication['login']." id=".$id." ref=".$ref." ref_ext=".$ref_ext);
@ -363,7 +363,7 @@ function getInvoice($authentication, $id = '', $ref = '', $ref_ext = '')
'note_private' => $invoice->note_private ? $invoice->note_private : '',
'note_public' => $invoice->note_public ? $invoice->note_public : '',
'status' => $invoice->statut,
'project_id' => $invoic->fk_project,
'project_id' => $invoice->fk_project,
'close_code' => $invoice->close_code ? $invoice->close_code : '',
'close_note' => $invoice->close_note ? $invoice->close_note : '',
'payment_mode_id' => $invoice->mode_reglement_id ? $invoice->mode_reglement_id : '',
@ -399,7 +399,7 @@ function getInvoice($authentication, $id = '', $ref = '', $ref_ext = '')
*/
function getInvoicesForThirdParty($authentication, $idthirdparty)
{
global $db, $conf, $langs;
global $db, $conf;
dol_syslog("Function: getInvoicesForThirdParty login=".$authentication['login']." idthirdparty=".$idthirdparty);
@ -482,7 +482,7 @@ function getInvoicesForThirdParty($authentication, $idthirdparty)
'fk_user_valid' => $invoice->user_valid ? $invoice->user_valid : '',
'date' => $invoice->date ?dol_print_date($invoice->date, 'dayrfc') : '',
'date_due' => $invoice->date_lim_reglement ?dol_print_date($invoice->date_lim_reglement, 'dayrfc') : '',
'date_creation' => $invoice->date_creation ?dol_print_date($invoice->date_creation, 'dayhourrfc') : '',
'date_creation' => $invoice->date_creation ?dol_print_date($invoice->date_creation, 'dayhourrfc') : '',
'date_validation' => $invoice->date_validation ?dol_print_date($invoice->date_creation, 'dayhourrfc') : '',
'date_modification' => $invoice->datem ?dol_print_date($invoice->datem, 'dayhourrfc') : '',
'type' => $invoice->type,
@ -492,7 +492,7 @@ function getInvoicesForThirdParty($authentication, $idthirdparty)
'note_private' => $invoice->note_private ? $invoice->note_private : '',
'note_public' => $invoice->note_public ? $invoice->note_public : '',
'status'=> $invoice->statut,
'project_id' => $invoic->fk_project,
'project_id' => $invoice->fk_project,
'close_code' => $invoice->close_code ? $invoice->close_code : '',
'close_note' => $invoice->close_note ? $invoice->close_note : '',
'payment_mode_id' => $invoice->mode_reglement_id ? $invoice->mode_reglement_id : '',
@ -528,17 +528,16 @@ function getInvoicesForThirdParty($authentication, $idthirdparty)
* Create an invoice
*
* @param array $authentication Array of authentication information
* @param Facture $invoice Invoice
* @param array $invoice Invoice
* @return array Array result
*/
function createInvoice($authentication, $invoice)
{
global $db, $conf, $langs;
global $db, $conf;
$now = dol_now();
dol_syslog("Function: createInvoice login=".$authentication['login']." id=".$invoice->id.
", ref=".$invoice->ref.", ref_ext=".$invoice->ref_ext);
dol_syslog("Function: createInvoice login=".$authentication['login']." id=".$invoice['id'].", ref=".$invoice['ref'].", ref_ext=".$invoice['ref_ext']);
if ($authentication['entity']) $conf->entity = $authentication['entity'];
@ -580,22 +579,22 @@ function createInvoice($authentication, $invoice)
if (isset($invoice['lines']['line'][0])) $arrayoflines = $invoice['lines']['line'];
else $arrayoflines = $invoice['lines'];
foreach ($arrayoflines as $key => $line)
foreach ($arrayoflines as $line)
{
// $key can be 'line' or '0','1',...
$newline = new FactureLigne($db);
$newline->product_type = $line['type'];
$newline->desc = $line['desc'];
$newline->fk_product = $line['fk_product'];
$newline->tva_tx = $line['vat_rate'];
$newline->fk_product = $line['product_id'];
$newline->tva_tx = isset($line['vat_rate']) ? $line['vat_rate'] : 0;
$newline->qty = $line['qty'];
$newline->subprice = $line['unitprice'];
$newline->subprice = isset($line['unitprice']) ? $line['unitprice'] : null;
$newline->total_ht = $line['total_net'];
$newline->total_tva = $line['total_vat'];
$newline->total_ttc = $line['total'];
$newline->date_start = dol_stringtotime($line['date_start']);
$newline->date_end = dol_stringtotime($line['date_end']);
$newline->fk_product = $line['product_id'];
$new_invoice->lines[] = $newline;
}
//var_dump($newobject->date_lim_reglement); exit;
@ -654,10 +653,7 @@ function createInvoiceFromOrder($authentication, $id_order = '', $ref_order = ''
{
global $db, $conf;
$now = dol_now();
dol_syslog("Function: createInvoiceFromOrder login=".$authentication['login']." id=".$id_order.
", ref=".$ref_order.", ref_ext=".$ref_ext_order);
dol_syslog("Function: createInvoiceFromOrder login=".$authentication['login']." id=".$id_order.", ref=".$ref_order.", ref_ext=".$ref_ext_order);
if ($authentication['entity']) $conf->entity = $authentication['entity'];
@ -781,12 +777,11 @@ function updateInvoice($authentication, $invoice)
$object->generateDocument($object->model_pdf, $outputlangs);
}
}
if ($invoice['status'] == Facture::STATUS_CLOSED)
{
$result = $object->set_paid($fuser, $invoice->close_code, $invoice->close_note);
if ($invoice['status'] == Facture::STATUS_CLOSED) {
$result = $object->set_paid($fuser, $invoice['close_code'], $invoice['close_note']);
}
if ($invoice['status'] == Facture::STATUS_ABANDONED)
$result = $object->set_canceled($fuser, $invoice->close_code, $invoice->close_note);
$result = $object->set_canceled($fuser, $invoice['close_code'], $invoice['close_note']);
}
}

View File

@ -354,7 +354,7 @@ $server->register(
*/
function getOrder($authentication, $id = '', $ref = '', $ref_ext = '')
{
global $db, $conf, $langs;
global $db, $conf;
dol_syslog("Function: getOrder login=".$authentication['login']." id=".$id." ref=".$ref." ref_ext=".$ref_ext);
@ -504,7 +504,7 @@ function getOrder($authentication, $id = '', $ref = '', $ref_ext = '')
*/
function getOrdersForThirdParty($authentication, $idthirdparty)
{
global $db, $conf, $langs;
global $db, $conf;
dol_syslog("Function: getOrdersForThirdParty login=".$authentication['login']." idthirdparty=".$idthirdparty);
@ -707,7 +707,7 @@ function createOrder($authentication, $order)
$extrafields->fetch_name_optionals_label($elementtype, true);
if (isset($extrafields->attributes[$elementtype]['label']) && is_array($extrafields->attributes[$elementtype]['label']) && count($extrafields->attributes[$elementtype]['label']))
{
foreach ($extrafields->attributes[$elementtype]['label'] as $key=>$label)
foreach ($extrafields->attributes[$elementtype]['label'] as $key => $label)
{
$key = 'options_'.$key;
$newobject->array_options[$key] = $order[$key];
@ -813,7 +813,7 @@ function validOrder($authentication, $id = '', $id_warehouse = 0)
{
global $db, $conf, $langs;
dol_syslog("Function: validOrder login=".$authentication['login']." id=".$id." ref=".$ref." ref_ext=".$ref_ext);
dol_syslog("Function: validOrder login=".$authentication['login']." id=".$id." id_warehouse=".$id_warehouse);
// Init and check authentication
$objectresp = array();
@ -830,7 +830,7 @@ function validOrder($authentication, $id = '', $id_warehouse = 0)
if ($fuser->rights->commande->lire)
{
$order = new Commande($db);
$result = $order->fetch($id, $ref, $ref_ext);
$result = $order->fetch($id);
$order->fetch_thirdparty();
$db->begin();
@ -889,8 +889,6 @@ function updateOrder($authentication, $order)
{
global $db, $conf, $langs;
$now = dol_now();
dol_syslog("Function: updateOrder login=".$authentication['login']);
if ($authentication['entity']) $conf->entity = $authentication['entity'];
@ -950,7 +948,7 @@ function updateOrder($authentication, $order)
$extrafields->fetch_name_optionals_label($elementtype, true);
if (isset($extrafields->attributes[$elementtype]['label']) && is_array($extrafields->attributes[$elementtype]['label']) && count($extrafields->attributes[$elementtype]['label']))
{
foreach ($extrafields->attributes[$elementtype]['label'] as $key=>$label)
foreach ($extrafields->attributes[$elementtype]['label'] as $key => $label)
{
$key = 'options_'.$key;
if (isset($order[$key]))

View File

@ -145,7 +145,7 @@ $server->register(
*/
function getVersions($authentication)
{
global $db, $conf, $langs;
global $conf;
dol_syslog("Function: getVersions login=".$authentication['login']);
@ -188,7 +188,7 @@ function getVersions($authentication)
*/
function getDocument($authentication, $modulepart, $file, $refname = '')
{
global $db, $conf, $langs, $mysoc;
global $db, $conf;
dol_syslog("Function: getDocument login=".$authentication['login'].' - modulepart='.$modulepart.' - file='.$file);
@ -283,10 +283,7 @@ function getDocument($authentication, $modulepart, $file, $refname = '')
{
if (file_exists($original_file))
{
dol_syslog("Function: getDocument $original_file $filename content-type=$type");
$file = $fileparams['fullname'];
$filename = basename($file);
dol_syslog("Function: getDocument $original_file content-type=$type");
$f = fopen($original_file, 'r');
$content_file = fread($f, filesize($original_file));

View File

@ -45,6 +45,7 @@ $langs->load("main");
if (empty($conf->global->MAIN_MODULE_WEBSERVICES))
{
$langs->load("admin");
dol_syslog("Call Dolibarr webservices interfaces with module webservices disabled");
print $langs->trans("WarningModuleNotActive", 'WebServices').'.<br><br>';
print $langs->trans("ToActivateModule");
@ -139,7 +140,7 @@ $server->register(
*/
function createPayment($authentication, $payment)
{
global $db, $conf, $langs;
global $db, $conf;
$now = dol_now();
@ -165,7 +166,7 @@ function createPayment($authentication, $payment)
if (!$error)
{
$soc = new Societe($db);
$res = $soc->fetch($payment['thirdparty_id']);
$soc->fetch($payment['thirdparty_id']);
$new_payment = new Paiement($db);
$new_payment->amount = doubleval($payment['amount']);

View File

@ -1,6 +1,7 @@
<?php
/* Copyright (C) 2006-2016 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2012 JF FERRY <jfefe@aternatik.fr>
* Copyright (C) 2020 Frédéric France <frederic.france@netlogic.fr>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -23,7 +24,9 @@
* \brief File that is entry point to call Dolibarr WebServices
*/
if (!defined("NOCSRFCHECK")) define("NOCSRFCHECK", '1');
if (!defined("NOCSRFCHECK")) {
define("NOCSRFCHECK", '1');
}
require '../master.inc.php';
require_once NUSOAP_PATH.'/nusoap.php'; // Include SOAP
@ -42,8 +45,7 @@ dol_syslog("Call Dolibarr webservices interfaces");
$langs->load("main");
// Enable and test if module web services is enabled
if (empty($conf->global->MAIN_MODULE_WEBSERVICES))
{
if (empty($conf->global->MAIN_MODULE_WEBSERVICES)) {
$langs->load("admin");
dol_syslog("Call Dolibarr webservices interfaces with module webservices disabled");
print $langs->trans("WarningModuleNotActive", 'WebServices').'.<br><br>';
@ -142,19 +144,22 @@ $extrafield_array = null;
if (is_array($extrafields) && count($extrafields) > 0) {
$extrafield_array = array();
}
if (isset($extrafields->attributes[$elementtype]['label']) && is_array($extrafields->attributes[$elementtype]['label']) && count($extrafields->attributes[$elementtype]['label']))
{
foreach ($extrafields->attributes[$elementtype]['label'] as $key=>$label)
{
if (isset($extrafields->attributes[$elementtype]['label']) && is_array($extrafields->attributes[$elementtype]['label']) && count($extrafields->attributes[$elementtype]['label'])) {
foreach ($extrafields->attributes[$elementtype]['label'] as $key => $label) {
$type = $extrafields->attributes[$elementtype]['type'][$key];
if ($type == 'date' || $type == 'datetime') {$type = 'xsd:dateTime'; }
else {$type = 'xsd:string'; }
if ($type == 'date' || $type == 'datetime') {
$type = 'xsd:dateTime';
} else {
$type = 'xsd:string';
}
$extrafield_array['options_'.$key] = array('name'=>'options_'.$key, 'type'=>$type);
}
}
if (is_array($extrafield_array)) $productorservice_fields = array_merge($productorservice_fields, $extrafield_array);
if (is_array($extrafield_array)) {
$productorservice_fields = array_merge($productorservice_fields, $extrafield_array);
}
// Define other specific objects
$server->wsdl->addComplexType(
@ -236,7 +241,6 @@ $server->wsdl->addComplexType(
);
// 5 styles: RPC/encoded, RPC/literal, Document/encoded (not WS-I compliant), Document/literal, Document/literal wrapped
// Style merely dictates how to translate a WSDL binding to a SOAP message. Nothing more. You can use either style with any programming model.
// http://www.ibm.com/developerworks/webservices/library/ws-whichwsdl/
@ -349,44 +353,49 @@ function getProductOrService($authentication, $id = '', $ref = '', $ref_ext = ''
$langcode = ($lang ? $lang : (empty($conf->global->MAIN_LANG_DEFAULT) ? 'auto' : $conf->global->MAIN_LANG_DEFAULT));
$langs->setDefaultLang($langcode);
if ($authentication['entity']) $conf->entity = $authentication['entity'];
if ($authentication['entity']) {
$conf->entity = $authentication['entity'];
}
// Init and check authentication
$objectresp = array();
$errorcode = ''; $errorlabel = '';
$errorcode = '';
$errorlabel = '';
$error = 0;
$fuser = check_authentication($authentication, $error, $errorcode, $errorlabel);
// Check parameters
if (!$error && (($id && $ref) || ($id && $ref_ext) || ($ref && $ref_ext)))
{
if (!$error && (($id && $ref) || ($id && $ref_ext) || ($ref && $ref_ext))) {
$error++;
$errorcode = 'BAD_PARAMETERS'; $errorlabel = "Parameter id, ref and ref_ext can't be both provided. You must choose one or other but not both.";
}
if (!$error)
{
if (!$error) {
$langcode = ($lang ? $lang : (empty($conf->global->MAIN_LANG_DEFAULT) ? 'auto' : $conf->global->MAIN_LANG_DEFAULT));
$langs->setDefaultLang($langcode);
$fuser->getrights();
$nbmax = 10;
if ($fuser->rights->produit->lire || $fuser->rights->service->lire)
{
if ($fuser->rights->produit->lire || $fuser->rights->service->lire) {
$product = new Product($db);
$result = $product->fetch($id, $ref, $ref_ext);
if ($result > 0)
{
if ($result > 0) {
$product->load_stock();
$dir = (!empty($conf->product->dir_output) ? $conf->product->dir_output : $conf->service->dir_output);
$pdir = get_exdir($product->id, 2, 0, 0, $product, 'product').$product->ref."/";
$dir = $dir.'/'.$pdir;
if (!empty($product->multilangs[$langs->defaultlang]["label"])) $product->label = $product->multilangs[$langs->defaultlang]["label"];
if (!empty($product->multilangs[$langs->defaultlang]["description"])) $product->description = $product->multilangs[$langs->defaultlang]["description"];
if (!empty($product->multilangs[$langs->defaultlang]["note"])) $product->note = $product->multilangs[$langs->defaultlang]["note"];
if (!empty($product->multilangs[$langs->defaultlang]["label"])) {
$product->label = $product->multilangs[$langs->defaultlang]["label"];
}
if (!empty($product->multilangs[$langs->defaultlang]["description"])) {
$product->description = $product->multilangs[$langs->defaultlang]["description"];
}
if (!empty($product->multilangs[$langs->defaultlang]["note"])) {
$product->note = $product->multilangs[$langs->defaultlang]["note"];
}
$productorservice_result_fields = array(
'id' => $product->id,
@ -436,10 +445,8 @@ function getProductOrService($authentication, $id = '', $ref = '', $ref_ext = ''
//Get extrafield values
$product->fetch_optionals();
if (isset($extrafields->attributes[$elementtype]['label']) && is_array($extrafields->attributes[$elementtype]['label']) && count($extrafields->attributes[$elementtype]['label']))
{
foreach ($extrafields->attributes[$elementtype]['label'] as $key=>$label)
{
if (isset($extrafields->attributes[$elementtype]['label']) && is_array($extrafields->attributes[$elementtype]['label']) && count($extrafields->attributes[$elementtype]['label'])) {
foreach ($extrafields->attributes[$elementtype]['label'] as $key => $label) {
$productorservice_result_fields = array_merge($productorservice_result_fields, array('options_'.$key => $product->array_options['options_'.$key]));
}
}
@ -449,20 +456,17 @@ function getProductOrService($authentication, $id = '', $ref = '', $ref_ext = ''
'result'=>array('result_code'=>'OK', 'result_label'=>''),
'product'=>$productorservice_result_fields
);
}
else {
} else {
$error++;
$errorcode = 'NOT_FOUND'; $errorlabel = 'Object not found for id='.$id.' nor ref='.$ref.' nor ref_ext='.$ref_ext;
}
}
else {
} else {
$error++;
$errorcode = 'PERMISSION_DENIED'; $errorlabel = 'User does not have permission for this request';
}
}
if ($error)
{
if ($error) {
$objectresp = array('result'=>array('result_code' => $errorcode, 'result_label' => $errorlabel));
}
//var_dump($objectresp);exit;
@ -479,37 +483,41 @@ function getProductOrService($authentication, $id = '', $ref = '', $ref_ext = ''
*/
function createProductOrService($authentication, $product)
{
global $db, $conf, $langs;
global $db, $conf;
$now = dol_now();
dol_syslog("Function: createProductOrService login=".$authentication['login']);
if ($authentication['entity']) $conf->entity = $authentication['entity'];
if ($authentication['entity']) {
$conf->entity = $authentication['entity'];
}
// Init and check authentication
$objectresp = array();
$errorcode = ''; $errorlabel = '';
$errorcode = '';
$errorlabel = '';
$error = 0;
$fuser = check_authentication($authentication, $error, $errorcode, $errorlabel);
// Check parameters
if (empty($product['price_base_type'])) {
if (isset($product['price_net']) && $product['price_net'] > 0) $product['price_base_type'] = 'HT';
if (isset($product['price']) && $product['price'] > 0) $product['price_base_type'] = 'TTC';
if (isset($product['price_net']) && $product['price_net'] > 0) {
$product['price_base_type'] = 'HT';
}
if (isset($product['price']) && $product['price'] > 0) {
$product['price_base_type'] = 'TTC';
}
}
if (isset($product['price_net']) && $product['price_net'] > 0 && isset($product['price']) && $product['price'] > 0)
{
if (isset($product['price_net']) && $product['price_net'] > 0 && isset($product['price']) && $product['price'] > 0) {
$error++; $errorcode = 'KO'; $errorlabel = "You must choose between price or price_net to provide price.";
}
if (!empty($product['barcode']) && empty($product['barcode_type']))
{
if (!empty($product['barcode']) && empty($product['barcode_type'])) {
$error++; $errorcode = 'KO'; $errorlabel = "You must set a barcode type when setting a barcode.";
}
if (!$error)
{
if (!$error) {
include_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
$newobject = new Product($db);
@ -528,34 +536,35 @@ function createProductOrService($authentication, $product)
$newobject->price_base_type = $product['price_base_type'];
$newobject->date_creation = $now;
if (!empty($product['barcode']))
{
if (!empty($product['barcode'])) {
$newobject->barcode = $product['barcode'];
$newobject->barcode_type = $product['barcode_type'];
}
$newobject->stock_reel = isset($product['stock_real']) ? $product['stock_real'] : null;
$newobject->pmp = isset($product['pmp']) ? $product['pmp'] : null;
$newobject->seuil_stock_alert = isset($product['stock_alert']) ? $product['stock_alert'] : null;
$newobject->seuil_stock_alerte = isset($product['stock_alert']) ? $product['stock_alert'] : null;
$newobject->country_id = isset($product['country_id']) ? $product['country_id'] : 0;
if (!empty($product['country_code'])) $newobject->country_id = getCountry($product['country_code'], 3);
if (!empty($product['country_code'])) {
$newobject->country_id = getCountry($product['country_code'], 3);
}
$newobject->customcode = isset($product['customcode']) ? $product['customcode'] : '';
$newobject->canvas = isset($product['canvas']) ? $product['canvas'] : '';
/*foreach($product['lines'] as $line)
{
$newline=new FactureLigne($db);
$newline->type=$line['type'];
$newline->desc=$line['desc'];
$newline->fk_product=$line['fk_product'];
$newline->total_ht=$line['total_net'];
$newline->total_vat=$line['total_vat'];
$newline->total_ttc=$line['total'];
$newline->vat=$line['vat_rate'];
$newline->qty=$line['qty'];
$newline->fk_product=$line['product_id'];
}*/
{
$newline=new FactureLigne($db);
$newline->type=$line['type'];
$newline->desc=$line['desc'];
$newline->fk_product=$line['fk_product'];
$newline->total_ht=$line['total_net'];
$newline->total_vat=$line['total_vat'];
$newline->total_ttc=$line['total'];
$newline->vat=$line['vat_rate'];
$newline->qty=$line['qty'];
$newline->fk_product=$line['product_id'];
}*/
//var_dump($product['ref_ext']);
//var_dump($product['lines'][0]['type']);
@ -563,10 +572,8 @@ function createProductOrService($authentication, $product)
$extrafields = new ExtraFields($db);
$extrafields->fetch_name_optionals_label($elementtype, true);
if (isset($extrafields->attributes[$elementtype]['label']) && is_array($extrafields->attributes[$elementtype]['label']) && count($extrafields->attributes[$elementtype]['label']))
{
foreach ($extrafields->attributes[$elementtype]['label'] as $key => $label)
{
if (isset($extrafields->attributes[$elementtype]['label']) && is_array($extrafields->attributes[$elementtype]['label']) && count($extrafields->attributes[$elementtype]['label'])) {
foreach ($extrafields->attributes[$elementtype]['label'] as $key => $label) {
$key = 'options_'.$key;
$newobject->array_options[$key] = $product[$key];
}
@ -575,43 +582,34 @@ function createProductOrService($authentication, $product)
$db->begin();
$result = $newobject->create($fuser, 0);
if ($result <= 0)
{
if ($result <= 0) {
$error++;
}
if (!$error)
{
if (!$error) {
// Update stock if stock count is provided and differs from database after creation or update
if (isset($product['stock_real']) && $product['stock_real'] != '' && !empty($conf->global->stock->enabled))
{
if (isset($product['stock_real']) && $product['stock_real'] != '' && !empty($conf->global->stock->enabled)) {
include_once DOL_DOCUMENT_ROOT.'/product/stock/class/entrepot.class.php';
$savstockreal = $newobject->stock_reel;
$newobject->load_stock('novirtual,nobatch'); // This overwrite ->stock_reel, surely 0 because we have just created product
$getstockreal = $newobject->stock_reel;
if ($savstockreal != $getstockreal)
{
if ($savstockreal != $getstockreal) {
$warehouse = new Entrepot($db);
$warehouse->fetch(0, $product['warehouse_ref']);
if ($warehouse->id > 0)
{
if (($savstockreal - $getstockreal) > 0)
{
if ($warehouse->id > 0) {
if (($savstockreal - $getstockreal) > 0) {
$result = $newobject->correct_stock($fuser, $warehouse->id, ($savstockreal - $getstockreal), 0, 'Correction from external call (Web Service)', 0, 'WS'.dol_print_date($now, 'dayhourlog'));
}
if (($savstockreal - $getstockreal) > 0)
{
if (($savstockreal - $getstockreal) > 0) {
$result = $newobject->correct_stock($fuser, $warehouse->id, ($savstockreal - $getstockreal), 1, 'Correction from external call (Web Service)', 0, 'WS'.dol_print_date($now, 'dayhourlog'));
}
if ($result <= 0)
{
if ($result <= 0) {
$error++;
$newobject->error = 'You set a different value for stock, but correction of stock count (before='.$getstockreal.', after='.$savstockreal.') fails with error '.$newobject->error;
}
}
else {
} else {
$error++;
$newobject->error = 'You set a different value for stock but we failed to find warehouse '.$product['warehouse_ref'].' to make correction.';
}
@ -619,12 +617,10 @@ function createProductOrService($authentication, $product)
}
}
if (!$error)
{
if (!$error) {
$db->commit();
$objectresp = array('result'=>array('result_code'=>'OK', 'result_label'=>''), 'id'=>$newobject->id, 'ref'=>$newobject->ref);
}
else {
} else {
$db->rollback();
$error++;
$errorcode = 'KO';
@ -632,8 +628,7 @@ function createProductOrService($authentication, $product)
}
}
if ($error)
{
if ($error) {
$objectresp = array('result'=>array('result_code' => $errorcode, 'result_label' => $errorlabel));
}
@ -650,43 +645,51 @@ function createProductOrService($authentication, $product)
*/
function updateProductOrService($authentication, $product)
{
global $db, $conf, $langs;
global $db, $conf;
$now = dol_now();
dol_syslog("Function: updateProductOrService login=".$authentication['login']);
if ($authentication['entity']) $conf->entity = $authentication['entity'];
if ($authentication['entity']) {
$conf->entity = $authentication['entity'];
}
// Init and check authentication
$objectresp = array();
$errorcode = ''; $errorlabel = '';
$errorcode = '';
$errorlabel = '';
$error = 0;
$fuser = check_authentication($authentication, $error, $errorcode, $errorlabel);
// Check parameters
if ($product['price_net'] > 0) $product['price_base_type'] = 'HT';
if ($product['price'] > 0) $product['price_base_type'] = 'TTC';
if ($product['price_net'] > 0) {
$product['price_base_type'] = 'HT';
}
if ($product['price'] > 0) {
$product['price_base_type'] = 'TTC';
}
if ($product['price_net'] > 0 && $product['price'] > 0)
{
if ($product['price_net'] > 0 && $product['price'] > 0) {
$error++; $errorcode = 'KO'; $errorlabel = "You must choose between price or price_net to provide price.";
}
if ($product['barcode'] && !$product['barcode_type'])
{
if ($product['barcode'] && !$product['barcode_type']) {
$error++; $errorcode = 'KO'; $errorlabel = "You must set a barcode type when setting a barcode.";
}
if (!$error)
{
if (!$error) {
include_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
$newobject = new Product($db);
$newobject->fetch($product['id']);
if (isset($product['ref'])) $newobject->ref = $product['ref'];
if (isset($product['ref_ext'])) $newobject->ref_ext = $product['ref_ext'];
if (isset($product['ref'])) {
$newobject->ref = $product['ref'];
}
if (isset($product['ref_ext'])) {
$newobject->ref_ext = $product['ref_ext'];
}
$newobject->type = $product['type'];
$newobject->label = $product['label'];
$newobject->description = $product['description'];
@ -699,30 +702,27 @@ function updateProductOrService($authentication, $product)
$newobject->price_base_type = $product['price_base_type'];
$newobject->date_creation = $now;
if ($product['barcode'])
{
if ($product['barcode']) {
$newobject->barcode = $product['barcode'];
$newobject->barcode_type = $product['barcode_type'];
}
$newobject->stock_reel = $product['stock_real'];
$newobject->pmp = $product['pmp'];
$newobject->seuil_stock_alert = $product['stock_alert'];
$newobject->stock_reel = isset($product['stock_real']) ? $product['stock_real'] : null;
$newobject->pmp = isset($product['pmp']) ? $product['pmp'] : null;
$newobject->seuil_stock_alerte = isset($product['stock_alert']) ? $product['stock_alert'] : null;
$newobject->country_id = $product['country_id'];
if ($product['country_code']) $newobject->country_id = getCountry($product['country_code'], 3);
$newobject->customcode = $product['customcode'];
$newobject->country_id = isset($product['country_id']) ? $product['country_id'] : 0;
if (!empty($product['country_code'])) $newobject->country_id = getCountry($product['country_code'], 3);
$newobject->customcode = isset($product['customcode']) ? $product['customcode'] : '';
$newobject->canvas = $product['canvas'];
$newobject->canvas = isset($product['canvas']) ? $product['canvas'] : '';
$elementtype = 'product';
$extrafields = new ExtraFields($db);
$extrafields->fetch_name_optionals_label($elementtype, true);
if (isset($extrafields->attributes[$elementtype]['label']) && is_array($extrafields->attributes[$elementtype]['label']) && count($extrafields->attributes[$elementtype]['label']))
{
foreach ($extrafields->attributes[$elementtype]['label'] as $key=>$label)
{
if (isset($extrafields->attributes[$elementtype]['label']) && is_array($extrafields->attributes[$elementtype]['label']) && count($extrafields->attributes[$elementtype]['label'])) {
foreach ($extrafields->attributes[$elementtype]['label'] as $key => $label) {
$key = 'options_'.$key;
$newobject->array_options[$key] = $product[$key];
}
@ -731,41 +731,32 @@ function updateProductOrService($authentication, $product)
$db->begin();
$result = $newobject->update($newobject->id, $fuser);
if ($result <= 0)
{
if ($result <= 0) {
$error++;
}
else {
} else {
// Update stock if stock count is provided and differs from database after creation or update
if (isset($product['stock_real']) && $product['stock_real'] != '' && !empty($conf->global->stock->enabled))
{
if (isset($product['stock_real']) && $product['stock_real'] != '' && !empty($conf->global->stock->enabled)) {
include_once DOL_DOCUMENT_ROOT.'/product/stock/class/entrepot.class.php';
$savstockreal = $newobject->stock_reel;
$newobject->load_stock('novirtual,nobatch'); // This overwrite ->stock_reel
$getstockreal = $newobject->stock_reel;
if ($savstockreal != $getstockreal)
{
if ($savstockreal != $getstockreal) {
$warehouse = new Entrepot($db);
$warehouse->fetch(0, $product['warehouse_ref']);
if ($warehouse->id > 0)
{
if (($savstockreal - $getstockreal) > 0)
{
if ($warehouse->id > 0) {
if (($savstockreal - $getstockreal) > 0) {
$result = $newobject->correct_stock($fuser, $warehouse->id, ($savstockreal - $getstockreal), 0, 'Correction from external call (Web Service)', 0, 'WS'.dol_print_date($now, 'dayhourlog'));
}
if (($savstockreal - $getstockreal) > 0)
{
if (($savstockreal - $getstockreal) > 0) {
$result = $newobject->correct_stock($fuser, $warehouse->id, ($savstockreal - $getstockreal), 1, 'Correction from external call (Web Service)', 0, 'WS'.dol_print_date($now, 'dayhourlog'));
}
if ($result <= 0)
{
if ($result <= 0) {
$error++;
$newobject->error = 'You set a different value for stock, but correction of stock count (before='.$getstockreal.', after='.$savstockreal.') fails with error '.$newobject->error;
}
}
else {
} else {
$error++;
$newobject->error = 'You set a different value for stock but we failed to find warehouse '.$product['warehouse_ref'].' to make correction.';
}
@ -773,32 +764,24 @@ function updateProductOrService($authentication, $product)
}
}
if (!$error)
{
if ($newobject->price_base_type == 'HT')
{
if (!$error) {
if ($newobject->price_base_type == 'HT') {
$result = $newobject->updatePrice($newobject->price, $newobject->price_base_type, $fuser);
if ($result <= 0)
{
if ($result <= 0) {
$error++;
}
}
elseif ($newobject->price_base_type == 'TTC')
{
$result = $newobject->updatePrice($newobject->price_ttc, $newobject->price_base_type);
if ($result <= 0)
{
} elseif ($newobject->price_base_type == 'TTC') {
$result = $newobject->updatePrice($newobject->price_ttc, $newobject->price_base_type, $fuser);
if ($result <= 0) {
$error++;
}
}
}
if (!$error)
{
if (!$error) {
$db->commit();
$objectresp = array('result'=>array('result_code'=>'OK', 'result_label'=>''), 'id'=>$newobject->id, 'ref'=>$newobject->ref);
}
else {
} else {
$db->rollback();
$error++;
$errorcode = 'KO';
@ -806,8 +789,7 @@ function updateProductOrService($authentication, $product)
}
}
if ($error)
{
if ($error) {
$objectresp = array('result'=>array('result_code' => $errorcode, 'result_label' => $errorlabel));
}
@ -824,15 +806,18 @@ function updateProductOrService($authentication, $product)
*/
function deleteProductOrService($authentication, $listofidstring)
{
global $db, $conf, $langs;
global $db, $conf;
dol_syslog("Function: deleteProductOrService login=".$authentication['login']);
if ($authentication['entity']) $conf->entity = $authentication['entity'];
if ($authentication['entity']) {
$conf->entity = $authentication['entity'];
}
// Init and check authentication
$objectresp = array();
$errorcode = ''; $errorlabel = '';
$errorcode = '';
$errorlabel = '';
$error = 0;
$fuser = check_authentication($authentication, $error, $errorcode, $errorlabel);
@ -844,32 +829,26 @@ function deleteProductOrService($authentication, $listofidstring)
$listofiddeleted = array();
// Check parameters
if (count($listofid) == 0 || empty($listofid[0]))
{
if (count($listofid) == 0 || empty($listofid[0])) {
$error++; $errorcode = 'KO'; $errorlabel = "List of Id of products or services to delete are required.";
}
if (!$error)
{
if (!$error) {
$firsterror = '';
$db->begin();
foreach ($listofid as $key => $id)
{
foreach ($listofid as $id) {
$newobject = new Product($db);
$result = $newobject->fetch($id);
if ($result == 0)
{
if ($result == 0) {
$error++;
$firsterror = 'Product or service with id '.$id.' not found';
break;
}
else {
} else {
$result = $newobject->delete($user);
if ($result <= 0)
{
if ($result <= 0) {
$error++;
$firsterror = $newobject->error;
break;
@ -879,13 +858,11 @@ function deleteProductOrService($authentication, $listofidstring)
}
}
if (!$error)
{
if (!$error) {
$db->commit();
//$objectresp=array('result'=>array('result_code'=>'OK', 'result_label'=>''), 'listofid'=>$listofiddeleted);
$objectresp = array('result'=>array('result_code'=>'OK', 'result_label'=>''), 'nbdeleted'=>count($listofiddeleted));
}
else {
} else {
$db->rollback();
$error++;
$errorcode = 'KO';
@ -893,15 +870,12 @@ function deleteProductOrService($authentication, $listofidstring)
}
}
if ($error)
{
if ($error) {
//$objectresp = array('result'=>array('result_code' => $errorcode, 'result_label' => $errorlabel), 'listofid'=>$listofiddeleted);
$objectresp = array('result'=>array('result_code' => $errorcode, 'result_label' => $errorlabel), 'nbdeleted'=>0);
}
elseif (count($listofiddeleted) == 0)
{
//$objectresp=array('result'=>array('result_code'=>'NOT_FOUND', 'result_label'=>'No product or service with id '.join(',',$listofid).' found'), 'listofid'=>$listofiddeleted);
$objectresp = array('result'=>array('result_code'=>'NOT_FOUND', 'result_label'=>'No product or service with id '.join(',', $listofid).' found'), 'nbdeleted'=>0);
} elseif (count($listofiddeleted) == 0) {
//$objectresp=array('result'=>array('result_code'=>'NOT_FOUND', 'result_label'=>'No product or service with id '.join(',',$listofid).' found'), 'listofid'=>$listofiddeleted);
$objectresp = array('result'=>array('result_code'=>'NOT_FOUND', 'result_label'=>'No product or service with id '.join(',', $listofid).' found'), 'nbdeleted'=>0);
}
return $objectresp;
@ -917,53 +891,56 @@ function deleteProductOrService($authentication, $listofidstring)
*/
function getListOfProductsOrServices($authentication, $filterproduct)
{
global $db, $conf, $langs;
global $db, $conf;
dol_syslog("Function: getListOfProductsOrServices login=".$authentication['login']);
if ($authentication['entity']) $conf->entity = $authentication['entity'];
if ($authentication['entity']) {
$conf->entity = $authentication['entity'];
}
// Init and check authentication
$objectresp = array();
$arrayproducts = array();
$errorcode = ''; $errorlabel = '';
$errorcode = '';
$errorlabel = '';
$error = 0;
$fuser = check_authentication($authentication, $error, $errorcode, $errorlabel);
// Check parameters
if (!$error)
{
if (!$error) {
$sql = "SELECT rowid, ref, ref_ext";
$sql .= " FROM ".MAIN_DB_PREFIX."product";
$sql .= " WHERE entity=".$conf->entity;
foreach ($filterproduct as $key => $val)
{
if ($key == 'type' && $val >= 0) $sql .= " AND fk_product_type = ".$db->escape($val);
if ($key == 'status_tosell') $sql .= " AND tosell = ".$db->escape($val);
if ($key == 'status_tobuy') $sql .= " AND tobuy = ".$db->escape($val);
foreach ($filterproduct as $key => $val) {
if ($key == 'type' && $val >= 0) {
$sql .= " AND fk_product_type = ".$db->escape($val);
}
if ($key == 'status_tosell') {
$sql .= " AND tosell = ".$db->escape($val);
}
if ($key == 'status_tobuy') {
$sql .= " AND tobuy = ".$db->escape($val);
}
}
$resql = $db->query($sql);
if ($resql)
{
$num = $db->num_rows($resql);
if ($resql) {
$num = $db->num_rows($resql);
$i = 0;
while ($i < $num)
{
$obj = $db->fetch_object($resql);
$arrayproducts[] = array('id'=>$obj->rowid, 'ref'=>$obj->ref, 'ref_ext'=>$obj->ref_ext);
$i++;
}
}
else {
$i = 0;
while ($i < $num) {
$obj = $db->fetch_object($resql);
$arrayproducts[] = array('id'=>$obj->rowid, 'ref'=>$obj->ref, 'ref_ext'=>$obj->ref_ext);
$i++;
}
} else {
$error++;
$errorcode = $db->lasterrno();
$errorlabel = $db->lasterror();
}
}
if ($error)
{
if ($error) {
$objectresp = array(
'result'=>array('result_code' => $errorcode, 'result_label' => $errorlabel),
'products'=>$arrayproducts
@ -996,7 +973,9 @@ function getProductsForCategory($authentication, $id, $lang = '')
dol_syslog("Function: getProductsForCategory login=".$authentication['login']." id=".$id);
if ($authentication['entity']) $conf->entity = $authentication['entity'];
if ($authentication['entity']) {
$conf->entity = $authentication['entity'];
}
$objectresp = array();
$errorcode = ''; $errorlabel = '';
@ -1005,27 +984,23 @@ function getProductsForCategory($authentication, $id, $lang = '')
$fuser = check_authentication($authentication, $error, $errorcode, $errorlabel);
if (!$error && !$id)
{
if (!$error && !$id) {
$error++;
$errorcode = 'BAD_PARAMETERS'; $errorlabel = "Parameter id must be provided.";
}
if (!$error)
{
if (!$error) {
$langcode = ($lang ? $lang : (empty($conf->global->MAIN_LANG_DEFAULT) ? 'auto' : $conf->global->MAIN_LANG_DEFAULT));
$langs->setDefaultLang($langcode);
$fuser->getrights();
$nbmax = 10;
if ($fuser->rights->produit->lire)
{
if ($fuser->rights->produit->lire) {
$categorie = new Categorie($db);
$result = $categorie->fetch($id);
if ($result > 0)
{
if ($result > 0) {
$table = "product";
$field = "product";
$sql = "SELECT fk_".$field." FROM ".MAIN_DB_PREFIX."categorie_".$table;
@ -1035,24 +1010,21 @@ function getProductsForCategory($authentication, $id, $lang = '')
dol_syslog("getProductsForCategory get id of product into category", LOG_DEBUG);
$res = $db->query($sql);
if ($res)
{
if ($res) {
$iProduct = 0;
$tmpproduct = new Product($db);
$products = array();
while ($rec = $db->fetch_array($res))
{
while ($rec = $db->fetch_array($res)) {
$tmpproduct->fetch($rec['fk_'.$field]);
if ($tmpproduct->status > 0)
{
if ($tmpproduct->status > 0) {
$dir = (!empty($conf->product->dir_output) ? $conf->product->dir_output : $conf->service->dir_output);
$pdir = get_exdir($tmpproduct->id, 2, 0, 0, $tmpproduct, 'product').$tmpproduct->id."/photos/";
$dir = $dir.'/'.$pdir;
$products[] = array(
'id' => $tmpproduct->id,
'ref' => $tmpproduct->ref,
'ref_ext' => $tmpproduct->ref_ext,
'ref' => $tmpproduct->ref,
'ref_ext' => $tmpproduct->ref_ext,
'label' => !empty($tmpproduct->multilangs[$langs->defaultlang]["label"]) ? $tmpproduct->multilangs[$langs->defaultlang]["label"] : $tmpproduct->label,
'description' => !empty($tmpproduct->multilangs[$langs->defaultlang]["description"]) ? $tmpproduct->multilangs[$langs->defaultlang]["description"] : $tmpproduct->description,
'date_creation' => dol_print_date($tmpproduct->date_creation, 'dayhourrfc'),
@ -1090,10 +1062,8 @@ function getProductsForCategory($authentication, $id, $lang = '')
//Get extrafield values
$tmpproduct->fetch_optionals();
if (isset($extrafields->attributes[$elementtype]['label']) && is_array($extrafields->attributes[$elementtype]['label']) && count($extrafields->attributes[$elementtype]['label']))
{
foreach ($extrafields->attributes[$elementtype]['label'] as $key=>$label)
{
if (isset($extrafields->attributes[$elementtype]['label']) && is_array($extrafields->attributes[$elementtype]['label']) && count($extrafields->attributes[$elementtype]['label'])) {
foreach ($extrafields->attributes[$elementtype]['label'] as $key => $label) {
$products[$iProduct] = array_merge($products[$iProduct], array('options_'.$key => $tmpproduct->array_options['options_'.$key]));
}
}
@ -1107,26 +1077,22 @@ function getProductsForCategory($authentication, $id, $lang = '')
'result'=>array('result_code'=>'OK', 'result_label'=>''),
'products'=> $products
);
}
else {
} else {
$errorcode = 'NORECORDS_FOR_ASSOCIATION'; $errorlabel = 'No products associated'.$sql;
$objectresp = array('result'=>array('result_code' => $errorcode, 'result_label' => $errorlabel));
dol_syslog("getProductsForCategory:: ".$errorcode, LOG_DEBUG);
}
}
else {
} else {
$error++;
$errorcode = 'NOT_FOUND'; $errorlabel = 'Object not found for id='.$id;
}
}
else {
} else {
$error++;
$errorcode = 'PERMISSION_DENIED'; $errorlabel = 'User does not have permission for this request';
}
}
if ($error)
{
if ($error) {
$objectresp = array('result'=>array('result_code' => $errorcode, 'result_label' => $errorlabel));
}

View File

@ -131,7 +131,7 @@ $server->wsdl->addComplexType(
);
$project_elements = array();
foreach ($listofreferent as $key => $_)
foreach ($listofreferent as $key => $label)
{
$project_elements[$key] = array('name'=>$key, 'type'=>'tns:elementsArray');
}
@ -279,7 +279,7 @@ function createProject($authentication, $project)
$extrafields->fetch_name_optionals_label($elementtype, true);
if (isset($extrafields->attributes[$elementtype]['label']) && is_array($extrafields->attributes[$elementtype]['label']) && count($extrafields->attributes[$elementtype]['label']))
{
foreach ($extrafields->attributes[$elementtype]['label'] as $key=>$label)
foreach ($extrafields->attributes[$elementtype]['label'] as $key => $label)
{
$key = 'options_'.$key;
$newobject->array_options[$key] = $project[$key];
@ -338,7 +338,7 @@ function createProject($authentication, $project)
*/
function getProject($authentication, $id = '', $ref = '')
{
global $db, $conf, $langs;
global $db, $conf;
dol_syslog("Function: getProject login=".$authentication['login']." id=".$id." ref=".$ref);
@ -389,7 +389,7 @@ function getProject($authentication, $id = '', $ref = '')
if (isset($extrafields->attributes[$elementtype]['label']) && is_array($extrafields->attributes[$elementtype]['label']) && count($extrafields->attributes[$elementtype]['label']))
{
$project->fetch_optionals();
foreach ($extrafields->attributes[$elementtype]['label'] as $key=>$label)
foreach ($extrafields->attributes[$elementtype]['label'] as $key => $label)
{
$project_result_fields = array_merge($project_result_fields, array('options_'.$key => $project->array_options['options_'.$key]));
}

View File

@ -225,7 +225,7 @@ $server->register(
*/
function getSupplierInvoice($authentication, $id = '', $ref = '', $ref_ext = '')
{
global $db, $conf, $langs;
global $db, $conf;
dol_syslog("Function: getSupplierInvoice login=".$authentication['login']." id=".$id." ref=".$ref." ref_ext=".$ref_ext);
@ -333,7 +333,7 @@ function getSupplierInvoice($authentication, $id = '', $ref = '', $ref_ext = '')
*/
function getSupplierInvoicesForThirdParty($authentication, $idthirdparty)
{
global $db, $conf, $langs;
global $db, $conf;
dol_syslog("Function: getSupplierInvoicesForThirdParty login=".$authentication['login']." idthirdparty=".$idthirdparty);
@ -344,6 +344,7 @@ function getSupplierInvoicesForThirdParty($authentication, $idthirdparty)
$errorcode = ''; $errorlabel = '';
$error = 0;
$fuser = check_authentication($authentication, $error, $errorcode, $errorlabel);
// Check parameters
if (!$error && empty($idthirdparty))
{

View File

@ -132,7 +132,7 @@ if (is_array($extrafields) && count($extrafields) > 0) {
}
if (isset($extrafields->attributes[$elementtype]['label']) && is_array($extrafields->attributes[$elementtype]['label']) && count($extrafields->attributes[$elementtype]['label']))
{
foreach ($extrafields->attributes[$elementtype]['label'] as $key=>$label)
foreach ($extrafields->attributes[$elementtype]['label'] as $key => $label)
{
//$value=$object->array_options["options_".$key];
$type = $extrafields->attributes[$elementtype]['type'][$key];
@ -290,7 +290,7 @@ $server->register(
*/
function getThirdParty($authentication, $id = '', $ref = '', $ref_ext = '')
{
global $db, $conf, $langs;
global $db, $conf;
dol_syslog("Function: getThirdParty login=".$authentication['login']." id=".$id." ref=".$ref." ref_ext=".$ref_ext);
@ -367,7 +367,7 @@ function getThirdParty($authentication, $id = '', $ref = '', $ref_ext = '')
if (isset($extrafields->attributes[$elementtype]['label']) && is_array($extrafields->attributes[$elementtype]['label']) && count($extrafields->attributes[$elementtype]['label']))
{
foreach ($extrafields->attributes[$elementtype]['label'] as $key=>$label)
foreach ($extrafields->attributes[$elementtype]['label'] as $key => $label)
{
$thirdparty_result_fields = array_merge($thirdparty_result_fields, array('options_'.$key => $thirdparty->array_options['options_'.$key]));
}
@ -408,7 +408,7 @@ function getThirdParty($authentication, $id = '', $ref = '', $ref_ext = '')
*/
function createThirdParty($authentication, $thirdparty)
{
global $db, $conf, $langs;
global $db, $conf;
$now = dol_now();
@ -483,7 +483,7 @@ function createThirdParty($authentication, $thirdparty)
$extrafields->fetch_name_optionals_label($elementtype, true);
if (isset($extrafields->attributes[$elementtype]['label']) && is_array($extrafields->attributes[$elementtype]['label']) && count($extrafields->attributes[$elementtype]['label']))
{
foreach ($extrafields->attributes[$elementtype]['label'] as $key=>$label)
foreach ($extrafields->attributes[$elementtype]['label'] as $key => $label)
{
$key = 'options_'.$key;
$newobject->array_options[$key] = $thirdparty[$key];
@ -538,7 +538,7 @@ function createThirdParty($authentication, $thirdparty)
*/
function updateThirdParty($authentication, $thirdparty)
{
global $db, $conf, $langs;
global $db, $conf;
$now = dol_now();
@ -617,7 +617,7 @@ function updateThirdParty($authentication, $thirdparty)
$extrafields->fetch_name_optionals_label($elementtype, true);
if (isset($extrafields->attributes[$elementtype]['label']) && is_array($extrafields->attributes[$elementtype]['label']) && count($extrafields->attributes[$elementtype]['label']))
{
foreach ($extrafields->attributes[$elementtype]['label'] as $key=>$label)
foreach ($extrafields->attributes[$elementtype]['label'] as $key => $label)
{
$key = 'options_'.$key;
$object->array_options[$key] = $thirdparty[$key];
@ -672,9 +672,7 @@ function updateThirdParty($authentication, $thirdparty)
*/
function getListOfThirdParties($authentication, $filterthirdparty)
{
global $db, $conf, $langs;
$now = dol_now();
global $db, $conf;
dol_syslog("Function: getListOfThirdParties login=".$authentication['login']);
@ -725,7 +723,7 @@ function getListOfThirdParties($authentication, $filterthirdparty)
if (isset($extrafields->attributes[$elementtype]['label']) && is_array($extrafields->attributes[$elementtype]['label']) && count($extrafields->attributes[$elementtype]['label']))
{
foreach ($extrafields->attributes[$elementtype]['label'] as $key=>$label)
foreach ($extrafields->attributes[$elementtype]['label'] as $key => $label)
{
$extrafieldsOptions['options_'.$key] = $obj->{$key};
}
@ -782,7 +780,7 @@ function getListOfThirdParties($authentication, $filterthirdparty)
*/
function deleteThirdParty($authentication, $id = '', $ref = '', $ref_ext = '')
{
global $db, $conf, $langs;
global $db, $conf;
dol_syslog("Function: deleteThirdParty login=".$authentication['login']." id=".$id." ref=".$ref." ref_ext=".$ref_ext);

View File

@ -195,7 +195,7 @@ if (is_array($extrafields) && count($extrafields) > 0) {
}
if (isset($extrafields->attributes[$elementtype]['label']) && is_array($extrafields->attributes[$elementtype]['label']) && count($extrafields->attributes[$elementtype]['label']))
{
foreach ($extrafields->attributes[$elementtype]['label'] as $key=>$label)
foreach ($extrafields->attributes[$elementtype]['label'] as $key => $label)
{
$type = $extrafields->attributes[$elementtype]['type'][$key];
if ($type == 'date' || $type == 'datetime') {$type = 'xsd:dateTime'; }
@ -308,7 +308,7 @@ $server->register(
*/
function getUser($authentication, $id, $ref = '', $ref_ext = '')
{
global $db, $conf, $langs;
global $db, $conf;
dol_syslog("Function: getUser login=".$authentication['login']." id=".$id." ref=".$ref." ref_ext=".$ref_ext);
@ -399,9 +399,7 @@ function getUser($authentication, $id, $ref = '', $ref_ext = '')
*/
function getListOfGroups($authentication)
{
global $db, $conf, $langs;
$now = dol_now();
global $db, $conf;
dol_syslog("Function: getListOfGroups login=".$authentication['login']);
@ -477,7 +475,7 @@ function createUserFromThirdparty($authentication, $thirdpartywithuser)
{
global $db, $conf, $langs;
dol_syslog("Function: createUserFromThirdparty login=".$authentication['login']." id=".$id." ref=".$ref." ref_ext=".$ref_ext);
dol_syslog("Function: createUserFromThirdparty login=".$authentication['login']);
if ($authentication['entity']) $conf->entity = $authentication['entity'];
@ -601,7 +599,7 @@ function createUserFromThirdparty($authentication, $thirdpartywithuser)
$extrafields->fetch_name_optionals_label($elementtype, true);
if (isset($extrafields->attributes[$elementtype]['label']) && is_array($extrafields->attributes[$elementtype]['label']) && count($extrafields->attributes[$elementtype]['label']))
{
foreach ($extrafields->attributes[$elementtype]['label'] as $key=>$label)
foreach ($extrafields->attributes[$elementtype]['label'] as $key => $label)
{
$key = 'contact_options_'.$key;
$key = substr($key, 8); // Remove 'contact_' prefix
@ -644,7 +642,7 @@ function createUserFromThirdparty($authentication, $thirdpartywithuser)
}
} else {
$error++;
$errors = ($thirdparty->error ? array($thirdparty->error) : $thirdparty->errors);
$errorcode = join(', ', ($thirdparty->error ? array($thirdparty->error) : $thirdparty->errors));
}
}
} else {
@ -662,7 +660,7 @@ function createUserFromThirdparty($authentication, $thirdpartywithuser)
{
$db->rollback();
$objectresp = array(
'result'=>array('result_code' => $errorcode, 'result_label' => $errorlabel)
'result'=>array('result_code' => $errorcode, 'result_label' => $errorlabel)
);
}
@ -680,9 +678,9 @@ function createUserFromThirdparty($authentication, $thirdpartywithuser)
function setUserPassword($authentication, $shortuser)
{
global $db, $conf, $langs;
global $db, $conf;
dol_syslog("Function: setUserPassword login=".$authentication['login']." id=".$id." ref=".$ref." ref_ext=".$ref_ext);
dol_syslog("Function: setUserPassword login=".$authentication['login']);
if ($authentication['entity']) $conf->entity = $authentication['entity'];
@ -715,7 +713,6 @@ function setUserPassword($authentication, $shortuser)
{
$objectresp = array(
'result'=>array('result_code' => 'OK', 'result_label' => ''),
'groups'=>$arraygroups
);
}
else {

View File

@ -131,6 +131,35 @@ class FunctionsLibTest extends PHPUnit\Framework\TestCase
print __METHOD__."\n";
}
/**
* testIsValidEmail
*
* @return void
*/
public function testIsValidEmail()
{
// Nb of line is same than entry text
$input="bidon@bademail";
$result=isValidEmail($input);
print __METHOD__." result=".$result."\n";
$this->assertFalse($result, 'Check isValidEmail '.$input);
$input="test@yahoo.com";
$result=isValidEmail($input);
print __METHOD__." result=".$result."\n";
$this->assertTrue($result, 'Check isValidEmail '.$input);
$input="The name of sender <test@yahoo.com>";
$result=isValidEmail($input);
print __METHOD__." result=".$result."\n";
$this->assertFalse($result, 'Check isValidEmail '.$input);
$input="1234.abcdefg@domainame.com.br";
$result=isValidEmail($input);
print __METHOD__." result=".$result."\n";
$this->assertTrue($result, 'Check isValidEmail '.$input);
}
/**
* testIsValidMXRecord

View File

@ -61,6 +61,9 @@ class WebservicesInvoicesTest extends PHPUnit\Framework\TestCase
protected $ns = 'http://www.dolibarr.org/ns/';
protected $pass = 'admin';
/**
* Constructor
* We save global variables into local variables
@ -102,6 +105,8 @@ class WebservicesInvoicesTest extends PHPUnit\Framework\TestCase
{
global $conf,$user,$langs,$db;
$now = dol_now();
// create a third_party, needed to create an invoice
//
// The third party is created in setUpBeforeClass() and not in the
@ -246,7 +251,7 @@ class WebservicesInvoicesTest extends PHPUnit\Framework\TestCase
'dolibarrkey'=>$conf->global->WEBSERVICES_KEY,
'sourceapplication'=>'DEMO',
'login'=>'admin',
'password'=>'admin',
'password'=>$this->pass,
'entity'=>'');
// Test URL
@ -270,7 +275,7 @@ class WebservicesInvoicesTest extends PHPUnit\Framework\TestCase
print "\n";
}
print __METHOD__." result=".$result['result']['result_code']."\n";
print __METHOD__." result=".$result['result']['result_code']." ".$result['result']['result_label']."\n";
$this->assertEquals('OK', $result['result']['result_code']);
$this->assertEquals('ref-phpunit-2', $result['ref_ext']);
@ -302,7 +307,7 @@ class WebservicesInvoicesTest extends PHPUnit\Framework\TestCase
'dolibarrkey'=>$conf->global->WEBSERVICES_KEY,
'sourceapplication'=>'DEMO',
'login'=>'admin',
'password'=>'admin',
'password'=>$this->pass,
'entity'=>'');
// Test URL
@ -401,7 +406,7 @@ class WebservicesInvoicesTest extends PHPUnit\Framework\TestCase
'dolibarrkey'=>$conf->global->WEBSERVICES_KEY,
'sourceapplication'=>'DEMO',
'login'=>'admin',
'password'=>'admin',
'password'=>$this->pass,
'entity'=>'');
// Test URL