diff --git a/ChangeLog b/ChangeLog index 19c77c702fd..258a308cce3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -3,6 +3,42 @@ English Dolibarr ChangeLog -------------------------------------------------------------- +***** ChangeLog for 12.0.1 compared to 12.0.0 ***** +FIX: reposition was broken if url end with #anchor +FIX: $_POST must be GETPOST +FIX: 10.0 - fatal with postgreSQL +FIX: #14109 +FIX: #14112 +FIX: #14142 +FIX: all extrafields cleared after update of one of them +FIX: Avoid warning when creating a module with already existing files +FIX: change selected fields on company card +FIX: Correct ModuleBuilder left menu +FIX: create a deposit with amount using comma didn't work +FIX: CSS +FIX: Entry from stripe intent were reported into SEPA payments +FIX: Filter on status, closing opening status +FIX: html lost on html extrafield +FIX: Label of popup on thirdparty +FIX: missing possibility to change entity when propal cloning +FIX: missing setup of extrafields for MO +FIX: Missing the tooltip when creating bank account +FIX: Missing token +FIX: non numeric value on comm/card.php +FIX: SQL Problem in customer invoice list +FIX: SQL Problem in social contribution list +FIX: SQL Problem in supplier invoice list +FIX: SQL syntax error when editing extrafields +FIX: Sql type +FIX: takepos 12 hook +FIX: Update form erased extrafields that were hidden +FIX: Update of extrafields date +FIX: Update of extrafiels on draft object +FIX: upload documents into manual ECM was reported a permission error +FIX: Use of office365 TLS with SMTPs method. +FIX: wrong origin +FIX: Permission error during import + ***** ChangeLog for 12.0.0 compared to 11.0.0 ***** For users: diff --git a/htdocs/accountancy/journal/bankjournal.php b/htdocs/accountancy/journal/bankjournal.php index 3372105cd85..4af83a1f121 100644 --- a/htdocs/accountancy/journal/bankjournal.php +++ b/htdocs/accountancy/journal/bankjournal.php @@ -254,6 +254,8 @@ if ($result) { } else { $tabpay[$obj->rowid]["lib"] = dol_trunc($obj->label, 60); } + + // Load of url links to the line into llx_bank $links = $object->get_url($obj->rowid); // Get an array('url'=>, 'url_id'=>, 'label'=>, 'type'=> 'fk_bank'=> ) //var_dump($i); @@ -320,6 +322,7 @@ if ($result) { $chargestatic->ref = $links[$key]['url_id']; $tabpay[$obj->rowid]["lib"] .= ' '.$chargestatic->getNomUrl(2); + $reg = array(); if (preg_match('/^\((.*)\)$/i', $links[$key]['label'], $reg)) { if ($reg[1] == 'socialcontribution') $reg[1] = 'SocialContribution'; @@ -331,11 +334,13 @@ if ($result) { $tabpay[$obj->rowid]["soclib"] = $chargestatic->getNomUrl(1, 30); $tabpay[$obj->rowid]["paymentscid"] = $chargestatic->id; + // Retreive the accounting code of the social contribution of the payment from link of payment. + // Note: We have the social contribution id, it can be faster to get accounting code from social contribution id. $sqlmid = 'SELECT cchgsoc.accountancy_code'; - $sqlmid .= " FROM ".MAIN_DB_PREFIX."c_chargesociales cchgsoc "; + $sqlmid .= " FROM ".MAIN_DB_PREFIX."c_chargesociales cchgsoc"; $sqlmid .= " INNER JOIN ".MAIN_DB_PREFIX."chargesociales as chgsoc ON chgsoc.fk_type=cchgsoc.id"; $sqlmid .= " INNER JOIN ".MAIN_DB_PREFIX."paiementcharge as paycharg ON paycharg.fk_charge=chgsoc.rowid"; - $sqlmid .= " INNER JOIN ".MAIN_DB_PREFIX."bank_url as bkurl ON bkurl.url_id=paycharg.rowid"; + $sqlmid .= " INNER JOIN ".MAIN_DB_PREFIX."bank_url as bkurl ON bkurl.url_id=paycharg.rowid AND bkurl.type = 'payment_sc'"; $sqlmid .= " WHERE bkurl.fk_bank=".$obj->rowid; dol_syslog("accountancy/journal/bankjournal.php:: sqlmid=".$sqlmid, LOG_DEBUG); diff --git a/htdocs/admin/bom_extrafields.php b/htdocs/admin/bom_extrafields.php new file mode 100644 index 00000000000..70d7720e994 --- /dev/null +++ b/htdocs/admin/bom_extrafields.php @@ -0,0 +1,113 @@ + + * Copyright (C) 2003 Jean-Louis Bergamo + * Copyright (C) 2004-2011 Laurent Destailleur + * Copyright (C) 2012 Regis Houssin + * Copyright (C) 2014 Florian Henry + * Copyright (C) 2015 Jean-François Ferry + * + * 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/bom_extrafields.php + * \ingroup bom + * \brief Page to setup extra fields of BOM + */ + +require '../main.inc.php'; +require_once DOL_DOCUMENT_ROOT.'/bom/lib/bom.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; + +// Load translation files required by the page +$langs->loadLangs(array('mrp', 'admin')); + +$extrafields = new ExtraFields($db); +$form = new Form($db); + +// List of supported format +$tmptype2label = ExtraFields::$type2label; +$type2label = array(''); +foreach ($tmptype2label as $key => $val) $type2label[$key] = $langs->transnoentitiesnoconv($val); + +$action = GETPOST('action', 'alpha'); +$attrname = GETPOST('attrname', 'alpha'); +$elementtype = 'bom_bom'; + +if (!$user->admin) accessforbidden(); + + +/* + * Actions + */ + +require DOL_DOCUMENT_ROOT.'/core/actions_extrafields.inc.php'; + + + +/* + * View + */ + + +llxHeader('', $langs->trans("BOMsSetup"), $help_url); + + +$linkback = ''.$langs->trans("BackToModuleList").''; +print load_fiche_titre($langs->trans("BOMsSetup"), $linkback, 'title_setup'); + + +$head = bomAdminPrepareHead(null); + +dol_fiche_head($head, 'bom_extrafields', $langs->trans("ExtraFields"), -1, 'account'); + +require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php'; + +dol_fiche_end(); + + +// Buttons +if ($action != 'create' && $action != 'edit') +{ + print '
'; + print "".$langs->trans("NewAttribute").""; + print "
"; +} + + +/* + * Creation of an optional field + */ +if ($action == 'create') +{ + print '
'; + print load_fiche_titre($langs->trans('NewAttribute')); + + require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php'; +} + +/* + * Edition of an optional field + */ +if ($action == 'edit' && !empty($attrname)) +{ + print "
"; + print load_fiche_titre($langs->trans("FieldEdition", $attrname)); + + require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php'; +} + +// End of page +llxFooter(); +$db->close(); diff --git a/htdocs/admin/mrp_extrafields.php b/htdocs/admin/mrp_extrafields.php new file mode 100644 index 00000000000..55df2a065d0 --- /dev/null +++ b/htdocs/admin/mrp_extrafields.php @@ -0,0 +1,113 @@ + + * Copyright (C) 2003 Jean-Louis Bergamo + * Copyright (C) 2004-2011 Laurent Destailleur + * Copyright (C) 2012 Regis Houssin + * Copyright (C) 2014 Florian Henry + * Copyright (C) 2015 Jean-François Ferry + * + * 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/mrp_extrafields.php + * \ingroup mrp + * \brief Page to setup extra fields of MOs + */ + +require '../main.inc.php'; +require_once DOL_DOCUMENT_ROOT.'/mrp/lib/mrp.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; + +// Load translation files required by the page +$langs->loadLangs(array('mrp', 'admin')); + +$extrafields = new ExtraFields($db); +$form = new Form($db); + +// List of supported format +$tmptype2label = ExtraFields::$type2label; +$type2label = array(''); +foreach ($tmptype2label as $key => $val) $type2label[$key] = $langs->transnoentitiesnoconv($val); + +$action = GETPOST('action', 'alpha'); +$attrname = GETPOST('attrname', 'alpha'); +$elementtype = 'mrp_mo'; + +if (!$user->admin) accessforbidden(); + + +/* + * Actions + */ + +require DOL_DOCUMENT_ROOT.'/core/actions_extrafields.inc.php'; + + + +/* + * View + */ + + +llxHeader('', $langs->trans("MrpSetupPage"), $help_url); + + +$linkback = ''.$langs->trans("BackToModuleList").''; +print load_fiche_titre($langs->trans("MrpSetupPage"), $linkback, 'title_setup'); + + +$head = mrpAdminPrepareHead(null); + +dol_fiche_head($head, 'mrp_extrafields', $langs->trans("ExtraFields"), -1, 'account'); + +require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php'; + +dol_fiche_end(); + + +// Buttons +if ($action != 'create' && $action != 'edit') +{ + print '
'; + print "".$langs->trans("NewAttribute").""; + print "
"; +} + + +/* + * Creation of an optional field + */ +if ($action == 'create') +{ + print '
'; + print load_fiche_titre($langs->trans('NewAttribute')); + + require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php'; +} + +/* + * Edition of an optional field + */ +if ($action == 'edit' && !empty($attrname)) +{ + print "
"; + print load_fiche_titre($langs->trans("FieldEdition", $attrname)); + + require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php'; +} + +// End of page +llxFooter(); +$db->close(); diff --git a/htdocs/bom/class/bom.class.php b/htdocs/bom/class/bom.class.php index 790487b4032..b23a96372c6 100644 --- a/htdocs/bom/class/bom.class.php +++ b/htdocs/bom/class/bom.class.php @@ -333,8 +333,10 @@ class BOM extends CommonObject public function fetch($id, $ref = null) { $result = $this->fetchCommon($id, $ref); + if ($result > 0 && !empty($this->table_element_line)) $this->fetchLines(); $this->calculateCosts(); + return $result; } diff --git a/htdocs/bom/lib/bom.lib.php b/htdocs/bom/lib/bom.lib.php index 1eb5fc52a5b..e88b1aa32a3 100644 --- a/htdocs/bom/lib/bom.lib.php +++ b/htdocs/bom/lib/bom.lib.php @@ -41,6 +41,11 @@ function bomAdminPrepareHead() $head[$h][2] = 'settings'; $h++; + $head[$h][0] = dol_buildpath("/admin/bom_extrafields.php", 1); + $head[$h][1] = $langs->trans("ExtraFields"); + $head[$h][2] = 'bom_extrafields'; + $h++; + /*$head[$h][0] = DOL_URL_ROOT."/bom/admin/about.php"; $head[$h][1] = $langs->trans("About"); $head[$h][2] = 'about'; diff --git a/htdocs/bom/tpl/objectline_title.tpl.php b/htdocs/bom/tpl/objectline_title.tpl.php index ab0184189a8..56e6cb59657 100644 --- a/htdocs/bom/tpl/objectline_title.tpl.php +++ b/htdocs/bom/tpl/objectline_title.tpl.php @@ -69,7 +69,7 @@ print ''.$form->textwithpicto($langs print ''.$form->textwithpicto($langs->trans('ManufacturingEfficiency'), $langs->trans('ValueOfMeansLoss')).''; // Cost -print ''.$langs->trans('CostPrice').''; +print ''.$form->textwithpicto($langs->trans("TotalCost"), $langs->trans("BOMTotalCost")).''; print ''; // No width to allow autodim diff --git a/htdocs/bom/tpl/objectline_view.tpl.php b/htdocs/bom/tpl/objectline_view.tpl.php index 667c66848ae..e1e94dc2076 100644 --- a/htdocs/bom/tpl/objectline_view.tpl.php +++ b/htdocs/bom/tpl/objectline_view.tpl.php @@ -113,7 +113,7 @@ if ($this->status == 0 && ($object_rights->write) && $action != 'selectlines') { $coldisplay++; if (($line->info_bits & 2) == 2 || !empty($disableedit)) { } else { - print 'id.'#line_'.$line->id.'">'.img_edit().''; + print 'id.'">'.img_edit().''; } print ''; diff --git a/htdocs/comm/action/card.php b/htdocs/comm/action/card.php index d733cb61ba3..860254756c9 100644 --- a/htdocs/comm/action/card.php +++ b/htdocs/comm/action/card.php @@ -111,6 +111,7 @@ $parameters = array('socid' => $socid); $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + /* * Actions */ @@ -317,7 +318,7 @@ if (empty($reshook) && $action == 'add') if (GETPOST("doneby") > 0) $object->userdoneid = GETPOST("doneby", "int"); } - $object->note_private = trim(GETPOST("note")); + $object->note_private = trim(GETPOST("note", "none")); if (isset($_POST["contactid"])) $object->contact = $contact; @@ -465,7 +466,7 @@ if (empty($reshook) && $action == 'update') $object->contactid = key($object->socpeopleassigned); } $object->fk_project = GETPOST("projectid", 'int'); - $object->note_private = GETPOST("note", "none"); + $object->note_private = trim(GETPOST("note", "none")); $object->fk_element = GETPOST("fk_element", "int"); $object->elementtype = GETPOST("elementtype", "alphanohtml"); @@ -1056,14 +1057,13 @@ if ($action == 'create') // Project if (!empty($conf->projet->enabled)) { - // Projet associe $langs->load("projects"); $projectid = GETPOST('projectid', 'int'); print ''.$langs->trans("Project").''; - $numproject = $formproject->select_projects((!empty($societe->id) ? $societe->id : -1), $projectid, 'projectid', 0, 0, 1, 1); + $numproject = $formproject->select_projects((!empty($societe->id) ? $societe->id : -1), $projectid, 'projectid', 0, 0, 1, 1, 0, 0, 0, '', 0, 0, 'maxwidth500'); print ' '; $urloption = '?action=create&donotclearsession=1'; @@ -1118,7 +1118,7 @@ if ($action == 'create') // Description print ''.$langs->trans("Description").''; require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $doleditor = new DolEditor('note', (GETPOST('note', 'none') ?GETPOST('note', 'none') : $object->note_private), '', 180, 'dolibarr_notes', 'In', true, true, $conf->fckeditor->enabled, ROWS_4, '90%'); + $doleditor = new DolEditor('note', (GETPOST('note', 'none') ? GETPOST('note', 'none') : $object->note_private), '', 180, 'dolibarr_notes', 'In', true, true, $conf->fckeditor->enabled, ROWS_4, '90%'); $doleditor->Create(); print ''; diff --git a/htdocs/comm/action/rapport/index.php b/htdocs/comm/action/rapport/index.php index 82477d307fc..aa1d53fcfca 100644 --- a/htdocs/comm/action/rapport/index.php +++ b/htdocs/comm/action/rapport/index.php @@ -35,8 +35,8 @@ require_once DOL_DOCUMENT_ROOT.'/core/modules/action/rapport.pdf.php'; $langs->loadLangs(array("agenda", "commercial")); $action = GETPOST('action', 'alpha'); -$month = GETPOST('month'); -$year = GETPOST('year'); +$month = GETPOST('month', 'int'); +$year = GETPOST('year', 'int'); $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST("sortfield", 'alpha'); @@ -119,9 +119,8 @@ if ($resql) print ''; print ''; print ''; - print ''; - print_barre_liste($langs->trans("EventReports"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_agenda', 0, '', '', $limit); + print_barre_liste($langs->trans("EventReports"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_agenda', 0, '', '', $limit, 0, 0, 1); $moreforfilter = ''; @@ -154,7 +153,7 @@ if ($resql) // Button to build doc print ''; - print 'month.'&year='.$obj->year.'">'.img_picto($langs->trans('BuildDoc'), 'filenew').''; + print 'month.'&year='.$obj->year.'">'.img_picto($langs->trans('BuildDoc'), 'filenew').''; print ''; $name = "actions-".$obj->month."-".$obj->year.".pdf"; diff --git a/htdocs/comm/remise.php b/htdocs/comm/remise.php index dc41845516a..53b32500a40 100644 --- a/htdocs/comm/remise.php +++ b/htdocs/comm/remise.php @@ -59,9 +59,9 @@ if (GETPOST('action', 'aZ09') == 'setremise') $discount_type = GETPOST('discount_type', 'int'); if (!empty($discount_type)) { - $result = $object->set_remise_supplier(price2num(GETPOST("remise")), GETPOST("note"), $user); + $result = $object->set_remise_supplier(price2num(GETPOST("remise")), GETPOST("note", "alphanohtml"), $user); } else { - $result = $object->set_remise_client(price2num(GETPOST("remise")), GETPOST("note"), $user); + $result = $object->set_remise_client(price2num(GETPOST("remise")), GETPOST("note", "alphanohtml"), $user); } if ($result > 0) @@ -187,7 +187,7 @@ if ($socid > 0) // Motif/Note print ''; - print $langs->trans("NoteReason").''; + print $langs->trans("NoteReason").''; print ""; diff --git a/htdocs/compta/bank/various_payment/list.php b/htdocs/compta/bank/various_payment/list.php index 5f68440809c..4e836f10af0 100644 --- a/htdocs/compta/bank/various_payment/list.php +++ b/htdocs/compta/bank/various_payment/list.php @@ -180,7 +180,7 @@ if ($result) print ''; print ''; - print_barre_liste($langs->trans("VariousPayments"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $totalnboflines, 'object_payment', 0, $newcardbutton, '', $limit, 0, 0, 1); + print_barre_liste($langs->trans("MenuVariousPayment"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $totalnboflines, 'object_payment', 0, $newcardbutton, '', $limit, 0, 0, 1); print '
'; print ''."\n"; diff --git a/htdocs/compta/charges/index.php b/htdocs/compta/charges/index.php index c64797b801c..1f69a6aa1c8 100644 --- a/htdocs/compta/charges/index.php +++ b/htdocs/compta/charges/index.php @@ -465,6 +465,7 @@ while ($j < $numlt) // Payment Salary +/* if (!empty($conf->salaries->enabled) && !empty($user->rights->salaries->read)) { if (!$mode || $mode != 'sconly') @@ -575,6 +576,7 @@ if (!empty($conf->salaries->enabled) && !empty($user->rights->salaries->read)) } } } +*/ print ''; diff --git a/htdocs/compta/facture/class/facture-rec.class.php b/htdocs/compta/facture/class/facture-rec.class.php index 71be89f30f5..8a13cf0f814 100644 --- a/htdocs/compta/facture/class/facture-rec.class.php +++ b/htdocs/compta/facture/class/facture-rec.class.php @@ -1349,7 +1349,7 @@ class FactureRec extends CommonInvoice $result = ''; - $label = ''.$langs->trans("ShowInvoice").''; + $label = ''.$langs->trans("RepeatableInvoice").''; if (!empty($this->ref)) { $label .= '
'.$langs->trans('Ref').': '.$this->ref; } diff --git a/htdocs/compta/paiement/cheque/card.php b/htdocs/compta/paiement/cheque/card.php index eeb578ad731..2fd885c5201 100644 --- a/htdocs/compta/paiement/cheque/card.php +++ b/htdocs/compta/paiement/cheque/card.php @@ -375,9 +375,10 @@ if ($action == 'new') $now = dol_now(); - print $langs->trans("SelectChequeTransactionAndGenerate").'

