diff --git a/.travis.yml b/.travis.yml index b3e57791fc8..529f3ea0ae3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -328,7 +328,7 @@ script: php upgrade2.php 6.0.0 7.0.0 MAIN_MODULE_WEBSITE,MAIN_MODULE_SUPPLIERPROPOSAL > $TRAVIS_BUILD_DIR/upgrade600700-2.log php step5.php 6.0.0 7.0.0 > $TRAVIS_BUILD_DIR/upgrade600700-3.log php upgrade.php 7.0.0 8.0.0 ignoredbversion > $TRAVIS_BUILD_DIR/upgrade700800.log - php upgrade2.php 7.0.0 8.0.0 > $TRAVIS_BUILD_DIR/upgrade700800-2.log + php upgrade2.php 7.0.0 8.0.0 MAIN_MODULE_TICKETSUP > $TRAVIS_BUILD_DIR/upgrade700800-2.log php step5.php 7.0.0 8.0.0 > $TRAVIS_BUILD_DIR/upgrade700800-3.log cd - set +e diff --git a/.tx/config b/.tx/config index 89d123b0362..14d735d8610 100644 --- a/.tx/config +++ b/.tx/config @@ -356,6 +356,12 @@ source_file = htdocs/langs/en_US/supplier_proposal.lang source_lang = en_US type = MOZILLAPROPERTIES +[dolibarr.ticketsup] +file_filter = htdocs/langs//ticketsup.lang +source_file = htdocs/langs/en_US/ticketsup.lang +source_lang = en_US +type = MOZILLAPROPERTIES + [dolibarr.trips] file_filter = htdocs/langs//trips.lang source_file = htdocs/langs/en_US/trips.lang diff --git a/htdocs/accountancy/bookkeeping/card.php b/htdocs/accountancy/bookkeeping/card.php index f0042f962bb..e9f50e77715 100644 --- a/htdocs/accountancy/bookkeeping/card.php +++ b/htdocs/accountancy/bookkeeping/card.php @@ -153,13 +153,13 @@ else if ($action == "add") { $book->label_operation= $label_operation; $book->debit = $debit; $book->credit = $credit; - $book->doc_date = GETPOST('doc_date'); - $book->doc_type = GETPOST('doc_type'); + $book->doc_date = GETPOST('doc_date','alpha'); + $book->doc_type = GETPOST('doc_type','alpha'); $book->piece_num = $piece_num; - $book->doc_ref = GETPOST('doc_ref'); - $book->code_journal = GETPOST('code_journal'); - $book->fk_doc = GETPOST('fk_doc'); - $book->fk_docdet = GETPOST('fk_docdet'); + $book->doc_ref = GETPOST('doc_ref','alpha'); + $book->code_journal = GETPOST('code_journal','alpha'); + $book->fk_doc = GETPOST('fk_doc','alpha'); + $book->fk_docdet = GETPOST('fk_docdet','alpha'); if (floatval($debit) != 0.0) { $book->montant = $debit; @@ -210,7 +210,7 @@ else if ($action == "confirm_create") { $book = new BookKeeping($db); - if (! GETPOST('code_journal') || GETPOST('code_journal') == '-1') { + if (! GETPOST('code_journal','alpha') || GETPOST('code_journal','alpha') == '-1') { setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv("Journal")), null, 'errors'); $action='create'; $error++; @@ -226,11 +226,11 @@ else if ($action == "confirm_create") { $book->label_compte = ''; $book->debit = 0; $book->credit = 0; - $book->doc_date = $date_start = dol_mktime(0, 0, 0, GETPOST('doc_datemonth'), GETPOST('doc_dateday'), GETPOST('doc_dateyear')); - $book->doc_type = GETPOST('doc_type'); - $book->piece_num = GETPOST('next_num_mvt'); - $book->doc_ref = GETPOST('doc_ref'); - $book->code_journal = GETPOST('code_journal'); + $book->doc_date = $date_start = dol_mktime(0, 0, 0, GETPOST('doc_datemonth','int'), GETPOST('doc_dateday','int'), GETPOST('doc_dateyear','int')); + $book->doc_type = GETPOST('doc_type','alpha'); + $book->piece_num = GETPOST('next_num_mvt','alpha'); + $book->doc_ref = GETPOST('doc_ref','alpha'); + $book->code_journal = GETPOST('code_journal','alpha'); $book->fk_doc = 0; $book->fk_docdet = 0; $book->montant = 0; @@ -265,8 +265,8 @@ if ($action == 'setdate') { } if ($action == 'setjournal') { - $journaldoc = trim(GETPOST('code_journal')); - $result = $object->updateByMvt($piece_num,'code_journal',$journaldoc,$mode); + $journaldoc = trim(GETPOST('code_journal','alpha')); + $result = $object->updateByMvt($piece_num, 'code_journal', $journaldoc, $mode); if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); } else { @@ -279,7 +279,7 @@ if ($action == 'setjournal') { } if ($action == 'setdocref') { - $refdoc = trim(GETPOST('doc_ref')); + $refdoc = trim(GETPOST('doc_ref','alpha')); $result = $object->updateByMvt($piece_num,'doc_ref',$refdoc,$mode); if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); @@ -476,11 +476,11 @@ if ($action == 'create') print ''; print ''; print ''; - print ''; + print ''; print ''; print ''; } else { - print $book->doc_ref ; + print $book->doc_ref ; } print ''; print ''; diff --git a/htdocs/accountancy/bookkeeping/list.php b/htdocs/accountancy/bookkeeping/list.php index ad8be2608c1..749033f8392 100644 --- a/htdocs/accountancy/bookkeeping/list.php +++ b/htdocs/accountancy/bookkeeping/list.php @@ -694,7 +694,7 @@ if ($num > 0) } // Action column - print ''; + print ''; print '' . img_edit() . ' '; print '' . img_delete() . ''; print ''; diff --git a/htdocs/accountancy/class/bookkeeping.class.php b/htdocs/accountancy/class/bookkeeping.class.php index 16f40139a38..13b25599280 100644 --- a/htdocs/accountancy/class/bookkeeping.class.php +++ b/htdocs/accountancy/class/bookkeeping.class.php @@ -501,7 +501,7 @@ class BookKeeping extends CommonObject } if (! $error) { - $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX . $this->table_element); + $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX . $this->table_element . $mode); if (! $notrigger) { // Uncomment this and change MYOBJECT to your own tag if you @@ -1101,7 +1101,7 @@ class BookKeeping extends CommonObject $this->db->begin(); $sql = "UPDATE " . MAIN_DB_PREFIX . $this->table_element . $mode . " as ab"; - $sql .= ' SET ab.' . $field . '=' . (is_numeric($value)?$value:"'".$value."'"); + $sql .= ' SET ab.' . $field . '=' . (is_numeric($value)?$value:"'".$this->db->escape($value)."'"); $sql .= ' WHERE ab.piece_num=' . $piece_num ; $resql = $this->db->query($sql); @@ -1184,7 +1184,7 @@ class BookKeeping extends CommonObject // first check if line not yet in bookkeeping $sql = "DELETE"; $sql .= " FROM " . MAIN_DB_PREFIX . $this->table_element; - $sql .= " WHERE import_key = '" . $importkey . "'"; + $sql .= " WHERE import_key = '" . $this->db->escape($importkey) . "'"; $resql = $this->db->query($sql); @@ -1222,7 +1222,7 @@ class BookKeeping extends CommonObject $sql.= " FROM " . MAIN_DB_PREFIX . $this->table_element.$mode; $sql.= " WHERE 1 = 1"; if (! empty($delyear)) $sql.= " AND YEAR(doc_date) = " . $delyear; // FIXME Must use between - if (! empty($journal)) $sql.= " AND code_journal = '".$journal."'"; + if (! empty($journal)) $sql.= " AND code_journal = '".$this->db->escape($journal)."'"; $sql .= " AND entity IN (" . getEntity('accountancy') . ")"; $resql = $this->db->query($sql); @@ -1254,7 +1254,7 @@ class BookKeeping extends CommonObject // first check if line not yet in bookkeeping $sql = "DELETE"; $sql .= " FROM " . MAIN_DB_PREFIX . $this->table_element; - $sql .= " WHERE piece_num = " . $piecenum; + $sql .= " WHERE piece_num = " . (int) $piecenum; $sql .= " AND entity IN (" . getEntity('accountancy') . ")"; $resql = $this->db->query($sql); diff --git a/htdocs/adherents/card.php b/htdocs/adherents/card.php index de4c0100c48..81757aab9e0 100644 --- a/htdocs/adherents/card.php +++ b/htdocs/adherents/card.php @@ -298,38 +298,38 @@ if (empty($reshook)) $object->oldcopy = clone $object; // Change values - $object->civility_id = trim($_POST["civility_id"]); - $object->firstname = trim($_POST["firstname"]); - $object->lastname = trim($_POST["lastname"]); - $object->login = trim($_POST["login"]); - $object->pass = trim($_POST["pass"]); + $object->civility_id = trim(GETPOST("civility_id",'alpha')); + $object->firstname = trim(GETPOST("firstname",'alpha')); + $object->lastname = trim(GETPOST("lastname",'alpha')); + $object->login = trim(GETPOST("login",'alpha')); + $object->pass = trim(GETPOST("pass",'alpha')); - $object->societe = trim($_POST["societe"]); - $object->company = trim($_POST["societe"]); + $object->societe = trim(GETPOST("societe",'alpha')); + $object->company = trim(GETPOST("societe",'alpha')); - $object->address = trim($_POST["address"]); - $object->zip = trim($_POST["zipcode"]); - $object->town = trim($_POST["town"]); - $object->state_id = $_POST["state_id"]; - $object->country_id = $_POST["country_id"]; + $object->address = trim(GETPOST("address",'alpha')); + $object->zip = trim(GETPOST("zipcode",'alpha')); + $object->town = trim(GETPOST("town",'alpha')); + $object->state_id = GETPOST("state_id",'int'); + $object->country_id = GETPOST("country_id",'int'); - $object->phone = trim($_POST["phone"]); - $object->phone_perso = trim($_POST["phone_perso"]); - $object->phone_mobile= trim($_POST["phone_mobile"]); - $object->email = trim($_POST["member_email"]); - $object->skype = trim($_POST["skype"]); + $object->phone = trim(GETPOST("phone",'alpha')); + $object->phone_perso = trim(GETPOST("phone_perso",'alpha')); + $object->phone_mobile= trim(GETPOST("phone_mobile",'alpha')); + $object->email = trim(GETPOST("member_email",'alpha')); + $object->skype = trim(GETPOST("skype",'alpha')); $object->birth = $birthdate; - $object->typeid = $_POST["typeid"]; - //$object->note = trim($_POST["comment"]); - $object->morphy = $_POST["morphy"]; + $object->typeid = GETPOST("typeid",'int'); + //$object->note = trim(GETPOST("comment","alpha")); + $object->morphy = GETPOST("morphy",'alpha'); - if (GETPOST('deletephoto')) $object->photo=''; + if (GETPOST('deletephoto','alpha')) $object->photo=''; elseif (! empty($_FILES['photo']['name'])) $object->photo = dol_sanitizeFileName($_FILES['photo']['name']); // Get status and public property - $object->statut = $_POST["statut"]; - $object->public = $_POST["public"]; + $object->statut = GETPOST("statut",'alpha'); + $object->public = GETPOST("public",'alpha'); // Fill array 'array_options' with data from add form $ret = $extrafields->setOptionalsFromPost($extralabels,$object); @@ -445,32 +445,32 @@ if (empty($reshook)) $datesubscription=dol_mktime(12, 0, 0, $_POST["remonth"], $_POST["reday"], $_POST["reyear"]); } - $typeid=$_POST["typeid"]; - $civility_id=$_POST["civility_id"]; - $lastname=$_POST["lastname"]; - $firstname=$_POST["firstname"]; - $societe=$_POST["societe"]; - $address=$_POST["address"]; - $zip=$_POST["zipcode"]; - $town=$_POST["town"]; - $state_id=$_POST["state_id"]; - $country_id=$_POST["country_id"]; + $typeid=GETPOST("typeid",'int'); + $civility_id=GETPOST("civility_id",'int'); + $lastname=GETPOST("lastname",'alpha'); + $firstname=GETPOST("firstname",'alpha'); + $societe=GETPOST("societe",'alpha'); + $address=GETPOST("address",'alpha'); + $zip=GETPOST("zipcode",'alpha'); + $town=GETPOST("town",'alpha'); + $state_id=GETPOST("state_id",'int'); + $country_id=GETPOST("country_id",'int'); - $phone=$_POST["phone"]; - $phone_perso=$_POST["phone_perso"]; - $phone_mobile=$_POST["phone_mobile"]; - $skype=$_POST["member_skype"]; - $email=$_POST["member_email"]; - $login=$_POST["member_login"]; - $pass=$_POST["password"]; - $photo=$_POST["photo"]; - //$comment=$_POST["comment"]; - $morphy=$_POST["morphy"]; - $subscription=$_POST["subscription"]; - $public=$_POST["public"]; + $phone=GETPOST("phone",'alpha'); + $phone_perso=GETPOST("phone_perso",'alpha'); + $phone_mobile=GETPOST("phone_mobile",'alpha'); + $skype=GETPOST("member_skype",'alpha'); + $email=GETPOST("member_email",'alpha'); + $login=GETPOST("member_login",'alpha'); + $pass=GETPOST("password",'alpha'); + $photo=GETPOST("photo",'alpha'); + //$comment=GETPOST("comment",'none'); + $morphy=GETPOST("morphy",'alpha'); + $subscription=GETPOST("subscription",'alpha'); + $public=GETPOST("public",'alpha'); - $userid=$_POST["userid"]; - $socid=$_POST["socid"]; + $userid=GETPOST("userid",'int'); + $socid=GETPOST("socid",'int'); $object->civility_id = $civility_id; $object->firstname = $firstname; @@ -1093,14 +1093,14 @@ else $morphys["phy"] = $langs->trans("Physical"); $morphys["mor"] = $langs->trans("Morale"); print ''.$langs->trans("Nature").''; - print $form->selectarray("morphy", $morphys, isset($_POST["morphy"])?$_POST["morphy"]:$object->morphy); + print $form->selectarray("morphy", $morphys, (GETPOSTISSET("morphy")?GETPOST("morphy",'alpha'):$object->morphy)); print ""; // Type print ''.$langs->trans("Type").''; if ($user->rights->adherent->creer) { - print $form->selectarray("typeid", $adht->liste_array(), (isset($_POST["typeid"])?$_POST["typeid"]:$object->typeid)); + print $form->selectarray("typeid", $adht->liste_array(), (GETPOSTISSET("typeid")?GETPOST("typeid",'int'):$object->typeid)); } else { diff --git a/htdocs/adherents/class/adherent.class.php b/htdocs/adherents/class/adherent.class.php index 3247fdf31e4..913853f430f 100644 --- a/htdocs/adherents/class/adherent.class.php +++ b/htdocs/adherents/class/adherent.class.php @@ -439,8 +439,8 @@ class Adherent extends CommonObject $sql.= ", note_public = ".($this->note_public?"'".$this->db->escape($this->note_public)."'":"null"); $sql.= ", photo = ".($this->photo?"'".$this->db->escape($this->photo)."'":"null"); $sql.= ", public = '".$this->db->escape($this->public)."'"; - $sql.= ", statut = ".$this->statut; - $sql.= ", fk_adherent_type = ".$this->typeid; + $sql.= ", statut = ".$this->db->escape($this->statut); + $sql.= ", fk_adherent_type = ".$this->db->escape($this->typeid); $sql.= ", morphy = '".$this->db->escape($this->morphy)."'"; $sql.= ", birth = ".($this->birth?"'".$this->db->idate($this->birth)."'":"null"); if ($this->datefin) $sql.= ", datefin = '".$this->db->idate($this->datefin)."'"; // Must be modified only when deleting a subscription diff --git a/htdocs/adherents/class/adherent_type.class.php b/htdocs/adherents/class/adherent_type.class.php index c352f5dc944..2f8592d3a21 100644 --- a/htdocs/adherents/class/adherent_type.class.php +++ b/htdocs/adherents/class/adherent_type.class.php @@ -265,7 +265,7 @@ class AdherentType extends CommonObject { $sql = "SELECT d.rowid, d.libelle as label, d.statut, d.subscription, d.mail_valid, d.note, d.vote"; $sql .= " FROM ".MAIN_DB_PREFIX."adherent_type as d"; - $sql .= " WHERE d.rowid = ".$rowid; + $sql .= " WHERE d.rowid = ".(int) $rowid; dol_syslog("Adherent_type::fetch", LOG_DEBUG); diff --git a/htdocs/adherents/list.php b/htdocs/adherents/list.php index fc30d6f1ae2..cae878829b7 100644 --- a/htdocs/adherents/list.php +++ b/htdocs/adherents/list.php @@ -42,23 +42,23 @@ $toselect = GETPOST('toselect', 'array'); // Security check $result=restrictedArea($user,'adherent'); -$filter=GETPOST("filter"); -$statut=GETPOST("statut"); -$search=GETPOST("search"); -$search_ref=GETPOST("search_ref"); -$search_lastname=GETPOST("search_lastname"); -$search_firstname=GETPOST("search_firstname"); -$search_login=GETPOST("search_login"); -$search_address=GETPOST("search_address"); -$search_zip=GETPOST("search_zip"); -$search_town=GETPOST("search_town"); -$search_state=GETPOST("search_state"); -$search_country=GETPOST("search_country"); -$search_phone=GETPOST("search_phone"); -$search_phone_perso=GETPOST("search_phone_perso"); -$search_phone_mobile=GETPOST("search_phone_mobile"); -$search_type=GETPOST("search_type"); -$search_email=GETPOST("search_email"); +$filter=GETPOST("filter",'alpha'); +$statut=GETPOST("statut",'alpha'); +$search=GETPOST("search",'alpha'); +$search_ref=GETPOST("search_ref",'alpha'); +$search_lastname=GETPOST("search_lastname",'alpha'); +$search_firstname=GETPOST("search_firstname",'alpha'); +$search_login=GETPOST("search_login",'alpha'); +$search_address=GETPOST("search_address",'alpha'); +$search_zip=GETPOST("search_zip",'alpha'); +$search_town=GETPOST("search_town",'alpha'); +$search_state=GETPOST("search_state",'alpha'); +$search_country=GETPOST("search_country",'alpha'); +$search_phone=GETPOST("search_phone",'alpha'); +$search_phone_perso=GETPOST("search_phone_perso",'alpha'); +$search_phone_mobile=GETPOST("search_phone_mobile",'alpha'); +$search_type=GETPOST("search_type",'alpha'); +$search_email=GETPOST("search_email",'alpha'); $search_categ = GETPOST("search_categ",'int'); $catid = GETPOST("catid",'int'); $optioncss = GETPOST('optioncss','alpha'); @@ -288,7 +288,7 @@ if ($num == 1 && ! empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && llxHeader('',$langs->trans("Member"),'EN:Module_Foundations|FR:Module_Adhérents|ES:Módulo_Miembros'); $titre=$langs->trans("MembersList"); -if (isset($_GET["statut"])) +if (GETPOSTISSET("statut")) { if ($statut == '-1,1') { $titre=$langs->trans("MembersListQualified"); } if ($statut == '-1') { $titre=$langs->trans("MembersListToValid"); } diff --git a/htdocs/admin/company.php b/htdocs/admin/company.php index 1a0680363a9..64e515ac76f 100644 --- a/htdocs/admin/company.php +++ b/htdocs/admin/company.php @@ -5,6 +5,7 @@ * Copyright (C) 2010-2014 Juanjo Menent * Copyright (C) 2011-2017 Philippe Grand * Copyright (C) 2015 Alexandre Spangaro + * Copyright (C) 2017 Rui Strecht * * 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 @@ -78,6 +79,7 @@ if ( ($action == 'update' && ! GETPOST("cancel",'alpha')) dolibarr_set_const($db, "MAIN_INFO_SOCIETE_TOWN", GETPOST("town",'nohtml'),'chaine',0,'',$conf->entity); dolibarr_set_const($db, "MAIN_INFO_SOCIETE_ZIP", GETPOST("zipcode",'alpha'),'chaine',0,'',$conf->entity); dolibarr_set_const($db, "MAIN_INFO_SOCIETE_STATE", GETPOST("state_id",'alpha'),'chaine',0,'',$conf->entity); + dolibarr_set_const($db, "MAIN_INFO_SOCIETE_REGION", GETPOST("region_code",'alpha'),'chaine',0,'',$conf->entity); dolibarr_set_const($db, "MAIN_MONNAIE", GETPOST("currency",'alpha'),'chaine',0,'',$conf->entity); dolibarr_set_const($db, "MAIN_INFO_SOCIETE_TEL", GETPOST("tel",'alpha'),'chaine',0,'',$conf->entity); dolibarr_set_const($db, "MAIN_INFO_SOCIETE_FAX", GETPOST("fax",'alpha'),'chaine',0,'',$conf->entity); @@ -339,18 +341,18 @@ if ($action == 'edit' || $action == 'updateedit') print ''; //if (empty($country_selected)) $country_selected=substr($langs->defaultlang,-2); // By default, country of localization - print $form->select_country($mysoc->country_id,'country_id'); + print $form->select_country($mysoc->country_id, 'country_id'); if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1); print ''."\n"; print ''; - $formcompany->select_departement($conf->global->MAIN_INFO_SOCIETE_STATE,$mysoc->country_code,'state_id'); + $formcompany->select_departement($conf->global->MAIN_INFO_SOCIETE_STATE, $mysoc->country_code, 'state_id'); print ''."\n"; print ''; - print $form->selectCurrency($conf->currency,"currency"); + print $form->selectCurrency($conf->currency, "currency"); print ''."\n"; @@ -726,8 +728,9 @@ else print ''; - print ''.$langs->trans("State").''; - if (! empty($conf->global->MAIN_INFO_SOCIETE_STATE)) print getState($conf->global->MAIN_INFO_SOCIETE_STATE); + if (! empty($conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT)) print ''.$langs->trans("Region-State").''; + else print ''.$langs->trans("State").''; + if (! empty($conf->global->MAIN_INFO_SOCIETE_STATE)) print getState($conf->global->MAIN_INFO_SOCIETE_STATE,$conf->global->MAIN_SHOW_STATE_CODE,0,$conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT); else print ' '; print ''; diff --git a/htdocs/admin/taxes.php b/htdocs/admin/taxes.php index 684577a6d6d..bf89da8522a 100644 --- a/htdocs/admin/taxes.php +++ b/htdocs/admin/taxes.php @@ -141,7 +141,7 @@ else print ''; print ''; - print ''; + print ''; print '
'.$langs->trans("CompanyIds").''.$langs->trans("Value").'
'.$langs->trans("CompanyIds").''.$langs->trans("Value").'
'; print ''; @@ -169,28 +169,29 @@ else print '
'; - print "
\n"; + print '
'; print ''; // Cas des parametres TAX_MODE_SELL/BUY_SERVICE/PRODUCT print ''; - print ''; + print ''; print "\n"; print ''; - print '\n"; print ''; - print '\n"; + print '\n"; print "
'.$langs->trans('OptionVatMode').''.$langs->trans('Description').''.$langs->trans('OptionVatMode').''.$langs->trans('Description').'
'.$langs->trans('OptionVATDefault').''.nl2br($langs->trans('OptionVatDefaultDesc')); + print ''.nl2br($langs->trans('OptionVatDefaultDesc')); print "
'.$langs->trans('OptionVATDebitOption').''.nl2br($langs->trans('OptionVatDebitOptionDesc'))."
'.nl2br($langs->trans('OptionVatDebitOptionDesc'))."
\n"; print '
'; - print load_fiche_titre($langs->trans("SummaryOfVatExigibilityUsedByDefault"),'',''); + print ' -> '.$langs->trans("SummaryOfVatExigibilityUsedByDefault"); //print ' ('.$langs->trans("CanBeChangedWhenMakingInvoice").')'; + print ''; - print ''; + print ''; // Products print ''; @@ -235,12 +236,18 @@ else print "
\n"; + + /* * Others params */ + +print load_fiche_titre($langs->trans("OtherOptions"),'',''); + print '
 '.$langs->trans("Buy").''.$langs->trans("Sell").'
 '.$langs->trans("Buy").''.$langs->trans("Sell").'
