Merge branch 'develop' into dev_add_tag_on_massaction

This commit is contained in:
Laurent Destailleur 2020-12-30 13:10:02 +01:00 committed by GitHub
commit 17b68a30d7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
43 changed files with 1607 additions and 1380 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

@ -238,18 +238,18 @@ if ($action == 'create') {
print $formaccounting->select_account($object->account_parent, 'account_parent', 1, null, 0, 0, 'minwidth200');
print '</td></tr>';
// Category
print '<tr><td>'.$langs->trans("AccountingCategory").'</td>';
print '<td>';
$formaccounting->select_accounting_category($object->account_category, 'account_category', 1, 0, 1);
print '</td></tr>';
// Chart of accounts type
print '<tr><td>'.$langs->trans("Pcgtype").'</td>';
print '<td>';
print '<input type="text" name="pcg_type" value="'.dol_escape_htmltag(GETPOSTISSET('pcg_type') ? GETPOST('pcg_type', 'alpha') : $object->pcg_type).'">';
print '</td></tr>';
// Category
print '<tr><td>'.$langs->trans("AccountingCategory").'</td>';
print '<td>';
$formaccounting->select_accounting_category($object->account_category, 'account_category', 1, 0, 1);
print '</td></tr>';
print '</table>';
print dol_get_fiche_end();
@ -300,18 +300,18 @@ if ($action == 'create') {
print $formaccounting->select_account($object->account_parent, 'account_parent', 1);
print '</td></tr>';
// Category
print '<tr><td>'.$langs->trans("AccountingCategory").'</td>';
print '<td>';
$formaccounting->select_accounting_category($object->account_category, 'account_category', 1);
print '</td></tr>';
// Chart of accounts type
print '<tr><td>'.$langs->trans("Pcgtype").'</td>';
print '<td>';
print '<input type="text" name="pcg_type" value="'.dol_escape_htmltag(GETPOSTISSET('pcg_type') ? GETPOST('pcg_type', 'alpha') : $object->pcg_type).'">';
print '</td></tr>';
// Category
print '<tr><td>'.$langs->trans("AccountingCategory").'</td>';
print '<td>';
$formaccounting->select_accounting_category($object->account_category, 'account_category', 1);
print '</td></tr>';
print '</table>';
print dol_get_fiche_end();

View File

@ -78,7 +78,7 @@ $form = new Form($db);
if (empty($search_date_start) && !GETPOSTISSET('formfilteraction'))
{
$sql = "SELECT date_start, date_end from ".MAIN_DB_PREFIX."accounting_fiscalyear ";
$sql .= " where date_start < '".$db->idate(dol_now())."' and date_end > '".$db->idate(dol_now())."'";
$sql .= " WHERE date_start < '".$db->idate(dol_now())."' AND date_end > '".$db->idate(dol_now())."'";
$sql .= $db->plimit(1);
$res = $db->query($sql);
if ($res->num_rows > 0) {
@ -242,10 +242,12 @@ if ($action != 'export_csv')
print '</div>';
}
$colspan = (!empty($conf->global->ACCOUNTANCY_SHOW_OPENING_BALANCE) ? 5 : 4);
print '<table class="liste '.($moreforfilter ? "listwithfilterbefore" : "").'">';
print '<tr class="liste_titre_filter">';
print '<td class="liste_titre" colspan="5">';
print '<td class="liste_titre" colspan="'.$colspan.'">';
print $langs->trans('From');
print $formaccounting->select_account($search_accountancy_code_start, 'search_accountancy_code_start', 1, array(), 1, 1, '');
print ' ';
@ -261,7 +263,7 @@ if ($action != 'export_csv')
print '<tr class="liste_titre">';
print_liste_field_titre("AccountAccounting", $_SERVER['PHP_SELF'], "t.numero_compte", "", $param, "", $sortfield, $sortorder);
print_liste_field_titre("OpeningBalance", $_SERVER['PHP_SELF'], "", $param, "", 'class="right"', $sortfield, $sortorder);
if (!empty($conf->global->ACCOUNTANCY_SHOW_OPENING_BALANCE)) print_liste_field_titre("OpeningBalance", $_SERVER['PHP_SELF'], "", $param, "", 'class="right"', $sortfield, $sortorder);
print_liste_field_titre("Debit", $_SERVER['PHP_SELF'], "t.debit", "", $param, 'class="right"', $sortfield, $sortorder);
print_liste_field_titre("Credit", $_SERVER['PHP_SELF'], "t.credit", "", $param, 'class="right"', $sortfield, $sortorder);
print_liste_field_titre("Balance", $_SERVER["PHP_SELF"], "", $param, "", 'class="right"', $sortfield, $sortorder);
@ -278,22 +280,30 @@ if ($action != 'export_csv')
$accountingaccountstatic = new AccountingAccount($db);
$sql = "SELECT t.numero_compte, (SUM(t.debit) - SUM(t.credit)) as opening_balance";
$sql .= " FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as t";
$sql .= " WHERE t.entity = ".$conf->entity; // Never do sharing into accounting features
$sql .= " AND t.doc_date < '".$db->idate($search_date_start)."'";
$sql .= " GROUP BY t.numero_compte";
// TODO Debug - This feature is dangerous, it takes all the entries and adds all the accounts
// without time and class limits (Class 6 and 7 accounts ???) and does not take into account the "a-nouveau" journal.
if (!empty($conf->global->ACCOUNTANCY_SHOW_OPENING_BALANCE)) {
$sql = "SELECT t.numero_compte, (SUM(t.debit) - SUM(t.credit)) as opening_balance";
$sql .= " FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping as t";
$sql .= " WHERE t.entity = " . $conf->entity; // Never do sharing into accounting features
$sql .= " AND t.doc_date < '" . $db->idate($search_date_start) . "'";
$sql .= " GROUP BY t.numero_compte";
$resql = $db->query($sql);
$nrows = $resql->num_rows;
$opening_balances = array();
for ($i = 0; $i < $nrows; $i++) {
$arr = $resql->fetch_array();
$opening_balances["'".$arr['numero_compte']."'"] = $arr['opening_balance'];
$resql = $db->query($sql);
$nrows = $resql->num_rows;
$opening_balances = array();
for ($i = 0; $i < $nrows; $i++) {
$arr = $resql->fetch_array();
$opening_balances["'" . $arr['numero_compte'] . "'"] = $arr['opening_balance'];
}
}
foreach ($object->lines as $line)
{
// reset before the fetch (in case of the fetch fails)
$accountingaccountstatic->id = 0;
$accountingaccountstatic->account_number = '';
$accountingaccountstatic->fetch(null, $line->numero_compte, true);
if (!empty($accountingaccountstatic->account_number)) {
$accounting_account = $accountingaccountstatic->getNomUrl(0, 1);
@ -311,8 +321,8 @@ if ($action != 'export_csv')
$root_account_description = $tmparrayforrootaccount['label'];
$root_account_number = $tmparrayforrootaccount['account_number'];
if (empty($accountingaccountstatic->account_number)) {
$link = '<a href="'.DOL_URL_ROOT.'/accountancy/admin/card.php?action=create&accountingaccount='.length_accountg($line->numero_compte).'">'.img_edit_add().'</a>';
if (empty($accountingaccountstatic->label) && $accountingaccountstatic->id > 0) {
$link = '<a href="'.DOL_URL_ROOT.'/accountancy/admin/card.php?action=update&token='.newToken().'&id='.$accountingaccountstatic->id.'">'.img_edit().'</a>';
}
if (!empty($show_subgroup))
@ -322,17 +332,22 @@ if ($action != 'export_csv')
// Show subtotal per accounting account
if ($displayed_account != "") {
print '<tr class="liste_total">';
print '<td class="right" colspan="2">'.$langs->trans("SubTotal").':</td>';
print '<td class="right">'.$langs->trans("SubTotal").':</td>';
if (!empty($conf->global->ACCOUNTANCY_SHOW_OPENING_BALANCE)) print '<td class="nowrap right">'.price($sous_total_opening_balance).'</td>';
print '<td class="nowrap right">'.price($sous_total_debit).'</td>';
print '<td class="nowrap right">'.price($sous_total_credit).'</td>';
print '<td class="nowrap right">'.price(price2num($sous_total_opening_balance + $sous_total_credit - $sous_total_debit)).'</td>';
if (!empty($conf->global->ACCOUNTANCY_SHOW_OPENING_BALANCE)) {
print '<td class="nowrap right">'.price(price2num($sous_total_opening_balance + $sous_total_debit - $sous_total_credit)).'</td>';
} else {
print '<td class="nowrap right">'.price(price2num($sous_total_debit - $sous_total_credit)).'</td>';
}
print "<td></td>\n";
print '</tr>';
}
// Show first line of a break
print '<tr class="trforbreak">';
print '<td colspan="6" style="font-weight:bold; border-bottom: 1pt solid black;">'.$line->numero_compte.($root_account_description ? ' - '.$root_account_description : '').'</td>';
print '<td colspan="'.($colspan+1).'" style="font-weight:bold; border-bottom: 1pt solid black;">'.$line->numero_compte.($root_account_description ? ' - '.$root_account_description : '').'</td>';
print '</tr>';
$displayed_account = $root_account_number;
@ -344,10 +359,14 @@ if ($action != 'export_csv')
print '<tr class="oddeven">';
print '<td>'.$accounting_account.'</td>';
print '<td class="nowraponall right">'.price($opening_balance).'</td>';
if (!empty($conf->global->ACCOUNTANCY_SHOW_OPENING_BALANCE)) print '<td class="nowraponall right">'.price($opening_balance).'</td>';
print '<td class="nowraponall right">'.price($line->debit).'</td>';
print '<td class="nowraponall right">'.price($line->credit).'</td>';
print '<td class="nowraponall right">'.price(price2num($opening_balance + $line->debit - $line->credit, 'MT')).'</td>';
if (!empty($conf->global->ACCOUNTANCY_SHOW_OPENING_BALANCE)) {
print '<td class="nowraponall right">'.price(price2num($opening_balance + $line->debit - $line->credit, 'MT')).'</td>';
} else {
print '<td class="nowraponall right">'.price(price2num($line->debit - $line->credit, 'MT')).'</td>';
}
print '<td class="center">'.$link;
print '</td>';
print "</tr>\n";
@ -360,12 +379,28 @@ if ($action != 'export_csv')
if (!empty($show_subgroup))
{
print '<tr class="liste_total"><td class="right" colspan="2">'.$langs->trans("SubTotal").':</td><td class="nowrap right">'.price($sous_total_debit).'</td><td class="nowrap right">'.price($sous_total_credit).'</td><td class="nowrap right">'.price(price2num($sous_total_opening_balance + $sous_total_debit - $sous_total_credit, 'MT')).'</td>';
print '<tr class="liste_total"><td class="right">'.$langs->trans("SubTotal").':</td>';
if (!empty($conf->global->ACCOUNTANCY_SHOW_OPENING_BALANCE)) print '<td class="nowrap right">'.price($sous_total_opening_balance).'</td>';
print '<td class="nowrap right">'.price($sous_total_debit).'</td>';
print '<td class="nowrap right">'.price($sous_total_credit).'</td>';
if (!empty($conf->global->ACCOUNTANCY_SHOW_OPENING_BALANCE)) {
print '<td class="nowrap right">' . price(price2num($sous_total_opening_balance + $sous_total_debit - $sous_total_credit, 'MT')) . '</td>';
} else {
print '<td class="nowrap right">' . price(price2num($sous_total_debit - $sous_total_credit, 'MT')) . '</td>';
}
print "<td></td>\n";
print '</tr>';
}
print '<tr class="liste_total"><td class="right" colspan="2">'.$langs->trans("AccountBalance").':</td><td class="nowrap right">'.price($total_debit).'</td><td class="nowrap right">'.price($total_credit).'</td><td class="nowrap right">'.price(price2num($total_opening_balance + $total_debit - $total_credit, 'MT')).'</td>';
print '<tr class="liste_total"><td class="right">'.$langs->trans("AccountBalance").':</td>';
if (!empty($conf->global->ACCOUNTANCY_SHOW_OPENING_BALANCE)) print '<td class="nowrap right">'.price($total_opening_balance).'</td>';
print '<td class="nowrap right">'.price($total_debit).'</td>';
print '<td class="nowrap right">'.price($total_credit).'</td>';
if (!empty($conf->global->ACCOUNTANCY_SHOW_OPENING_BALANCE)) {
print '<td class="nowrap right">' . price(price2num($total_opening_balance + $total_debit - $total_credit, 'MT')) . '</td>';
} else {
print '<td class="nowrap right">' . price(price2num($total_debit - $total_credit, 'MT')) . '</td>';
}
print "<td></td>\n";
print '</tr>';

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

@ -251,7 +251,7 @@ PaymentsNotLinkedToProduct=Payment not linked to any product / service
OpeningBalance=Opening balance
ShowOpeningBalance=Show opening balance
HideOpeningBalance=Hide opening balance
ShowSubtotalByGroup=Show subtotal by group
ShowSubtotalByGroup=Show subtotal by level
Pcgtype=Group of account
PcgtypeDesc=Group of account are used as predefined 'filter' and 'grouping' criteria for some accounting reports. For example, 'INCOME' or 'EXPENSE' are used as groups for accounting accounts of products to build the expense/income report.

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

@ -88,6 +88,10 @@ class PaymentSalary extends CommonObject
*/
public $fk_user_modif;
/**
* @var array Array with all fields and their property. Do not use it as a static var. It may be modified by constructor.
*/
public $fields = array();
/**
* Constructor
@ -120,8 +124,7 @@ class PaymentSalary extends CommonObject
$this->note = trim($this->note);
// Check parameters
if (empty($this->fk_user) || $this->fk_user < 0)
{
if (empty($this->fk_user) || $this->fk_user < 0) {
$this->error = 'ErrorBadParameter';
return -1;
}
@ -151,35 +154,29 @@ class PaymentSalary extends CommonObject
dol_syslog(get_class($this)."::update", LOG_DEBUG);
$resql = $this->db->query($sql);
if (!$resql)
{
if (!$resql) {
$this->error = "Error ".$this->db->lasterror();
return -1;
}
// Update extrafield
if (!$error)
{
if (!$error)
{
$result = $this->insertExtraFields();
if ($result < 0)
{
$error++;
}
if (!$error) {
$result = $this->insertExtraFields();
if ($result < 0) {
$error++;
}
}
if (!$notrigger)
{
if (!$notrigger) {
// Call trigger
$result = $this->call_trigger('PAYMENT_SALARY_MODIFY', $user);
if ($result < 0) $error++;
if ($result < 0) {
$error++;
}
// End call triggers
}
if (!$error)
{
if (!$error) {
$this->db->commit();
return 1;
} else {
@ -227,26 +224,24 @@ class PaymentSalary extends CommonObject
dol_syslog(get_class($this)."::fetch", LOG_DEBUG);
$resql = $this->db->query($sql);
if ($resql)
{
if ($this->db->num_rows($resql))
{
if ($resql) {
if ($this->db->num_rows($resql)) {
$obj = $this->db->fetch_object($resql);
$this->id = $obj->rowid;
$this->ref = $obj->rowid;
$this->tms = $this->db->jdate($obj->tms);
$this->ref = $obj->rowid;
$this->tms = $this->db->jdate($obj->tms);
$this->fk_user = $obj->fk_user;
$this->datep = $this->db->jdate($obj->datep);
$this->datev = $this->db->jdate($obj->datev);
$this->datep = $this->db->jdate($obj->datep);
$this->datev = $this->db->jdate($obj->datev);
$this->amount = $obj->amount;
$this->fk_project = $obj->fk_project;
$this->type_payement = $obj->fk_typepayment;
$this->num_payment = $obj->num_payment;
$this->label = $obj->label;
$this->datesp = $this->db->jdate($obj->datesp);
$this->dateep = $this->db->jdate($obj->dateep);
$this->note = $obj->note;
$this->label = $obj->label;
$this->datesp = $this->db->jdate($obj->datesp);
$this->dateep = $this->db->jdate($obj->dateep);
$this->note = $obj->note;
$this->fk_bank = $obj->fk_bank;
$this->fk_user_author = $obj->fk_user_author;
$this->fk_user_modif = $obj->fk_user_modif;
@ -282,18 +277,18 @@ class PaymentSalary extends CommonObject
// Call trigger
$result = $this->call_trigger('PAYMENT_SALARY_DELETE', $user);
if ($result < 0) return -1;
if ($result < 0) {
return -1;
}
// End call triggers
// Delete donation
if (!$error)
{
if (!$error) {
$sql = "DELETE FROM ".MAIN_DB_PREFIX."payment_salary_extrafields";
$sql .= " WHERE fk_object=".$this->id;
$resql = $this->db->query($sql);
if (!$resql)
{
if (!$resql) {
$this->errors[] = $this->db->lasterror();
$error++;
}
@ -304,8 +299,7 @@ class PaymentSalary extends CommonObject
dol_syslog(get_class($this)."::delete", LOG_DEBUG);
$resql = $this->db->query($sql);
if (!$resql)
{
if (!$resql) {
$this->error = "Error ".$this->db->lasterror();
return -1;
}
@ -326,7 +320,7 @@ class PaymentSalary extends CommonObject
$this->id = 0;
$this->tms = '';
$this->fk_user = '';
$this->fk_user = 1;
$this->datep = '';
$this->datev = '';
$this->amount = '';
@ -335,8 +329,8 @@ class PaymentSalary extends CommonObject
$this->dateep = '';
$this->note = '';
$this->fk_bank = '';
$this->fk_user_author = '';
$this->fk_user_modif = '';
$this->fk_user_author = 1;
$this->fk_user_modif = 1;
}
/**
@ -356,34 +350,29 @@ class PaymentSalary extends CommonObject
$this->amount = price2num(trim($this->amount));
$this->label = trim($this->label);
$this->note = trim($this->note);
$this->fk_bank = trim($this->fk_bank);
$this->fk_user_author = trim($this->fk_user_author);
$this->fk_user_modif = trim($this->fk_user_modif);
$this->fk_bank = (int) $this->fk_bank;
$this->fk_user_author = (int) $this->fk_user_author;
$this->fk_user_modif = (int) $this->fk_user_modif;
// Check parameters
if (!$this->label)
{
$this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentities("Label"));
if (!$this->label) {
$this->errors[] = $langs->trans("ErrorFieldRequired", $langs->transnoentities("Label"));
return -3;
}
if ($this->fk_user < 0 || $this->fk_user == '')
{
$this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentities("Employee"));
if ($this->fk_user <= 0 || $this->fk_user == '') {
$this->errors[] = $langs->trans("ErrorFieldRequired", $langs->transnoentities("Employee"));
return -4;
}
if ($this->amount < 0 || $this->amount == '')
{
$this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentities("Amount"));
if ($this->amount < 0 || $this->amount == '') {
$this->errors[] = $langs->trans("ErrorFieldRequired", $langs->transnoentities("Amount"));
return -5;
}
if (!empty($conf->banque->enabled) && (empty($this->accountid) || $this->accountid <= 0))
{
$this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentities("Account"));
if (!empty($conf->banque->enabled) && (empty($this->accountid) || $this->accountid <= 0)) {
$this->errors[] = $langs->trans("ErrorFieldRequired", $langs->transnoentities("Account"));
return -6;
}
if (!empty($conf->banque->enabled) && (empty($this->type_payment) || $this->type_payment <= 0))
{
$this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentities("PaymentMode"));
if (!empty($conf->banque->enabled) && (empty($this->type_payment) || $this->type_payment <= 0)) {
$this->errors[] = $langs->trans("ErrorFieldRequired", $langs->transnoentities("PaymentMode"));
return -7;
}
@ -398,7 +387,9 @@ class PaymentSalary extends CommonObject
$sql .= ", salary";
$sql .= ", fk_typepayment";
$sql .= ", num_payment";
if ($this->note) $sql .= ", note";
if ($this->note) {
$sql .= ", note";
}
$sql .= ", label";
$sql .= ", datesp";
$sql .= ", dateep";
@ -416,7 +407,9 @@ class PaymentSalary extends CommonObject
$sql .= ", ".($this->salary > 0 ? $this->salary : "null");
$sql .= ", ".$this->db->escape($this->type_payment);
$sql .= ", '".$this->db->escape($this->num_payment)."'";
if ($this->note) $sql .= ", '".$this->db->escape($this->note)."'";
if ($this->note) {
$sql .= ", '".$this->db->escape($this->note)."'";
}
$sql .= ", '".$this->db->escape($this->label)."'";
$sql .= ", '".$this->db->idate($this->datesp)."'";
$sql .= ", '".$this->db->idate($this->dateep)."'";
@ -428,30 +421,25 @@ class PaymentSalary extends CommonObject
dol_syslog(get_class($this)."::create", LOG_DEBUG);
$result = $this->db->query($sql);
if ($result)
{
if ($result) {
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."payment_salary");
if ($this->id > 0)
{
if (!empty($conf->banque->enabled) && !empty($this->amount))
{
if ($this->id > 0) {
if (!empty($conf->banque->enabled) && !empty($this->amount)) {
// Insert into llx_bank
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
$acc = new Account($this->db);
$result = $acc->fetch($this->accountid);
if ($result <= 0) dol_print_error($this->db);
if ($result <= 0) {
dol_print_error($this->db);
}
// Update extrafield
if (!$error) {
if (!$error)
{
$result = $this->insertExtraFields();
if ($result < 0)
{
$error++;
}
$result = $this->insertExtraFields();
if ($result < 0) {
$error++;
}
}
@ -473,22 +461,19 @@ class PaymentSalary extends CommonObject
// Update fk_bank into llx_paiement.
// So we know the payment which has generate the banking ecriture
if ($bank_line_id > 0)
{
if ($bank_line_id > 0) {
$this->update_fk_bank($bank_line_id);
} else {
$this->error = $acc->error;
$error++;
}
if (!$error)
{
if (!$error) {
// Add link 'payment_salary' in bank_url between payment and bank transaction
$url = DOL_URL_ROOT.'/salaries/card.php?id=';
$result = $acc->add_url_line($bank_line_id, $this->id, $url, "(SalaryPayment)", "payment_salary");
if ($result <= 0)
{
if ($result <= 0) {
$this->error = $acc->error;
$error++;
}
@ -507,8 +492,7 @@ class PaymentSalary extends CommonObject
'user'
);
if ($result <= 0)
{
if ($result <= 0) {
$this->error = $acc->error;
$error++;
}
@ -516,12 +500,15 @@ class PaymentSalary extends CommonObject
// Call trigger
$result = $this->call_trigger('PAYMENT_SALARY_CREATE', $user);
if ($result < 0) $error++;
if ($result < 0) {
$error++;
}
// End call triggers
} else $error++;
} else {
$error++;
}
if (!$error)
{
if (!$error) {
$this->db->commit();
return $this->id;
} else {
@ -548,8 +535,7 @@ class PaymentSalary extends CommonObject
$sql = 'UPDATE '.MAIN_DB_PREFIX.'payment_salary SET fk_bank = '.$id_bank;
$sql .= ' WHERE rowid = '.$this->id;
$result = $this->db->query($sql);
if ($result)
{
if ($result) {
return 1;
} else {
dol_print_error($this->db);
@ -574,7 +560,9 @@ class PaymentSalary extends CommonObject
global $dolibarr_main_authentication, $dolibarr_main_demo;
global $menumanager;
if (!empty($conf->dol_no_mouse_hover)) $notooltip = 1; // Force disable tooltips
if (!empty($conf->dol_no_mouse_hover)) {
$notooltip = 1; // Force disable tooltips
}
$result = '';
@ -583,10 +571,11 @@ class PaymentSalary extends CommonObject
if (!empty($this->label)) {
$labeltoshow = $this->label;
$reg = array();
if (preg_match('/^\((.*)\)$/i', $this->label, $reg))
{
if (preg_match('/^\((.*)\)$/i', $this->label, $reg)) {
// Label generique car entre parentheses. On l'affiche en le traduisant
if ($reg[1] == 'paiement') $reg[1] = 'Payment';
if ($reg[1] == 'paiement') {
$reg[1] = 'Payment';
}
$labeltoshow = $langs->trans($reg[1]);
}
$label .= '<br><b>'.$langs->trans('Label').':</b> '.$labeltoshow;
@ -594,19 +583,20 @@ class PaymentSalary extends CommonObject
$url = DOL_URL_ROOT.'/salaries/card.php?id='.$this->id;
if ($option != 'nolink')
{
if ($option != 'nolink') {
// Add param to save lastsearch_values or not
$add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values = 1;
if ($add_save_lastsearch_values) $url .= '&save_lastsearch_values=1';
if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) {
$add_save_lastsearch_values = 1;
}
if ($add_save_lastsearch_values) {
$url .= '&save_lastsearch_values=1';
}
}
$linkclose = '';
if (empty($notooltip))
{
if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER))
{
if (empty($notooltip)) {
if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) {
$label = $langs->trans("ShowMyObject");
$linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"';
}
@ -614,20 +604,26 @@ class PaymentSalary extends CommonObject
$linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"';
/*
$hookmanager->initHooks(array('myobjectdao'));
$parameters=array('id'=>$this->id);
$reshook=$hookmanager->executeHooks('getnomurltooltip',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks
if ($reshook > 0) $linkclose = $hookmanager->resPrint;
*/
} else $linkclose = ($morecss ? ' class="'.$morecss.'"' : '');
$hookmanager->initHooks(array('myobjectdao'));
$parameters=array('id'=>$this->id);
$reshook=$hookmanager->executeHooks('getnomurltooltip',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks
if ($reshook > 0) $linkclose = $hookmanager->resPrint;
*/
} else {
$linkclose = ($morecss ? ' class="'.$morecss.'"' : '');
}
$linkstart = '<a href="'.$url.'"';
$linkstart .= $linkclose.'>';
$linkend = '</a>';
$result .= $linkstart;
if ($withpicto) $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1);
if ($withpicto != 2) $result .= $this->ref;
if ($withpicto) {
$result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1);
}
if ($withpicto != 2) {
$result .= $this->ref;
}
$result .= $linkend;
//if ($withpicto != 2) $result.=(($addlabel && $this->label) ? $sep . dol_trunc($this->label, ($addlabel > 1 ? $addlabel : 0)) : '');
@ -635,8 +631,11 @@ class PaymentSalary extends CommonObject
$hookmanager->initHooks(array('salarypayment'));
$parameters = array('id'=>$this->id, 'getnomurl'=>$result);
$reshook = $hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
if ($reshook > 0) $result = $hookmanager->resPrint;
else $result .= $hookmanager->resPrint;
if ($reshook > 0) {
$result = $hookmanager->resPrint;
} else {
$result .= $hookmanager->resPrint;
}
return $result;
}
@ -656,14 +655,11 @@ class PaymentSalary extends CommonObject
dol_syslog(get_class($this).'::info', LOG_DEBUG);
$result = $this->db->query($sql);
if ($result)
{
if ($this->db->num_rows($result))
{
if ($result) {
if ($this->db->num_rows($result)) {
$obj = $this->db->fetch_object($result);
$this->id = $obj->rowid;
if ($obj->fk_user_author)
{
if ($obj->fk_user_author) {
$cuser = new User($this->db);
$cuser->fetch($obj->fk_user_author);
$this->user_creation = $cuser;
@ -703,40 +699,40 @@ class PaymentSalary extends CommonObject
$langs->load('compta');
/*if ($mode == 0)
{
if ($status == 0) return $langs->trans('ToValidate');
if ($status == 1) return $langs->trans('Validated');
}
if ($mode == 1)
{
if ($status == 0) return $langs->trans('ToValidate');
if ($status == 1) return $langs->trans('Validated');
}
if ($mode == 2)
{
if ($status == 0) return img_picto($langs->trans('ToValidate'),'statut1').' '.$langs->trans('ToValidate');
if ($status == 1) return img_picto($langs->trans('Validated'),'statut4').' '.$langs->trans('Validated');
}
if ($mode == 3)
{
if ($status == 0) return img_picto($langs->trans('ToValidate'),'statut1');
if ($status == 1) return img_picto($langs->trans('Validated'),'statut4');
}
if ($mode == 4)
{
if ($status == 0) return img_picto($langs->trans('ToValidate'),'statut1').' '.$langs->trans('ToValidate');
if ($status == 1) return img_picto($langs->trans('Validated'),'statut4').' '.$langs->trans('Validated');
}
if ($mode == 5)
{
if ($status == 0) return $langs->trans('ToValidate').' '.img_picto($langs->trans('ToValidate'),'statut1');
if ($status == 1) return $langs->trans('Validated').' '.img_picto($langs->trans('Validated'),'statut4');
}
if ($mode == 6)
{
if ($status == 0) return $langs->trans('ToValidate').' '.img_picto($langs->trans('ToValidate'),'statut1');
if ($status == 1) return $langs->trans('Validated').' '.img_picto($langs->trans('Validated'),'statut4');
}*/
{
if ($status == 0) return $langs->trans('ToValidate');
if ($status == 1) return $langs->trans('Validated');
}
if ($mode == 1)
{
if ($status == 0) return $langs->trans('ToValidate');
if ($status == 1) return $langs->trans('Validated');
}
if ($mode == 2)
{
if ($status == 0) return img_picto($langs->trans('ToValidate'),'statut1').' '.$langs->trans('ToValidate');
if ($status == 1) return img_picto($langs->trans('Validated'),'statut4').' '.$langs->trans('Validated');
}
if ($mode == 3)
{
if ($status == 0) return img_picto($langs->trans('ToValidate'),'statut1');
if ($status == 1) return img_picto($langs->trans('Validated'),'statut4');
}
if ($mode == 4)
{
if ($status == 0) return img_picto($langs->trans('ToValidate'),'statut1').' '.$langs->trans('ToValidate');
if ($status == 1) return img_picto($langs->trans('Validated'),'statut4').' '.$langs->trans('Validated');
}
if ($mode == 5)
{
if ($status == 0) return $langs->trans('ToValidate').' '.img_picto($langs->trans('ToValidate'),'statut1');
if ($status == 1) return $langs->trans('Validated').' '.img_picto($langs->trans('Validated'),'statut4');
}
if ($mode == 6)
{
if ($status == 0) return $langs->trans('ToValidate').' '.img_picto($langs->trans('ToValidate'),'statut1');
if ($status == 1) return $langs->trans('Validated').' '.img_picto($langs->trans('Validated'),'statut4');
}*/
return '';
}
}

View File

@ -26,7 +26,9 @@
require '../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/salaries/class/paymentsalary.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
if (!empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingjournal.class.php';
if (!empty($conf->accounting->enabled)) {
require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingjournal.class.php';
}
// Load translation files required by the page
$langs->loadLangs(array("compta", "salaries", "bills", "hrm"));
@ -46,12 +48,18 @@ $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
$sortfield = GETPOST('sortfield', 'aZ09comma');
$sortorder = GETPOST('sortorder', 'aZ09comma');
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
if (empty($page) || $page == -1 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha') || (empty($toselect) && $massaction === '0')) { $page = 0; } // If $page is not defined, or '' or -1 or if we click on clear filters or if we select empty mass action
if (empty($page) || $page == -1 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha') || (empty($toselect) && $massaction === '0')) {
$page = 0;
} // If $page is not defined, or '' or -1 or if we click on clear filters or if we select empty mass action
$offset = $limit * $page;
$pageprev = $page - 1;
$pagenext = $page + 1;
if (!$sortfield) $sortfield = "s.datep,s.rowid";
if (!$sortorder) $sortorder = "DESC,DESC";
if (!$sortfield) {
$sortfield = "s.datep,s.rowid";
}
if (!$sortorder) {
$sortorder = "DESC,DESC";
}
// Initialize technical objects
$object = new PaymentSalary($db);
@ -64,8 +72,12 @@ $extrafields->fetch_name_optionals_label($object->table_element);
$search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_');
if (!$sortfield) $sortfield = "s.datep,s.rowid";
if (!$sortorder) $sortorder = "DESC,DESC";
if (!$sortfield) {
$sortfield = "s.datep,s.rowid";
}
if (!$sortorder) {
$sortorder = "DESC,DESC";
}
$search_ref = GETPOST('search_ref', 'int');
$search_user = GETPOST('search_user', 'alpha');
@ -77,14 +89,14 @@ $search_account = GETPOST('search_account', 'int');
$filtre = GETPOST("filtre", 'restricthtml');
if (!GETPOST('search_type_id', 'int'))
{
if (!GETPOST('search_type_id', 'int')) {
$newfiltre = str_replace('filtre=', '', $filtre);
$filterarray = explode('-', $newfiltre);
foreach ($filterarray as $val)
{
foreach ($filterarray as $val) {
$part = explode(':', $val);
if ($part[0] == 's.fk_typepayment') $search_type_id = $part[1];
if ($part[0] == 's.fk_typepayment') {
$search_type_id = $part[1];
}
}
} else {
$search_type_id = GETPOST('search_type_id', 'int');
@ -94,22 +106,26 @@ $childids = $user->getAllChildIds(1);
// Security check
$socid = GETPOST("socid", "int");
if ($user->socid) $socid = $user->socid;
if ($user->socid) {
$socid = $user->socid;
}
$result = restrictedArea($user, 'salaries', '', '', '');
// Initialize array of search criterias
$search_all = GETPOST("search_all", 'alpha');
$search = array();
foreach ($object->fields as $key => $val)
{
if (GETPOST('search_'.$key, 'alpha') !== '') $search[$key] = GETPOST('search_'.$key, 'alpha');
foreach ($object->fields as $key => $val) {
if (GETPOST('search_'.$key, 'alpha') !== '') {
$search[$key] = GETPOST('search_'.$key, 'alpha');
}
}
// List of fields to search into when doing a "search in all"
$fieldstosearchall = array();
foreach ($object->fields as $key => $val)
{
if ($val['searchall']) $fieldstosearchall['t.'.$key] = $val['label'];
foreach ($object->fields as $key => $val) {
if ($val['searchall']) {
$fieldstosearchall['t.'.$key] = $val['label'];
}
}
$permissiontoread = $user->rights->salaries->read;
@ -121,21 +137,26 @@ $permissiontodelete = $user->rights->salaries->delete;
* Actions
*/
if (GETPOST('cancel', 'alpha')) { $action = 'list'; $massaction = ''; }
if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction = ''; }
if (GETPOST('cancel', 'alpha')) {
$action = 'list';
$massaction = '';
}
if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') {
$massaction = '';
}
$parameters = array();
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
if ($reshook < 0) {
setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
}
if (empty($reshook))
{
if (empty($reshook)) {
// Selection of new fields
include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
// Purge search criteria
if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All test are required to be compatible with all browsers
{
if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All test are required to be compatible with all browsers
$search_ref = "";
$search_user = "";
$search_label = "";
@ -146,8 +167,7 @@ if (empty($reshook))
$search_type_id = "";
}
if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')
|| GETPOST('button_search_x', 'alpha') || GETPOST('button_search.x', 'alpha') || GETPOST('button_search', 'alpha'))
{
|| GETPOST('button_search_x', 'alpha') || GETPOST('button_search.x', 'alpha') || GETPOST('button_search', 'alpha')) {
$massaction = ''; // Protection to avoid mass action if we force a new search during a mass action confirmation
}
@ -158,8 +178,7 @@ if (empty($reshook))
include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
// Validate records
if (!$error && $massaction == 'buildsepa' && $permissiontoadd)
{
if (!$error && $massaction == 'buildsepa' && $permissiontoadd) {
$objecttmp = new $objectclass($db);
// TODO
@ -192,16 +211,32 @@ $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."bank_account as ba ON b.fk_account = ba.ro
$sql .= " ".MAIN_DB_PREFIX."user as u";
$sql .= " WHERE u.rowid = s.fk_user";
$sql .= " AND s.entity IN (".getEntity('payment_salaries').")";
if (empty($user->rights->salaries->readall)) $sql .= " AND s.fk_user IN (".join(',', $childids).")";
if (empty($user->rights->salaries->readall)) {
$sql .= " AND s.fk_user IN (".join(',', $childids).")";
}
// Search criteria
if ($search_ref) $sql .= " AND s.rowid=".((int) $search_ref);
if ($search_user) $sql .= natural_search(array('u.login', 'u.lastname', 'u.firstname', 'u.email'), $search_user);
if ($search_label) $sql .= natural_search(array('s.label'), $search_label);
if ($search_date_start) $sql .= " AND s.datep >= '".$db->idate($search_date_start)."'";
if ($search_date_end) $sql .= " AND s.datep <= '".$db->idate($search_date_end)."'";
if ($search_amount) $sql .= natural_search("s.amount", $search_amount, 1);
if ($search_account > 0) $sql .= " AND b.fk_account=".((int) $search_account);
if ($search_ref) {
$sql .= " AND s.rowid=".((int) $search_ref);
}
if ($search_user) {
$sql .= natural_search(array('u.login', 'u.lastname', 'u.firstname', 'u.email'), $search_user);
}
if ($search_label) {
$sql .= natural_search(array('s.label'), $search_label);
}
if ($search_date_start) {
$sql .= " AND s.datep >= '".$db->idate($search_date_start)."'";
}
if ($search_date_end) {
$sql .= " AND s.datep <= '".$db->idate($search_date_end)."'";
}
if ($search_amount) {
$sql .= natural_search("s.amount", $search_amount, 1);
}
if ($search_account > 0) {
$sql .= " AND b.fk_account=".((int) $search_account);
}
if ($filtre) {
$filtre = str_replace(":", "=", $filtre);
$sql .= " AND ".$filtre;
@ -213,26 +248,24 @@ $sql .= $db->order($sortfield, $sortorder);
// Count total nb of records
$nbtotalofrecords = '';
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
{
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
$resql = $db->query($sql);
$nbtotalofrecords = $db->num_rows($resql);
if (($page * $limit) > $nbtotalofrecords) // if total of record found is smaller than page * limit, goto and load page 0
{
if (($page * $limit) > $nbtotalofrecords) { // if total of record found is smaller than page * limit, goto and load page 0
$page = 0;
$offset = 0;
}
}
// if total of record found is smaller than limit, no need to do paging and to restart another select with limits set.
if (is_numeric($nbtotalofrecords) && ($limit > $nbtotalofrecords || empty($limit)))
{
if (is_numeric($nbtotalofrecords) && ($limit > $nbtotalofrecords || empty($limit))) {
$num = $nbtotalofrecords;
} else {
if ($limit) $sql .= $db->plimit($limit + 1, $offset);
if ($limit) {
$sql .= $db->plimit($limit + 1, $offset);
}
$resql = $db->query($sql);
if (!$resql)
{
if (!$resql) {
dol_print_error($db);
exit;
}
@ -248,16 +281,36 @@ llxHeader('', $title, $help_url);
$arrayofselected = is_array($toselect) ? $toselect : array();
$param = '';
if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage);
if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit);
if ($search_type_id) $param .= '&search_type_id='.urlencode($search_type_id);
if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss);
if ($search_ref) $param .= '&search_ref='.urlencode($search_ref);
if ($search_user > 0) $param .= '&search_user='.urlencode($search_user);
if ($search_label) $param .= '&search_label='.urlencode($search_label);
if ($search_account) $param .= '&search_account='.urlencode($search_account);
if ($search_date_start) $param .= '&search_date_startday='.urlencode(GETPOST('search_date_startday', 'int')).'&search_date_startmonth='.urlencode(GETPOST('search_date_startmonth', 'int')).'&search_date_startyear='.urlencode(GETPOST('search_date_startyear', 'int'));
if ($search_date_end) $param .= '&search_date_endday='.urlencode(GETPOST('search_date_endday', 'int')).'&search_date_endmonth='.urlencode(GETPOST('search_date_endmonth', 'int')).'&search_date_endyear='.urlencode(GETPOST('search_date_endyear', 'int'));
if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
$param .= '&contextpage='.urlencode($contextpage);
}
if ($limit > 0 && $limit != $conf->liste_limit) {
$param .= '&limit='.urlencode($limit);
}
if ($search_type_id) {
$param .= '&search_type_id='.urlencode($search_type_id);
}
if ($optioncss != '') {
$param .= '&optioncss='.urlencode($optioncss);
}
if ($search_ref) {
$param .= '&search_ref='.urlencode($search_ref);
}
if ($search_user > 0) {
$param .= '&search_user='.urlencode($search_user);
}
if ($search_label) {
$param .= '&search_label='.urlencode($search_label);
}
if ($search_account) {
$param .= '&search_account='.urlencode($search_account);
}
if ($search_date_start) {
$param .= '&search_date_startday='.urlencode(GETPOST('search_date_startday', 'int')).'&search_date_startmonth='.urlencode(GETPOST('search_date_startmonth', 'int')).'&search_date_startyear='.urlencode(GETPOST('search_date_startyear', 'int'));
}
if ($search_date_end) {
$param .= '&search_date_endday='.urlencode(GETPOST('search_date_endday', 'int')).'&search_date_endmonth='.urlencode(GETPOST('search_date_endmonth', 'int')).'&search_date_endyear='.urlencode(GETPOST('search_date_endyear', 'int'));
}
// Add $param from extra fields
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
@ -267,11 +320,15 @@ $arrayofmassactions = array(
//'buildsepa'=>$langs->trans("BuildSepa"), // TODO
);
//if ($permissiontodelete) $arrayofmassactions['predelete'] = '<span class="fa fa-trash paddingrightonly"></span>'.$langs->trans("Delete");
if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete'))) $arrayofmassactions = array();
if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete'))) {
$arrayofmassactions = array();
}
$massactionbutton = $form->selectMassAction('', $arrayofmassactions);
print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">';
if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
if ($optioncss != '') {
print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
}
print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
print '<input type="hidden" name="action" value="list">';
@ -280,7 +337,9 @@ print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
$url = DOL_URL_ROOT.'/salaries/card.php?action=create';
if (!empty($socid)) $url .= '&socid='.$socid;
if (!empty($socid)) {
$url .= '&socid='.$socid;
}
$newcardbutton = dolGetButtonTitle($langs->trans('NewSalaryPayment'), '', 'fa fa-plus-circle', $url, '', $user->rights->salaries->write);
print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $totalnboflines, 'object_payment', 0, $newcardbutton, '', $limit, 0, 0, 1);
@ -323,8 +382,7 @@ print '<td class="liste_titre left">';
$form->select_types_paiements($search_type_id, 'search_type_id', '', 0, 1, 1, 16);
print '</td>';
// Account
if (!empty($conf->banque->enabled))
{
if (!empty($conf->banque->enabled)) {
print '<td class="liste_titre">';
$form->select_comptes($search_account, 'search_account', 0, '', 1);
print '</td>';
@ -356,7 +414,9 @@ print_liste_field_titre("Label", $_SERVER["PHP_SELF"], "s.label", "", $param, 'c
print_liste_field_titre("DatePayment", $_SERVER["PHP_SELF"], "s.datep,s.rowid", "", $param, '', $sortfield, $sortorder, 'center ');
print_liste_field_titre("DateValue", $_SERVER["PHP_SELF"], "s.datev,s.rowid", "", $param, '', $sortfield, $sortorder, 'center ');
print_liste_field_titre("PaymentMode", $_SERVER["PHP_SELF"], "type", "", $param, 'class="left"', $sortfield, $sortorder);
if (!empty($conf->banque->enabled)) print_liste_field_titre("BankAccount", $_SERVER["PHP_SELF"], "ba.label", "", $param, "", $sortfield, $sortorder);
if (!empty($conf->banque->enabled)) {
print_liste_field_titre("BankAccount", $_SERVER["PHP_SELF"], "ba.label", "", $param, "", $sortfield, $sortorder);
}
print_liste_field_titre("PayedByThisPayment", $_SERVER["PHP_SELF"], "s.amount", "", $param, 'class="right"', $sortfield, $sortorder);
// Extra fields
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
@ -371,11 +431,11 @@ print '</tr>'."\n";
// Detect if we need a fetch on each output line
$needToFetchEachLine = 0;
if (is_array($extrafields->attributes[$object->table_element]['computed']) && count($extrafields->attributes[$object->table_element]['computed']) > 0)
{
foreach ($extrafields->attributes[$object->table_element]['computed'] as $key => $val)
{
if (preg_match('/\$object/', $val)) $needToFetchEachLine++; // There is at least one compute field that use $object
if (is_array($extrafields->attributes[$object->table_element]['computed']) && count($extrafields->attributes[$object->table_element]['computed']) > 0) {
foreach ($extrafields->attributes[$object->table_element]['computed'] as $key => $val) {
if (preg_match('/\$object/', $val)) {
$needToFetchEachLine++; // There is at least one compute field that use $object
}
}
}
@ -384,10 +444,11 @@ if (is_array($extrafields->attributes[$object->table_element]['computed']) && co
$i = 0;
$total = 0;
$totalarray = array();
while ($i < ($limit ? min($num, $limit) : $num))
{
while ($i < ($limit ? min($num, $limit) : $num)) {
$obj = $db->fetch_object($resql);
if (empty($obj)) break; // Should not happen
if (empty($obj)) {
break; // Should not happen
}
// Store properties in $object
$object->setVarsFromFetchObj($obj);
@ -409,41 +470,50 @@ while ($i < ($limit ? min($num, $limit) : $num))
// Ref
print "<td>".$salstatic->getNomUrl(1)."</td>\n";
if (!$i) $totalarray['nbfield']++;
if (!$i) {
$totalarray['nbfield']++;
}
// Employee
print "<td>".$userstatic->getNomUrl(1)."</td>\n";
if (!$i) $totalarray['nbfield']++;
if (!$i) {
$totalarray['nbfield']++;
}
// Label payment
print "<td>".dol_trunc($obj->label, 40)."</td>\n";
if (!$i) $totalarray['nbfield']++;
if (!$i) {
$totalarray['nbfield']++;
}
// Date payment
print '<td class="center">'.dol_print_date($db->jdate($obj->datep), 'day')."</td>\n";
if (!$i) $totalarray['nbfield']++;
if (!$i) {
$totalarray['nbfield']++;
}
// Date value
print '<td class="center">'.dol_print_date($db->jdate($obj->datev), 'day')."</td>\n";
if (!$i) $totalarray['nbfield']++;
if (!$i) {
$totalarray['nbfield']++;
}
// Type
print '<td>'.$langs->trans("PaymentTypeShort".$obj->payment_code).' '.$obj->num_payment.'</td>';
if (!$i) $totalarray['nbfield']++;
if (!$i) {
$totalarray['nbfield']++;
}
// Account
if (!empty($conf->banque->enabled))
{
if (!empty($conf->banque->enabled)) {
print '<td>';
if ($obj->fk_bank > 0)
{
if ($obj->fk_bank > 0) {
//$accountstatic->fetch($obj->fk_bank);
$accountstatic->id = $obj->bid;
$accountstatic->ref = $obj->bref;
$accountstatic->number = $obj->bnumber;
if (!empty($conf->accounting->enabled))
{
if (!empty($conf->accounting->enabled)) {
$accountstatic->account_number = $obj->account_number;
$accountingjournal = new AccountingJournal($db);
@ -453,15 +523,23 @@ while ($i < ($limit ? min($num, $limit) : $num))
}
$accountstatic->label = $obj->blabel;
print $accountstatic->getNomUrl(1);
} else print '&nbsp;';
} else {
print '&nbsp;';
}
print '</td>';
if (!$i) $totalarray['nbfield']++;
if (!$i) {
$totalarray['nbfield']++;
}
}
// Amount
print '<td class="nowrap right">'.price($obj->amount).'</td>';
if (!$i) $totalarray['nbfield']++;
if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'totalttcfield';
if (!$i) {
$totalarray['nbfield']++;
}
if (!$i) {
$totalarray['pos'][$totalarray['nbfield']] = 'totalttcfield';
}
$totalarray['val']['totalttcfield'] += $obj->amount;
// Extra fields
@ -472,14 +550,17 @@ while ($i < ($limit ? min($num, $limit) : $num))
print $hookmanager->resPrint;
// Action column
print '<td class="nowrap center">';
if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
{
if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
$selected = 0;
if (in_array($object->id, $arrayofselected)) $selected = 1;
if (in_array($object->id, $arrayofselected)) {
$selected = 1;
}
print '<input id="cb'.$object->id.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$object->id.'"'.($selected ? ' checked="checked"' : '').'>';
}
print '</td>';
if (!$i) $totalarray['nbfield']++;
if (!$i) {
$totalarray['nbfield']++;
}
print '</tr>'."\n";
@ -491,10 +572,13 @@ include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
// If no record found
if ($num == 0)
{
if ($num == 0) {
$colspan = 1;
foreach ($arrayfields as $key => $val) { if (!empty($val['checked'])) $colspan++; }
foreach ($arrayfields as $key => $val) {
if (!empty($val['checked'])) {
$colspan++;
}
}
print '<tr><td colspan="'.$colspan.'" class="opacitymedium">'.$langs->trans("NoRecordFound").'</td></tr>';
}

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

@ -1773,7 +1773,7 @@ class User extends CommonObject
$adh->pass = $this->pass;
$adh->societe = (empty($adh->societe) && $this->societe_id ? $this->societe_id : $adh->societe);
//$adh->societe = (empty($adh->societe) && $this->societe_id ? $this->societe_id : $adh->societe);
$adh->address = $this->address;
$adh->town = $this->town;
@ -2385,6 +2385,7 @@ class User extends CommonObject
}
$result = ''; $label = '';
$companylink = '';
if (!empty($this->photo)) {
$label .= '<div class="photointooltip">';

View File

@ -270,10 +270,10 @@ function getContact($authentication, $id, $ref_ext)
if ($result > 0)
{
// Only internal user who have contact read permission
// Or for external user who have contact read permission, with restrict on societe_id
// Or for external user who have contact read permission, with restrict on socid
if (
$fuser->rights->societe->contact->lire && !$fuser->societe_id
|| ($fuser->rights->societe->contact->lire && ($fuser->societe_id == $contact->socid))
$fuser->rights->societe->contact->lire && !$fuser->socid
|| ($fuser->rights->societe->contact->lire && ($fuser->socid == $contact->socid))
) {
$contact_result_fields = array(
'id' => $contact->id,

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);
@ -367,7 +367,7 @@ function getOrder($authentication, $id = '', $ref = '', $ref_ext = '')
$fuser = check_authentication($authentication, $error, $errorcode, $errorlabel);
if ($fuser->societe_id) $socid = $fuser->societe_id;
if ($fuser->socid) $socid = $fuser->socid;
// Check parameters
if (!$error && (($id && $ref) || ($id && $ref_ext) || ($ref && $ref_ext)))
@ -387,10 +387,10 @@ function getOrder($authentication, $id = '', $ref = '', $ref_ext = '')
if ($result > 0)
{
// Security for external user
if ($socid && ($socid != $order->socid))
if ($socid && (empty($order->socid) || $socid != $order->socid))
{
$error++;
$errorcode = 'PERMISSION_DENIED'; $errorlabel = $order->socid.'User does not have permission for this request';
$errorcode = 'PERMISSION_DENIED'; $errorlabel = 'User does not have permission for this request';
}
if (!$error)
@ -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);
@ -516,7 +516,7 @@ function getOrdersForThirdParty($authentication, $idthirdparty)
$error = 0;
$fuser = check_authentication($authentication, $error, $errorcode, $errorlabel);
if ($fuser->societe_id) $socid = $fuser->societe_id;
if ($fuser->socid) $socid = $fuser->socid;
// Check parameters
if (!$error && empty($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);
@ -208,7 +208,7 @@ function getDocument($authentication, $modulepart, $file, $refname = '')
$fuser = check_authentication($authentication, $error, $errorcode, $errorlabel);
if ($fuser->societe_id) $socid = $fuser->societe_id;
if ($fuser->socid) $socid = $fuser->socid;
// Check parameters
if (!$error && (!$file || !$modulepart))
@ -234,7 +234,7 @@ function getDocument($authentication, $modulepart, $file, $refname = '')
$original_file = $check_access['original_file'];
// Basic protection (against external users only)
if ($fuser->societe_id > 0)
if ($fuser->socid > 0)
{
if ($sqlprotectagainstexternals)
{
@ -246,7 +246,7 @@ function getDocument($authentication, $modulepart, $file, $refname = '')
while ($i < $num)
{
$obj = $db->fetch_object($resql);
if ($fuser->societe_id != $obj->fk_soc)
if ($fuser->socid != $obj->fk_soc)
{
$accessallowed = 0;
break;
@ -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 (!empty($extrafield_array) && 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'];
@ -487,7 +485,7 @@ function createUserFromThirdparty($authentication, $thirdpartywithuser)
$fuser = check_authentication($authentication, $error, $errorcode, $errorlabel);
if ($fuser->societe_id) $socid = $fuser->societe_id;
if ($fuser->socid) $socid = $fuser->socid;
if (!$error && !$thirdpartywithuser)
{
@ -504,7 +502,7 @@ function createUserFromThirdparty($authentication, $thirdpartywithuser)
$thirdparty = new Societe($db);
// If a contact / company already exists with the email, return the corresponding socid
$sql = "SELECT s.rowid as societe_id FROM ".MAIN_DB_PREFIX."societe as s";
$sql = "SELECT s.rowid as socid FROM ".MAIN_DB_PREFIX."societe as s";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."socpeople as sp ON sp.fk_soc = s.rowid";
$sql .= " WHERE s.entity=".$conf->entity;
$sql .= " AND s.email='".$db->escape($thirdpartywithuser['email'])."'";
@ -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'];
@ -692,7 +690,7 @@ function setUserPassword($authentication, $shortuser)
$fuser = check_authentication($authentication, $error, $errorcode, $errorlabel);
if ($fuser->societe_id) $socid = $fuser->societe_id;
if ($fuser->socid) $socid = $fuser->socid;
if (!$error && !$shortuser)
{
@ -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