'."\n"; + print ''.$langs->trans("SelectChequeTransactionAndGenerate").'

'."\n"; print ''; + print ''; print ''; dol_fiche_head(); diff --git a/htdocs/compta/prelevement/class/bonprelevement.class.php b/htdocs/compta/prelevement/class/bonprelevement.class.php index 5db9ccde671..8cf77667a62 100644 --- a/htdocs/compta/prelevement/class/bonprelevement.class.php +++ b/htdocs/compta/prelevement/class/bonprelevement.class.php @@ -819,7 +819,7 @@ class BonPrelevement extends CommonObject * @param string $executiondate Date to execute the transfer * @param int $notrigger Disable triggers * @param string $type 'direct-debit' or 'bank-transfer' - * @return int <0 if KO, nbre of invoice withdrawed if OK + * @return int <0 if KO, No of invoice included into file if OK */ public function create($banque = 0, $agence = 0, $mode = 'real', $format = 'ALL', $executiondate = '', $notrigger = 0, $type = 'direct-debit') { @@ -831,7 +831,12 @@ class BonPrelevement extends CommonObject require_once DOL_DOCUMENT_ROOT."/compta/facture/class/facture.class.php"; require_once DOL_DOCUMENT_ROOT."/societe/class/societe.class.php"; - if (empty($format)) return 'ErrorBadParametersForDirectDebitFileCreate'; + if ($type != 'bank-transfer') { + if (empty($format)) { + $this->error = 'ErrorBadParametersForDirectDebitFileCreate'; + return -1; + } + } $error = 0; @@ -1091,6 +1096,7 @@ class BonPrelevement extends CommonObject // Fetch invoice $fact = new Facture($this->db); $fact->fetch($fac[0]); + /* * Add standing order * @@ -1163,14 +1169,15 @@ class BonPrelevement extends CommonObject $this->context['factures_prev'] = $factures_prev; // Generation of SEPA file $this->filename - $result = $this->generate($format, $executiondate); + // This also the the property $this->total that is included into file + $result = $this->generate($format, $executiondate, $type); } dol_syslog(__METHOD__."::End withdraw receipt, file ".$this->filename, LOG_DEBUG); } //var_dump($factures_prev);exit; /* - * Update total + * Update total defined after generation of file */ $sql = "UPDATE ".MAIN_DB_PREFIX."prelevement_bons"; $sql .= " SET amount = ".price2num($this->total); @@ -1455,7 +1462,7 @@ class BonPrelevement extends CommonObject /** - * Generate a withdrawal file. + * Generate a direct debit or credit transfer file. * Generation Formats: * - Europe: SEPA (France: CFONB no more supported, Spain: AEB19 if external module EsAEB is enabled) * - Others countries: Warning message @@ -1463,9 +1470,10 @@ class BonPrelevement extends CommonObject * * @param string $format FRST, RCUR or ALL * @param string $executiondate Date to execute transfer + * @param string $type 'direct-debit' or 'credit-transfer' * @return int >=0 if OK, <0 if KO */ - public function generate($format = 'ALL', $executiondate = '') + public function generate($format = 'ALL', $executiondate = '', $type = 'direct-debit') { global $conf, $langs, $mysoc; @@ -1473,7 +1481,7 @@ class BonPrelevement extends CommonObject $result = 0; - dol_syslog(get_class($this)."::generate build file ".$this->filename); + dol_syslog(get_class($this)."::generate build file=".$this->filename." type=".$type); $this->file = fopen($this->filename, "w"); if (empty($this->file)) @@ -1483,153 +1491,191 @@ class BonPrelevement extends CommonObject } $found = 0; + $this->total = 0; // Build file for European countries if ($mysoc->isInEEC()) { $found++; - /** - * SECTION CREATION FICHIER SEPA - */ - // SEPA Initialisation - $CrLf = "\n"; + if ($type == 'bank-transfer') { + print 'TODO'; + exit; + } else { + /** + * SECTION CREATION FICHIER SEPA + */ + // SEPA Initialisation + $CrLf = "\n"; - $now = dol_now(); + $now = dol_now(); - $dateTime_ECMA = dol_print_date($now, '%Y-%m-%dT%H:%M:%S'); + $dateTime_ECMA = dol_print_date($now, '%Y-%m-%dT%H:%M:%S'); - $date_actu = $now; - if (!empty($executiondate)) $date_actu = $executiondate; + $date_actu = $now; + if (!empty($executiondate)) $date_actu = $executiondate; - $dateTime_YMD = dol_print_date($date_actu, '%Y%m%d'); - $dateTime_YMDHMS = dol_print_date($date_actu, '%Y%m%d%H%M%S'); - $fileDebiteurSection = ''; - $fileEmetteurSection = ''; - $i = 0; - $this->total = 0; + $dateTime_YMD = dol_print_date($date_actu, '%Y%m%d'); + $dateTime_YMDHMS = dol_print_date($date_actu, '%Y%m%d%H%M%S'); + $fileDebiteurSection = ''; + $fileEmetteurSection = ''; + $i = 0; - /* - * Section Debitor (sepa Debiteurs bloc lines) - */ + /* + * Section Debitor (sepa Debiteurs bloc lines) + */ - $sql = "SELECT soc.code_client as code, soc.address, soc.zip, soc.town, c.code as country_code,"; - $sql .= " pl.client_nom as nom, pl.code_banque as cb, pl.code_guichet as cg, pl.number as cc, pl.amount as somme,"; - $sql .= " f.ref as fac, pf.fk_facture as idfac, rib.datec, rib.iban_prefix as iban, rib.bic as bic, rib.rowid as drum, rib.rum, rib.date_rum"; - $sql .= " FROM"; - $sql .= " ".MAIN_DB_PREFIX."prelevement_lignes as pl,"; - $sql .= " ".MAIN_DB_PREFIX."facture as f,"; - $sql .= " ".MAIN_DB_PREFIX."prelevement_facture as pf,"; - $sql .= " ".MAIN_DB_PREFIX."societe as soc,"; - $sql .= " ".MAIN_DB_PREFIX."c_country as c,"; - $sql .= " ".MAIN_DB_PREFIX."societe_rib as rib"; - $sql .= " WHERE pl.fk_prelevement_bons = ".$this->id; - $sql .= " AND pl.rowid = pf.fk_prelevement_lignes"; - $sql .= " AND pf.fk_facture = f.rowid"; - $sql .= " AND soc.fk_pays = c.rowid"; - $sql .= " AND soc.rowid = f.fk_soc"; - $sql .= " AND rib.fk_soc = f.fk_soc"; - $sql .= " AND rib.default_rib = 1"; - $sql .= " AND rib.type = 'ban'"; - //print $sql; + $sql = "SELECT soc.code_client as code, soc.address, soc.zip, soc.town, c.code as country_code,"; + $sql .= " pl.client_nom as nom, pl.code_banque as cb, pl.code_guichet as cg, pl.number as cc, pl.amount as somme,"; + $sql .= " f.ref as fac, pf.fk_facture as idfac, rib.datec, rib.iban_prefix as iban, rib.bic as bic, rib.rowid as drum, rib.rum, rib.date_rum"; + $sql .= " FROM"; + $sql .= " ".MAIN_DB_PREFIX."prelevement_lignes as pl,"; + $sql .= " ".MAIN_DB_PREFIX."facture as f,"; + $sql .= " ".MAIN_DB_PREFIX."prelevement_facture as pf,"; + $sql .= " ".MAIN_DB_PREFIX."societe as soc,"; + $sql .= " ".MAIN_DB_PREFIX."c_country as c,"; + $sql .= " ".MAIN_DB_PREFIX."societe_rib as rib"; + $sql .= " WHERE pl.fk_prelevement_bons = ".$this->id; + $sql .= " AND pl.rowid = pf.fk_prelevement_lignes"; + $sql .= " AND pf.fk_facture = f.rowid"; + $sql .= " AND soc.fk_pays = c.rowid"; + $sql .= " AND soc.rowid = f.fk_soc"; + $sql .= " AND rib.fk_soc = f.fk_soc"; + $sql .= " AND rib.default_rib = 1"; + $sql .= " AND rib.type = 'ban'"; + //print $sql; - // Define $fileDebiteurSection. One section DrctDbtTxInf per invoice. - $resql = $this->db->query($sql); - if ($resql) - { - $num = $this->db->num_rows($resql); - while ($i < $num) + // Define $fileDebiteurSection. One section DrctDbtTxInf per invoice. + $resql = $this->db->query($sql); + if ($resql) { - $obj = $this->db->fetch_object($resql); - $daterum = (!empty($obj->date_rum)) ? $this->db->jdate($obj->date_rum) : $this->db->jdate($obj->datec); - $fileDebiteurSection .= $this->EnregDestinataireSEPA($obj->code, $obj->nom, $obj->address, $obj->zip, $obj->town, $obj->country_code, $obj->cb, $obj->cg, $obj->cc, $obj->somme, $obj->fac, $obj->idfac, $obj->iban, $obj->bic, $daterum, $obj->drum, $obj->rum); - $this->total = $this->total + $obj->somme; - $i++; + $num = $this->db->num_rows($resql); + while ($i < $num) + { + $obj = $this->db->fetch_object($resql); + $daterum = (!empty($obj->date_rum)) ? $this->db->jdate($obj->date_rum) : $this->db->jdate($obj->datec); + $fileDebiteurSection .= $this->EnregDestinataireSEPA($obj->code, $obj->nom, $obj->address, $obj->zip, $obj->town, $obj->country_code, $obj->cb, $obj->cg, $obj->cc, $obj->somme, $obj->fac, $obj->idfac, $obj->iban, $obj->bic, $daterum, $obj->drum, $obj->rum); + $this->total = $this->total + $obj->somme; + $i++; + } + $nbtotalDrctDbtTxInf = $i; + } + else + { + fputs($this->file, 'ERROR DEBITOR '.$sql.$CrLf); // DEBITOR = Customers + $result = -2; } - $nbtotalDrctDbtTxInf = $i; - } - else - { - fputs($this->file, 'ERROR DEBITOR '.$sql.$CrLf); // DEBITOR = Customers - $result = -2; - } - // Define $fileEmetteurSection. Start of bloc PmtInf. Will contains all DrctDbtTxInf - if ($result != -2) - { - $fileEmetteurSection .= $this->EnregEmetteurSEPA($conf, $date_actu, $nbtotalDrctDbtTxInf, $this->total, $CrLf, $format); - } - else - { - fputs($this->file, 'ERROR CREDITOR'.$CrLf); // CREDITOR = My company - } + // Define $fileEmetteurSection. Start of bloc PmtInf. Will contains all DrctDbtTxInf + if ($result != -2) + { + $fileEmetteurSection .= $this->EnregEmetteurSEPA($conf, $date_actu, $nbtotalDrctDbtTxInf, $this->total, $CrLf, $format); + } + else + { + fputs($this->file, 'ERROR CREDITOR'.$CrLf); // CREDITOR = My company + } - /** - * SECTION CREATION SEPA FILE - */ - // SEPA File Header - fputs($this->file, '<'.'?xml version="1.0" encoding="UTF-8" standalone="yes"?'.'>'.$CrLf); - fputs($this->file, ''.$CrLf); - fputs($this->file, ' '.$CrLf); - // SEPA Group header - fputs($this->file, ' '.$CrLf); - fputs($this->file, ' '.('PREL'.$dateTime_YMD.'/REF'.$this->id).''.$CrLf); - fputs($this->file, ' '.$dateTime_ECMA.''.$CrLf); - fputs($this->file, ' '.$i.''.$CrLf); - fputs($this->file, ' '.$this->total.''.$CrLf); - fputs($this->file, ' '.$CrLf); - fputs($this->file, ' '.strtoupper(dol_string_unaccent($this->raison_sociale)).''.$CrLf); - fputs($this->file, ' '.$CrLf); - fputs($this->file, ' '.$CrLf); - fputs($this->file, ' '.$CrLf); - fputs($this->file, ' '.$conf->global->PRELEVEMENT_ICS.''.$CrLf); - fputs($this->file, ' '.$CrLf); - fputs($this->file, ' '.$CrLf); - fputs($this->file, ' '.$CrLf); - fputs($this->file, ' '.$CrLf); - fputs($this->file, ' '.$CrLf); - // SEPA File Emetteur - if ($result != -2) - { fputs($this-> file, $fileEmetteurSection); } - // SEPA File Debiteurs - if ($result != -2) - { fputs($this-> file, $fileDebiteurSection); } - // SEPA FILE FOOTER - fputs($this->file, ' '.$CrLf); - fputs($this->file, ' '.$CrLf); - fputs($this->file, ''.$CrLf); + /** + * SECTION CREATION SEPA FILE + */ + // SEPA File Header + fputs($this->file, '<'.'?xml version="1.0" encoding="UTF-8" standalone="yes"?'.'>'.$CrLf); + fputs($this->file, ''.$CrLf); + fputs($this->file, ' '.$CrLf); + // SEPA Group header + fputs($this->file, ' '.$CrLf); + fputs($this->file, ' '.('PREL'.$dateTime_YMD.'/REF'.$this->id).''.$CrLf); + fputs($this->file, ' '.$dateTime_ECMA.''.$CrLf); + fputs($this->file, ' '.$i.''.$CrLf); + fputs($this->file, ' '.$this->total.''.$CrLf); + fputs($this->file, ' '.$CrLf); + fputs($this->file, ' '.strtoupper(dol_string_unaccent($this->raison_sociale)).''.$CrLf); + fputs($this->file, ' '.$CrLf); + fputs($this->file, ' '.$CrLf); + fputs($this->file, ' '.$CrLf); + fputs($this->file, ' '.$conf->global->PRELEVEMENT_ICS.''.$CrLf); + fputs($this->file, ' '.$CrLf); + fputs($this->file, ' '.$CrLf); + fputs($this->file, ' '.$CrLf); + fputs($this->file, ' '.$CrLf); + fputs($this->file, ' '.$CrLf); + // SEPA File Emetteur + if ($result != -2) + { fputs($this-> file, $fileEmetteurSection); } + // SEPA File Debiteurs + if ($result != -2) + { fputs($this-> file, $fileDebiteurSection); } + // SEPA FILE FOOTER + fputs($this->file, ' '.$CrLf); + fputs($this->file, ' '.$CrLf); + fputs($this->file, ''.$CrLf); + } } // Build file for Other Countries with unknow format if (!$found) { - $this->total = 0; - $sql = "SELECT pl.amount"; - $sql .= " FROM"; - $sql .= " ".MAIN_DB_PREFIX."prelevement_lignes as pl,"; - $sql .= " ".MAIN_DB_PREFIX."facture as f,"; - $sql .= " ".MAIN_DB_PREFIX."prelevement_facture as pf"; - $sql .= " WHERE pl.fk_prelevement_bons = ".$this->id; - $sql .= " AND pl.rowid = pf.fk_prelevement_lignes"; - $sql .= " AND pf.fk_facture = f.rowid"; + if ($type == 'bank-transfer') { + $sql = "SELECT pl.amount"; + $sql .= " FROM"; + $sql .= " ".MAIN_DB_PREFIX."prelevement_lignes as pl,"; + $sql .= " ".MAIN_DB_PREFIX."facture_fourn as f,"; + $sql .= " ".MAIN_DB_PREFIX."prelevement_facture as pf"; + $sql .= " WHERE pl.fk_prelevement_bons = ".$this->id; + $sql .= " AND pl.rowid = pf.fk_prelevement_lignes"; + $sql .= " AND pf.fk_facture_fourn = f.rowid"; - //Lines - $i = 0; - $resql = $this->db->query($sql); - if ($resql) - { - $num = $this->db->num_rows($resql); - - while ($i < $num) + // Lines + $i = 0; + $resql = $this->db->query($sql); + if ($resql) { - $obj = $this->db->fetch_object($resql); - $this->total = $this->total + $obj->amount; - $i++; + $num = $this->db->num_rows($resql); + + while ($i < $num) + { + $obj = $this->db->fetch_object($resql); + $this->total = $this->total + $obj->amount; + + // TODO Write record into file + $i++; + } + } + else + { + $result = -2; + } + } else { + $sql = "SELECT pl.amount"; + $sql .= " FROM"; + $sql .= " ".MAIN_DB_PREFIX."prelevement_lignes as pl,"; + $sql .= " ".MAIN_DB_PREFIX."facture as f,"; + $sql .= " ".MAIN_DB_PREFIX."prelevement_facture as pf"; + $sql .= " WHERE pl.fk_prelevement_bons = ".$this->id; + $sql .= " AND pl.rowid = pf.fk_prelevement_lignes"; + $sql .= " AND pf.fk_facture = f.rowid"; + + // Lines + $i = 0; + $resql = $this->db->query($sql); + if ($resql) + { + $num = $this->db->num_rows($resql); + + while ($i < $num) + { + $obj = $this->db->fetch_object($resql); + $this->total = $this->total + $obj->amount; + + // TODO Write record into file + $i++; + } + } + else + { + $result = -2; } - } - else - { - $result = -2; } $langs->load('withdrawals'); diff --git a/htdocs/compta/prelevement/create.php b/htdocs/compta/prelevement/create.php index 80055b20d72..ff25af5e0e9 100644 --- a/htdocs/compta/prelevement/create.php +++ b/htdocs/compta/prelevement/create.php @@ -191,7 +191,8 @@ print ''; if ($nb) { if ($pricetowithdraw) { print $langs->trans('ExecutionDate').' '; - print $form->selectDate(); + $datere = dol_mktime(0, 0, 0, GETPOST('remonth', 'int'), GETPOST('reday', 'int'), GETPOST('reyear', 'int')); + print $form->selectDate($datere, 're'); if ($mysoc->isInEEC()) { $title = $langs->trans("CreateForSepa"); @@ -200,7 +201,10 @@ if ($nb) { } if ($type != 'bank-transfer') { - print ''; + print ''; } print ''; } else { diff --git a/htdocs/compta/resultat/index.php b/htdocs/compta/resultat/index.php index ad81a3943c1..b912723adfc 100644 --- a/htdocs/compta/resultat/index.php +++ b/htdocs/compta/resultat/index.php @@ -500,7 +500,7 @@ elseif ($modecompta == "BOOKKEEPING") } /* - * Charges sociales non deductibles + * Social contributions */ $subtotal_ht = 0; @@ -513,7 +513,6 @@ if (!empty($conf->tax->enabled) && ($modecompta == 'CREANCES-DETTES' || $modecom $sql .= " FROM ".MAIN_DB_PREFIX."c_chargesociales as c"; $sql .= ", ".MAIN_DB_PREFIX."chargesociales as cs"; $sql .= " WHERE cs.fk_type = c.id"; - $sql .= " AND c.deductible = 0"; if (!empty($date_start) && !empty($date_end)) $sql .= " AND cs.date_ech >= '".$db->idate($date_start)."' AND cs.date_ech <= '".$db->idate($date_end)."'"; } @@ -525,7 +524,6 @@ if (!empty($conf->tax->enabled) && ($modecompta == 'CREANCES-DETTES' || $modecom $sql .= ", ".MAIN_DB_PREFIX."paiementcharge as p"; $sql .= " WHERE p.fk_charge = cs.rowid"; $sql .= " AND cs.fk_type = c.id"; - $sql .= " AND c.deductible = 0"; if (!empty($date_start) && !empty($date_end)) $sql .= " AND p.datep >= '".$db->idate($date_start)."' AND p.datep <= '".$db->idate($date_end)."'"; } @@ -533,69 +531,7 @@ if (!empty($conf->tax->enabled) && ($modecompta == 'CREANCES-DETTES' || $modecom $sql .= " AND cs.entity = ".$conf->entity; $sql .= " GROUP BY c.libelle, dm"; - dol_syslog("get social contributions deductible=0 ", LOG_DEBUG); - $result = $db->query($sql); - if ($result) { - $num = $db->num_rows($result); - $i = 0; - if ($num) { - while ($i < $num) { - $obj = $db->fetch_object($result); - - if (!isset($decaiss[$obj->dm])) $decaiss[$obj->dm] = 0; - $decaiss[$obj->dm] += $obj->amount; - - if (!isset($decaiss_ttc[$obj->dm])) $decaiss_ttc[$obj->dm] = 0; - $decaiss_ttc[$obj->dm] += $obj->amount; - - $i++; - } - } - } else { - dol_print_error($db); - } -} -elseif ($modecompta == "BOOKKEEPING") -{ - // Nothing from this table -} - - -/* - * Charges sociales deductibles - */ - -$subtotal_ht = 0; -$subtotal_ttc = 0; -if (!empty($conf->tax->enabled) && ($modecompta == 'CREANCES-DETTES' || $modecompta == "RECETTES-DEPENSES")) -{ - if ($modecompta == 'CREANCES-DETTES') - { - $sql = "SELECT c.libelle as nom, date_format(cs.date_ech,'%Y-%m') as dm, sum(cs.amount) as amount"; - $sql .= " FROM ".MAIN_DB_PREFIX."c_chargesociales as c"; - $sql .= ", ".MAIN_DB_PREFIX."chargesociales as cs"; - $sql .= " WHERE cs.fk_type = c.id"; - $sql .= " AND c.deductible = 1"; - if (!empty($date_start) && !empty($date_end)) - $sql .= " AND cs.date_ech >= '".$db->idate($date_start)."' AND cs.date_ech <= '".$db->idate($date_end)."'"; - } - elseif ($modecompta == "RECETTES-DEPENSES") - { - $sql = "SELECT c.libelle as nom, date_format(p.datep,'%Y-%m') as dm, sum(p.amount) as amount"; - $sql .= " FROM ".MAIN_DB_PREFIX."c_chargesociales as c"; - $sql .= ", ".MAIN_DB_PREFIX."chargesociales as cs"; - $sql .= ", ".MAIN_DB_PREFIX."paiementcharge as p"; - $sql .= " WHERE p.fk_charge = cs.rowid"; - $sql .= " AND cs.fk_type = c.id"; - $sql .= " AND c.deductible = 1"; - if (!empty($date_start) && !empty($date_end)) - $sql .= " AND p.datep >= '".$db->idate($date_start)."' AND p.datep <= '".$db->idate($date_end)."'"; - } - - $sql .= " AND cs.entity = ".$conf->entity; - $sql .= " GROUP BY c.libelle, dm"; - - dol_syslog("get social contributions paid deductible=1", LOG_DEBUG); + dol_syslog("get social contributions", LOG_DEBUG); $result = $db->query($sql); if ($result) { $num = $db->num_rows($result); @@ -735,7 +671,7 @@ elseif ($modecompta == 'BOOKKEEPING') { /* - * Donation get dunning paiement + * Donation get dunning payments */ if (!empty($conf->don->enabled) && ($modecompta == 'CREANCES-DETTES' || $modecompta == "RECETTES-DEPENSES")) diff --git a/htdocs/contrat/card.php b/htdocs/contrat/card.php index 33c1d098b63..e181874303f 100644 --- a/htdocs/contrat/card.php +++ b/htdocs/contrat/card.php @@ -2128,13 +2128,6 @@ else else print ''; } - if (!empty($conf->facture->enabled) && $object->statut > 0) - { - $langs->load("bills"); - if ($user->rights->facture->creer) print ''; - else print ''; - } - if (!empty($conf->commande->enabled) && $object->statut > 0 && $object->nbofservicesclosed < $nbofservices) { $langs->load("orders"); @@ -2142,9 +2135,11 @@ else else print ''; } - // Clone - if ($user->rights->contrat->creer) { - print ''; + if (!empty($conf->facture->enabled) && $object->statut > 0) + { + $langs->load("bills"); + if ($user->rights->facture->creer) print ''; + else print ''; } if ($object->nbofservicesclosed > 0 || $object->nbofserviceswait > 0) @@ -2178,10 +2173,13 @@ else //} } - // On peut supprimer entite si - // - Droit de creer + mode brouillon (erreur creation) - // - Droit de supprimer - if (($user->rights->contrat->creer && $object->statut == 0) || $user->rights->contrat->supprimer) + // Clone + if ($user->rights->contrat->creer) { + print ''; + } + + // Delete + if (($user->rights->contrat->creer && $object->statut == $object::STATUS_DRAFT) || $user->rights->contrat->supprimer) { print ''; } diff --git a/htdocs/core/actions_addupdatedelete.inc.php b/htdocs/core/actions_addupdatedelete.inc.php index 66ed09413ef..912c9953229 100644 --- a/htdocs/core/actions_addupdatedelete.inc.php +++ b/htdocs/core/actions_addupdatedelete.inc.php @@ -96,6 +96,12 @@ if ($action == 'add' && !empty($permissiontoadd)) } } + // Fill array 'array_options' with data from add form + if (!$error) { + $ret = $extrafields->setOptionalsFromPost(null, $object); + if ($ret < 0) $error++; + } + if (!$error) { $result = $object->create($user); @@ -174,6 +180,12 @@ if ($action == 'update' && !empty($permissiontoadd)) } } + // Fill array 'array_options' with data from add form + if (!$error) { + $ret = $extrafields->setOptionalsFromPost(null, $object, '@GETPOSTISSET'); + if ($ret < 0) $error++; + } + if (!$error) { $result = $object->update($user); @@ -201,7 +213,14 @@ if ($action == "update_extras" && !empty($permissiontoadd)) $attributekey = GETPOST('attribute', 'alpha'); $attributekeylong = 'options_'.$attributekey; - $object->array_options['options_'.$attributekey] = GETPOST($attributekeylong, ' alpha'); + + if (GETPOSTISSET($attributekeylong.'day') && GETPOSTISSET($attributekeylong.'month') && GETPOSTISSET($attributekeylong.'year')) { + // This is properties of a date + $object->array_options['options_'.$attributekey] = dol_mktime(GETPOST($attributekeylong.'hour', 'int'), GETPOST($attributekeylong.'min', 'int'), GETPOST($attributekeylong.'sec', 'int'), GETPOST($attributekeylong.'month', 'int'), GETPOST($attributekeylong.'day', 'int'), GETPOST($attributekeylong.'year', 'int')); + //var_dump(dol_print_date($object->array_options['options_'.$attributekey]));exit; + } else { + $object->array_options['options_'.$attributekey] = GETPOST($attributekeylong, ' alpha'); + } $result = $object->insertExtraFields(empty($triggermodname) ? '' : $triggermodname, $user); if ($result > 0) diff --git a/htdocs/core/actions_fetchobject.inc.php b/htdocs/core/actions_fetchobject.inc.php index 268d37d92d2..e85e3ed629a 100644 --- a/htdocs/core/actions_fetchobject.inc.php +++ b/htdocs/core/actions_fetchobject.inc.php @@ -47,8 +47,10 @@ if (($id > 0 || (!empty($ref) && !in_array($action, array('create', 'createtask' setEventMessages('Fetch on object (type '.get_class($object).') return an error without filling $object->error nor $object->errors', null, 'errors'); } } - else setEventMessages($object->error, $object->errors, 'errors'); - $action = ''; + else { + setEventMessages($object->error, $object->errors, 'errors'); + } + $action = ''; } } } diff --git a/htdocs/core/ajax/row.php b/htdocs/core/ajax/row.php index 852910ce9e3..afb33907593 100644 --- a/htdocs/core/ajax/row.php +++ b/htdocs/core/ajax/row.php @@ -47,8 +47,8 @@ top_httphead(); print ''."\n"; // Registering the location of boxes -if ((!empty($_POST['roworder'])) && (!empty($_POST['table_element_line'])) - && (!empty($_POST['fk_element'])) && (!empty($_POST['element_id']))) +if (GETPOST('roworder', 'alpha') && GETPOST('table_element_line', 'alpha', 2) + && GETPOST('fk_element', 'alpha', 2) && GETPOST('element_id', 'int', 2)) { $roworder = GETPOST('roworder', 'alpha', 2); $table_element_line = GETPOST('table_element_line', 'alpha', 2); diff --git a/htdocs/core/boxes/box_services_contracts.php b/htdocs/core/boxes/box_services_contracts.php index 9d96d11f64d..7d6d2b0ee10 100644 --- a/htdocs/core/boxes/box_services_contracts.php +++ b/htdocs/core/boxes/box_services_contracts.php @@ -143,7 +143,7 @@ class box_services_contracts extends ModeleBoxes $thirdpartytmp->code_compta_fournisseur = $objp->code_compta_fournisseur; $dateline = $this->db->jdate($objp->date_line); - if ($contractstatic->statut == Contrat::STATUS_VALIDATED && $objp->statut == ContratLigne::STATUS_OPEN && ($dateline + $conf->contrat->services->expires->warning_delay) < $now) $late = img_warning($langs->trans("Late")); + if ($contractstatic->statut == Contrat::STATUS_VALIDATED && $objp->statut == ContratLigne::STATUS_OPEN && !empty($dateline) && ($dateline + $conf->contrat->services->expires->warning_delay) < $now) $late = img_warning($langs->trans("Late")); // Multilangs if (!empty($conf->global->MAIN_MULTILANGS) && $objp->product_id > 0) // if option multilang is on diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 138d4d0a62b..9601320af49 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -5848,7 +5848,7 @@ abstract class CommonObject * Update an extra field value for the current object. * 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 (without starting 'options_') + * @param string $key Key of the extrafield to update (without starting 'options_') * @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 @@ -7159,8 +7159,6 @@ abstract class CommonObject $html_id = (empty($this->id) ? '' : 'extrarow-'.$this->element.'_'.$key.'_'.$this->id); - $out .= ''; - if (!empty($conf->global->MAIN_EXTRAFIELDS_USE_TWO_COLUMS) && ($e % 2) == 0) { $colspan = '0'; } if ($action == 'selectlines') { $colspan++; } @@ -7190,6 +7188,7 @@ abstract class CommonObject $labeltoshow = $langs->trans($label); $helptoshow = $langs->trans($extrafields->attributes[$this->table_element]['help'][$key]); + $out .= ''; $out .= '
setVarsFromFetchObj($obj); + + // Retreive all extrafield + // fetch optionals attributes and labels + $this->fetch_optionals(); + return $this->id; } else @@ -8150,6 +8154,9 @@ abstract class CommonObject $sql .= ' FROM '.MAIN_DB_PREFIX.$objectline->table_element; $sql .= ' WHERE fk_'.$this->element.' = '.$this->id; if ($morewhere) $sql .= $morewhere; + if (isset($objectline->fields['position'])) { + $sql .= $this->db->order('position', 'ASC'); + } $resql = $this->db->query($sql); if ($resql) diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php index caf43f94342..90fc879bd17 100644 --- a/htdocs/core/class/extrafields.class.php +++ b/htdocs/core/class/extrafields.class.php @@ -2017,7 +2017,9 @@ class ExtraFields * * @param array $extralabels Deprecated (old $array of extrafields, now set this to null) * @param object $object Object - * @param string $onlykey Only the following key is filled. When we make update of only one extrafield ($action = 'update_extras'), calling page must set this to avoid to have other extrafields being reset. + * @param string $onlykey Only some keys are filled:$this + * 'string' => When we make update of only one extrafield ($action = 'update_extras'), calling page can set this to avoid to have other extrafields being reset. + * '@GETPOSTISSET' => When we make update of extrafields ($action = 'update'), calling page can set this to avoid to have fields not into POST being reset. * @return int 1 if array_options set, 0 if no value, -1 if error (field required missing for example) */ public function setOptionalsFromPost($extralabels, &$object, $onlykey = '') @@ -2034,7 +2036,8 @@ class ExtraFields // Get extra fields foreach ($extralabels as $key => $value) { - if (!empty($onlykey) && $key != $onlykey) continue; + if (!empty($onlykey) && $onlykey != '@GETPOSTISSET' && $key != $onlykey) continue; + if (!empty($onlykey) && $onlykey == '@GETPOSTISSET' && ! GETPOSTISSET('options_'.$key)) continue; $key_type = $this->attributes[$object->table_element]['type'][$key]; if ($key_type == 'separate') continue; diff --git a/htdocs/core/js/lib_foot.js.php b/htdocs/core/js/lib_foot.js.php index 40596596b97..d04379210a6 100644 --- a/htdocs/core/js/lib_foot.js.php +++ b/htdocs/core/js/lib_foot.js.php @@ -184,7 +184,8 @@ print ' { if (this.href) { - this.href=this.href+\'&page_y=\'+page_y; + var hrefarray = this.href.split("#", 2); + this.href=hrefarray[0]+\'&page_y=\'+page_y; console.log("We click on tag with .reposition class. this.ref is now "+this.href); } else diff --git a/htdocs/core/lib/ajax.lib.php b/htdocs/core/lib/ajax.lib.php index 1d3e80b90be..fc481e70957 100644 --- a/htdocs/core/lib/ajax.lib.php +++ b/htdocs/core/lib/ajax.lib.php @@ -61,7 +61,7 @@ function ajax_autocompleter($selected, $htmlname, $url, $urloption = '', $minLen $script .= '