'.$langs->trans("Product").'
'; print ''; -print ''; +print ''; +print '\n"; foreach ($list as $key) diff --git a/htdocs/admin/ticketsup.php b/htdocs/admin/ticketsup.php index be1a3d2f8bf..4f6839d1e59 100644 --- a/htdocs/admin/ticketsup.php +++ b/htdocs/admin/ticketsup.php @@ -18,14 +18,15 @@ /** * \file admin/ticketsup.php - * \ingroup ticketsup - * \brief This file is a module setup page + * \ingroup ticketsup + * \brief This file is a module setup page */ require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT . "/core/lib/admin.lib.php"; require_once DOL_DOCUMENT_ROOT."/ticketsup/class/ticketsup.class.php"; require_once DOL_DOCUMENT_ROOT."/core/lib/ticketsup.lib.php"; + // Translations $langs->load("ticketsup"); @@ -214,9 +215,12 @@ if ($action == 'setvarother') { } } + + /* * View */ + $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); $form = new Form($db); @@ -226,28 +230,22 @@ $page_name = "TicketsupSetup"; llxHeader('', $langs->trans($page_name), $help_url); // Subheader -$linkback = '' -. $langs->trans("BackToModuleList") . ''; -print load_fiche_titre($langs->trans($page_name), $linkback); +$linkback = '' . $langs->trans("BackToModuleList") . ''; + +print load_fiche_titre($langs->trans($page_name), $linkback, 'title_setup'); // Configuration header $head = ticketsupAdminPrepareHead(); -dol_fiche_head( - $head, - 'settings', - $langs->trans("Module110120Name"), - 0, - "ticketsup@ticketsup" -); -print '

' . $langs->trans("TicketsupSetupDictionaries") . ' : ' . dol_buildpath('/admin/dict.php', 2) . '

'; +dol_fiche_head($head, 'settings', $langs->trans("Module56000Name"), -1, "ticketsup"); -print '

' . $langs->trans("TicketsupPublicAccess") . ' : ' . dol_buildpath('/ticketsup/public/index.php', 2) . '

'; +print $langs->trans("TicketsupSetupDictionaries") . ' : ' . dol_buildpath('/admin/dict.php', 2) . '
'; -//print '

'. $langs->trans("TicketsupSetupPage").'

