diff --git a/ChangeLog b/ChangeLog index 2a72296477c..43fecf4d2e7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2,8 +2,20 @@ English Dolibarr ChangeLog -------------------------------------------------------------- + +***** ChangeLog for 8.0.0 compared to 7.0.0 ***** + +WARNING: + +Following changes may create regressions for some external modules, but were necessary to make Dolibarr better: +* Hook 'maildao' was renamed into 'mail' into the method sendfile that send emails, and method was renamed from + 'doaction' into 'sendMail'. + + ***** ChangeLog for 7.0.0 compared to 6.0.5 ***** For users: +NEW: When payment is registered, PDF of invoices are also regenerated so payments + appears with no need to click on regenerate. NEW: #5711 Add shipment line deleting and editing for draft shipments. NEW: Accept substitution key __[ABC]__ replaced with value of const ABC NEW: Accountancy Add variant on sell account for intracommunity sales & export sales @@ -276,6 +288,12 @@ Following changes may create regressions for some external modules, but were nec and add 'td.' to the beginning of the dragHandle match string. * IE8 and earlier and Firefox 12 and earlier (< 2012) are no more supported. +* If you use the external module "multicompany", you must also upgrade the module. Multicompany module for + Dolibarr v7 is required because with Dolibarr v7, payment modes and payment conditions are management as data + that are dedicated to each company. If you keep your old version of multicompany module, mode and + condition of payments will appears empty in all companies that are not the first one. By upgrading the + multicompany module to a version that support Dolibarr v7, everything should work as expected. + ***** ChangeLog for 6.0.5 compared to 6.0.4 ***** FIX: security vulnerability reported by ADLab of Venustech diff --git a/htdocs/accountancy/bookkeeping/list.php b/htdocs/accountancy/bookkeeping/list.php index 8ecf04fdbc8..42328fbc1ed 100644 --- a/htdocs/accountancy/bookkeeping/list.php +++ b/htdocs/accountancy/bookkeeping/list.php @@ -87,7 +87,7 @@ $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; if ($sortorder == "") $sortorder = "ASC"; -if ($sortfield == "") $sortfield = "t.rowid"; +if ($sortfield == "") $sortfield = "t.piece_num,t.rowid"; $object = new BookKeeping($db); @@ -98,25 +98,30 @@ $form = new Form($db); if (! in_array($action, array('export_file', 'delmouv', 'delmouvconfirm')) && ! isset($_POST['begin']) && ! isset($_GET['begin']) && ! isset($_POST['formfilteraction']) && GETPOST('page','int') == '' && ! GETPOST('noreset','int')) { - $query = "SELECT date_start, date_end from ".MAIN_DB_PREFIX."accounting_fiscalyear "; - $query.= " where date_start < '".$this->idate(dol_now())."' and date_end > '".$this->idate(dol_now())."' limit 1"; - $res = $db->query($query); - if ($res->num_rows > 0) { - $fiscalYear = $db->fetch_object($res); - $search_date_start = strtotime($fiscalYear->date_start); - $search_date_end = strtotime($fiscalYear->date_end); - } else { - $month_start= ($conf->global->SOCIETE_FISCAL_MONTH_START?($conf->global->SOCIETE_FISCAL_MONTH_START):1); - $year_start = dol_print_date(dol_now(), '%Y'); - $year_end = $year_start + 1; - $month_end = $month_start - 1; - if ($month_end < 1) - { - $month_end = 12; - $year_end--; + if (empty($search_date_start) && empty($search_date_end)) + { + $query = "SELECT date_start, date_end from ".MAIN_DB_PREFIX."accounting_fiscalyear "; + $query.= " where date_start < '".$db->idate(dol_now())."' and date_end > '".$db->idate(dol_now())."' limit 1"; + $res = $db->query($query); + + if ($res->num_rows > 0) { + $fiscalYear = $db->fetch_object($res); + $search_date_start = strtotime($fiscalYear->date_start); + $search_date_end = strtotime($fiscalYear->date_end); + } else { + $month_start= ($conf->global->SOCIETE_FISCAL_MONTH_START?($conf->global->SOCIETE_FISCAL_MONTH_START):1); + $year_start = dol_print_date(dol_now(), '%Y'); + if (dol_print_date(dol_now(), '%m') < $month_start) $year_start--; // If current month is lower that starting fiscal month, we start last year + $year_end = $year_start + 1; + $month_end = $month_start - 1; + if ($month_end < 1) + { + $month_end = 12; + $year_end--; + } + $search_date_start = dol_mktime(0, 0, 0, $month_start, 1, $year_start); + $search_date_end = dol_get_last_day($year_end, $month_end); } - $search_date_start = dol_mktime(0, 0, 0, $month_start, 1, $year_start); - $search_date_end = dol_get_last_day($year_end, $month_end); } } @@ -124,7 +129,7 @@ if (! in_array($action, array('export_file', 'delmouv', 'delmouvconfirm')) && ! $arrayfields=array( 't.piece_num'=>array('label'=>$langs->trans("TransactionNumShort"), 'checked'=>1), 't.doc_date'=>array('label'=>$langs->trans("Docdate"), 'checked'=>1), - 't.doc_ref'=>array('label'=>$langs->trans("Docref"), 'checked'=>1), + 't.doc_ref'=>array('label'=>$langs->trans("Piece"), 'checked'=>1), 't.numero_compte'=>array('label'=>$langs->trans("AccountAccountingShort"), 'checked'=>1), 't.subledger_account'=>array('label'=>$langs->trans("SubledgerAccount"), 'checked'=>1), 't.label_operation'=>array('label'=>$langs->trans("Label"), 'checked'=>1), @@ -430,7 +435,7 @@ else $button.= $langs->trans("ExportList"); $button.= ''; -$groupby = ' ' . $langs->trans("GroupByAccountAccounting") . ''; +$groupby = ' ' . $langs->trans("GroupByAccountAccounting") . ''; $addbutton = '' . $langs->trans("NewAccountingMvt") . ''; print_barre_liste($title_page, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $button, $result, $nbtotalofrecords, 'title_accountancy', 0, $groupby.$addbutton, '', $limit); @@ -576,17 +581,17 @@ print ''; print "\n"; print ''; -if (! empty($arrayfields['t.piece_num']['checked'])) print_liste_field_titre("TransactionNumShort", $_SERVER['PHP_SELF'], "t.piece_num", "", $param, "", $sortfield, $sortorder); -if (! empty($arrayfields['t.doc_date']['checked'])) print_liste_field_titre("Docdate", $_SERVER['PHP_SELF'], "t.doc_date", "", $param, 'align="center"', $sortfield, $sortorder); -if (! empty($arrayfields['t.doc_ref']['checked'])) print_liste_field_titre("Docref", $_SERVER['PHP_SELF'], "t.doc_ref", "", $param, "", $sortfield, $sortorder); -if (! empty($arrayfields['t.numero_compte']['checked'])) print_liste_field_titre("AccountAccountingShort", $_SERVER['PHP_SELF'], "t.numero_compte", "", $param, "", $sortfield, $sortorder); -if (! empty($arrayfields['t.subledger_account']['checked'])) print_liste_field_titre("SubledgerAccount", $_SERVER['PHP_SELF'], "t.subledger_account", "", $param, "", $sortfield, $sortorder); -if (! empty($arrayfields['t.label_operation']['checked'])) print_liste_field_titre("Label", $_SERVER['PHP_SELF'], "t.label_operation", "", $param, "", $sortfield, $sortorder); -if (! empty($arrayfields['t.debit']['checked'])) print_liste_field_titre("Debit", $_SERVER['PHP_SELF'], "t.debit", "", $param, 'align="right"', $sortfield, $sortorder); -if (! empty($arrayfields['t.credit']['checked'])) print_liste_field_titre("Credit", $_SERVER['PHP_SELF'], "t.credit", "", $param, 'align="right"', $sortfield, $sortorder); -if (! empty($arrayfields['t.code_journal']['checked'])) print_liste_field_titre("Codejournal", $_SERVER['PHP_SELF'], "t.code_journal", "", $param, 'align="center"', $sortfield, $sortorder); -if (! empty($arrayfields['t.date_creation']['checked'])) print_liste_field_titre("DateCreation", $_SERVER['PHP_SELF'], "t.date_creation", "", $param, 'align="center"', $sortfield, $sortorder); -if (! empty($arrayfields['t.tms']['checked'])) print_liste_field_titre("DateModification", $_SERVER['PHP_SELF'], "t.tms", "", $param, 'align="center"', $sortfield, $sortorder); +if (! empty($arrayfields['t.piece_num']['checked'])) print_liste_field_titre($arrayfields['t.piece_num']['label'], $_SERVER['PHP_SELF'], "t.piece_num", "", $param, "", $sortfield, $sortorder); +if (! empty($arrayfields['t.doc_date']['checked'])) print_liste_field_titre($arrayfields['t.doc_date']['label'], $_SERVER['PHP_SELF'], "t.doc_date", "", $param, 'align="center"', $sortfield, $sortorder); +if (! empty($arrayfields['t.doc_ref']['checked'])) print_liste_field_titre($arrayfields['t.doc_ref']['label'], $_SERVER['PHP_SELF'], "t.doc_ref", "", $param, "", $sortfield, $sortorder); +if (! empty($arrayfields['t.numero_compte']['checked'])) print_liste_field_titre($arrayfields['t.numero_compte']['label'], $_SERVER['PHP_SELF'], "t.numero_compte", "", $param, "", $sortfield, $sortorder); +if (! empty($arrayfields['t.subledger_account']['checked'])) print_liste_field_titre($arrayfields['t.subledger_account']['label'], $_SERVER['PHP_SELF'], "t.subledger_account", "", $param, "", $sortfield, $sortorder); +if (! empty($arrayfields['t.label_operation']['checked'])) print_liste_field_titre($arrayfields['t.label_operation']['label'], $_SERVER['PHP_SELF'], "t.label_operation", "", $param, "", $sortfield, $sortorder); +if (! empty($arrayfields['t.debit']['checked'])) print_liste_field_titre($arrayfields['t.debit']['label'], $_SERVER['PHP_SELF'], "t.debit", "", $param, 'align="right"', $sortfield, $sortorder); +if (! empty($arrayfields['t.credit']['checked'])) print_liste_field_titre($arrayfields['t.credit']['label'], $_SERVER['PHP_SELF'], "t.credit", "", $param, 'align="right"', $sortfield, $sortorder); +if (! empty($arrayfields['t.code_journal']['checked'])) print_liste_field_titre($arrayfields['t.code_journal']['label'], $_SERVER['PHP_SELF'], "t.code_journal", "", $param, 'align="center"', $sortfield, $sortorder); +if (! empty($arrayfields['t.date_creation']['checked'])) print_liste_field_titre($arrayfields['t.date_creation']['label'], $_SERVER['PHP_SELF'], "t.date_creation", "", $param, 'align="center"', $sortfield, $sortorder); +if (! empty($arrayfields['t.tms']['checked'])) print_liste_field_titre($arrayfields['t.tms']['label'], $_SERVER['PHP_SELF'], "t.tms", "", $param, 'align="center"', $sortfield, $sortorder); print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"],"",'','','align="center"',$sortfield,$sortorder,'maxwidthsearch '); print "\n"; @@ -677,14 +682,14 @@ if ($num > 0) // Creation operation date if (! empty($arrayfields['t.date_creation']['checked'])) { - print '' . dol_print_date($line->date_creation, 'day') . ''; + print '' . dol_print_date($line->date_creation, 'dayhour') . ''; if (! $i) $totalarray['nbfield']++; } // Modification operation date if (! empty($arrayfields['t.tms']['checked'])) { - print '' . dol_print_date($line->date_modification, 'day') . ''; + print '' . dol_print_date($line->date_modification, 'dayhour') . ''; if (! $i) $totalarray['nbfield']++; } @@ -704,6 +709,7 @@ if ($num > 0) if (isset($totalarray['totaldebitfield']) || isset($totalarray['totalcreditfield'])) { $i=0; + print ''; while ($i < $totalarray['nbfield']) { $i++; diff --git a/htdocs/accountancy/bookkeeping/listbyaccount.php b/htdocs/accountancy/bookkeeping/listbyaccount.php index 08aa1aac19d..c450fb5bb63 100644 --- a/htdocs/accountancy/bookkeeping/listbyaccount.php +++ b/htdocs/accountancy/bookkeeping/listbyaccount.php @@ -68,7 +68,7 @@ $pagenext = $page + 1; if ($sortorder == "") $sortorder = "ASC"; if ($sortfield == "") $sortfield = "t.rowid"; -if (empty($search_date_start)) { +if (empty($search_date_start) && empty($search_date_end)) { $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.= $db->plimit(1); @@ -81,6 +81,7 @@ if (empty($search_date_start)) { } else { $month_start= ($conf->global->SOCIETE_FISCAL_MONTH_START?($conf->global->SOCIETE_FISCAL_MONTH_START):1); $year_start = dol_print_date(dol_now(), '%Y'); + if (dol_print_date(dol_now(), '%m') < $month_start) $year_start--; // If current month is lower that starting fiscal month, we start last year $year_end = $year_start + 1; $month_end = $month_start - 1; if ($month_end < 1) @@ -225,14 +226,13 @@ if ($action == 'delbookkeepingyear') { } - +$param=$options; print '
'; -$viewflat = ' ' . $langs->trans("ViewFlatList") . ''; +$viewflat = ' ' . $langs->trans("ViewFlatList") . ''; $addbutton = '' . $langs->trans("NewAccountingMvt") . ''; -$param=$options; if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.urlencode($contextpage); if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.urlencode($limit); diff --git a/htdocs/accountancy/class/bookkeeping.class.php b/htdocs/accountancy/class/bookkeeping.class.php index 4aba5bb0591..b59258f6cd7 100644 --- a/htdocs/accountancy/class/bookkeeping.class.php +++ b/htdocs/accountancy/class/bookkeeping.class.php @@ -781,7 +781,8 @@ class BookKeeping extends CommonObject $sql .= " t.code_journal,"; $sql .= " t.journal_label,"; $sql .= " t.piece_num,"; - $sql .= " t.date_creation"; + $sql .= " t.date_creation,"; + $sql .= " t.tms as date_modification"; $sql .= ' FROM ' . MAIN_DB_PREFIX . $this->table_element . ' as t'; // Manage filter $sqlwhere = array (); @@ -849,7 +850,8 @@ class BookKeeping extends CommonObject $line->code_journal = $obj->code_journal; $line->journal_label = $obj->journal_label; $line->piece_num = $obj->piece_num; - $line->date_creation = $obj->date_creation; + $line->date_creation = $this->db->jdate($obj->date_creation); + $line->date_modification = $this->db->jdate($obj->date_modification); $this->lines[] = $line; } diff --git a/htdocs/accountancy/journal/bankjournal.php b/htdocs/accountancy/journal/bankjournal.php index b9b079067b8..fcb24f7757a 100644 --- a/htdocs/accountancy/journal/bankjournal.php +++ b/htdocs/accountancy/journal/bankjournal.php @@ -303,6 +303,7 @@ if ($result) { } $chargestatic->ref = $chargestatic->lib; $tabpay[$obj->rowid]["soclib"] = $chargestatic->getNomUrl(1, 30); + $tabpay[$obj->rowid]["paymentscid"] = $chargestatic->id; $sqlmid = 'SELECT cchgsoc.accountancy_code'; $sqlmid .= " FROM " . MAIN_DB_PREFIX . "c_chargesociales cchgsoc "; @@ -401,7 +402,9 @@ if (! $error && $action == 'writebookkeeping') { $now = dol_now(); $error = 0; - foreach ( $tabpay as $key => $val ) { // $key is rowid into llx_bank + foreach ( $tabpay as $key => $val ) // $key is rowid into llx_bank + { + $date = dol_print_date($db->jdate($val["date"]), 'day'); $ref = getSourceDocRef($val, $tabtype[$key]); @@ -423,7 +426,14 @@ if (! $error && $action == 'writebookkeeping') { // Line into bank account foreach ( $tabbq[$key] as $k => $mt ) { - if ($mt) { + if ($mt) + { + $reflabel = $langs->trans("Bank"); + $reflabel.= ' '.$val['bank_account_ref']; + if (! empty($val['soclib'])) { + $reflabel .= " - " . dol_string_nohtmltag($val['soclib']); + } + $bookkeeping = new BookKeeping($db); $bookkeeping->doc_date = $val["date"]; $bookkeeping->doc_ref = $ref; @@ -442,31 +452,8 @@ if (! $error && $action == 'writebookkeeping') { $bookkeeping->date_create = $now; // No subledger_account value for the bank line but add a specific label_operation - if ($tabtype[$key] == 'payment') { - $bookkeeping->subledger_account = ''; - $bookkeeping->label_operation = $tabcompany[$key]['name'] . ' - ' . $ref; - } else if ($tabtype[$key] == 'payment_supplier') { - $bookkeeping->subledger_account = ''; - $bookkeeping->label_operation = $tabcompany[$key]['name'] . ' - ' . $ref; - } else if ($tabtype[$key] == 'payment_expensereport') { - $bookkeeping->subledger_account = ''; - $bookkeeping->label_operation = $tabuser[$key]['name'] . ' - ' . $ref; - } else if ($tabtype[$key] == 'payment_salary') { - $bookkeeping->subledger_account = ''; - $bookkeeping->label_operation = $tabuser[$key]['name'] . ' - ' . $ref; - } else if ($tabtype[$key] == 'payment_vat') { - $bookkeeping->subledger_account = ''; - $bookkeeping->label_operation = $ref; - } else if ($tabtype[$key] == 'payment_donation') { - $bookkeeping->subledger_account = ''; - $bookkeeping->label_operation = $ref; - } else if ($tabtype[$key] == 'payment_various') { - $bookkeeping->subledger_account = ''; - $bookkeeping->label_operation = $ref; - } else if ($tabtype[$key] == 'unknown') { - // ??? - $bookkeeping->subledger_account = ''; - } + $bookkeeping->subledger_account = ''; + $bookkeeping->label_operation = $reflabel; $totaldebit += $bookkeeping->debit; $totalcredit += $bookkeeping->credit; @@ -491,108 +478,151 @@ if (! $error && $action == 'writebookkeeping') { } // Third party - if (! $errorforline && is_array($tabtp[$key])) + if (! $errorforline) { - // Line into thirdparty account - foreach ( $tabtp[$key] as $k => $mt ) { - if ($mt) { - $bookkeeping = new BookKeeping($db); - $bookkeeping->doc_date = $val["date"]; - $bookkeeping->doc_ref = $ref; - $bookkeeping->doc_type = 'bank'; - $bookkeeping->fk_doc = $key; - $bookkeeping->fk_docdet = $val["fk_bank"]; - $bookkeeping->montant = $mt; - $bookkeeping->sens = ($mt < 0) ? 'D' : 'C'; - $bookkeeping->debit = ($mt < 0 ? - $mt : 0); - $bookkeeping->credit = ($mt >= 0) ? $mt : 0; - $bookkeeping->code_journal = $journal; - $bookkeeping->journal_label = $journal_label; - $bookkeeping->fk_user_author = $user->id; - $bookkeeping->date_create = $now; + if (is_array($tabtp[$key])) + { + // Line into thirdparty account + foreach ( $tabtp[$key] as $k => $mt ) { + if ($mt) + { + $reflabel = dol_string_nohtmltag($val['soclib']); - if ($tabtype[$key] == 'payment') { // If payment is payment of customer invoice, we get ref of invoice - $bookkeeping->label_operation = $tabcompany[$key]['name'] . ' - ' . $ref; - $bookkeeping->subledger_account = $tabcompany[$key]['code_compta']; - $bookkeeping->subledger_label = $tabcompany[$key]['name']; - $bookkeeping->numero_compte = $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER; - $bookkeeping->label_compte = ''; - } else if ($tabtype[$key] == 'payment_supplier') { // If payment is payment of supplier invoice, we get ref of invoice - $bookkeeping->label_operation = $tabcompany[$key]['name'] . ' - ' . $ref; - $bookkeeping->subledger_account = $tabcompany[$key]['code_compta']; - $bookkeeping->subledger_label = $tabcompany[$key]['name']; - $bookkeeping->numero_compte = $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER; - $bookkeeping->label_compte = ''; - } else if ($tabtype[$key] == 'payment_expensereport') { - $bookkeeping->label_operation = $tabuser[$key]['name'] . ' - ' . $ref; - $bookkeeping->subledger_account = $tabuser[$key]['accountancy_code']; - $bookkeeping->subledger_label = $tabuser[$key]['name']; - $bookkeeping->numero_compte = $conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT; - $bookkeeping->label_compte = ''; - } else if ($tabtype[$key] == 'payment_salary') { - $bookkeeping->label_operation = $tabuser[$key]['name'] . ' - ' . $ref; - $bookkeeping->subledger_account = $tabuser[$key]['accountancy_code']; - $bookkeeping->subledger_label = $tabuser[$key]['name']; - $bookkeeping->numero_compte = $conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT; - $bookkeeping->label_compte = ''; - } else if (in_array($tabtype[$key], array('sc', 'payment_sc'))) { // If payment is payment of social contribution - $bookkeeping->label_operation = $ref; - $bookkeeping->subledger_account = ''; - $bookkeeping->subledger_label = ''; - $bookkeeping->numero_compte = $k; - $bookkeeping->label_compte = $objmid->labelc; - } else if ($tabtype[$key] == 'payment_vat') { - $bookkeeping->label_operation = $ref; - $bookkeeping->subledger_account = ''; - $bookkeeping->subledger_label = ''; - $bookkeeping->numero_compte = $k; - $bookkeeping->label_compte = ''; - } else if ($tabtype[$key] == 'payment_donation') { - $bookkeeping->label_operation = $ref; - $bookkeeping->subledger_account = ''; - $bookkeeping->subledger_label = ''; - $bookkeeping->numero_compte = $k; - $bookkeeping->label_compte = ''; - } else if ($tabtype[$key] == 'payment_various') { - $bookkeeping->label_operation = $ref; - $bookkeeping->subledger_account = ''; - $bookkeeping->subledger_label = ''; - $bookkeeping->numero_compte = $k; - $bookkeeping->label_compte = ''; - } else if ($tabtype[$key] == 'banktransfert') { - $bookkeeping->label_operation = $ref; - $bookkeeping->subledger_account = ''; - $bookkeeping->subledger_label = ''; - $bookkeeping->numero_compte = $k; - $bookkeeping->label_compte = ''; - } else { - if ($tabtype[$key] == 'unknown') // Unknown transaction, we will use a waiting account for thirdparty. - { - // Temporary account - $bookkeeping->label_operation = ''; + $bookkeeping = new BookKeeping($db); + $bookkeeping->doc_date = $val["date"]; + $bookkeeping->doc_ref = $ref; + $bookkeeping->doc_type = 'bank'; + $bookkeeping->fk_doc = $key; + $bookkeeping->fk_docdet = $val["fk_bank"]; + $bookkeeping->montant = $mt; + $bookkeeping->sens = ($mt < 0) ? 'D' : 'C'; + $bookkeeping->debit = ($mt < 0 ? - $mt : 0); + $bookkeeping->credit = ($mt >= 0) ? $mt : 0; + $bookkeeping->code_journal = $journal; + $bookkeeping->journal_label = $journal_label; + $bookkeeping->fk_user_author = $user->id; + $bookkeeping->date_create = $now; + + if ($tabtype[$key] == 'payment') { // If payment is payment of customer invoice, we get ref of invoice + $bookkeeping->subledger_account = $tabcompany[$key]['code_compta']; + $bookkeeping->subledger_label = $tabcompany[$key]['name']; + $bookkeeping->numero_compte = $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER; + $bookkeeping->label_compte = ''; + } else if ($tabtype[$key] == 'payment_supplier') { // If payment is payment of supplier invoice, we get ref of invoice + $bookkeeping->subledger_account = $tabcompany[$key]['code_compta']; + $bookkeeping->subledger_label = $tabcompany[$key]['name']; + $bookkeeping->numero_compte = $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER; + $bookkeeping->label_compte = ''; + } else if ($tabtype[$key] == 'payment_expensereport') { + $bookkeeping->subledger_account = $tabuser[$key]['accountancy_code']; + $bookkeeping->subledger_label = $tabuser[$key]['name']; + $bookkeeping->numero_compte = $conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT; + $bookkeeping->label_compte = ''; + } else if ($tabtype[$key] == 'payment_salary') { + $bookkeeping->subledger_account = $tabuser[$key]['accountancy_code']; + $bookkeeping->subledger_label = $tabuser[$key]['name']; + $bookkeeping->numero_compte = $conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT; + $bookkeeping->label_compte = ''; + } else if (in_array($tabtype[$key], array('sc', 'payment_sc'))) { // If payment is payment of social contribution $bookkeeping->subledger_account = ''; $bookkeeping->subledger_label = ''; - $bookkeeping->numero_compte = $conf->global->ACCOUNTING_ACCOUNT_SUSPENSE; + $bookkeeping->numero_compte = $k; + $bookkeeping->label_compte = $objmid->labelc; + } else if ($tabtype[$key] == 'payment_vat') { + $bookkeeping->subledger_account = ''; + $bookkeeping->subledger_label = ''; + $bookkeeping->numero_compte = $k; $bookkeeping->label_compte = ''; + } else if ($tabtype[$key] == 'payment_donation') { + $bookkeeping->subledger_account = ''; + $bookkeeping->subledger_label = ''; + $bookkeeping->numero_compte = $k; + $bookkeeping->label_compte = ''; + } else if ($tabtype[$key] == 'payment_various') { + $bookkeeping->subledger_account = ''; + $bookkeeping->subledger_label = ''; + $bookkeeping->numero_compte = $k; + $bookkeeping->label_compte = ''; + } else if ($tabtype[$key] == 'banktransfert') { + $bookkeeping->subledger_account = ''; + $bookkeeping->subledger_label = ''; + $bookkeeping->numero_compte = $k; + $bookkeeping->label_compte = ''; + } else { + if ($tabtype[$key] == 'unknown') // Unknown transaction, we will use a waiting account for thirdparty. + { + // Temporary account + $bookkeeping->subledger_account = ''; + $bookkeeping->subledger_label = ''; + $bookkeeping->numero_compte = $conf->global->ACCOUNTING_ACCOUNT_SUSPENSE; + $bookkeeping->label_compte = ''; + } + } + + $bookkeeping->label_operation = $reflabel; + + $totaldebit += $bookkeeping->debit; + $totalcredit += $bookkeeping->credit; + + $result = $bookkeeping->create($user); + if ($result < 0) { + if ($bookkeeping->error == 'BookkeepingRecordAlreadyExists') // Already exists + { + $error++; + $errorforline++; + setEventMessages('Transaction for ('.$bookkeeping->doc_type.', '.$bookkeeping->fk_doc.', '.$bookkeeping->fk_docdet.') were already recorded', null, 'warnings'); + } + else + { + $error++; + $errorforline++; + setEventMessages($bookkeeping->error, $bookkeeping->errors, 'errors'); + } } } + } + } + else { // If thirdparty unkown, output the waiting account + foreach ( $tabbq[$key] as $k => $mt ) { + if ($mt) + { + $reflabel = 'WaitingAccount'; - $totaldebit += $bookkeeping->debit; - $totalcredit += $bookkeeping->credit; + $bookkeeping = new BookKeeping($db); + $bookkeeping->doc_date = $val["date"]; + $bookkeeping->doc_ref = $ref; + $bookkeeping->doc_type = 'bank'; + $bookkeeping->fk_doc = $key; + $bookkeeping->fk_docdet = $val["fk_bank"]; + $bookkeeping->montant = $mt; + $bookkeeping->sens = ($mt < 0) ? 'D' : 'C'; + $bookkeeping->debit = ($mt < 0 ? - $mt : 0); + $bookkeeping->credit = ($mt >= 0) ? $mt : 0; + $bookkeeping->code_journal = $journal; + $bookkeeping->journal_label = $journal_label; + $bookkeeping->fk_user_author = $user->id; + $bookkeeping->date_create = $now; + $bookkeeping->label_compte = ''; - $result = $bookkeeping->create($user); - if ($result < 0) { - if ($bookkeeping->error == 'BookkeepingRecordAlreadyExists') // Already exists - { - $error++; - $errorforline++; - setEventMessages('Transaction for ('.$bookkeeping->doc_type.', '.$bookkeeping->fk_doc.', '.$bookkeeping->fk_docdet.') were already recorded', null, 'warnings'); - } - else - { - $error++; - $errorforline++; - setEventMessages($bookkeeping->error, $bookkeeping->errors, 'errors'); + $bookkeeping->label_operation = $reflabel; + + $totaldebit += $bookkeeping->debit; + $totalcredit += $bookkeeping->credit; + + $result = $bookkeeping->create($user); + if ($result < 0) { + if ($bookkeeping->error == 'BookkeepingRecordAlreadyExists') // Already exists + { + $error++; + $errorforline++; + setEventMessages('Transaction for ('.$bookkeeping->doc_type.', '.$bookkeeping->fk_doc.', '.$bookkeeping->fk_docdet.') were already recorded', null, 'warnings'); + } + else + { + $error++; + $errorforline++; + setEventMessages($bookkeeping->error, $bookkeeping->errors, 'errors'); + } } } } @@ -662,101 +692,102 @@ if ($action == 'exportcsv') { // ISO and not UTF8 ! include DOL_DOCUMENT_ROOT . '/accountancy/tpl/export_journal.tpl.php'; - $companystatic = new Client($db); - $userstatic = new User($db); + // CSV header line + print '"' . $langs->trans("BankId").'"' . $sep; + print '"' . $langs->trans("Date") . '"' . $sep; + print '"' . $langs->trans("PaymentMode") . '"' . $sep; + print '"' . $langs->trans("AccountAccounting") . '"' . $sep; + print '"' . $langs->trans("LedgerAccount") . '"' . $sep; + print '"' . $langs->trans("SubledgerAccount") . '"' . $sep; + print '"' . $langs->trans("Label"). '"' . $sep; + print '"' . $langs->trans("Amount") . '"' . $sep; + print '"' . $langs->trans("Amount") . '"' . $sep; + print '"' . $langs->trans("Journal") . '"' . $sep; + print '"' . $langs->trans("Note") . '"' . $sep; + print "\n"; - foreach ( $tabpay as $key => $val ) { + + foreach ( $tabpay as $key => $val ) + { $date = dol_print_date($db->jdate($val["date"]), 'day'); $ref = getSourceDocRef($val, $tabtype[$key]); - // - if (! empty($tabcompany[$key]['id'])) - { - $companystatic->id = $tabcompany[$key]['id']; - $companystatic->name = $tabcompany[$key]['name']; - } - else - { - $companystatic->id = 0; - $companystatic->name = ''; - } - if (! empty($tabuser[$key]['id'])) - { - $userstatic->id = $tabuser[$key]['id']; - $userstatic->lastname = $tabuser[$key]['lastname']; - $userstatic->firstname = $tabuser[$key]['firstname']; - } - else - { - $userstatic->id = 0; - $userstatic->lastname = ''; - $userstatic->firstname = ''; - } - // Bank foreach ( $tabbq[$key] as $k => $mt ) { - print '"' . $key . '"' . $sep; - print '"' . $date . '"' . $sep; - print '"' . $val["type_payment"] . '"' . $sep; - print '"' . length_accountg(html_entity_decode($k)) . '"' . $sep; - print '"' . length_accountg(html_entity_decode($k)) . '"' . $sep; - print " " . $sep; - if ($companystatic->name == '') { - print '"' . $val['bank_account_ref'] . " - " . utf8_decode($reflabel) . '"' . $sep; - } else { - print '"' . $val['bank_account_ref'] . ' - ' . utf8_decode($companystatic->name) . '"' . $sep; + if ($mt) + { + $reflabel = $langs->trans("Bank"); + $reflabel.= ' '.$val['bank_account_ref']; + if (! empty($val['soclib'])) { + $reflabel .= " - " . dol_string_nohtmltag($val['soclib']); + } + + print '"' . $key . '"' . $sep; + print '"' . $date . '"' . $sep; + print '"' . $val["type_payment"] . '"' . $sep; + print '"' . length_accountg(html_entity_decode($k)) . '"' . $sep; + print '"' . length_accountg(html_entity_decode($k)) . '"' . $sep; + print " " . $sep; + print '"' . $reflabel . '"' . $sep; + print '"' . ($mt >= 0 ? price($mt) : '') . '"' . $sep; + print '"' . ($mt < 0 ? price(- $mt) : '') . '"' . $sep; + print '"' . $journal . '"' . $sep; + print '"' . dol_string_nohtmltag($ref) . '"' . $sep; + print "\n"; } - print '"' . ($mt >= 0 ? price($mt) : '') . '"' . $sep; - print '"' . ($mt < 0 ? price(- $mt) : '') . '"' . $sep; - print '"' . $journal . '"' . $sep; - print "\n"; } // Third party if (is_array($tabtp[$key])) { foreach ( $tabtp[$key] as $k => $mt ) { - if ($mt) { + if ($mt) + { + $reflabel = dol_string_nohtmltag($val['soclib']); + print '"' . $key . '"' . $sep; print '"' . $date . '"' . $sep; print '"' . $val["type_payment"] . '"' . $sep; print '"' . length_accounta(html_entity_decode($k)) . '"' . $sep; if ($tabtype[$key] == 'payment_supplier') { - print '"' . $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER . '"' . $sep; + print '"' . $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER . '"' . $sep; } else if($tabtype[$key] == 'payment') { - print '"' . $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER . '"' . $sep; + print '"' . $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER . '"' . $sep; + } else if($tabtype[$key] == 'payment_expensereport') { + print '"' . $conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT . '"' . $sep; + } else if($tabtype[$key] == 'payment_salary') { + print '"' . $conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT . '"' . $sep; } else { - print '"' . length_accounta(html_entity_decode($k)) . '"' . $sep; + print '"' . length_accounta(html_entity_decode($k)) . '"' . $sep; } print '"' . length_accounta(html_entity_decode($k)) . '"' . $sep; - if ($companystatic->name == '') { - print '"' . $langs->trans('ThirdParty') . " - " . utf8_decode($reflabel) . '"' . $sep; - } else { - print '"' . $langs->trans('ThirdParty') . " - " . utf8_decode($companystatic->name) . '"' . $sep; - } + print '"' . $reflabel . '"' . $sep; print '"' . ($mt < 0 ? price(- $mt) : '') . '"' . $sep; print '"' . ($mt >= 0 ? price($mt) : '') . '"' . $sep; print '"' . $journal . '"' . $sep; + print '"' . dol_string_nohtmltag($ref) . '"' . $sep; print "\n"; } } - } else { + } else { // If thirdparty unkown, output the waiting account foreach ( $tabbq[$key] as $k => $mt ) { - print '"' . $key . '"' . $sep; - print '"' . $date . '"' . $sep; - print '"' . $val["type_payment"] . '"' . $sep; - print '"' . length_accountg($conf->global->ACCOUNTING_ACCOUNT_SUSPENSE) . '"' . $sep; - print '"' . length_accountg($conf->global->ACCOUNTING_ACCOUNT_SUSPENSE) . '"' . $sep; - print " " . $sep; - if ($companystatic->name == '') { - print '"' . $val['bank_account_ref'] . ' - ' . utf8_decode($reflabel) . '"' . $sep; - } else { - print '"' . $val['bank_account_ref'] . ' - ' . utf8_decode($companystatic->name) . '"' . $sep; + if ($mt) + { + $reflabel = 'WaitingAccount'; + + print '"' . $key . '"' . $sep; + print '"' . $date . '"' . $sep; + print '"' . $val["type_payment"] . '"' . $sep; + print '"' . length_accountg($conf->global->ACCOUNTING_ACCOUNT_SUSPENSE) . '"' . $sep; + print '"' . length_accountg($conf->global->ACCOUNTING_ACCOUNT_SUSPENSE) . '"' . $sep; + print "" . $sep; + print '"' . $reflabel . '"' . $sep; + print '"' . ($mt < 0 ? price(- $mt) : '') . '"' . $sep; + print '"' . ($mt >= 0 ? price($mt) : '') . '"' . $sep; + print '"' . $journal . '"' . $sep; + print '"' . dol_string_nohtmltag($ref) . '"' . $sep; + print "\n"; } - print '"' . ($mt < 0 ? price(- $mt) : '') . '"' . $sep; - print '"' . ($mt >= 0 ? price($mt) : '') . '"' . $sep; - print '"' . $journal . '"' . $sep; - print "\n"; } } } @@ -862,7 +893,8 @@ if (empty($action) || $action == 'view') { $r = ''; - foreach ( $tabpay as $key => $val ) { // $key is rowid in llx_bank + foreach ( $tabpay as $key => $val ) // $key is rowid in llx_bank + { $date = dol_print_date($db->jdate($val["date"]), 'day'); $ref = getSourceDocRef($val, $tabtype[$key]); @@ -870,48 +902,55 @@ if (empty($action) || $action == 'view') { // Bank foreach ( $tabbq[$key] as $k => $mt ) { - //var_dump($tabpay[$key]); - print ''; - print ''; - print ""; - print "" . $date . ""; - print "" . $ref . ""; - // Ledger account - print ""; - $accounttoshow = length_accountg($k); - if (empty($accounttoshow) || $accounttoshow == 'NotDefined') + if ($mt) { - print ''.$langs->trans("BankAccountNotDefined").''; + $reflabel = $langs->trans("Bank"); + $reflabel.= ' '.$val['bank_account_ref']; + if (! empty($val['soclib'])) { + $reflabel .= " - " . $val['soclib']; + } + + //var_dump($tabpay[$key]); + print ''; + print ''; + print ""; + print "" . $date . ""; + print "" . $ref . ""; + // Ledger account + print ""; + $accounttoshow = length_accountg($k); + if (empty($accounttoshow) || $accounttoshow == 'NotDefined') + { + print ''.$langs->trans("BankAccountNotDefined").''; + } + else print $accounttoshow; + print ""; + // Subledger account + print ""; + /*$accounttoshow = length_accountg($k); + if (empty($accounttoshow) || $accounttoshow == 'NotDefined') + { + print ''.$langs->trans("BankAccountNotDefined").''; + } + else print $accounttoshow;*/ + print ""; + print ""; + print $reflabel; + print ""; + print "" . $val["type_payment"] . ""; + print "" . ($mt >= 0 ? price($mt) : '') . ""; + print "" . ($mt < 0 ? price(- $mt) : '') . ""; + print ""; } - else print $accounttoshow; - print ""; - // Subledger account - print ""; - /*$accounttoshow = length_accountg($k); - if (empty($accounttoshow) || $accounttoshow == 'NotDefined') - { - print ''.$langs->trans("BankAccountNotDefined").''; - } - else print $accounttoshow;*/ - print ""; - print ""; - //var_dump($tabpay[$key]); - print $langs->trans("Bank"); - print ' '.$val['bank_account_ref']; - if (! empty($val['soclib'])) { - print " - " . $val['soclib']; - } - print ""; - print "" . $val["type_payment"] . ""; - print "" . ($mt >= 0 ? price($mt) : '') . ""; - print "" . ($mt < 0 ? price(- $mt) : '') . ""; - print ""; } // Third party if (is_array($tabtp[$key])) { foreach ( $tabtp[$key] as $k => $mt ) { - if ($k != 'type') { + if ($mt) + { + $reflabel = $val['soclib']; + print ''; print ''; print ""; @@ -974,42 +1013,47 @@ if (empty($action) || $action == 'view') { } } print ""; - print "" . $reflabel . ' ' . $val['soclib'] . ""; + print "" . $reflabel . ""; print "" . $val["type_payment"] . ""; print "" . ($mt < 0 ? price(- $mt) : '') . ""; print "" . ($mt >= 0 ? price($mt) : '') . ""; print ""; } } - } else { + } else { // Waiting account foreach ( $tabbq[$key] as $k => $mt ) { - print ''; - print ''; - print ""; - print "" . $date . ""; - print "" . $ref . ""; - // Ledger account - print ""; - /*if (empty($accounttoshow) || $accounttoshow == 'NotDefined') + if ($mt) { - print ''.$langs->trans("WaitAccountNotDefined").''; + $reflabel = 'WaitingAccount'; + + print ''; + print ''; + print ""; + print "" . $date . ""; + print "" . $ref . ""; + // Ledger account + print ""; + /*if (empty($accounttoshow) || $accounttoshow == 'NotDefined') + { + print ''.$langs->trans("WaitAccountNotDefined").''; + } + else */ print length_accountg($conf->global->ACCOUNTING_ACCOUNT_SUSPENSE); + print ""; + // Subledger account + print ""; + /*if (empty($accounttoshowsubledger) || $accounttoshowsubledger == 'NotDefined') + { + print ''.$langs->trans("WaitAccountNotDefined").''; + } + else print length_accountg($conf->global->ACCOUNTING_ACCOUNT_SUSPENSE); + */ + print ""; + print "" . $reflabel . ""; + print "" . $val["type_payment"] . ""; + print "" . ($mt < 0 ? price(- $mt) : '') . ""; + print "" . ($mt >= 0 ? price($mt) : '') . ""; + print ""; } - else */ print length_accountg($conf->global->ACCOUNTING_ACCOUNT_SUSPENSE); - print ""; - // Subledger account - print ""; - /*if (empty($accounttoshowsubledger) || $accounttoshowsubledger == 'NotDefined') - { - print ''.$langs->trans("WaitAccountNotDefined").''; - } - else print length_accountg($conf->global->ACCOUNTING_ACCOUNT_SUSPENSE); - */ - print ""; - print "" . $reflabel . ""; - print "" . $val["type_payment"] . ""; - print "" . ($mt < 0 ? price(- $mt) : '') . ""; - print "" . ($mt >= 0 ? price($mt) : '') . ""; - print ""; } } } @@ -1089,6 +1133,13 @@ function getSourceDocRef($val, $typerecord) $sqlmid .= " WHERE s.rowid=" . $val["paymentsalid"]; $ref = $langs->trans("SalaryPayment"); } + elseif ($typerecord == 'sc') + { + $sqlmid = 'SELECT sc.rowid as ref'; + $sqlmid .= " FROM " . MAIN_DB_PREFIX . "paiementcharge as sc"; + $sqlmid .= " WHERE sc.rowid=" . $val["paymentscid"]; + $ref = $langs->trans("SocialContribution"); + } elseif ($typerecord == 'payment_vat') { $sqlmid = 'SELECT v.rowid as ref'; diff --git a/htdocs/adherents/agenda.php b/htdocs/adherents/agenda.php index 61cb960f05c..927bd22f7fa 100644 --- a/htdocs/adherents/agenda.php +++ b/htdocs/adherents/agenda.php @@ -148,10 +148,10 @@ if ($object->id > 0) //print ''; - $morehtmlcenter = ''; + $createbutton = ''; if (! empty($conf->agenda->enabled)) { - $morehtmlcenter.=''.$langs->trans("AddAction").''; + $createbutton.=''.$langs->trans("AddAction").''; } if (! empty($conf->agenda->enabled) && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read) )) @@ -162,7 +162,7 @@ if ($object->id > 0) if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage; if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit; - print_barre_liste($langs->trans("ActionsOnMember"), 0, $_SERVER["PHP_SELF"], '', $sortfield, $sortorder, $morehtmlcenter, 0, -1, '', '', '', '', 0, 1, 1); + print_barre_liste($langs->trans("ActionsOnMember"), 0, $_SERVER["PHP_SELF"], '', $sortfield, $sortorder, '', 0, -1, '', '', $createbutton, '', 0, 1, 1); // List of all actions $filters=array(); diff --git a/htdocs/admin/export.php b/htdocs/admin/export.php new file mode 100644 index 00000000000..51de27998da --- /dev/null +++ b/htdocs/admin/export.php @@ -0,0 +1,103 @@ + + * Copyright (C) 2004-2011 Laurent Destailleur + * Copyright (C) 2004 Sebastien Di Cintio + * Copyright (C) 2004 Benoit Mortier + * Copyright (C) 2004 Eric Seigne + * Copyright (C) 2005-2012 Regis Houssin + * Copyright (C) 2011-2012 Juanjo Menent + * Copyright (C) 2011-2015 Philippe Grand + * + * 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 + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file htdocs/admin/expedition.php + * \ingroup expedition + * \brief Page d'administration/configuration du module Expedition + */ + +require '../main.inc.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; + + +$langs->load("admin"); +$langs->load("exports"); + +$langs->load('other'); + +if (! $user->admin) + accessforbidden(); + +$action=GETPOST('action','alpha'); +$value=GETPOST('value','alpha'); + +/* + * Actions + */ + +include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; + + +/* + * View + */ + +$page_name = "ExportSetup"; +llxHeader('', $langs->trans($page_name)); + +// Subheader +$linkback = '' + . $langs->trans("BackToModuleList") . ''; +print_fiche_titre($langs->trans($page_name), $linkback); + +// Configuration header + +dol_fiche_head( + $head, + 'settings', + $langs->trans("ExportsArea"), + 0, + "exports" +); + +// Setup page goes here +$form=new Form($db); +$var=false; +print ''; +print ''; +print ''."\n"; +print ''; +print ''."\n"; + + +// Example with a yes / no select +$var=!$var; +print ''; +print ''; +print ''; +print ''; + + +print '
'.$langs->trans("ExportModel").' 
'.$langs->trans("set_EXPORTS_SHARE_MODELS").' '; +print ''; +print ''; +print ''; +echo ajax_constantonoff('EXPORTS_SHARE_MODELS'); +print ''; +print '
'; + +llxFooter(); + +$db->close(); \ No newline at end of file diff --git a/htdocs/admin/mails.php b/htdocs/admin/mails.php index d482322a054..bbac43b5c18 100644 --- a/htdocs/admin/mails.php +++ b/htdocs/admin/mails.php @@ -70,6 +70,7 @@ complete_substitutions_array($substitutionarrayfortest, $langs); if ($action == 'update' && empty($_POST["cancel"])) { dolibarr_set_const($db, "MAIN_DISABLE_ALL_MAILS", GETPOST("MAIN_DISABLE_ALL_MAILS"),'chaine',0,'',$conf->entity); + dolibarr_set_const($db, "MAIN_MAIL_FORCE_SENDTO", GETPOST("MAIN_MAIL_FORCE_SENDTO"),'chaine',0,'',$conf->entity); // Send mode parameters dolibarr_set_const($db, "MAIN_MAIL_SENDMODE", GETPOST("MAIN_MAIL_SENDMODE"),'chaine',0,'',$conf->entity); dolibarr_set_const($db, "MAIN_MAIL_SMTP_PORT", GETPOST("MAIN_MAIL_SMTP_PORT"),'chaine',0,'',$conf->entity); @@ -239,6 +240,11 @@ if ($action == 'edit') print $form->selectyesno('MAIN_DISABLE_ALL_MAILS',$conf->global->MAIN_DISABLE_ALL_MAILS,1); print ''; + // Force e-mail recipient + print ''.$langs->trans("MAIN_MAIL_FORCE_SENDTO").''; + print ''; + print ''; + // Separator print ' '; @@ -478,6 +484,11 @@ else print ''.$langs->trans("MAIN_DISABLE_ALL_MAILS").''.yn($conf->global->MAIN_DISABLE_ALL_MAILS).''; + // Force e-mail recipient + print ''.$langs->trans("MAIN_MAIL_FORCE_SENDTO").''.$conf->global->MAIN_MAIL_FORCE_SENDTO; + if (! empty($conf->global->MAIN_MAIL_FORCE_SENDTO) && ! isValidEmail($conf->global->MAIN_MAIL_FORCE_SENDTO)) print img_warning($langs->trans("ErrorBadEMail")); + print ''; + // Separator print ' '; @@ -644,25 +655,7 @@ else dol_fiche_end(); - if ($conf->global->MAIN_MAIL_SENDMODE == 'mail' && empty($conf->global->MAIN_FIX_FOR_BUGGED_MTA)) - { - print '
'; - /* - // Warning 1 - if ($linuxlike) - { - $sendmailoption=ini_get('mail.force_extra_parameters'); - if (empty($sendmailoption) || ! preg_match('/ba/',$sendmailoption)) - { - print info_admin($langs->trans("SendmailOptionNotComplete")); - } - }*/ - // Warning 2 - print info_admin($langs->trans("SendmailOptionMayHurtBuggedMTA")); - } - - - // Boutons actions + // Actions button print '
'; print ''.$langs->trans("Modify").''; @@ -689,6 +682,22 @@ else print '
'; + if ($conf->global->MAIN_MAIL_SENDMODE == 'mail' && empty($conf->global->MAIN_FIX_FOR_BUGGED_MTA)) + { + /* + // Warning 1 + if ($linuxlike) + { + $sendmailoption=ini_get('mail.force_extra_parameters'); + if (empty($sendmailoption) || ! preg_match('/ba/',$sendmailoption)) + { + print info_admin($langs->trans("SendmailOptionNotComplete")); + } + }*/ + // Warning 2 + print info_admin($langs->trans("SendmailOptionMayHurtBuggedMTA")); + } + if ($conf->global->MAIN_MAIL_SENDMODE == 'mail' && ! in_array($action, array('testconnect', 'test', 'testhtml'))) { $text = $langs->trans("WarningPHPMail"); diff --git a/htdocs/admin/salaries.php b/htdocs/admin/salaries.php index 85603de2ae5..f5a3624939d 100644 --- a/htdocs/admin/salaries.php +++ b/htdocs/admin/salaries.php @@ -39,8 +39,7 @@ $action = GETPOST('action', 'alpha'); // Other parameters SALARIES_* $list = array ( - 'SALARIES_ACCOUNTING_ACCOUNT_PAYMENT', - 'SALARIES_ACCOUNTING_ACCOUNT_CHARGE' + 'SALARIES_XXX', ); /* @@ -97,7 +96,7 @@ print "\n"; foreach ($list as $key) { - + print ''; diff --git a/htdocs/api/admin/explorer.php b/htdocs/api/admin/explorer.php index a9f13928217..0aecfcd5d7e 100644 --- a/htdocs/api/admin/explorer.php +++ b/htdocs/api/admin/explorer.php @@ -87,7 +87,13 @@ foreach ($modulesdir as $dir) $part = 'compta/facture'; $obj = 'facture'; } - if (empty($conf->$module->enabled)) $enabled=false; + if ($module == 'ficheinter') { + $obj = 'fichinter'; + $part = 'fichinter'; + $module='fichinter'; + } + + if (empty($conf->$module->enabled)) $enabled=false; if ($enabled) { diff --git a/htdocs/api/index.php b/htdocs/api/index.php index 99334880d3a..353b945cfda 100644 --- a/htdocs/api/index.php +++ b/htdocs/api/index.php @@ -145,6 +145,7 @@ if (! empty($reg[1]) && $reg[1] == 'explorer' && ($reg[2] == '/swagger.json' || $modulenameforenabled = $module; if ($module == 'propale') { $modulenameforenabled='propal'; } if ($module == 'supplierproposal') { $modulenameforenabled='supplier_proposal'; } + if ($module == 'ficheinter') { $modulenameforenabled='ficheinter'; } dol_syslog("Found module file ".$file." - module=".$module." - modulenameforenabled=".$modulenameforenabled." - moduledirforclass=".$moduledirforclass); @@ -217,7 +218,7 @@ if (! empty($reg[1]) && ($reg[1] != 'explorer' || ($reg[2] != '/swagger.json' && $moduledirforclass = getModuleDirForApiClass($module); // Load a dedicated API file - dol_syslog("Load a dedicated API file moduledirforclass=".$moduledirforclass); + dol_syslog("Load a dedicated API file module=".$module." moduledirforclass=".$moduledirforclass); $tmpmodule = $module; if ($tmpmodule != 'api') @@ -229,6 +230,11 @@ if (! empty($reg[1]) && ($reg[1] != 'explorer' || ($reg[2] != '/swagger.json' && $classfile = 'supplier_orders'; if ($module == 'supplierinvoices') $classfile = 'supplier_invoices'; + if ($module == 'ficheinter') + $classfile = 'interventions'; + if ($module == 'interventions') + $classfile = 'interventions'; + $dir_part_file = dol_buildpath('/' . $moduledirforclass . '/class/api_' . $classfile . '.class.php', 0, 2); $classname = ucwords($module); diff --git a/htdocs/blockedlog/admin/blockedlog_list.php b/htdocs/blockedlog/admin/blockedlog_list.php index 08b384d7ac5..d508d1edceb 100644 --- a/htdocs/blockedlog/admin/blockedlog_list.php +++ b/htdocs/blockedlog/admin/blockedlog_list.php @@ -453,24 +453,36 @@ if (is_array($blocks)) if (empty($search_showonlyerrors) || ! $checkresult[$block->id]) { print ''; + // ID print ''.$block->id.''; + // Date print ''.dol_print_date($block->date_creation,'dayhour').''; + // User print ''; + //print $block->getUser() print $block->user_fullname; print ''; + // Action print ''.$langs->trans('log'.$block->action).''; + // Ref print ''.$block->ref_object.''; + // Link to source object print ''.$object_link.''; + + // Amount print ''.price($block->amounts).''; + + // Details link print ''.img_info($langs->trans('ShowDetails')).''; + // Fingerprint print ''; print $form->textwithpicto(dol_trunc($block->signature, '12'), $block->signature, 1, 'help', '', 0, 2, 'fingerprint'); print ''; diff --git a/htdocs/blockedlog/class/blockedlog.class.php b/htdocs/blockedlog/class/blockedlog.class.php index 2f3c5d60640..3dc3ade52e5 100644 --- a/htdocs/blockedlog/class/blockedlog.class.php +++ b/htdocs/blockedlog/class/blockedlog.class.php @@ -149,11 +149,10 @@ class BlockedLog if ($conf->adherent->enabled) $this->trackedevents['MEMBER_SUBSCRIPTION_MODIFY']='logMEMBER_SUBSCRIPTION_MODIFY'; if ($conf->adherent->enabled) $this->trackedevents['MEMBER_SUBSCRIPTION_DELETE']='logMEMBER_SUBSCRIPTION_DELETE'; - /* - $trackedevents['PAYMENT_VARIOUS_CREATE']='BlockedLogVariousPaymentCreate'; - $trackedevents['PAYMENT_VARIOUS_MODIFY']='BlockedLogVariousPaymentModify'; - $trackedevents['PAYMENT_VARIOUS_DELETE']='BlockedLogVariousPaymentDelete'; - */ + + if ($conf->banque->enabled) $this->trackedevents['PAYMENT_VARIOUS_CREATE']='logPAYMENT_VARIOUS_CREATE'; + if ($conf->banque->enabled) $this->trackedevents['PAYMENT_VARIOUS_MODIFY']='logPAYMENT_VARIOUS_MODIFY'; + if ($conf->banque->enabled) $this->trackedevents['PAYMENT_VARIOUS_DELETE']='logPAYMENT_VARIOUS_DELETE'; } /** @@ -218,6 +217,17 @@ class BlockedLog $this->error++; } } + else if($this->element === 'payment_various') { + require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/paymentvarious.class.php'; + + $object = new PaymentVarious($this->db); + if ($object->fetch($this->fk_object)>0) { + return $object->getNomUrl(1); + } + else{ + $this->error++; + } + } else if($this->element === 'don' || $this->element === 'donation') { require_once DOL_DOCUMENT_ROOT.'/don/class/don.class.php'; @@ -299,7 +309,7 @@ class BlockedLog { $this->date_object = $object->datev; } - elseif ($object->element == 'payment_donation') + elseif ($object->element == 'payment_donation' || $object->element == 'payment_various') { $this->date_object = $object->datepaid?$object->datepaid:$object->datep; } @@ -401,21 +411,26 @@ class BlockedLog if (! empty($object->newref)) $this->object_data->ref = $object->newref; } - elseif ($this->element == 'payment' || $this->element == 'payment_supplier' || $this->element == 'payment_donation') + elseif ($this->element == 'payment' || $this->element == 'payment_supplier' || $this->element == 'payment_donation' || $this->element == 'payment_various') { $datepayment = $object->datepaye?$object->datepaye:($object->datepaid?$object->datepaid:$object->datep); - $paymenttypeid = $object->paiementid?$object->paiementid:$object->paymenttype; + $paymenttypeid = $object->paiementid?$object->paiementid:($object->paymenttype?$object->paymenttype:$object->type_payment); $this->object_data->ref = $object->ref; $this->object_data->date = $datepayment; $this->object_data->type_code = dol_getIdFromCode($this->db, $paymenttypeid, 'c_paiement', 'id', 'code'); - $this->object_data->payment_num = $object->num_paiement; + $this->object_data->payment_num = ($object->num_paiement?$object->num_paiement:$object->num_payment); //$this->object_data->fk_account = $object->fk_account; $this->object_data->note = $object->note; //var_dump($this->object_data);exit; $totalamount=0; + if (! is_array($object->amounts) && $object->amount) + { + $object->amounts=array($object->id => $object->amount); + } + $paymentpartnumber=0; foreach($object->amounts as $objid => $amount) { @@ -439,26 +454,41 @@ class BlockedLog include_once DOL_DOCUMENT_ROOT.'/don/class/don.class.php'; $tmpobject = new Don($this->db); } + elseif ($this->element == 'payment_various') + { + include_once DOL_DOCUMENT_ROOT.'/compta/bank/class/paymentvarious.class.php'; + $tmpobject = new PaymentVarious($this->db); + } + if (! is_object($tmpobject)) { continue; } $result = $tmpobject->fetch($objid); + if ($result <= 0) { $this->error = $tmpobject->error; $this->errors = $tmpobject->errors; + dol_syslog("Failed to fetch object with id ".$objid, LOG_ERR); return -1; } $paymentpart = new stdClass(); $paymentpart->amount = $amount; - if ($this->element != 'payment_donation') + if (! in_array($this->element, array('payment_donation', 'payment_various'))) { $result = $tmpobject->fetch_thirdparty(); - if ($result <= 0) + if ($result == 0) + { + $this->error='Failed to fetch thirdparty for object with id '.$tmpobject->id; + $this->errors[] = $this->error; + dol_syslog("Failed to fetch thirdparty for object with id ".$tmpobject->id, LOG_ERR); + return -1; + } + elseif ($result < 0) { $this->error = $tmpobject->error; $this->errors = $tmpobject->errors; @@ -481,21 +511,25 @@ class BlockedLog if ($this->element == 'payment_donation') $paymentpart->donation = new stdClass(); else $paymentpart->invoice = new stdClass(); - foreach($tmpobject as $key=>$value) + if ($this->element != 'payment_various') { - if (in_array($key, array('fields'))) continue; // Discard some properties - if (! in_array($key, array( - 'ref','facnumber','ref_client','ref_supplier','date','datef','type','total_ht','total_tva','total_ttc','localtax1','localtax2','revenuestamp','datepointoftax','note_public' - ))) continue; // Discard if not into a dedicated list - if (!is_object($value)) + foreach($tmpobject as $key=>$value) { - if ($this->element == 'payment_donation') $paymentpart->donation->{$key} = $value; - else $paymentpart->invoice->{$key} = $value; + if (in_array($key, array('fields'))) continue; // Discard some properties + if (! in_array($key, array( + 'ref','facnumber','ref_client','ref_supplier','date','datef','type','total_ht','total_tva','total_ttc','localtax1','localtax2','revenuestamp','datepointoftax','note_public' + ))) continue; // Discard if not into a dedicated list + if (!is_object($value)) + { + if ($this->element == 'payment_donation') $paymentpart->donation->{$key} = $value; + elseif ($this->element == 'payment_various') $paymentpart->various->{$key} = $value; + else $paymentpart->invoice->{$key} = $value; + } } - } - $paymentpartnumber++; - $this->object_data->payment_part[$paymentpartnumber] = $paymentpart; + $paymentpartnumber++; // first payment will be 1 + $this->object_data->payment_part[$paymentpartnumber] = $paymentpart; + } } $this->object_data->amount = $totalamount; diff --git a/htdocs/categories/class/categorie.class.php b/htdocs/categories/class/categorie.class.php index 87594b2031f..5658460927c 100644 --- a/htdocs/categories/class/categorie.class.php +++ b/htdocs/categories/class/categorie.class.php @@ -825,7 +825,7 @@ class Categorie extends CommonObject $sql = "SELECT c.fk_" . $this->MAP_CAT_FK[$type]; $sql .= " FROM " . MAIN_DB_PREFIX . "categorie_" . $this->MAP_CAT_TABLE[$type] . " as c"; $sql .= ", " . MAIN_DB_PREFIX . $this->MAP_OBJ_TABLE[$type] . " as o"; - $sql .= " WHERE o.entity IN (" . getEntity( $obj->element, 1).")"; + $sql .= " WHERE o.entity IN (" . getEntity( $obj->element).")"; $sql.= " AND c.fk_categorie = ".$this->id; $sql .= " AND c.fk_" . $this->MAP_CAT_FK[$type] . " = o.rowid"; @@ -1066,7 +1066,7 @@ class Categorie extends CommonObject if (! empty($conf->global->MAIN_MULTILANGS)) $sql.= ", t.label as label_trans, t.description as description_trans"; $sql.= " FROM ".MAIN_DB_PREFIX."categorie as c"; if (! empty($conf->global->MAIN_MULTILANGS)) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."categorie_lang as t ON t.fk_category=c.rowid AND t.lang='".$current_lang."'"; - $sql .= " WHERE c.entity IN (" . getEntity( 'category', 1 ) . ")"; + $sql .= " WHERE c.entity IN (" . getEntity( 'category') . ")"; $sql .= " AND c.type = " . $type; dol_syslog(get_class($this)."::get_full_arbo get category list", LOG_DEBUG); @@ -1481,7 +1481,7 @@ class Categorie extends CommonObject $sql = "SELECT ct.fk_categorie, c.label, c.rowid"; $sql .= " FROM " . MAIN_DB_PREFIX . "categorie_" . $this->MAP_CAT_TABLE[$type] . " as ct, " . MAIN_DB_PREFIX . "categorie as c"; $sql .= " WHERE ct.fk_categorie = c.rowid AND ct.fk_" . $this->MAP_CAT_FK[$type] . " = " . (int) $id . " AND c.type = " . $this->MAP_ID[$type]; - $sql .= " AND c.entity IN (" . getEntity( 'category', 1 ) . ")"; + $sql .= " AND c.entity IN (" . getEntity( 'category') . ")"; $res = $this->db->query($sql); if ($res) @@ -1542,7 +1542,7 @@ class Categorie extends CommonObject // Generation requete recherche $sql = "SELECT rowid FROM " . MAIN_DB_PREFIX . "categorie"; $sql .= " WHERE type = " . $this->MAP_ID[$type]; - $sql .= " AND entity IN (" . getEntity( 'category', 1 ) . ")"; + $sql .= " AND entity IN (" . getEntity( 'category') . ")"; if ($nom) { if (! $exact) diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php index 985a50df9ec..c7aa1d80800 100644 --- a/htdocs/comm/action/class/actioncomm.class.php +++ b/htdocs/comm/action/class/actioncomm.class.php @@ -1633,6 +1633,7 @@ class ActionComm extends CommonObject if (empty($conf->global->AGENDA_REMINDER_EMAIL)) { + $langs->load("agenda"); $this->output = $langs->trans('EventRemindersByEmailNotEnabled', $langs->transnoentitiesnoconv("Agenda")); return 0; } diff --git a/htdocs/comm/card.php b/htdocs/comm/card.php index fa2af2dc3eb..49f351be4c3 100644 --- a/htdocs/comm/card.php +++ b/htdocs/comm/card.php @@ -773,7 +773,7 @@ if ($object->id > 0) } /* - * Last sendings + * Last shipments */ if (! empty($conf->expedition->enabled) && $user->rights->expedition->lire) { $sendingstatic = new Expedition($db); @@ -1245,7 +1245,7 @@ if ($object->id > 0) print ''; - if (! empty($conf->global->MAIN_REPEATCONTACTONEACHTAB)) + if (! empty($conf->global->MAIN_DUPLICATE_CONTACTS_TAB_ON_CUSTOMER_CARD)) { // List of contacts show_contacts($conf,$langs,$db,$object,$_SERVER["PHP_SELF"].'?socid='.$object->id); diff --git a/htdocs/comm/index.php b/htdocs/comm/index.php index 9edad60f400..c394ef69d8d 100644 --- a/htdocs/comm/index.php +++ b/htdocs/comm/index.php @@ -470,7 +470,7 @@ if (! empty($conf->societe->enabled) && $user->rights->societe->lire) $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; if (! $user->rights->societe->client->voir && ! $socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql.= " WHERE s.client IN (1, 2, 3)"; - $sql.= " AND s.entity IN (".getEntity($companystatic->element, 1).")"; + $sql.= " AND s.entity IN (".getEntity($companystatic->element).")"; if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; if ($socid) $sql.= " AND s.rowid = $socid"; $sql .= " ORDER BY s.tms DESC"; @@ -534,7 +534,7 @@ if (! empty($conf->fournisseur->enabled) && $user->rights->societe->lire) $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; if (! $user->rights->societe->client->voir && ! $user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql.= " WHERE s.fournisseur = 1"; - $sql.= " AND s.entity IN (".getEntity($companystatic->element, 1).")"; + $sql.= " AND s.entity IN (".getEntity($companystatic->element).")"; if (! $user->rights->societe->client->voir && ! $user->societe_id) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; if ($socid) $sql.= " AND s.rowid = ".$socid; $sql.= " ORDER BY s.datec DESC"; diff --git a/htdocs/comm/mailing/card.php b/htdocs/comm/mailing/card.php index cedd04c46c1..db19e943b4b 100644 --- a/htdocs/comm/mailing/card.php +++ b/htdocs/comm/mailing/card.php @@ -156,6 +156,7 @@ if (empty($reshook)) $sql = "SELECT mc.rowid, mc.fk_mailing, mc.lastname, mc.firstname, mc.email, mc.other, mc.source_url, mc.source_id, mc.source_type, mc.tag"; $sql .= " FROM ".MAIN_DB_PREFIX."mailing_cibles as mc"; $sql .= " WHERE mc.statut < 1 AND mc.fk_mailing = ".$object->id; + $sql .= " ORDER BY mc.statut DESC"; // first status 0, then status -1 dol_syslog("card.php: select targets", LOG_DEBUG); $resql=$db->query($sql); @@ -840,7 +841,7 @@ else if (! empty($conf->global->MAILING_SMTP_SETUP_EMAILS_FOR_QUESTIONS)) setEventMessages($langs->trans("MailSendSetupIs3", $conf->global->MAILING_SMTP_SETUP_EMAILS_FOR_QUESTIONS), null, 'warnings'); $_GET["action"]=''; } - else if ($conf->global->MAILING_LIMIT_SENDBYWEB == '-1') + else if ($conf->global->MAILING_LIMIT_SENDBYWEB < 0) { if (! empty($conf->global->MAILING_LIMIT_WARNING_PHPMAIL) && $sendingmode == 'mail') setEventMessages($langs->transnoentitiesnoconv($conf->global->MAILING_LIMIT_WARNING_PHPMAIL), null, 'warnings'); if (! empty($conf->global->MAILING_LIMIT_WARNING_NOPHPMAIL) && $sendingmode != 'mail') setEventMessages($langs->transnoentitiesnoconv($conf->global->MAILING_LIMIT_WARNING_NOPHPMAIL), null, 'warnings'); @@ -875,7 +876,16 @@ else $linkback = ''.$langs->trans("BackToList").''; $morehtmlright=''; - if ($object->statut == 2) $morehtmlright.=' ('.$object->countNbOfTargets('alreadysent').'/'.$object->nbemail.') '; + $nbtry = $nbok = 0; + if ($object->statut == 2 || $object->statut == 3) + { + $nbtry = $object->countNbOfTargets('alreadysent'); + $nbko = $object->countNbOfTargets('alreadysentko'); + + $morehtmlright.=' ('.$nbtry.'/'.$object->nbemail; + if ($nbko) $morehtmlright.=' - '.$nbko.' '.$langs->trans("Error"); + $morehtmlright.=')   '; + } dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', '', '', 0, '', $morehtmlright); @@ -903,11 +913,11 @@ else print ''; print $langs->trans("TotalNbOfDistinctRecipients"); print ''; - $nbemail = ($object->nbemail?$object->nbemail:img_warning('').' '.$langs->trans("NoTargetYet").''); - if ($object->statut != 3 && is_numeric($nbemail)) + $nbemail = ($object->nbemail?$object->nbemail:0); + if (is_numeric($nbemail)) { $text=''; - if (! empty($conf->global->MAILING_LIMIT_SENDBYWEB) && $conf->global->MAILING_LIMIT_SENDBYWEB < $nbemail) + if ((! empty($conf->global->MAILING_LIMIT_SENDBYWEB) && $conf->global->MAILING_LIMIT_SENDBYWEB < $nbemail) && ($object->statut == 1 || ($object->statut == 2 && $nbtry < $nbemail))) { if ($conf->global->MAILING_LIMIT_SENDBYWEB > 0) { @@ -915,9 +925,10 @@ else } else { - $text.=$langs->trans('NotEnoughPermissions'); + $text.=$langs->trans('SendingFromWebInterfaceIsNotAllowed'); } } + if (empty($nbemail)) $nbemail.=' '.img_warning('').' '.$langs->trans("NoTargetYet").''; if ($text) { print $form->textwithpicto($nbemail,$text,1,'warning'); @@ -1008,7 +1019,11 @@ else if (($object->statut == 1 || $object->statut == 2) && $object->nbemail > 0 && $user->rights->mailing->valider) { - if ($conf->global->MAILING_LIMIT_SENDBYWEB < 0 || (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! $user->rights->mailing->mailing_advance->send)) + if ($conf->global->MAILING_LIMIT_SENDBYWEB < 0) + { + print ''.$langs->trans("SendMailing").''; + } + else if (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! $user->rights->mailing->mailing_advance->send) { print ''.$langs->trans("SendMailing").''; } @@ -1183,15 +1198,30 @@ else print ''; print $langs->trans("TotalNbOfDistinctRecipients"); print ''; - $nbemail = ($object->nbemail?$object->nbemail:img_warning('').' '.$langs->trans("NoTargetYet").''); - if (!empty($conf->global->MAILING_LIMIT_SENDBYWEB) && is_numeric($nbemail) && $conf->global->MAILING_LIMIT_SENDBYWEB < $nbemail) + $nbemail = ($object->nbemail?$object->nbemail:0); + if (is_numeric($nbemail)) { - $text=$langs->trans('LimitSendingEmailing',$conf->global->MAILING_LIMIT_SENDBYWEB); - print $form->textwithpicto($nbemail,$text,1,'warning'); - } - else - { - print $nbemail; + $text=''; + if ((! empty($conf->global->MAILING_LIMIT_SENDBYWEB) && $conf->global->MAILING_LIMIT_SENDBYWEB < $nbemail) && ($object->statut == 1 || $object->statut == 2)) + { + if ($conf->global->MAILING_LIMIT_SENDBYWEB > 0) + { + $text.=$langs->trans('LimitSendingEmailing',$conf->global->MAILING_LIMIT_SENDBYWEB); + } + else + { + $text.=$langs->trans('SendingFromWebInterfaceIsNotAllowed'); + } + } + if (empty($nbemail)) $nbemail.=' '.img_warning('').' '.$langs->trans("NoTargetYet").''; + if ($text) + { + print $form->textwithpicto($nbemail,$text,1,'warning'); + } + else + { + print $nbemail; + } } print ''; diff --git a/htdocs/comm/mailing/cibles.php b/htdocs/comm/mailing/cibles.php index 7729c2737cc..57af9f5c601 100644 --- a/htdocs/comm/mailing/cibles.php +++ b/htdocs/comm/mailing/cibles.php @@ -171,6 +171,7 @@ if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x', /* * View */ + llxHeader('',$langs->trans("Mailing"),'EN:Module_EMailing|FR:Module_Mailing|ES:Módulo_Mailing'); $form = new Form($db); @@ -185,7 +186,16 @@ if ($object->fetch($id) >= 0) $linkback = ''.$langs->trans("BackToList").''; $morehtmlright=''; - if ($object->statut == 2) $morehtmlright.=' ('.$object->countNbOfTargets('alreadysent').'/'.$object->nbemail.') '; + $nbtry = $nbok = 0; + if ($object->statut == 2 || $object->statut == 3) + { + $nbtry = $object->countNbOfTargets('alreadysent'); + $nbko = $object->countNbOfTargets('alreadysentko'); + + $morehtmlright.=' ('.$nbtry.'/'.$object->nbemail; + if ($nbko) $morehtmlright.=' - '.$nbko.' '.$langs->trans("Error"); + $morehtmlright.=')   '; + } dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', '', '', 0, '', $morehtmlright); @@ -206,15 +216,30 @@ if ($object->fetch($id) >= 0) print ''; print $langs->trans("TotalNbOfDistinctRecipients"); print ''; - $nbemail = ($object->nbemail?$object->nbemail:'0'); - if (!empty($conf->global->MAILING_LIMIT_SENDBYWEB) && ($conf->global->MAILING_LIMIT_SENDBYWEB < $nbemail) && ($object->statut == 1 || $object->statut == 2)) + $nbemail = ($object->nbemail?$object->nbemail:0); + if (is_numeric($nbemail)) { - $text=$langs->trans('LimitSendingEmailing',$conf->global->MAILING_LIMIT_SENDBYWEB); - print $form->textwithpicto($nbemail,$text,1,'warning'); - } - else - { - print $nbemail; + $text=''; + if ((! empty($conf->global->MAILING_LIMIT_SENDBYWEB) && $conf->global->MAILING_LIMIT_SENDBYWEB < $nbemail) && ($object->statut == 1 || ($object->statut == 2 && $nbtry < $nbemail))) + { + if ($conf->global->MAILING_LIMIT_SENDBYWEB > 0) + { + $text.=$langs->trans('LimitSendingEmailing',$conf->global->MAILING_LIMIT_SENDBYWEB); + } + else + { + $text.=$langs->trans('SendingFromWebInterfaceIsNotAllowed'); + } + } + if (empty($nbemail)) $nbemail.=' '.img_warning('').' '.$langs->trans("NoTargetYet").''; + if ($text) + { + print $form->textwithpicto($nbemail,$text,1,'warning'); + } + else + { + print $nbemail; + } } print ''; @@ -411,6 +436,8 @@ if ($object->fetch($id) >= 0) $num = $db->num_rows($resql); $param = "&id=".$object->id; + //if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.urlencode($contextpage); + if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.urlencode($limit); if ($search_lastname) $param.= "&search_lastname=".urlencode($search_lastname); if ($search_firstname) $param.= "&search_firstname=".urlencode($search_firstname); if ($search_email) $param.= "&search_email=".urlencode($search_email); @@ -552,7 +579,7 @@ if ($object->fetch($id) >= 0) } print ''; - // Statut pour l'email destinataire (Attentioon != statut du mailing) + // Status of recipient sending email (Warning != status of emailing) if ($obj->statut == 0) { print ' '; @@ -563,18 +590,22 @@ if ($object->fetch($id) >= 0) { print ''.$obj->date_envoi.''; print ''; - print $object::libStatutDest($obj->statut,2,$obj->error_text); + print $object::libStatutDest($obj->statut, 2, $obj->error_text); print ''; } // Search Icon print ''; - if ($obj->statut == 0) + if ($obj->statut == 0) // Not sent yet { if ($user->rights->mailing->creer && $allowaddtarget) { - print ''.img_delete($langs->trans("RemoveRecipient")); + print ''.img_delete($langs->trans("RemoveRecipient")).''; } } + /*if ($obj->statut == -1) // Sent with error + { + print ''.$langs->trans("Retry").''; + }*/ print ''; print ''; diff --git a/htdocs/comm/mailing/class/mailing.class.php b/htdocs/comm/mailing/class/mailing.class.php index 72c2b6d4690..63fc0a2caab 100644 --- a/htdocs/comm/mailing/class/mailing.class.php +++ b/htdocs/comm/mailing/class/mailing.class.php @@ -34,7 +34,7 @@ class Mailing extends CommonObject public $element='mailing'; public $table_element='mailing'; public $picto='email'; - + var $titre; var $sujet; var $body; @@ -43,7 +43,7 @@ class Mailing extends CommonObject var $bgimage; var $statut; // Status 0=Draft, 1=Validated, 2=Sent partially, 3=Sent completely - + var $email_from; var $email_replyto; var $email_errorsto; @@ -431,7 +431,7 @@ class Mailing extends CommonObject return -1; } } - + /** * Delete targets emailing * @@ -481,11 +481,11 @@ class Mailing extends CommonObject } } - + /** * Count number of target with status * - * @param string $mode Mode ('alreadysent' = Sent success or error) + * @param string $mode Mode ('alreadysent' = Sent success or error, 'alreadysentok' = Sent success, 'alreadysentko' = Sent error) * @return int Nb of target with status */ function countNbOfTargets($mode) @@ -493,12 +493,14 @@ class Mailing extends CommonObject $sql = "SELECT COUNT(rowid) as nb FROM ".MAIN_DB_PREFIX."mailing_cibles"; $sql.= " WHERE fk_mailing = ".$this->id; if ($mode == 'alreadysent') $sql.= " AND statut <> 0"; - else + elseif ($mode == 'alreadysentok') $sql.= " AND statut > 0"; + elseif ($mode == 'alreadysentko') $sql.= " AND statut = -1"; + else { $this->error='BadValueForParameterMode'; return -2; } - + $resql=$this->db->query($sql); if ($resql) { @@ -512,10 +514,10 @@ class Mailing extends CommonObject } return 0; } - + /** - * Retourne le libelle du statut d'un mailing (brouillon, validee, ... + * Return label of status of emailing (draft, validated, ...) * * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long * @return string Label diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php index bf0c691084f..8bd9f7ffa98 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -2130,6 +2130,22 @@ if ($action == 'create') print ''; } + $tmparray=$object->getTotalWeightVolume(); + $totalWeight=$tmparray['weight']; + $totalVolume=$tmparray['volume']; + if ($totalWeight) { + print '' . $langs->trans("CalculatedWeight") . ''; + print ''; + print showDimensionInBestUnit($totalWeight, 0, "weight", $langs, isset($conf->global->MAIN_WEIGHT_DEFAULT_ROUND)?$conf->global->MAIN_WEIGHT_DEFAULT_ROUND:-1, isset($conf->global->MAIN_WEIGHT_DEFAULT_UNIT)?$conf->global->MAIN_WEIGHT_DEFAULT_UNIT:'no'); + print ''; + } + if ($totalVolume) { + print '' . $langs->trans("CalculatedVolume") . ''; + print ''; + print showDimensionInBestUnit($totalVolume, 0, "volume", $langs, isset($conf->global->MAIN_VOLUME_DEFAULT_ROUND)?$conf->global->MAIN_VOLUME_DEFAULT_ROUND:-1, isset($conf->global->MAIN_VOLUME_DEFAULT_UNIT)?$conf->global->MAIN_VOLUME_DEFAULT_UNIT:'no'); + print ''; + } + // Incoterms if (!empty($conf->incoterm->enabled)) { diff --git a/htdocs/comm/prospect/index.php b/htdocs/comm/prospect/index.php index 0ec6f20ae46..8db5308bf3f 100644 --- a/htdocs/comm/prospect/index.php +++ b/htdocs/comm/prospect/index.php @@ -76,7 +76,7 @@ $sql.= ", ".MAIN_DB_PREFIX."c_stcomm as st "; if (! $user->rights->societe->client->voir && ! $socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql.= " WHERE s.fk_stcomm = st.id"; $sql.= " AND s.client IN (2, 3)"; -$sql.= " AND s.entity IN (".getEntity($companystatic->element, 1).")"; +$sql.= " AND s.entity IN (".getEntity($companystatic->element).")"; if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; $sql.= " GROUP BY st.id"; $sql.= " ORDER BY st.id"; @@ -96,7 +96,7 @@ if ($resql) while ($i < $num) { $obj = $db->fetch_object($resql); - + print ''; print ''; print img_action($langs->trans("Show"),$obj->id).' '; @@ -140,7 +140,7 @@ if (! empty($conf->propal->enabled) && $user->rights->propale->lire) while ($i < $num) { $obj = $db->fetch_object($resql); - + print ''; print ''.img_object($langs->trans("ShowPropal"),"propal").' '.$obj->ref.''; print ''; @@ -150,7 +150,7 @@ if (! empty($conf->propal->enabled) && $user->rights->propale->lire) $total += $obj->price; } if ($total>0) { - + print ''.$langs->trans("Total")."".price($total).""; } print "
"; @@ -205,7 +205,7 @@ if (! empty($conf->propal->enabled) && $user->rights->propale->lire) while ($i < $num) { $obj = $db->fetch_object($resql); - + print ''; print ''; print img_object($langs->trans("ShowPropal"),"propal").' '.$obj->ref.''; @@ -243,7 +243,7 @@ $sql = "SELECT s.nom as name, s.rowid as socid, s.client, s.canvas"; $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; if (! $user->rights->societe->client->voir && ! $socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql.= " WHERE s.fk_stcomm = 1"; -$sql.= " AND s.entity IN (".getEntity($companystatic->element, 1).")"; +$sql.= " AND s.entity IN (".getEntity($companystatic->element).")"; if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; $sql.= " ORDER BY s.tms ASC"; $sql.= $db->plimit(15, 0); @@ -263,7 +263,7 @@ if ($resql) while ($i < $num) { $obj = $db->fetch_object($resql); - + print ''; $companystatic->id=$obj->socid; $companystatic->name=$obj->name; diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index 2d4d138f61a..24ab03c831a 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -2300,12 +2300,15 @@ if ($action == 'create' && $user->rights->commande->creer) $tmparray=$object->getTotalWeightVolume(); $totalWeight=$tmparray['weight']; $totalVolume=$tmparray['volume']; - if ($totalWeight || $totalVolume) + if ($totalWeight) { print ''.$langs->trans("CalculatedWeight").''; print ''; print showDimensionInBestUnit($totalWeight, 0, "weight", $langs, isset($conf->global->MAIN_WEIGHT_DEFAULT_ROUND)?$conf->global->MAIN_WEIGHT_DEFAULT_ROUND:-1, isset($conf->global->MAIN_WEIGHT_DEFAULT_UNIT)?$conf->global->MAIN_WEIGHT_DEFAULT_UNIT:'no'); print ''; + } + if ($totalVolume) + { print ''.$langs->trans("CalculatedVolume").''; print ''; print showDimensionInBestUnit($totalVolume, 0, "volume", $langs, isset($conf->global->MAIN_VOLUME_DEFAULT_ROUND)?$conf->global->MAIN_VOLUME_DEFAULT_ROUND:-1, isset($conf->global->MAIN_VOLUME_DEFAULT_UNIT)?$conf->global->MAIN_VOLUME_DEFAULT_UNIT:'no'); diff --git a/htdocs/commande/class/api_orders.class.php b/htdocs/commande/class/api_orders.class.php index e1edde93922..cbd505a41b8 100644 --- a/htdocs/commande/class/api_orders.class.php +++ b/htdocs/commande/class/api_orders.class.php @@ -153,6 +153,7 @@ class Orders extends DolibarrApi { $num = $db->num_rows($result); $min = min($num, ($limit <= 0 ? $num : $limit)); + $i=0; while ($i < $min) { $obj = $db->fetch_object($result); @@ -276,7 +277,7 @@ class Orders extends DolibarrApi $request_data->product_type, $request_data->rang, $request_data->special_code, - $fk_parent_line, + $request_data->fk_parent_line, $request_data->fk_fournprice, $request_data->pa_ht, $request_data->label, @@ -424,14 +425,6 @@ class Orders extends DolibarrApi if ($this->commande->availability($this->commande->availability_id) < 0) throw new RestException(400, 'Error while updating availability'); } - // update bank account - if(!empty($this->commande->fk_account)) - { - if($this->commande->setBankAccount($this->commande->fk_account) == 0) - { - throw new RestException(400,$this->commande->error); - } - } if ($this->commande->update(DolibarrApiAccess::$user) > 0) { @@ -479,7 +472,7 @@ class Orders extends DolibarrApi /** * Validate an order * - * If you get a bad value for param notrigger check that ou provide this in body + * If you get a bad value for param notrigger check, provide this in body * { * "idwarehouse": 0, * "notrigger": 0 diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index 7998a25bd13..65b704693fb 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -3036,6 +3036,8 @@ class Commande extends CommonOrder */ function update(User $user, $notrigger=0) { + global $conf; + $error=0; // Clean parameters @@ -3069,6 +3071,7 @@ class Commande extends CommonOrder $sql.= " fk_projet=".(isset($this->fk_project)?$this->fk_project:"null").","; $sql.= " fk_cond_reglement=".(isset($this->cond_reglement_id)?$this->cond_reglement_id:"null").","; $sql.= " fk_mode_reglement=".(isset($this->mode_reglement_id)?$this->mode_reglement_id:"null").","; + $sql.= " fk_account=".($this->fk_account>0?$this->fk_account:"null").","; $sql.= " note_private=".(isset($this->note_private)?"'".$this->db->escape($this->note_private)."'":"null").","; $sql.= " note_public=".(isset($this->note_public)?"'".$this->db->escape($this->note_public)."'":"null").","; $sql.= " model_pdf=".(isset($this->modelpdf)?"'".$this->db->escape($this->modelpdf)."'":"null").","; diff --git a/htdocs/compta/bank/bankentries_list.php b/htdocs/compta/bank/bankentries_list.php index 0493ffef3b0..380392c6805 100644 --- a/htdocs/compta/bank/bankentries_list.php +++ b/htdocs/compta/bank/bankentries_list.php @@ -387,7 +387,7 @@ if ($optioncss != '') $param.='&optioncss='.$optioncss; // Add $param from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; - +$options = array(); if ($id > 0 || ! empty($ref)) { @@ -398,7 +398,6 @@ if ($id > 0 || ! empty($ref)) // Load bank groups require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/bankcateg.class.php'; $bankcateg = new BankCateg($db); - $options = array(); foreach ($bankcateg->fetchAll() as $bankcategory) { $options[$bankcategory->id] = $bankcategory->label; @@ -531,7 +530,6 @@ dol_syslog('compta/bank/bankentries_list.php', LOG_DEBUG); $resql = $db->query($sql); if ($resql) { - $var=True; $num = $db->num_rows($resql); $arrayofselected=is_array($toselect)?$toselect:array(); @@ -569,14 +567,12 @@ if ($resql) // Form to reconcile if ($user->rights->banque->consolidate && $action == 'reconcile') { -// print ''; -// print ''; -// print '
'; print '
'; print ''.$langs->trans("InputReceiptNumber").': '; print ''; // The only default value is value we just entered print '
'; - if ($options) { + if (is_array($options) && count($options)) + { print $langs->trans("EventualyAddCategory").': '; print Form::selectarray('cat', $options, GETPOST('cat'), 1); } @@ -629,7 +625,6 @@ if ($resql) '; } print '

'; -// print '
'; } // Form to add a transaction with no invoice @@ -663,7 +658,8 @@ if ($resql) print ''; print ''; print ''; - if (is_array($options) && count($options)) { + if (is_array($options) && count($options)) + { print '
'.$langs->trans("Rubrique").': '; print Form::selectarray('cat1', $options, GETPOST('cat1'), 1); } diff --git a/htdocs/compta/bank/class/paymentvarious.class.php b/htdocs/compta/bank/class/paymentvarious.class.php index 5922b3f5aa7..fe56ea99504 100644 --- a/htdocs/compta/bank/class/paymentvarious.class.php +++ b/htdocs/compta/bank/class/paymentvarious.class.php @@ -34,6 +34,8 @@ class PaymentVarious extends CommonObject public $table_element='payment_various'; //!< Name of table without prefix where object is stored public $picto = 'bill'; + var $id; + var $ref; var $tms; var $datep; var $datev; @@ -87,8 +89,7 @@ class PaymentVarious extends CommonObject // Update request $sql = "UPDATE ".MAIN_DB_PREFIX."payment_various SET"; - - $sql.= " tms='".$this->db->idate($this->tms)."',"; + if ($this->tms) $sql.= " tms='".$this->db->idate($this->tms)."',"; $sql.= " datep='".$this->db->idate($this->datep)."',"; $sql.= " datev='".$this->db->idate($this->datev)."',"; $sql.= " sens=".$this->sens.","; @@ -102,7 +103,6 @@ class PaymentVarious extends CommonObject $sql.= " fk_bank=".($this->fk_bank > 0 ? $this->fk_bank:"null").","; $sql.= " fk_user_author=".$this->fk_user_author.","; $sql.= " fk_user_modif=".$this->fk_user_modif; - $sql.= " WHERE rowid=".$this->id; dol_syslog(get_class($this)."::update", LOG_DEBUG); @@ -146,7 +146,6 @@ class PaymentVarious extends CommonObject global $langs; $sql = "SELECT"; $sql.= " v.rowid,"; - $sql.= " v.tms,"; $sql.= " v.datep,"; $sql.= " v.datev,"; @@ -164,7 +163,6 @@ class PaymentVarious extends CommonObject $sql.= " b.fk_account,"; $sql.= " b.fk_type,"; $sql.= " b.rappro"; - $sql.= " FROM ".MAIN_DB_PREFIX."payment_various as v"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank as b ON v.fk_bank = b.rowid"; $sql.= " WHERE v.rowid = ".$id; @@ -184,7 +182,7 @@ class PaymentVarious extends CommonObject $this->datev = $this->db->jdate($obj->datev); $this->sens = $obj->sens; $this->amount = $obj->amount; - $this->type_payement = $obj->fk_typepayment; + $this->type_payment = $obj->fk_typepayment; $this->num_payment = $obj->num_payment; $this->label = $obj->label; $this->note = $obj->note; @@ -350,6 +348,7 @@ class PaymentVarious extends CommonObject if ($result) { $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."payment_various"); + $this->ref = $this->id; if ($this->id > 0) { diff --git a/htdocs/compta/bank/various_payment/card.php b/htdocs/compta/bank/various_payment/card.php index 90aa3e5e432..b6649250e64 100644 --- a/htdocs/compta/bank/various_payment/card.php +++ b/htdocs/compta/bank/various_payment/card.php @@ -49,7 +49,7 @@ $sens=GETPOST("sens","int"); $amount=GETPOST("amount"); $paymenttype=GETPOST("paymenttype"); $accountancy_code=GETPOST("accountancy_code","int"); -$projectid = (GETPOST('projectid') ? GETPOST('projectid', 'int') : 0); +$projectid = (GETPOST('projectid','int') ? GETPOST('projectid', 'int') : GETPOST('fk_project','int')); // Security check $socid = GETPOST("socid","int"); @@ -96,22 +96,23 @@ if (empty($reshook)) { $error=0; - $datep=dol_mktime(12,0,0, GETPOST("datepmonth"), GETPOST("datepday"), GETPOST("datepyear")); - $datev=dol_mktime(12,0,0, GETPOST("datevmonth"), GETPOST("datevday"), GETPOST("datevyear")); + $datep=dol_mktime(12,0,0, GETPOST("datepmonth",'int'), GETPOST("datepday",'int'), GETPOST("datepyear",'int')); + $datev=dol_mktime(12,0,0, GETPOST("datevmonth",'int'), GETPOST("datevday",'int'), GETPOST("datevyear",'int')); if (empty($datev)) $datev=$datep; - $object->accountid=GETPOST("accountid") > 0 ? GETPOST("accountid","int") : 0; + $object->ref=''; // TODO + $object->accountid=GETPOST("accountid",'int') > 0 ? GETPOST("accountid","int") : 0; $object->datev=$datev; $object->datep=$datep; - $object->amount=price2num(GETPOST("amount")); - $object->label=GETPOST("label"); - $object->note=GETPOST("note"); - $object->type_payment=GETPOST("paymenttype") > 0 ? GETPOST("paymenttype", "int") : 0; - $object->num_payment=GETPOST("num_payment"); + $object->amount=price2num(GETPOST("amount",'alpha')); + $object->label=GETPOST("label",'none'); + $object->note=GETPOST("note",'none'); + $object->type_payment=GETPOST("paymenttype",'int') > 0 ? GETPOST("paymenttype", "int") : 0; + $object->num_payment=GETPOST("num_payment",'alpha'); $object->fk_user_author=$user->id; $object->accountancy_code=GETPOST("accountancy_code") > 0 ? GETPOST("accountancy_code","int") : ""; $object->sens=GETPOST('sens'); - $object->fk_project= GETPOST('fk_project'); + $object->fk_project= GETPOST('fk_project','int'); if (empty($datep) || empty($datev)) { @@ -411,7 +412,7 @@ if ($id) print ''; // Label - print ''; + print ''; // Payment date print ""; diff --git a/htdocs/compta/bank/various_payment/index.php b/htdocs/compta/bank/various_payment/index.php index e32dc8818e2..d52cbeb7595 100644 --- a/htdocs/compta/bank/various_payment/index.php +++ b/htdocs/compta/bank/various_payment/index.php @@ -108,21 +108,19 @@ $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank_account as ba ON b.fk_account = ba.row $sql.= " WHERE v.entity IN (".getEntity('payment_various').")"; // Search criteria -if ($search_ref) $sql.=" AND v.rowid=".$search_ref; -if ($search_label) $sql.=natural_search(array('v.label'), $search_label); -if ($search_amount_deb) $sql.=natural_search("v.amount", $search_amount_deb, 1); -if ($search_amount_cred) $sql.=natural_search("v.amount", $search_amount_cred, 1); -if ($search_account > 0) $sql.=" AND b.fk_account=".$search_account; -if ($search_date) $sql.=" AND v.datep=".$search_date; -if ($search_accountancy_code) $sql.=" AND v.accountancy_code=".$search_accountancy_code; - +if ($search_ref) $sql.=" AND v.rowid=".$search_ref; +if ($search_label) $sql.=natural_search(array('v.label'), $search_label); +if ($search_amount_deb) $sql.=natural_search("v.amount", $search_amount_deb, 1); +if ($search_amount_cred) $sql.=natural_search("v.amount", $search_amount_cred, 1); +if ($search_account > 0) $sql.=" AND b.fk_account=".$search_account; +if ($search_date) $sql.=" AND v.datep=".$search_date; +if ($search_accountancy_code > 0) $sql.=" AND v.accountancy_code=".$search_accountancy_code; +if ($typeid > 0) $sql .= " AND v.fk_typepayment=".$typeid; if ($filtre) { $filtre=str_replace(":","=",$filtre); $sql .= " AND ".$filtre; } -if ($typeid) { - $sql .= " AND v.fk_typepayment=".$typeid; -} + $sql.= $db->order($sortfield,$sortorder); $totalnboflines=0; @@ -142,10 +140,18 @@ if ($result) $var=true; $param=''; - if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage; - if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit; - if ($typeid) $param.='&typeid='.$typeid; - if ($optioncss != '') $param.='&optioncss='.$optioncss; + if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.urlencode($contextpage); + if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.urlencode($limit); + if ($search_ref) $param.='&search_ref='.urlencode($search_ref); + if ($search_label) $param.='&search_label='.urlencode($search_label); + if ($typeid > 0) $param.='&typeid='.urlencode($typeid); + if ($search_amount_deb) $param.='&search_amount_deb='.urlencode($search_amount_deb); + if ($search_amount_cred) $param.='&search_amount_cred='.urlencode($search_amount_cred); + if ($search_account > 0) $param.='&search_amount='.urlencode($search_account); + //if ($search_date) $param.='&search_date='.$search_date; + if ($search_accountancy_code > 0) $param.='&search_accountancy_code='.urlencode($search_accountancy_code); + + if ($optioncss != '') $param.='&optioncss='.urlencode($optioncss); print ''; @@ -162,18 +168,6 @@ if ($result) print '
'; print '
'.$langs->trans("Label").''.$object->label.'
'.$langs->trans("Label").''.$object->label.'
'."\n"; - print ''; - print_liste_field_titre("Ref",$_SERVER["PHP_SELF"],"v.rowid","",$param,"",$sortfield,$sortorder); - print_liste_field_titre("Label",$_SERVER["PHP_SELF"],"v.label","",$param,'align="left"',$sortfield,$sortorder); - print_liste_field_titre("DatePayment",$_SERVER["PHP_SELF"],"v.datep","",$param,'align="center"',$sortfield,$sortorder); - print_liste_field_titre("PaymentMode",$_SERVER["PHP_SELF"],"type","",$param,'align="left"',$sortfield,$sortorder); - if (! empty($conf->banque->enabled)) print_liste_field_titre("BankAccount",$_SERVER["PHP_SELF"],"ba.label","",$param,"",$sortfield,$sortorder); - if (! empty($conf->accounting->enabled)) print_liste_field_titre("AccountAccounting",$_SERVER["PHP_SELF"],"v.accountancy_code","",$param,'align="left"',$sortfield,$sortorder); - print_liste_field_titre("Debit",$_SERVER["PHP_SELF"],"v.amount","",$param,'align="right"',$sortfield,$sortorder); - print_liste_field_titre("Credit",$_SERVER["PHP_SELF"],"v.amount","",$param,'align="right"',$sortfield,$sortorder); - print_liste_field_titre('',$_SERVER["PHP_SELF"],"",'','','',$sortfield,$sortorder,'maxwidthsearch '); - print "\n"; - print ''; // Ref @@ -227,6 +221,20 @@ if ($result) print "\n"; + + print ''; + print_liste_field_titre("Ref",$_SERVER["PHP_SELF"],"v.rowid","",$param,"",$sortfield,$sortorder); + print_liste_field_titre("Label",$_SERVER["PHP_SELF"],"v.label","",$param,'align="left"',$sortfield,$sortorder); + print_liste_field_titre("DatePayment",$_SERVER["PHP_SELF"],"v.datep","",$param,'align="center"',$sortfield,$sortorder); + print_liste_field_titre("PaymentMode",$_SERVER["PHP_SELF"],"type","",$param,'align="left"',$sortfield,$sortorder); + if (! empty($conf->banque->enabled)) print_liste_field_titre("BankAccount",$_SERVER["PHP_SELF"],"ba.label","",$param,"",$sortfield,$sortorder); + if (! empty($conf->accounting->enabled)) print_liste_field_titre("AccountAccounting",$_SERVER["PHP_SELF"],"v.accountancy_code","",$param,'align="left"',$sortfield,$sortorder); + print_liste_field_titre("Debit",$_SERVER["PHP_SELF"],"v.amount","",$param,'align="right"',$sortfield,$sortorder); + print_liste_field_titre("Credit",$_SERVER["PHP_SELF"],"v.amount","",$param,'align="right"',$sortfield,$sortorder); + print_liste_field_titre('',$_SERVER["PHP_SELF"],"",'','','',$sortfield,$sortorder,'maxwidthsearch '); + print "\n"; + + $totalarray=array(); while ($i < min($num,$limit)) { diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index c299c1d1de5..ca6d2bc8fdd 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -683,7 +683,7 @@ if (empty($reshook)) $i = 0; foreach ($object->lines as $line) { - if ($line->total_ht!=0) + if ($line->product_type < 9 && $line->total_ht != 0) // Remove lines with product_type greater than or equal to 9 { // no need to create discount if amount is null $amount_ht[$line->tva_tx] += $line->total_ht; $amount_tva[$line->tva_tx] += $line->total_tva; @@ -1570,7 +1570,7 @@ if (empty($reshook)) setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Type')), null, 'errors'); $error ++; } - if ($prod_entry_mode == 'free' && empty($idprod) && (! ($price_ht >= 0) || $price_ht == '') && $price_ht_devise == '') // Unit price can be 0 but not '' + if ($prod_entry_mode == 'free' && empty($idprod) && (($price_ht < 0 && empty($conf->global->FACTURE_ENABLE_NEGATIVE_LINES)) || $price_ht == '') && $price_ht_devise == '') // Unit price can be 0 but not '' { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("UnitPriceHT")), null, 'errors'); $error ++; @@ -3047,10 +3047,10 @@ else if ($id > 0 || ! empty($ref)) } } - // Confirmation de la validation + // Confirmation of validation if ($action == 'valid') { - // on verifie si l'objet est en numerotation provisoire + // we check object has a draft number $objectref = substr($object->ref, 1, 4); if ($objectref == 'PROV') { $savdate = $object->date; diff --git a/htdocs/compta/facture/class/api_invoices.class.php b/htdocs/compta/facture/class/api_invoices.class.php index e691d497194..c1f8774095a 100644 --- a/htdocs/compta/facture/class/api_invoices.class.php +++ b/htdocs/compta/facture/class/api_invoices.class.php @@ -60,30 +60,30 @@ class Invoices extends DolibarrApi * * @throws RestException */ - function get($id) - { + function get($id) + { if(! DolibarrApiAccess::$user->rights->facture->lire) { throw new RestException(401); } - $result = $this->invoice->fetch($id); - if( ! $result ) { - throw new RestException(404, 'Invoice not found'); - } + $result = $this->invoice->fetch($id); + if (! $result) { + throw new RestException(404, 'Invoice not found'); + } - // Get payment details - $this->invoice->totalpaye = $this->invoice->getSommePaiement(); - $this->invoice->totalcreditnotes = $this->invoice->getSumCreditNotesUsed(); - $this->invoice->totaldeposits = $this->invoice->getSumDepositsUsed(); - $this->invoice->resteapayer = price2num($this->invoice->total_ttc - $this->invoice->totalpaye - $this->invoice->totalcreditnotes - $this->invoice->totaldeposits, 'MT'); + // Get payment details + $this->invoice->totalpaye = $this->invoice->getSommePaiement(); + $this->invoice->totalcreditnotes = $this->invoice->getSumCreditNotesUsed(); + $this->invoice->totaldeposits = $this->invoice->getSumDepositsUsed(); + $this->invoice->resteapayer = price2num($this->invoice->total_ttc - $this->invoice->totalpaye - $this->invoice->totalcreditnotes - $this->invoice->totaldeposits, 'MT'); - if( ! DolibarrApi::_checkAccessToResource('facture',$this->invoice->id)) { + if (! DolibarrApi::_checkAccessToResource('facture',$this->invoice->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } $this->invoice->fetchObjectLinked(); return $this->_cleanObjectDatas($this->invoice); - } + } /** * List invoices diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 8eed645edc4..35ab14454ef 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -1163,9 +1163,9 @@ class Facture extends CommonInvoice $label.= '
' . $langs->trans('AmountHT') . ': ' . price($this->total_ht, 0, $langs, 0, -1, -1, $conf->currency); if (! empty($this->total_tva)) $label.= '
' . $langs->trans('VAT') . ': ' . price($this->total_tva, 0, $langs, 0, -1, -1, $conf->currency); - if (! empty($this->total_tva)) + if (! empty($this->total_localtax1)) $label.= '
' . $langs->trans('LT1') . ': ' . price($this->total_localtax1, 0, $langs, 0, -1, -1, $conf->currency); - if (! empty($this->total_tva)) + if (! empty($this->total_localtax2)) $label.= '
' . $langs->trans('LT2') . ': ' . price($this->total_localtax2, 0, $langs, 0, -1, -1, $conf->currency); if (! empty($this->total_ttc)) $label.= '
' . $langs->trans('AmountTTC') . ': ' . price($this->total_ttc, 0, $langs, 0, -1, -1, $conf->currency); diff --git a/htdocs/compta/facture/fiche-rec.php b/htdocs/compta/facture/fiche-rec.php index e7eea16f316..af81e797252 100644 --- a/htdocs/compta/facture/fiche-rec.php +++ b/htdocs/compta/facture/fiche-rec.php @@ -1056,7 +1056,7 @@ if ($action == 'create') print ''; - print ''; - print ''; print ''; @@ -1404,7 +1404,7 @@ else // Note private print ''; print ''; diff --git a/htdocs/compta/index.php b/htdocs/compta/index.php index 98b4a95b0e4..c36037940b9 100644 --- a/htdocs/compta/index.php +++ b/htdocs/compta/index.php @@ -140,8 +140,8 @@ if (! empty($conf->facture->enabled) && $user->rights->facture->lire) $sql.= ", f.rowid, f.total as total_ht, f.tva as total_tva, f.total_ttc, f.ref_client"; $sql.= ", f.type"; $sql.= ", s.nom as name"; - $sql.= ", s.rowid as socid"; - $sql.= ",s.code_client"; + $sql.= ", s.rowid as socid, s.email"; + $sql.= ", s.code_client, s.code_compta, s.code_fournisseur, s.code_compta_fournisseur"; if (!$user->rights->societe->client->voir && !$socid) $sql.= ", sc.fk_soc, sc.fk_user "; $sql.= " FROM ".MAIN_DB_PREFIX."facture as f, ".MAIN_DB_PREFIX."societe as s"; if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; @@ -177,22 +177,28 @@ if (! empty($conf->facture->enabled) && $user->rights->facture->lire) while ($i < $num) { $obj = $db->fetch_object($resql); - print ''; print ''; print ''; @@ -226,8 +232,8 @@ if (! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->facture- { $sql = "SELECT f.ref, f.rowid, f.total_ht, f.total_tva, f.total_ttc, f.type, f.ref_supplier"; $sql.= ", s.nom as name"; - $sql.= ", s.rowid as socid"; - $sql.= ", s.code_fournisseur"; + $sql.= ", s.rowid as socid, s.email"; + $sql.= ", s.code_fournisseur, s.code_compta_fournisseur"; $sql.= " FROM ".MAIN_DB_PREFIX."facture_fourn as f, ".MAIN_DB_PREFIX."societe as s"; if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql.= " WHERE s.rowid = f.fk_soc AND f.fk_statut = 0"; @@ -256,22 +262,28 @@ if (! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->facture- while ($i < $num) { $obj = $db->fetch_object($resql); - print ''; print ''; print ''; @@ -311,7 +323,7 @@ if (! empty($conf->facture->enabled) && $user->rights->facture->lire) $sql.= ", f.date_lim_reglement as datelimite"; $sql.= ", s.nom as name"; $sql.= ", s.rowid as socid"; - $sql.= ", s.code_client"; + $sql.= ", s.code_client, s.code_compta"; $sql.= ", sum(pf.amount) as am"; $sql.= " FROM ".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture as f"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."paiement_facture as pf on f.rowid=pf.fk_facture"; @@ -325,7 +337,8 @@ if (! empty($conf->facture->enabled) && $user->rights->facture->lire) $reshook=$hookmanager->executeHooks('printFieldListWhereCustomerLastModified',$parameters); $sql.=$hookmanager->resPrint; - $sql.= " GROUP BY f.rowid, f.facnumber, f.fk_statut, f.type, f.total, f.tva, f.total_ttc, f.paye, f.tms, f.date_lim_reglement, s.nom, s.rowid, s.code_client"; + $sql.= " GROUP BY f.rowid, f.facnumber, f.fk_statut, f.type, f.total, f.tva, f.total_ttc, f.paye, f.tms, f.date_lim_reglement,"; + $sql.= " s.nom, s.rowid, s.code_client, s.code_compta"; $sql.= " ORDER BY f.tms DESC "; $sql.= $db->plimit($max, 0); @@ -350,19 +363,28 @@ if (! empty($conf->facture->enabled) && $user->rights->facture->lire) { $obj = $db->fetch_object($resql); + $facturestatic->ref=$obj->facnumber; + $facturestatic->id=$obj->rowid; + $facturestatic->total_ht=$obj->total_ht; + $facturestatic->total_tva=$obj->total_tva; + $facturestatic->total_ttc=$obj->total_ttc; + $facturestatic->statut = $obj->fk_statut; + $facturestatic->date_lim_reglement = $db->jdate($obj->datelimite); + $facturestatic->type=$obj->type; + + $thirdpartystatic->id=$obj->socid; + $thirdpartystatic->name=$obj->name; + $thirdpartystatic->client=1; + $thirdpartystatic->code_client = $obj->code_client; + //$thirdpartystatic->code_fournisseur = $obj->code_fournisseur; + $thirdpartystatic->code_compta = $obj->code_compta; + //$thirdpartystatic->code_compta_fournisseur = $obj->code_compta_fournisseur; + print ''; print '
'; print $form->textwithpicto($langs->trans('NotePublic'), $htmltext, 1, 'help', '', 0, 2, 'notepublic'); print ''; + print ''; $doleditor = new DolEditor('note_public', $note_public, '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, '90%'); print $doleditor->Create(1); @@ -1067,7 +1067,7 @@ if ($action == 'create') print ''; print $form->textwithpicto($langs->trans('NotePrivate'), $htmltext, 1, 'help', '', 0, 2, 'noteprivate'); print ''; + print ''; $doleditor = new DolEditor('note_private', $note_private, '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, '90%'); print $doleditor->Create(1); // print ' @@ -1396,7 +1396,7 @@ else // Note public print '
'; print $form->editfieldkey($form->textwithpicto($langs->trans('NotePublic'), $htmltext, 1, 'help', '', 0, 2, 'notepublic'), 'note_public', $object->note_public, $object, $user->rights->facture->creer); - print ''; + print ''; print $form->editfieldval($langs->trans("NotePublic"), 'note_public', $object->note_public, $object, $user->rights->facture->creer, 'textarea:'.ROWS_4.':90%', '', null, null, '', 1); print '
'; print $form->editfieldkey($form->textwithpicto($langs->trans("NotePrivate"), $htmltext, 1, 'help', '', 0, 2, 'noteprivate'), 'note_private', $object->note_private, $object, $user->rights->facture->creer); - print ''; + print ''; print $form->editfieldval($langs->trans("NotePrivate"), 'note_private', $object->note_private, $object, $user->rights->facture->creer, 'textarea:'.ROWS_4.':90%', '', null, null, '', 1); print '
'; + $facturestatic->ref=$obj->facnumber; $facturestatic->id=$obj->rowid; - $facturestatic->total_ht=$obj->total_ht; - $facturestatic->total_tva=$obj->total_tva; - $facturestatic->total_ttc=$obj->total_ttc; - $facturestatic->ref_client=$obj->ref_client; + $facturestatic->total_ht=$obj->total_ht; + $facturestatic->total_tva=$obj->total_tva; + $facturestatic->total_ttc=$obj->total_ttc; + $facturestatic->ref_client=$obj->ref_client; $facturestatic->type=$obj->type; + + $companystatic->id=$obj->socid; + $companystatic->name=$obj->name; + $companystatic->email=$obj->email; + $companystatic->client = 1; + $companystatic->code_client = $obj->code_client; + $companystatic->code_fournisseur = $obj->code_fournisseur; + $companystatic->code_compta = $obj->code_compta; + $companystatic->code_compta_fournisseur = $obj->code_compta_fournisseur; + + print '
'; print $facturestatic->getNomUrl(1,''); print ''; - $companystatic->id=$obj->socid; - $companystatic->name=$obj->name; - $companystatic->client = 1; - $companystatic->code_client = $obj->code_client; - $companystatic->code_fournisseur = $obj->code_fournisseur; print $companystatic->getNomUrl(1,'',16); print ''.price($obj->total_ttc).'
'; + $facturesupplierstatic->ref=$obj->ref; $facturesupplierstatic->id=$obj->rowid; - $facturesupplierstatic->total_ht=$obj->total_ht; - $facturesupplierstatic->total_tva=$obj->total_tva; - $facturesupplierstatic->total_ttc=$obj->total_ttc; - $facturesupplierstatic->ref_supplier=$obj->ref_supplier; + $facturesupplierstatic->total_ht=$obj->total_ht; + $facturesupplierstatic->total_tva=$obj->total_tva; + $facturesupplierstatic->total_ttc=$obj->total_ttc; + $facturesupplierstatic->ref_supplier=$obj->ref_supplier; $facturesupplierstatic->type=$obj->type; + + $companystatic->id=$obj->socid; + $companystatic->name=$obj->name; + $companystatic->email=$obj->email; + $companystatic->fournisseur = 1; + $companystatic->code_client = $obj->code_client; + $companystatic->code_fournisseur = $obj->code_fournisseur; + $companystatic->code_compta = $obj->code_compta; + $companystatic->code_compta_fournisseur = $obj->code_compta_fournisseur; + + print '
'; print $facturesupplierstatic->getNomUrl(1,'',16); print ''; - $companystatic->id=$obj->socid; - $companystatic->name=$obj->name; - $companystatic->fournisseur = 1; - $companystatic->code_client = $obj->code_client; - $companystatic->code_fournisseur = $obj->code_fournisseur; print $companystatic->getNomUrl(1,'supplier',16); print ''.price($obj->total_ttc).'
'; print ''; print ''; print ''; print ''; if (! empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) print ''; print ''; @@ -425,7 +442,7 @@ if (! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->facture- $sql = "SELECT ff.rowid, ff.ref, ff.fk_statut, ff.libelle, ff.total_ht, ff.total_tva, ff.total_ttc, ff.tms, ff.paye"; $sql.= ", s.nom as name"; $sql.= ", s.rowid as socid"; - $sql.= ", s.code_fournisseur"; + $sql.= ", s.code_fournisseur, s.code_compta_fournisseur"; $sql.= ", SUM(pf.amount) as am"; $sql.= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."facture_fourn as ff"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."paiementfourn_facturefourn as pf on ff.rowid=pf.fk_facturefourn"; @@ -439,7 +456,8 @@ if (! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->facture- $reshook=$hookmanager->executeHooks('printFieldListWhereSupplierLastModified',$parameters); $sql.=$hookmanager->resPrint; - $sql.= " GROUP BY ff.rowid, ff.ref, ff.fk_statut, ff.libelle, ff.total_ht, ff.tva, ff.total_tva, ff.total_ttc, ff.tms, ff.paye, s.nom, s.rowid, s.code_fournisseur"; + $sql.= " GROUP BY ff.rowid, ff.ref, ff.fk_statut, ff.libelle, ff.total_ht, ff.tva, ff.total_tva, ff.total_ttc, ff.tms, ff.paye,"; + $sql.= " s.nom, s.rowid, s.code_fournisseur, s.code_compta_fournisseur"; $sql.= " ORDER BY ff.tms DESC "; $sql.= $db->plimit($max, 0); @@ -463,20 +481,25 @@ if (! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->facture- while ($i < $num) { $obj = $db->fetch_object($resql); - print ''; - print ''; + print ''; if (! empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) print ''; @@ -673,9 +696,9 @@ if (! empty($conf->facture->enabled) && ! empty($conf->commande->enabled) && $us $langs->load("orders"); $sql = "SELECT sum(f.total) as tot_fht, sum(f.total_ttc) as tot_fttc"; - $sql.= ", s.nom as name"; + $sql.= ", s.nom as name, s.email"; $sql.= ", s.rowid as socid"; - $sql.= ", s.code_client"; + $sql.= ", s.code_client, s.code_compta"; $sql.= ", c.rowid, c.ref, c.facture, c.fk_statut, c.total_ht, c.tva as total_tva, c.total_ttc"; $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; @@ -693,7 +716,7 @@ if (! empty($conf->facture->enabled) && ! empty($conf->commande->enabled) && $us $reshook=$hookmanager->executeHooks('printFieldListWhereCustomerOrderToBill',$parameters); $sql.=$hookmanager->resPrint; - $sql.= " GROUP BY s.nom, s.rowid, s.code_client, c.rowid, c.ref, c.facture, c.fk_statut, c.tva, c.total_ht, c.total_ttc"; + $sql.= " GROUP BY s.nom, s.rowid, s.email, s.code_client, s.code_compta, c.rowid, c.ref, c.facture, c.fk_statut, c.tva, c.total_ht, c.total_ttc"; $resql = $db->query($sql); if ( $resql ) @@ -712,18 +735,28 @@ if (! empty($conf->facture->enabled) && ! empty($conf->commande->enabled) && $us print ''; print ''; print ''; + $tot_ht=$tot_ttc=$tot_tobill=0; $societestatic = new Societe($db); while ($i < $num) { $obj = $db->fetch_object($resql); - print ''; - print ''; + print ''; @@ -1407,8 +1490,11 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon='', $noprint= //$userstatic->id=$histo[$key]['userid']; //$userstatic->login=$histo[$key]['login']; //$out.=$userstatic->getLoginUrl(1); - $userstatic->fetch($histo[$key]['userid']); - $out.=$userstatic->getNomUrl(-1); + if ($histo[$key]['userid'] > 0) + { + $userstatic->fetch($histo[$key]['userid']); + $out.=$userstatic->getNomUrl(-1); + } $out.=''; // Type @@ -1560,7 +1646,6 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon='', $noprint= function show_subsidiaries($conf,$langs,$db,$object) { global $user; - global $bc; $i=-1; diff --git a/htdocs/core/lib/files.lib.php b/htdocs/core/lib/files.lib.php index 042d1318f77..206d1bb8099 100644 --- a/htdocs/core/lib/files.lib.php +++ b/htdocs/core/lib/files.lib.php @@ -1706,7 +1706,15 @@ function dol_convert_file($fileinput, $ext='png', $fileoutput='') if (empty($fileoutput)) $fileoutput=$fileinput.".".$ext; $count = $image->getNumberImages(); - $ret = $image->writeImages($fileoutput, true); + + if (! dol_is_file($fileoutput) || is_writeable($fileoutput)) + { + $ret = $image->writeImages($fileoutput, true); + } + else + { + dol_syslog("Warning: Failed to write cache preview file '.$fileoutput.'. Check permission on file/dir", LOG_ERR); + } if ($ret) return $count; else return -3; } diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 9cbf52c1cc8..a736f3c139a 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -111,7 +111,7 @@ function getDoliDBInstance($type, $host, $user, $pass, $name, $port) * 'commande', 'commande_fournisseur', 'expedition', 'intervention', 'survey', * 'contract', 'tax', 'expensereport', 'holiday', 'multicurrency', 'project', * 'email_template', 'event', 'donation' - * 'c_paiement', ... + * 'c_paiement', 'c_payment_term', ... * @param int $shared 0=Return id of current entity only, * 1=Return id of current entity + shared entities (default) * @param int $forceentity Entity id @@ -550,7 +550,7 @@ function GETPOST($paramname, $check='none', $method=0, $filter=NULL, $options=NU if (! is_array($out) || empty($out)) $out=array(); break; case 'nohtml': - $out=dol_string_nohtmltag($out); + $out=dol_string_nohtmltag($out, 0); break; case 'alphanohtml': // Recommended for search params if (! is_array($out)) @@ -2278,7 +2278,7 @@ function dol_print_phone($phone,$countrycode='',$cid=0,$socid=0,$addlink='',$sep $titlealt=($withpicto=='fax'?$langs->trans("Fax"):$langs->trans("Phone")); } $rep=''; - + if ($hookmanager) { $parameters = array('countrycode' => $countrycode, 'cid' => $cid, 'socid' => $socid,'titlealt' => $titlealt, 'picto' => $withpicto); $reshook = $hookmanager->executeHooks('printPhone', $parameters, $phone); @@ -2304,7 +2304,7 @@ function dol_print_phone($phone,$countrycode='',$cid=0,$socid=0,$addlink='',$sep if ($adddivfloat) $rep.=''; else $rep.=''; } - + return $rep; } @@ -3520,15 +3520,16 @@ function dol_print_error($db='',$error='',$errors=null) * @param string $prefixcode Prefix of public error code * @param string $errormessage Complete error message * @param array $errormessages Array of error messages + * @param string $morecss More css * @return void */ -function dol_print_error_email($prefixcode, $errormessage='', $errormessages=array()) +function dol_print_error_email($prefixcode, $errormessage='', $errormessages=array(), $morecss='error') { global $langs,$conf; $langs->load("errors"); $now=dol_now(); - print '
' . "\n"; diff --git a/htdocs/core/tpl/objectline_create.tpl.php b/htdocs/core/tpl/objectline_create.tpl.php index 2d6178ed79b..d26a31b3cd2 100644 --- a/htdocs/core/tpl/objectline_create.tpl.php +++ b/htdocs/core/tpl/objectline_create.tpl.php @@ -131,7 +131,7 @@ if ($nolinesbefore) { if (! empty($conf->global->MAIN_VIEW_LINE_NUMBER)) { $coldisplay=2; ?> - > + global->MAIN_VIEW_LINE_NUMBER)) { print ''; } ?> "; //} - if($conf->categorie->enabled) { + if ($conf->categorie->enabled) { // Categories print '"; } @@ -1464,6 +1464,7 @@ else $cate_arbo = $form->select_all_categories(Categorie::TYPE_PRODUCT, '', 'parent', 64, 0, 1); $c = new Categorie($db); $cats = $c->containing($object->id,Categorie::TYPE_PRODUCT); + $arrayselected=array(); foreach($cats as $cat) { $arrayselected[] = $cat->id; } diff --git a/htdocs/product/class/api_products.class.php b/htdocs/product/class/api_products.class.php index b21a6a34046..516c67f1fbe 100644 --- a/htdocs/product/class/api_products.class.php +++ b/htdocs/product/class/api_products.class.php @@ -197,7 +197,8 @@ class Products extends DolibarrApi } /** - * Update product + * Update product. + * Price will be updated by this API only if option is set on "One price per product". See other APIs for other price modes. * * @param int $id Id of product to update * @param array $request_data Datas @@ -209,6 +210,8 @@ class Products extends DolibarrApi */ function put($id, $request_data = NULL) { + global $conf; + if(! DolibarrApiAccess::$user->rights->produit->creer) { throw new RestException(401); } @@ -222,15 +225,63 @@ class Products extends DolibarrApi throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } + $oldproduct = dol_clone($this->product, 0); + foreach($request_data as $field => $value) { if ($field == 'id') continue; $this->product->$field = $value; } - if($this->product->update($id, DolibarrApiAccess::$user,1,'update')) - return $this->get ($id); + $result = $this->product->update($id, DolibarrApiAccess::$user, 1, 'update'); - return false; + // If price mode is 1 price per product + if ($result > 0 && ! empty($conf->global->PRODUCT_PRICE_UNIQ)) + { + // We update price only if it was changed + $pricemodified = false; + if ($this->product->price_base_type != $oldproduct->price_base_type) $pricemodified = true; + else + { + if ($this->product->tva_tx != $oldproduct->tva_tx) $pricemodified = true; + if ($this->product->tva_npr != $oldproduct->tva_npr) $pricemodified = true; + if ($this->product->default_vat_code != $oldproduct->default_vat_code) $pricemodified = true; + + if ($this->product->price_base_type == 'TTC') + { + if ($this->product->price_ttc != $oldproduct->price_ttc) $pricemodified = true; + if ($this->product->price_min_ttc != $oldproduct->price_min_ttc) $pricemodified = true; + } + else + { + if ($this->product->price != $oldproduct->price) $pricemodified = true; + if ($this->product->price_min != $oldproduct->price_min) $pricemodified = true; + } + } + + if ($pricemodified) + { + $newvat = $this->product->tva_tx; + $newnpr = $this->product->tva_npr; + $newvatsrccode = $this->product->default_vat_code; + + $newprice = $this->product->price; + $newpricemin = $this->product->price_min; + if ($this->product->price_base_type == 'TTC') + { + $newprice = $this->product->price_ttc; + $newpricemin = $this->product->price_min_ttc; + } + + $result = $this->product->updatePrice($newprice, $this->product->price_base_type, DolibarrApiAccess::$user, $newvat, $newpricemin, 0, $newnpr, 0, 0, array(), $newvatsrccode); + } + } + + if ($result <= 0) + { + throw new RestException(500, "Error updating product", array_merge(array($this->product->error), $this->product->errors)); + } + + return $this->get($id); } /** @@ -431,6 +482,8 @@ class Products extends DolibarrApi unset($object->lastname); unset($object->civility_id); + unset($object->recuperableonly); + return $object; } diff --git a/htdocs/projet/card.php b/htdocs/projet/card.php index 2b8633ca31f..b5646e37128 100644 --- a/htdocs/projet/card.php +++ b/htdocs/projet/card.php @@ -153,8 +153,8 @@ if (empty($reshook)) $object->socid = GETPOST('socid','int'); $object->description = GETPOST('description','none'); // Do not use 'alpha' here, we want field as it is $object->public = GETPOST('public','alpha'); - $object->opp_amount = price2num(GETPOST('opp_amount')); - $object->budget_amount = price2num(GETPOST('budget_amount')); + $object->opp_amount = price2num(GETPOST('opp_amount','alpha')); + $object->budget_amount = price2num(GETPOST('budget_amount','alpha')); $object->datec = dol_now(); $object->date_start = $date_start; $object->date_end = $date_end; @@ -251,13 +251,14 @@ if (empty($reshook)) $object->ref = GETPOST('ref','alpha'); $object->title = GETPOST('title','none'); // Do not use 'alpha' here, we want field as it is + $object->statut = GETPOST('status','int'); $object->socid = GETPOST('socid','int'); $object->description = GETPOST('description','none'); // Do not use 'alpha' here, we want field as it is $object->public = GETPOST('public','alpha'); $object->date_start = empty($_POST["projectstart"])?'':$date_start; $object->date_end = empty($_POST["projectend"])?'':$date_end; - if (isset($_POST['opp_amount'])) $object->opp_amount = price2num(GETPOST('opp_amount')); - if (isset($_POST['budget_amount'])) $object->budget_amount= price2num(GETPOST('budget_amount')); + if (isset($_POST['opp_amount'])) $object->opp_amount = price2num(GETPOST('opp_amount','alpha')); + if (isset($_POST['budget_amount'])) $object->budget_amount= price2num(GETPOST('budget_amount','alpha')); if (isset($_POST['opp_status'])) $object->opp_status = $opp_status; if (isset($_POST['opp_percent'])) $object->opp_percent = $opp_percent; @@ -737,6 +738,16 @@ elseif ($object->id > 0) print ''; print ''; + // Status + print ''; + // Thirdparty if ($conf->societe->enabled) { @@ -765,9 +776,6 @@ elseif ($object->id > 0) print $form->selectarray('public',$array,$object->public); print ''; - // Status - print ''; - if (! empty($conf->global->PROJECT_USE_OPPORTUNITIES)) { // Opportunity status @@ -781,18 +789,18 @@ elseif ($object->id > 0) print ''; print ''; - // Opportunity probability - print ''; - print ''; - print ''; + // Opportunity probability + print ''; + print ''; + print ''; - // Opportunity amount - print ''; - print ''; - print ''; - } + // Opportunity amount + print ''; + print ''; + print ''; + } // Date start print '
'; - $facturestatic->ref=$obj->facnumber; - $facturestatic->id=$obj->rowid; - $facturestatic->total_ht=$obj->total_ht; - $facturestatic->total_tva=$obj->total_tva; - $facturestatic->total_ttc=$obj->total_ttc; - $facturestatic->statut = $obj->fk_statut; - $facturestatic->date_lim_reglement = $db->jdate($obj->datelimite); - $facturestatic->type=$obj->type; print $facturestatic->getNomUrl(1,''); print ''; @@ -379,12 +401,7 @@ if (! empty($conf->facture->enabled) && $user->rights->facture->lire) print ''; - $thirdpartystatic->id=$obj->socid; - $thirdpartystatic->name=$obj->name; - $thirdpartystatic->client=1; - $thirdpartystatic->code_client = $obj->code_client; - $thirdpartystatic->code_fournisseur = $obj->code_fournisseur; - print $thirdpartystatic->getNomUrl(1,'customer',44); + print $thirdpartystatic->getNomUrl(1,'customer',44); print ''.price($obj->total_ht).''.price($obj->total_ttc).'
'; + $facstatic->ref=$obj->ref; - $facstatic->id = $obj->rowid; - $facstatic->total_ht = $obj->total_ht; - $facstatic->total_tva = $obj->total_tva; - $facstatic->total_ttc = $obj->total_ttc; - print $facstatic->getNomUrl(1,''); - print ''; + $facstatic->id = $obj->rowid; + $facstatic->total_ht = $obj->total_ht; + $facstatic->total_tva = $obj->total_tva; + $facstatic->total_ttc = $obj->total_ttc; + $thirdpartystatic->id=$obj->socid; $thirdpartystatic->name=$obj->name; $thirdpartystatic->fournisseur=1; - $thirdpartystatic->code_client = $obj->code_client; - $thirdpartystatic->code_fournisseur = $obj->code_fournisseur; + //$thirdpartystatic->code_client = $obj->code_client; + $thirdpartystatic->code_fournisseur = $obj->code_fournisseur; + //$thirdpartystatic->code_compta = $obj->code_compta; + $thirdpartystatic->code_compta_fournisseur = $obj->code_compta_fournisseur; + + print '
'; + print $facstatic->getNomUrl(1,''); + print ''; print $thirdpartystatic->getNomUrl(1,'supplier',44); print ''.price($obj->total_ht).''.$langs->trans("ToBill").' 
'; + $societestatic->id=$obj->socid; + $societestatic->name=$obj->name; + $societestatic->email=$obj->email; + $societestatic->client=1; + $societestatic->code_client = $obj->code_client; + //$societestatic->code_fournisseur = $obj->code_fournisseur; + $societestatic->code_compta = $obj->code_compta; + //$societestatic->code_fournisseur = $obj->code_fournisseur; $commandestatic->id=$obj->rowid; $commandestatic->ref=$obj->ref; + print '
'; + print ''; print ''; print ''; if (! empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) print ''; @@ -787,8 +815,8 @@ if (! empty($conf->facture->enabled) && $user->rights->facture->lire) $sql = "SELECT f.rowid, f.facnumber, f.fk_statut, f.datef, f.type, f.total as total_ht, f.tva as total_tva, f.total_ttc, f.paye, f.tms"; $sql.= ", f.date_lim_reglement as datelimite"; $sql.= ", s.nom as name"; - $sql.= ", s.rowid as socid"; - $sql.= ", s.code_client"; + $sql.= ", s.rowid as socid, s.email"; + $sql.= ", s.code_client, s.code_compta"; $sql.= ", sum(pf.amount) as am"; $sql.= " FROM ".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture as f"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."paiement_facture as pf on f.rowid=pf.fk_facture"; @@ -802,7 +830,8 @@ if (! empty($conf->facture->enabled) && $user->rights->facture->lire) $reshook=$hookmanager->executeHooks('printFieldListWhereCustomerUnpaid',$parameters); $sql.=$hookmanager->resPrint; - $sql.= " GROUP BY f.rowid, f.facnumber, f.fk_statut, f.datef, f.type, f.total, f.tva, f.total_ttc, f.paye, f.tms, f.date_lim_reglement, s.nom, s.rowid, s.code_client"; + $sql.= " GROUP BY f.rowid, f.facnumber, f.fk_statut, f.datef, f.type, f.total, f.tva, f.total_ttc, f.paye, f.tms, f.date_lim_reglement,"; + $sql.= " s.nom, s.rowid, s.email, s.code_client, s.code_compta"; $sql.= " ORDER BY f.datef ASC, f.facnumber ASC"; $resql = $db->query($sql); @@ -829,19 +858,29 @@ if (! empty($conf->facture->enabled) && $user->rights->facture->lire) { $obj = $db->fetch_object($resql); + $facturestatic->ref=$obj->facnumber; + $facturestatic->id=$obj->rowid; + $facturestatic->total_ht=$obj->total_ht; + $facturestatic->total_tva=$obj->total_tva; + $facturestatic->total_ttc=$obj->total_ttc; + $facturestatic->type=$obj->type; + $facturestatic->statut = $obj->fk_statut; + $facturestatic->date_lim_reglement = $db->jdate($obj->datelimite); + + $societestatic->id=$obj->socid; + $societestatic->name=$obj->name; + $societestatic->email=$obj->email; + $societestatic->client=1; + $societestatic->code_client = $obj->code_client; + $societestatic->code_fournisseur = $obj->code_fournisseur; + $societestatic->code_compta = $obj->code_compta; + $societestatic->code_compta_fournisseur = $obj->code_compta_fournisseur; + print ''; print '\n"; - print "\n"; + // Label + print "\n"; print '\n"; print '\n"; // Type diff --git a/htdocs/contact/card.php b/htdocs/contact/card.php index bc0031b5992..9c35714dcd5 100644 --- a/htdocs/contact/card.php +++ b/htdocs/contact/card.php @@ -607,7 +607,15 @@ else // State if (empty($conf->global->SOCIETE_DISABLE_STATE)) { - print ''; } diff --git a/htdocs/contact/class/contact.class.php b/htdocs/contact/class/contact.class.php index 1f307b00c69..f616ca728b6 100644 --- a/htdocs/contact/class/contact.class.php +++ b/htdocs/contact/class/contact.class.php @@ -42,6 +42,27 @@ class Contact extends CommonObject public $ismultientitymanaged = 1; // 0=No test on entity, 1=Test with field entity, 2=Test with link by societe public $picto = 'contact'; + + // BEGIN MODULEBUILDER PROPERTIES + /** + * @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( + 'rowid' =>array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'index'=>1, 'position'=>1, 'comment'=>'Id'), + 'lastname' =>array('type'=>'varchar(128)', 'label'=>'Name', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'showoncombobox'=>1, 'index'=>1, 'position'=>10, 'searchall'=>1), + 'firstname' =>array('type'=>'varchar(128)', 'label'=>'Firstname', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'showoncombobox'=>1, 'index'=>1, 'position'=>11, 'searchall'=>1), + 'entity' =>array('type'=>'integer', 'label'=>'Entity', 'enabled'=>1, 'visible'=>0, 'default'=>1, 'notnull'=>1, 'index'=>1, 'position'=>20), + 'note_public' =>array('type'=>'text', 'label'=>'NotePublic', 'enabled'=>1, 'visible'=>0, 'position'=>60), + 'note_private' =>array('type'=>'text', 'label'=>'NotePrivate', 'enabled'=>1, 'visible'=>0, 'position'=>61), + 'datec' =>array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>500), + 'tms' =>array('type'=>'timestamp', 'label'=>'DateModification', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>501), + //'date_valid' =>array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>-2, 'position'=>502), + 'fk_user_creat' =>array('type'=>'integer', 'label'=>'UserAuthor', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>510), + 'fk_user_modif' =>array('type'=>'integer', 'label'=>'UserModif', 'enabled'=>1, 'visible'=>-2, 'notnull'=>-1, 'position'=>511), + //'fk_user_valid' =>array('type'=>'integer', 'label'=>'UserValidation', 'enabled'=>1, 'visible'=>-1, 'position'=>512), + 'import_key' =>array('type'=>'varchar(14)', 'label'=>'ImportId', 'enabled'=>1, 'visible'=>-2, 'notnull'=>-1, 'index'=>1, 'position'=>1000), + ); + public $civility_id; // In fact we store civility_code public $civility_code; public $address; @@ -96,9 +117,15 @@ class Contact extends CommonObject public $user_id; public $user_login; + // END MODULEBUILDER PROPERTIES + + public $oldcopy; // To contains a clone of this when we need to save old properties of object + + + /** * Constructor * @@ -131,7 +158,7 @@ class Contact extends CommonObject $sql.= " WHERE sp.fk_soc = s.rowid AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; $clause = "AND"; } - $sql.= ' '.$clause.' sp.entity IN ('.getEntity($this->element, 1).')'; + $sql.= ' '.$clause.' sp.entity IN ('.getEntity($this->element).')'; $sql.= " AND (sp.priv='0' OR (sp.priv='1' AND sp.fk_user_creat=".$user->id."))"; if ($user->societe_id > 0) $sql.=" AND sp.fk_soc = ".$user->societe_id; diff --git a/htdocs/contrat/card.php b/htdocs/contrat/card.php index 21324613bdf..0ca4b4d879d 100644 --- a/htdocs/contrat/card.php +++ b/htdocs/contrat/card.php @@ -3,7 +3,7 @@ * Copyright (C) 2004-2014 Laurent Destailleur * Copyright (C) 2005-2014 Regis Houssin * Copyright (C) 2006 Andre Cianfarani - * Copyright (C) 2010-2015 Juanjo Menent + * Copyright (C) 2010-2017 Juanjo Menent * Copyright (C) 2013 Christophe Battarel * Copyright (C) 2013-2014 Florian Henry * Copyright (C) 2014-2016 Ferran Marcet @@ -657,43 +657,53 @@ if (empty($reshook)) else if ($action == 'updateline' && $user->rights->contrat->creer && ! GETPOST('cancel','alpha')) { - if (!empty($date_start_update) && !empty($date_end_update) && $date_start_update > $date_end_update) - { - setEventMessages($langs->trans("Error").': '.$langs->trans("DateStartPlanned").' > '.$langs->trans("DateEndPlanned"), null, 'errors'); - $action = 'editline'; - $_GET['rowid'] = GETPOST('elrowid'); - $error++; - } + $error = 0; - if (!$error) { - $objectline = new ContratLigne($db); - if ($objectline->fetch(GETPOST('elrowid'))) - { - $db->begin(); + if (!empty($date_start_update) && !empty($date_end_update) && $date_start_update > $date_end_update) + { + setEventMessages($langs->trans("Error").': '.$langs->trans("DateStartPlanned").' > '.$langs->trans("DateEndPlanned"), null, 'errors'); + $action = 'editline'; + $_GET['rowid'] = GETPOST('elrowid'); + $error++; + } - if ($date_start_real_update == '') $date_start_real_update=$objectline->date_ouverture; - if ($date_end_real_update == '') $date_end_real_update=$objectline->date_cloture; + if (! $error) + { + $objectline = new ContratLigne($db); + if ($objectline->fetch(GETPOST('elrowid')) < 0) + { + setEventMessages($objectline->error, $objectline->errors, 'errors'); + $error++; + } + } - $vat_rate = GETPOST('eltva_tx'); - // Define info_bits - $info_bits = 0; - if (preg_match('/\*/', $vat_rate)) + $db->begin(); + + if (! $error) + { + if ($date_start_real_update == '') $date_start_real_update=$objectline->date_ouverture; + if ($date_end_real_update == '') $date_end_real_update=$objectline->date_cloture; + + $vat_rate = GETPOST('eltva_tx'); + // Define info_bits + $info_bits = 0; + if (preg_match('/\*/', $vat_rate)) $info_bits |= 0x01; // Define vat_rate $vat_rate = str_replace('*', '', $vat_rate); - $localtax1_tx=get_localtax($vat_rate, 1, $object->thirdparty, $mysoc); - $localtax2_tx=get_localtax($vat_rate, 2, $object->thirdparty, $mysoc); + $localtax1_tx=get_localtax($vat_rate, 1, $object->thirdparty, $mysoc); + $localtax2_tx=get_localtax($vat_rate, 2, $object->thirdparty, $mysoc); - $txtva = $vat_rate; + $txtva = $vat_rate; // Clean vat code - $vat_src_code=''; - if (preg_match('/\((.*)\)/', $txtva, $reg)) - { + $vat_src_code=''; + if (preg_match('/\((.*)\)/', $txtva, $reg)) + { $vat_src_code = $reg[1]; $txtva = preg_replace('/\s*\(.*\)/', '', $txtva); // Remove code into vatrate. - } + } // ajout prix d'achat $fk_fournprice = $_POST['fournprice']; @@ -704,22 +714,22 @@ if (empty($reshook)) $fk_unit = GETPOST('unit', 'alpha'); - $objectline->description=GETPOST('product_desc','none'); - $objectline->price_ht=GETPOST('elprice'); - $objectline->subprice=GETPOST('elprice'); - $objectline->qty=GETPOST('elqty'); - $objectline->remise_percent=GETPOST('elremise_percent'); - $objectline->tva_tx=($txtva?$txtva:0); // Field may be disabled, so we use vat rate 0 - $objectline->vat_src_code=$vat_src_code; - $objectline->localtax1_tx=is_numeric($localtax1_tx)?$localtax1_tx:0; - $objectline->localtax2_tx=is_numeric($localtax2_tx)?$localtax2_tx:0; - $objectline->date_ouverture_prevue=$date_start_update; - $objectline->date_ouverture=$date_start_real_update; - $objectline->date_fin_validite=$date_end_update; - $objectline->date_cloture=$date_end_real_update; - $objectline->fk_user_cloture=$user->id; - $objectline->fk_fournprice=$fk_fournprice; - $objectline->pa_ht=$pa_ht; + $objectline->description=GETPOST('product_desc','none'); + $objectline->price_ht=GETPOST('elprice'); + $objectline->subprice=GETPOST('elprice'); + $objectline->qty=GETPOST('elqty'); + $objectline->remise_percent=GETPOST('elremise_percent'); + $objectline->tva_tx=($txtva?$txtva:0); // Field may be disabled, so we use vat rate 0 + $objectline->vat_src_code=$vat_src_code; + $objectline->localtax1_tx=is_numeric($localtax1_tx)?$localtax1_tx:0; + $objectline->localtax2_tx=is_numeric($localtax2_tx)?$localtax2_tx:0; + $objectline->date_ouverture_prevue=$date_start_update; + $objectline->date_ouverture=$date_start_real_update; + $objectline->date_fin_validite=$date_end_update; + $objectline->date_cloture=$date_end_real_update; + $objectline->fk_user_cloture=$user->id; + $objectline->fk_fournprice=$fk_fournprice; + $objectline->pa_ht=$pa_ht; if ($fk_unit > 0) { $objectline->fk_unit = GETPOST('unit'); @@ -727,30 +737,30 @@ if (empty($reshook)) $objectline->fk_unit = null; } - // Extrafields - $extrafieldsline = new ExtraFields($db); - $extralabelsline = $extrafieldsline->fetch_name_optionals_label($objectline->table_element); - $array_options = $extrafieldsline->getOptionalsFromPost($extralabelsline, $predef); - $objectline->array_options=$array_options; + // Extrafields + $extrafieldsline = new ExtraFields($db); + $extralabelsline = $extrafieldsline->fetch_name_optionals_label($objectline->table_element); + $array_options = $extrafieldsline->getOptionalsFromPost($extralabelsline, $predef); + $objectline->array_options=$array_options; - // TODO verifier price_min si fk_product et multiprix + // TODO verifier price_min si fk_product et multiprix - $result=$objectline->update($user); - if ($result > 0) - { - $db->commit(); - } - else - { + $result=$objectline->update($user); + if ($result < 0) + { + $error++; setEventMessages($objectline->error, $objectline->errors, 'errors'); - $db->rollback(); - } - } - else - { - setEventMessages($objectline->error, $objectline->errors, 'errors'); - } - } + } + } + + if (! $error) + { + $db->commit(); + } + else + { + $db->rollback(); + } } else if ($action == 'confirm_deleteline' && $confirm == 'yes' && $user->rights->contrat->creer) @@ -771,6 +781,30 @@ if (empty($reshook)) else if ($action == 'confirm_valid' && $confirm == 'yes' && $user->rights->contrat->creer) { $result = $object->validate($user); + + if ($result > 0) + { + // Define output language + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) + { + $outputlangs = $langs; + $newlang = ''; + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id','aZ09')) $newlang = GETPOST('lang_id','aZ09'); + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang; + if (! empty($newlang)) { + $outputlangs = new Translate("", $conf); + $outputlangs->setDefaultLang($newlang); + } + $model=$object->modelpdf; + $ret = $object->fetch($id); // Reload to get new records + + $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); + } + } + else + { + setEventMessages($object->error, $object->errors, 'errors'); + } } else if ($action == 'reopen' && $user->rights->contrat->creer) diff --git a/htdocs/contrat/class/contrat.class.php b/htdocs/contrat/class/contrat.class.php index a6d557a0776..fd1019390be 100644 --- a/htdocs/contrat/class/contrat.class.php +++ b/htdocs/contrat/class/contrat.class.php @@ -1268,26 +1268,14 @@ class Contrat extends CommonObject { if (! $notrigger) { - // Uncomment this and change MYOBJECT to your own tag if you - // want this action calls a trigger. - - //// Call triggers - //$result=$this->call_trigger('MYOBJECT_MODIFY',$user); - //if ($result < 0) { $error++; //Do also what you must do to rollback action if trigger fail} - //// End call triggers + // Call triggers + $result=$this->call_trigger('CONTRACT_MODIFY',$user); + if ($result < 0) { $error++; } + // End call triggers } } - if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && is_array($this->array_options) && count($this->array_options)>0) // For avoid conflicts if trigger used - { - $result=$this->insertExtraFields(); - if ($result < 0) - { - $error++; - } - } - - if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && is_array($this->array_options) && count($this->array_options)>0) // For avoid conflicts if trigger used + if (! $error && empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && is_array($this->array_options) && count($this->array_options)>0) // For avoid conflicts if trigger used { $result=$this->insertExtraFields(); if ($result < 0) @@ -2872,6 +2860,9 @@ class ContratLigne extends CommonObjectLine $this->db->begin(); + $this->oldcopy = new ContratLigne($this->db); + $this->oldcopy->fetch($this->id); + // Update request $sql = "UPDATE ".MAIN_DB_PREFIX."contratdet SET"; $sql.= " fk_contrat=".$this->fk_contrat.","; @@ -2911,22 +2902,14 @@ class ContratLigne extends CommonObjectLine dol_syslog(get_class($this)."::update", LOG_DEBUG); $resql = $this->db->query($sql); - if ($resql) - { - $contrat=new Contrat($this->db); - $contrat->fetch($this->fk_contrat); - $result=$contrat->update_statut($user); - } - else + if (! $resql) { $this->error="Error ".$this->db->lasterror(); $error++; - //return -1; } if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && is_array($this->array_options) && count($this->array_options)>0) // For avoid conflicts if trigger used { - $result=$this->insertExtraFields(); if ($result < 0) { @@ -2934,19 +2917,52 @@ class ContratLigne extends CommonObjectLine } } - if (empty($error)) { - if (! $notrigger) + // If we change a planned date (start or end), sync dates for all services + if (! $error && ! empty($conf->global->CONTRACT_SYNC_PLANNED_DATE_OF_SERVICES)) { - // Call trigger - $result=$this->call_trigger('LINECONTRACT_UPDATE',$user); - if ($result < 0) { $error++; $this->db->rollback(); return -1; } - // End call triggers - } + if ($this->date_ouverture_prevue != $this->oldcopy->date_ouverture_prevue) + { + $sql ='UPDATE '.MAIN_DB_PREFIX.'contratdet SET'; + $sql.= " date_ouverture_prevue = ".($this->date_ouverture_prevue!=''?"'".$this->db->idate($this->date_ouverture_prevue)."'":"null"); + $sql.= " WHERE fk_contrat = ".$this->fk_contrat; + + $resql = $this->db->query($sql); + if (! $resql) + { + $error++; + $this->error="Error ".$this->db->lasterror(); + } + } + if ($this->date_fin_validite != $this->oldcopy->date_fin_validite) + { + $sql ='UPDATE '.MAIN_DB_PREFIX.'contratdet SET'; + $sql.= " date_fin_validite = ".($this->date_fin_validite!=''?"'".$this->db->idate($this->date_fin_validite)."'":"null"); + $sql.= " WHERE fk_contrat = ".$this->fk_contrat; + + $resql = $this->db->query($sql); + if (! $resql) + { + $error++; + $this->error="Error ".$this->db->lasterror(); + } + } } - if (empty($error)) { - $this->db->commit(); - return 1; + if (! $error) + { + if (! $notrigger) + { + // Call trigger + $result=$this->call_trigger('LINECONTRACT_UPDATE', $user); + if ($result < 0) { $error++; $this->db->rollback(); } + // End call triggers + } + } + + if (! $error) + { + $this->db->commit(); + return 1; } else { $this->db->rollback(); $this->errors[]=$this->error; diff --git a/htdocs/core/actions_changeselectedfields.inc.php b/htdocs/core/actions_changeselectedfields.inc.php index 11884f81224..6d39272f74e 100644 --- a/htdocs/core/actions_changeselectedfields.inc.php +++ b/htdocs/core/actions_changeselectedfields.inc.php @@ -33,14 +33,14 @@ if (GETPOST('formfilteraction') == 'listafterchangingselectedfields') $tabparam=array(); $varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage; - + if (GETPOST("selectedfields")) $tabparam["MAIN_SELECTEDFIELDS_".$varpage]=GETPOST("selectedfields"); else $tabparam["MAIN_SELECTEDFIELDS_".$varpage]=''; include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; - + $result=dol_set_user_param($db, $conf, $user, $tabparam); - + //$action='list'; //var_dump($tabparam);exit; } diff --git a/htdocs/core/actions_sendmails.inc.php b/htdocs/core/actions_sendmails.inc.php index eea69e37c13..962d00ee4b8 100644 --- a/htdocs/core/actions_sendmails.inc.php +++ b/htdocs/core/actions_sendmails.inc.php @@ -106,7 +106,6 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO $subject='';$actionmsg='';$actionmsg2=''; - if (! empty($conf->dolimail->enabled)) $langs->load("dolimail@dolimail"); $langs->load('mails'); if (is_object($object)) @@ -321,6 +320,7 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO // Feature to push mail sent into Sent folder + /* This code must be now included into the hook mail, method sendMailAfter if (! empty($conf->dolimail->enabled)) { $mailfromid = explode("#", $_POST['frommail'],3); // $_POST['frommail'] = 'aaa#Sent# ' // TODO Use a better way to define Sent dir. @@ -329,7 +329,7 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO { $mbid = $mailfromid[1]; - /*IMAP Postbox*/ + // IMAP Postbox $mailboxconfig = new IMAP($db); $mailboxconfig->fetch($mbid); if ($mailboxconfig->mailbox_imap_host) $ref=$mailboxconfig->get_ref(); @@ -361,6 +361,7 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO } } } + */ // Make substitution in email content $substitutionarray=getCommonSubstitutionArray($langs, 0, null, $object); @@ -393,7 +394,8 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO $result=$mailfile->sendfile(); if ($result) { - // FIXME This must be moved into the trigger for action $trigger_name + // Two hooks are available into method $mailfile->sendfile, so dedicated code is no more required + /* if (! empty($conf->dolimail->enabled)) { $mid = (GETPOST('mid','int') ? GETPOST('mid','int') : 0); // Original mail id is set ? @@ -411,7 +413,7 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO if ($movemail) setEventMessages($langs->trans("MailMovedToImapFolder",$folder), null, 'mesgs'); else setEventMessages($langs->trans("MailMovedToImapFolder_Warning",$folder), null, 'warnings'); } - } + }*/ // Initialisation of datas if (is_object($object)) @@ -446,12 +448,10 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO // This avoid sending mail twice if going out and then back to page $mesg=$langs->trans('MailSuccessfulySent',$mailfile->getValidAddress($from,2),$mailfile->getValidAddress($sendto,2)); setEventMessages($mesg, null, 'mesgs'); - if ($conf->dolimail->enabled) - { - header('Location: '.$_SERVER["PHP_SELF"].'?'.($paramname?$paramname:'id').'='.(is_object($object)?$object->id:'').'&'.($paramname2?$paramname2:'mid').'='.$parm2val); - exit; - } - header('Location: '.$_SERVER["PHP_SELF"].'?'.($paramname?$paramname:'id').'='.(is_object($object)?$object->id:'')); + + $moreparam=''; + if (isset($paramname2) || isset($paramval2)) $moreparam.= '&'.($paramname2?$paramname2:'mid').'='.$paramval2; + header('Location: '.$_SERVER["PHP_SELF"].'?'.($paramname?$paramname:'id').'='.(is_object($object)?$object->id:'').$moreparam); exit; } else diff --git a/htdocs/core/boxes/box_produits.php b/htdocs/core/boxes/box_produits.php index 3ccbc05be24..3261572460e 100644 --- a/htdocs/core/boxes/box_produits.php +++ b/htdocs/core/boxes/box_produits.php @@ -84,7 +84,7 @@ class box_produits extends ModeleBoxes { $sql = "SELECT p.rowid, p.label, p.ref, p.price, p.price_base_type, p.price_ttc, p.fk_product_type, p.tms, p.tosell, p.tobuy, p.fk_price_expression, p.entity"; $sql.= " FROM ".MAIN_DB_PREFIX."product as p"; - $sql.= ' WHERE p.entity IN ('.getEntity($productstatic->element, 1).')'; + $sql.= ' WHERE p.entity IN ('.getEntity($productstatic->element).')'; if (empty($user->rights->produit->lire)) $sql.=' AND p.fk_product_type != 0'; if (empty($user->rights->service->lire)) $sql.=' AND p.fk_product_type != 1'; // Add where from hooks diff --git a/htdocs/core/boxes/box_produits_alerte_stock.php b/htdocs/core/boxes/box_produits_alerte_stock.php index e244d276fac..9dc75612773 100644 --- a/htdocs/core/boxes/box_produits_alerte_stock.php +++ b/htdocs/core/boxes/box_produits_alerte_stock.php @@ -88,7 +88,7 @@ class box_produits_alerte_stock extends ModeleBoxes $sql.= " SUM(".$db->ifsql("s.reel IS NULL","0","s.reel").") as total_stock"; $sql.= " FROM ".MAIN_DB_PREFIX."product as p"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product_stock as s on p.rowid = s.fk_product"; - $sql.= ' WHERE p.entity IN ('.getEntity($productstatic->element, 1).')'; + $sql.= ' WHERE p.entity IN ('.getEntity($productstatic->element).')'; $sql.= " AND p.tosell = 1 AND p.seuil_stock_alerte > 0"; if (empty($user->rights->produit->lire)) $sql.=' AND p.fk_product_type != 0'; if (empty($user->rights->service->lire)) $sql.=' AND p.fk_product_type != 1'; diff --git a/htdocs/core/class/CMailFile.class.php b/htdocs/core/class/CMailFile.class.php index d9469c11559..e19892e9a58 100644 --- a/htdocs/core/class/CMailFile.class.php +++ b/htdocs/core/class/CMailFile.class.php @@ -482,7 +482,7 @@ class CMailFile /** - * Send mail that was prepared by constructor + * Send mail that was prepared by constructor. * * @return boolean True if mail sent, false otherwise */ @@ -495,19 +495,25 @@ class CMailFile $res=false; - if (empty($conf->global->MAIN_DISABLE_ALL_MAILS)) + if (empty($conf->global->MAIN_DISABLE_ALL_MAILS) || !empty($conf->global->MAIN_MAIL_FORCE_SENDTO)) { require_once DOL_DOCUMENT_ROOT . '/core/class/hookmanager.class.php'; $hookmanager = new HookManager($db); - $hookmanager->initHooks(array('maildao')); - $reshook = $hookmanager->executeHooks('doactions', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks - if (! empty($reshook)) + $hookmanager->initHooks(array('mail')); + + $parameters=array(); $action=''; + $reshook = $hookmanager->executeHooks('sendMail', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + if ($reshook < 0) { - $this->error = "Error in hook maildao doactions " . $reshook; + $this->error = "Error in hook maildao sendMail " . $reshook; dol_syslog("CMailFile::sendfile: mail end error=" . $this->error, LOG_ERR); return $reshook; } + if ($reshook == 1) // Hook replace standard code + { + return true; + } // Check number of recipient is lower or equal than MAIL_MAX_NB_OF_RECIPIENTS_IN_SAME_EMAIL if (empty($conf->global->MAIL_MAX_NB_OF_RECIPIENTS_TO_IN_SAME_EMAIL)) $conf->global->MAIL_MAX_NB_OF_RECIPIENTS_TO_IN_SAME_EMAIL=10; @@ -557,6 +563,12 @@ class CMailFile $keyfortls ='MAIN_MAIL_EMAIL_TLS_EMAILING'; $keyforstarttls ='MAIN_MAIL_EMAIL_STARTTLS_EMAILING'; } + + if(!empty($conf->global->MAIN_MAIL_FORCE_SENDTO)) { + $this->addr_to = $conf->global->MAIN_MAIL_FORCE_SENDTO; + $this->addr_cc = ''; + $this->addr_bcc = ''; + } // Action according to choosed sending method if ($this->sendmode == 'mail') @@ -760,13 +772,21 @@ class CMailFile } else { - // Send mail method not correctly defined // -------------------------------------- return 'Bad value for sendmode'; } + $parameters=array(); $action=''; + $reshook = $hookmanager->executeHooks('sendMailAfter', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + if ($reshook < 0) + { + $this->error = "Error in hook maildao sendMailAfter " . $reshook; + dol_syslog("CMailFile::sendfile: mail end error=" . $this->error, LOG_ERR); + + return $reshook; + } } else { diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 592960670a0..54b656c9cd7 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -79,7 +79,7 @@ abstract class CommonObject */ public $array_options=array(); /** - * @var int[] Array of linked objects ids. Loaded by ->fetchObjectLinked + * @var int[][] Array of linked objects ids. Loaded by ->fetchObjectLinked */ public $linkedObjectsIds; /** @@ -1274,14 +1274,15 @@ abstract class CommonObject } /** - * Load object from specific field - * - * @param string $table Table element or element line - * @param string $field Field selected - * @param string $key Import key - * @return int <0 if KO, >0 if OK - */ - function fetchObjectFrom($table,$field,$key) + * Load object from specific field + * + * @param string $table Table element or element line + * @param string $field Field selected + * @param string $key Import key + * @param string $element Element name + * @return int <0 if KO, >0 if OK + */ + function fetchObjectFrom($table, $field, $key, $element = null) { global $conf; @@ -1289,7 +1290,11 @@ abstract class CommonObject $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX.$table; $sql.= " WHERE ".$field." = '".$key."'"; - $sql.= " AND entity = ".$conf->entity; + if (! empty($element)) { + $sql.= " AND entity IN (".getEntity($element).")"; + } else { + $sql.= " AND entity = ".$conf->entity; + } dol_syslog(get_class($this).'::fetchObjectFrom', LOG_DEBUG); $resql = $this->db->query($sql); @@ -1341,6 +1346,7 @@ abstract class CommonObject * @param User|string $fuser Update the user of last update field with this user. If not provided, current user is used except if value is 'none' * @param string $trigkey Trigger key to run (in most cases something like 'XXX_MODIFY') * @return int <0 if KO, >0 if OK + * @see updateExtraField */ function setValueFrom($field, $value, $table='', $id=null, $format='', $id_field='', $fuser=null, $trigkey='') { @@ -4452,7 +4458,7 @@ abstract class CommonObject * @param array $optionsArray Array resulting of call of extrafields->fetch_name_optionals_label(). Deprecated. Function must be called without parameters. * @return int <0 if error, 0 if no values of extrafield to find nor found, 1 if an attribute is found and value loaded */ - function fetch_optionals($rowid=null,$optionsArray=null) + function fetch_optionals($rowid=null, $optionsArray=null) { if (empty($rowid)) $rowid=$this->id; @@ -4567,6 +4573,7 @@ abstract class CommonObject * @param string $trigger If defined, call also the trigger (for example COMPANY_MODIFY) * @param User $userused Object user * @return int -1=error, O=did nothing, 1=OK + * @see updateExtraField, setValueFrom */ function insertExtraFields($trigger='', $userused=null) { @@ -4597,16 +4604,30 @@ abstract class CommonObject foreach($new_array_options as $key => $value) { - $attributeKey = substr($key,8); // Remove 'options_' prefix - $attributeType = $extrafields->attribute_type[$attributeKey]; - $attributeLabel = $extrafields->attribute_label[$attributeKey]; - $attributeParam = $extrafields->attribute_param[$attributeKey]; + $attributeKey = substr($key,8); // Remove 'options_' prefix + $attributeType = $extrafields->attribute_type[$attributeKey]; + $attributeLabel = $extrafields->attribute_label[$attributeKey]; + $attributeParam = $extrafields->attribute_param[$attributeKey]; + $attributeRequired = $extrafields->attribute_required[$attributeKey]; + + if ($attributeRequired) + { + $mandatorypb=false; + if ($attributeType == 'link' && $this->array_options[$key] == '-1') $mandatorypb=true; + if ($this->array_options[$key] === '') $mandatorypb=true; + if ($mandatorypb) + { + $this->errors[]=$langs->trans('ErrorFieldRequired', $attributeLabel); + return -1; + } + } + switch ($attributeType) { case 'int': if (!is_numeric($value) && $value!='') { - $this->errors[]=$langs->trans("ExtraFieldHasWrongValue",$attributeLabel); + $this->errors[]=$langs->trans("ExtraFieldHasWrongValue", $attributeLabel); return -1; } elseif ($value=='') @@ -4630,23 +4651,27 @@ abstract class CommonObject $new_array_options[$key] = $this->db->idate($this->array_options[$key]); break; case 'link': - $param_list=array_keys($attributeParam ['options']); + $param_list=array_keys($attributeParam['options']); // 0 : ObjectName // 1 : classPath $InfoFieldList = explode(":", $param_list[0]); dol_include_once($InfoFieldList[1]); if ($InfoFieldList[0] && class_exists($InfoFieldList[0])) { - $object = new $InfoFieldList[0]($this->db); - if ($value) + if ($value == '-1') // -1 is key for no defined in combo list of objects { + $new_array_options[$key]=''; + } + elseif ($value) + { + $object = new $InfoFieldList[0]($this->db); if (is_numeric($value)) $res=$object->fetch($value); else $res=$object->fetch('',$value); if ($res > 0) $new_array_options[$key]=$object->id; else { - $this->error="Ref '".$value."' for object '".$object->element."' not found"; + $this->error="Id/Ref '".$value."' for object '".$object->element."' not found"; $this->db->rollback(); return -1; } @@ -4659,6 +4684,7 @@ abstract class CommonObject break; } } + $this->db->begin(); $table_element = $this->table_element; @@ -4704,7 +4730,7 @@ abstract class CommonObject $error++; } - if (!$error && !$trigger) + if (! $error && $trigger) { // Call trigger $this->context=array('extrafieldaddupdate'=>1); @@ -4729,15 +4755,19 @@ abstract class CommonObject /** * Update an exta field value for the current object. - * Data to describe values to insert/update are stored into $this->array_options=array('options_codeforfield1'=>'valueforfield1', 'options_codeforfield2'=>'valueforfield2', ...) - * This function delte record with all extrafields and insert them again from the array $this->array_options. + * Data to describe values to update are stored into $this->array_options=array('options_codeforfield1'=>'valueforfield1', 'options_codeforfield2'=>'valueforfield2', ...) * - * @param string $key Key of the extrafield - * @return int -1=error, O=did nothing, 1=OK + * @param string $key Key of the extrafield + * @param string $trigger If defined, call also the trigger (for example COMPANY_MODIFY) + * @param User $userused Object user + * @return int -1=error, O=did nothing, 1=OK + * @see setValueFrom */ - function updateExtraField($key) + function updateExtraField($key, $trigger, $userused) { - global $conf,$langs; + global $conf,$langs,$user; + + if (empty($userused)) $userused=$user; $error=0; @@ -4789,9 +4819,9 @@ abstract class CommonObject // 1 : classPath $InfoFieldList = explode(":", $param_list[0]); dol_include_once($InfoFieldList[1]); - $object = new $InfoFieldList[0]($this->db); if ($value) { + $object = new $InfoFieldList[0]($this->db); $object->fetch(0,$value); $this->array_options["options_".$key]=$object->id; } @@ -4804,7 +4834,21 @@ abstract class CommonObject $resql = $this->db->query($sql); if (! $resql) { + $error++; $this->error=$this->db->lasterror(); + } + + if (! $error && $trigger) + { + // Call trigger + $this->context=array('extrafieldupdate'=>1); + $result=$this->call_trigger($trigger, $userused); + if ($result < 0) $error++; + // End call trigger + } + + if ($error) + { $this->db->rollback(); return -1; } @@ -5908,7 +5952,7 @@ abstract class CommonObject * @param int $dest_id New thirdparty id (the thirdparty that will received element of the other) * @param string[] $tables Tables that need to be changed * @param int $ignoreerrors Ignore errors. Return true even if errors. We need this when replacement can fails like for categories (categorie of old thirdparty may already exists on new one) - * @return bool + * @return bool True if success, False if error */ public static function commonReplaceThirdparty(DoliDB $db, $origin_id, $dest_id, array $tables, $ignoreerrors=0) { @@ -6313,12 +6357,14 @@ abstract class CommonObject $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX . $this->table_element); } + // Create extrafields if (! $error) { $result=$this->insertExtraFields(); if ($result < 0) $error++; } + // Triggers if (! $error && ! $notrigger) { // Call triggers @@ -6380,13 +6426,13 @@ abstract class CommonObject /** * Update object into database * - * @param User $user User that modifies - * @param bool $notrigger false=launch triggers after, true=disable triggers - * @return int <0 if KO, >0 if OK + * @param User $user User that modifies + * @param bool $notrigger false=launch triggers after, true=disable triggers + * @return int <0 if KO, >0 if OK */ public function updateCommon(User $user, $notrigger = false) { - global $langs; + global $conf, $langs; $error = 0; @@ -6434,7 +6480,22 @@ abstract class CommonObject } } - if (! $error && ! $notrigger) { + // Update extrafield + if (! $error) + { + if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used + { + $result=$this->insertExtraFields(); + if ($result < 0) + { + $error++; + } + } + } + + // Triggers + if (! $error && ! $notrigger) + { // Call triggers $result=$this->call_trigger(strtoupper(get_class($this)).'_MODIFY',$user); if ($result < 0) { $error++; } //Do also here what you must do to rollback action if trigger fail @@ -6473,6 +6534,19 @@ abstract class CommonObject } } + if (! $error) + { + $sql = "DELETE FROM " . MAIN_DB_PREFIX . $this->table_element."_extrafields"; + $sql.= " WHERE fk_object=" . $this->id; + + $resql = $this->db->query($sql); + if (! $resql) + { + $this->errors[] = $this->db->lasterror(); + $error++; + } + } + if (! $error) { $sql = 'DELETE FROM '.MAIN_DB_PREFIX.$this->table_element.' WHERE rowid='.$this->id; diff --git a/htdocs/core/class/conf.class.php b/htdocs/core/class/conf.class.php index dd8081754d8..a1d051440c3 100644 --- a/htdocs/core/class/conf.class.php +++ b/htdocs/core/class/conf.class.php @@ -259,9 +259,6 @@ class Conf // Load translation object with current language if (empty($this->global->MAIN_LANG_DEFAULT)) $this->global->MAIN_LANG_DEFAULT="en_US"; - //if (! isset($this->global->MAIN_REPEATCONTACTONEACHTAB)) $this->global->MAIN_REPEATCONTACTONEACHTAB=1; - //if (! isset($this->global->MAIN_REPEATADDRESSONEACHTAB)) $this->global->MAIN_REPEATADDRESSONEACHTAB=1; - $rootfordata = DOL_DATA_ROOT; $rootforuser = DOL_DATA_ROOT; // If multicompany module is enabled, we redefine the root of data diff --git a/htdocs/core/class/dolgraph.class.php b/htdocs/core/class/dolgraph.class.php index 329383160aa..ba7a67be3cb 100644 --- a/htdocs/core/class/dolgraph.class.php +++ b/htdocs/core/class/dolgraph.class.php @@ -594,7 +594,7 @@ class DolGraph * @param string $fileurl Url path to show image if saved onto disk * @return integer|null */ - function draw($file,$fileurl='') + function draw($file, $fileurl='') { if (empty($file)) { @@ -602,12 +602,17 @@ class DolGraph dol_syslog(get_class($this)."::draw ".$this->error, LOG_ERR); return -2; } - if (! is_array($this->data) || count($this->data) < 1) + if (! is_array($this->data)) { $this->error="Call to draw method was made but SetData was not called or called with an empty dataset for parameters"; dol_syslog(get_class($this)."::draw ".$this->error, LOG_ERR); return -1; } + if (count($this->data) < 1) + { + $this->error="Call to draw method was made but SetData was is an empty dataset"; + dol_syslog(get_class($this)."::draw ".$this->error, LOG_WARNING); + } $call = "draw_".$this->_library; call_user_func_array(array($this,$call), array($file,$fileurl)); } @@ -822,7 +827,7 @@ class DolGraph $legends=array(); $nblot=count($this->data[0])-1; // -1 to remove legend - if ($nblot < 0) dol_print_error('', 'Bad value for property ->data. Must be set by mydolgraph->SetData before calling mydolgrapgh->draw'); + if ($nblot < 0) dol_syslog('Bad value for property ->data. Must be set by mydolgraph->SetData before calling mydolgrapgh->draw', LOG_WARNING); $firstlot=0; // Works with line but not with bars //if ($nblot > 2) $firstlot = ($nblot - 2); // We limit nblot to 2 because jflot can't manage more than 2 bars on same x diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php index bc37c428bb6..fd3c60a5b85 100644 --- a/htdocs/core/class/extrafields.class.php +++ b/htdocs/core/class/extrafields.class.php @@ -168,7 +168,7 @@ class ExtraFields if ($result > 0 || $err1 == 'DB_ERROR_COLUMN_ALREADY_EXISTS' || $type == 'separate') { // Add declaration of field into table - $result2=$this->create_label($attrname, $label, $type, $pos, $size, $elementtype, $unique, $required, $param, $alwayseditable, $perms, $list, $notused, $default, $computed, $entity, $langfile, $enabled); + $result2=$this->create_label($attrname, $label, $type, $pos, $size, $elementtype, $unique, $required, $param, $alwayseditable, $perms, $list, $notused, $default_value, $computed, $entity, $langfile, $enabled); $err2=$this->errno; if ($result2 > 0 || ($err1 == 'DB_ERROR_COLUMN_ALREADY_EXISTS' && $err2 == 'DB_ERROR_RECORD_ALREADY_EXISTS')) { @@ -309,7 +309,7 @@ class ExtraFields if (! empty($attrname) && preg_match("/^\w[a-zA-Z0-9-_]*$/",$attrname) && ! is_numeric($attrname)) { - if(is_array($param) && count($param) > 0) + if (is_array($param) && count($param) > 0) { $params = serialize($param); } @@ -627,10 +627,17 @@ class ExtraFields { $this->db->begin(); - if (is_array($param)) + if (is_array($param) && count($param) > 0) { - if (count($param) > 0) $param = $this->db->escape(serialize($param)); - else $param=''; + $params = serialize($param); + } + elseif (strlen($param) > 0) + { + $params = trim($param); + } + else + { + $params=''; } $sql_del = "DELETE FROM ".MAIN_DB_PREFIX."extrafields"; @@ -674,7 +681,7 @@ class ExtraFields $sql.= " ".($langfile?"'".$this->db->escape($langfile)."'":"null").","; $sql.= " ".$pos.","; $sql.= " '".$this->db->escape($alwayseditable)."',"; - $sql.= " '".$this->db->escape($param)."',"; + $sql.= " '".$this->db->escape($params)."',"; $sql.= " ".$list.", "; $sql.= " ".(($default!='')?"'".$this->db->escape($default)."'":"null").","; $sql.= " ".($computed?"'".$this->db->escape($computed)."'":"null").","; @@ -1344,28 +1351,48 @@ class ExtraFields /** * Return HTML string to put an output field into a page * - * @param string $key Key of attribute - * @param string $value Value to show - * @param string $moreparam To add more parameters on html input tag (only checkbox use html input for output rendering) - * @return string Formated value + * @param string $key Key of attribute + * @param string $value Value to show + * @param string $moreparam To add more parameters on html input tag (only checkbox use html input for output rendering) + * @param string $extrafieldsobjectkey If defined, use the new method to get extrafields data + * @return string Formated value */ - function showOutputField($key,$value,$moreparam='') + function showOutputField($key, $value, $moreparam='', $extrafieldsobjectkey='') { global $conf,$langs; - $elementtype=$this->attribute_elementtype[$key]; // seems not used - $label=$this->attribute_label[$key]; - $type=$this->attribute_type[$key]; - $size=$this->attribute_size[$key]; - $default=$this->attribute_default[$key]; - $computed=$this->attribute_computed[$key]; - $unique=$this->attribute_unique[$key]; - $required=$this->attribute_required[$key]; - $param=$this->attribute_param[$key]; - $perms=$this->attribute_perms[$key]; - $langfile=$this->attribute_langfile[$key]; - $list=$this->attribute_list[$key]; - $hidden=(($list == 0) ? 1 : 0); // If zero, we are sure it is hidden, otherwise we show. If it depends on mode (view/create/edit form or list, this must be filtered by caller) + if (! empty($extrafieldsobjectkey)) + { + $elementtype=$this->attributes[$extrafieldsobjectkey]['elementtype'][$key]; // seems not used + $label=$this->attributes[$extrafieldsobjectkey]['label'][$key]; + $type=$this->attributes[$extrafieldsobjectkey]['type'][$key]; + $size=$this->attributes[$extrafieldsobjectkey]['size'][$key]; + $default=$this->attributes[$extrafieldsobjectkey]['default'][$key]; + $computed=$this->attributes[$extrafieldsobjectkey]['computed'][$key]; + $unique=$this->attributes[$extrafieldsobjectkey]['unique'][$key]; + $required=$this->attributes[$extrafieldsobjectkey]['required'][$key]; + $param=$this->attributes[$extrafieldsobjectkey]['param'][$key]; + $perms=$this->attributes[$extrafieldsobjectkey]['perms'][$key]; + $langfile=$this->attributes[$extrafieldsobjectkey]['langfile'][$key]; + $list=$this->attributes[$extrafieldsobjectkey]['list'][$key]; + $hidden=(($list == 0) ? 1 : 0); // If zero, we are sure it is hidden, otherwise we show. If it depends on mode (view/create/edit form or list, this must be filtered by caller) + } + else + { + $elementtype=$this->attribute_elementtype[$key]; // seems not used + $label=$this->attribute_label[$key]; + $type=$this->attribute_type[$key]; + $size=$this->attribute_size[$key]; + $default=$this->attribute_default[$key]; + $computed=$this->attribute_computed[$key]; + $unique=$this->attribute_unique[$key]; + $required=$this->attribute_required[$key]; + $param=$this->attribute_param[$key]; + $perms=$this->attribute_perms[$key]; + $langfile=$this->attribute_langfile[$key]; + $list=$this->attribute_list[$key]; + $hidden=(($list == 0) ? 1 : 0); // If zero, we are sure it is hidden, otherwise we show. If it depends on mode (view/create/edit form or list, this must be filtered by caller) + } if ($hidden) return ''; // This is a protection. If field is hidden, we should just not call this method. @@ -1593,8 +1620,9 @@ class ExtraFields elseif ($type == 'link') { $out=''; - // only if something to display (perf) - if ($value) + + // Only if something to display (perf) + if ($value) // If we have -1 here, pb is into sert, not into ouptu { $param_list=array_keys($param['options']); // $param_list='ObjectName:classPath' @@ -1641,14 +1669,16 @@ class ExtraFields /** * Return tag to describe alignement to use for this extrafield * - * @param string $key Key of attribute - * @return string Formated value + * @param string $key Key of attribute + * @param string $extrafieldsobjectkey If defined, use the new method to get extrafields data + * @return string Formated value */ - function getAlignFlag($key) + function getAlignFlag($key, $extrafieldsobjectkey='') { global $conf,$langs; - $type=$this->attribute_type[$key]; + if (! empty($extrafieldsobjectkey)) $type=$this->attributes[$extrafieldsobjectkey]['type'][$key]; + else $type=$this->attribute_type[$key]; $align=''; diff --git a/htdocs/core/class/hookmanager.class.php b/htdocs/core/class/hookmanager.class.php index 31833c113b4..1a19e313e08 100644 --- a/htdocs/core/class/hookmanager.class.php +++ b/htdocs/core/class/hookmanager.class.php @@ -139,6 +139,9 @@ class HookManager 'addMoreMassActions', 'addSearchEntry', 'addStatisticLine', + 'createDictionaryFieldList', + 'editDictionaryFieldlist', + 'getFormMail', 'deleteFile', 'doActions', 'doMassActions', @@ -175,10 +178,9 @@ class HookManager 'formatEvent', 'printObjectLine', 'printObjectSubLine', - 'createDictionaryFieldList', - 'editDictionaryFieldlist', - 'getFormMail', - 'showLinkToObjectBlock' + 'showLinkToObjectBlock', + 'sendMail', + 'sendMailAfter' ) )) $hooktype='addreplace'; diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index e3f283368f1..cbd2eb5c3b3 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -1726,7 +1726,7 @@ class Form * @param int $filtertype Filter on product type (''=nofilter, 0=product, 1=service) * @param int $limit Limit on number of returned lines * @param int $price_level Level of price to show - * @param int $status -1=Return all products, 0=Products not on sell, 1=Products on sell + * @param int $status Sell status -1=Return all products, 0=Products not on sell, 1=Products on sell * @param int $finished 2=all, 1=finished, 0=raw material * @param string $selected_input_value Value of preselected input text (for use with ajax) * @param int $hidelabel Hide label (0=no, 1=yes, 2=show search icon (before) and placeholder, 3 search icon after) @@ -1740,7 +1740,7 @@ class Form * 'warehouseopen' = select products from open warehouses, * 'warehouseclosed' = select products from closed warehouses, * 'warehouseinternal' = select products from warehouses for internal correct/transfer only - * @param array $selected_combinations Selected combinations. Format: array([attrid] => attrval, [...]) + * @param array $selected_combinations Selected combinations. Format: array([attrid] => attrval, [...]) * @return void */ function select_produits($selected='', $htmlname='productid', $filtertype='', $limit=20, $price_level=0, $status=1, $finished=2, $selected_input_value='', $hidelabel=0, $ajaxoptions=array(), $socid=0, $showempty='1', $forcecombo=0, $morecss='', $hidepriceinlabel=0, $warehouseStatus='', $selected_combinations = array()) @@ -2390,7 +2390,7 @@ class Form * Return list of suppliers products * * @param int $socid Id societe fournisseur (0 pour aucun filtre) - * @param int $selected Produit pre-selectionne + * @param int $selected Product price pre-selected (must be 'id' in product_fournisseur_price or 'idprod_IDPROD') * @param string $htmlname Nom de la zone select * @param string $filtertype Filter on product type (''=nofilter, 0=product, 1=service) * @param string $filtre Pour filtre sql @@ -5275,7 +5275,7 @@ class Form $confkeyforautocompletemode=strtoupper($prefixforautocompletemode).'_USE_SEARCH_TO_SELECT'; // For example COMPANY_USE_SEARCH_TO_SELECT $fieldstoshow='t.ref'; - if (! empty($objecttmp->fields)) + if (! empty($objecttmp->fields)) // For object that declare it, it is better to use declared fields ( like societe, contact, ...) { $tmpfieldstoshow=''; foreach($objecttmp->fields as $key => $val) diff --git a/htdocs/core/class/html.formcompany.class.php b/htdocs/core/class/html.formcompany.class.php index c434202ba2e..d3990acc9c8 100644 --- a/htdocs/core/class/html.formcompany.class.php +++ b/htdocs/core/class/html.formcompany.class.php @@ -266,10 +266,10 @@ class FormCompany $out.= '
'; print $commandestatic->getNomUrl(1); @@ -741,11 +774,6 @@ if (! empty($conf->facture->enabled) && ! empty($conf->commande->enabled) && $us print ''; - $societestatic->id=$obj->socid; - $societestatic->name=$obj->name; - $societestatic->client=1; - $societestatic->code_client = $obj->code_client; - $societestatic->code_fournisseur = $obj->code_fournisseur; print $societestatic->getNomUrl(1,'customer',44); print ''.price($obj->total_ht).'
'; print ''; print ''; print ''; print ''; print ''; @@ -912,9 +946,9 @@ if (! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->facture- $sql = "SELECT ff.rowid, ff.ref, ff.fk_statut, ff.libelle, ff.total_ht, ff.total_tva, ff.total_ttc, ff.paye"; $sql.= ", ff.date_lim_reglement"; $sql.= ", s.nom as name"; - $sql.= ", s.rowid as socid"; - $sql.= ", s.code_client"; - $sql.= ", s.code_fournisseur"; + $sql.= ", s.rowid as socid, s.email"; + $sql.= ", s.code_client, s.code_compta"; + $sql.= ", s.code_fournisseur, s.code_compta_fournisseur"; $sql.= ", sum(pf.amount) as am"; $sql.= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."facture_fourn as ff"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."paiementfourn_facturefourn as pf on ff.rowid=pf.fk_facturefourn"; @@ -930,8 +964,8 @@ if (! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->facture- $reshook=$hookmanager->executeHooks('printFieldListWhereSupplierUnpaid',$parameters); $sql.=$hookmanager->resPrint; - $sql.= " GROUP BY ff.rowid, ff.ref, ff.fk_statut, ff.libelle, ff.total_ht, ff.tva, ff.total_tva, ff.total_ttc, ff.paye,"; - $sql.= " s.nom, s.rowid, s.code_client, s.code_fournisseur, ff.date_lim_reglement"; + $sql.= " GROUP BY ff.rowid, ff.ref, ff.fk_statut, ff.libelle, ff.total_ht, ff.tva, ff.total_tva, ff.total_ttc, ff.paye, ff.date_lim_reglement,"; + $sql.= " s.nom, s.rowid, s.email, s.code_client, s.code_fournisseur, s.code_compta, s.code_compta_fournisseur"; $sql.= " ORDER BY ff.date_lim_reglement ASC"; $resql=$db->query($sql); @@ -958,19 +992,25 @@ if (! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->facture- { $obj = $db->fetch_object($resql); - print ''; - $societestatic->id=$obj->socid; - $societestatic->name=$obj->name; - $societestatic->client=0; - $societestatic->code_client = $obj->code_client; - $societestatic->code_fournisseur = $obj->code_fournisseur; print ''; print ''; if (! empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) print ''; diff --git a/htdocs/compta/paiement.php b/htdocs/compta/paiement.php index f2e1352cdbb..11751fe258b 100644 --- a/htdocs/compta/paiement.php +++ b/htdocs/compta/paiement.php @@ -257,7 +257,7 @@ if (empty($reshook)) if (! $error) { - $paiement_id = $paiement->create($user, (GETPOST('closepaidinvoices')=='on'?1:0)); // This include closing invoices + $paiement_id = $paiement->create($user, (GETPOST('closepaidinvoices')=='on'?1:0)); // This include closing invoices and regenerating documents if ($paiement_id < 0) { setEventMessages($paiement->error, $paiement->errors, 'errors'); diff --git a/htdocs/compta/paiement/class/paiement.class.php b/htdocs/compta/paiement/class/paiement.class.php index bbdc6f94dfb..00ae831dc3a 100644 --- a/htdocs/compta/paiement/class/paiement.class.php +++ b/htdocs/compta/paiement/class/paiement.class.php @@ -141,7 +141,7 @@ class Paiement extends CommonObject /** * Create payment of invoices into database. * Use this->amounts to have list of invoices for the payment. - * For payment of a customer invoice, amounts are postive, for payment of credit note, amounts are negative + * For payment of a customer invoice, amounts are positive, for payment of credit note, amounts are negative * * @param User $user Object user * @param int $closepaidinvoices 1=Also close payed invoices to paid, 0=Do nothing more @@ -233,11 +233,12 @@ class Paiement extends CommonObject $resql=$this->db->query($sql); if ($resql) { + $invoice=new Facture($this->db); + $invoice->fetch($facid); + // If we want to closed payed invoices if ($closepaidinvoices) { - $invoice=new Facture($this->db); - $invoice->fetch($facid); $paiement = $invoice->getSommePaiement(); $creditnotes=$invoice->getSumCreditNotesUsed(); $deposits=$invoice->getSumDepositsUsed(); @@ -338,26 +339,25 @@ class Paiement extends CommonObject $error++; } } - } - - if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) - { - $outputlangs = $langs; - if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $invoice->thirdparty->default_lang; - if (! empty($newlang)) { - $outputlangs = new Translate("", $conf); - $outputlangs->setDefaultLang($newlang); - } - $ret = $invoice->fetch($id); // Reload to get new records - - $result = $invoice->generateDocument($invoice->modelpdf, $outputlangs); - if ($result < 0) { - setEventMessages($invoice->error, $invoice->errors, 'errors'); - $error++; - } - } } + + // Regenerate documents of invoices + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) + { + $outputlangs = $langs; + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $invoice->thirdparty->default_lang; + if (! empty($newlang)) { + $outputlangs = new Translate("", $conf); + $outputlangs->setDefaultLang($newlang); + } + $ret = $invoice->fetch($facid); // Reload to get new records + $result = $invoice->generateDocument($invoice->modelpdf, $outputlangs); + if ($result < 0) { + setEventMessages($invoice->error, $invoice->errors, 'errors'); + $error++; + } + } } else { diff --git a/htdocs/compta/tva/class/tva.class.php b/htdocs/compta/tva/class/tva.class.php index eab716a7957..b951c05f574 100644 --- a/htdocs/compta/tva/class/tva.class.php +++ b/htdocs/compta/tva/class/tva.class.php @@ -2,6 +2,7 @@ /* Copyright (C) 2002-2003 Rodolphe Quiedeville * Copyright (C) 2004-2008 Laurent Destailleur * Copyright (C) 2011-2017 Alexandre Spangaro + * Copyright (C) 2018 Philippe Grand * * 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 @@ -651,25 +652,76 @@ class Tva extends CommonObject * * @param int $withpicto 0=No picto, 1=Include picto into link, 2=Only picto * @param string $option link option + * @param int $notooltip 1=Disable tooltip * @return string Chaine with URL */ - function getNomUrl($withpicto=0,$option='') + function getNomUrl($withpicto=0, $option='', $notooltip=0) { global $langs; $result=''; $label=$langs->trans("ShowVatPayment").': '.$this->ref; - $link = ''; - $linkend=''; + $url = DOL_URL_ROOT.'/compta/tva/card.php?id='.$this->id; + + $linkclose=''; + if (empty($notooltip)) + { + if (! empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) + { + $label=$langs->trans("ShowMyObject"); + $linkclose.=' alt="'.dol_escape_htmltag($label, 1).'"'; + } + $linkclose.=' title="'.dol_escape_htmltag($label, 1).'"'; + $linkclose.=' class="classfortooltip'.($morecss?' '.$morecss:'').'"'; + } + else $linkclose = ($morecss?' class="'.$morecss.'"':''); + + $linkstart = ''; + $linkend =''; $picto='payment'; - if ($withpicto) $result.=($link.img_object($label, $picto, 'class="classfortooltip"').$linkend); - if ($withpicto && $withpicto != 2) $result.=' '; - if ($withpicto != 2) $result.=$link.$this->ref.$linkend; + $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; + $result .= $linkend; + return $result; } + + /** + * Return amount of payments already done + * + * @return int Amount of payment already done, <0 if KO + */ + function getSommePaiement() + { + $table='paiementcharge'; + $field='fk_charge'; + + $sql = 'SELECT sum(amount) as amount'; + $sql.= ' FROM '.MAIN_DB_PREFIX.$table; + $sql.= ' WHERE '.$field.' = '.$this->id; + + dol_syslog(get_class($this)."::getSommePaiement", LOG_DEBUG); + $resql=$this->db->query($sql); + if ($resql) + { + $amount=0; + + $obj = $this->db->fetch_object($resql); + if ($obj) $amount=$obj->amount?$obj->amount:0; + + $this->db->free($resql); + return $amount; + } + else + { + return -1; + } + } /** * Informations of vat payment object diff --git a/htdocs/compta/tva/document.php b/htdocs/compta/tva/document.php new file mode 100644 index 00000000000..2fb7ba272c8 --- /dev/null +++ b/htdocs/compta/tva/document.php @@ -0,0 +1,177 @@ + + * Copyright (C) 2004-2014 Laurent Destailleur + * Copyright (C) 2005 Marc Barilley / Ocebo + * Copyright (C) 2005-2009 Regis Houssin + * Copyright (C) 2005 Simon TOSSER + * Copyright (C) 2011 Juanjo Menent + * Copyright (C) 2013 Cédric Salvador + * Copyright (C) 2018 Philippe Grand + * + * 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 + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file htdocs/compta/tva/document.php + * \ingroup tax + * \brief Page with attached files on social contributions + */ + +require '../../main.inc.php'; +require_once DOL_DOCUMENT_ROOT.'/compta/tva/class/tva.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/vat.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; +if (! empty($conf->projet->enabled)) +{ + require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; + require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php'; +} + +$langs->load("other"); +$langs->load("companies"); +$langs->load("compta"); +$langs->load("bills"); + +$id = GETPOST('id','int'); +$action = GETPOST('action','aZ09'); +$confirm = GETPOST('confirm', 'alpha'); + +// Security check +if ($user->societe_id) $socid=$user->societe_id; +$result = restrictedArea($user, 'tax', $id, 'vat','charges'); + + +// Get parameters +$sortfield = GETPOST("sortfield",'alpha'); +$sortorder = GETPOST("sortorder",'alpha'); +$page = GETPOST("page",'int'); +if ($page == -1) { + $page = 0; +} +$offset = $conf->liste_limit * $page; +$pageprev = $page - 1; +$pagenext = $page + 1; +if (! $sortorder) $sortorder="ASC"; +if (! $sortfield) $sortfield="name"; + + +$object = new Tva($db); +if ($id > 0) $object->fetch($id); + +$upload_dir = $conf->tax->dir_output.'/'.dol_sanitizeFileName($object->ref); +$modulepart='tax'; + + +/* + * Actions + */ + +include_once DOL_DOCUMENT_ROOT . '/core/actions_linkedfiles.inc.php'; + +if ($action == 'setlib' && $user->rights->tax->charges->creer) +{ + $object->fetch($id); + $result = $object->setValueFrom('libelle', GETPOST('lib'), '', '', 'text', '', $user, 'TAX_MODIFY'); + if ($result < 0) + setEventMessages($object->error, $object->errors, 'errors'); +} + + +/* + * View + */ + +$form = new Form($db); +if (! empty($conf->projet->enabled)) { $formproject = new FormProjets($db); } + +$title = $langs->trans("VATPayment") . ' - ' . $langs->trans("Documents"); +$help_url='EN:Module_Taxes_and_social_contributions|FR:Module Taxes et dividendes|ES:Módulo Impuestos y cargas sociales (IVA, impuestos)'; +llxHeader("",$title,$help_url); + +if ($object->id) +{ + $alreadypayed=$object->getSommePaiement(); + + $head=vat_prepare_head($object); + + dol_fiche_head($head, 'documents', $langs->trans("VATPayment"), -1, 'bill'); + + $morehtmlref='
'; + // Label of social contribution + $morehtmlref.=$form->editfieldkey("Label", 'lib', $object->lib, $object, $user->rights->tax->charges->creer, 'string', '', 0, 1); + $morehtmlref.=$form->editfieldval("Label", 'lib', $object->lib, $object, $user->rights->tax->charges->creer, 'string', '', null, null, '', 1); + // Project + if (! empty($conf->projet->enabled)) + { + $langs->load("projects"); + $morehtmlref.='
'.$langs->trans('Project') . ' : '; + if (! empty($object->fk_project)) { + $proj = new Project($db); + $proj->fetch($object->fk_project); + $morehtmlref.=''; + $morehtmlref.=$proj->ref; + $morehtmlref.=''; + } else { + $morehtmlref.=''; + } + } + $morehtmlref.='
'; + + $linkback = '' . $langs->trans("BackToList") . ''; + + $object->totalpaye = $totalpaye; // To give a chance to dol_banner_tab to use already paid amount to show correct status + + dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', $morehtmlref, '', 0, '', $morehtmlright); + + print '
'; + print '
'; + + // Construit liste des fichiers + $filearray=dol_dir_list($upload_dir,"files",0,'','(\.meta|_preview.*\.png)$',$sortfield,(strtolower($sortorder)=='desc'?SORT_DESC:SORT_ASC),1); + $totalsize=0; + foreach($filearray as $key => $file) + { + $totalsize+=$file['size']; + } + + + print '
'; - $facturestatic->ref=$obj->facnumber; - $facturestatic->id=$obj->rowid; - $facturestatic->total_ht=$obj->total_ht; - $facturestatic->total_tva=$obj->total_tva; - $facturestatic->total_ttc=$obj->total_ttc; - $facturestatic->type=$obj->type; - $facturestatic->statut = $obj->fk_statut; - $facturestatic->date_lim_reglement = $db->jdate($obj->datelimite); print $facturestatic->getNomUrl(1,''); print ''; @@ -858,11 +897,6 @@ if (! empty($conf->facture->enabled) && $user->rights->facture->lire) print '' ; - $societestatic->id=$obj->socid; - $societestatic->name=$obj->name; - $societestatic->client=1; - $societestatic->code_client = $obj->code_client; - $societestatic->code_fournisseur = $obj->code_fournisseur; print $societestatic->getNomUrl(1,'customer',44); print ''.dol_print_date($db->jdate($obj->datelimite),'day').'
'; $facstatic->ref=$obj->ref; $facstatic->id = $obj->rowid; - $facstatic->total_ht = $obj->total_ht; - $facstatic->total_tva = $obj->total_tva; - $facstatic->total_ttc = $obj->total_ttc; + $facstatic->total_ht = $obj->total_ht; + $facstatic->total_tva = $obj->total_tva; + $facstatic->total_ttc = $obj->total_ttc; + + $societestatic->id=$obj->socid; + $societestatic->name=$obj->name; + $societestatic->email=$obj->email; + $societestatic->client=0; + $societestatic->fournisseur=1; + $societestatic->code_client = $obj->code_client; + $societestatic->code_fournisseur = $obj->code_fournisseur; + $societestatic->code_compta = $obj->code_compta; + $societestatic->code_compta_fournisseur = $obj->code_compta_fournisseur; + + print '
'; print $facstatic->getNomUrl(1,''); print ''.$societestatic->getNomUrl(1, 'supplier', 44).''.dol_print_date($db->jdate($obj->date_lim_reglement),'day').''.price($obj->total_ht).'
'; + + print ''; + print ''; + print '
'.$langs->trans("NbOfAttachedFiles").''.count($filearray).'
'.$langs->trans("TotalSizeOfAttachedFiles").''.$totalsize.' '.$langs->trans("bytes").'
'; + + print ''; + + print '
'; + + dol_fiche_end(); + + $modulepart = 'tax'; + $permission = $user->rights->tax->charges->creer; + $permtoedit = $user->rights->fournisseur->facture->creer; + $param = '&id=' . $object->id; + include_once DOL_DOCUMENT_ROOT . '/core/tpl/document_actions_post_headers.tpl.php'; +} +else +{ + print $langs->trans("ErrorUnknown"); +} + + +llxFooter(); + +$db->close(); diff --git a/htdocs/compta/tva/reglement.php b/htdocs/compta/tva/reglement.php index c411013250f..1a0b0699128 100644 --- a/htdocs/compta/tva/reglement.php +++ b/htdocs/compta/tva/reglement.php @@ -217,8 +217,11 @@ if ($result) $tva_static->id=$obj->rowid; $tva_static->ref=$obj->rowid; + + // Ref print "
".$tva_static->getNomUrl(1)."".dol_trunc($obj->label,40)."".dol_trunc($obj->label,40)."'.dol_print_date($db->jdate($obj->dv),'day')."'.dol_print_date($db->jdate($obj->dp),'day')."
'; + if(!empty($conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT) && ($conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT == 1 || $conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT == 2)) + { + print '
'; + } + else + { + print '
'; + } + if ($object->country_id) { print $formcompany->select_state(GETPOST("state_id",'alpha')?GETPOST("state_id",'alpha'):$object->state_id,$object->country_code,'state_id'); @@ -852,7 +860,15 @@ else // State if (empty($conf->global->SOCIETE_DISABLE_STATE)) { - print '
'; + if(!empty($conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT) && ($conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT == 1 || $conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT == 2)) + { + print '
'; + } + else + { + print '
'; + } + print $formcompany->select_state($object->state_id,isset($_POST["country_id"])?GETPOST("country_id"):$object->country_id,'state_id'); print '
'."\n"; + print '
'; // You can use div-table-responsive-no-min if you dont need reserved height for your table + print "\n".'
'."\n"; $param="socid=".$object->id; if ($search_status != '') $param.='&search_status='.$search_status; if ($search_name != '') $param.='&search_name='.urlencode($search_name); - $sql = "SELECT p.rowid, p.lastname, p.firstname, p.fk_pays as country_id, p.civility, p.poste, p.phone as phone_pro, p.phone_mobile, p.phone_perso, p.fax, p.email, p.skype, p.statut, p.photo,"; - $sql .= " p.civility as civility_id, p.address, p.zip, p.town"; - $sql .= " FROM ".MAIN_DB_PREFIX."socpeople as p"; - $sql .= " WHERE p.fk_soc = ".$object->id; - if ($search_status!='' && $search_status != '-1') $sql .= " AND p.statut = ".$db->escape($search_status); - if ($search_name) $sql .= " AND (p.lastname LIKE '%".$db->escape($search_name)."%' OR p.firstname LIKE '%".$db->escape($search_name)."%')"; - $sql.= " ORDER BY $sortfield $sortorder"; + $sql = "SELECT t.rowid, t.lastname, t.firstname, t.fk_pays as country_id, t.civility, t.poste, t.phone as phone_pro, t.phone_mobile, t.phone_perso, t.fax, t.email, t.skype, t.statut, t.photo,"; + $sql .= " t.civility as civility_id, t.address, t.zip, t.town"; + $sql .= " FROM ".MAIN_DB_PREFIX."socpeople as t"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."socpeople_extrafields as ef on (t.rowid = ef.fk_object)"; + $sql .= " WHERE t.fk_soc = ".$object->id; + if ($search_status!='' && $search_status != '-1') $sql .= " AND t.statut = ".$db->escape($search_status); + if ($search_name) $sql .= " AND (t.lastname LIKE '%".$db->escape($search_name)."%' OR t.firstname LIKE '%".$db->escape($search_name)."%')"; + if ($sortfield == "t.name") $sql.=" ORDER BY t.lastname $sortorder, t.firstname $sortorder"; + else $sql.= " ORDER BY $sortfield $sortorder"; dol_syslog('core/lib/company.lib.php :: show_contacts', LOG_DEBUG); $result = $db->query($sql); @@ -842,59 +890,63 @@ function show_contacts($conf,$langs,$db,$object,$backtopage='') $num = $db->num_rows($result); - $colspan=9; - - print ''; - - // Photo - Name - print ''; - - // Position - print ''; - - // Address - Phone - Email - print ''; - - // Status - print ''; - - // Add to agenda - if (! empty($conf->agenda->enabled) && $user->rights->agenda->myactions->create) - { - $colspan++; - print ''; - } - - // Action - print ''; - - print ""; - - $titlefieldaddress=$langs->trans("Address").' / '.$langs->trans("Phone").' / '.$langs->trans("Email"); - if (! empty($conf->dol_optimize_smallscreen)) $titlefieldaddress=$langs->trans("Address"); - + // Fields title search + // -------------------------------------------------------------------- print ''; - print_liste_field_titre("Name",$_SERVER["PHP_SELF"],"p.lastname","",$param,'',$sortfield,$sortorder); - print_liste_field_titre("Poste",$_SERVER["PHP_SELF"],"p.poste","",$param,'',$sortfield,$sortorder); - print_liste_field_titre($titlefieldaddress,$_SERVER["PHP_SELF"],"","",$param,'',$sortfield,$sortorder); - print_liste_field_titre("Status",$_SERVER["PHP_SELF"],"p.statut","",$param,'align="center"',$sortfield,$sortorder); - // Add to agenda - if (! empty($conf->agenda->enabled) && ! empty($user->rights->agenda->myactions->create)) print_liste_field_titre(''); - // Edit - print_liste_field_titre(''); - print "\n"; + foreach($contactstatic->fields as $key => $val) + { + $align=''; + if (in_array($val['type'], array('date','datetime','timestamp'))) $align.=($align?' ':'').'center'; + if (in_array($val['type'], array('timestamp'))) $align.=($align?' ':'').'nowrap'; + if ($key == 'status' || $key == 'statut') $align.=($align?' ':'').'center'; + if (! empty($arrayfields['t.'.$key]['checked'])) + { + print ''; + } + } + // Extra fields + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php'; + + // Fields from hook + $parameters=array('arrayfields'=>$arrayfields); + $reshook=$hookmanager->executeHooks('printFieldListOption', $parameters, $contactstatic); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; + // Action column + print ''; + print ''."\n"; + + + // Fields title label + // -------------------------------------------------------------------- + print ''; + foreach($contactstatic->fields as $key => $val) + { + $align=''; + if (in_array($val['type'], array('date','datetime','timestamp'))) $align.=($align?' ':'').'center'; + if (in_array($val['type'], array('timestamp'))) $align.=($align?' ':'').'nowrap'; + if ($key == 'status' || $key == 'statut') $align.=($align?' ':'').'center'; + if (! empty($arrayfields['t.'.$key]['checked'])) print getTitleFieldOfList($arrayfields['t.'.$key]['label'], 0, $_SERVER['PHP_SELF'], 't.'.$key, '', $param, ($align?'class="'.$align.'"':''), $sortfield, $sortorder, $align.' ')."\n"; + } + // Extra fields + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; + // Hook fields + $parameters=array('arrayfields'=>$arrayfields); + $reshook=$hookmanager->executeHooks('printFieldListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; + print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"],'','','','align="center"',$sortfield,$sortorder,'maxwidthsearch ')."\n"; + print ''."\n"; + + $i = -1; if ($num || (GETPOST('button_search') || GETPOST('button_search.x') || GETPOST('button_search_x'))) { - $i=0; + $i = 0; while ($i < $num) { @@ -923,46 +975,81 @@ function show_contacts($conf,$langs,$db,$object,$backtopage='') $contactstatic->country_code = $country_code; $contactstatic->setGenderFromCivility(); + $contactstatic->fetch_optionals(); + + if (is_array($contactstatic->array_options)) + { + foreach($contactstatic->array_options as $key => $val) + { + $obj->$key = $val; + } + } print ''; + // ID + if (! empty($arrayfields['t.rowid']['checked'])) + { + print ''; + } + // Photo - Name - print ''; + if (! empty($arrayfields['t.name']['checked'])) + { + print ''; + } // Job position - print ''; + if (! empty($arrayfields['t.poste']['checked'])) + { + print ''; + } // Address - Phone - Email - print ''; + if (! empty($arrayfields['t.address']['checked'])) + { + print ''; + } // Status - print ''; + if (! empty($arrayfields['t.statut']['checked'])) + { + print ''; + } - // Add to agenda + // Extra fields + $extrafieldsobjectkey='socpeople'; + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; + + // Actions + print ''; + print '   '; } // Edit if ($user->rights->societe->contact->creer) { - print ''; + print ''; } - else print ''; + + print ''; print "\n"; $i++; @@ -970,9 +1057,9 @@ function show_contacts($conf,$langs,$db,$object,$backtopage='') } else { - print ''; - print ''; - print "\n"; + $colspan=1; + foreach($arrayfields as $key => $val) { if (! empty($val['checked'])) $colspan++; } + print ''; } print "\n
'; - print ''; - print ''; - print ''; - print $form->selectarray('search_status', array('-1'=>'','0'=>$contactstatic->LibStatut(0,1),'1'=>$contactstatic->LibStatut(1,1)),$search_status); - print ''; - $searchpicto=$form->showFilterButtons(); - print $searchpicto; - print '
'; + if (in_array($key, array('lastname','name'))) print ''; + elseif (in_array($key, array('statut'))) print $form->selectarray('search_status', array('-1'=>'','0'=>$contactstatic->LibStatut(0,1),'1'=>$contactstatic->LibStatut(1,1)),$search_status); + print ''; + $searchpicto=$form->showFilterButtons(); + print $searchpicto; + print '
'; + print $contactstatic->id; + print ''; - print $form->showphoto('contact',$contactstatic,0,0,0,'photorefnoborder valignmiddle marginrightonly','small',1,0,1); - print $contactstatic->getNomUrl(0,'',0,'&backtopage='.urlencode($backtopage)); - print ''; + print $form->showphoto('contact',$contactstatic,0,0,0,'photorefnoborder valignmiddle marginrightonly','small',1,0,1); + print $contactstatic->getNomUrl(0,'',0,'&backtopage='.urlencode($backtopage)); + print ''; - if ($obj->poste) print $obj->poste; - print ''; + if ($obj->poste) print $obj->poste; + print ''; - print $contactstatic->getBannerAddress('contact', $object); - print ''; + print $contactstatic->getBannerAddress('contact', $object); + print ''.$contactstatic->getLibStatut(5).''.$contactstatic->getLibStatut(5).''; + + // Add to agenda if (! empty($conf->agenda->enabled) && $user->rights->agenda->myactions->create) { - print ''; print ''; print img_object($langs->trans("Event"),"action"); - print ''; print ''; print img_edit(); - print ' 
'.$langs->trans("None").'
'.$langs->trans("None").'
\n"; print ''; @@ -995,7 +1082,6 @@ function show_contacts($conf,$langs,$db,$object,$backtopage='') function show_addresses($conf,$langs,$db,$object,$backtopage='') { global $user; - global $bc; require_once DOL_DOCUMENT_ROOT.'/societe/class/address.class.php'; @@ -1087,7 +1173,7 @@ function show_addresses($conf,$langs,$db,$object,$backtopage='') */ function show_actions_todo($conf,$langs,$db,$filterobj,$objcon='',$noprint=0,$actioncode='') { - global $bc,$user,$conf; + global $user,$conf; $out = show_actions_done($conf,$langs,$db,$filterobj,$objcon,1,$actioncode, 'todo'); @@ -1114,7 +1200,7 @@ function show_actions_todo($conf,$langs,$db,$filterobj,$objcon='',$noprint=0,$ac */ function show_actions_done($conf, $langs, $db, $filterobj, $objcon='', $noprint=0, $actioncode='', $donetodo='done', $filters=array(), $sortfield='a.datep,a.id', $sortorder='DESC') { - global $bc,$user,$conf; + global $user,$conf; global $form; global $param; @@ -1142,14 +1228,14 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon='', $noprint= if (is_object($filterobj) && get_class($filterobj) == 'Adherent') $sql.= ", m.lastname, m.firstname"; if (is_object($filterobj) && get_class($filterobj) == 'CommandeFournisseur') $sql.= ", o.ref"; if (is_object($filterobj) && get_class($filterobj) == 'Product') $sql.= ", o.ref"; - $sql.= " FROM ".MAIN_DB_PREFIX."user as u, ".MAIN_DB_PREFIX."actioncomm as a"; + $sql.= " FROM ".MAIN_DB_PREFIX."actioncomm as a"; + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."user as u on u.rowid = a.fk_user_action"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_actioncomm as c ON a.fk_action = c.id"; if (is_object($filterobj) && get_class($filterobj) == 'Societe') $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."socpeople as sp ON a.fk_contact = sp.rowid"; if (is_object($filterobj) && get_class($filterobj) == 'Adherent') $sql.= ", ".MAIN_DB_PREFIX."adherent as m"; if (is_object($filterobj) && get_class($filterobj) == 'CommandeFournisseur') $sql.= ", ".MAIN_DB_PREFIX."commande_fournisseur as o"; if (is_object($filterobj) && get_class($filterobj) == 'Product') $sql.= ", ".MAIN_DB_PREFIX."product as o"; - $sql.= " WHERE u.rowid = a.fk_user_action"; - $sql.= " AND a.entity IN (".getEntity('agenda').")"; + $sql.= " WHERE a.entity IN (".getEntity('agenda').")"; if (is_object($filterobj) && get_class($filterobj) == 'Societe' && $filterobj->id) $sql.= " AND a.fk_soc = ".$filterobj->id; if (is_object($filterobj) && get_class($filterobj) == 'Project' && $filterobj->id) $sql.= " AND a.fk_project = ".$filterobj->id; if (is_object($filterobj) && get_class($filterobj) == 'Adherent') @@ -1192,7 +1278,6 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon='', $noprint= if ($donetodo == 'done') $sql.= " AND (a.percent = 100 OR (a.percent = -1 AND a.datep <= '".$db->idate($now)."'))"; if (is_array($filters) && $filters['search_agenda_label']) $sql.= natural_search('a.label', $filters['search_agenda_label']); $sql.= $db->order($sortfield, $sortorder); - dol_syslog("company.lib::show_actions_done", LOG_DEBUG); $resql=$db->query($sql); if ($resql) @@ -1298,7 +1383,6 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon='', $noprint= } } - if (! empty($conf->agenda->enabled) || (! empty($conf->mailing->enabled) && ! empty($objcon->email))) { $delay_warning=$conf->global->MAIN_DELAY_ACTIONS_TODO*24*60*60; @@ -1385,7 +1469,6 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon='', $noprint= foreach ($histo as $key=>$value) { - $actionstatic->fetch($histo[$key]['id']); // TODO Do we need this, we already have a lot of data of line into $histo $out.='
+ element == 'contrat') + + $freelines = false; + if (empty($conf->global->MAIN_DISABLE_FREE_LINES)) { - if (empty($conf->product->enabled) && empty($conf->service->enabled) && empty($conf->global->CONTRACT_SUPPORT_PRODUCTS)) $forceall=-1; // With contract, by default, no choice at all, except if CONTRACT_SUPPORT_PRODUCTS is set - else $forceall=0; - } - - // Free line - echo ''; - // Show radio free line - if ($forceall >= 0 && (! empty($conf->product->enabled) || ! empty($conf->service->enabled))) - { - echo ''; - echo ' '; - } - else - { - echo ''; - // Show type selector - if ($forceall >= 0) + $freelines = true; + $forceall=1; // We always force all type for free lines (module product or service means we use predefined product or service) + if ($object->element == 'contrat') { - if (empty($conf->product->enabled) || empty($conf->service->enabled)) echo $langs->trans("Type"); - else echo $langs->trans("FreeLineOfType"); + if (empty($conf->product->enabled) && empty($conf->service->enabled) && empty($conf->global->CONTRACT_SUPPORT_PRODUCTS)) $forceall=-1; // With contract, by default, no choice at all, except if CONTRACT_SUPPORT_PRODUCTS is set + else $forceall=0; + } + + // Free line + echo ''; + // Show radio free line + if ($forceall >= 0 && (! empty($conf->product->enabled) || ! empty($conf->service->enabled))) + { + echo ''; echo ' '; } + else + { + echo ''; + // Show type selector + if ($forceall >= 0) + { + if (empty($conf->product->enabled) || empty($conf->service->enabled)) echo $langs->trans("Type"); + else echo $langs->trans("FreeLineOfType"); + echo ' '; + } + } + + echo $form->select_type_of_lines(isset($_POST["type"])?GETPOST("type",'alpha',2):-1,'type',1,1,$forceall); + + echo ''; } - echo $form->select_type_of_lines(isset($_POST["type"])?GETPOST("type",'alpha',2):-1,'type',1,1,$forceall); - - echo ''; - // Predefined product/service if (! empty($conf->product->enabled) || ! empty($conf->service->enabled)) { - if ($forceall >= 0) echo '
'; + if ($forceall >= 0 && $freelines) echo '
'; echo ''; echo '
+ $("#prod_entry_mode_predef").click(); + /* When changing predefined product, we reload list of supplier prices required for margin combo */ $("#idprod, #idprodfournprice").change(function() diff --git a/htdocs/core/triggers/interface_50_modBlockedlog_ActionsBlockedLog.class.php b/htdocs/core/triggers/interface_50_modBlockedlog_ActionsBlockedLog.class.php index 25dc957df02..ec0b0cb6941 100644 --- a/htdocs/core/triggers/interface_50_modBlockedlog_ActionsBlockedLog.class.php +++ b/htdocs/core/triggers/interface_50_modBlockedlog_ActionsBlockedLog.class.php @@ -51,7 +51,7 @@ class InterfaceActionsBlockedLog extends DolibarrTriggers if (empty($conf->blockedlog->enabled)) return 0; // Module not active, we do nothing // Test if event/record is qualified - $listofqualifiedelement = array('facture', 'don', 'payment', 'payment_donation', 'subscription'); + $listofqualifiedelement = array('facture', 'don', 'payment', 'payment_donation', 'subscription','payment_various'); if (! in_array($object->element, $listofqualifiedelement)) return 1; dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); @@ -120,9 +120,10 @@ class InterfaceActionsBlockedLog extends DolibarrTriggers $res = $b->create($user); - if ($res<0) + if ($res < 0) { - setEventMessages($b->error, $b->errors, 'errors'); + $this->error = $b->error; + $this->errors = $b->errors; return -1; } else diff --git a/htdocs/exports/class/export.class.php b/htdocs/exports/class/export.class.php index b1b9b42adc5..8a662c83dcf 100644 --- a/htdocs/exports/class/export.class.php +++ b/htdocs/exports/class/export.class.php @@ -697,11 +697,13 @@ class Export $sql.= 'label,'; $sql.= 'type,'; $sql.= 'field,'; + $sql.= 'fk_user,'; $sql.= 'filter'; $sql.= ') VALUES ('; $sql.= "'".$this->db->escape($this->model_name)."',"; $sql.= "'".$this->db->escape($this->datatoexport)."',"; $sql.= "'".$this->db->escape($this->hexa)."',"; + $sql.= "'".$user->id."',"; $sql.= "'".$this->db->escape($this->hexafiltervalue)."'"; $sql.= ")"; diff --git a/htdocs/exports/export.php b/htdocs/exports/export.php index a21dcdce7a6..92a63afcd0e 100644 --- a/htdocs/exports/export.php +++ b/htdocs/exports/export.php @@ -551,7 +551,8 @@ if ($step == 2 && $datatoexport) print ''; print '
'; print $langs->trans("SelectExportFields").' '; - $htmlother->select_export_model($exportmodelid,'exportmodelid',$datatoexport,1); + if(empty($conf->global->EXPORTS_SHARE_MODELS))$htmlother->select_export_model($exportmodelid,'exportmodelid',$datatoexport,1,$user->id); + else $htmlother->select_export_model($exportmodelid,'exportmodelid',$datatoexport,1); print ' '; print ''; print '
'; @@ -1082,6 +1083,7 @@ if ($step == 4 && $datatoexport) $sql = "SELECT rowid, label"; $sql.= " FROM ".MAIN_DB_PREFIX."export_model"; $sql.= " WHERE type = '".$datatoexport."'"; + if(empty($conf->global->EXPORTS_SHARE_MODELS))$sql.=" AND fk_user=".$user->id; $sql.= " ORDER BY rowid"; $resql = $db->query($sql); if ($resql) diff --git a/htdocs/fichinter/class/api_interventions.class.php b/htdocs/fichinter/class/api_interventions.class.php new file mode 100644 index 00000000000..23073737d7e --- /dev/null +++ b/htdocs/fichinter/class/api_interventions.class.php @@ -0,0 +1,424 @@ + + * Copyright (C) 2016 Laurent Destailleur + * + * 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 + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + + use Luracast\Restler\RestException; + + require_once DOL_DOCUMENT_ROOT.'/fichinter/class/fichinter.class.php'; + +/** + * API class for fichinters + * + * @access protected + * @class DolibarrApiAccess {@requires user,external} + */ +class Interventions extends DolibarrApi +{ + + /** + * @var array $FIELDS Mandatory fields, checked when create and update object + */ + static $FIELDS = array( + 'socid', + 'fk_project', + 'description' + ); + + /** + * @var array $FIELDS Mandatory fields, checked when create and update object + */ + static $FIELDSLINE = array( + 'description', + 'date', + 'duree' + ); + + /** + * @var fichinter $fichinter {@type fichinter} + */ + public $fichinter; + + /** + * Constructor + */ + function __construct() + { + global $db, $conf; + $this->db = $db; + $this->fichinter = new Fichinter($this->db); + } + + /** + * Get properties of a Expense Report object + * + * Return an array with Expense Report informations + * + * @param int $id ID of Expense Report + * @return array|mixed Data without useless information + * + * @throws RestException + */ + function get($id) + { + if(! DolibarrApiAccess::$user->rights->ficheinter->lire) { + throw new RestException(401); + } + + $result = $this->fichinter->fetch($id); + if( ! $result ) { + throw new RestException(404, 'Intervention report not found'); + } + + if( ! DolibarrApi::_checkAccessToResource('fichinter',$this->fichinter->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } + + $this->fichinter->fetchObjectLinked(); + return $this->_cleanObjectDatas($this->fichinter); + } + + /** + * List of interventions + * + * Return a list of interventions + * + * @param string $sortfield Sort field + * @param string $sortorder Sort order + * @param int $limit Limit for list + * @param int $page Page number + * @param string $thirdparty_ids Thirdparty ids to filter orders of. {@example '1' or '1,2,3'} {@pattern /^[0-9,]*$/i} + * @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.ref:like:'SO-%') and (t.date_creation:<:'20160101')" + * @return array Array of order objects + * + * @throws RestException + */ + function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $thirdparty_ids = '', $sqlfilters = '') { + global $db, $conf; + + $obj_ret = array(); + + // case of external user, $thirdparty_ids param is ignored and replaced by user's socid + $socids = DolibarrApiAccess::$user->societe_id ? DolibarrApiAccess::$user->societe_id : $thirdparty_ids; + + // If the internal user must only see his customers, force searching by him + $search_sale = 0; + if (! DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) $search_sale = DolibarrApiAccess::$user->id; + + $sql = "SELECT t.rowid"; + if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) $sql .= ", sc.fk_soc, sc.fk_user"; // We need these fields in order to filter by sale (including the case where the user can only see his prospects) + $sql.= " FROM ".MAIN_DB_PREFIX."fichinter as t"; + + if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; // We need this table joined to the select in order to filter by sale + + $sql.= ' WHERE t.entity IN ('.getEntity('fichinter').')'; + if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) $sql.= " AND t.fk_soc = sc.fk_soc"; + if ($socids) $sql.= " AND t.fk_soc IN (".$socids.")"; + if ($search_sale > 0) $sql.= " AND t.rowid = sc.fk_soc"; // Join for the needed table to filter by sale + // Insert sale filter + if ($search_sale > 0) + { + $sql .= " AND sc.fk_user = ".$search_sale; + } + // Add sql filters + if ($sqlfilters) + { + if (! DolibarrApi::_checkFilters($sqlfilters)) + { + throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); + } + $regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; + $sql.=" AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; + } + + $sql.= $db->order($sortfield, $sortorder); + if ($limit) { + if ($page < 0) + { + $page = 0; + } + $offset = $limit * $page; + + $sql.= $db->plimit($limit + 1, $offset); + } + + dol_syslog("API Rest request"); + $result = $db->query($sql); + + if ($result) + { + $num = $db->num_rows($result); + $min = min($num, ($limit <= 0 ? $num : $limit)); + while ($i < $min) + { + $obj = $db->fetch_object($result); + $fichinter_static = new Fichinter($db); + if($fichinter_static->fetch($obj->rowid)) { + $obj_ret[] = $this->_cleanObjectDatas($fichinter_static); + } + $i++; + } + } + else { + throw new RestException(503, 'Error when retrieve fichinter list : '.$db->lasterror()); + } + if( ! count($obj_ret)) { + throw new RestException(404, 'No finchinter found'); + } + return $obj_ret; + } + + /** + * Create intervention object + * + * @param array $request_data Request data + * @return int ID of intervention + */ + function post($request_data = NULL) + { + if(! DolibarrApiAccess::$user->rights->ficheinter->creer) { + throw new RestException(401, "Insuffisant rights"); + } + // Check mandatory fields + $result = $this->_validate($request_data); + foreach($request_data as $field => $value) { + $this->fichinter->$field = $value; + } + + if ($this->fichinter->create(DolibarrApiAccess::$user) < 0) { + throw new RestException(500, "Error creating fichinter", array_merge(array($this->fichinter->error), $this->fichinter->errors)); + } + + return $this->fichinter->id; + } + + + /** + * Get lines of an intervention + * + * @param int $id Id of intervention + * + * @url GET {id}/lines + * + * @return int + */ + /* TODO + function getLines($id) { + if(! DolibarrApiAccess::$user->rights->ficheinter->lire) { + throw new RestException(401); + } + + $result = $this->fichinter->fetch($id); + if( ! $result ) { + throw new RestException(404, 'Intervention not found'); + } + + if( ! DolibarrApi::_checkAccessToResource('fichinter',$this->fichinter->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } + $this->fichinter->getLinesArray(); + $result = array(); + foreach ($this->fichinter->lines as $line) { + array_push($result,$this->_cleanObjectDatas($line)); + } + return $result; + } + */ + + /** + * Add a line to given intervention + * + * @param int $id Id of intervention to update + * @param array $request_data Request data + * + * @url POST {id}/lines + * + * @return int + */ + function postLine($id, $request_data = NULL) + { + if(! DolibarrApiAccess::$user->rights->ficheinter->creer) { + throw new RestException(401, "Insuffisant rights"); + } + // Check mandatory fields + $result = $this->_validateLine($request_data); + + foreach($request_data as $field => $value) { + $this->fichinter->$field = $value; + } + + if( ! $result ) { + throw new RestException(404, 'Intervention not found'); + } + + if( ! DolibarrApi::_checkAccessToResource('fichinter',$this->fichinter->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } + + $updateRes = $this->fichinter->addLine( + DolibarrApiAccess::$user, + $id, + $this->fichinter->description, + $this->fichinter->date, + $this->fichinter->duree + ); + + if ($updateRes > 0) { + return $updateRes; + } + else { + throw new RestException(400, $this->fichinter->error); + } + } + + /** + * Validate an intervention + * + * If you get a bad value for param notrigger check, provide this in body + * { + * "notrigger": 0 + * } + * + * @param int $id Intervention ID + * @param int $notrigger 1=Does not execute triggers, 0= execute triggers + * + * @url POST {id}/validate + * + * @return array + */ + function validate($id, $notrigger=0) + { + if(! DolibarrApiAccess::$user->rights->ficheinter->creer) { + throw new RestException(401, "Insuffisant rights"); + } + $result = $this->fichinter->fetch($id); + if( ! $result ) { + throw new RestException(404, 'Intervention not found'); + } + + if( ! DolibarrApi::_checkAccessToResource('fichinter',$this->fichinter->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } + + $result = $this->fichinter->setValid(DolibarrApiAccess::$user, $notrigger); + if ($result == 0) { + throw new RestException(304, 'Error nothing done. May be object is already validated'); + } + if ($result < 0) { + throw new RestException(500, 'Error when validating Intervention: '.$this->commande->error); + } + + $this->fichinter->fetchObjectLinked(); + + return $this->_cleanObjectDatas($this->fichinter); + } + + /** + * Close an intervention + * + * @param int $id Intervention ID + * + * @url POST {id}/close + * + * @return array + */ + function closeFichinter($id) + { + if(! DolibarrApiAccess::$user->rights->ficheinter->creer) + { + throw new RestException(401, "Insuffisant rights"); + } + $result = $this->fichinter->fetch($id); + if (! $result) { + throw new RestException(404, 'Intervention not found'); + } + + if (! DolibarrApi::_checkAccessToResource('fichinter',$this->fichinter->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } + + $result = $this->fichinter->setStatut(3); + + if ($result == 0) { + throw new RestException(304, 'Error nothing done. May be object is already closed'); + } + if ($result < 0) { + throw new RestException(500, 'Error when closing Intervention: '.$this->fichinter->error); + } + + $this->fichinter->fetchObjectLinked(); + + return $this->_cleanObjectDatas($this->fichinter); + } + + /** + * Validate fields before create or update object + * + * @param array $data Data to validate + * @return array + * + * @throws RestException + */ + function _validate($data) + { + $fichinter = array(); + foreach (Interventions::$FIELDS as $field) { + if (!isset($data[$field])) + throw new RestException(400, "$field field missing"); + $fichinter[$field] = $data[$field]; + } + return $fichinter; + } + + + /** + * Clean sensible object datas + * + * @param object $object Object to clean + * @return array Array of cleaned object properties + */ + function _cleanObjectDatas($object) { + + $object = parent::_cleanObjectDatas($object); + + unset($object->statuts_short); + unset($object->statuts_logo); + unset($object->statuts); + + return $object; + } + + /** + * Validate fields before create or update object + * + * @param array $data Data to validate + * @return array + * + * @throws RestException + */ + function _validateLine($data) + { + $fichinter = array(); + foreach (Interventions::$FIELDSLINE as $field) { + if (!isset($data[$field])) + throw new RestException(400, "$field field missing"); + $fichinter[$field] = $data[$field]; + } + return $fichinter; + } + + +} diff --git a/htdocs/fichinter/class/fichinter.class.php b/htdocs/fichinter/class/fichinter.class.php index 237d09570d1..ce122b045b5 100644 --- a/htdocs/fichinter/class/fichinter.class.php +++ b/htdocs/fichinter/class/fichinter.class.php @@ -128,7 +128,7 @@ class Fichinter extends CommonObject $sql.= " WHERE sc.fk_user = " .$user->id; $clause = "AND"; } - $sql.= " ".$clause." fi.entity IN (".getEntity($this->element, 1).")"; + $sql.= " ".$clause." fi.entity IN (".getEntity($this->element).")"; $resql=$this->db->query($sql); if ($resql) @@ -157,7 +157,7 @@ class Fichinter extends CommonObject */ function create($user, $notrigger=0) { - global $conf, $user, $langs; + global $conf, $langs; dol_syslog(get_class($this)."::create ref=".$this->ref); diff --git a/htdocs/fourn/card.php b/htdocs/fourn/card.php index 6f473f8deb3..724f90af228 100644 --- a/htdocs/fourn/card.php +++ b/htdocs/fourn/card.php @@ -101,6 +101,21 @@ if (empty($reshook)) $result=$object->setPaymentMethods(GETPOST('mode_reglement_supplier_id','int')); if ($result < 0) dol_print_error($db,$object->error); } + if ($action == 'update_extras') { + $object->fetch($id); + + // Fill array 'array_options' with data from update form + $extralabels = $extrafields->fetch_name_optionals_label($object->table_element); + $ret = $extrafields->setOptionalsFromPost($extralabels, $object, GETPOST('attribute')); + + if ($ret < 0) $error++; + if (! $error) + { + $result = $object->insertExtraFields(); + if ($result < 0) $error++; + } + if ($error) $action = 'edit_extras'; + } } @@ -779,7 +794,7 @@ if ($object->id > 0) print ''; - if (! empty($conf->global->MAIN_REPEATCONTACTONEACHTAB)) + if (! empty($conf->global->MAIN_DUPLICATE_CONTACTS_TAB_ON_MAIN_CARD)) { print '
'; // List of contacts diff --git a/htdocs/fourn/class/paiementfourn.class.php b/htdocs/fourn/class/paiementfourn.class.php index 6d402598284..fc917e112f7 100644 --- a/htdocs/fourn/class/paiementfourn.class.php +++ b/htdocs/fourn/class/paiementfourn.class.php @@ -210,11 +210,12 @@ class PaiementFourn extends Paiement $resql=$this->db->query($sql); if ($resql) { + $invoice=new FactureFournisseur($this->db); + $invoice->fetch($facid); + // If we want to closed payed invoices if ($closepaidinvoices) { - $invoice=new FactureFournisseur($this->db); - $invoice->fetch($facid); $paiement = $invoice->getSommePaiement(); //$creditnotes=$invoice->getSumCreditNotesUsed(); $creditnotes=0; @@ -228,17 +229,34 @@ class PaiementFourn extends Paiement } else dol_syslog("Remain to pay for invoice ".$facid." not null. We do nothing."); } + + // Regenerate documents of invoices + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) + { + $outputlangs = $langs; + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $invoice->thirdparty->default_lang; + if (! empty($newlang)) { + $outputlangs = new Translate("", $conf); + $outputlangs->setDefaultLang($newlang); + } + $ret = $invoice->fetch($facid); // Reload to get new records + $result = $invoice->generateDocument($invoice->modelpdf, $outputlangs); + if ($result < 0) { + setEventMessages($invoice->error, $invoice->errors, 'errors'); + $error++; + } + } } else { - dol_syslog('Paiement::Create Erreur INSERT dans paiement_facture '.$facid); + $this->error=$this->db->lasterror(); $error++; } } else { - dol_syslog('PaiementFourn::Create Montant non numerique',LOG_ERR); + dol_syslog(get_class($this).'::Create Amount line '.$key.' not a number. We discard it.'); } } diff --git a/htdocs/install/mysql/migration/7.0.0-8.0.0.sql b/htdocs/install/mysql/migration/7.0.0-8.0.0.sql index 1b9375ef1a8..498d9226b2e 100644 --- a/htdocs/install/mysql/migration/7.0.0-8.0.0.sql +++ b/htdocs/install/mysql/migration/7.0.0-8.0.0.sql @@ -22,5 +22,12 @@ -- To set a field as default NULL: -- VPGSQL8.2 ALTER TABLE llx_table ALTER COLUMN name SET DEFAULT NULL; -- Note: fields with type BLOB/TEXT can't have default value. + + + + -- For 8.0 + ALTER TABLE llx_societe ADD COLUMN fk_entrepot integer DEFAULT 0; + +ALTER TABLE llx_projet ADD COLUMN bill_time integer DEFAULT 0; \ No newline at end of file diff --git a/htdocs/install/mysql/tables/llx_commandedet.sql b/htdocs/install/mysql/tables/llx_commandedet.sql index 81ba14cca2c..0d6468309f5 100644 --- a/htdocs/install/mysql/tables/llx_commandedet.sql +++ b/htdocs/install/mysql/tables/llx_commandedet.sql @@ -39,26 +39,26 @@ create table llx_commandedet remise real DEFAULT 0, -- montant de la remise fk_remise_except integer NULL, -- Lien vers table des remises fixes price real, -- prix final - subprice double(24,8) DEFAULT 0, -- P.U. HT (exemple 100) - total_ht double(24,8) DEFAULT 0, -- Total HT de la ligne toute quantite et incluant remise ligne et globale - total_tva double(24,8) DEFAULT 0, -- Total TVA de la ligne toute quantite et incluant remise ligne et globale - total_localtax1 double(24,8) DEFAULT 0, -- Total LocalTax1 - total_localtax2 double(24,8) DEFAULT 0, -- Total LocalTax2 - total_ttc double(24,8) DEFAULT 0, -- Total TTC de la ligne toute quantite et incluant remise ligne et globale - product_type integer DEFAULT 0, + subprice double(24,8) DEFAULT 0, -- P.U. HT (exemple 100) + total_ht double(24,8) DEFAULT 0, -- Total HT de la ligne toute quantite et incluant remise ligne et globale + total_tva double(24,8) DEFAULT 0, -- Total TVA de la ligne toute quantite et incluant remise ligne et globale + total_localtax1 double(24,8) DEFAULT 0, -- Total LocalTax1 + total_localtax2 double(24,8) DEFAULT 0, -- Total LocalTax2 + total_ttc double(24,8) DEFAULT 0, -- Total TTC de la ligne toute quantite et incluant remise ligne et globale + product_type integer DEFAULT 0, -- 0 or 1. Value 9 may be used by some modules (amount of line may not be included into generated discount if value is 9). date_start datetime DEFAULT NULL, -- date debut si service date_end datetime DEFAULT NULL, -- date fin si service info_bits integer DEFAULT 0, -- TVA NPR ou non - buy_price_ht double(24,8) DEFAULT 0, -- buying price + buy_price_ht double(24,8) DEFAULT 0, -- buying price fk_product_fournisseur_price integer DEFAULT NULL, -- reference of supplier price when line was added (may be used to update buy_price_ht current price when future invoice will be created) - special_code integer DEFAULT 0, -- code pour les lignes speciales + special_code integer DEFAULT 0, -- code for special lines (may be 1=transport, 2=ecotax, 3=option, moduleid=...) rang integer DEFAULT 0, - fk_unit integer DEFAULT NULL, -- lien vers table des unités + fk_unit integer DEFAULT NULL, -- lien vers table des unités import_key varchar(14), - fk_commandefourndet integer DEFAULT NULL, -- link to detail line of commande fourn (resplenish) + fk_commandefourndet integer DEFAULT NULL, -- link to detail line of commande fourn (resplenish) fk_multicurrency integer, multicurrency_code varchar(255), diff --git a/htdocs/install/mysql/tables/llx_facturedet.sql b/htdocs/install/mysql/tables/llx_facturedet.sql index 28c07e6d508..05c68e92751 100644 --- a/htdocs/install/mysql/tables/llx_facturedet.sql +++ b/htdocs/install/mysql/tables/llx_facturedet.sql @@ -47,7 +47,7 @@ create table llx_facturedet total_localtax1 double(24,8) DEFAULT 0, -- Total LocalTax1 for total quantity of line total_localtax2 double(24,8) DEFAULT 0, -- Total LocalTax2 for total quantity of line total_ttc double(24,8), -- Total TTC de la ligne toute quantite et incluant remise ligne et globale - product_type integer DEFAULT 0, + product_type integer DEFAULT 0, -- 0 or 1. Value 9 may be used by some modules (amount of line may not be included into generated discount if value is 9). date_start datetime DEFAULT NULL, -- date start if service date_end datetime DEFAULT NULL, -- date end if service info_bits integer DEFAULT 0, -- VAT NPR or not (for france only) @@ -57,7 +57,7 @@ create table llx_facturedet fk_code_ventilation integer DEFAULT 0 NOT NULL, -- Id in table llx_accounting_bookeeping to know accounting account for product line - special_code integer DEFAULT 0, -- code pour les lignes speciales + special_code integer DEFAULT 0, -- code for special lines (may be 1=transport, 2=ecotax, 3=option, moduleid=...) rang integer DEFAULT 0, -- position of line fk_contract_line integer NULL, -- id of contract line when invoice comes from contract lines import_key varchar(14), diff --git a/htdocs/install/mysql/tables/llx_projet.sql b/htdocs/install/mysql/tables/llx_projet.sql index 3875e64e1a7..8e58f0ad8c8 100644 --- a/htdocs/install/mysql/tables/llx_projet.sql +++ b/htdocs/install/mysql/tables/llx_projet.sql @@ -41,7 +41,8 @@ create table llx_projet note_public text, --budget_days real, -- budget in days is sum of field planned_workload of tasks opp_amount double(24,8), - budget_amount double(24,8), + budget_amount double(24,8), + bill_time integer DEFAULT 0, -- Set to 1 if time spent must be converted into invoices model_pdf varchar(255), import_key varchar(14) -- Import key )ENGINE=innodb; diff --git a/htdocs/install/mysql/tables/llx_propaldet.sql b/htdocs/install/mysql/tables/llx_propaldet.sql index 70029acdb08..283708fd7ce 100644 --- a/htdocs/install/mysql/tables/llx_propaldet.sql +++ b/htdocs/install/mysql/tables/llx_propaldet.sql @@ -44,7 +44,7 @@ create table llx_propaldet total_localtax1 double(24,8) DEFAULT 0, -- Total localtax1 total_localtax2 double(24,8) DEFAULT 0, -- Total localtax2 total_ttc double(24,8) DEFAULT 0, -- Total TTC de la ligne toute quantite et incluant remise ligne et globale - product_type integer DEFAULT 0, + product_type integer DEFAULT 0, -- 0 or 1. Value 9 may be used by some modules (amount of line may not be included into generated discount if value is 9). date_start datetime DEFAULT NULL, -- date debut si service date_end datetime DEFAULT NULL, -- date fin si service info_bits integer DEFAULT 0, -- TVA NPR ou non @@ -52,8 +52,8 @@ create table llx_propaldet buy_price_ht double(24,8) DEFAULT 0, -- buying price fk_product_fournisseur_price integer DEFAULT NULL, -- reference of supplier price when line was added (may be used to update buy_price_ht current price when future invoice will be created) - special_code integer DEFAULT 0, -- code pour les lignes speciales - rang integer DEFAULT 0, -- ordre affichage sur la propal + special_code integer DEFAULT 0, -- code for special lines (may be 1=transport, 2=ecotax, 3=option, moduleid=...) + rang integer DEFAULT 0, -- ordre affichage sur la propal fk_unit integer DEFAULT NULL, -- lien vers table des unités fk_multicurrency integer, diff --git a/htdocs/install/mysql/tables/llx_societe.sql b/htdocs/install/mysql/tables/llx_societe.sql index c23ca3a183c..f6ee1f39220 100644 --- a/htdocs/install/mysql/tables/llx_societe.sql +++ b/htdocs/install/mysql/tables/llx_societe.sql @@ -33,8 +33,6 @@ create table llx_societe statut tinyint DEFAULT 0, -- statut parent integer, - tms timestamp, - datec datetime, -- creation date status tinyint DEFAULT 1, -- cessation d'activité ( 1 -- en activité, 0 -- cessation d'activité) @@ -57,15 +55,15 @@ create table llx_societe fk_typent integer DEFAULT 0, -- fk_forme_juridique integer DEFAULT 0, -- juridical status fk_currency varchar(3), -- default currency - siren varchar(128), -- IDProf1: siren or RCS for france - siret varchar(128), -- IDProf2: siret for france - ape varchar(128), -- IDProf3: code ape for france + siren varchar(128), -- IDProf1: siren or RCS for france, ... + siret varchar(128), -- IDProf2: siret for france, ... + ape varchar(128), -- IDProf3: code ape for france, ... idprof4 varchar(128), -- IDProf4: nu for france idprof5 varchar(128), -- IDProf5: nu for france idprof6 varchar(128), -- IDProf6: nu for france tva_intra varchar(20), -- tva - capital double(24,8), -- capital de la societe - fk_stcomm integer DEFAULT 0 NOT NULL, -- commercial statut + capital double(24,8) DEFAULT NULL, -- capital de la societe + fk_stcomm integer DEFAULT 0 NOT NULL, -- commercial statut note_private text, -- note_public text, -- model_pdf varchar(255), @@ -79,8 +77,6 @@ create table llx_societe customer_bad tinyint DEFAULT 0, -- mauvais payeur 0/1 customer_rate real DEFAULT 0, -- taux fiabilite client (0 a 1) supplier_rate real DEFAULT 0, -- taux fiabilite fournisseur (0 a 1) - fk_user_creat integer NULL, -- utilisateur qui a cree l'info - fk_user_modif integer, -- utilisateur qui a modifie l'info remise_client real DEFAULT 0, -- remise systematique pour le client mode_reglement tinyint, -- mode de reglement cond_reglement tinyint, -- condition de reglement @@ -99,10 +95,17 @@ create table llx_societe default_lang varchar(6), -- default language logo varchar(255) DEFAULT NULL, canvas varchar(32) DEFAULT NULL, -- type of canvas if used (null by default) - import_key varchar(14), -- import key + fk_entrepot integer DEFAULT 0, -- if we need a link between third party and warehouse webservices_url varchar(255), -- supplier webservice url webservices_key varchar(128), -- supplier webservice key - fk_multicurrency integer, - multicurrency_code varchar(255) + tms timestamp, -- last modification date + datec datetime, -- creation date + fk_user_creat integer NULL, -- utilisateur qui a cree l'info + fk_user_modif integer, -- utilisateur qui a modifie l'info + + fk_multicurrency integer, + multicurrency_code varchar(255), + + import_key varchar(14) -- import key )ENGINE=innodb; diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index cae43a9e3b5..c2201c5d118 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -269,9 +269,10 @@ MAIN_MAIL_SMTP_SERVER=SMTP/SMTPS Host (By default in php.ini: %s) MAIN_MAIL_SMTP_PORT_NotAvailableOnLinuxLike=SMTP/SMTPS Port (Not defined into PHP on Unix like systems) MAIN_MAIL_SMTP_SERVER_NotAvailableOnLinuxLike=SMTP/SMTPS Host (Not defined into PHP on Unix like systems) MAIN_MAIL_EMAIL_FROM=Sender email for automatic emails (By default in php.ini: %s) -MAIN_MAIL_ERRORS_TO=Sender email used for error returns emails sent +MAIN_MAIL_ERRORS_TO=Email used as 'Errors-To' field in emails sent MAIN_MAIL_AUTOCOPY_TO= Send systematically a hidden carbon-copy of all sent emails to MAIN_DISABLE_ALL_MAILS=Disable all emails sendings (for test purposes or demos) +MAIN_MAIL_FORCE_SENDTO=Send all emails to (instead of real recipients, for test purposes) MAIN_MAIL_SENDMODE=Method to use to send EMails MAIN_MAIL_SMTPS_ID=SMTP ID if authentication required MAIN_MAIL_SMTPS_PW=SMTP Password if authentication required @@ -415,7 +416,7 @@ ExtrafieldParamHelpcheckbox=List of values must be lines with format key,value ( ExtrafieldParamHelpradio=List of values must be lines with format key,value (where key can't be '0')

for example :
1,value1
2,value2
3,value3
... ExtrafieldParamHelpsellist=List of values comes from a table
Syntax : table_name:label_field:id_field::filter
Example : c_typent:libelle:id::filter

- idfilter is necessarly a primary int key
- filter can be a simple test (eg active=1) to display only active value
You can also use $ID$ in filter witch is the current id of current object
To do a SELECT in filter use $SEL$
if you want to filter on extrafields use syntax extra.fieldcode=... (where field code is the code of extrafield)

In order to have the list depending on another complementary attribute list:
c_typent:libelle:id:options_parent_list_code|parent_column:filter

In order to have the list depending on another list:
c_typent:libelle:id:parent_list_code|parent_column:filter ExtrafieldParamHelpchkbxlst=List of values comes from a table
Syntax : table_name:label_field:id_field::filter
Example : c_typent:libelle:id::filter

filter can be a simple test (eg active=1) to display only active value
You can also use $ID$ in filter witch is the current id of current object
To do a SELECT in filter use $SEL$
if you want to filter on extrafields use syntax extra.fieldcode=... (where field code is the code of extrafield)

In order to have the list depending on another complementary attribute list :
c_typent:libelle:id:options_parent_list_code|parent_column:filter

In order to have the list depending on another list:
c_typent:libelle:id:parent_list_code|parent_column:filter -ExtrafieldParamHelplink=Parameters must be ObjectName:Classpath
Syntax : ObjectName:Classpath
Example : Societe:societe/class/societe.class.php +ExtrafieldParamHelplink=Parameters must be ObjectName:Classpath
Syntax : ObjectName:Classpath
Examples :
Societe:societe/class/societe.class.php
Contact:contact/class/contact.class.php LibraryToBuildPDF=Library used for PDF generation WarningUsingFPDF=Warning: Your conf.php contains directive dolibarr_pdf_force_fpdf=1. This means you use the FPDF library to generate PDF files. This library is old and does not support a lot of features (Unicode, image transparency, cyrillic, arab and asiatic languages, ...), so you may experience errors during PDF generation.
To solve this and have a full support of PDF generation, please download TCPDF library, then comment or remove the line $dolibarr_pdf_force_fpdf=1, and add instead $dolibarr_lib_TCPDF_PATH='path_to_TCPDF_dir' LocalTaxDesc=Some countries apply 2 or 3 taxes on each invoice line. If this is the case, choose type for second and third tax and its rate. Possible type are:
1 : local tax apply on products and services without vat (localtax is calculated on amount without tax)
2 : local tax apply on products and services including vat (localtax is calculated on amount + main tax)
3 : local tax apply on products without vat (localtax is calculated on amount without tax)
4 : local tax apply on products including vat (localtax is calculated on amount + main vat)
5 : local tax apply on services without vat (localtax is calculated on amount without tax)
6 : local tax apply on services including vat (localtax is calculated on amount + tax) diff --git a/htdocs/langs/en_US/blockedlog.lang b/htdocs/langs/en_US/blockedlog.lang index 93f64bddbaa..9f6a49a5146 100644 --- a/htdocs/langs/en_US/blockedlog.lang +++ b/htdocs/langs/en_US/blockedlog.lang @@ -14,6 +14,9 @@ OkCheckFingerprintValidityButChainIsKo=Archived log seems valid compared to prev AddedByAuthority=Stored into remote authority NotAddedByAuthorityYet=Not yet stored into remote authority ShowDetails=Show stored details +logPAYMENT_VARIOUS_CREATE=Payment (not assigned to invoice) created +logPAYMENT_VARIOUS_MODIFY=Payment (not assigned to invoice) modified +logPAYMENT_VARIOUS_DELETE=Payment (not assigned to invoice) logical deletion logPAYMENT_ADD_TO_BANK=Payment added to bank logPAYMENT_CUSTOMER_CREATE=Customer payment created logPAYMENT_CUSTOMER_DELETE=Customer payment logical deletion @@ -41,7 +44,7 @@ DownloadLogCSV=Export archived logs (CSV) logDOC_PREVIEW=Preview of a validated document in order to print or download logDOC_DOWNLOAD=Download of a validated document in order to print or send DataOfArchivedEvent=Full datas of archived event -ImpossibleToReloadObject=Object (type %s, id %s) removed (see 'Full data' link for unerasable saved data) +ImpossibleToReloadObject=Original object (type %s, id %s) not linked (see 'Full datas' column to get unalterable saved data) BlockedLogAreRequiredByYourCountryLegislation=Unalterable Logs module may be required by the legislation of your country. Disabling this module may render any future transactions invalid with respect to the law and the use of legal software as they can not be validated by a tax audit. BlockedLogActivatedBecauseRequiredByYourCountryLegislation=Unalterable Logs module was activated because of the legislation of your country. Disabling this module may render any future transactions invalid with respect to the law and the use of legal software as they can not be validated by a tax audit. BlockedLogDisableNotAllowedForCountry=List of countries where usage of this module is mandatory (just to prevent to disable the module by error, if your country is in this list, disable of module is not possible without editing this list first. Note also that enabling/disabling this module will keep a track into the unalterable log). diff --git a/htdocs/langs/en_US/companies.lang b/htdocs/langs/en_US/companies.lang index 7cff22df092..c5bc84acaf8 100644 --- a/htdocs/langs/en_US/companies.lang +++ b/htdocs/langs/en_US/companies.lang @@ -56,6 +56,7 @@ Address=Address State=State/Province StateShort=State Region=Region +Region-State=Region - State Country=Country CountryCode=Country code CountryId=Country id diff --git a/htdocs/langs/en_US/compta.lang b/htdocs/langs/en_US/compta.lang index e54d613628e..632ef67feb9 100644 --- a/htdocs/langs/en_US/compta.lang +++ b/htdocs/langs/en_US/compta.lang @@ -1,5 +1,5 @@ # Dolibarr language file - Source file is en_US - compta -MenuFinancial=Billing / Payment +MenuFinancial=Billing | Payment TaxModuleSetupToModifyRules=Go to Taxes module setup to modify rules for calculation TaxModuleSetupToModifyRulesLT=Go to Company setup to modify rules for calculation OptionMode=Option for accountancy diff --git a/htdocs/langs/en_US/mails.lang b/htdocs/langs/en_US/mails.lang index 4be167d3061..8e2b093fdc2 100644 --- a/htdocs/langs/en_US/mails.lang +++ b/htdocs/langs/en_US/mails.lang @@ -87,6 +87,7 @@ MailingModuleDescEmailsFromFile=Emails from file MailingModuleDescEmailsFromUser=Emails input by user MailingModuleDescDolibarrUsers=Users with Emails MailingModuleDescThirdPartiesByCategories=Third parties (by categories) +SendingFromWebInterfaceIsNotAllowed=Sending from web interface is not allowed. # Libelle des modules de liste de destinataires mailing LineInFile=Line %s in file diff --git a/htdocs/langs/en_US/salaries.lang b/htdocs/langs/en_US/salaries.lang index 2a3372ed847..f1db7ea1cf3 100644 --- a/htdocs/langs/en_US/salaries.lang +++ b/htdocs/langs/en_US/salaries.lang @@ -1,7 +1,7 @@ # Dolibarr language file - Source file is en_US - salaries SALARIES_ACCOUNTING_ACCOUNT_PAYMENT=Accounting account used for user third parties SALARIES_ACCOUNTING_ACCOUNT_PAYMENT_Desc=The dedicated accounting account defined on user card will be used for Subledger accouting only. This one will be used for General Ledger and as default value of Subledger accounting if dedicated user accouting account on user is not defined. -SALARIES_ACCOUNTING_ACCOUNT_CHARGE=Accounting account by default for personnel expenses +SALARIES_ACCOUNTING_ACCOUNT_CHARGE=Accounting account by default for wage payments Salary=Salary Salaries=Salaries NewSalaryPayment=New salary payment diff --git a/htdocs/langs/es_ES/accountancy.lang b/htdocs/langs/es_ES/accountancy.lang index a5e4fbdf465..59c20932702 100644 --- a/htdocs/langs/es_ES/accountancy.lang +++ b/htdocs/langs/es_ES/accountancy.lang @@ -25,8 +25,8 @@ Chartofaccounts=Plan contable CurrentDedicatedAccountingAccount=Cuenta contable dedicada AssignDedicatedAccountingAccount=Nueva cuenta a asignar InvoiceLabel=Etiqueta factura -OverviewOfAmountOfLinesNotBound=Ver la cantidad de líneas no ligadas a cuentas contables -OverviewOfAmountOfLinesBound=Ver la cantidad de líneas ligadas a cuentas contables +OverviewOfAmountOfLinesNotBound=Ver la cantidad de líneas no vinculadas a una cuenta contable +OverviewOfAmountOfLinesBound=Ver la cantidad de líneas vinculadas a una cuenta contable OtherInfo=Otra información DeleteCptCategory=Eliminar la cuenta contable del grupo ConfirmDeleteCptCategory=¿Está seguro de querer eliminar esta cuenta contable del grupo de cuentas contables? @@ -158,7 +158,7 @@ NumPiece=Apunte TransactionNumShort=Núm. transacción AccountingCategory=Grupos personalizados GroupByAccountAccounting=Agrupar por cuenta contable -AccountingAccountGroupsDesc=You can define here some groups of accounting account. They will be used for personalized accounting reports. +AccountingAccountGroupsDesc=Puedes definir aquí algunos grupos de cuentas contables. Se usarán para informes de contabilidad personalizados. ByAccounts=Por cuentas ByPredefinedAccountGroups=Por grupos predefinidos ByPersonalizedAccountGroups=Por grupos personalizados @@ -173,7 +173,7 @@ DelBookKeeping=Eliminar los registros del Libro Mayor FinanceJournal=Diario financiero ExpenseReportsJournal=Diario informe de gastos DescFinanceJournal=El diario financiero incluye todos los tipos de pagos por cuenta bancaria -DescJournalOnlyBindedVisible=Esta es una vista de registros que están vinculados a una cuenta contable y pueden ser registrados en el Libro Mayor. +DescJournalOnlyBindedVisible=Esta es una vista del registro vinculado a una cuenta contable y que se puede registrar en el Libro Mayor. VATAccountNotDefined=Cuenta contable para IVA no definida ThirdpartyAccountNotDefined=Cuenta contable de tercero no definida ProductAccountNotDefined=Cuenta contable de producto no definida @@ -191,7 +191,7 @@ DescThirdPartyReport=Consulte aquí el listado de clientes y proveedores y sus c ListAccounts=Listado de cuentas contables UnknownAccountForThirdparty=Cuenta contable de tercero desconocida, usaremos %s UnknownAccountForThirdpartyBlocking=Cuenta contable de tercero desconocida. Error de bloqueo -UnknownAccountForThirdpartyAndWaitingAccountNotDefinedBlocking=Unknown third party account and waiting account not defined. Blocking error +UnknownAccountForThirdpartyAndWaitingAccountNotDefinedBlocking=Cuenta del terceros desconocida y cuenta de espera no definida. Error de bloqueo Pcgtype=Grupo de cuenta Pcgsubtype=Subgrupo de cuenta @@ -224,6 +224,8 @@ GeneralLedgerSomeRecordWasNotRecorded=Algunas de las operaciones que no podrán NoNewRecordSaved=No hay más registros para el diario ListOfProductsWithoutAccountingAccount=Listado de productos sin cuentas contables ChangeBinding=Cambiar la unión +Accounted=Contabilizada en el Libro Mayor +NotYetAccounted=Aún no contabilizada en el Libro Mayor ## Admin ApplyMassCategories=Aplicar categorías en masa diff --git a/htdocs/langs/es_ES/admin.lang b/htdocs/langs/es_ES/admin.lang index c8e8d5cfe43..02057302f8a 100644 --- a/htdocs/langs/es_ES/admin.lang +++ b/htdocs/langs/es_ES/admin.lang @@ -260,18 +260,18 @@ FontSize=Tamaño de fuente Content=Contenido NoticePeriod=Plazo de aviso NewByMonth=Nuevo por mes -Emails=Emails -EMailsSetup=Configuración emails +Emails=E-Mails +EMailsSetup=Configuración e-mails EMailsDesc=Esta página le permite sobrescribir sus parámetros de PHP para el envío de correos electrónicos. En la mayoría de los casos, en el sistema operativo Unix/Linux, su configuración de PHP es correcta y estos parámetros son inútiles. EmailSenderProfiles=Perfiles de remitentes de e-mails MAIN_MAIL_SMTP_PORT=Puerto del servidor SMTP (Por defecto en php.ini: %s) MAIN_MAIL_SMTP_SERVER=Nombre host o ip del servidor SMTP (Por defecto en php.ini: %s) MAIN_MAIL_SMTP_PORT_NotAvailableOnLinuxLike=Puerto del servidor SMTP (No definido en PHP en sistemas de tipo Unix) MAIN_MAIL_SMTP_SERVER_NotAvailableOnLinuxLike=Nombre servidor o ip del servidor SMTP (No definido en PHP en sistemas de tipo Unix) -MAIN_MAIL_EMAIL_FROM=Correo electrónico del remitente para correos electrónicos automáticos (por defecto en php.ini: %s) -MAIN_MAIL_ERRORS_TO=Correo electrónico del remitente utilizado para los correos electrónicos de error enviados +MAIN_MAIL_EMAIL_FROM=E-mail del remitente para e-mails automáticos (por defecto en php.ini: %s) +MAIN_MAIL_ERRORS_TO=E-mail del remitente utilizado para los e-mails de error enviados MAIN_MAIL_AUTOCOPY_TO= Enviar automáticamente copia oculta de los e-mails enviados a -MAIN_DISABLE_ALL_MAILS=Deshabilitar todos los envíos de correos electrónicos (para propósitos de prueba o demostraciones) +MAIN_DISABLE_ALL_MAILS=Deshabilitar todos los envíos de e-mail (para propósitos de prueba o demostraciones) MAIN_MAIL_SENDMODE=Método de envío de e-mails MAIN_MAIL_SMTPS_ID=ID de autentificación SMTP si se requiere autenticación SMTP MAIN_MAIL_SMTPS_PW=Contraseña autentificación SMTP si se requiere autentificación SMTP @@ -410,11 +410,11 @@ ExtrafieldCheckBoxFromList=Casilla de selección de tabla ExtrafieldLink=Objeto adjuntado ComputedFormula=Campo combinado ComputedFormulaDesc=Puede introducir aquí una fórmula utilizando otras propiedades de objeto o cualquier código PHP para obtener un valor calculado dinámico. Puede utilizar cualquier fórmula compatible con PHP, incluido el operador de condición "?" y los objetos globales siguientes: $db, $conf, $langs, $mysoc, $user, $object.
ATENCIÓN: Sólo algunas propiedades de $object pueden estar disponibles. Si necesita propiedades no cargadas, solo busque el objeto en su fórmula como en el segundo ejemplo.
Usando un campo computado significa que no puede ingresar ningún valor de la interfaz. Además, si hay un error de sintaxis, la fórmula puede devolver nada.

Ejemplo de fórmula:
$object->id < 10 ? round($object->id / 2, 2) : ($object->id + 2 * $user->id) * (int) substr($mysoc->zip, 1, 2)

Ejemlo de recarga de objeto
(($reloadedobj = new Societe($db)) && ($reloadedobj->fetch($obj->id ? $obj->id : ($obj->rowid ? $obj->rowid : $object->id)) > 0)) ? $reloadedobj->array_options['options_extrafieldkey'] * $reloadedobj->capital / 5 : '-1'

Otro ejemplo de fórmula para forzar la carga del objeto y su objeto principal:
(($reloadedobj = new Task($db)) && ($reloadedobj->fetch($object->id) > 0) && ($secondloadedobj = new Project($db)) && ($secondloadedobj->fetch($reloadedobj->fk_project) > 0)) ? $secondloadedobj->ref : 'Parent project not found' -ExtrafieldParamHelpselect=El listado de parámetros tiene que ser key,valor

por ejemplo:
1,value1
2,value2
3,value3
...

Para tener una lista en funcion de atributos complementarios de lista:
1,value1|options_parent_list_code:parent_key
2,value2|options_parent_list_code:parent_key

Para tener la lista en función de otra:
1,value1|parent_list_code:parent_key
2,value2|parent_list_code:parent_key +ExtrafieldParamHelpselect=El listado de parámetros tiene que ser key,valor

por ejemplo:
1,value1
2,value2
3,value3
...

Para tener una lista en funcion de campos adicionales de lista:
1,value1|options_parent_list_code:parent_key
2,value2|options_parent_list_code:parent_key

Para tener la lista en función de otra:
1,value1|parent_list_code:parent_key
2,value2|parent_list_code:parent_key ExtrafieldParamHelpcheckbox=El listado de parámetros tiene que ser key,valor

por ejemplo:
1,value1
2,value2
3,value3
... ExtrafieldParamHelpradio=El listado de parámetros tiene que ser key,valor (donde key no puede ser 0)

por ejemplo:
1,value1
2,value2
3,value3
... -ExtrafieldParamHelpsellist=Lista de parámetros proviene de una tabla
Sintaxis: nombre_tabla: etiqueta_field: id_field :: filtro
Ejemplo: c_typent: libelle: id :: filtro

filtro puede ser una prueba simple (por ejemplo, activa = 1) Para mostrar sólo el valor activo
También puede utilizar $ ID $ en el filtro witch es el actual id del objeto actual
Para hacer un SELECT en el filtro de uso $ SEL $
si desea filtrar en extrafields utilizar la sintaxis Extra.fieldcode = ... (donde código de campo es el código de extrafield)

Para que la lista dependa de otra lista de atributos complementarios:
c_typent: libelle: id: options_ parent_list_code | parent_column: filter

Para que la lista dependa de otra lista:
c_typent: libelle: id: parent_list_code | parent_column: filter -ExtrafieldParamHelpchkbxlst=Lista de parámetros proviene de una tabla
Sintaxis: nombre_tabla: etiqueta_field: id_field :: filtro
Ejemplo: c_typent: libelle: id :: filtro

filtro puede ser una prueba simple (por ejemplo, activa = 1) Para mostrar sólo el valor activo
También puede utilizar $ ID $ en el filtro witch es el id actual del objeto actual
Para hacer un SELECT en el filtro de uso $ SEL $
si desea filtrar en extrafields utilizar la sintaxis Extra.fieldcode = ... (donde código de campo es el código de extrafield)

Para que la lista dependa de otra lista de atributos complementarios:
c_typent: libelle: id: options_ parent_list_code | parent_column: filter

Para que la lista dependa de otra lista:
c_typent: libelle: id: parent_list_code | parent_column: filter +ExtrafieldParamHelpsellist=Lista de parámetros proviene de una tabla
Sintaxis: nombre_tabla: etiqueta_field: id_field :: filtro
Ejemplo: c_typent: libelle: id :: filtro

filtro puede ser una prueba simple (por ejemplo, activa = 1) Para mostrar sólo el valor activo
También puede utilizar $ ID $ en el filtro witch es el actual id del objeto actual
Para hacer un SELECT en el filtro de uso $ SEL $
si desea filtrar en campos adicionales utilizar la sintaxis Extra.fieldcode = ... (donde código de campo es el código de campo adicional)

Para que la lista dependa de otra lista de campos adicionales:
c_typent: libelle: id: options_ parent_list_code | parent_column: filter

Para que la lista dependa de otra lista:
c_typent: libelle: id: parent_list_code | parent_column: filter +ExtrafieldParamHelpchkbxlst=Lista de parámetros proviene de una tabla
Sintaxis: nombre_tabla: etiqueta_field: id_field :: filtro
Ejemplo: c_typent: libelle: id :: filtro

filtro puede ser una prueba simple (por ejemplo, activa = 1) Para mostrar sólo el valor activo
También puede utilizar $ ID $ en el filtro witch es el id actual del objeto actual
Para hacer un SELECT en el filtro de uso $ SEL $
si desea filtrar en campos adicionales utilizar la sintaxis Extra.fieldcode = ... (donde código de campo es el código de campo adicional)

Para que la lista dependa de otra lista de campos adicionales:
c_typent: libelle: id: options_ parent_list_code | parent_column: filter

Para que la lista dependa de otra lista:
c_typent: libelle: id: parent_list_code | parent_column: filter ExtrafieldParamHelplink=Los parámetros deben ser ObjectName: Classpath
Sintaxis: ObjectName:Classpath
Ejemplo: Societe:societe/class/societe.class.php LibraryToBuildPDF=Libreria usada en la generación de los PDF WarningUsingFPDF=Atención: Su archivo conf.php contiene la directiva dolibarr_pdf_force_fpdf=1. Esto hace que se use la librería FPDF para generar sus archivos PDF. Esta librería es antigua y no cubre algunas funcionalidades (Unicode, transparencia de imágenes, idiomas cirílicos, árabes o asiáticos, etc.), por lo que puede tener problemas en la generación de los PDF.
Para resolverlo, y disponer de un soporte completo de PDF, puede descargar la librería TCPDF , y a continuación comentar o eliminar la línea $dolibarr_pdf_force_fpdf=1, y añadir en su lugar $dolibarr_lib_TCPDF_PATH='ruta_a_TCPDF' @@ -551,6 +551,8 @@ Module520Desc=Gestión de créditos Module600Name=Notificaciones Module600Desc=Enviar notificaciones por e-mail (desencadenados por algunos eventos) a los usuarios (configuración definida para cada usuario), los contactos de terceros (configuración definida en cada tercero) o e-mails fijos Module600Long=Tenga en cuenta que este módulo está dedicado a enviar mensajes de e-mail en tiempo real cuando se produce un evento. Si está buscando una función para enviar recordatorios por e-mail de los eventos de su agenda, vaya a la configuración del módulo Agenda. +Module610Name=Variantes de productos +Module610Desc=Permite la creación de variantes de productos en función de los atributos (color, tamaño, ...) Module700Name=Donaciones Module700Desc=Gestión de donaciones Module770Name=Informes de gastos @@ -598,7 +600,7 @@ Module10000Name=Sitios web Module10000Desc=Cree sitios web públicos con un editor WYSIWYG. Configure el servidor web (Apache, Nginx,...) para que apunte al directorio dedicado para tenerlo en línea en Internet. Module20000Name=Gestión de días libres retribuidos Module20000Desc=Gestión de los días libres retribuidos de los empleados -Module39000Name=Lotes de producto +Module39000Name=Lotes de productos Module39000Desc=Gestión de lotes o series, fechas de caducidad y venta de los productos Module50000Name=PayBox Module50000Desc=Módulo para ofrecer pagos online aceptando pagos con tarjeta de Débito/Crédito via PayBox. Esto puede ser usado para permitir a tus clientes realizar pagos libres o pagos en un objeto de Dolibarr en particular (factura, pedido...) @@ -824,12 +826,12 @@ Permission1232=Crear facturas de proveedores Permission1233=Validar facturas de proveedores Permission1234=Eliminar facturas de proveedores Permission1235=Enviar facturas de proveedores por correo -Permission1236=Exportar facturas de proveedores, atributos y pagos +Permission1236=Exportar facturas de proveedores, campos adicionales y pagos Permission1237=Exportar pedidos de proveedores junto con sus detalles Permission1251=Lanzar las importaciones en masa a la base de datos (carga de datos) -Permission1321=Exportar facturas a clientes, atributos y cobros +Permission1321=Exportar facturas a clientes, campos adicionales y cobros Permission1322=Reabrir una factura pagada -Permission1421=Exportar pedidos de clientes y atributos +Permission1421=Exportar pedidos de clientes y campos adicionales Permission20001=Leer peticiones días retribuidos (suyos y subordinados) Permission20002=Cear/modificar sus días retribuidos Permission20003=Eliminar peticiones de días retribuidos @@ -890,7 +892,7 @@ DictionaryStaff=Empleados DictionaryAvailability=Tiempos de entrega DictionaryOrderMethods=Métodos de pedido DictionarySource=Orígenes de presupuestos/pedidos -DictionaryAccountancyCategory=Personalized groups for reports +DictionaryAccountancyCategory=Grupos personalizados para imformes DictionaryAccountancysystem=Modelos de planes contables DictionaryAccountancyJournal=Diarios contables DictionaryEMailTemplates=Plantillas E-Mails @@ -1108,23 +1110,23 @@ MAIN_PROXY_HOST=Nombre/Dirección del servidor proxy MAIN_PROXY_PORT=Puerto del servidor proxy MAIN_PROXY_USER=Login del servidor proxy MAIN_PROXY_PASS=Contraseña del servidor proxy -DefineHereComplementaryAttributes=Defina aquí la lista de atributos adicionales, no disponibles por defecto, y que desea gestionar para %s. -ExtraFields=Atributos adicionales -ExtraFieldsLines=Atributos adicionales (líneas) -ExtraFieldsLinesRec=Atributos complementarios (plantillas de líneas de facturas) -ExtraFieldsSupplierOrdersLines=Atributos complementarios (líneas de pedido) -ExtraFieldsSupplierInvoicesLines=Atributos complementarios (líneas de factura) -ExtraFieldsThirdParties=Atributos adicionales (terceros) -ExtraFieldsContacts=Atributos adicionales (contactos/direcciones) -ExtraFieldsMember=Atributos adicionales (miembros) -ExtraFieldsMemberType=Atributos adicionales (tipos de miembros) -ExtraFieldsCustomerInvoices=Atributos adicionales (facturas a clientes) -ExtraFieldsCustomerInvoicesRec=Atributos complementarios (plantillas de facturas) -ExtraFieldsSupplierOrders=Atributos adicionales (pedidos a proveedores) -ExtraFieldsSupplierInvoices=Atributos adicionales (facturas) -ExtraFieldsProject=Atributos adicionales (proyectos) -ExtraFieldsProjectTask=Atributos adicionales (tareas) -ExtraFieldHasWrongValue=El atributo %s tiene un valor no válido +DefineHereComplementaryAttributes=Defina aquí la lista de campos adicionales, no disponibles por defecto, y que desea gestionar para %s. +ExtraFields=Campos adicionales +ExtraFieldsLines=Campos adicionales (líneas) +ExtraFieldsLinesRec=Campos adicionales (plantillas de líneas de facturas) +ExtraFieldsSupplierOrdersLines=Campos adicionales (líneas de pedido) +ExtraFieldsSupplierInvoicesLines=Campos adicionales (líneas de factura) +ExtraFieldsThirdParties=Campos adicionales (terceros) +ExtraFieldsContacts=Campos adicionales (contactos/direcciones) +ExtraFieldsMember=Campos adicionales (miembros) +ExtraFieldsMemberType=Campos adicionales (tipos de miembros) +ExtraFieldsCustomerInvoices=Campos adicionales (facturas a clientes) +ExtraFieldsCustomerInvoicesRec=Campos adicionales (plantillas de facturas) +ExtraFieldsSupplierOrders=Campos adicionales (pedidos a proveedores) +ExtraFieldsSupplierInvoices=Campos adicionales (facturas) +ExtraFieldsProject=Campos adicionales (proyectos) +ExtraFieldsProjectTask=Campos adicionales (tareas) +ExtraFieldHasWrongValue=El campo %s tiene un valor no válido AlphaNumOnlyLowerCharsAndNoSpace=sólo alfanuméricos y minúsculas sin espacio SendmailOptionNotComplete=Atención, en algunos sistemas Linux, con este método de envio, para poder enviar mails en su nombre, la configuración de sendmail debe contener la opción -ba (parámetro mail.force_extra_parameters en el archivo php.ini). Si algunos de sus destinatarios no reciben sus mensajes, pruebe a modificar este parámetro PHP con mail.force_extra_parameters=-ba. PathToDocuments=Rutas de acceso a documentos @@ -1303,17 +1305,17 @@ LDAPContactDnExample=DN completo (ej: ou=contacts,dc=example,dc=com) LDAPMemberDn=DN de los miembros LDAPMemberDnExample=DN completo (ex: ou=members,dc=society,dc=com) LDAPMemberObjectClassList=Lista de objectClass -LDAPMemberObjectClassListExample=Lista de ObjectClass que definen los atributos de un registro (ej: top,inetOrgPerson o top,user for active directory) +LDAPMemberObjectClassListExample=Lista de ObjectClass que definen los atributos de un registro (ej: top,inetOrgPerson o top,user para active directory) LDAPMemberTypeDn=Tipos DN de miembros de Dolibar LDAPMemberTypepDnExample=DN completo (por ejemplo, ou=memberstypes, dc=example, dc=com) LDAPMemberTypeObjectClassList=Lista de objectClass LDAPMemberTypeObjectClassListExample=Lista de ObjectClass que definen los atributos de un registro (ej: top,groupOfUniqueNames) LDAPUserObjectClassList=Lista de objectClass -LDAPUserObjectClassListExample=Lista de ObjectClass que definen los atributos de un registro (ej: top,inetOrgPerson o top,user for active directory) +LDAPUserObjectClassListExample=Lista de ObjectClass que definen los atributos de un registro (ej: top,inetOrgPerson o top,user para active directory) LDAPGroupObjectClassList=Lista de objectClass LDAPGroupObjectClassListExample=Lista de ObjectClass que definen los atributos de un registro (ej: top,groupOfUniqueNames) LDAPContactObjectClassList=Lista de objectClass -LDAPContactObjectClassListExample=Lista de objectClass que definen los atributos de un registro (ej: top,inetOrgPerson o top,user for active directory) +LDAPContactObjectClassListExample=Lista de objectClass que definen los atributos de un registro (ej: top,inetOrgPerson o top,user para active directory) LDAPTestConnect=Probar la conexión LDAP LDAPTestSynchroContact=Probar la sincronización de contactos LDAPTestSynchroUser=Probar la sincronización de usuarios @@ -1728,21 +1730,21 @@ SeeSubstitutionVars=Vea * nota para un listado de posibles variables de sustituc SeeChangeLog=Ver archivo ChangeLog (solo inglés) AllPublishers=Todos los editores UnknownPublishers=Editores desconocidos -AddRemoveTabs=Añadir o eliminar pestañas -AddDataTables=Añadir tablas de objetos -AddDictionaries=Añadir diccionarios -AddData=Agregar objetos o datos de diccionarios -AddBoxes=Añadir paneles -AddSheduledJobs=Añadir tareas programadas -AddHooks=Añadir hooks -AddTriggers=Añadir triggers -AddMenus=Añadir menús -AddPermissions=Añadir permisos -AddExportProfiles=Añadir perfiles de exportación -AddImportProfiles=Añadir perfiles de importación -AddOtherPagesOrServices=Añadir otras páginas o servicios -AddModels=Añadir modelos de documentos o numeración -AddSubstitutions=Añadir substituciones de claves +AddRemoveTabs=Añade o elimina pestañas +AddDataTables=Añade tablas de objetos +AddDictionaries=Añade diccionarios +AddData=Añade objetos o datos de diccionarios +AddBoxes=Añade paneles +AddSheduledJobs=Añade tareas programadas +AddHooks=Añade hooks +AddTriggers=Añade triggers +AddMenus=Añade menús +AddPermissions=Añade permisos +AddExportProfiles=Añade perfiles de exportación +AddImportProfiles=Añade perfiles de importación +AddOtherPagesOrServices=Añade otras páginas o servicios +AddModels=Añade modelos de documentos o numeración +AddSubstitutions=Añade substituciones de claves DetectionNotPossible=No es posible la detección UrlToGetKeyToUseAPIs=Url para conseguir token para usar la API (una vez recibido el token se guarda en la tabla de usuarios de la base de datos y se debe proporcionar en cada llamada API) ListOfAvailableAPIs=Listado de APIs disponibles diff --git a/htdocs/langs/es_ES/bills.lang b/htdocs/langs/es_ES/bills.lang index 7cf978aba75..2ece66711c7 100644 --- a/htdocs/langs/es_ES/bills.lang +++ b/htdocs/langs/es_ES/bills.lang @@ -178,7 +178,7 @@ ConfirmCancelBillQuestion=¿Porqué quiere clasificar esta factura como 'abandon ConfirmClassifyPaidPartially=¿Está seguro de querer cambiar el estado de la factura %s a pagado? ConfirmClassifyPaidPartiallyQuestion=Esta factura no ha sido pagado completamente. ¿Cual es la razón para cerrar esta factura? ConfirmClassifyPaidPartiallyReasonAvoir=El resto a pagar (%s %s) es un descuento otorgado por pronto pago. Regularizaré el IVA con un abono. -ConfirmClassifyPaidPartiallyReasonDiscount=Remaining unpaid (%s %s) is a discount granted because payment was made before term. +ConfirmClassifyPaidPartiallyReasonDiscount=El resto a pagar (%s%s) es un descuento otorgado por pronto pago. ConfirmClassifyPaidPartiallyReasonDiscountNoVat=El resto a pagar (%s %s) es un descuento otorgado por pronto pago. Acepto perder el IVA en este descuento. ConfirmClassifyPaidPartiallyReasonDiscountVat=El resto a pagar (%s %s) es un descuento otorgado por pronto pago. Recuperaré el IVA sin usar un abono. ConfirmClassifyPaidPartiallyReasonBadCustomer=Cliente moroso diff --git a/htdocs/langs/es_ES/categories.lang b/htdocs/langs/es_ES/categories.lang index 9d83ca86817..6a834e36fea 100644 --- a/htdocs/langs/es_ES/categories.lang +++ b/htdocs/langs/es_ES/categories.lang @@ -78,7 +78,7 @@ CatCusLinks=Enlaces entre clientes/clientes potenciales y etiquetas/categorías CatProdLinks=Enlaces entre productos/servicios y etiquetas/categorías CatProJectLinks=Enlaces entre proyectos y etiquetas/categorías DeleteFromCat=Eliminar de la etiqueta/categoría -ExtraFieldsCategories=Atributos complementarios +ExtraFieldsCategories=Campos adicionales CategoriesSetup=Configuración de etiquetas/categorías CategorieRecursiv=Enlazar con la etiqueta/categoría automáticamente CategorieRecursivHelp=Si está activado, el producto se enlazará a la categoría padre si lo añadimos a una subcategoría diff --git a/htdocs/langs/es_ES/companies.lang b/htdocs/langs/es_ES/companies.lang index 98fcc553b0d..d70114dacae 100644 --- a/htdocs/langs/es_ES/companies.lang +++ b/htdocs/langs/es_ES/companies.lang @@ -374,9 +374,9 @@ ContactNotLinkedToCompany=Contacto no vinculado a un tercero DolibarrLogin=Login usuario NoDolibarrAccess=Sin acceso de usuario ExportDataset_company_1=Terceros (Empresas / asociaciones / particulares) y propiedades -ExportDataset_company_2=Contactos de terceros y atributos +ExportDataset_company_2=Contactos de terceros y campos adicionales ImportDataset_company_1=Terceros (Empresas / asociaciones / particulares) y propiedades -ImportDataset_company_2=Contactos/Direcciones (de terceros o no) y atributos +ImportDataset_company_2=Contactos/Direcciones (de terceros o no) y campos adicionales ImportDataset_company_3=Cuentas bancarias ImportDataset_company_4=Terceros/Comerciales (Afecta a los usuarios comerciales de terceros) PriceLevel=Nivel de precios diff --git a/htdocs/langs/es_ES/compta.lang b/htdocs/langs/es_ES/compta.lang index 18eb89f6dbd..277c8f8fcf5 100644 --- a/htdocs/langs/es_ES/compta.lang +++ b/htdocs/langs/es_ES/compta.lang @@ -24,7 +24,7 @@ PaymentsNotLinkedToInvoice=Pagos vinculados a ninguna factura, por lo que ningu PaymentsNotLinkedToUser=Pagos no vinculados a un usuario Profit=Beneficio AccountingResult=Resultado contable -BalanceBefore=Balance (before) +BalanceBefore=Balance (antes) Balance=Saldo Debit=Debe Credit=Haber diff --git a/htdocs/langs/es_ES/donations.lang b/htdocs/langs/es_ES/donations.lang index fddc435971d..0b6c7d207f3 100644 --- a/htdocs/langs/es_ES/donations.lang +++ b/htdocs/langs/es_ES/donations.lang @@ -31,4 +31,4 @@ DONATION_ART200=Mostrar artículo 200 del CGI si se está interesado DONATION_ART238=Mostrar artículo 238 del CGI si se está interesado DONATION_ART885=Mostrar artículo 885 del CGI si se está interesado DonationPayment=Pago de donación -DonationValidated=Donation %s validated +DonationValidated=Donación %s validada diff --git a/htdocs/langs/es_ES/languages.lang b/htdocs/langs/es_ES/languages.lang index d460b1e968f..ec9b14b68fc 100644 --- a/htdocs/langs/es_ES/languages.lang +++ b/htdocs/langs/es_ES/languages.lang @@ -35,7 +35,7 @@ Language_es_PA=Español (Panamá) Language_es_PY=Español (Paraguay) Language_es_PE=Español (Perú) Language_es_PR=Español (Puerto Rico) -Language_es_UY=Spanish (Uruguay) +Language_es_UY=Español (Uruguay) Language_es_VE=Español (Venezuela) Language_et_EE=Estonio Language_eu_ES=Vasco diff --git a/htdocs/langs/es_ES/main.lang b/htdocs/langs/es_ES/main.lang index 729daa6ebcf..310a4b5dd6c 100644 --- a/htdocs/langs/es_ES/main.lang +++ b/htdocs/langs/es_ES/main.lang @@ -722,8 +722,8 @@ After=Después IPAddress=Dirección IP Frequency=Frecuencia IM=Mensajería instantánea -NewAttribute=Nuevo atributo -AttributeCode=Código atributo +NewAttribute=Nuevo campo +AttributeCode=Código URLPhoto=Url de la foto/logo SetLinkToAnotherThirdParty=Vincular a otro tercero LinkTo=Enlazar a @@ -885,7 +885,7 @@ Select2NotFound=No se han encontrado registros Select2Enter=Introducir Select2MoreCharacter=o más caracteres Select2MoreCharacters=o más caracteres -Select2MoreCharactersMore=Sintaxis de búsqueda:
| OR (a|b)
* Cualquier caracter (a*b)
^Empezar con (^ab)
$Terminar con (ab$)
+Select2MoreCharactersMore=Sintaxis de búsqueda:
| O (a|b)
* Cualquier carácter (a*b)
^ Empieza con (^ab)
$ Termina con (ab$)
Select2LoadingMoreResults=Cargando más resultados... Select2SearchInProgress=Búsqueda en progreso... SearchIntoThirdparties=Terceros @@ -912,5 +912,5 @@ CommentPage=Espacio de comentarios CommentAdded=Comentario añadido CommentDeleted=Comentario borrado Everybody=Proyecto compartido -PayedBy=Payed by -PayedTo=Payed to +PayedBy=Pagado por +PayedTo=Pagado a diff --git a/htdocs/langs/es_ES/modulebuilder.lang b/htdocs/langs/es_ES/modulebuilder.lang index 6be47b732bf..188887b7a06 100644 --- a/htdocs/langs/es_ES/modulebuilder.lang +++ b/htdocs/langs/es_ES/modulebuilder.lang @@ -43,6 +43,8 @@ PathToModulePackage=Ruta al zip del módulo/aplicación PathToModuleDocumentation=Ruta a la documentación del módulo/aplicación SpaceOrSpecialCharAreNotAllowed=Espacios o caracteres especiales no son permitidos. FileNotYetGenerated=Fichero todavía no generado +RegenerateClassAndSql=Borrar y regenerar archivos de clase y sql +RegenerateMissingFiles=Generar archivos no encontrados SpecificationFile=Fichero con las reglas de negocio LanguageFile=Archivo para el idioma ConfirmDeleteProperty=¿Estás seguro que quieres eliminar la propiedad %s? Esto cambiará código en la clase PHP pero también eliminará la columna de la definición de la tabla del objeto. diff --git a/htdocs/langs/es_ES/multicurrency.lang b/htdocs/langs/es_ES/multicurrency.lang index dba8d088ca5..493c5f400a5 100644 --- a/htdocs/langs/es_ES/multicurrency.lang +++ b/htdocs/langs/es_ES/multicurrency.lang @@ -7,7 +7,7 @@ multicurrency_syncronize_error=Error sincronización: %s MULTICURRENCY_USE_RATE_ON_DOCUMENT_DATE=Usar fecha del documento para encontrar la tasa de la divisa, en lugar de usar la última tasa conocida multicurrency_useOriginTx=Cuando un objeto se crea desde otro, mantenga la conversión original del objeto de origen (de lo contrario, utilice la tasa de conversión más reciente conocida) CurrencyLayerAccount=CurrencyLayer API -CurrencyLayerAccount_help_to_synchronize=Debe crear una cuenta en su sitio web para utilizar esta función.
Obtenga su clave API
Si utiliza una cuenta gratuita, no puede cambiar la divisa origen (USD por defecto)
. Pero si su divisa principal no es USD, puede usar la divisa origen alternativa para forzar su divisa principal.

Está limitado a 1000 sincronizaciones por mes +CurrencyLayerAccount_help_to_synchronize=Debe crear una cuenta en su sitio web para usar esta funcionalidad
Obtenga su Clave API
Si usa una cuenta gratuita no puede cambiar la moneda origen (por defecto USD)
Pero si su moneda principal no es USD puede usar la moneda origen alternativa para forzar su moneda principal

Estará limitado a 1000 sincronizaciones por mes multicurrency_appId=Clave API multicurrency_appCurrencySource=Divisa origen multicurrency_alternateCurrencySource=Divisa origen alternativa diff --git a/htdocs/langs/es_ES/other.lang b/htdocs/langs/es_ES/other.lang index 2646aea5291..99dfadd2d7d 100644 --- a/htdocs/langs/es_ES/other.lang +++ b/htdocs/langs/es_ES/other.lang @@ -162,9 +162,9 @@ SizeUnitinch=pulgada SizeUnitfoot=pie SizeUnitpoint=punto BugTracker=Incidencias -SendNewPasswordDesc=Este formulario le permite solicitar una nueva contraseña. Se le enviará a su dirección de e-mail.
El cambio se hará efectivo una vez que haga clic en el enlace de confirmación en el e-mail.
Compruebe su bandeja de entrada. +SendNewPasswordDesc=Este formulario le permite obtener una nueva contraseña. Le será enviada a su e-mail.
El cambio será efectivo una vez haga clic en el enlace de confirmación del e-mail.
Revise su e-mail. BackToLoginPage=Volver a la página de conexión -AuthenticationDoesNotAllowSendNewPassword=El modo de autenticación es %s.
En este modo, Dolibarr no conoce ni cambia su contraseña.
Póngase en contacto con el administrador del sistema si desea cambiar su contraseña. +AuthenticationDoesNotAllowSendNewPassword=El modo de autentificación de Dolibarr está configurado como "%s".
En este modo Dolibarr no puede conocer ni modificar su contraseña
Contacte con su administrador para conocer las modalidades de cambio. EnableGDLibraryDesc=Instale o active la libreria GD en su PHP para poder usar esta opción ProfIdShortDesc=Prof Id %s es una información dependiente del país del tercero.
Por ejemplo, para el país %s, és el código %s. DolibarrDemo=Demo de Dolibarr ERP/CRM diff --git a/htdocs/langs/es_ES/printing.lang b/htdocs/langs/es_ES/printing.lang index 352718f6cb9..f9735557d02 100644 --- a/htdocs/langs/es_ES/printing.lang +++ b/htdocs/langs/es_ES/printing.lang @@ -49,4 +49,6 @@ DirectPrintingJobsDesc=Esta página lista los trabajos encontrados en las impres GoogleAuthNotConfigured=Configuración de Google OAuth no realizada. Habilite el módulo de OAuth y establezca un Google ID / Secreto. GoogleAuthConfigured=Las credenciales OAuth de Google se encuentran en la configuración del módulo OAuth. PrintingDriverDescprintgcp=Configuración variables del driver de impresión Google Cloud Print. +PrintingDriverDescprintipp=Configuración variables para el driver de impresión Cups. PrintTestDescprintgcp=Listado de impresoras para Google Cloud Print. +PrintTestDescprintipp=Listado de Impresoras para Cups. diff --git a/htdocs/langs/es_ES/products.lang b/htdocs/langs/es_ES/products.lang index 394aa9e6be1..7234df78d8e 100644 --- a/htdocs/langs/es_ES/products.lang +++ b/htdocs/langs/es_ES/products.lang @@ -239,7 +239,7 @@ MinimumRecommendedPrice=El precio mínimo recomendado es: %s PriceExpressionEditor=Editor de expresión de precios PriceExpressionSelected=Expresión de precios seleccionada PriceExpressionEditorHelp1="price = 2 + 2" o "2 + 2" para configurar un precio. Use ; para separar expresiones -PriceExpressionEditorHelp2=Puede acceder a los atributos adicionales con variables como #extrafield_myextrafieldkey# y variables globales con #global_mycode# +PriceExpressionEditorHelp2=Puede acceder a los campos adicionales con variables como #extrafield_myextrafieldkey# y variables globales con #global_mycode# PriceExpressionEditorHelp3=En productos y servicios, y precios de proveedor están disponibles las siguientes variables
#tva_tx# #localtax1_tx# #localtax2_tx# #weight# #length# #surface# #price_min# PriceExpressionEditorHelp4=Solamente en los precios de productos y servicios: #supplier_min_price#
In supplier prices only: #supplier_quantity# and #supplier_tva_tx# PriceExpressionEditorHelp5=Valores globales disponibles: diff --git a/htdocs/langs/es_ES/users.lang b/htdocs/langs/es_ES/users.lang index daddb0fcf66..f089a880b64 100644 --- a/htdocs/langs/es_ES/users.lang +++ b/htdocs/langs/es_ES/users.lang @@ -63,7 +63,7 @@ CreateDolibarrThirdParty=Crear un tercero LoginAccountDisableInDolibarr=La cuenta está desactivada en Dolibarr UsePersonalValue=Utilizar valores personalizados InternalUser=Usuario interno -ExportDataset_user_1=Usuarios Dolibarr y atributos +ExportDataset_user_1=Usuarios Dolibarr y campos adicionales DomainUser=Usuario de dominio Reactivate=Reactivar CreateInternalUserDesc=Este formulario le permite crear un usuario interno para su empresa/asociación. Para crear un usuario externo (cliente, proveedor, etc), use el botón "Crear una cuenta de usuario" desde una ficha de un contacto del tercero. diff --git a/htdocs/langs/es_ES/website.lang b/htdocs/langs/es_ES/website.lang index 38a2155f292..14f1f3c2083 100644 --- a/htdocs/langs/es_ES/website.lang +++ b/htdocs/langs/es_ES/website.lang @@ -41,7 +41,7 @@ VirtualHostUrlNotDefined=URL del Host Virtual servido por un servidor externo no NoPageYet=No hay páginas todavía SyntaxHelp=Ayuda en la sintaxis del código YouCanEditHtmlSourceckeditor=Puede editar código fuente HTML utilizando el botón "Origen" en el editor. -YouCanEditHtmlSource=Puede editar el código fuente HTML usando el botón "Origen" en el editor. También puede incluir código PHP en esta fuente mediante etiquetas <?php ?>. Las siguientes variables globales están disponibles: $conf, $langs, $db, $mysoc, $user, $website.

También puede incluir contenido de otra Página/Contenedor con la siguiente sintaxis: <?php dolIncludeHtmlContent ($websitekey. '/contentaliastoinclude.php'); ?>

Para incluir un vínculo para descargar un archivo almacenado en el directorio de documentos/medios, utilice la sintaxis:
<a href="/document.php?modulepart=medias&file=filename.ext". +YouCanEditHtmlSource=
Puede incluir código PHP en este fuente usando los tags <?php ?>. Dispone de estas variables globales: $conf, $langs, $db, $mysoc, $user, $website.

También puede incluir contenido de otra Página/Contenedor con la siguiente sintaxis:
<?php includeContainer('alias_of_container_to_include'); ?>

Para incluir un enlace para descargar un archivo guardado en el directorio documents, use el wrapper document.php :
Por ejemplo, para un archivo de documents/ecm (es necesario estar logueado), la sintaxis:
<a href="/document.php?modulepart=ecm&file=[relative_dir/]filename.ext">
Para un archivo de into documents/medias (directorio abierto para acceso público), la sintaxis es:
<a href="/document.php?modulepart=medias&file=[relative_dir/]filename.ext">
Para un archivo compartido mediante un enlace compartido (acceso abierto utilizando la clave hash para compartir del archivo), la sintaxis es:
<a href="/document.php?hashp=publicsharekeyoffile">

Para incluir una imagen guardada en el directorio documents , use el wrapper viewimage.php :
Ejemplo para una imagen de documents/medias (acceso abierto), la sintaxis es:
<a href="/viewimage.php?modulepart=medias&file=[relative_dir/]filename.ext">
ClonePage=Clonar página/contenedor CloneSite=Clonar sitio SiteAdded=Sitio web agregado diff --git a/htdocs/langs/es_ES/withdrawals.lang b/htdocs/langs/es_ES/withdrawals.lang index a8b25e5088e..355380794e6 100644 --- a/htdocs/langs/es_ES/withdrawals.lang +++ b/htdocs/langs/es_ES/withdrawals.lang @@ -26,7 +26,7 @@ LastWithdrawalReceipt=Las %s últimas domiciliaciones MakeWithdrawRequest=Realizar una petición de domiciliación WithdrawRequestsDone=%s domiciliaciones registradas ThirdPartyBankCode=Código banco del tercero -NoInvoiceCouldBeWithdrawed=No se ha domiciliado ninguna factura. Asegúrese de que las facturas son de empresas con los datos de cuentas bancarias correctos. +NoInvoiceCouldBeWithdrawed=No se ha podido realizar la petición de domiciliación de ninguna factura. Compruebe que los terceros de las facturas relacionadas tienen una cuenta IBAN válida y dicho IBAN tiene un RUM con modo %s. ClassCredited=Clasificar como "Abonada" ClassCreditedConfirm=¿Está seguro de querer clasificar esta domiciliación como abonada en su cuenta bancaria? TransData=Fecha envío diff --git a/htdocs/langs/fr_FR/exports.lang b/htdocs/langs/fr_FR/exports.lang index 6cd067822a2..48df77c7641 100644 --- a/htdocs/langs/fr_FR/exports.lang +++ b/htdocs/langs/fr_FR/exports.lang @@ -131,3 +131,7 @@ KeysToUseForUpdates=Clé à utiliser pour mettre à jour les données NbInsert=Nombre de lignes insérées: %s NbUpdate=Nombre de lignes mises à jour: %s MultipleRecordFoundWithTheseFilters=Plusieurs enregistrements ont été trouvés avec ces filtres: %s +## setup page +ExportSetup=Configuration du module Export +ExportModel = Modèle d'export +set_EXPORTS_SHARE_MODELS = Partager tous les profils d'export \ No newline at end of file diff --git a/htdocs/langs/pt_PT/companies.lang b/htdocs/langs/pt_PT/companies.lang index 4875dc8e3de..8f797802925 100644 --- a/htdocs/langs/pt_PT/companies.lang +++ b/htdocs/langs/pt_PT/companies.lang @@ -56,6 +56,7 @@ Address=Direcção State=Distrito StateShort=Estado Region=Região +Region-State=Distrito - Concelho Country=País CountryCode=Código país CountryId=ID país diff --git a/htdocs/modulebuilder/template/core/triggers/interface_99_modMyModule_MyModuleTriggers.class.php b/htdocs/modulebuilder/template/core/triggers/interface_99_modMyModule_MyModuleTriggers.class.php index 62b35bfdf39..e413c969119 100644 --- a/htdocs/modulebuilder/template/core/triggers/interface_99_modMyModule_MyModuleTriggers.class.php +++ b/htdocs/modulebuilder/template/core/triggers/interface_99_modMyModule_MyModuleTriggers.class.php @@ -211,6 +211,7 @@ class InterfaceMyModuleTriggers extends DolibarrTriggers // Contracts case 'CONTRACT_CREATE': case 'CONTRACT_ACTIVATE': + case 'CONTRACT_MODIFY': case 'CONTRACT_CANCEL': case 'CONTRACT_CLOSE': case 'CONTRACT_DELETE': diff --git a/htdocs/modulebuilder/template/mymoduleindex.php b/htdocs/modulebuilder/template/mymoduleindex.php index c6f70b0ba85..8073d31fd60 100644 --- a/htdocs/modulebuilder/template/mymoduleindex.php +++ b/htdocs/modulebuilder/template/mymoduleindex.php @@ -175,7 +175,7 @@ if (! empty($conf->mymodule->enabled) && $user->rights->mymodule->read) $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; if (! $user->rights->societe->client->voir && ! $socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql.= " WHERE s.client IN (1, 2, 3)"; - $sql.= " AND s.entity IN (".getEntity($companystatic->element, 1).")"; + $sql.= " AND s.entity IN (".getEntity($companystatic->element).")"; if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; if ($socid) $sql.= " AND s.rowid = $socid"; $sql .= " ORDER BY s.tms DESC"; diff --git a/htdocs/product/card.php b/htdocs/product/card.php index a54f1d90885..861c46328df 100644 --- a/htdocs/product/card.php +++ b/htdocs/product/card.php @@ -1106,11 +1106,11 @@ else print "
'.$langs->trans("Categories").''; $cate_arbo = $form->select_all_categories(Categorie::TYPE_PRODUCT, '', 'parent', 64, 0, 1); - print $form->multiselectarray('categories', $cate_arbo, $arrayselected, '', 0, '', 0, '100%'); + print $form->multiselectarray('categories', $cate_arbo, GETPOST('categories', 'array'), '', 0, '', 0, '100%'); print "
'.$langs->trans("Label").'
'.$langs->trans("Status").''; + print ''; + print '
'.$langs->trans("Status").''.$object->getLibStatut(4).'
'.$langs->trans("OpportunityProbability").' %'; - print ''; - print '
'.$langs->trans("OpportunityProbability").' %'; + print ''; + print '
'.$langs->trans("OpportunityAmount").'
'.$langs->trans("OpportunityAmount").'
'.$langs->trans("DateStart").''; @@ -1205,7 +1213,7 @@ elseif ($object->id > 0) // List of actions on element include_once DOL_DOCUMENT_ROOT . '/core/class/html.formactions.class.php'; $formactions = new FormActions($db); - $somethingshown = $formactions->showactions($object, 'project', $socid, 1, '', $MAXEVENT, '', $morehtmlright); + $somethingshown = $formactions->showactions($object, 'project', 0, 1, '', $MAXEVENT, '', $morehtmlright); print ''; } diff --git a/htdocs/projet/class/project.class.php b/htdocs/projet/class/project.class.php index 7a42e77c644..e24a444702c 100644 --- a/htdocs/projet/class/project.class.php +++ b/htdocs/projet/class/project.class.php @@ -303,16 +303,9 @@ class Project extends CommonObject $resql=$this->db->query($sql); if ($resql) { - if (!$notrigger) + // Update extrafield + if (! $error) { - // Call trigger - $result=$this->call_trigger('PROJECT_MODIFY',$user); - if ($result < 0) { $error++; } - // End call triggers - } - - //Update extrafield - if (!$error) { if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used { $result=$this->insertExtraFields(); @@ -323,6 +316,14 @@ class Project extends CommonObject } } + if (! $error && !$notrigger) + { + // Call trigger + $result=$this->call_trigger('PROJECT_MODIFY',$user); + if ($result < 0) { $error++; } + // End call triggers + } + if (! $error && (is_object($this->oldcopy) && $this->oldcopy->ref !== $this->ref)) { // We remove directory @@ -508,13 +509,13 @@ class Project extends CommonObject } /** - * Return list of elements for type, linked to project + * Return list of elements for type, linked to a project * * @param string $type 'propal','order','invoice','order_supplier','invoice_supplier',... * @param string $tablename name of table associated of the type * @param string $datefieldname name of date field for filter - * @param string $dates Start date (ex 00:00:00) - * @param string $datee End date (ex 23:59:59) + * @param int $dates Start date + * @param int $datee End date * @return mixed Array list of object ids linked to project, < 0 or string if error */ function get_element_list($type, $tablename, $datefieldname='', $dates='', $datee='') @@ -523,29 +524,31 @@ class Project extends CommonObject if ($this->id <= 0) return $elements; + $ids = $this->id; + if ($type == 'agenda') { - $sql = "SELECT id as rowid FROM " . MAIN_DB_PREFIX . "actioncomm WHERE fk_project=" . $this->id; + $sql = "SELECT id as rowid FROM " . MAIN_DB_PREFIX . "actioncomm WHERE fk_project IN (". $ids .")"; } elseif ($type == 'expensereport') { - $sql = "SELECT ed.rowid FROM " . MAIN_DB_PREFIX . "expensereport as e, " . MAIN_DB_PREFIX . "expensereport_det as ed WHERE e.rowid = ed.fk_expensereport AND ed.fk_projet=" . $this->id; + $sql = "SELECT ed.rowid FROM " . MAIN_DB_PREFIX . "expensereport as e, " . MAIN_DB_PREFIX . "expensereport_det as ed WHERE e.rowid = ed.fk_expensereport AND ed.fk_projet IN (". $ids .")"; } elseif ($type == 'project_task') { - $sql = "SELECT DISTINCT pt.rowid FROM " . MAIN_DB_PREFIX . "projet_task as pt, " . MAIN_DB_PREFIX . "projet_task_time as ptt WHERE pt.rowid = ptt.fk_task AND pt.fk_projet=" . $this->id; + $sql = "SELECT DISTINCT pt.rowid FROM " . MAIN_DB_PREFIX . "projet_task as pt, " . MAIN_DB_PREFIX . "projet_task_time as ptt WHERE pt.rowid = ptt.fk_task AND pt.fk_projet IN (". $ids .")"; } elseif ($type == 'project_task_time') // Case we want to duplicate line foreach user { - $sql = "SELECT DISTINCT pt.rowid, ptt.fk_user FROM " . MAIN_DB_PREFIX . "projet_task as pt, " . MAIN_DB_PREFIX . "projet_task_time as ptt WHERE pt.rowid = ptt.fk_task AND pt.fk_projet=" . $this->id; + $sql = "SELECT DISTINCT pt.rowid, ptt.fk_user FROM " . MAIN_DB_PREFIX . "projet_task as pt, " . MAIN_DB_PREFIX . "projet_task_time as ptt WHERE pt.rowid = ptt.fk_task AND pt.fk_projet IN (". $ids .")"; } elseif ($type == 'stock_mouvement') { - $sql = 'SELECT ms.rowid, ms.fk_user_author as fk_user FROM ' . MAIN_DB_PREFIX . 'stock_mouvement as ms WHERE ms.origintype = "project" AND ms.fk_origin = ' . $this->id . ' AND ms.type_mouvement = 1'; + $sql = 'SELECT ms.rowid, ms.fk_user_author as fk_user FROM ' . MAIN_DB_PREFIX . "stock_mouvement as ms WHERE ms.origintype = 'project' AND ms.fk_origin IN (". $ids .") AND ms.type_mouvement = 1"; } else { - $sql = "SELECT rowid FROM " . MAIN_DB_PREFIX . $tablename." WHERE fk_projet=" . $this->id; + $sql = "SELECT rowid FROM " . MAIN_DB_PREFIX . $tablename." WHERE fk_projet IN (". $ids .")"; } if ($dates > 0) diff --git a/htdocs/projet/element.php b/htdocs/projet/element.php index 38a6c8e8c7c..d4829d8e839 100644 --- a/htdocs/projet/element.php +++ b/htdocs/projet/element.php @@ -103,9 +103,9 @@ $socid=$object->socid; //if ($user->societe_id > 0) $socid = $user->societe_id; // For external user, no check is done on company because readability is managed by public status of project and assignement. $result = restrictedArea($user, 'projet', $projectid, 'projet&project'); - $hookmanager->initHooks(array('projectOverview')); + /* * View */ @@ -470,7 +470,7 @@ $listofreferent=array( ); $parameters=array('listofreferent'=>$listofreferent); -$resHook = $hookmanager->executeHooks('completeListOfReferent',$parameters,$object,$action); +$resHook = $hookmanager->executeHooks('completeListOfReferent', $parameters, $object, $action); if(!empty($hookmanager->resArray)) { diff --git a/htdocs/public/members/new.php b/htdocs/public/members/new.php index 6a5fcbdfc62..978c646a524 100644 --- a/htdocs/public/members/new.php +++ b/htdocs/public/members/new.php @@ -26,7 +26,7 @@ * * Note that you can add following constant to change behaviour of page * MEMBER_NEWFORM_AMOUNT Default amount for auto-subscribe form - * MEMBER_NEWFORM_EDITAMOUNT Amount can be edited + * MEMBER_NEWFORM_EDITAMOUNT 0 or 1 = Amount can be edited * MEMBER_NEWFORM_PAYONLINE Suggest payment with paypal, paybox or stripe * MEMBER_NEWFORM_DOLIBARRTURNOVER Show field turnover (specific for dolibarr foundation) * MEMBER_URL_REDIRECT_SUBSCRIPTION Url to redirect once subscribe submitted diff --git a/htdocs/public/paybox/newpayment.php b/htdocs/public/paybox/newpayment.php index c386dc7e84e..bd27554c500 100644 --- a/htdocs/public/paybox/newpayment.php +++ b/htdocs/public/paybox/newpayment.php @@ -155,7 +155,7 @@ if (! empty($conf->global->PAYMENT_SECURITY_TOKEN)) if (GETPOST('action','aZ09') == 'dopayment') { - $PRICE=price2num(GETPOST("newamount"),'MT'); + $PRICE=price2num(GETPOST("newamount",'alpha'),'MT'); $email=GETPOST("email"); $origfulltag=GETPOST("fulltag",'alpha'); @@ -275,7 +275,7 @@ print $text; // Output payment summary form print '
'; print ''; -print ''."\n"; +print ''."\n"; $found=false; $error=0; @@ -305,7 +305,7 @@ if (! GETPOST("source") && $valid) if (empty($amount) || ! is_numeric($amount)) { print ''; - print ''; + print ''; } else { print ''.price($amount).''; @@ -321,7 +321,7 @@ if (! GETPOST("source") && $valid) // Tag print ''."\n"; @@ -392,7 +392,7 @@ if (GETPOST("source") == 'order' && $valid) if (empty($amount) || ! is_numeric($amount)) { print ''; - print ''; + print ''; } else { print ''.price($amount).''; @@ -407,7 +407,7 @@ if (GETPOST("source") == 'order' && $valid) // Tag print ''."\n"; @@ -480,7 +480,7 @@ if (GETPOST("source") == 'invoice' && $valid) if (empty($amount) || ! is_numeric($amount)) { print ''; - print ''; + print ''; } else { print ''.price($amount).''; @@ -495,7 +495,7 @@ if (GETPOST("source") == 'invoice' && $valid) // Tag print ''."\n"; @@ -656,7 +656,7 @@ if (GETPOST("source") == 'contractline' && $valid) if (empty($amount) || ! is_numeric($amount)) { print ''; - print ''; + print ''; } else { print ''.price($amount).''; @@ -671,7 +671,7 @@ if (GETPOST("source") == 'contractline' && $valid) // Tag print ''."\n"; @@ -754,7 +754,7 @@ if (GETPOST("source") == 'membersubscription' && $valid) print ''."\n"; - if (empty($amount) && ! GETPOST('newamount')) $_GET['newamount']=$member->last_subscription_amount; + if (empty($amount) && ! GETPOST('newamount','alpha')) $_GET['newamount']=$member->last_subscription_amount; } // Amount @@ -762,12 +762,31 @@ if (GETPOST("source") == 'membersubscription' && $valid) print ''."\n"; diff --git a/htdocs/public/paybox/paymentok.php b/htdocs/public/paybox/paymentok.php index e3812c28dc1..63c15b035f2 100644 --- a/htdocs/public/paybox/paymentok.php +++ b/htdocs/public/paybox/paymentok.php @@ -126,6 +126,7 @@ $result=$interface->run_triggers('PAYBOX_PAYMENT_OK',$object,$user,$langs,$conf) if ($result < 0) { $error++; $errors=$interface->errors; } // Fin appel triggers +$tmptag=dolExplodeIntoArray($fulltag,'.','='); // Send an email if (! empty($conf->global->ONLINE_PAYMENT_SENDEMAIL)) @@ -152,7 +153,6 @@ if (! empty($conf->global->ONLINE_PAYMENT_SENDEMAIL)) $urlback=$_SERVER["REQUEST_URI"]; $topic='['.$appli.'] '.$langs->transnoentitiesnoconv("NewOnlinePaymentReceived"); - $tmptag=dolExplodeIntoArray($fulltag,'.','='); $content=""; if (! empty($tmptag['MEM'])) { diff --git a/htdocs/public/payment/newpayment.php b/htdocs/public/payment/newpayment.php index 3f2c2979e00..74ffcfd120a 100644 --- a/htdocs/public/payment/newpayment.php +++ b/htdocs/public/payment/newpayment.php @@ -268,7 +268,7 @@ if ($action == 'dopayment') { if ($paymentmethod == 'paypal') { - $PAYPAL_API_PRICE=price2num(GETPOST("newamount"),'MT'); + $PAYPAL_API_PRICE=price2num(GETPOST("newamount",'alpha'),'MT'); $PAYPAL_PAYMENT_TYPE='Sale'; $origfulltag=GETPOST("fulltag",'alpha'); @@ -366,7 +366,7 @@ if ($action == 'dopayment') if ($paymentmethod == 'stripe') { - if (GETPOST('newamount')) $amount = GETPOST('newamount'); + if (GETPOST('newamount','alpha')) $amount = price2num(GETPOST('newamount','alpha'),'MT'); else { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Amount")), null, 'errors'); @@ -647,7 +647,7 @@ if (! $source) if (empty($amount) || ! is_numeric($amount)) { print ''; - print ''; + print ''; } else { print ''.price($amount).''; @@ -661,7 +661,7 @@ if (! $source) // Tag print ''."\n"; @@ -738,7 +738,7 @@ if ($source == 'order') if (empty($amount) || ! is_numeric($amount)) { print ''; - print ''; + print ''; } else { print ''.price($amount).''; @@ -752,7 +752,7 @@ if ($source == 'order') // Tag print ''."\n"; @@ -858,7 +858,7 @@ if ($source == 'invoice') if (empty($amount) || ! is_numeric($amount)) { print ''; - print ''; + print ''; } else { print ''.price($amount).''; @@ -877,7 +877,7 @@ if ($source == 'invoice') // Tag print ''."\n"; @@ -1079,7 +1079,7 @@ if ($source == 'contractline') if (empty($amount) || ! is_numeric($amount)) { print ''; - print ''; + print ''; } else { print ''.price($amount).''; @@ -1093,7 +1093,7 @@ if ($source == 'contractline') // Tag print ''."\n"; @@ -1202,7 +1202,7 @@ if ($source == 'membersubscription') print ''."\n"; - if (empty($amount) && ! GETPOST('newamount')) $_GET['newamount']=$member->last_subscription_amount; + if (empty($amount) && ! GETPOST('newamount','alpha')) $_GET['newamount']=$member->last_subscription_amount; } // Amount @@ -1215,27 +1215,31 @@ if ($source == 'membersubscription') if (empty($conf->global->MEMBER_NEWFORM_AMOUNT)) print ')'; } print ''."\n"; diff --git a/htdocs/public/payment/paymentok.php b/htdocs/public/payment/paymentok.php index 7ccd95abcdf..d74305890df 100644 --- a/htdocs/public/payment/paymentok.php +++ b/htdocs/public/payment/paymentok.php @@ -188,7 +188,7 @@ if (! empty($conf->paypal->enabled)) if ($PAYPALTOKEN) { // Get on url call - $onlinetoken = $PAYPALTOKEN; + $onlinetoken = $PAYPALTOKEN; $fulltag = $FULLTAG; $payerID = $PAYPALPAYERID; // Set by newpayment.php @@ -291,6 +291,8 @@ if ($ispaymentok) $sendemail = ''; if (! empty($conf->global->ONLINE_PAYMENT_SENDEMAIL)) $sendemail=$conf->global->ONLINE_PAYMENT_SENDEMAIL; + $tmptag=dolExplodeIntoArray($fulltag,'.','='); + // Send an email if ($sendemail) { @@ -316,7 +318,6 @@ if ($ispaymentok) $urlback=$_SERVER["REQUEST_URI"]; $topic='['.$appli.'] '.$langs->transnoentitiesnoconv("NewOnlinePaymentReceived"); - $tmptag=dolExplodeIntoArray($fulltag,'.','='); $content=""; if (! empty($tmptag['MEM'])) { @@ -388,6 +389,8 @@ else if ($paymentmethod == 'paybox' && ! empty($conf->global->PAYBOX_PAYONLINE_SENDEMAIL)) $sendemail=$conf->global->PAYBOX_PAYONLINE_SENDEMAIL; if ($paymentmethod == 'stripe' && ! empty($conf->global->STRIPE_PAYONLINE_SENDEMAIL)) $sendemail=$conf->global->STRIPE_PAYONLINE_SENDEMAIL; + $tmptag=dolExplodeIntoArray($fulltag,'.','='); + // Send an email if ($sendemail) { diff --git a/htdocs/public/paypal/newpayment.php b/htdocs/public/paypal/newpayment.php index 2bb58e4b676..b1ecfa43803 100644 --- a/htdocs/public/paypal/newpayment.php +++ b/htdocs/public/paypal/newpayment.php @@ -192,7 +192,7 @@ if (! empty($conf->global->PAYPAL_SECURITY_TOKEN)) if (GETPOST('action','aZ09') == 'dopayment') { - $PAYPAL_API_PRICE=price2num(GETPOST("newamount"),'MT'); + $PAYPAL_API_PRICE=price2num(GETPOST("newamount",'alpha'),'MT'); $PAYPAL_PAYMENT_TYPE='Sale'; $origfulltag=GETPOST("fulltag",'alpha'); @@ -361,7 +361,7 @@ print $text; // Output payment summary form print '
'.$langs->trans("ThisIsInformationOnPayment").' :
'.$langs->trans("ThisIsInformationOnPayment").' :
'.$langs->trans("PaymentCode"); - print ''.$fulltag.''; + print ''.$fulltag.''; print ''; print ''; print '
'.$langs->trans("PaymentCode"); - print ''.$fulltag.''; + print ''.$fulltag.''; print ''; print ''; print '
'.$langs->trans("PaymentCode"); - print ''.$fulltag.''; + print ''.$fulltag.''; print ''; print ''; print '
'.$langs->trans("PaymentCode"); - print ''.$fulltag.''; + print ''.$fulltag.''; print ''; print ''; print '
'.price($member->last_subscription_amount); print '
'.$langs->trans("Amount"); if (empty($amount)) print ' ('.$langs->trans("ToComplete").')'; print ''; + $valtoshow=''; if (empty($amount) || ! is_numeric($amount)) { - $valtoshow=GETPOST("newamount",'int'); + $valtoshow=price2num(GETPOST("newamount",'alpha'),'MT'); + // force default subscription amount to value defined into constant... + if (empty($valtoshow)) + { + if (! empty($conf->global->MEMBER_NEWFORM_EDITAMOUNT)) { + if (! empty($conf->global->MEMBER_NEWFORM_AMOUNT)) { + $valtoshow = $conf->global->MEMBER_NEWFORM_AMOUNT; + } + } + else { + if (! empty($conf->global->MEMBER_NEWFORM_AMOUNT)) { + $amount = $conf->global->MEMBER_NEWFORM_AMOUNT; + } + } + } + } + if (empty($amount) || ! is_numeric($amount)) + { + //$valtoshow=price2num(GETPOST("newamount",'alpha'),'MT'); if (! empty($conf->global->MEMBER_MIN_AMOUNT) && $valtoshow) $valtoshow=max($conf->global->MEMBER_MIN_AMOUNT,$valtoshow); print ''; - print ''; + print ''; } else { $valtoshow=$amount; @@ -784,7 +803,7 @@ if (GETPOST("source") == 'membersubscription' && $valid) // Tag print '
'.$langs->trans("PaymentCode"); - print ''.$fulltag.''; + print ''.$fulltag.''; print ''; print ''; print '
'.$langs->trans("PaymentCode"); - print ''.$fulltag.''; + print ''.$fulltag.''; print ''; print ''; print '
'.$langs->trans("PaymentCode"); - print ''.$fulltag.''; + print ''.$fulltag.''; print ''; print ''; print '
'.$langs->trans("PaymentCode"); - print ''.$fulltag.''; + print ''.$fulltag.''; print ''; print ''; print '
'.$langs->trans("PaymentCode"); - print ''.$fulltag.''; + print ''.$fulltag.''; print ''; print ''; print '
'.price($member->last_subscription_amount); print '
'; + $valtoshow=''; if (empty($amount) || ! is_numeric($amount)) { - $valtoshow=GETPOST("newamount",'int'); + $valtoshow=price2num(GETPOST("newamount",'alpha'),'MT'); // force default subscription amount to value defined into constant... - if (! empty($conf->global->MEMBER_NEWFORM_EDITAMOUNT)) { - if (! empty($conf->global->MEMBER_NEWFORM_AMOUNT)) { - $valtoshow = $conf->global->MEMBER_NEWFORM_AMOUNT; + if (empty($valtoshow)) + { + if (! empty($conf->global->MEMBER_NEWFORM_EDITAMOUNT)) { + if (! empty($conf->global->MEMBER_NEWFORM_AMOUNT)) { + $valtoshow = $conf->global->MEMBER_NEWFORM_AMOUNT; + } } - } - else { - if (! empty($conf->global->MEMBER_NEWFORM_AMOUNT)) { - $amount = $conf->global->MEMBER_NEWFORM_AMOUNT; + else { + if (! empty($conf->global->MEMBER_NEWFORM_AMOUNT)) { + $amount = $conf->global->MEMBER_NEWFORM_AMOUNT; + } } } } if (empty($amount) || ! is_numeric($amount)) { - //$valtoshow=GETPOST("newamount",'int'); + //$valtoshow=price2num(GETPOST("newamount",'alpha'),'MT'); if (! empty($conf->global->MEMBER_MIN_AMOUNT) && $valtoshow) $valtoshow=max($conf->global->MEMBER_MIN_AMOUNT,$valtoshow); print ''; - print ''; + print ''; } else { $valtoshow=$amount; @@ -1252,7 +1256,7 @@ if ($source == 'membersubscription') // Tag print '
'.$langs->trans("PaymentCode"); - print ''.$fulltag.''; + print ''.$fulltag.''; print ''; print ''; print '
'; print ''; -print ''."\n"; +print ''."\n"; $found=false; $error=0; @@ -375,21 +375,19 @@ if (! GETPOST("source")) $fulltag=$tag; // Creditor - print ''."\n"; // Amount - print ''."\n"; // Tag - print ''."\n"; @@ -475,7 +472,7 @@ if (GETPOST("source") == 'order') if (empty($amount) || ! is_numeric($amount)) { print ''; - print ''; + print ''; } else { print ''.price($amount).''; @@ -490,7 +487,7 @@ if (GETPOST("source") == 'order') // Tag print ''."\n"; @@ -585,7 +582,7 @@ if (GETPOST("source") == 'invoice') if (empty($amount) || ! is_numeric($amount)) { print ''; - print ''; + print ''; } else { print ''.price($amount).''; @@ -600,7 +597,7 @@ if (GETPOST("source") == 'invoice') // Tag print ''."\n"; @@ -783,7 +780,7 @@ if (GETPOST("source") == 'contractline') if (empty($amount) || ! is_numeric($amount)) { print ''; - print ''; + print ''; } else { print ''.price($amount).''; @@ -798,7 +795,7 @@ if (GETPOST("source") == 'contractline') // Tag print ''."\n"; @@ -902,7 +899,7 @@ if (GETPOST("source") == 'membersubscription') print ''."\n"; - if (empty($amount) && ! GETPOST('newamount')) $_GET['newamount']=$member->last_subscription_amount; + if (empty($amount) && ! GETPOST('newamount','alpha')) $_GET['newamount']=$member->last_subscription_amount; } // Amount @@ -915,12 +912,31 @@ if (GETPOST("source") == 'membersubscription') print ')'; } print ''."\n"; diff --git a/htdocs/public/paypal/paymentok.php b/htdocs/public/paypal/paymentok.php index 9ae2e90795e..80ec1d8ec2b 100644 --- a/htdocs/public/paypal/paymentok.php +++ b/htdocs/public/paypal/paymentok.php @@ -181,6 +181,8 @@ if ($PAYPALTOKEN) if ($result < 0) { $error++; $errors=$interface->errors; } // Fin appel triggers + $tmptag=dolExplodeIntoArray($fulltag,'.','='); + // Send an email if (! empty($conf->global->ONLINE_PAYMENT_SENDEMAIL)) { @@ -206,7 +208,6 @@ if ($PAYPALTOKEN) $urlback=$_SERVER["REQUEST_URI"]; $topic='['.$appli.'] '.$langs->transnoentitiesnoconv("NewOnlinePaymentReceived"); - $tmptag=dolExplodeIntoArray($fulltag,'.','='); $content=""; if (! empty($tmptag['MEM'])) { @@ -265,6 +266,8 @@ if ($PAYPALTOKEN) if ($mysoc->email) echo "\nPlease, send a screenshot of this page to ".$mysoc->email."
\n"; + $tmptag=dolExplodeIntoArray($fulltag,'.','='); + // Send an email if (! empty($conf->global->ONLINE_PAYMENT_SENDEMAIL)) { diff --git a/htdocs/public/stripe/newpayment.php b/htdocs/public/stripe/newpayment.php index 38d81f7e991..36cd64b4f01 100644 --- a/htdocs/public/stripe/newpayment.php +++ b/htdocs/public/stripe/newpayment.php @@ -202,7 +202,7 @@ else if (! empty($conf->global->ONLINE_PAYMENT_CREDITOR)) $creditor=$conf->globa if ($action == 'dopayment') // We click on button Create payment { - if (GETPOST('newamount')) $amount = GETPOST('newamount'); + if (GETPOST('newamount','alpha')) $amount = price2num(GETPOST('newamount','alpha'),'MT'); else { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Amount")), null, 'errors'); @@ -429,7 +429,7 @@ print $text; // Output payment summary form print '
'.$langs->trans("ThisIsInformationOnPayment").' :
'.$langs->trans("ThisIsInformationOnPayment").' :
'.$langs->trans("Creditor"); print ''.$creditor.''; print ''; print '
'.$langs->trans("Amount"); if (empty($amount)) print ' ('.$langs->trans("ToComplete").')'; print ''; if (empty($amount) || ! is_numeric($amount)) { print ''; - print ''; + print ''; } else { print ''.price($amount).''; @@ -402,9 +400,8 @@ if (! GETPOST("source")) print '
'.$langs->trans("PaymentCode"); - print ''.$fulltag.''; + print ''.$fulltag.''; print ''; print ''; print '
'.$langs->trans("PaymentCode"); - print ''.$fulltag.''; + print ''.$fulltag.''; print ''; print ''; print '
'.$langs->trans("PaymentCode"); - print ''.$fulltag.''; + print ''.$fulltag.''; print ''; print ''; print '
'.$langs->trans("PaymentCode"); - print ''.$fulltag.''; + print ''.$fulltag.''; print ''; print ''; print '
'.price($member->last_subscription_amount); print '
'; + $valtoshow=''; if (empty($amount) || ! is_numeric($amount)) { - $valtoshow=GETPOST("newamount",'int'); + $valtoshow=price2num(GETPOST("newamount",'alpha'),'MT'); + // force default subscription amount to value defined into constant... + if (empty($valtoshow)) + { + if (! empty($conf->global->MEMBER_NEWFORM_EDITAMOUNT)) { + if (! empty($conf->global->MEMBER_NEWFORM_AMOUNT)) { + $valtoshow = $conf->global->MEMBER_NEWFORM_AMOUNT; + } + } + else { + if (! empty($conf->global->MEMBER_NEWFORM_AMOUNT)) { + $amount = $conf->global->MEMBER_NEWFORM_AMOUNT; + } + } + } + } + if (empty($amount) || ! is_numeric($amount)) + { + //$valtoshow=price2num(GETPOST("newamount",'alpha'),'MT'); if (! empty($conf->global->MEMBER_MIN_AMOUNT) && $valtoshow) $valtoshow=max($conf->global->MEMBER_MIN_AMOUNT,$valtoshow); print ''; - print ''; + print ''; } else { $valtoshow=$amount; @@ -937,7 +953,7 @@ if (GETPOST("source") == 'membersubscription') // Tag print '
'.$langs->trans("PaymentCode"); - print ''.$fulltag.''; + print ''.$fulltag.''; print ''; print ''; print '
'; print ''; -print ''."\n"; +print ''."\n"; $found=false; $error=0; @@ -455,7 +455,7 @@ if (! GETPOST("source")) if (empty($amount) || ! is_numeric($amount)) { print ''; - print ''; + print ''; } else { print ''.price($amount).''; @@ -470,7 +470,7 @@ if (! GETPOST("source")) // Tag print ''."\n"; @@ -541,7 +541,7 @@ if (GETPOST("source") == 'order') if (empty($amount) || ! is_numeric($amount)) { print ''; - print ''; + print ''; } else { print ''.price($amount).''; @@ -556,7 +556,7 @@ if (GETPOST("source") == 'order') // Tag print ''."\n"; @@ -652,7 +652,7 @@ if (GETPOST("source") == 'invoice') if (empty($amount) || ! is_numeric($amount)) { print ''; - print ''; + print ''; } else { print ''.price($amount).''; @@ -667,7 +667,7 @@ if (GETPOST("source") == 'invoice') // Tag print ''."\n"; @@ -852,7 +852,7 @@ if (GETPOST("source") == 'contractline') if (empty($amount) || ! is_numeric($amount)) { print ''; - print ''; + print ''; } else { print ''.price($amount).''; @@ -867,7 +867,7 @@ if (GETPOST("source") == 'contractline') // Tag print ''."\n"; @@ -971,7 +971,7 @@ if (GETPOST("source") == 'membersubscription') print ''."\n"; - if (empty($amount) && ! GETPOST('newamount')) $_GET['newamount']=$member->last_subscription_amount; + if (empty($amount) && ! GETPOST('newamount','alpha')) $_GET['newamount']=$member->last_subscription_amount; } // Amount @@ -984,12 +984,31 @@ if (GETPOST("source") == 'membersubscription') print ')'; } print ''."\n"; diff --git a/htdocs/public/stripe/paymentok.php b/htdocs/public/stripe/paymentok.php index f018bc98b7a..d0ce82d1ca8 100644 --- a/htdocs/public/stripe/paymentok.php +++ b/htdocs/public/stripe/paymentok.php @@ -127,6 +127,8 @@ if ($ispaymentok) $sendemail = ''; if (! empty($conf->global->ONLINE_PAYMENT_SENDEMAIL)) $sendemail=$conf->global->ONLINE_PAYMENT_SENDEMAIL; + $tmptag=dolExplodeIntoArray($fulltag,'.','='); + // Send an email if ($sendemail) { @@ -152,7 +154,6 @@ if ($ispaymentok) $urlback=$_SERVER["REQUEST_URI"]; $topic='['.$appli.'] '.$langs->transnoentitiesnoconv("NewOnlinePaymentReceived"); - $tmptag=dolExplodeIntoArray($fulltag,'.','='); $content=""; if (! empty($tmptag['MEM'])) { diff --git a/htdocs/societe/card.php b/htdocs/societe/card.php index 2dc70b74c7d..9fdad8916e1 100644 --- a/htdocs/societe/card.php +++ b/htdocs/societe/card.php @@ -119,7 +119,7 @@ if (empty($reshook)) { $object->fetch($socid); - $errors = 0; + $error = 0; $soc_origin_id = GETPOST('soc_origin', 'int'); $soc_origin = new Societe($db); @@ -131,13 +131,13 @@ if (empty($reshook)) } else { - if (!$errors && $soc_origin->fetch($soc_origin_id) < 1) + if (!$error && $soc_origin->fetch($soc_origin_id) < 1) { setEventMessages($langs->trans('ErrorRecordNotFound'), null, 'errors'); - $errors++; + $error++; } - if (!$errors) + if (!$error) { // TODO Move the merge function into class of object. @@ -184,48 +184,67 @@ if (empty($reshook)) $suppcats = $static_cat->containing($soc_origin->id, 'supplier', 'id'); $object->setCategories($suppcats, 'supplier'); + // If thirdparty has a new code that is same than origin, we clean origin code to avoid duplicate key from database unique keys. + if ($soc_origin->code_client == $object->code_client + || $soc_origin->code_fournisseur == $object->code_fournisseur + || $soc_origin->barcode == $object->barcode) + { + dol_syslog("We clean customer and supplier code so we will be able to make the update of target"); + $soc_origin->code_client = ''; + $soc_origin->code_fournisseur = ''; + $soc_origin->barcode = ''; + $soc_origin->update($soc_origin->id, $user, 0, 1, 1, 'merge'); + } + // Update - $object->update($object->id, $user, 0); + $object->update($object->id, $user, 0, 1, 1, 'merge'); + if ($result < 0) + { + $error++; + } // Move links - $objects = array( - 'Adherent' => '/adherents/class/adherent.class.php', - 'Societe' => '/societe/class/societe.class.php', - 'Categorie' => '/categories/class/categorie.class.php', - 'ActionComm' => '/comm/action/class/actioncomm.class.php', - 'Propal' => '/comm/propal/class/propal.class.php', - 'Commande' => '/commande/class/commande.class.php', - 'Facture' => '/compta/facture/class/facture.class.php', - 'FactureRec' => '/compta/facture/class/facture-rec.class.php', - 'LignePrelevement' => '/compta/prelevement/class/ligneprelevement.class.php', - 'Contact' => '/contact/class/contact.class.php', - 'Contrat' => '/contrat/class/contrat.class.php', - 'Expedition' => '/expedition/class/expedition.class.php', - 'Fichinter' => '/fichinter/class/fichinter.class.php', - 'CommandeFournisseur' => '/fourn/class/fournisseur.commande.class.php', - 'FactureFournisseur' => '/fourn/class/fournisseur.facture.class.php', - 'SupplierProposal' => '/supplier_proposal/class/supplier_proposal.class.php', - 'ProductFournisseur' => '/fourn/class/fournisseur.product.class.php', - 'Livraison' => '/livraison/class/livraison.class.php', - 'Product' => '/product/class/product.class.php', - 'Project' => '/projet/class/project.class.php', - 'User' => '/user/class/user.class.php', - ); - - //First, all core objects must update their tables - foreach ($objects as $object_name => $object_file) + if (! $error) { - require_once DOL_DOCUMENT_ROOT.$object_file; + $objects = array( + 'Adherent' => '/adherents/class/adherent.class.php', + 'Societe' => '/societe/class/societe.class.php', + 'Categorie' => '/categories/class/categorie.class.php', + 'ActionComm' => '/comm/action/class/actioncomm.class.php', + 'Propal' => '/comm/propal/class/propal.class.php', + 'Commande' => '/commande/class/commande.class.php', + 'Facture' => '/compta/facture/class/facture.class.php', + 'FactureRec' => '/compta/facture/class/facture-rec.class.php', + 'LignePrelevement' => '/compta/prelevement/class/ligneprelevement.class.php', + 'Contact' => '/contact/class/contact.class.php', + 'Contrat' => '/contrat/class/contrat.class.php', + 'Expedition' => '/expedition/class/expedition.class.php', + 'Fichinter' => '/fichinter/class/fichinter.class.php', + 'CommandeFournisseur' => '/fourn/class/fournisseur.commande.class.php', + 'FactureFournisseur' => '/fourn/class/fournisseur.facture.class.php', + 'SupplierProposal' => '/supplier_proposal/class/supplier_proposal.class.php', + 'ProductFournisseur' => '/fourn/class/fournisseur.product.class.php', + 'Livraison' => '/livraison/class/livraison.class.php', + 'Product' => '/product/class/product.class.php', + 'Project' => '/projet/class/project.class.php', + 'User' => '/user/class/user.class.php', + ); - if (!$errors && !$object_name::replaceThirdparty($db, $soc_origin->id, $object->id)) + //First, all core objects must update their tables + foreach ($objects as $object_name => $object_file) { - $errors++; - setEventMessages($db->lasterror(), null, 'errors'); + require_once DOL_DOCUMENT_ROOT.$object_file; + + if (!$error && !$object_name::replaceThirdparty($db, $soc_origin->id, $object->id)) + { + $error++; + setEventMessages($db->lasterror(), null, 'errors'); + } } } - //External modules should update their ones too - if (!$errors) + // External modules should update their ones too + if (! $error) { $reshook = $hookmanager->executeHooks('replaceThirdparty', array( 'soc_origin' => $soc_origin->id, @@ -235,7 +254,7 @@ if (empty($reshook)) if ($reshook < 0) { setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); - $errors++; + $error++; } } @@ -254,16 +273,16 @@ if (empty($reshook)) // End call triggers } - if (!$errors) + if (!$error) { //We finally remove the old thirdparty if ($soc_origin->delete($soc_origin->id, $user) < 1) { - $errors++; + $error++; } } - if (!$errors) + if (!$error) { setEventMessages($langs->trans('ThirdpartiesMergeSuccess'), null, 'mesgs'); $db->commit(); @@ -1143,7 +1162,15 @@ else // State if (empty($conf->global->SOCIETE_DISABLE_STATE)) { - print ''; @@ -1700,7 +1727,15 @@ else // State if (empty($conf->global->SOCIETE_DISABLE_STATE)) { - print ''; } @@ -1874,6 +1909,7 @@ else $cate_arbo = $form->select_all_categories(Categorie::TYPE_CUSTOMER, null, null, null, null, 1); $c = new Categorie($db); $cats = $c->containing($object->id, Categorie::TYPE_CUSTOMER); + $arrayselected=array(); foreach ($cats as $cat) { $arrayselected[] = $cat->id; } @@ -1888,6 +1924,7 @@ else $cate_arbo = $form->select_all_categories(Categorie::TYPE_SUPPLIER, null, null, null, null, 1); $c = new Categorie($db); $cats = $c->containing($object->id, Categorie::TYPE_SUPPLIER); + $arrayselected=array(); foreach ($cats as $cat) { $arrayselected[] = $cat->id; } diff --git a/htdocs/societe/class/api_thirdparties.class.php b/htdocs/societe/class/api_thirdparties.class.php index 658dc6a50e2..35301b06a07 100644 --- a/htdocs/societe/class/api_thirdparties.class.php +++ b/htdocs/societe/class/api_thirdparties.class.php @@ -243,6 +243,218 @@ class Thirdparties extends DolibarrApi return false; } + /** + * Merge a thirdparty into another one. + * + * Merge content (properties, notes) and objects (like invoices, events, orders, proposals, ...) of a thirdparty into a target thirdparty, + * then delete the merged thirdparty. + * If a property has a defined value both in thirdparty to delete and thirdparty to keep, the value into the thirdparty to + * delete will be ignored, the value of target thirdparty will remain, except for notes (content is concatenated). + * + * @param int $id ID of thirdparty to keep (the target thirdparty) + * @param int $idtodelete ID of thirdparty to remove (the thirdparty to delete), once data has been merged into the target thirdparty. + * @return int + * + * @url PUT {id}/merge/{idtodelete} + */ + function merge($id, $idtodelete) + { + global $db, $hookmanager; + + if ($id == $idtodelete) + { + throw new RestException(400, 'Try to merge a thirdparty into itself'); + } + + if(! DolibarrApiAccess::$user->rights->societe->creer) { + throw new RestException(401); + } + + $result = $this->company->fetch($id); // include the fetch of extra fields + if( ! $result ) { + throw new RestException(404, 'Thirdparty not found'); + } + + if( ! DolibarrApi::_checkAccessToResource('societe',$this->company->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } + + $this->companytoremove = new Societe($db); + + $result = $this->companytoremove->fetch($idtodelete); // include the fetch of extra fields + if( ! $result ) { + throw new RestException(404, 'Thirdparty not found'); + } + + if( ! DolibarrApi::_checkAccessToResource('societe',$this->companytoremove->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } + + $soc_origin = $this->companytoremove; + $object = $this->company; + $user = DolibarrApiAccess::$user; + + + // Call same code than into action 'confirm_merge' + + + $db->begin(); + + // Recopy some data + $object->client = $object->client | $soc_origin->client; + $object->fournisseur = $object->fournisseur | $soc_origin->fournisseur; + $listofproperties=array( + 'address', 'zip', 'town', 'state_id', 'country_id', 'phone', 'phone_pro', 'fax', 'email', 'skype', 'url', 'barcode', + 'idprof1', 'idprof2', 'idprof3', 'idprof4', 'idprof5', 'idprof6', + 'tva_intra', 'effectif_id', 'forme_juridique', 'remise_percent', 'mode_reglement_supplier_id', 'cond_reglement_supplier_id', 'name_bis', + 'stcomm_id', 'outstanding_limit', 'price_level', 'parent', 'default_lang', 'ref', 'ref_ext', 'import_key', 'fk_incoterms', 'fk_multicurrency', + 'code_client', 'code_fournisseur', 'code_compta', 'code_compta_fournisseur', + 'model_pdf', 'fk_projet' + ); + foreach ($listofproperties as $property) + { + if (empty($object->$property)) $object->$property = $soc_origin->$property; + } + + // Concat some data + $listofproperties=array( + 'note_public', 'note_private' + ); + foreach ($listofproperties as $property) + { + $object->$property = dol_concatdesc($object->$property, $soc_origin->$property); + } + + // Merge extrafields + if (is_array($soc_origin->array_options)) + { + foreach ($soc_origin->array_options as $key => $val) + { + if (empty($object->array_options[$key])) $object->array_options[$key] = $val; + } + } + + // Merge categories + $static_cat = new Categorie($db); + $custcats = $static_cat->containing($soc_origin->id, 'customer', 'id'); + $object->setCategories($custcats, 'customer'); + $suppcats = $static_cat->containing($soc_origin->id, 'supplier', 'id'); + $object->setCategories($suppcats, 'supplier'); + + // If thirdparty has a new code that is same than origin, we clean origin code to avoid duplicate key from database unique keys. + if ($soc_origin->code_client == $object->code_client + || $soc_origin->code_fournisseur == $object->code_fournisseur + || $soc_origin->barcode == $object->barcode) + { + dol_syslog("We clean customer and supplier code so we will be able to make the update of target"); + $soc_origin->code_client = ''; + $soc_origin->code_fournisseur = ''; + $soc_origin->barcode = ''; + $soc_origin->update($soc_origin->id, $user, 0, 1, 1, 'merge'); + } + + // Update + $result = $object->update($object->id, $user, 0, 1, 1, 'merge'); + if ($result < 0) + { + $error++; + } + + // Move links + if (! $error) + { + $objects = array( + 'Adherent' => '/adherents/class/adherent.class.php', + 'Societe' => '/societe/class/societe.class.php', + 'Categorie' => '/categories/class/categorie.class.php', + 'ActionComm' => '/comm/action/class/actioncomm.class.php', + 'Propal' => '/comm/propal/class/propal.class.php', + 'Commande' => '/commande/class/commande.class.php', + 'Facture' => '/compta/facture/class/facture.class.php', + 'FactureRec' => '/compta/facture/class/facture-rec.class.php', + 'LignePrelevement' => '/compta/prelevement/class/ligneprelevement.class.php', + 'Contact' => '/contact/class/contact.class.php', + 'Contrat' => '/contrat/class/contrat.class.php', + 'Expedition' => '/expedition/class/expedition.class.php', + 'Fichinter' => '/fichinter/class/fichinter.class.php', + 'CommandeFournisseur' => '/fourn/class/fournisseur.commande.class.php', + 'FactureFournisseur' => '/fourn/class/fournisseur.facture.class.php', + 'SupplierProposal' => '/supplier_proposal/class/supplier_proposal.class.php', + 'ProductFournisseur' => '/fourn/class/fournisseur.product.class.php', + 'Livraison' => '/livraison/class/livraison.class.php', + 'Product' => '/product/class/product.class.php', + 'Project' => '/projet/class/project.class.php', + 'User' => '/user/class/user.class.php', + ); + + //First, all core objects must update their tables + foreach ($objects as $object_name => $object_file) + { + require_once DOL_DOCUMENT_ROOT.$object_file; + + if (!$errors && !$object_name::replaceThirdparty($db, $soc_origin->id, $object->id)) + { + $errors++; + //setEventMessages($db->lasterror(), null, 'errors'); + } + } + } + + // External modules should update their ones too + if (!$errors) + { + $reshook = $hookmanager->executeHooks('replaceThirdparty', array( + 'soc_origin' => $soc_origin->id, + 'soc_dest' => $object->id + ), $soc_dest, $action); + + if ($reshook < 0) + { + //setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + $errors++; + } + } + + + if (! $error) + { + $object->context=array('merge'=>1, 'mergefromid'=>$soc_origin->id); + + // Call trigger + $result=$object->call_trigger('COMPANY_MODIFY',$user); + if ($result < 0) + { + //setEventMessages($object->error, $object->errors, 'errors'); + $error++; + } + // End call triggers + } + + if (! $error) + { + //We finally remove the old thirdparty + if ($soc_origin->delete($soc_origin->id, $user) < 1) + { + $errors++; + } + } + + // End of merge + + if ($error) + { + $db->rollback(); + + throw new RestException(500, 'Error failed to merged thirdparty '.$this->companytoremove->id.' into '.$id.'. Enable and read log file for more information.'); + } + else + { + $db->commit(); + } + + return $this->get($id); + } + /** * Delete thirdparty * @@ -339,6 +551,139 @@ class Thirdparties extends DolibarrApi } + + /** + * Get outstanding proposals of thirdparty + * + * @param int $id ID of the thirdparty + * @param string $mode 'customer' or 'supplier' + * + * @url GET {id}/outstandingproposals + * + * @return array List of outstandings proposals of thirdparty + * + * @throws 400 + * @throws 401 + * @throws 404 + */ + function getOutStandingProposals($id, $mode='customer') + { + $obj_ret = array(); + + if(! DolibarrApiAccess::$user->rights->societe->lire) { + throw new RestException(401); + } + + if(empty($id)) { + throw new RestException(400, 'Thirdparty ID is mandatory'); + } + + if( ! DolibarrApi::_checkAccessToResource('societe',$id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } + + $result = $this->company->fetch($id); + if( ! $result ) { + throw new RestException(404, 'Thirdparty not found'); + } + + $result = $this->company->getOutstandingProposals($mode); + + unset($result['total_ht']); + unset($result['total_ttc']); + + return $result; + } + + + /** + * Get outstanding orders of thirdparty + * + * @param int $id ID of the thirdparty + * @param string $mode 'customer' or 'supplier' + * + * @url GET {id}/outstandingorders + * + * @return array List of outstandings orders of thirdparty + * + * @throws 400 + * @throws 401 + * @throws 404 + */ + function getOutStandingOrder($id, $mode='customer') + { + $obj_ret = array(); + + if(! DolibarrApiAccess::$user->rights->societe->lire) { + throw new RestException(401); + } + + if(empty($id)) { + throw new RestException(400, 'Thirdparty ID is mandatory'); + } + + if( ! DolibarrApi::_checkAccessToResource('societe',$id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } + + $result = $this->company->fetch($id); + if( ! $result ) { + throw new RestException(404, 'Thirdparty not found'); + } + + $result = $this->company->getOutstandingOrders($mode); + + unset($result['total_ht']); + unset($result['total_ttc']); + + return $result; + } + + /** + * Get outstanding invoices of thirdparty + * + * @param int $id ID of the thirdparty + * @param string $mode 'customer' or 'supplier' + * + * @url GET {id}/outstandinginvoices + * + * @return array List of outstandings invoices of thirdparty + * + * @throws 400 + * @throws 401 + * @throws 404 + */ + function getOutStandingInvoices($id, $mode='customer') + { + $obj_ret = array(); + + if(! DolibarrApiAccess::$user->rights->societe->lire) { + throw new RestException(401); + } + + if(empty($id)) { + throw new RestException(400, 'Thirdparty ID is mandatory'); + } + + if( ! DolibarrApi::_checkAccessToResource('societe',$id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } + + $result = $this->company->fetch($id); + if( ! $result ) { + throw new RestException(404, 'Thirdparty not found'); + } + + $result = $this->company->getOutstandingBills($mode); + + unset($result['total_ht']); + unset($result['total_ttc']); + + return $result; + } + + + /** * Get fixed amount discount of a thirdparty (all sources: deposit, credit note, commercial offers...) * diff --git a/htdocs/societe/class/client.class.php b/htdocs/societe/class/client.class.php index b4ee6b86249..6db71eb4218 100644 --- a/htdocs/societe/class/client.class.php +++ b/htdocs/societe/class/client.class.php @@ -65,7 +65,7 @@ class Client extends Societe $clause = "AND"; } $sql.= " ".$clause." s.client IN (1,2,3)"; - $sql.= ' AND s.entity IN ('.getEntity($this->element, 1).')'; + $sql.= ' AND s.entity IN ('.getEntity($this->element).')'; $sql.= " GROUP BY s.client"; $resql=$this->db->query($sql); diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index cd4b66a23a1..44e95f4159b 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -738,7 +738,7 @@ class Societe extends CommonObject * @param int $call_trigger 0=no, 1=yes * @param int $allowmodcodeclient Inclut modif code client et code compta * @param int $allowmodcodefournisseur Inclut modif code fournisseur et code compta fournisseur - * @param string $action 'add' or 'update' + * @param string $action 'add' or 'update' or 'merge' * @param int $nosyncmember Do not synchronize info of linked member * @return int <0 if KO, >=0 if OK */ @@ -867,7 +867,12 @@ class Societe extends CommonObject // Check name is required and codes are ok or unique. // If error, this->errors[] is filled $result = 0; - if ($action != 'add') $result = $this->verify(); // We don't check when update called during a create because verify was already done + if ($action != 'add' && $action != 'merge') + { + // We don't check when update called during a create because verify was already done. + // For a merge, we suppose source data is clean and a customer code of a deleted thirdparty must be accepted into a target thirdparty with empty code without duplicate error + $result = $this->verify(); + } if ($result >= 0) { @@ -1148,7 +1153,8 @@ class Societe extends CommonObject $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_departements as d ON s.fk_departement = d.rowid'; $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_typent as te ON s.fk_typent = te.id'; $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_incoterms as i ON s.fk_incoterms = i.rowid'; - $sql .= ' WHERE s.entity IN ('.getEntity($this->element, 1).')'; + + $sql .= ' WHERE s.entity IN ('.getEntity($this->element).')'; if ($rowid) $sql .= ' AND s.rowid = '.$rowid; if ($ref) $sql .= " AND s.nom = '".$this->db->escape($ref)."'"; if ($ref_ext) $sql .= " AND s.ref_ext = '".$this->db->escape($ref_ext)."'"; @@ -3461,7 +3467,7 @@ class Societe extends CommonObject $outstandingOpened+=$obj->total_ttc; } } - return array('opened'=>$outstandingOpened, 'total_ht'=>$outstandingTotal, 'total_ttc'=>$outstandingTotalIncTax); + return array('opened'=>$outstandingOpened, 'total_ht'=>$outstandingTotal, 'total_ttc'=>$outstandingTotalIncTax); // 'opened' is 'incl taxes' } else return array(); @@ -3501,7 +3507,7 @@ class Societe extends CommonObject $outstandingOpened+=$obj->total_ttc; } } - return array('opened'=>$outstandingOpened, 'total_ht'=>$outstandingTotal, 'total_ttc'=>$outstandingTotalIncTax); + return array('opened'=>$outstandingOpened, 'total_ht'=>$outstandingTotal, 'total_ttc'=>$outstandingTotalIncTax); // 'opened' is 'incl taxes' } else return array(); @@ -3572,7 +3578,7 @@ class Societe extends CommonObject $outstandingOpened+=$obj->total_ttc - $paiement - $creditnotes - $deposits; } } - return array('opened'=>$outstandingOpened, 'total_ht'=>$outstandingTotal, 'total_ttc'=>$outstandingTotalIncTax); + return array('opened'=>$outstandingOpened, 'total_ht'=>$outstandingTotal, 'total_ttc'=>$outstandingTotalIncTax); // 'opened' is 'incl taxes' } else { @@ -3767,16 +3773,22 @@ class Societe extends CommonObject * Function used to replace a thirdparty id with another one. * It must be used within a transaction to avoid trouble * - * @param DoliDB $db Database handler - * @param int $origin_id Old thirdparty id - * @param int $dest_id New thirdparty id - * @return bool + * @param DoliDB $db Database handler + * @param int $origin_id Old thirdparty id (will be removed) + * @param int $dest_id New thirdparty id + * @return bool True if success, False if error */ public static function replaceThirdparty(DoliDB $db, $origin_id, $dest_id) { + if ($origin_id == $id) + { + dol_syslog('Error: Try to merge a thirdparty into itself'); + return false; + } + /** - * Thirdparty commercials cannot be the same in both thirdparties so we look for them and remove some - * Because this function is meant to be executed within a transaction, we won't take care of it. + * Thirdparty commercials cannot be the same in both thirdparties so we look for them and remove some to avoid duplicate. + * Because this function is meant to be executed within a transaction, we won't take care of begin/commit. */ $sql = 'SELECT rowid FROM '.MAIN_DB_PREFIX.'societe_commerciaux '; $sql .= ' WHERE fk_soc = '.(int) $dest_id.' AND fk_user IN ( '; diff --git a/htdocs/societe/contact.php b/htdocs/societe/contact.php index 4077c1e1b28..d57f61045c0 100644 --- a/htdocs/societe/contact.php +++ b/htdocs/societe/contact.php @@ -44,11 +44,7 @@ require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; if (! empty($conf->adherent->enabled)) require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; -$langs->load("companies"); -$langs->load("commercial"); -$langs->load("bills"); -$langs->load("banks"); -$langs->load("users"); +$langs->loadLangs(array("companies","commercial","bills","banks","users")); if (! empty($conf->categorie->enabled)) $langs->load("categories"); if (! empty($conf->incoterm->enabled)) $langs->load("incoterm"); if (! empty($conf->notification->enabled)) $langs->load("mails"); @@ -115,6 +111,9 @@ if (empty($reshook)) exit; } } + + // Selection of new fields + include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; } @@ -169,8 +168,6 @@ else if ($action != 'presend') { - print '
'; - // Contacts list if (empty($conf->global->SOCIETE_DISABLE_CONTACTS)) { @@ -182,10 +179,6 @@ else { $result=show_addresses($conf,$langs,$db,$object,$_SERVER["PHP_SELF"].'?socid='.$object->id); } - - - print '
'; - } } diff --git a/htdocs/societe/list.php b/htdocs/societe/list.php index 6de4ae1296c..47852c71403 100644 --- a/htdocs/societe/list.php +++ b/htdocs/societe/list.php @@ -142,6 +142,9 @@ if (($tmp = $langs->transnoentities("ProfId4".$mysoc->country_code)) && $tmp != if (($tmp = $langs->transnoentities("ProfId5".$mysoc->country_code)) && $tmp != "ProfId5".$mysoc->country_code && $tmp != '-') $fieldstosearchall['s.idprof5']='ProfId5'; if (($tmp = $langs->transnoentities("ProfId6".$mysoc->country_code)) && $tmp != "ProfId6".$mysoc->country_code && $tmp != '-') $fieldstosearchall['s.idprof6']='ProfId6'; if (!empty($conf->barcode->enabled)) $fieldstosearchall['s.barcode']='Gencod'; +// Personalized search criterias. Example: $conf->global->THIRDPARTY_QUICKSEARCH_ON_FIELDS = 's.nom=ThirdPartyName;s.name_alias=AliasNameShort;s.code_client=CustomerCode' +if (! empty($conf->global->THIRDPARTY_QUICKSEARCH_ON_FIELDS)) $fieldstosearchall=dolExplodeIntoArray($conf->global->THIRDPARTY_QUICKSEARCH_ON_FIELDS); + // Define list of fields to show into list $checkedcustomercode=(in_array($contextpage, array('thirdpartylist', 'customerlist', 'prospectlist')) ? 1 : 0); @@ -513,7 +516,7 @@ $param=''; if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage; if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit; if ($search_all != '') $param = "&sall=".urlencode($search_all); -if ($sall != '') $param .= "&sall=".urlencode($sall); +if ($sall != '') $param.= "&sall=".urlencode($sall); if ($search_categ_cus > 0) $param.='&search_categ_cus='.urlencode($search_categ_cus); if ($search_categ_sup > 0) $param.='&search_categ_sup='.urlencode($search_categ_sup); if ($search_sale > 0) $param.='&search_sale='.urlencode($search_sale); @@ -995,16 +998,7 @@ while ($i < min($num, $limit)) $savalias = $obj->name_alias; if (! empty($arrayfields['s.name_alias']['checked'])) $companystatic->name_alias=''; print '\n"; $companystatic->name_alias = $savalias; if (! $i) $totalarray['nbfield']++; diff --git a/htdocs/societe/note.php b/htdocs/societe/note.php index 0dbb20ebd00..d0766bc24d8 100644 --- a/htdocs/societe/note.php +++ b/htdocs/societe/note.php @@ -62,7 +62,7 @@ if (! empty($conf->global->MAIN_HTML_TITLE) && preg_match('/thirdpartynameonly/' $help_url='EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas'; llxHeader('',$title,$help_url); -if ($id > 0) +if ($object->id > 0) { /* * Affichage onglets @@ -120,6 +120,11 @@ if ($id > 0) dol_fiche_end(); } +else +{ + $langs->load("errors"); + print $langs->trans("ErrorRecordNotFound"); +} llxFooter(); $db->close(); diff --git a/htdocs/theme/eldy/style.css.php b/htdocs/theme/eldy/style.css.php index cd7eaf67c73..69038535669 100644 --- a/htdocs/theme/eldy/style.css.php +++ b/htdocs/theme/eldy/style.css.php @@ -357,7 +357,7 @@ input.buttonpayment { background: none; padding-left: 30px; text-align: ; - border: 2px solid #ccc; + border: 1px solid #ddd; background-color: #eee; white-space: normal; } @@ -589,6 +589,9 @@ textarea.centpercent { .wordwrap { word-wrap: break-word; } +.wordbreak { + word-break: break-all; +} .nobold { font-weight: normal !important; } diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php index e86d85a2c34..3cb7ae4d7a9 100644 --- a/htdocs/theme/md/style.css.php +++ b/htdocs/theme/md/style.css.php @@ -591,6 +591,9 @@ textarea.centpercent { .wordwrap { word-wrap: break-word; } +.wordbreak { + word-break: break-all; +} .nobold { font-weight: normal !important; }
'.$langs->trans("ThisIsInformationOnPayment").' :
'.$langs->trans("ThisIsInformationOnPayment").' :
'.$langs->trans("PaymentCode"); - print ''.$fulltag.''; + print ''.$fulltag.''; print ''; print ''; print '
'.$langs->trans("PaymentCode"); - print ''.$fulltag.''; + print ''.$fulltag.''; print ''; print ''; print '
'.$langs->trans("PaymentCode"); - print ''.$fulltag.''; + print ''.$fulltag.''; print ''; print ''; print '
'.$langs->trans("PaymentCode"); - print ''.$fulltag.''; + print ''.$fulltag.''; print ''; print ''; print '
'.price($member->last_subscription_amount); print '
'; + $valtoshow=''; if (empty($amount) || ! is_numeric($amount)) { - $valtoshow=GETPOST("newamount",'int'); + $valtoshow=price2num(GETPOST("newamount",'alpha'),'MT'); + // force default subscription amount to value defined into constant... + if (empty($valtoshow)) + { + if (! empty($conf->global->MEMBER_NEWFORM_EDITAMOUNT)) { + if (! empty($conf->global->MEMBER_NEWFORM_AMOUNT)) { + $valtoshow = $conf->global->MEMBER_NEWFORM_AMOUNT; + } + } + else { + if (! empty($conf->global->MEMBER_NEWFORM_AMOUNT)) { + $amount = $conf->global->MEMBER_NEWFORM_AMOUNT; + } + } + } + } + if (empty($amount) || ! is_numeric($amount)) + { + //$valtoshow=price2num(GETPOST("newamount",'alpha'),'MT'); if (! empty($conf->global->MEMBER_MIN_AMOUNT) && $valtoshow) $valtoshow=max($conf->global->MEMBER_MIN_AMOUNT,$valtoshow); print ''; - print ''; + print ''; } else { $valtoshow=$amount; @@ -1006,7 +1025,7 @@ if (GETPOST("source") == 'membersubscription') // Tag print '
'.$langs->trans("PaymentCode"); - print ''.$fulltag.''; + print ''.$fulltag.''; print ''; print ''; print '
'.fieldLabel('State','state_id').''; + if(!empty($conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT) && ($conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT == 1 || $conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT == 2)) + { + print '
'.fieldLabel('Region-State','state_id').''; + } + else + { + print '
'.fieldLabel('State','state_id').''; + } + if ($object->country_id) print $formcompany->select_state($object->state_id,$object->country_code); else print $countrynotdefined; print '
'.fieldLabel('State','state_id').''; + if(!empty($conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT) && ($conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT == 1 || $conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT == 2)) + { + print '
'.fieldLabel('Region-State','state_id').''; + } + else + { + print '
'.fieldLabel('State','state_id').''; + } + print $formcompany->select_state($object->state_id,$object->country_code); print '
'; - //if (! empty($arrayfields['s.name_alias']['checked'])) // Hide alias from output - //{ - $savalias=$companystatic->name_alias; - $companystatic->name_alias=''; - //} print $companystatic->getNomUrl(1,'',100); - //if (! empty($arrayfields['s.name_alias']['checked'])) // Hide alias from output - //{ - $companystatic->name_alias=$savalias; - //} print "