'; +print $langs->trans("TicketsupPublicAccess") . ' : ' . dol_buildpath('/ticketsup/public/index.php', 2) . ''; dol_fiche_end(); + /* * Projects Numbering model */ @@ -546,7 +544,7 @@ if (empty($conf->global->FCKEDITOR_ENABLE_MAIL)) { // Email d'envoi des notifications print ''; print ''; +print ''; print ''; diff --git a/htdocs/admin/ticketsup_extrafields.php b/htdocs/admin/ticketsup_extrafields.php index 6a6a36a3bf8..5709472e858 100644 --- a/htdocs/admin/ticketsup_extrafields.php +++ b/htdocs/admin/ticketsup_extrafields.php @@ -26,7 +26,7 @@ require_once DOL_DOCUMENT_ROOT."/core/lib/ticketsup.lib.php"; require_once DOL_DOCUMENT_ROOT . '/core/class/extrafields.class.php'; require_once DOL_DOCUMENT_ROOT . '/core/lib/admin.lib.php'; -$langs->load("ticketsup@ticketsup"); +$langs->load("ticketsup"); $langs->load("admin"); $extrafields = new ExtraFields($db); @@ -47,14 +47,14 @@ if (!$user->admin) { accessforbidden(); } + /* * Actions */ -if (versioncompare(versiondolibarrarray(), array(3, 5, 0)) > 0) { - include DOL_DOCUMENT_ROOT . '/core/actions_extrafields.inc.php'; -} elseif (versioncompare(versiondolibarrarray(), array(3, 4, 0)) > 0) { - include DOL_DOCUMENT_ROOT . '/core/admin_extrafields.inc.php'; -} + +include DOL_DOCUMENT_ROOT . '/core/actions_extrafields.inc.php'; + + /* * View @@ -67,17 +67,11 @@ $page_name = "TicketsupSetup"; llxHeader('', $langs->trans($page_name), $help_url); $linkback = '' . $langs->trans("BackToModuleList") . ''; -print load_fiche_titre($langs->trans("TicketsupSetup"), $linkback, 'setup'); +print load_fiche_titre($langs->trans("TicketsupSetup"), $linkback, 'title_setup'); $head = ticketsupAdminPrepareHead(); -dol_fiche_head( - $head, - 'attributes', - $langs->trans("Module110120Name"), - 0, - "ticketsup@ticketsup" -); +dol_fiche_head($head, 'attributes', $langs->trans("Module56000Name"), -1, "ticketsup"); require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php'; diff --git a/htdocs/bookmarks/card.php b/htdocs/bookmarks/card.php index dcc6d8cdeab..54512a8049e 100644 --- a/htdocs/bookmarks/card.php +++ b/htdocs/bookmarks/card.php @@ -35,7 +35,7 @@ if (! $user->rights->bookmark->lire) { restrictedArea($user, 'bookmarks'); } -$id=GETPOST("id"); +$id=GETPOST("id",'int'); $action=GETPOST("action","alpha"); $title=GETPOST("title","alpha"); $url=GETPOST("url","alpha"); diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php index 6452e3ca922..af829969789 100644 --- a/htdocs/comm/action/class/actioncomm.class.php +++ b/htdocs/comm/action/class/actioncomm.class.php @@ -164,6 +164,7 @@ class ActionComm extends CommonObject // Properties for links to other objects var $fk_element; // Id of record + var $elementid; // Id of record alternative for API var $elementtype; // Type of record. This if property ->element of object linked to. // Ical @@ -550,7 +551,7 @@ class ActionComm extends CommonObject $sql.= " a.fk_user_author, a.fk_user_mod,"; $sql.= " a.fk_user_action, a.fk_user_done,"; $sql.= " a.fk_contact, a.percent as percentage,"; - $sql.= " a.fk_element, a.elementtype,"; + $sql.= " a.fk_element as elementid, a.elementtype,"; $sql.= " a.priority, a.fulldayevent, a.location, a.punctual, a.transparency,"; $sql.= " c.id as type_id, c.code as type_code, c.libelle as type_label, c.color as type_color, c.picto as type_picto,"; $sql.= " s.nom as socname,"; @@ -624,7 +625,8 @@ class ActionComm extends CommonObject $this->societe->id = $obj->fk_soc; // deprecated $this->contact->id = $obj->fk_contact; // deprecated - $this->fk_element = $obj->fk_element; + $this->fk_element = $obj->elementid; + $this->elementid = $obj->elementid; $this->elementtype = $obj->elementtype; $this->fetchResources(); diff --git a/htdocs/comm/action/class/api_agendaevents.class.php b/htdocs/comm/action/class/api_agendaevents.class.php index 58deec46f5e..7fd76b5d1a9 100644 --- a/htdocs/comm/action/class/api_agendaevents.class.php +++ b/htdocs/comm/action/class/api_agendaevents.class.php @@ -80,6 +80,8 @@ class AgendaEvents extends DolibarrApi throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } + $result = $this->actioncomm->fetch_optionals(); + $this->actioncomm->fetchObjectLinked(); return $this->_cleanObjectDatas($this->actioncomm); } @@ -319,7 +321,6 @@ class AgendaEvents extends DolibarrApi unset($object->usermod); unset($object->libelle); - unset($object->array_options); unset($object->context); unset($object->canvas); unset($object->contact); diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index a35f89f9038..44375df6dc8 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -56,15 +56,7 @@ if (!empty($conf->variants->enabled)) { require_once DOL_DOCUMENT_ROOT.'/variants/class/ProductCombination.class.php'; } -$langs->load('orders'); -$langs->load('sendings'); -$langs->load('companies'); -$langs->load('bills'); -$langs->load('propal'); -$langs->load('deliveries'); -$langs->load('sendings'); -$langs->load('products'); -$langs->load('other'); +$langs->loadLangs(array('orders','sendings','companies','bills','propal','deliveries','products','other')); if (!empty($conf->incoterm->enabled)) $langs->load('incoterm'); if (! empty($conf->margin->enabled)) $langs->load('margins'); if (! empty($conf->productbatch->enabled)) $langs->load("productbatch"); diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index 235f15d9010..52219e12d9f 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -3135,6 +3135,12 @@ class Commande extends CommonOrder // End call triggers } + if ($this->nb_expedition() != 0) + { + $this->errors[] = $langs->trans('SomeShipmentExists'); + $error++; + } + if (! $error) { // Delete order details diff --git a/htdocs/compta/bank/list.php b/htdocs/compta/bank/list.php index 817d6dc84e9..6a39416342e 100644 --- a/htdocs/compta/bank/list.php +++ b/htdocs/compta/bank/list.php @@ -89,8 +89,8 @@ $arrayfields=array( 'accountype'=>array('label'=>$langs->trans("Type"), 'checked'=>1), 'b.label'=>array('label'=>$langs->trans("Label"), 'checked'=>1), 'b.number'=>array('label'=>$langs->trans("AccountIdShort"), 'checked'=>1), - 'b.account_number'=>array('label'=>$langs->trans("AccountAccounting"), 'checked'=>$conf->accountancy->enabled), - 'b.fk_accountancy_journal'=>array('label'=>$langs->trans("AccountancyJournal"), 'checked'=>$conf->accountancy->enabled), + 'b.account_number'=>array('label'=>$langs->trans("AccountAccounting"), 'checked'=>(! empty($conf->accounting->enabled) || ! empty($conf->accounting->enabled))), + 'b.fk_accountancy_journal'=>array('label'=>$langs->trans("AccountancyJournal"), 'checked'=>(! empty($conf->accounting->enabled) || ! empty($conf->accounting->enabled))), 'toreconcile'=>array('label'=>$langs->trans("TransactionsToConciliate"), 'checked'=>1), 'b.currency_code'=>array('label'=>$langs->trans("Currency"), 'checked'=>0), 'b.datec'=>array('label'=>$langs->trans("DateCreation"), 'checked'=>0, 'position'=>500), diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index 90bc80a6a19..1dd7dab2de8 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -553,7 +553,7 @@ if (empty($reshook)) || (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->facture->invoice_advance->unvalidate))) ) { - $idwarehouse = GETPOST('idwarehouse'); + $idwarehouse = GETPOST('idwarehouse','int'); $object->fetch($id); $object->fetch_thirdparty(); @@ -640,8 +640,8 @@ if (empty($reshook)) else if ($action == 'confirm_paid_partially' && $confirm == 'yes' && $user->rights->facture->paiement) { $object->fetch($id); - $close_code = $_POST["close_code"]; - $close_note = $_POST["close_note"]; + $close_code = GETPOST("close_code",'none'); + $close_note = GETPOST("close_note",'none'); if ($close_code) { $result = $object->set_paid($user, $close_code, $close_note); if ($result<0) setEventMessages($object->error, $object->errors, 'errors'); @@ -651,8 +651,8 @@ if (empty($reshook)) } // Classify "abandoned" else if ($action == 'confirm_canceled' && $confirm == 'yes') { $object->fetch($id); - $close_code = $_POST["close_code"]; - $close_note = $_POST["close_note"]; + $close_code = GETPOST("close_code",'none'); + $close_note = GETPOST("close_note",'none'); if ($close_code) { $result = $object->set_canceled($user, $close_code, $close_note); if ($result<0) setEventMessages($object->error, $object->errors, 'errors'); @@ -1419,6 +1419,7 @@ if (empty($reshook)) } } + // Situation invoices if (GETPOST('type') == Facture::TYPE_SITUATION && (!empty($_POST['situations']))) { $datefacture = dol_mktime(12, 0, 0, $_POST['remonth'], $_POST['reday'], $_POST['reyear']); @@ -1455,16 +1456,16 @@ if (empty($reshook)) $object->fetch_thirdparty(); $object->date = $datefacture; $object->date_pointoftax = $date_pointoftax; - $object->note_public = trim($_POST['note_public']); - $object->note = trim($_POST['note']); - $object->ref_client = $_POST['ref_client']; - $object->ref_int = $_POST['ref_int']; - $object->modelpdf = $_POST['model']; - $object->fk_project = $_POST['projectid']; - $object->cond_reglement_id = $_POST['cond_reglement_id']; - $object->mode_reglement_id = $_POST['mode_reglement_id']; - $object->remise_absolue = $_POST['remise_absolue']; - $object->remise_percent = $_POST['remise_percent']; + $object->note_public = trim(GETPOST('note_public','none')); + $object->note = trim(GETPOST('note','none')); + $object->ref_client = GETPOST('ref_client','alpha'); + $object->ref_int = GETPOST('ref_int','alpha'); + $object->modelpdf = GETPOST('model','alpha'); + $object->fk_project = GETPOST('projectid','int'); + $object->cond_reglement_id = GETPOST('cond_reglement_id','int'); + $object->mode_reglement_id = GETPOST('mode_reglement_id','int'); + $object->remise_absolue = GETPOST('remise_absolue','int'); + $object->remise_percent = GETPOST('remise_percent','int'); // Proprietes particulieres a facture de remplacement @@ -1533,14 +1534,14 @@ if (empty($reshook)) // Set if we used free entry or predefined product $predef=''; - $product_desc=(GETPOST('dp_desc')?GETPOST('dp_desc'):''); + $product_desc=(GETPOST('dp_desc','none')?GETPOST('dp_desc','none'):''); $price_ht = GETPOST('price_ht'); $price_ht_devise = GETPOST('multicurrency_price_ht'); $prod_entry_mode = GETPOST('prod_entry_mode','alpha'); if ($prod_entry_mode == 'free') { $idprod=0; - $tva_tx = (GETPOST('tva_tx') ? GETPOST('tva_tx') : 0); + $tva_tx = (GETPOST('tva_tx','alpha') ? GETPOST('tva_tx','alpha') : 0); } else { diff --git a/htdocs/compta/facture/class/facture-rec.class.php b/htdocs/compta/facture/class/facture-rec.class.php index c36e6cb09d1..630433324c4 100644 --- a/htdocs/compta/facture/class/facture-rec.class.php +++ b/htdocs/compta/facture/class/facture-rec.class.php @@ -439,7 +439,7 @@ class FactureRec extends CommonInvoice $sql = 'SELECT l.rowid, l.fk_product, l.product_type, l.label as custom_label, l.description, l.product_type, l.price, l.qty, l.vat_src_code, l.tva_tx, '; $sql.= ' l.localtax1_tx, l.localtax2_tx, l.localtax1_type, l.localtax2_type, l.remise, l.remise_percent, l.subprice,'; - $sql.= ' l.info_bits, l.total_ht, l.total_tva, l.total_ttc,'; + $sql.= ' l.info_bits, l.date_start_fill, l.date_end_fill, l.total_ht, l.total_tva, l.total_ttc,'; //$sql.= ' l.situation_percent, l.fk_prev_id,'; //$sql.= ' l.localtax1_tx, l.localtax2_tx, l.localtax1_type, l.localtax2_type, l.remise_percent, l.fk_remise_except, l.subprice,'; $sql.= ' l.rang, l.special_code,'; @@ -487,6 +487,8 @@ class FactureRec extends CommonInvoice $line->remise_percent = $objp->remise_percent; $line->fk_remise_except = $objp->fk_remise_except; $line->fk_product = $objp->fk_product; + $line->date_start_fill = $objp->date_start_fill; + $line->date_end_fill = $objp->date_end_fill; $line->info_bits = $objp->info_bits; $line->total_ht = $objp->total_ht; $line->total_tva = $objp->total_tva; @@ -602,15 +604,17 @@ class FactureRec extends CommonInvoice * @param string $label Label of the line * @param string $fk_unit Unit * @param double $pu_ht_devise Unit price in currency + * @param int $date_start_fill 1=Flag to fill start date when generating invoice + * @param int $date_end_fill 1=Flag to fill end date when generating invoice * @return int <0 if KO, Id of line if OK */ - function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1=0, $txlocaltax2=0, $fk_product=0, $remise_percent=0, $price_base_type='HT', $info_bits=0, $fk_remise_except='', $pu_ttc=0, $type=0, $rang=-1, $special_code=0, $label='', $fk_unit=null, $pu_ht_devise=0) + function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1=0, $txlocaltax2=0, $fk_product=0, $remise_percent=0, $price_base_type='HT', $info_bits=0, $fk_remise_except='', $pu_ttc=0, $type=0, $rang=-1, $special_code=0, $label='', $fk_unit=null, $pu_ht_devise=0, $date_start_fill=0, $date_end_fill=0) { global $mysoc; $facid=$this->id; - dol_syslog(get_class($this)."::addline facid=$facid,desc=$desc,pu_ht=$pu_ht,qty=$qty,txtva=$txtva,txlocaltax1=$txlocaltax1,txlocaltax2=$txlocaltax2,fk_product=$fk_product,remise_percent=$remise_percent,info_bits=$info_bits,fk_remise_except=$fk_remise_except,price_base_type=$price_base_type,pu_ttc=$pu_ttc,type=$type,fk_unit=$fk_unit,pu_ht_devise=$pu_ht_devise", LOG_DEBUG); + dol_syslog(get_class($this)."::addline facid=$facid,desc=$desc,pu_ht=$pu_ht,qty=$qty,txtva=$txtva,txlocaltax1=$txlocaltax1,txlocaltax2=$txlocaltax2,fk_product=$fk_product,remise_percent=$remise_percent,info_bits=$info_bits,fk_remise_except=$fk_remise_except,price_base_type=$price_base_type,pu_ttc=$pu_ttc,type=$type,fk_unit=$fk_unit,pu_ht_devise=$pu_ht_devise,date_start_fill=$date_start_fill,date_end_fill=$date_end_fill", LOG_DEBUG); include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php'; // Check parameters @@ -700,6 +704,8 @@ class FactureRec extends CommonInvoice $sql.= ", total_localtax1"; $sql.= ", total_localtax2"; $sql.= ", total_ttc"; + $sql.= ", date_start_fill"; + $sql.= ", date_end_fill"; $sql.= ", info_bits"; $sql.= ", rang"; $sql.= ", special_code"; @@ -727,6 +733,8 @@ class FactureRec extends CommonInvoice $sql.= ", ".price2num($total_localtax1); $sql.= ", ".price2num($total_localtax2); $sql.= ", ".price2num($total_ttc); + $sql.= ", ".(int) $date_start_fill; + $sql.= ", ".(int) $date_end_fill; $sql.= ", ".$info_bits; $sql.= ", ".$rang; $sql.= ", ".$special_code; @@ -778,9 +786,11 @@ class FactureRec extends CommonInvoice * @param string $fk_unit Unit * @param double $pu_ht_devise Unit price in currency * @param int $notrigger disable line update trigger + * @param int $date_start_fill 1=Flag to fill start date when generating invoice + * @param int $date_end_fill 1=Flag to fill end date when generating invoice * @return int <0 if KO, Id of line if OK */ - function updateline($rowid, $desc, $pu_ht, $qty, $txtva, $txlocaltax1=0, $txlocaltax2=0, $fk_product=0, $remise_percent=0, $price_base_type='HT', $info_bits=0, $fk_remise_except='', $pu_ttc=0, $type=0, $rang=-1, $special_code=0, $label='', $fk_unit=null, $pu_ht_devise = 0, $notrigger=0) + function updateline($rowid, $desc, $pu_ht, $qty, $txtva, $txlocaltax1=0, $txlocaltax2=0, $fk_product=0, $remise_percent=0, $price_base_type='HT', $info_bits=0, $fk_remise_except='', $pu_ttc=0, $type=0, $rang=-1, $special_code=0, $label='', $fk_unit=null, $pu_ht_devise = 0, $notrigger=0, $date_start_fill=0, $date_end_fill=0) { global $mysoc; @@ -883,6 +893,8 @@ class FactureRec extends CommonInvoice $sql.= ", total_localtax1='".price2num($total_localtax1)."'"; $sql.= ", total_localtax2='".price2num($total_localtax2)."'"; $sql.= ", total_ttc='".price2num($total_ttc)."'"; + $sql.= ", date_start_fill=".((int) $date_start_fill); + $sql.= ", date_end_fill=".((int) $date_end_fill); $sql.= ", info_bits=".$info_bits; $sql.= ", rang=".$rang; $sql.= ", special_code=".$special_code; @@ -948,7 +960,7 @@ class FactureRec extends CommonInvoice * Create all recurrents invoices (for all entities if multicompany is used). * A result may also be provided into this->output. * - * WARNING: This method change context $conf->entity to be in correct context for each recurring invoice found. + * WARNING: This method change temporarly context $conf->entity to be in correct context for each recurring invoice found. * * @return int 0 if OK, < 0 if KO (this function is used also by cron so only 0 is OK) */ @@ -1561,6 +1573,10 @@ class FactureLigneRec extends CommonInvoiceLine public $element='facturedetrec'; public $table_element='facturedet_rec'; + var $date_start_fill; + var $date_end_fill; + + /** * Delete line in database * @@ -1615,7 +1631,7 @@ class FactureLigneRec extends CommonInvoiceLine { $sql = 'SELECT l.rowid, l.fk_facture ,l.fk_product, l.product_type, l.label as custom_label, l.description, l.product_type, l.price, l.qty, l.vat_src_code, l.tva_tx,'; $sql.= ' l.localtax1_tx, l.localtax2_tx, l.localtax1_type, l.localtax2_type, l.remise, l.remise_percent, l.subprice,'; - $sql.= ' l.info_bits, l.total_ht, l.total_tva, l.total_ttc,'; + $sql.= ' l.date_start_fill, l.date_end_fill, l.info_bits, l.total_ht, l.total_tva, l.total_ttc,'; $sql.= ' l.rang, l.special_code,'; $sql.= ' l.fk_unit, l.fk_contract_line,'; $sql.= ' p.ref as product_ref, p.fk_product_type as fk_product_type, p.label as product_label, p.description as product_desc'; @@ -1655,6 +1671,8 @@ class FactureLigneRec extends CommonInvoiceLine $this->remise_percent = $objp->remise_percent; $this->fk_remise_except = $objp->fk_remise_except; $this->fk_product = $objp->fk_product; + $this->date_start_fill = $objp->date_start_fill; + $this->date_end_fill = $objp->date_end_fill; $this->info_bits = $objp->info_bits; $this->total_ht = $objp->total_ht; $this->total_tva = $objp->total_tva; @@ -1711,6 +1729,9 @@ class FactureLigneRec extends CommonInvoiceLine $sql.= ", product_type=".$this->product_type; $sql.= ", remise_percent='".price2num($this->remise_percent)."'"; $sql.= ", subprice='".price2num($this->subprice)."'"; + $sql.= ", info_bits='".price2num($this->info_bits)."'"; + $sql.= ", date_start_fill=".(int) $this->date_start_fill; + $sql.= ", date_end_fill=".(int) $this->date_end_fill; $sql.= ", total_ht='".price2num($this->total_ht)."'"; $sql.= ", total_tva='".price2num($this->total_tva)."'"; $sql.= ", total_localtax1='".price2num($this->total_localtax1)."'"; diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 1939aa0e62f..8aca7562654 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -287,6 +287,10 @@ class Facture extends CommonInvoice $this->db->begin(); + $originaldatewhen=null; + $nextdatewhen=null; + $previousdaynextdatewhen=null; + // Create invoice from a template invoice if ($this->fac_rec > 0) { @@ -297,7 +301,10 @@ class Facture extends CommonInvoice $result=$_facrec->fetch($this->fac_rec); $result=$_facrec->fetchObjectLinked(); // This load $_facrec->linkedObjectsIds + // Define some dates $originaldatewhen = $_facrec->date_when; + $nextdatewhen=dol_time_plus_duree($originaldatewhen, $_facrec->frequency, $_facrec->unit_frequency); + $previousdaynextdatewhen=dol_time_plus_duree($nextdatewhen, -1, 'd'); $this->socid = $_facrec->socid; // Invoice created on same thirdparty than template $this->entity = $_facrec->entity; // Invoice created in same entity than template @@ -374,7 +381,8 @@ class Facture extends CommonInvoice $substitutionarray['__INVOICE_NEXT_YEAR__'] = dol_print_date(dol_time_plus_duree($this->date, 1, 'y'), '%Y'); // Only for tempalte invoice $substitutionarray['__INVOICE_DATE_NEXT_INVOICE_BEFORE_GEN__'] = dol_print_date($originaldatewhen, 'dayhour'); - $substitutionarray['__INVOICE_DATE_NEXT_INVOICE_AFTER_GEN__'] = dol_print_date(dol_time_plus_duree($originaldatewhen, $_facrec->frequency, $_facrec->unit_frequency), 'dayhour'); + $substitutionarray['__INVOICE_DATE_NEXT_INVOICE_AFTER_GEN__'] = dol_print_date($nextdatewhen, 'dayhour'); + $substitutionarray['__INVOICE_PREVIOUS_DATE_NEXT_INVOICE_AFTER_GEN__'] = dol_print_date($previousdaynextdatewhen, 'dayhour'); //var_dump($substitutionarray);exit; @@ -494,6 +502,7 @@ class Facture extends CommonInvoice } } + // Propagate contacts if (! $error && $this->id && ! empty($conf->global->MAIN_PROPAGATE_CONTACTS_FROM_ORIGIN) && ! empty($this->origin) && ! empty($this->origin_id)) // Get contact from origin object { $originforcontact = $this->origin; @@ -531,11 +540,10 @@ class Facture extends CommonInvoice else dol_print_error($resqlcontact); } - /* - * Insert lines of invoices into database + * Insert lines of invoices, if not from template invoice, into database */ - if (count($this->lines) && is_object($this->lines[0])) // If this->lines is array of InvoiceLines (preferred mode) + if (! $error && empty($this->fac_rec) && count($this->lines) && is_object($this->lines[0])) // If this->lines is array of InvoiceLines (preferred mode) { $fk_parent_line = 0; @@ -545,9 +553,18 @@ class Facture extends CommonInvoice $newinvoiceline=$this->lines[$i]; $newinvoiceline->fk_facture=$this->id; - // TODO This seems not used. Here we put origin 'facture' but after, we put an id of object ! - $newinvoiceline->origin = $this->element; - $newinvoiceline->origin_id = $this->lines[$i]->id; + $newinvoiceline->origin = $this->lines[$i]->element; + $newinvoiceline->origin_id = $this->lines[$i]->id; + + // Auto set date of service ? + if ($this->lines[$i]->date_start_fill == 1 && $originaldatewhen) // $originaldatewhen is defined when generating from recurring invoice only + { + $newinvoiceline->date_start = $originaldatewhen; + } + if ($this->lines[$i]->date_end_fill == 1 && $previousdaynextdatewhen) // $previousdaynextdatewhen is defined when generating from recurring invoice only + { + $newinvoiceline->date_end = $previousdaynextdatewhen; + } if ($result >= 0) { @@ -581,7 +598,7 @@ class Facture extends CommonInvoice } } } - else // If this->lines is an array of invoice line arrays + elseif (! $error && empty($this->fac_rec)) // If this->lines is an array of invoice line arrays { $fk_parent_line = 0; @@ -689,7 +706,9 @@ class Facture extends CommonInvoice $localtax2_tx, $_facrec->lines[$i]->fk_product, $_facrec->lines[$i]->remise_percent, - '','',0, + ($_facrec->lines[$i]->date_start_fill == 1 && $originaldatewhen)?$originaldatewhen:'', + ($_facrec->lines[$i]->date_end_fill == 1 && $previousdaynextdatewhen)?$previousdaynextdatewhen:'', + 0, $tva_npr, '', 'HT', @@ -2522,8 +2541,8 @@ class Facture extends CommonInvoice * @param double $txlocaltax2 Local tax 2 rate (deprecated, use instead txtva with code inside) * @param int $fk_product Id of predefined product/service * @param double $remise_percent Percent of discount on line - * @param int $date_start Date start of service - * @param int $date_end Date end of service + * @param int $date_start Date start of service + * @param int $date_end Date end of service * @param int $ventil Code of dispatching into accountancy * @param int $info_bits Bits de type de lignes * @param int $fk_remise_except Id discount used diff --git a/htdocs/compta/facture/fiche-rec.php b/htdocs/compta/facture/fiche-rec.php index 8d955f1141d..6f96e74d345 100644 --- a/htdocs/compta/facture/fiche-rec.php +++ b/htdocs/compta/facture/fiche-rec.php @@ -66,22 +66,8 @@ if ($action == "create" || $action == "add") $objecttype = ''; $result = restrictedArea($user, 'facture', $id, $objecttype); $projectid = GETPOST('projectid','int'); -$search_ref=GETPOST('search_ref'); -$search_societe=GETPOST('search_societe'); -$search_montant_ht=GETPOST('search_montant_ht'); -$search_montant_vat=GETPOST('search_montant_vat'); -$search_montant_ttc=GETPOST('search_montant_ttc'); -$search_payment_mode=GETPOST('search_payment_mode'); -$search_payment_term=GETPOST('search_payment_term'); -$day=GETPOST('day'); -$year=GETPOST('year'); -$month=GETPOST('month'); -$day_date_when=GETPOST('day_date_when'); $year_date_when=GETPOST('year_date_when'); $month_date_when=GETPOST('month_date_when'); -$search_recurring=GETPOST('search_recurring','int'); -$search_frequency=GETPOST('search_frequency','alpha'); -$search_unit_frequency=GETPOST('search_unit_frequency','alpha'); $limit = GETPOST('limit')?GETPOST('limit','int'):$conf->liste_limit; $sortfield = GETPOST("sortfield",'alpha'); @@ -144,28 +130,6 @@ if (empty($reshook)) include DOL_DOCUMENT_ROOT.'/core/actions_lineupdown.inc.php'; // Must be include, not include_once - // Do we click on purge search criteria ? - if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x','alpha') || GETPOST('button_removefilter','alpha')) // All test are required to be compatible with all browsers - { - $search_ref=''; - $search_societe=''; - $search_montant_ht=''; - $search_montant_vat=''; - $search_montant_ttc=''; - $search_montant_mode=''; - $search_montant_term=''; - $day=''; - $year=''; - $month=''; - $day_date_when=''; - $year_date_when=''; - $month_date_when=''; - $search_recurring=''; - $search_frequency=''; - $search_unit_frequency=''; - $search_array_options=array(); - } - // Mass actions /*$objectclass='MyObject'; $objectlabel='MyObject'; @@ -686,6 +650,9 @@ if (empty($reshook)) $fk_unit= GETPOST('units', 'alpha'); } + $date_start_fill = GETPOST('date_start_fill','int'); + $date_end_fill = GETPOST('date_end_fill','int'); + // Margin $fournprice = price2num(GETPOST('fournprice' . $predef) ? GETPOST('fournprice' . $predef) : ''); $buyingprice = price2num(GETPOST('buying_price' . $predef) != '' ? GETPOST('buying_price' . $predef) : ''); // If buying_price is '0', we must keep this value @@ -706,7 +673,7 @@ if (empty($reshook)) else { // Insert line - $result = $object->addline($desc, $pu_ht, $qty, $tva_tx,$localtax1_tx, $localtax2_tx, $idprod, $remise_percent, $price_base_type, $info_bits, '', $pu_ttc, $type, - 1, $special_code, $label, $fk_unit); + $result = $object->addline($desc, $pu_ht, $qty, $tva_tx,$localtax1_tx, $localtax2_tx, $idprod, $remise_percent, $price_base_type, $info_bits, '', $pu_ttc, $type, - 1, $special_code, $label, $fk_unit, 0, $date_start_fill, $date_end_fill); if ($result > 0) { @@ -762,6 +729,9 @@ if (empty($reshook)) unset($_POST['date_endmonth']); unset($_POST['date_endyear']); + unset($_POST['date_start_fill']); + unset($_POST['date_end_fill']); + unset($_POST['situations']); unset($_POST['progress']); } @@ -883,6 +853,9 @@ if (empty($reshook)) $error ++; } + $date_start_fill = GETPOST('date_start_fill','int'); + $date_end_fill = GETPOST('date_end_fill','int'); + // Update line if (! $error) { @@ -905,7 +878,10 @@ if (empty($reshook)) $special_code, $label, GETPOST('units'), - $pu_ht_devise + $pu_ht_devise, + 0, + $date_start_fill, + $date_end_fill ); if ($result >= 0) diff --git a/htdocs/compta/stats/casoc.php b/htdocs/compta/stats/casoc.php index f59b6fc454f..b7b37d0837c 100644 --- a/htdocs/compta/stats/casoc.php +++ b/htdocs/compta/stats/casoc.php @@ -63,18 +63,18 @@ if (! empty($conf->comptabilite->enabled)) $result=restrictedArea($user,'compta' if (! empty($conf->accounting->enabled)) $result=restrictedArea($user,'accounting','','','comptarapport'); // Date range -$year=GETPOST("year"); -$month=GETPOST("month"); -$search_societe = GETPOST("search_societe"); -$search_zip = GETPOST("search_zip"); -$search_town = GETPOST("search_town"); -$search_country = GETPOST("search_country"); -$date_startyear = GETPOST("date_startyear"); -$date_startmonth = GETPOST("date_startmonth"); -$date_startday = GETPOST("date_startday"); -$date_endyear = GETPOST("date_endyear"); -$date_endmonth = GETPOST("date_endmonth"); -$date_endday = GETPOST("date_endday"); +$year=GETPOST("year",'int'); +$month=GETPOST("month",'int'); +$search_societe = GETPOST("search_societe",'alpha'); +$search_zip = GETPOST("search_zip",'alpha'); +$search_town = GETPOST("search_town",'alpha'); +$search_country = GETPOST("search_country",'alpha'); +$date_startyear = GETPOST("date_startyear",'alpha'); +$date_startmonth = GETPOST("date_startmonth",'alpha'); +$date_startday = GETPOST("date_startday",'alpha'); +$date_endyear = GETPOST("date_endyear",'alpha'); +$date_endmonth = GETPOST("date_endmonth",'alpha'); +$date_endday = GETPOST("date_endday",'alpha'); if (empty($year)) { $year_current = strftime("%Y",dol_now()); @@ -85,8 +85,8 @@ if (empty($year)) $month_current = strftime("%m",dol_now()); $year_start = $year; } -$date_start=dol_mktime(0,0,0,$_REQUEST["date_startmonth"],$_REQUEST["date_startday"],$_REQUEST["date_startyear"]); -$date_end=dol_mktime(23,59,59,$_REQUEST["date_endmonth"],$_REQUEST["date_endday"],$_REQUEST["date_endyear"]); +$date_start=dol_mktime(0,0,0,GETPOST("date_startmonth"),GETPOST("date_startday"),GETPOST("date_startyear")); +$date_end=dol_mktime(23,59,59,GETPOST("date_endmonth"),GETPOST("date_endday"),GETPOST("date_endyear")); // Quarter if (empty($date_start) || empty($date_end)) // We define date_start and date_end { diff --git a/htdocs/compta/tva/quadri_detail.php b/htdocs/compta/tva/quadri_detail.php index c622881d273..d4ccbf98804 100644 --- a/htdocs/compta/tva/quadri_detail.php +++ b/htdocs/compta/tva/quadri_detail.php @@ -447,7 +447,7 @@ else $ratiopaymentinvoice=1; if ($modetax == 0) { - if (isset($fields['payment_amount']) && $fields['ftotal_ttc']) $ratiopaymentinvoice=($fields['payment_amount']/$fields['ftotal_ttc']); + if (isset($fields['payment_amount']) && price2num($fields['ftotal_ttc'])) $ratiopaymentinvoice=($fields['payment_amount']/$fields['ftotal_ttc']); print ''; if (empty($notabletag) && GETPOST('action','aZ09') != 'edit'.$htmlname && $perm) $ret.=''; @@ -139,12 +140,13 @@ class Form * @param string $editvalue When in edit mode, use this value as $value instead of value (for example, you can provide here a formated price instead of value). Use '' to use same than $value * @param object $extObject External object * @param mixed $custommsg String or Array of custom messages : eg array('success' => 'MyMessage', 'error' => 'MyMessage') - * @param string $moreparam More param to add on a href URL + * @param string $moreparam More param to add on the form action href URL * @param int $notabletag Do no output table tags * @param string $formatfunc Call a specific function to output field + * @param string $paramid Key of parameter for id ('id', 'socid') * @return string HTML edit field */ - function editfieldval($text, $htmlname, $value, $object, $perm, $typeofdata='string', $editvalue='', $extObject=null, $custommsg=null, $moreparam='', $notabletag=0, $formatfunc='') + function editfieldval($text, $htmlname, $value, $object, $perm, $typeofdata='string', $editvalue='', $extObject=null, $custommsg=null, $moreparam='', $notabletag=0, $formatfunc='', $paramid='id') { global $conf,$langs,$db; @@ -166,7 +168,7 @@ class Form $ret.=''; $ret.=''; $ret.=''; - $ret.=''; + $ret.=''; if (empty($notabletag)) $ret.='
' . $langs->trans('OtherOptions') . '' . $langs->trans('Parameters') . ''; print "
' . $langs->trans("TicketEmailNotificationFrom") . ''; -print ''; print $form->textwithpicto('', $langs->trans("TicketEmailNotificationFromHelp"), 1, 'help'); print ''; //print $fields['totalht']."-".$fields['payment_amount']."-".$fields['ftotal_ttc']; if ($fields['payment_amount'] && $fields['ftotal_ttc']) diff --git a/htdocs/contact/class/contact.class.php b/htdocs/contact/class/contact.class.php index eca1174bb59..432515fbf1f 100644 --- a/htdocs/contact/class/contact.class.php +++ b/htdocs/contact/class/contact.class.php @@ -1078,9 +1078,10 @@ class Contact extends CommonObject * @param int $maxlen Max length of * @param string $moreparam Add more param into URL * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking + * @param int $notooltip 1=Disable tooltip * @return string String with URL */ - function getNomUrl($withpicto=0, $option='', $maxlen=0, $moreparam='', $save_lastsearch_value=-1) + function getNomUrl($withpicto=0, $option='', $maxlen=0, $moreparam='', $save_lastsearch_value=-1, $notooltip=0) { global $conf, $langs, $hookmanager; @@ -1112,13 +1113,16 @@ class Contact extends CommonObject $linkstart = 'global->MAIN_OPTIMIZEFORTEXTBROWSER)) - { - $label=$langs->trans("ShowContact"); - $linkclose.=' alt="'.dol_escape_htmltag($label, 1).'"'; - } - $linkclose.= ' title="'.dol_escape_htmltag($label, 1).'"'; - $linkclose.= ' class="classfortooltip">'; + if (empty($notooltip)) { + if (! empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) + { + $label=$langs->trans("ShowContact"); + $linkclose.=' alt="'.dol_escape_htmltag($label, 1).'"'; + } + $linkclose.= ' title="'.dol_escape_htmltag($label, 1).'"'; + $linkclose.= ' class="classfortooltip"'; + } + $linkclose.='>'; if (! is_object($hookmanager)) { diff --git a/htdocs/contrat/card.php b/htdocs/contrat/card.php index 8034b8594d5..de69513e62a 100644 --- a/htdocs/contrat/card.php +++ b/htdocs/contrat/card.php @@ -6,7 +6,7 @@ * Copyright (C) 2010-2017 Juanjo Menent * Copyright (C) 2013 Christophe Battarel * Copyright (C) 2013-2014 Florian Henry - * Copyright (C) 2014-2016 Ferran Marcet + * Copyright (C) 2014-2018 Ferran Marcet * Copyright (C) 2014-2016 Marcos García * Copyright (C) 2015 Jean-François Ferry * @@ -2143,7 +2143,7 @@ else print ''; } - if ($object->nbofservicesclosed > 0) + if ($object->nbofservicesclosed > 0 || $object->nbofserviceswait > 0) { print ''; } diff --git a/htdocs/core/boxes/box_last_modified_ticketsup.php b/htdocs/core/boxes/box_last_modified_ticketsup.php index 08bf47ad46c..c63864b0fe0 100644 --- a/htdocs/core/boxes/box_last_modified_ticketsup.php +++ b/htdocs/core/boxes/box_last_modified_ticketsup.php @@ -18,9 +18,9 @@ */ /** - * \file ticketsup/core/boxes/ticketsup_latest.php - * \ingroup ticketsup - * \brief This box shows latest UNREAD tickets + * \file core/boxes/box_last_modified_ticketsup.php + * \ingroup ticketsup + * \brief This box shows latest modified tickets */ require_once DOL_DOCUMENT_ROOT . "/core/boxes/modules_boxes.php"; @@ -31,7 +31,7 @@ class box_last_modified_ticketsup extends ModeleBoxes { public $boxcode = "box_last_modified_ticketsup"; - public $boximg = "ticketsup@ticketsup"; + public $boximg = "ticketsup"; public $boxlabel; public $depends = array("ticketsup"); public $db; diff --git a/htdocs/core/boxes/box_last_ticketsup.php b/htdocs/core/boxes/box_last_ticketsup.php index 3eecceb74ae..5c39229835b 100644 --- a/htdocs/core/boxes/box_last_ticketsup.php +++ b/htdocs/core/boxes/box_last_ticketsup.php @@ -18,9 +18,9 @@ */ /** - * \file ticketsup/core/boxes/ticketsup_latest.php - * \ingroup ticketsup - * \brief This box shows latest tickets + * \file core/boxes/box_ticketsup_latest.php + * \ingroup ticketsup + * \brief This box shows latest created tickets */ require_once DOL_DOCUMENT_ROOT . "/core/boxes/modules_boxes.php"; @@ -31,7 +31,7 @@ class box_last_ticketsup extends ModeleBoxes { public $boxcode = "box_last_ticketsup"; - public $boximg = "ticketsup@ticketsup"; + public $boximg = "ticketsup"; public $boxlabel; public $depends = array("ticketsup"); public $db; diff --git a/htdocs/core/class/CMailFile.class.php b/htdocs/core/class/CMailFile.class.php index b7af324adb7..0caf056eab6 100644 --- a/htdocs/core/class/CMailFile.class.php +++ b/htdocs/core/class/CMailFile.class.php @@ -349,6 +349,8 @@ class CMailFile require_once DOL_DOCUMENT_ROOT.'/includes/swiftmailer/lexer/lib/Doctrine/Common/Lexer/AbstractLexer.php'; + require_once DOL_DOCUMENT_ROOT.'/includes/swiftmailer/egulias/email-validator/EmailValidator/Exception/InvalidEmail.php'; + require_once DOL_DOCUMENT_ROOT.'/includes/swiftmailer/egulias/email-validator/EmailValidator/Exception/NoDomainPart.php'; require_once DOL_DOCUMENT_ROOT.'/includes/swiftmailer/egulias/email-validator/EmailValidator/EmailParser.php'; require_once DOL_DOCUMENT_ROOT.'/includes/swiftmailer/egulias/email-validator/EmailValidator/EmailLexer.php'; require_once DOL_DOCUMENT_ROOT.'/includes/swiftmailer/egulias/email-validator/EmailValidator/EmailValidator.php'; @@ -384,12 +386,30 @@ class CMailFile // Set the From address with an associative array //$this->message->setFrom(array('john@doe.com' => 'John Doe')); - if (! empty($from)) $this->message->setFrom($this->getArrayAddress($from)); + if (! empty($from)) { + try { + $this->message->setFrom($this->getArrayAddress($from)); + } catch (Exception $e) { + $this->errors[] = $e->getMessage(); + } + } // Set the To addresses with an associative array - if (! empty($to)) $this->message->setTo($this->getArrayAddress($to)); + if (! empty($to)) { + try { + $this->message->setTo($this->getArrayAddress($to)); + } catch (Exception $e) { + $this->errors[] = $e->getMessage(); + } + } - if (! empty($replyto)) $this->message->SetReplyTo($this->getArrayAddress($replyto)); + if (! empty($replyto)) { + try { + $this->message->SetReplyTo($this->getArrayAddress($replyto)); + } catch (Exception $e) { + $this->errors[] = $e->getMessage(); + } + } $this->message->setCharSet($conf->file->character_set_client); diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 6616745888b..0e3719d2427 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -13,6 +13,7 @@ * Copyright (C) 2016 Bahfir abbes * Copyright (C) 2017 ATM Consulting * Copyright (C) 2017 Nicolas ZABOURI + * Copyright (C) 2017 Rui Strecht * Copyright (C) 2018 Frederic France * * This program is free software; you can redistribute it and/or modify @@ -197,7 +198,32 @@ abstract class CommonObject * @var string * @see getFullAddress(), isInEEC(), country */ - public $country_code; + public $country_code; + /** + * @var string + * @see getFullAddress() + */ + public $state; + /** + * @var int + * @see getFullAddress(), state + */ + public $state_id; + /** + * @var string + * @see getFullAddress(), state + */ + public $state_code; + /** + * @var string + * @see getFullAddress(), region + */ + public $region; + /** + * @var string + * @see getFullAddress(), region + */ + public $region_code; /** * @var int @@ -422,9 +448,10 @@ abstract class CommonObject * * @param int $withcountry 1=Add country into address string * @param string $sep Separator to use to build string + * @param int $withregion 1=Add region into address string * @return string Full address string */ - function getFullAddress($withcountry=0,$sep="\n") + function getFullAddress($withcountry=0,$sep="\n",$withregion=0) { if ($withcountry && $this->country_id && (empty($this->country_code) || empty($this->country))) { @@ -434,6 +461,16 @@ abstract class CommonObject $this->country =$tmparray['label']; } + if ($withregion && $this->state_id && (empty($this->state_code) || empty($this->state) || empty($this->region) || empty($this->region_cpde))) + { + require_once DOL_DOCUMENT_ROOT .'/core/lib/company.lib.php'; + $tmparray=getState($this->state_id,'all',0,1); + $this->state_code =$tmparray['code']; + $this->state =$tmparray['label']; + $this->region_code =$tmparray['region_code']; + $this->region =$tmparray['region']; + } + return dol_format_address($this, $withcountry, $sep); } @@ -471,7 +508,7 @@ abstract class CommonObject $out=''; $outdone=0; - $coords = $this->getFullAddress(1,', '); + $coords = $this->getFullAddress(1,', ',$conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT); if ($coords) { if (! empty($conf->use_javascript_ajax)) @@ -489,7 +526,12 @@ abstract class CommonObject if (! in_array($this->country_code,$countriesusingstate) && empty($conf->global->MAIN_FORCE_STATE_INTO_ADDRESS) // If MAIN_FORCE_STATE_INTO_ADDRESS is on, state is already returned previously with getFullAddress && empty($conf->global->SOCIETE_DISABLE_STATE) && $this->state) { - $out.=($outdone?' - ':'').$this->state; + if (!empty($conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT) && $conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT == 1 && $this->region) { + $out.=($outdone?' - ':'').$this->region.' - '.$this->state; + } + else { + $out.=($outdone?' - ':'').$this->state; + } $outdone++; } @@ -5527,7 +5569,7 @@ abstract class CommonObject $label = $val['label']; $type = $val['type']; $size = $val['css']; - + // Convert var to be able to share same code than showOutputField of extrafields if (preg_match('/varchar\((\d+)\)/', $type, $reg)) { @@ -6481,19 +6523,21 @@ abstract class CommonObject /** * Load object in memory from the database * - * @param int $id Id object - * @param string $ref Ref - * @return int <0 if KO, 0 if not found, >0 if OK + * @param int $id Id object + * @param string $ref Ref + * @param string $morewhere More SQL filters (' AND ...') + * @return int <0 if KO, 0 if not found, >0 if OK */ - public function fetchCommon($id, $ref = null) + public function fetchCommon($id, $ref = null, $morewhere = '') { if (empty($id) && empty($ref)) return false; $sql = 'SELECT '.$this->get_field_list(); $sql.= ' FROM '.MAIN_DB_PREFIX.$this->table_element; - if(!empty($id)) $sql.= ' WHERE rowid = '.$id; + if (!empty($id)) $sql.= ' WHERE rowid = '.$id; else $sql.= " WHERE ref = ".$this->quote($ref, $this->fields['ref']); + if ($morewhere) $sql.=$morewhere; $res = $this->db->query($sql); if ($res) @@ -6675,6 +6719,9 @@ abstract class CommonObject // TODO... } + + /* Part for comments */ + /** * Load comments linked with current task * @return boolean 1 if ok diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 70274040fd3..181b5f7b9b6 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -81,9 +81,10 @@ class Form * @param string $moreparam More param to add on a href URL. * @param int $fieldrequired 1 if we want to show field as mandatory using the "fieldrequired" CSS. * @param int $notabletag 1=Do not output table tags but output a ':', 2=Do not output table tags and no ':', 3=Do not output table tags but output a ' ' + * @param string $paramid Key of parameter for id ('id', 'socid') * @return string HTML edit field */ - function editfieldkey($text, $htmlname, $preselected, $object, $perm, $typeofdata='string', $moreparam='', $fieldrequired=0, $notabletag=0) + function editfieldkey($text, $htmlname, $preselected, $object, $perm, $typeofdata='string', $moreparam='', $fieldrequired=0, $notabletag=0, $paramid='id') { global $conf,$langs; @@ -117,7 +118,7 @@ class Form if (! empty($notabletag)) $ret.=' '; if (empty($notabletag) && GETPOST('action','aZ09') != 'edit'.$htmlname && $perm) $ret.=''; - if ($htmlname && GETPOST('action','aZ09') != 'edit'.$htmlname && $perm) $ret.='id.$moreparam.'">'.img_edit($langs->trans('Edit'), ($notabletag ? 0 : 1)).''; + if ($htmlname && GETPOST('action','aZ09') != 'edit'.$htmlname && $perm) $ret.='id.$moreparam.'">'.img_edit($langs->trans('Edit'), ($notabletag ? 0 : 1)).''; if (! empty($notabletag) && $notabletag == 1) $ret.=' : '; if (! empty($notabletag) && $notabletag == 3) $ret.=' '; if (empty($notabletag) && GETPOST('action','aZ09') != 'edit'.$htmlname && $perm) $ret.='
'; if (empty($notabletag)) $ret.=''; $addcolumforpicto=($delallowed || $printer || $morepicto); - $out.= ''; } else $out = $hookmanager->resPrint; // Replace line @@ -811,7 +811,7 @@ class FormFile if (count($file_list) == 0 && count($link_list) == 0 && $headershown) { - $out.=''."\n"; + $out.=''."\n"; } } @@ -861,7 +861,7 @@ class FormFile preg_match('/\/([0-9]+)\/[^\/]+\/'.preg_quote($modulesubdir).'$/', $filedir, $regs); $entity = ((! empty($regs[1]) && $regs[1] > 1) ? $regs[1] : $conf->entity); } - + $filterforfilesearch = preg_quote(basename($modulesubdir),'/').'[^\-]+'; $file_list=dol_dir_list($filedir, 'files', 0, $filterforfilesearch, '\.meta$|\.png$'); // Get list of files starting with name of ref (but not followed by "-" to discard uploaded files) @@ -1233,7 +1233,7 @@ class FormFile if ($permtoeditline) { // Link to resize - print ''.img_picto($langs->trans("Resize"),DOL_URL_ROOT.'/theme/common/transform-crop-and-resize','class="paddingrightonly"',1).''; + print ''.img_picto($langs->trans("Resize"),'resize','class="paddingrightonly"').''; } } diff --git a/htdocs/core/class/html.formsms.class.php b/htdocs/core/class/html.formsms.class.php index 94e60ba8082..103b40e33df 100644 --- a/htdocs/core/class/html.formsms.class.php +++ b/htdocs/core/class/html.formsms.class.php @@ -205,8 +205,16 @@ function limitChars(textarea, limit, infodiv) try { $classname=ucfirst($classfile); - $sms = new $classname($this->db); - $resultsender = $sms->SmsSenderList(); + if (class_exists($classname)) + { + $sms = new $classname($this->db); + $resultsender = $sms->SmsSenderList(); + } + else + { + $sms = new stdClass(); + $sms->error='The SMS manager '.$classfile.' defined into SMS setup MAIN_SMS_SENDMODE is not found'; + } } catch(Exception $e) { diff --git a/htdocs/core/class/html.formticketsup.class.php b/htdocs/core/class/html.formticketsup.class.php index 52b470c0929..bb77649dfcc 100644 --- a/htdocs/core/class/html.formticketsup.class.php +++ b/htdocs/core/class/html.formticketsup.class.php @@ -122,7 +122,7 @@ class FormTicketsup $langs->load("other"); $langs->load("mails"); - $langs->load("ticketsup@ticketsup"); + $langs->load("ticketsup"); $form = new Form($this->db); $formcompany = new FormCompany($this->db); @@ -148,18 +148,19 @@ class FormTicketsup } print ''; + print '
'; print '
'; if (preg_match('/^(string|email)/',$typeofdata)) @@ -4778,7 +4780,7 @@ class Form * @param string $addplusone Add a link "+1 hour". Value must be name of another select_date field. * @param datetime $adddateof Add a link "Date of invoice" using the following date. * @return string|null Nothing or string if nooutput is 1 - * @see form_date + * @see form_date, select_month, select_year, select_dayofweek */ function select_date($set_time='', $prefix='re', $h=0, $m=0, $empty=0, $form_name="", $d=1, $addnowlink=0, $nooutput=0, $disabled=0, $fullday='', $addplusone='', $adddateof='') { diff --git a/htdocs/core/class/html.formcompany.class.php b/htdocs/core/class/html.formcompany.class.php index faa548a5d16..27da8e4de39 100644 --- a/htdocs/core/class/html.formcompany.class.php +++ b/htdocs/core/class/html.formcompany.class.php @@ -222,8 +222,8 @@ class FormCompany $sql .= " ".MAIN_DB_PREFIX ."c_departements as d, ".MAIN_DB_PREFIX."c_regions as r,".MAIN_DB_PREFIX."c_country as c"; $sql .= " WHERE d.fk_region=r.code_region and r.fk_pays=c.rowid"; $sql .= " AND d.active = 1 AND r.active = 1 AND c.active = 1"; - if ($country_codeid && is_numeric($country_codeid)) $sql .= " AND c.rowid = '".$country_codeid."'"; - if ($country_codeid && ! is_numeric($country_codeid)) $sql .= " AND c.code = '".$country_codeid."'"; + if ($country_codeid && is_numeric($country_codeid)) $sql .= " AND c.rowid = '".$this->db->escape($country_codeid)."'"; + if ($country_codeid && ! is_numeric($country_codeid)) $sql .= " AND c.code = '".$this->db->escape($country_codeid)."'"; $sql .= " ORDER BY c.code, d.code_departement"; dol_syslog(get_class($this)."::select_departement", LOG_DEBUG); @@ -265,16 +265,26 @@ class FormCompany { $out.= ''; } $i++; diff --git a/htdocs/core/class/html.formfile.class.php b/htdocs/core/class/html.formfile.class.php index 077a29d4595..5eef895bb0c 100644 --- a/htdocs/core/class/html.formfile.class.php +++ b/htdocs/core/class/html.formfile.class.php @@ -616,7 +616,7 @@ class FormFile $out.= '
'; + $out.= ''; // Model if (! empty($modellist)) @@ -755,7 +755,7 @@ class FormFile $out.= ($param?'&'.$param:''); //$out.= '&modulepart='.$modulepart; // TODO obsolete ? //$out.= '&urlsource='.urlencode($urlsource); // TODO obsolete ? - $out.= '">'.img_picto($langs->trans("Delete"), 'delete.png').''; + $out.= '">'.img_picto($langs->trans("Delete"), 'delete').''; } if ($printer) { @@ -778,7 +778,7 @@ class FormFile $res = $hookmanager->executeHooks('formBuilddocLineOptions',$parameters,$file); if (empty($res)) { - $out .= $hookmanager->resPrint; // Complete line + $out.= $hookmanager->resPrint; // Complete line $out.= '
'.$langs->trans("None").'
'.$langs->trans("None").'
'; if ($this->withref) { // Ref $defaultref = $ticketstat->getDefaultRef(); - print ''; + print ''; } // FK_USER_CREATE if ($this->withusercreate > 0 && $this->fk_user_create) { - print ''; } else { - print ''; + print ''; print ''; print ''; } @@ -252,8 +253,8 @@ class FormTicketsup // TITLE if ($this->withemail) { - print ''; } @@ -281,7 +282,7 @@ class FormTicketsup } // Type - print ''; @@ -392,6 +393,7 @@ class FormTicketsup } print '
' . $langs->trans("Ref") . '
' . $langs->trans("Ref") . '
' . $langs->trans("CreatedBy") . ''; + print '
' . $langs->trans("CreatedBy") . ''; $langs->load("users"); $fuser = new User($this->db); @@ -177,7 +178,7 @@ class FormTicketsup // altairis: force company and contact id for external user if (empty($user->socid)) { // Company - print '
' . $langs->trans("Customer") . ''; + print '
' . $langs->trans("Customer") . ''; $events = array(); $events[] = array('method' => 'getContacts', 'url' => dol_buildpath('/core/ajax/contacts.php', 1), 'htmlname' => 'contactid', 'params' => array('add-customer-contact' => 'disabled')); print $form->select_company($this->withfromsocid, 'socid', '', 1, 1, '', $events); @@ -194,7 +195,7 @@ class FormTicketsup } }); }); - + function runJsCodeForEvent'.$htmlname.'(obj) { console.log("Run runJsCodeForEvent'.$htmlname.'"); var id = $("#'.$htmlname.'").val(); @@ -244,7 +245,7 @@ class FormTicketsup $formcompany->selectTypeContact($ticketstatic, '', 'type', 'external'); print '
'; - print ''; + print '
'; + print ''; print '
'; + print '
'; print $this->selectTypesTickets((GETPOST('type_code') ? GETPOST('type_code') : $this->type_code), 'type_code', '', '2'); print '
'; + print ''; print '
'; print ''; @@ -416,9 +418,10 @@ class FormTicketsup * @param int $empty 1=peut etre vide, 0 sinon * @param int $noadmininfo 0=Add admin info, 1=Disable admin info * @param int $maxlength Max length of label + * @param string $morecss More CSS * @return void */ - public function selectTypesTickets($selected = '', $htmlname = 'tickettype', $filtertype = '', $format = 0, $empty = 0, $noadmininfo = 0, $maxlength = 0) + public function selectTypesTickets($selected = '', $htmlname = 'tickettype', $filtertype = '', $format = 0, $empty = 0, $noadmininfo = 0, $maxlength = 0, $morecss='') { global $langs, $user; @@ -434,7 +437,7 @@ class FormTicketsup $ticketstat->loadCacheTypesTickets(); - print ''; if ($empty) { print ''; } @@ -499,8 +502,10 @@ class FormTicketsup } print ''; if ($user->admin && !$noadmininfo) { - print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionnarySetup"), 1); + print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); } + + print ajax_combobox('select'.$htmlname); } /** @@ -511,11 +516,12 @@ class FormTicketsup * @param string $filtertype To filter on field type in llx_c_ticketsup_category (array('code'=>xx,'label'=>zz)) * @param int $format 0=id+libelle, 1=code+code, 2=code+libelle, 3=id+code * @param int $empty 1=peut etre vide, 0 sinon - * @param int $noadmininfo 0=Add admin info, 1=Disable admin info + * @param int $noadmininfo 0=Add admin info, 1=Disable admin info * @param int $maxlength Max length of label - * @return void + * @param string $morecss More CSS + * @return void */ - public function selectCategoriesTickets($selected = '', $htmlname = 'ticketcategory', $filtertype = '', $format = 0, $empty = 0, $noadmininfo = 0, $maxlength = 0) + public function selectCategoriesTickets($selected = '', $htmlname = 'ticketcategory', $filtertype = '', $format = 0, $empty = 0, $noadmininfo = 0, $maxlength = 0, $morecss='') { global $langs, $user; @@ -531,7 +537,7 @@ class FormTicketsup $ticketstat->loadCacheCategoriesTickets(); - print ''; if ($empty) { print ''; } @@ -597,8 +603,10 @@ class FormTicketsup } print ''; if ($user->admin && !$noadmininfo) { - print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionnarySetup"), 1); + print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); } + + print ajax_combobox('select'.$htmlname); } /** @@ -609,11 +617,12 @@ class FormTicketsup * @param string $filtertype To filter on field type in llx_c_ticketsup_severity (array('code'=>xx,'label'=>zz)) * @param int $format 0=id+libelle, 1=code+code, 2=code+libelle, 3=id+code * @param int $empty 1=peut etre vide, 0 sinon - * @param int $noadmininfo 0=Add admin info, 1=Disable admin info + * @param int $noadmininfo 0=Add admin info, 1=Disable admin info * @param int $maxlength Max length of label - * @return void + * @param string $morecss More CSS + * @return void */ - public function selectSeveritiesTickets($selected = '', $htmlname = 'ticketseverity', $filtertype = '', $format = 0, $empty = 0, $noadmininfo = 0, $maxlength = 0) + public function selectSeveritiesTickets($selected = '', $htmlname = 'ticketseverity', $filtertype = '', $format = 0, $empty = 0, $noadmininfo = 0, $maxlength = 0, $morecss='') { global $langs, $user; @@ -629,7 +638,7 @@ class FormTicketsup $ticketstat->loadCacheSeveritiesTickets(); - print ''; if ($empty) { print ''; } @@ -694,8 +703,10 @@ class FormTicketsup } print ''; if ($user->admin && !$noadmininfo) { - print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionnarySetup"), 1); + print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); } + + print ajax_combobox('select'.$htmlname); } /** diff --git a/htdocs/core/class/translate.class.php b/htdocs/core/class/translate.class.php index 69fe031459d..0df169a3c3e 100644 --- a/htdocs/core/class/translate.class.php +++ b/htdocs/core/class/translate.class.php @@ -895,7 +895,7 @@ class Translate $sql = "SELECT ".$fieldlabel." as label"; $sql.= " FROM ".MAIN_DB_PREFIX.$tablename; - $sql.= " WHERE ".$fieldkey." = '".($keyforselect?$keyforselect:$key)."'"; + $sql.= " WHERE ".$fieldkey." = '".$db->escape($keyforselect?$keyforselect:$key)."'"; if ($filteronentity) $sql.= " AND entity IN (" . getEntity($tablename). ')'; dol_syslog(get_class($this).'::getLabelFromKey', LOG_DEBUG); $resql = $db->query($sql); @@ -977,7 +977,7 @@ class Translate $sql = "SELECT code_iso, label, unicode"; $sql.= " FROM ".MAIN_DB_PREFIX."c_currencies"; $sql.= " WHERE active = 1"; - if (! empty($currency_code)) $sql.=" AND code_iso = '".$currency_code."'"; + if (! empty($currency_code)) $sql.=" AND code_iso = '".$db->escape($currency_code)."'"; //$sql.= " ORDER BY code_iso ASC"; // Not required, a sort is done later dol_syslog(get_class($this).'::loadCacheCurrencies', LOG_DEBUG); diff --git a/htdocs/core/lib/admin.lib.php b/htdocs/core/lib/admin.lib.php index 0f219a032cc..2c94dcf65ca 100644 --- a/htdocs/core/lib/admin.lib.php +++ b/htdocs/core/lib/admin.lib.php @@ -1031,7 +1031,8 @@ function unActivateModule($value, $requiredby=1) /** - * Add external modules to list of dictionaries + * Add external modules to list of dictionaries. + * Addition is done into var $taborder, $tabname, etc... that are passed with pointers. * * @param array $taborder Taborder * @param array $tabname Tabname @@ -1097,23 +1098,20 @@ function complete_dictionary_with_modules(&$taborder,&$tabname,&$tablib,&$tabsql if ($modulequalified) { // Load languages files of module - if (isset($objMod->langfiles) && is_array($objMod->langfiles)) - { - foreach($objMod->langfiles as $langfile) - { - $langs->load($langfile); - } - } + if (isset($objMod->langfiles) && is_array($objMod->langfiles)) { + foreach ($objMod->langfiles as $langfile) { + $langs->load($langfile); + } + } - // Complete arrays - //&$tabname,&$tablib,&$tabsql,&$tabsqlsort,&$tabfield,&$tabfieldvalue,&$tabfieldinsert,&$tabrowid,&$tabcond + // Complete the arrays &$tabname,&$tablib,&$tabsql,&$tabsqlsort,&$tabfield,&$tabfieldvalue,&$tabfieldinsert,&$tabrowid,&$tabcond if (empty($objMod->dictionaries) && ! empty($objMod->dictionnaries)) $objMod->dictionaries=$objMod->dictionnaries; // For backward compatibility if (! empty($objMod->dictionaries)) { //var_dump($objMod->dictionaries['tabname']); $nbtabname=$nbtablib=$nbtabsql=$nbtabsqlsort=$nbtabfield=$nbtabfieldvalue=$nbtabfieldinsert=$nbtabrowid=$nbtabcond=$nbtabfieldcheck=$nbtabhelp=0; - foreach($objMod->dictionaries['tabname'] as $val) { $nbtabname++; $taborder[] = max($taborder)+1; $tabname[] = $val; } + foreach($objMod->dictionaries['tabname'] as $val) { $nbtabname++; $taborder[] = max($taborder)+1; $tabname[] = $val; } // Position foreach($objMod->dictionaries['tablib'] as $val) { $nbtablib++; $tablib[] = $val; } foreach($objMod->dictionaries['tabsql'] as $val) { $nbtabsql++; $tabsql[] = $val; } foreach($objMod->dictionaries['tabsqlsort'] as $val) { $nbtabsqlsort++; $tabsqlsort[] = $val; } @@ -1130,6 +1128,10 @@ function complete_dictionary_with_modules(&$taborder,&$tabname,&$tablib,&$tabsql print 'Error in descriptor of module '.$const_name.'. Array ->dictionaries has not same number of record for key "tabname", "tablib", "tabsql" and "tabsqlsort"'; //print "$const_name: $nbtabname=$nbtablib=$nbtabsql=$nbtabsqlsort=$nbtabfield=$nbtabfieldvalue=$nbtabfieldinsert=$nbtabrowid=$nbtabcond=$nbtabfieldcheck=$nbtabhelp\n"; } + else + { + $taborder[] = 0; // Add an empty line + } } $j++; diff --git a/htdocs/core/lib/company.lib.php b/htdocs/core/lib/company.lib.php index 023729e680d..6e056971c0d 100644 --- a/htdocs/core/lib/company.lib.php +++ b/htdocs/core/lib/company.lib.php @@ -9,6 +9,7 @@ * Copyright (C) 2013 Alexandre Spangaro * Copyright (C) 2015 Frederic France * Copyright (C) 2015 Raphaël Doursenaud + * Copyright (C) 2017 Rui Strecht * * 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 @@ -178,6 +179,8 @@ function societe_prepare_head(Societe $object) // Bank accounts if (empty($conf->global->SOCIETE_DISABLE_BANKACCOUNT)) { + $nbBankAccount=0; + $foundonexternalonlinesystem=0; $langs->load("banks"); $title = $langs->trans("BankAccounts"); @@ -185,11 +188,16 @@ function societe_prepare_head(Societe $object) { $langs->load("stripe"); $title = $langs->trans("BankAccountsAndGateways"); + + $servicestatus = 0; + if (! empty($conf->global->STRIPE_LIVE) && ! GETPOST('forcesandbox','alpha')) $servicestatus = 1; + + include_once DOL_DOCUMENT_ROOT.'/societe/class/societeaccount.class.php'; + $societeaccount = new SocieteAccount($db); + $stripecu = $societeaccount->getCustomerAccount($object->id, 'stripe', $servicestatus); // Get thirdparty cu_... + if ($stripecu) $foundonexternalonlinesystem++; } - $nbBankAccount=0; - $head[$h][0] = DOL_URL_ROOT .'/societe/paymentmodes.php?socid='.$object->id; - $head[$h][1] = $title; $sql = "SELECT COUNT(n.rowid) as nb"; $sql.= " FROM ".MAIN_DB_PREFIX."societe_rib as n"; $sql.= " WHERE fk_soc = ".$object->id; @@ -208,7 +216,13 @@ function societe_prepare_head(Societe $object) else { dol_print_error($db); } - if ($nbBankAccount > 0) $head[$h][1].= ' '.$nbBankAccount.''; + + //if (! empty($conf->stripe->enabled) && $nbBankAccount > 0) $nbBankAccount = '...'; // No way to know exact number + + $head[$h][0] = DOL_URL_ROOT .'/societe/paymentmodes.php?socid='.$object->id; + $head[$h][1] = $title; + if ($foundonexternalonlinesystem) $head[$h][1].= ' ...'; + elseif ($nbBankAccount > 0) $head[$h][1].= ' '.$nbBankAccount.''; $head[$h][2] = 'rib'; $h++; } @@ -460,22 +474,29 @@ function getCountry($searchkey, $withcode='', $dbtouse=0, $outputlangs='', $entc /** * Return state translated from an id. Return value is always utf8 encoded and without entities. * - * @param int $id id of state (province/departement) + * @param int $id id of state (province/departement) * @param int $withcode '0'=Return label, * '1'=Return string code + label, * '2'=Return code, * 'all'=return array('id'=>,'code'=>,'label'=>) * @param DoliDB $dbtouse Database handler (using in global way may fail because of conflicts with some autoload features) - * @return string String with state code or state name (Return value is always utf8 encoded and without entities) + * @param int $withregion '0'=Ignores region, + * '1'=Add region name/code/id as needed to output, + * @param Translate $outputlangs Langs object for output translation, not fully implemented yet + * @param int $entconv 0=Return value without entities and not converted to output charset, 1=Ready for html output + * @return mixed String with state code or state name or Array('id','code','label')/Array('id','code','label','region_code','region') */ -function getState($id,$withcode='',$dbtouse=0) +function getState($id,$withcode='',$dbtouse=0,$withregion=0,$outputlangs='',$entconv=1) { global $db,$langs; if (! is_object($dbtouse)) $dbtouse=$db; - $sql = "SELECT rowid, code_departement as code, nom as label FROM ".MAIN_DB_PREFIX."c_departements"; - $sql.= " WHERE rowid=".$id; + $sql = "SELECT d.rowid as id, d.code_departement as code, d.nom as name, d.active, c.label as country, c.code as country_code, r.code_region as region_code, r.nom as region_name FROM"; + $sql .= " ".MAIN_DB_PREFIX ."c_departements as d, ".MAIN_DB_PREFIX."c_regions as r,".MAIN_DB_PREFIX."c_country as c"; + $sql .= " WHERE d.fk_region=r.code_region and r.fk_pays=c.rowid and d.rowid=".$id; + $sql .= " AND d.active = 1 AND r.active = 1 AND c.active = 1"; + $sql .= " ORDER BY c.code, d.code_departement"; dol_syslog("Company.lib::getState", LOG_DEBUG); $resql=$dbtouse->query($sql); @@ -484,11 +505,46 @@ function getState($id,$withcode='',$dbtouse=0) $obj = $dbtouse->fetch_object($resql); if ($obj) { - $label=$obj->label; - if ($withcode == '1') return $label=$obj->code?"$obj->code":"$obj->code - $label"; - else if ($withcode == '2') return $label=$obj->code; - else if ($withcode == 'all') return array('id'=>$obj->rowid,'code'=>$obj->code,'label'=>$label); - else return $label; + $label=((! empty($obj->name) && $obj->name!='-')?$obj->name:''); + if (is_object($outputlangs)) + { + $outputlangs->load("dict"); + if ($entconv) $label=($obj->code && ($outputlangs->trans("State".$obj->code)!="State".$obj->code))?$outputlangs->trans("State".$obj->code):$label; + else $label=($obj->code && ($outputlangs->transnoentitiesnoconv("State".$obj->code)!="State".$obj->code))?$outputlangs->transnoentitiesnoconv("State".$obj->code):$label; + } + + if ($withcode == 1) { + if ($withregion == 1) { + return $label = $obj->region_name . ' - ' . $obj->code . ' - ' . ($langs->trans($obj->code)!=$obj->code?$langs->trans($obj->code):($obj->name!='-'?$obj->name:'')); + } + else { + return $label = $obj->code . ' - ' . ($langs->trans($obj->code)!=$obj->code?$langs->trans($obj->code):($obj->name!='-'?$obj->name:'')); + } + } + else if ($withcode == 2) { + if ($withregion == 1) { + return $label = $obj->region_name . ' - ' . ($langs->trans($obj->code)!=$obj->code?$langs->trans($obj->code):($obj->name!='-'?$obj->name:'')); + } + else { + return $label = ($langs->trans($obj->code)!=$obj->code?$langs->trans($obj->code):($obj->name!='-'?$obj->name:'')); + } + } + else if ($withcode === 'all') { + if ($withregion == 1) { + return array('id'=>$obj->id,'code'=>$obj->code,'label'=>$label,'region_code'=>$obj->region_code,'region'=>$obj->region_name); + } + else { + return array('id'=>$obj->id,'code'=>$obj->code,'label'=>$label); + } + } + else { + if ($withregion == 1) { + return $label = $obj->region_name . ' - ' . $label; + } + else { + return $label; + } + } } else { diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 7e817786714..bed4bcc8d6a 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -3052,18 +3052,26 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $ } else { + $pictowithoutext = preg_replace('/(\.png|\.gif|\.svg)$/', '', $picto); + //if (in_array($picto, array('switch_off', 'switch_on', 'off', 'on'))) - if (in_array($picto, array('switch_off', 'switch_on', 'off', 'on'))) + if (in_array($pictowithoutext, array('delete', 'edit', 'off', 'on', 'resize', 'switch_off', 'switch_on'))) { - $fakey = $picto; $facolor=''; $fasize=''; - if ($picto == 'switch_off') { $fakey = 'fa-toggle-off'; $facolor='#999'; $fasize='2em'; } - if ($picto == 'switch_on') { $fakey = 'fa-toggle-on'; $facolor='#227722'; $fasize='2em'; } - if ($picto == 'off') { $fakey = 'fa-square-o'; $fasize='1.3em'; } - if ($picto == 'on') { $fakey = 'fa-check-square-o'; $fasize='1.3em'; } - $enabledisablehtml=''; - $enabledisablehtml.=''; + $fakey = $pictowithoutext; $facolor=''; $fasize=''; + if ($pictowithoutext == 'switch_off') { $fakey = 'fa-toggle-off'; $facolor='#999'; $fasize='2em'; } + elseif ($pictowithoutext == 'switch_on') { $fakey = 'fa-toggle-on'; $facolor='#227722'; $fasize='2em'; } + elseif ($pictowithoutext == 'off') { $fakey = 'fa-square-o'; $fasize='1.3em'; } + elseif ($pictowithoutext == 'on') { $fakey = 'fa-check-square-o'; $fasize='1.3em'; } + elseif ($pictowithoutext == 'delete') { $fakey = 'fa-trash'; $facolor='#444'; } + elseif ($pictowithoutext == 'edit') { $fakey = 'fa-pencil'; $facolor='#444'; } + elseif ($pictowithoutext == 'resize') { $fakey = 'fa-crop'; $facolor='#444'; } + else { $fakey = 'fa-'.$pictowithoutext; $facolor='#999'; } + + if (preg_match('/class="([^"]+)"/', $moreatt, $reg)) { $morecss.=($morecss?' ':'').$reg[1]; } + $enabledisablehtml =''; if (! empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) $enabledisablehtml.=$titlealt; $enabledisablehtml.=''; + return $enabledisablehtml; } @@ -3306,6 +3314,7 @@ function img_delete($titlealt = 'default', $other = 'class="pictodelete"') if ($titlealt == 'default') $titlealt = $langs->trans('Delete'); return img_picto($titlealt, 'delete.png', $other); + //return ''; } /** @@ -3525,6 +3534,24 @@ function img_allow($allow, $titlealt = 'default') return '-'; } +/** + * Return image of a credit card according to its brand name + * + * @param string $brand Brand name of credit card + * @return string Return img tag + */ +function img_credit_card($brand) +{ + if ($brand == 'Visa') {$brand='cc-visa';} + elseif ($brand == 'MasterCard') {$brand='cc-mastercard';} + elseif ($brand == 'American Express') {$brand='cc-amex';} + elseif ($brand == 'Discover') {$brand='cc-discover';} + elseif ($brand == 'JCB') {$brand='cc-jcb';} + elseif ($brand == 'Diners Club') {$brand='cc-diners-club';} + elseif (! in_array($brand, array('cc-visa','cc-mastercard','cc-amex','cc-discover','cc-jcb','cc-diners-club'))) {$brand='credit-card';} + + return ''; +} /** * Show MIME img of a file @@ -6149,12 +6176,19 @@ function setEventMessage($mesgs, $style='mesgs') */ function setEventMessages($mesg, $mesgs, $style='mesgs') { - if (! in_array((string) $style, array('mesgs','warnings','errors'))) dol_print_error('','Bad parameter style='.$style.' for setEventMessages'); - if (empty($mesgs)) setEventMessage($mesg, $style); + if (empty($mesg) && empty($mesgs)) + { + dol_syslog("Try to add a message in stack with empty message", LOG_WARNING); + } else { - if (! empty($mesg) && ! in_array($mesg, $mesgs)) setEventMessage($mesg, $style); // Add message string if not already into array - setEventMessage($mesgs, $style); + if (! in_array((string) $style, array('mesgs','warnings','errors'))) dol_print_error('','Bad parameter style='.$style.' for setEventMessages'); + if (empty($mesgs)) setEventMessage($mesg, $style); + else + { + if (! empty($mesg) && ! in_array($mesg, $mesgs)) setEventMessage($mesg, $style); // Add message string if not already into array + setEventMessage($mesgs, $style); + } } } diff --git a/htdocs/core/lib/functions2.lib.php b/htdocs/core/lib/functions2.lib.php index 49a2f12db03..25c47632a14 100644 --- a/htdocs/core/lib/functions2.lib.php +++ b/htdocs/core/lib/functions2.lib.php @@ -1451,7 +1451,7 @@ function dol_set_user_param($db, $conf, &$user, $tab) foreach ($tab as $key => $value) { if ($i > 0) $sql.=','; - $sql.="'".$key."'"; + $sql.="'".$this->db->escape($key)."'"; $i++; } $sql.= ")"; @@ -1472,7 +1472,7 @@ function dol_set_user_param($db, $conf, &$user, $tab) { $sql = "INSERT INTO ".MAIN_DB_PREFIX."user_param(fk_user,entity,param,value)"; $sql.= " VALUES (".$user->id.",".$conf->entity.","; - $sql.= " '".$key."','".$db->escape($value)."')"; + $sql.= " '".$this->db->escape($key)."','".$db->escape($value)."')"; dol_syslog("functions2.lib::dol_set_user_param", LOG_DEBUG); $result=$db->query($sql); diff --git a/htdocs/core/lib/ticketsup.lib.php b/htdocs/core/lib/ticketsup.lib.php index b25f3d1a4cd..68f8d820116 100644 --- a/htdocs/core/lib/ticketsup.lib.php +++ b/htdocs/core/lib/ticketsup.lib.php @@ -31,7 +31,7 @@ function ticketsupAdminPrepareHead() { global $langs, $conf; - $langs->load("ticketsup@ticketsup"); + $langs->load("ticketsup"); $h = 0; $head = array(); @@ -75,16 +75,19 @@ function ticketsup_prepare_head($object) $head[$h][2] = 'tabTicketsup'; $h++; - if (empty($user->socid)) { - $head[$h][0] = DOL_URL_ROOT.'/ticketsup/contacts.php?track_id=' . $object->track_id; - $head[$h][1] = $langs->trans('Contacts'); - $head[$h][2] = 'tabTicketContacts'; - $h++; + + if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB) && empty($user->socid)) + { + $nbContact = count($object->liste_contact(-1,'internal')) + count($object->liste_contact(-1,'external')); + $head[$h][0] = DOL_URL_ROOT.'/ticketsup/contact.php?track_id='.$object->track_id; + $head[$h][1] = $langs->trans('ContactsAddresses'); + if ($nbContact > 0) $head[$h][1].= ' '.$nbContact.''; + $head[$h][2] = 'contact'; + $h++; } complete_head_from_modules($conf, $langs, $object, $head, $h, 'ticketsup'); - // Attached files include_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php'; $upload_dir = $conf->ticketsup->dir_output . "/" . $object->track_id; diff --git a/htdocs/core/modules/commande/doc/pdf_einstein.modules.php b/htdocs/core/modules/commande/doc/pdf_einstein.modules.php index 7c24e49e89b..9d15b263b66 100644 --- a/htdocs/core/modules/commande/doc/pdf_einstein.modules.php +++ b/htdocs/core/modules/commande/doc/pdf_einstein.modules.php @@ -1330,7 +1330,7 @@ class pdf_einstein extends ModelePDFCommandes $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$labelbeforecontactname." ".$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs))."\n"; } - $carac_emetteur .= pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty); + $carac_emetteur .= pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, '', 0, 'source', $object); // Show sender $posy=42+$top_shift; diff --git a/htdocs/core/modules/contract/doc/pdf_strato.modules.php b/htdocs/core/modules/contract/doc/pdf_strato.modules.php index 2cea64a72a6..74b5d43f489 100644 --- a/htdocs/core/modules/contract/doc/pdf_strato.modules.php +++ b/htdocs/core/modules/contract/doc/pdf_strato.modules.php @@ -583,7 +583,7 @@ class pdf_strato extends ModelePDFContract $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$outputlangs->transnoentities("Name").": ".$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs))."\n"; } - $carac_emetteur .= pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty); + $carac_emetteur .= pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, '', 0, 'source', $object); // Show sender $posy=42; diff --git a/htdocs/core/modules/expedition/doc/pdf_merou.modules.php b/htdocs/core/modules/expedition/doc/pdf_merou.modules.php index 68795126487..0ae6ed3ebe5 100644 --- a/htdocs/core/modules/expedition/doc/pdf_merou.modules.php +++ b/htdocs/core/modules/expedition/doc/pdf_merou.modules.php @@ -542,7 +542,7 @@ class pdf_merou extends ModelePdfExpedition $pdf->SetTextColor(0,0,0); // Sender properties - $carac_emetteur = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty); + $carac_emetteur = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, '', 0, 'source', $object); $pdf->SetFont('','', $default_font_size - 3); $pdf->SetXY($blSocX,$blSocY+4); diff --git a/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php b/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php index f7eca910b7e..978f15d2ae8 100644 --- a/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php +++ b/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php @@ -935,7 +935,7 @@ class pdf_rouget extends ModelePdfExpedition $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$outputlangs->transnoentities("Name").": ".$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs))."\n"; } - $carac_emetteur .= pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty); + $carac_emetteur .= pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, '', 0, 'source', $object); // Show sender $posy=!empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 40 : 42; diff --git a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php index 21adfe4edb4..6a063ec0e86 100644 --- a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php +++ b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php @@ -1692,7 +1692,7 @@ class pdf_crabe extends ModelePDFFactures if ($showaddress) { // Sender properties - $carac_emetteur = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty); + $carac_emetteur = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, '', 0, 'source', $object); // Show sender $posy=!empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 40 : 42; diff --git a/htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php b/htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php index f63f05b07f9..2307f896973 100644 --- a/htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php +++ b/htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php @@ -584,7 +584,7 @@ class pdf_soleil extends ModelePDFFicheinter $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$outputlangs->transnoentities("Name").": ".$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs))."\n"; } - $carac_emetteur .= pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty); + $carac_emetteur .= pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, '', 0, 'source', $object); // Show sender $posy=42; diff --git a/htdocs/core/modules/livraison/doc/pdf_typhon.modules.php b/htdocs/core/modules/livraison/doc/pdf_typhon.modules.php index fcb0bb6b057..06d6920e866 100644 --- a/htdocs/core/modules/livraison/doc/pdf_typhon.modules.php +++ b/htdocs/core/modules/livraison/doc/pdf_typhon.modules.php @@ -799,7 +799,7 @@ class pdf_typhon extends ModelePDFDeliveryOrder if ($showaddress) { // Sender properties - $carac_emetteur = pdf_build_address($outputlangs,$this->emetteur); + $carac_emetteur = pdf_build_address($outputlangs,$this->emetteur, $object->thirdparty, '', 0, 'source', $object); // Show sender $posy=42; diff --git a/htdocs/core/modules/mailings/advthirdparties.modules.php b/htdocs/core/modules/mailings/advthirdparties.modules.php index 9252ae5ec3a..e6f0255b9d9 100644 --- a/htdocs/core/modules/mailings/advthirdparties.modules.php +++ b/htdocs/core/modules/mailings/advthirdparties.modules.php @@ -100,7 +100,7 @@ class mailing_advthirdparties extends MailingTargets 'source_url' => $this->url($obj->id,'thirdparty'), 'source_id' => $obj->id, 'source_type' => 'thirdparty' - ); + ); } } @@ -289,11 +289,11 @@ class mailing_advthirdparties extends MailingTargets if ($type=='thirdparty') { $companystatic=new Societe($this->db); $companystatic->fetch($id); - return $companystatic->getNomUrl(0); + return $companystatic->getNomUrl(0, '', 0, 1); } elseif ($type=='contact') { $contactstatic=new Contact($this->db); $contactstatic->fetch($id); - return $contactstatic->getNomUrl(0); + return $contactstatic->getNomUrl(0, '', 0, '', -1, 0); } } diff --git a/htdocs/core/modules/modAccounting.class.php b/htdocs/core/modules/modAccounting.class.php index ea7208cc5dd..d8365776d9c 100644 --- a/htdocs/core/modules/modAccounting.class.php +++ b/htdocs/core/modules/modAccounting.class.php @@ -71,73 +71,88 @@ class modAccounting extends DolibarrModules $this->langfiles = array("accountancy","compta"); // Constants + // List of particular constants to add when module is enabled (key, 'chaine', value, desc, visible, 'current' or 'allentities', deleteonunactive) + // Example: $this->const=array(0=>array('MYMODULE_MYNEWCONST1','chaine','myvalue','This is a constant to add',1), + // 1=>array('MYMODULE_MYNEWCONST2','chaine','myvalue','This is another constant to add',0, 'current', 1) + // ); $this->const = array(); $this->const[1] = array( "MAIN_COMPANY_CODE_ALWAYS_REQUIRED", "chaine", "1", - "With this constants on, third party code is always required whatever is numbering module behaviour" + "With this constants on, third party code is always required whatever is numbering module behaviour", 0, 'current', 0 ); $this->const[2] = array( "MAIN_BANK_ACCOUNTANCY_CODE_ALWAYS_REQUIRED", "chaine", "1", - "With this constants on, bank account number is always required" + "With this constants on, bank account number is always required", 0, 'current', 1 ); $this->const[3] = array( "ACCOUNTING_ACCOUNT_SUSPENSE", "chaine", - "471" + "471", + "", 0, 'current', 0 ); $this->const[4] = array( "ACCOUNTING_ACCOUNT_TRANSFER_CASH", "chaine", - "58" + "58", + "", 0, 'current', 0 ); $this->const[5] = array( "CHARTOFACCOUNTS", "chaine", - "2" + "2", + "", 0, 'current', 0 ); $this->const[6] = array( "ACCOUNTING_EXPORT_MODELCSV", "chaine", - "1" + "1", + "", 0, 'current', 0 ); $this->const[7] = array( "ACCOUNTING_LENGTH_GACCOUNT", "chaine", - "" + "", + "", 0, 'current', 0 ); $this->const[8] = array( "ACCOUNTING_LENGTH_AACCOUNT", "chaine", - "" + "", + "", 0, 'current', 0 ); $this->const[9] = array( "ACCOUNTING_LIST_SORT_VENTILATION_TODO", "yesno", - "1" + "1", + "", 0, 'current', 0 ); $this->const[10] = array( "ACCOUNTING_LIST_SORT_VENTILATION_DONE", "yesno", - "1" + "1", + "", 0, 'current', 0 ); $this->const[11] = array ( "ACCOUNTING_EXPORT_DATE", "chaine", - "%d%m%Y" + "%d%m%Y", + "", 0, 'current', 0 ); $this->const[12] = array( "ACCOUNTING_EXPORT_SEPARATORCSV", "string", - "," + ",", + "", 0, 'current', 0 ); $this->const[13] = array( "ACCOUNTING_EXPORT_FORMAT", "chaine", - "csv" + "csv", + "", 0, 'current', 0 ); // Tabs diff --git a/htdocs/core/modules/modApi.class.php b/htdocs/core/modules/modApi.class.php index 24d784585d3..86588f06ed4 100644 --- a/htdocs/core/modules/modApi.class.php +++ b/htdocs/core/modules/modApi.class.php @@ -125,21 +125,6 @@ class modApi extends DolibarrModules $conf->api->enabled=0; } $this->dictionaries=array(); - /* Example: - if (! isset($conf->api->enabled)) $conf->api->enabled=0; // This is to avoid warnings - $this->dictionaries=array( - 'langs'=>'mylangfile@api', - 'tabname'=>array(MAIN_DB_PREFIX."table1",MAIN_DB_PREFIX."table2",MAIN_DB_PREFIX."table3"), // List of tables we want to see into dictonnary editor - 'tablib'=>array("Table1","Table2","Table3"), // Label of tables - 'tabsql'=>array('SELECT f.rowid as rowid, f.code, f.label, f.active FROM '.MAIN_DB_PREFIX.'table1 as f','SELECT f.rowid as rowid, f.code, f.label, f.active FROM '.MAIN_DB_PREFIX.'table2 as f','SELECT f.rowid as rowid, f.code, f.label, f.active FROM '.MAIN_DB_PREFIX.'table3 as f'), // Request to select fields - 'tabsqlsort'=>array("label ASC","label ASC","label ASC"), // Sort order - 'tabfield'=>array("code,label","code,label","code,label"), // List of fields (result of select to show dictionary) - 'tabfieldvalue'=>array("code,label","code,label","code,label"), // List of fields (list of fields to edit a record) - 'tabfieldinsert'=>array("code,label","code,label","code,label"), // List of fields (list of fields for insert) - 'tabrowid'=>array("rowid","rowid","rowid"), // Name of columns with primary key (try to always name it 'rowid') - 'tabcond'=>array($conf->api->enabled,$conf->api->enabled,$conf->api->enabled) // Condition to show each dictionary - ); - */ // Boxes // Add here list of php file(s) stored in core/boxes that contains class to show a box. diff --git a/htdocs/core/modules/modTicketsup.class.php b/htdocs/core/modules/modTicketsup.class.php index 38299617788..00d01031294 100644 --- a/htdocs/core/modules/modTicketsup.class.php +++ b/htdocs/core/modules/modTicketsup.class.php @@ -74,7 +74,7 @@ class modTicketsup extends DolibarrModules // use this->picto='pictovalue' // If file is in module/img directory under name object_pictovalue.png // use this->picto='pictovalue@module' - $this->picto = 'ticketsup@ticketsup'; // mypicto@ticketsup + $this->picto = 'ticketsup'; // mypicto@ticketsup // Defined all module parts (triggers, login, substitutions, menus, css, etc...) // for default path (eg: /ticketsup/core/xxxxx) (0=disable, 1=enable) // for specific path of parts (eg: /ticketsup/core/modules/barcode) @@ -135,7 +135,7 @@ class modTicketsup extends DolibarrModules $conf->ticketsup->enabled=0; } $this->dictionaries = array( - 'langs' => 'ticketsup@ticketsup', + 'langs' => 'ticketsup', 'tabname' => array(MAIN_DB_PREFIX . "c_ticketsup_type", MAIN_DB_PREFIX . "c_ticketsup_category", MAIN_DB_PREFIX . "c_ticketsup_severity"), 'tablib' => array("TicketsupDictType", "TicketsupDictCategory", "TicketsupDictSeverity"), 'tabsql' => array('SELECT f.rowid as rowid, f.code, f.pos, f.label, f.active, f.use_default FROM ' . MAIN_DB_PREFIX . 'c_ticketsup_type as f', 'SELECT f.rowid as rowid, f.code, f.pos, f.label, f.active, f.use_default FROM ' . MAIN_DB_PREFIX . 'c_ticketsup_category as f', 'SELECT f.rowid as rowid, f.code, f.pos, f.label, f.active, f.use_default FROM ' . MAIN_DB_PREFIX . 'c_ticketsup_severity as f'), @@ -153,17 +153,16 @@ class modTicketsup extends DolibarrModules $r = 0; // Example: - $this->boxes[$r][1] = "box_last_ticketsup@ticketsup"; + $this->boxes[$r][1] = "box_last_ticketsup"; $r++; - $this->boxes[$r][1] = "box_last_modified_ticketsup@ticketsup"; + $this->boxes[$r][1] = "box_last_modified_ticketsup"; $r++; // Permissions $this->rights = array(); // Permission array used by this module - $r = 0; - $r++; + $r=0; $this->rights[$r][0] = 56001; // id de la permission $this->rights[$r][1] = "Read ticket"; // libelle de la permission $this->rights[$r][2] = 'r'; // type de la permission (deprecie a ce jour) @@ -209,9 +208,9 @@ class modTicketsup extends DolibarrModules 'mainmenu' => 'ticketsup', 'leftmenu' => '1', // Use 1 if you also want to add left menu entries using this descriptor. 'url' => '/ticketsup/index.php', - 'langs' => 'ticketsup@ticketsup', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. + 'langs' => 'ticketsup', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. 'position' => 100, - 'enabled' => '1', // Define condition to show or hide menu entry. Use '$conf->ticketsup->enabled' if entry must be visible if module is enabled. + 'enabled' => '$conf->ticketsup->enabled', // Define condition to show or hide menu entry. Use '$conf->ticketsup->enabled' if entry must be visible if module is enabled. 'perms' => '$user->rights->ticketsup->read', // Use 'perms'=>'$user->rights->ticketsup->level1->level2' if you want your menu with a permission rules 'target' => '', 'user' => 2); // 0=Menu for internal users, 1=external users, 2=both @@ -223,9 +222,9 @@ class modTicketsup extends DolibarrModules 'mainmenu' => 'ticketsup', 'leftmenu' => 'ticketsup', 'url' => '/ticketsup/index.php', - 'langs' => 'ticketsup@ticketsup', + 'langs' => 'ticketsup', 'position' => 101, - 'enabled' => 1, + 'enabled' => '$conf->ticketsup->enabled', 'perms' => '$user->rights->ticketsup->read', 'target' => '', 'user' => 2); @@ -236,9 +235,9 @@ class modTicketsup extends DolibarrModules 'titre' => 'NewTicket', 'mainmenu' => 'ticketsup', 'url' => '/ticketsup/new.php?action=create_ticket', - 'langs' => 'ticketsup@ticketsup', + 'langs' => 'ticketsup', 'position' => 102, - 'enabled' => 1, + 'enabled' => '$conf->ticketsup->enabled', 'perms' => '$user->rights->ticketsup->write', 'target' => '', 'user' => 2); @@ -250,9 +249,9 @@ class modTicketsup extends DolibarrModules 'mainmenu' => 'ticketsup', 'leftmenu' => 'ticketsuplist', 'url' => '/ticketsup/list.php', - 'langs' => 'ticketsup@ticketsup', + 'langs' => 'ticketsup', 'position' => 103, - 'enabled' => 1, + 'enabled' => '$conf->ticketsup->enabled', 'perms' => '$user->rights->ticketsup->read', 'target' => '', 'user' => 2); @@ -264,9 +263,9 @@ class modTicketsup extends DolibarrModules 'mainmenu' => 'ticketsup', 'leftmenu' => 'ticketsuplist', 'url' => '/ticketsup/list.php?search_fk_status=non_closed', - 'langs' => 'ticketsup@ticketsup', + 'langs' => 'ticketsup', 'position' => 104, - 'enabled' => 1, + 'enabled' => '$conf->ticketsup->enabled', 'perms' => '$user->rights->ticketsup->read', 'target' => '', 'user' => 2); @@ -278,9 +277,9 @@ class modTicketsup extends DolibarrModules 'mainmenu' => 'ticketsup', 'leftmenu' => 'ticketsupmy', 'url' => '/ticketsup/list.php?mode=my_assign', - 'langs' => 'ticketsup@ticketsup', + 'langs' => 'ticketsup', 'position' => 105, - 'enabled' => 1, + 'enabled' => '$conf->ticketsup->enabled', 'perms' => '$user->rights->ticketsup->read', 'target' => '', 'user' => 0); @@ -291,9 +290,9 @@ class modTicketsup extends DolibarrModules 'titre' => 'MenuTicketsupMyAssignNonClosed', 'mainmenu' => 'ticketsup', 'url' => '/ticketsup/list.php?mode=my_assign&search_fk_status=non_closed', - 'langs' => 'ticketsup@ticketsup', + 'langs' => 'ticketsup', 'position' => 106, - 'enabled' => 1, + 'enabled' => '$conf->ticketsup->enabled', 'perms' => '$user->rights->ticketsup->read', 'target' => '', 'user' => 0); @@ -301,13 +300,12 @@ class modTicketsup extends DolibarrModules } /** - * Function called when module is enabled. - * The init function add constants, boxes, permissions and menus - * (defined in constructor) into Dolibarr database. - * It also creates data directories + * Function called when module is enabled. + * The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database. + * It also creates data directories * - * @param string $options Options when enabling module ('', 'noboxes') - * @return int 1 if OK, 0 if KO + * @param string $options Options when enabling module ('', 'noboxes') + * @return int 1 if OK, 0 if KO */ public function init($options = '') { @@ -317,40 +315,10 @@ class modTicketsup extends DolibarrModules array("sql" => "insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (110121, 'ticketsup', 'internal', 'CONTRIBUTOR', 'Intervenant', 1);", "ignoreerror" => 1), array("sql" => "insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (110122, 'ticketsup', 'external', 'SUPPORTCLI', 'Contact client suivi incident', 1);", "ignoreerror" => 1), array("sql" => "insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (110123, 'ticketsup', 'external', 'CONTRIBUTOR', 'Intervenant', 1);", "ignoreerror" => 1), - array("sql" => "insert into llx_c_action_trigger (rowid,code,label,description,elementtype,rang) values ('','TICKETMESSAGE_SENTBYMAIL','Envoi message de réponse par mail','Executed when a response is made on a ticket','ticketsup','');", "ignoreerror" => 1), - + array("sql" => "insert into llx_c_action_trigger (rowid,code,label,description,elementtype,rang) values ('','TICKETMESSAGE_SENTBYMAIL','Send email for ticket','Executed when a response is made on a ticket','ticketsup','');", "ignoreerror" => 1), ); - $result = $this->loadTables(); - return $this->_init($sql, $options); } - /** - * Function called when module is disabled. - * Remove from database constants, boxes and permissions from Dolibarr database. - * Data directories are not deleted - * - * @param string $options Options when enabling module ('', 'noboxes') - * @return int 1 if OK, 0 if KO - */ - public function remove($options = '') - { - $sql = array(); - - return $this->_remove($sql, $options); - } - - /** - * Create tables, keys and data required by module - * Files llx_table1.sql, llx_table1.key.sql llx_data.sql with create table, create keys - * and create data commands must be stored in directory /ticketsup/sql/ - * This function is called by this->init - * - * @return int <=0 if KO, >0 if OK - */ - private function loadTables() - { - return $this->_load_tables('/ticketsup/sql/'); - } } diff --git a/htdocs/core/modules/modules_ticketsup.php b/htdocs/core/modules/modules_ticketsup.php index 9eb652c31f4..e6e47adaa9f 100644 --- a/htdocs/core/modules/modules_ticketsup.php +++ b/htdocs/core/modules/modules_ticketsup.php @@ -49,7 +49,7 @@ abstract class ModeleNumRefTicketsup public function info() { global $langs; - $langs->load("ticketsup@ticketsup"); + $langs->load("ticketsup"); return $langs->trans("NoDescription"); } @@ -61,7 +61,7 @@ abstract class ModeleNumRefTicketsup public function getExample() { global $langs; - $langs->load("ticketsup@ticketsup"); + $langs->load("ticketsup"); return $langs->trans("NoExample"); } diff --git a/htdocs/core/modules/propale/doc/pdf_azur.modules.php b/htdocs/core/modules/propale/doc/pdf_azur.modules.php index a54cfbf212f..fba77613828 100644 --- a/htdocs/core/modules/propale/doc/pdf_azur.modules.php +++ b/htdocs/core/modules/propale/doc/pdf_azur.modules.php @@ -1515,7 +1515,7 @@ class pdf_azur extends ModelePDFPropales $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$labelbeforecontactname." ".$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs))."\n"; } - $carac_emetteur .= pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty); + $carac_emetteur .= pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, '', 0, 'source', $object); // Show sender $posy=42+$top_shift; diff --git a/htdocs/core/modules/supplier_invoice/pdf/pdf_canelle.modules.php b/htdocs/core/modules/supplier_invoice/pdf/pdf_canelle.modules.php index 9cdb9ebc6a0..f927b064a69 100644 --- a/htdocs/core/modules/supplier_invoice/pdf/pdf_canelle.modules.php +++ b/htdocs/core/modules/supplier_invoice/pdf/pdf_canelle.modules.php @@ -1086,7 +1086,7 @@ class pdf_canelle extends ModelePDFSuppliersInvoices if ($showaddress) { // Sender properties - $carac_emetteur = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty); + $carac_emetteur = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, '', 0, 'source', $object); // Show sender $posy=42; diff --git a/htdocs/core/modules/supplier_order/pdf/pdf_muscadet.modules.php b/htdocs/core/modules/supplier_order/pdf/pdf_muscadet.modules.php index d272957d80d..f61000d3b08 100644 --- a/htdocs/core/modules/supplier_order/pdf/pdf_muscadet.modules.php +++ b/htdocs/core/modules/supplier_order/pdf/pdf_muscadet.modules.php @@ -1211,7 +1211,7 @@ class pdf_muscadet extends ModelePDFSuppliersOrders if ($showaddress) { // Sender properties - $carac_emetteur = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty); + $carac_emetteur = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, '', 0, 'source', $object); // Show sender $posy=42; diff --git a/htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php b/htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php index 7411933dd26..46d4e35d10e 100644 --- a/htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php +++ b/htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php @@ -1306,7 +1306,7 @@ class pdf_aurore extends ModelePDFSupplierProposal $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$labelbeforecontactname.": ".$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs))."\n"; } - $carac_emetteur .= pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty); + $carac_emetteur .= pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, '', 0, 'source', $object); // Show sender $posy=42; diff --git a/htdocs/core/modules/ticketsup/mod_ticketsup_universal.php b/htdocs/core/modules/ticketsup/mod_ticketsup_universal.php index 8c0c8c8fe0c..881ba5a7f15 100644 --- a/htdocs/core/modules/ticketsup/mod_ticketsup_universal.php +++ b/htdocs/core/modules/ticketsup/mod_ticketsup_universal.php @@ -43,7 +43,7 @@ class mod_ticketsup_universal extends ModeleNumRefTicketsup { global $conf, $langs; - $langs->load("ticketsup@ticketsup"); + $langs->load("ticketsup"); $langs->load("admin"); $form = new Form($this->db); diff --git a/htdocs/core/tpl/objectline_create.tpl.php b/htdocs/core/tpl/objectline_create.tpl.php index 501e3db3d6c..e2dfed0f68b 100644 --- a/htdocs/core/tpl/objectline_create.tpl.php +++ b/htdocs/core/tpl/objectline_create.tpl.php @@ -283,6 +283,18 @@ else { if (! empty($conf->global->FCKEDITOR_ENABLE_DETAILS_FULL)) $toolbarname='dolibarr_notes'; $doleditor=new DolEditor('dp_desc',GETPOST('dp_desc'),'',100,$toolbarname,'',false,true,$enabled,$nbrows,'98%'); $doleditor->Create(); + + // Show autofill date for recuring invoices + if (! empty($conf->service->enabled) && $object->element == 'facturerec') + { + echo '

'; + echo $langs->trans('AutoFillDateFrom').' '; + echo $form->selectyesno('date_start_fill', $line->date_start_fill, 1); + echo ' - '; + echo $langs->trans('AutoFillDateTo').' '; + echo $form->selectyesno('date_end_fill', $line->date_end_fill, 1); + echo '
'; + } ?> @@ -594,8 +606,17 @@ jQuery(document).ready(function() { if (editor) { editor.focus(); } } } - if (jQuery('#select_type').val() == '0') jQuery('#trlinefordates').hide(); - else jQuery('#trlinefordates').show(); + console.log("Hide/show date according to product type"); + if (jQuery('#select_type').val() == '0') + { + jQuery('#trlinefordates').hide(); + jQuery('.divlinefordates').hide(); + } + else + { + jQuery('#trlinefordates').show(); + jQuery('.divlinefordates').show(); + } }); $("#prod_entry_mode_predef").on( "click", function() { @@ -799,7 +820,7 @@ function setforfree() { jQuery("#units, #title_units").show(); } function setforpredef() { - console.log("Call setforpredef. We hide some fields"); + console.log("Call setforpredef. We hide some fields and show dates"); jQuery("#select_type").val(-1); jQuery("#prod_entry_mode_free").prop('checked',false).change(); @@ -820,6 +841,9 @@ function setforpredef() { jQuery(".np_marginRate").hide(); // May no exists jQuery(".np_markRate").hide(); // May no exists jQuery("#units, #title_units").hide(); + + jQuery('#trlinefordates').show(); + jQuery('.divlinefordates').show(); } diff --git a/htdocs/core/tpl/objectline_edit.tpl.php b/htdocs/core/tpl/objectline_edit.tpl.php index 67adba3a2ae..30b4f01cfb8 100644 --- a/htdocs/core/tpl/objectline_edit.tpl.php +++ b/htdocs/core/tpl/objectline_edit.tpl.php @@ -62,7 +62,10 @@ if (!empty($conf->multicurrency->enabled)) $colspan+=2; $coldisplay=-1; // We remove first td ?> > - global->MAIN_VIEW_LINE_NUMBER) ? ' colspan="2"' : ''); ?>>global->MAIN_VIEW_LINE_NUMBER))?2:1; ?> + global->MAIN_VIEW_LINE_NUMBER)) { ?> + + +
@@ -83,7 +86,7 @@ $coldisplay=-1; // We remove first td echo ' - '.nl2br($line->product_label); ?> -
+

@@ -110,6 +113,18 @@ $coldisplay=-1; // We remove first td } else { print ''; } + + // Show autofill date for recuring invoices + if (! empty($conf->service->enabled) && $line->product_type == 1 && $line->element == 'facturedetrec') + { + echo '
'; + echo $langs->trans('AutoFillDateFrom').' '; + echo $form->selectyesno('date_start_fill', $line->date_start_fill, 1); + echo ' - '; + echo $langs->trans('AutoFillDateTo').' '; + echo $form->selectyesno('date_end_fill', $line->date_end_fill, 1); + } + ?> @@ -117,7 +132,7 @@ $coldisplay=-1; // We remove first td if ($object->element == 'supplier_proposal' || $object->element == 'order_supplier' || $object->element == 'invoice_supplier') // We must have same test in printObjectLines { ?> - + service->enabled) && $line->product_type == 1 && $dateSelector) { ?> > + global->MAIN_VIEW_LINE_NUMBER)) { ?> + + trans('ServiceLimitedDuration').' '.$langs->trans('From').' '; ?> global->MAIN_USE_HOURMIN_IN_DATE_RANGE)?$conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE:''); @@ -264,7 +282,8 @@ $coldisplay=-1; // We remove first td ?> - + '; @@ -692,7 +692,7 @@ if ($id > 0) $total_insurance = 0; $total_interest = 0; $total_capital = 0; - print ''; + print '
'; print ''; print ''; print ''; @@ -729,7 +729,9 @@ if ($id > 0) $staytopay = $object->capital - $totalpaid; print ''; - print ''; + print ''; } print "
'.$langs->trans("RefPayment").''.$langs->trans("Date").'
'.$langs->trans("RemainderToPay").' :'.price($staytopay, 0, $langs, 0, 0, -1, $conf->currency).'
'; + print price($staytopay, 0, $langs, 0, 0, -1, $conf->currency); + print '
"; $db->free($resql); diff --git a/htdocs/loan/class/loanschedule.class.php b/htdocs/loan/class/loanschedule.class.php index ebb1820bca0..a430f79366e 100644 --- a/htdocs/loan/class/loanschedule.class.php +++ b/htdocs/loan/class/loanschedule.class.php @@ -386,7 +386,7 @@ class LoanSchedule extends CommonObject * @param int $loanid Id object * @return int <0 if KO, >0 if OK */ - function fetchall($loanid) + function fetchAll($loanid) { global $langs; @@ -409,7 +409,7 @@ class LoanSchedule extends CommonObject $sql.= " FROM ".MAIN_DB_PREFIX.$this->table_element." as t"; $sql.= " WHERE t.fk_loan = ".$loanid; - dol_syslog(get_class($this)."::fetchall", LOG_DEBUG); + dol_syslog(get_class($this)."::fetchAll", LOG_DEBUG); $resql=$this->db->query($sql); if ($resql) diff --git a/htdocs/loan/createschedule.php b/htdocs/loan/createschedule.php index 70688461ae9..0ecc0038835 100644 --- a/htdocs/loan/createschedule.php +++ b/htdocs/loan/createschedule.php @@ -22,14 +22,11 @@ */ require '../main.inc.php'; - require_once DOL_DOCUMENT_ROOT.'/loan/class/loan.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/loan.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT.'/loan/class/loanschedule.class.php'; -global $user; - $loanid = GETPOST('loanid', 'int'); $action = GETPOST('action','aZ09'); @@ -92,7 +89,7 @@ if ($action == 'updateecheancier') { } $echeance = new LoanSchedule($db); -$echeance->fetchall($object->id); +$echeance->fetchAll($object->id); top_htmlhead('', ''); $var = ! $var; @@ -107,6 +104,7 @@ $(document).ready(function() { var idcap=echeance-1; idcap = '#hi_capital'+idcap; var capital=$(idcap).val(); + console.log("Change montly amount echeance="+echeance+" idcap="+idcap+" capital="+capital); $.ajax({ dataType: 'json', url: 'calcmens.php', @@ -135,50 +133,59 @@ $(document).ready(function() { print ''; print ''; print ''; -if(count($echeance->lines)>0){ +if(count($echeance->lines)>0) +{ print ''; }else{ print ''; } print ''; print ''; -print '"; +print ''; print ''; print ''; -Print ''; -Print ''; -Print ''; -Print ''; -Print ''; -print ''; +Print ''; +Print ''; +Print ''; +Print ''; +Print ''; +print ''."\n"; if ($object->nbterm > 0 && count($echeance->lines)==0) { $i=1; $capital = $object->capital; - while($i <$object->nbterm+1){ - $mens = round($echeance->calc_mens($capital, $object->rate/100, $object->nbterm-$i+1),2,PHP_ROUND_HALF_UP); + while($i <$object->nbterm+1) + { + $mens = price2num($echeance->calc_mens($capital, $object->rate/100, $object->nbterm-$i+1), 'MT'); $int = ($capital*($object->rate/12))/100; - $int = round($int,2,PHP_ROUND_HALF_UP); - $cap_rest = round($capital - ($mens-$int),2,PHP_ROUND_HALF_UP); + $int = price2num($int, 'MT'); + $cap_rest = price2num($capital - ($mens-$int), 'MT'); print ''; print ''; print ''; print ''; print ''; print ''; - print ''; + print ''."\n"; $i++; $capital = $cap_rest; } -}elseif(count($echeance->lines)>0){ +} +elseif(count($echeance->lines)>0) +{ $i=1; $capital = $object->capital; foreach ($echeance->lines as $line){ $mens = $line->amount_capital+$line->amount_insurance+$line->amount_interest; $int = $line->amount_interest; - $cap_rest = round($capital - ($mens-$int),2,PHP_ROUND_HALF_UP); + $cap_rest = price2num($capital - ($mens-$int), 'MT'); print ''; print ''; print ''; @@ -189,7 +196,7 @@ if ($object->nbterm > 0 && count($echeance->lines)==0) } print ''; print ''; - print ''; + print ''."\n"; $i++; $capital = $cap_rest; } diff --git a/htdocs/modulebuilder/index.php b/htdocs/modulebuilder/index.php index dbc69c943dd..51ca2b9debb 100644 --- a/htdocs/modulebuilder/index.php +++ b/htdocs/modulebuilder/index.php @@ -181,6 +181,61 @@ if ($dirins && $action == 'addlanguage' && !empty($module)) $result = dolCopyDir($srcfile, $destfile, 0, 0); } +if ($dirins && $action == 'initobject' && $module && GETPOST('createtablearray','alpha')) +{ + $tablename = GETPOST('initfromtablename','alpha'); + $_results = $db->DDLDescTable($tablename); + if (empty($_results)) + { + setEventMessages($langs->trans("ErrorTableNotFound", $tablename), null, 'errors'); + } + else + { + /*public $fields=array( + 'rowid' =>array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'index'=>1, 'position'=>1, 'comment'=>'Id'), + 'ref' =>array('type'=>'varchar(128)', 'label'=>'Ref', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'showoncombobox'=>1, 'index'=>1, 'position'=>10, 'searchall'=>1, 'comment'=>'Reference of object'), + 'entity' =>array('type'=>'integer', 'label'=>'Entity', 'enabled'=>1, 'visible'=>0, 'default'=>1, 'notnull'=>1, 'index'=>1, 'position'=>20), + 'label' =>array('type'=>'varchar(255)', 'label'=>'Label', 'enabled'=>1, 'visible'=>1, 'position'=>30, 'searchall'=>1, 'css'=>'minwidth200', 'help'=>'Help text'), + 'amount' =>array('type'=>'double(24,8)', 'label'=>'Amount', 'enabled'=>1, 'visible'=>1, 'default'=>'null', 'position'=>40, 'searchall'=>0, 'isameasure'=>1, 'help'=>'Help text'), + 'fk_soc' =>array('type'=>'integer:Societe:societe/class/societe.class.php', 'label'=>'ThirdParty', 'visible'=>1, 'enabled'=>1, 'position'=>50, 'notnull'=>-1, 'index'=>1, 'searchall'=>1, 'help'=>'LinkToThirparty'), + 'description' =>array('type'=>'text', 'label'=>'Descrption', 'enabled'=>1, 'visible'=>0, 'position'=>60), + 'note_public' =>array('type'=>'html', 'label'=>'NotePublic', 'enabled'=>1, 'visible'=>0, 'position'=>61), + 'note_private' =>array('type'=>'html', 'label'=>'NotePrivate', 'enabled'=>1, 'visible'=>0, 'position'=>62), + 'date_creation' =>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'=>0, 'position'=>1000), + 'status' =>array('type'=>'integer', 'label'=>'Status', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'default'=>0, 'index'=>1, 'position'=>1000, 'arrayofkeyval'=>array(0=>'Draft', 1=>'Active', -1=>'Cancel')), + );*/ + + $string = 'public $fields=array('."\n"; + $string.="
"; + $i=10; + while ($obj = $db->fetch_object($_results)) + { + $fieldname = $obj->Field; + $type = $obj->Type; + if ($type == 'int(11)') $type='integer'; + $notnull = ($obj->Null == 'YES'?0:1); + $label = preg_replace('/_/', ' ', ucfirst($fieldname)); + if ($fieldname == 'rowid') $label='ID'; + + $string.= "'".$obj->Field."' =>array('type'=>'".$type."', 'label'=>'".$label."', 'enabled'=>1, 'visible'=>-2"; + if ($notnull) $string.= ", 'notnull'=>".$notnull; + $string.= ", 'position'=>".$i."),\n"; + $string.="
"; + $i+=5; + } + $string.= ');'."\n"; + $string.="
"; + print $string; + exit; + } +} + if ($dirins && $action == 'initobject' && $module && $objectname) { if (preg_match('/[^a-z0-9_]/i', $objectname)) @@ -490,7 +545,7 @@ if ($dirins && $action == 'addproperty' && !empty($module) && ! empty($tabobj)) setEventMessages($langs->trans('FilesForObjectUpdated', $objectname), null); clearstatcache(true); - + // Make a redirect to reload all data header("Location: ".DOL_URL_ROOT.'/modulebuilder/index.php?tab=objects&module='.$module.'&tabobj='.$objectname.'&nocache='.time()); @@ -525,7 +580,7 @@ if ($dirins && $action == 'confirm_deleteproperty' && $propertykey) setEventMessages($langs->trans('FilesForObjectUpdated', $objectname), null); clearstatcache(true); - + // Make a redirect to reload all data header("Location: ".DOL_URL_ROOT.'/modulebuilder/index.php?tab=objects&module='.$module.'&tabobj='.$objectname); @@ -1413,7 +1468,20 @@ elseif (! empty($module)) print $langs->trans("EnterNameOfObjectDesc").'

'; print ''; - print ''; + print ''; + print '
'; + print '
'; + print '
'; + print $langs->trans("Or"); + print '
'; + print '
'; + print '
'; + //print ' '; + print $langs->trans("InitStructureFromExistingTable"); + print ''; + print ''; + print '
'; + print ''; } elseif ($tabobj == 'deleteobject') @@ -1549,7 +1617,7 @@ elseif (! empty($module)) print '


'; if(function_exists('opcache_invalidate')) opcache_invalidate($dirread.'/'.$pathtoclass,true); // remove the include cache hell ! - + if (empty($forceddirread)) { $result = dol_include_once($pathtoclass); diff --git a/htdocs/modulebuilder/template/class/myobject.class.php b/htdocs/modulebuilder/template/class/myobject.class.php index e40b6b178e6..267a869fb46 100644 --- a/htdocs/modulebuilder/template/class/myobject.class.php +++ b/htdocs/modulebuilder/template/class/myobject.class.php @@ -142,12 +142,21 @@ class MyObject extends CommonObject */ public function __construct(DoliDB $db) { - global $conf; + global $conf, $user; $this->db = $db; - if (empty($conf->global->MAIN_SHOW_TECHNICAL_ID)) $this->fields['rowid']['visible']=0; - if (empty($conf->multicompany->enabled)) $this->fields['entity']['enabled']=0; + if (empty($conf->global->MAIN_SHOW_TECHNICAL_ID) && isset($this->fields['rowid'])) $this->fields['rowid']['visible']=0; + if (empty($conf->multicompany->enabled) && isset($this->fields['entity'])) $this->fields['entity']['enabled']=0; + + // Unset fields that are disabled + foreach($this->fields as $key => $val) + { + if (isset($val['enabled']) && empty($val['enabled'])) + { + unset($this->fields[$key]); + } + } } /** diff --git a/htdocs/modulebuilder/template/myobject_list.php b/htdocs/modulebuilder/template/myobject_list.php index 2ef8fa97030..2ac18cb5db4 100644 --- a/htdocs/modulebuilder/template/myobject_list.php +++ b/htdocs/modulebuilder/template/myobject_list.php @@ -220,6 +220,7 @@ if ($object->ismultientitymanaged == 1) $sql.= " WHERE t.entity IN (".getEntity( else $sql.=" WHERE 1 = 1"; foreach($search as $key => $val) { + if ($key == 'status' && $search[$key] == -1) continue; $mode_search=(($object->isInt($object->fields[$key]) || $object->isFloat($object->fields[$key]))?1:0); if ($search[$key] != '') $sql.=natural_search($key, $search[$key], (($key == 'status')?2:$mode_search)); } diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index 8b6cc95368e..633d85e854b 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -1716,7 +1716,7 @@ class Product extends CommonObject $price_ttc = price2num($price_ttc,'MU'); if ( $newminprice !== '' || $newminprice === 0) - { + { $price_min = price2num($newminprice,'MU'); $price_min_ttc = price2num($newminprice) * (1 + ($newvat / 100)); $price_min_ttc = price2num($price_min_ttc,'MU'); @@ -2279,8 +2279,8 @@ class Product extends CommonObject } } } - - // If stock decrease is on invoice validation, the theorical stock continue to + + // If stock decrease is on invoice validation, the theorical stock continue to // count the orders to ship in theorical stock when some are already removed b invoice validation. // If option DECREASE_ONLY_UNINVOICEDPRODUCTS is on, we make a compensation. if (! empty($conf->global->STOCK_CALCULATE_ON_BILL)) @@ -4285,7 +4285,7 @@ class Product extends CommonObject if ($user->rights->produit->creer || $user->rights->service->creer) { // Link to resize - $return.= ''.img_picto($langs->trans("Resize"),DOL_URL_ROOT.'/theme/common/transform-crop-and-resize','',1).'   '; + $return.= ''.img_picto($langs->trans("Resize"), 'resize', '').'   '; // Link to delete $return.= ''; @@ -4311,7 +4311,7 @@ class Product extends CommonObject if ($user->rights->produit->creer || $user->rights->service->creer) { // Link to resize - $return.= ''.img_picto($langs->trans("Resize"),DOL_URL_ROOT.'/theme/common/transform-crop-and-resize','',1).'   '; + $return.= ''.img_picto($langs->trans("Resize"), 'resize', '').'   '; // Link to delete $return.= ''; diff --git a/htdocs/product/stock/replenish.php b/htdocs/product/stock/replenish.php index e51747fd78c..5a61e8b2a98 100644 --- a/htdocs/product/stock/replenish.php +++ b/htdocs/product/stock/replenish.php @@ -158,6 +158,8 @@ if ($action == 'order' && isset($_POST['valid'])) $line->total_ttc = $line->total_ht + $line->total_tva; $line->remise_percent = $obj->remise_percent; $line->ref_fourn = $obj->ref_fourn; + $line->type = $product->type; + $line->fk_unit = $product->fk_unit; $suppliers[$obj->fk_soc]['lines'][] = $line; } } @@ -202,7 +204,13 @@ if ($action == 'order' && isset($_POST['valid'])) $line->remise_percent, 'HT', 0, - $line->info_bits + $line->type, + 0, + false, + null, + null, + 0, + $line->fk_unit ); } if ($result < 0) { diff --git a/htdocs/projet/admin/project.php b/htdocs/projet/admin/project.php index 1eddf00eb46..b1cf4d9773b 100644 --- a/htdocs/projet/admin/project.php +++ b/htdocs/projet/admin/project.php @@ -1,11 +1,11 @@ * Copyright (C) 2011-2016 Laurent Destailleur - * Copyright (C) 2011-2012 Juanjo Menent + * Copyright (C) 2011-2015 Juanjo Menent * Copyright (C) 2011-2015 Philippe Grand * Copyright (C) 2013 Florian Henry - * Copyright (C) 2015 Juanjo Menent * Copyright (C) 2015 Marcos García + * Copyright (C) 2018 Ferran Marcet * * 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 @@ -59,7 +59,7 @@ if ($action == 'setmainoptions') else dolibarr_del_const($db, "PROJECT_USE_OPPORTUNITIES", $conf->entity); // Warning, the constant saved and used in code is PROJECT_HIDE_TASKS - if (GETPOST('PROJECT_USE_TASKS')) dolibarr_del_const($db, "PROJECT_USE_TASKS", $conf->entity); + if (GETPOST('PROJECT_USE_TASKS')) dolibarr_del_const($db, "PROJECT_HIDE_TASKS", $conf->entity); else dolibarr_set_const($db, "PROJECT_HIDE_TASKS",1,'chaine',0,'',$conf->entity); } diff --git a/htdocs/projet/element.php b/htdocs/projet/element.php index 2b753a50468..8b791b7a9c7 100644 --- a/htdocs/projet/element.php +++ b/htdocs/projet/element.php @@ -1137,9 +1137,12 @@ foreach ($listofreferent as $key => $value) print ''; print ''; } - else // error + else { - print $elementarray; + if (! is_array($elementarray)) // error + { + print $elementarray; + } } print "
' . "Création d'échéancier'; +print $langs->trans("FinancialCommitment"); +print '
Echéance Date Montant Intérêts Capital restant du
'.$langs->trans("DueDate").''.$langs->trans("Date").''.$langs->trans("Amount").''.$langs->trans("InterestAmount").''.$langs->trans("Remain"); +print ' ('.price2num($object->capital).')'; +print ''; +print '
' . $i .'' . dol_print_date(dol_time_plus_duree($object->datestart, $i-1, 'm'),'day') . ''.price($int,0,'',1).' €'.price($cap_rest).' €
' . $i .'' . dol_print_date($line->datep,'day') . ''.price($int,0,'',1).' €'.price($cap_rest).' €
 
"; print "
\n"; diff --git a/htdocs/public/payment/newpayment.php b/htdocs/public/payment/newpayment.php index f7ceb201da5..7230170e1aa 100644 --- a/htdocs/public/payment/newpayment.php +++ b/htdocs/public/payment/newpayment.php @@ -542,7 +542,7 @@ if (! empty($conf->paypal->enabled) && (! empty($conf->global->PAYPAL_API_SANDBO { dol_htmloutput_mesg($langs->trans('YouAreCurrentlyInSandboxMode','Paypal'),'','warning'); } -if (! empty($conf->stripe->enabled) && (empty($conf->global->STRIPE_LIVE) || empty($conf->global->STRIPECONNECT_LIVE) || GETPOST('forcesandbox','alpha'))) +if (! empty($conf->stripe->enabled) && (empty($conf->global->STRIPE_LIVE) || GETPOST('forcesandbox','alpha'))) { dol_htmloutput_mesg($langs->trans('YouAreCurrentlyInSandboxMode','Stripe'),'','warning'); } @@ -1384,7 +1384,7 @@ if (preg_match('/^dopayment/',$action)) /* print '