diff --git a/ChangeLog b/ChangeLog index b870df3e802..bbd12d6325c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -28,6 +28,7 @@ Following changes may create regressions for some external modules, but were nec * Files for variables of themes were renamed from graph-color.php into theme_vars.inc.php to match naming convention of extension .inc.php for files to be included. * All methods set_draft() were renamed into setDraft(). +* Signatures of methods createFromClone() has been standardized. All methods requires the object User as first parameter. * Removed deprecated function function test_sql_and_script_inject that was replaced with testSqlAndScriptInject. * Method load_measuring_units were renamed into selectMeasuringUnits and select_measuring_units was deprecated. * Hidden option CHANGE_ORDER_CONCAT_DESCRIPTION were renamed into MAIN_CHANGE_ORDER_CONCAT_DESCRIPTION. diff --git a/htdocs/accountancy/admin/account.php b/htdocs/accountancy/admin/account.php index 089c156eb04..9d4f4b68370 100644 --- a/htdocs/accountancy/admin/account.php +++ b/htdocs/accountancy/admin/account.php @@ -258,7 +258,7 @@ if ($resql) print ''; - - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - - $form = new Form($db); - $formaccounting = new FormAccounting($db); - - while ( $i < min($num_lines, $limit) ) { - $objp = $db->fetch_object($result); - print ''; - - print ''; - - print ''; - - // Colonne choix du compte - print ''; - - print ''; - - print ''; - - // Colonne choix ligne a ventiler - $checked = ('label' == 'O') ? ' checked' : ''; - - print ''; - - print ''; - $i ++; - } - - print ''; - - print '
' . $langs->trans("AccountAccouting") . '' . $langs->trans("label") . '' . $langs->trans("Accountparent") . '' . $langs->trans("Pcgtype") . '' . $langs->trans("Pcgsubtype") . '' . $langs->trans("Import") . '
'; - print $objp->accounting; - print ''; - print ''; - print ''; - print $formaccounting->select_account($accounting->account_parent, 'AccountParent'); - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print '
 
'; - print ''; -} else { - print $db->error(); -} - -// End of page -llxFooter(); -$db->close(); diff --git a/htdocs/accountancy/admin/productaccount.php b/htdocs/accountancy/admin/productaccount.php index 37ec3c4e503..537eddfceb4 100644 --- a/htdocs/accountancy/admin/productaccount.php +++ b/htdocs/accountancy/admin/productaccount.php @@ -279,7 +279,8 @@ if ($result) if ($search_desc > 0) $param.="&search_desc=".urlencode($search_desc); if ($search_current_account > 0) $param.="&search_current_account=".urlencode($search_current_account); if ($search_current_account_valid && $search_current_account_valid != '-1') $param.="&search_current_account_valid=".urlencode($search_current_account_valid); - + if ($accounting_product_mode) $param.='&accounting_product_mode='.urlencode($accounting_product_mode); + print '
'; if ($optioncss != '') print ''; print ''; @@ -317,8 +318,11 @@ if ($result) $varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage; $selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields + $buttonsave = ''; + //print '
'.$buttonsave.'
'; + $texte=$langs->trans("ListOfProductsServices"); - print_barre_liste($texte, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, '', 0, '', '', $limit); + print_barre_liste($texte, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $buttonsave, $num, $nbtotalofrecords, '', 0, '', '', $limit); print '
'; print ''; @@ -473,8 +477,8 @@ if ($result) if (atleastoneselected) jQuery("#changeaccount").removeAttr(\'disabled\'); else jQuery("#changeaccount").attr(\'disabled\',\'disabled\'); - if (atleastoneselected) jQuery("#changeaccount").attr(\'class\',\'butAction\'); - else jQuery("#changeaccount").attr(\'class\',\'butActionRefused\'); + if (atleastoneselected) jQuery("#changeaccount").attr(\'class\',\'button\'); + else jQuery("#changeaccount").attr(\'class\',\'button\'); } jQuery(".checkforselect, #checkallactions").click(function() { init_savebutton(); @@ -492,9 +496,6 @@ if ($result) }); '; - - print '
'; - print ''; $db->free($result); diff --git a/htdocs/accountancy/class/accountingaccount.class.php b/htdocs/accountancy/class/accountingaccount.class.php index f214a3f3570..33f8990bc8d 100644 --- a/htdocs/accountancy/class/accountingaccount.class.php +++ b/htdocs/accountancy/class/accountingaccount.class.php @@ -233,16 +233,8 @@ class AccountingAccount extends CommonObject $this->pcg_subtype = trim($this->pcg_subtype); if (isset($this->account_number)) $this->account_number = trim($this->account_number); - if (isset($this->account_parent)) - $this->account_parent = trim($this->account_parent); if (isset($this->label)) $this->label = trim($this->label); - if (isset($this->account_category)) - $this->account_category = trim($this->account_category); - if (isset($this->fk_user_author)) - $this->fk_user_author = trim($this->fk_user_author); - if (isset($this->active)) - $this->active = trim($this->active); if (empty($this->pcg_type) || $this->pcg_type == '-1') { diff --git a/htdocs/accountancy/class/bookkeeping.class.php b/htdocs/accountancy/class/bookkeeping.class.php index 03552557f86..3c985d325bc 100644 --- a/htdocs/accountancy/class/bookkeeping.class.php +++ b/htdocs/accountancy/class/bookkeeping.class.php @@ -1409,16 +1409,14 @@ class BookKeeping extends CommonObject /** * Load an object from its id and create a new one in database * - * @param int $fromid Id of object to clone - * - * @return int New id of clone + * @param User $user User making the clone + * @param int $fromid Id of object to clone + * @return int New id of clone */ - public function createFromClone($fromid) + public function createFromClone(User $user, $fromid) { dol_syslog(__METHOD__, LOG_DEBUG); - global $user; - $error = 0; $object = new BookKeeping($this->db); diff --git a/htdocs/accountancy/customer/list.php b/htdocs/accountancy/customer/list.php index c21388a529a..4b3906d60da 100644 --- a/htdocs/accountancy/customer/list.php +++ b/htdocs/accountancy/customer/list.php @@ -421,6 +421,8 @@ if ($result) { $facture_static = new Facture($db); $product_static = new Product($db); + $isSellerInEEC = isInEEC($mysoc); + while ( $i < min($num_lines, $limit) ) { $objp = $db->fetch_object($result); @@ -440,7 +442,7 @@ if ($result) { $code_sell_p_notset = ''; $objp->aarowid_suggest = $objp->aarowid; - $isinEEC = isInEEC($objp->country_code); + $isBuyerInEEC = isInEEC($objp); if ($objp->type_l == 1) { $objp->code_sell_l = (! empty($conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT : ''); @@ -455,15 +457,17 @@ if ($result) { } if ($objp->code_sell_l == -1) $objp->code_sell_l=''; - if ($objp->country_sell == '1') { + if ($objp->country_code == $mysoc->country_code || empty($objp->country_code)) { // If buyer in same country than seller (if not defined, we assume it is same country) $objp->code_sell_p = $objp->code_sell; $objp->aarowid_suggest = $objp->aarowid; - } elseif ($isinEEC === true) { - $objp->code_sell_p = $objp->code_sell_intra; - $objp->aarowid_suggest = $objp->aarowid_intra; } else { - $objp->code_sell_p = $objp->code_sell_export; - $objp->aarowid_suggest = $objp->aarowid_export; + if ($isSellerInEEC && $isBuyerInEEC) { // European intravat sale + $objp->code_sell_p = $objp->code_sell_intra; + $objp->aarowid_suggest = $objp->aarowid_intra; + } else { // Foreign sale + $objp->code_sell_p = $objp->code_sell_export; + $objp->aarowid_suggest = $objp->aarowid_export; + } } if (! empty($objp->code_sell)) { diff --git a/htdocs/adherents/class/adherent_type.class.php b/htdocs/adherents/class/adherent_type.class.php index b87e6aa527e..c310bb18627 100644 --- a/htdocs/adherents/class/adherent_type.class.php +++ b/htdocs/adherents/class/adherent_type.class.php @@ -1,8 +1,9 @@ +/* Copyright (C) 2002 Rodolphe Quiedeville * Copyright (C) 2004-2008 Laurent Destailleur * Copyright (C) 2009-2017 Regis Houssin * Copyright (C) 2016 Charlie Benke + * Copyright (C) 2018-2019 Thibault Foucart * * 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 @@ -64,6 +65,11 @@ class AdherentType extends CommonObject * @var string Adherent type label */ public $label; + + /** + * @var string Adherent type nature + */ + public $morphy; /** * @var int Subsription required (0 or 1) @@ -184,6 +190,7 @@ class AdherentType extends CommonObject $sql.= "SET "; $sql.= "statut = ".$this->statut.","; $sql.= "libelle = '".$this->db->escape($this->label) ."',"; + $sql.= "morphy = '".$this->db->escape($this->morphy) ."',"; $sql.= "subscription = '".$this->db->escape($this->subscription)."',"; $sql.= "note = '".$this->db->escape($this->note)."',"; $sql.= "vote = ".(integer) $this->db->escape($this->vote).","; @@ -274,7 +281,7 @@ class AdherentType extends CommonObject */ public function fetch($rowid) { - $sql = "SELECT d.rowid, d.libelle as label, d.statut, d.subscription, d.mail_valid, d.note, d.vote"; + $sql = "SELECT d.rowid, d.libelle as label, d.morphy, d.statut, d.subscription, d.mail_valid, d.note, d.vote"; $sql .= " FROM ".MAIN_DB_PREFIX."adherent_type as d"; $sql .= " WHERE d.rowid = ".(int) $rowid; @@ -290,6 +297,7 @@ class AdherentType extends CommonObject $this->id = $obj->rowid; $this->ref = $obj->rowid; $this->label = $obj->label; + $this->morphy = $obj->morphy; $this->statut = $obj->statut; $this->subscription = $obj->subscription; $this->mail_valid = $obj->mail_valid; @@ -402,6 +410,21 @@ class AdherentType extends CommonObject return -1; } } + + /** + * Return translated label by the nature of a adherent (physical or moral) + * + * @param string $morphy Nature of the adherent (physical or moral) + * @return string Label + */ + public function getmorphylib($morphy = '') + { + global $langs; + if ($morphy == 'phy') { return $langs->trans("Physical"); } + elseif ($morphy == 'mor') { return $langs->trans("Moral"); } + else return $langs->trans("Physical & Morale"); + //return $morphy; + } /** * Return clicable name (with picto eventually) diff --git a/htdocs/adherents/subscription.php b/htdocs/adherents/subscription.php index 39466e8ae8a..b28a8b31f2c 100644 --- a/htdocs/adherents/subscription.php +++ b/htdocs/adherents/subscription.php @@ -5,6 +5,7 @@ * Copyright (C) 2012-2017 Regis Houssin * Copyright (C) 2015-2016 Alexandre Spangaro * Copyright (C) 2018 Frédéric France + * Copyright (C) 2019 Thibault FOUCART * * 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 @@ -668,7 +669,7 @@ if ($rowid > 0) { $sql = "SELECT d.rowid, d.firstname, d.lastname, d.societe,"; $sql.= " c.rowid as crowid, c.subscription,"; - $sql.= " c.datec,"; + $sql.= " c.datec, c.fk_type as cfk_type,"; $sql.= " c.dateadh as dateh,"; $sql.= " c.datef,"; $sql.= " c.fk_bank,"; @@ -693,6 +694,7 @@ if ($rowid > 0) print ''; print_liste_field_titre('Ref', $_SERVER["PHP_SELF"], 'c.rowid', '', $param, '', $sortfield, $sortorder); print ''; + print ''; print ''; print ''; print ''; @@ -703,6 +705,7 @@ if ($rowid > 0) print "\n"; $accountstatic=new Account($db); + $adht = new AdherentType($db); while ($i < $num) { @@ -711,9 +714,20 @@ if ($rowid > 0) $subscriptionstatic->ref=$objp->crowid; $subscriptionstatic->id=$objp->crowid; + if ($objp->cfk_type > 0) + { + $adht->fetch($objp->cfk_type); + } + print ''; print ''; print '\n"; + print ''; print '\n"; print '\n"; print ''; diff --git a/htdocs/adherents/type.php b/htdocs/adherents/type.php index 72ea99ff18d..089d817ac94 100644 --- a/htdocs/adherents/type.php +++ b/htdocs/adherents/type.php @@ -1,10 +1,11 @@ +/* Copyright (C) 2001-2002 Rodolphe Quiedeville * Copyright (C) 2003 Jean-Louis Bergamo * Copyright (C) 2004-2011 Laurent Destailleur * Copyright (C) 2005-2017 Regis Houssin * Copyright (C) 2013 Florian Henry * Copyright (C) 2015 Alexandre Spangaro + * Copyright (C) 2019 Thibault Foucart * * 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 @@ -57,6 +58,7 @@ if (! $sortorder) { $sortorder="DESC"; } if (! $sortfield) { $sortfield="d.lastname"; } $label=GETPOST("label", "alpha"); +$morphy=GETPOST("morphy", "alpha"); $statut=GETPOST("statut", "int"); $subscription=GETPOST("subscription", "int"); $vote=GETPOST("vote", "int"); @@ -103,6 +105,7 @@ if ($cancel) { if ($action == 'add' && $user->rights->adherent->configurer) { $object->label = trim($label); + $object->morphy = trim($morphy); $object->statut = (int) $statut; $object->subscription = (int) $subscription; $object->note = trim($comment); @@ -157,6 +160,7 @@ if ($action == 'update' && $user->rights->adherent->configurer) $object->oldcopy = clone $object; $object->label = trim($label); + $object->morphy = trim($morphy); $object->statut = (int) $statut; $object->subscription = (int) $subscription; $object->note = trim($comment); @@ -215,7 +219,7 @@ if (! $rowid && $action != 'create' && $action != 'edit') { //dol_fiche_head(''); - $sql = "SELECT d.rowid, d.libelle as label, d.subscription, d.vote, d.statut"; + $sql = "SELECT d.rowid, d.libelle as label, d.subscription, d.vote, d.statut, d.morphy"; $sql.= " FROM ".MAIN_DB_PREFIX."adherent_type as d"; $sql.= " WHERE d.entity IN (".getEntity('member_type').")"; @@ -256,6 +260,7 @@ if (! $rowid && $action != 'create' && $action != 'edit') print ''; print ''; print ''; + print ''; print ''; print ''; print ''; @@ -277,6 +282,11 @@ if (! $rowid && $action != 'create' && $action != 'edit') //'.img_object($langs->trans("ShowType"),'group').' '.$objp->rowid.' print ''; print ''; + print ''; print ''; print ''; print ''; + + // Morphy + $morphys[""] = $langs->trans("Physical & Morale"); + $morphys["phy"] = $langs->trans("Physical"); + $morphys["mor"] = $langs->trans("Morale"); + print '"; print ''; + + // Morphy + print ''; + print ''; print ''; + + // Morphy + $morphys[""] = $langs->trans("Physical & Morale"); + $morphys["phy"] = $langs->trans("Physical"); + $morphys["mor"] = $langs->trans("Morale"); + print '"; print ''; print ''; - print ''; + print ''; // Move up/down print ''; // Delete print ''; print ''; @@ -604,11 +644,14 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea if (empty($reshook)) { - print '' . $langs->trans("Edit") . '' . "\n"; + print ''; - print '' . $langs->trans("CollectNow") . '' . "\n"; + // Clone + print ''; - print '' . $langs->trans('Delete') . '' . "\n"; + print ''; + + print ''; } print '' . "\n"; } diff --git a/htdocs/admin/tools/dolibarr_export.php b/htdocs/admin/tools/dolibarr_export.php index 8d753840ad7..e63aec50dca 100644 --- a/htdocs/admin/tools/dolibarr_export.php +++ b/htdocs/admin/tools/dolibarr_export.php @@ -50,7 +50,7 @@ if (! $user->admin) if ($action == 'delete') { - $file=$conf->admin->dir_output.'/'.GETPOST('urlfile'); + $file=$conf->admin->dir_output.'/backup/'.basename(GETPOST('urlfile', 'alpha')); $ret=dol_delete_file($file, 1); if ($ret) setEventMessages($langs->trans("FileWasRemoved", GETPOST('urlfile')), null, 'mesgs'); else setEventMessages($langs->trans("ErrorFailToDeleteFile", GETPOST('urlfile')), null, 'errors'); diff --git a/htdocs/admin/tools/export.php b/htdocs/admin/tools/export.php index a833b5160b9..acfa29f2c74 100644 --- a/htdocs/admin/tools/export.php +++ b/htdocs/admin/tools/export.php @@ -133,7 +133,8 @@ if ($what == 'mysql') dol_syslog("Command are restricted to ".$dolibarr_main_restrict_os_commands.". We check that one of this command is inside ".$cmddump); foreach($arrayofallowedcommand as $allowedcommand) { - if (preg_match('/'.preg_quote($allowedcommand, '/').'/', $cmddump)) + $basenamecmddump=basename($cmddump); + if (preg_match('/^'.preg_quote($allowedcommand, '/').'$/', $basenamecmddump)) // the provided command $cmddump must be an allowed command { $ok=1; break; diff --git a/htdocs/asset/list.php b/htdocs/asset/list.php index dc2ce9dddf6..029b5334d55 100644 --- a/htdocs/asset/list.php +++ b/htdocs/asset/list.php @@ -295,6 +295,14 @@ if ($user->rights->asset->delete) $arrayofmassactions['predelete']='selectMassAction('', $arrayofmassactions); +$newcardbutton=''; +if ($user->rights->asset->write) +{ + $newcardbutton=''.$langs->trans('NewAsset').''; + $newcardbutton.= ''; + $newcardbutton.= ''; +} + print '
'; if ($optioncss != '') print ''; print ''; @@ -305,7 +313,7 @@ print ''; print ''; print ''; -print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'title_companies', 0, '', '', $limit); +print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'title_companies', 0, $newcardbutton, '', $limit); // Add code for pre mass action (confirmation or email presend form) $topicmail="SendAssetsRef"; diff --git a/htdocs/asset/type.php b/htdocs/asset/type.php index 9f11889185f..303d05b298b 100644 --- a/htdocs/asset/type.php +++ b/htdocs/asset/type.php @@ -220,6 +220,14 @@ if (! $rowid && $action != 'create' && $action != 'edit') $param = ''; + $newcardbutton=''; + if ($user->rights->asset->configurer) + { + $newcardbutton=''.$langs->trans('NewAssetType').''; + $newcardbutton.= ''; + $newcardbutton.= ''; + } + print ''; if ($optioncss != '') print ''; print ''; @@ -229,7 +237,7 @@ if (! $rowid && $action != 'create' && $action != 'edit') print ''; print ''; - print_barre_liste($langs->trans("AssetsTypes"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_generic.png', 0, '', '', $limit); + print_barre_liste($langs->trans("AssetsTypes"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_generic.png', 0, $newcardbutton, '', $limit); $moreforfilter = ''; diff --git a/htdocs/categories/class/api_categories.class.php b/htdocs/categories/class/api_categories.class.php index c975236f930..9b59e1f001b 100644 --- a/htdocs/categories/class/api_categories.class.php +++ b/htdocs/categories/class/api_categories.class.php @@ -15,10 +15,15 @@ * along with this program. If not, see . */ - use Luracast\Restler\RestException; +use Luracast\Restler\RestException; - require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; - require_once DOL_DOCUMENT_ROOT.'/societe/class/client.class.php'; +require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; +require_once DOL_DOCUMENT_ROOT.'/societe/class/client.class.php'; + +require_once DOL_DOCUMENT_ROOT.'/adherents/class/api_members.class.php'; +require_once DOL_DOCUMENT_ROOT.'/product/class/api_products.class.php'; +require_once DOL_DOCUMENT_ROOT.'/societe/class/api_contacts.class.php'; +require_once DOL_DOCUMENT_ROOT.'/societe/class/api_thirdparties.class.php'; /** * API class for categories @@ -335,4 +340,61 @@ class Categories extends DolibarrApi } return $category; } + + /** + * Get the list of objects in a category. + * + * @param int $id ID of category + * @param string $type Type of category ('member', 'customer', 'supplier', 'product', 'contact') + * @param int $onlyids Return only ids of objects (consume less memory) + * + * @return mixed + * + * @url GET {id}/objects + */ + public function getObjects($id, $type, $onlyids = 0) + { + dol_syslog("getObjects($id, $type, $onlyids)", LOG_DEBUG); + + if (! DolibarrApiAccess::$user->rights->categorie->lire) { + throw new RestException(401); + } + + if (empty($type)) + { + throw new RestException(500, 'The "type" parameter is required.'); + } + + $result = $this->category->fetch($id); + if (! $result) { + throw new RestException(404, 'category not found'); + } + + if (! DolibarrApi::_checkAccessToResource('category', $this->category->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } + + $result = $this->category->getObjectsInCateg($type, $onlyids); + + if ($result < 0) { + throw new RestException(503, 'Error when retrieving objects list : '.$this->category->error); + } + + $objects = $result; + $cleaned_objects = array(); + if ($type == 'member') { + $objects_api = new Members(); + } elseif ($type == 'customer' || $type == 'supplier') { + $objects_api = new Thirdparties(); + } elseif ($type == 'product') { + $objects_api = new Products(); + } elseif ($type == 'contact') { + $objects_api = new Contacts(); + } + foreach ($objects as $obj) { + $cleaned_objects[] = $objects_api->_cleanObjectDatas($obj); + } + + return $cleaned_objects; + } } diff --git a/htdocs/comm/action/card.php b/htdocs/comm/action/card.php index 5654b3cb37f..bd3a3aeb360 100644 --- a/htdocs/comm/action/card.php +++ b/htdocs/comm/action/card.php @@ -164,7 +164,7 @@ if ($action == 'confirm_clone' && $confirm == 'yes') reset($object->socpeopleassigned); $object->contactid = key($object->socpeopleassigned); } - $result = $object->createFromClone(GETPOST('fk_userowner'), GETPOST('socid')); + $result = $object->createFromClone($user, GETPOST('fk_userowner'), GETPOST('socid')); if ($result > 0) { header("Location: " . $_SERVER['PHP_SELF'] . '?id=' . $result); exit(); @@ -903,7 +903,7 @@ if ($action == 'create') $numproject=$formproject->select_projects((! empty($societe->id)?$societe->id:-1), $projectid, 'projectid', 0, 0, 1, 1); - print '   '.$langs->trans("AddProject").''; + print '   '.$langs->trans("AddProject").''; $urloption='?action=create'; $url = dol_buildpath('comm/action/card.php', 2).$urloption; @@ -1301,7 +1301,7 @@ if ($id > 0) $numprojet=$formproject->select_projects(($object->socid > 0 ? $object->socid : -1), $object->fk_project, 'projectid', 0, 0, 1, 0, 0, 0, 0, '', 0); if ($numprojet==0) { - print '   '.$langs->trans("AddProject").''; + print '   '.$langs->trans("AddProject").''; } print ''; } diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php index 96aaa17fdd2..b543d6790c6 100644 --- a/htdocs/comm/action/class/actioncomm.class.php +++ b/htdocs/comm/action/class/actioncomm.class.php @@ -87,14 +87,14 @@ class ActionComm extends CommonObject * @var string Agenda event label */ public $label; - + /** * Date creation record (datec) * * @var integer */ public $datec; - + /** * Date modification record (tms) * @@ -129,14 +129,14 @@ class ActionComm extends CommonObject * @var int */ public $usermodid; - + /** * Date action start (datep) * * @var integer */ public $datep; - + /** * Date action end (datep2) * @@ -504,13 +504,13 @@ class ActionComm extends CommonObject /** * Load an object from its id and create a new one in database * - * @param user $fuser Object user making action + * @param User $fuser Object user making action * @param int $socid Id of thirdparty * @return int New id of clone */ - public function createFromClone($fuser, $socid) + public function createFromClone(User $fuser, $socid) { - global $db, $user, $langs, $conf, $hookmanager; + global $db, $conf, $hookmanager; $error=0; $now=dol_now(); @@ -529,20 +529,6 @@ class ActionComm extends CommonObject $this->id=0; - if (!is_object($fuser)) - { - if ($fuser > 0) - { - $u = new User($db); - $u->fetch($fuser); - $fuser = $u; - } - else - { - $fuser = $user; - } - } - // Create clone $this->context['createfromclone']='createfromclone'; $result=$this->create($fuser); diff --git a/htdocs/comm/action/index.php b/htdocs/comm/action/index.php index 84719bc8673..48165361d7c 100644 --- a/htdocs/comm/action/index.php +++ b/htdocs/comm/action/index.php @@ -614,18 +614,9 @@ if ($resql) // Defined date_start_in_calendar and date_end_in_calendar property // They are date start and end of action but modified to not be outside calendar view. - if ($event->percentage <= 0) - { - $event->date_start_in_calendar=$event->datep; - if ($event->datef != '' && $event->datef >= $event->datep) $event->date_end_in_calendar=$event->datef; - else $event->date_end_in_calendar=$event->datep; - } - else - { - $event->date_start_in_calendar=$event->datep; - if ($event->datef != '' && $event->datef >= $event->datep) $event->date_end_in_calendar=$event->datef; - else $event->date_end_in_calendar=$event->datep; - } + $event->date_start_in_calendar=$event->datep; + if ($event->datef != '' && $event->datef >= $event->datep) $event->date_end_in_calendar=$event->datef; + else $event->date_end_in_calendar=$event->datep; // Define ponctual property if ($event->date_start_in_calendar == $event->date_end_in_calendar) { diff --git a/htdocs/comm/mailing/card.php b/htdocs/comm/mailing/card.php index b710ba4656b..34ed7708e9e 100644 --- a/htdocs/comm/mailing/card.php +++ b/htdocs/comm/mailing/card.php @@ -97,7 +97,7 @@ if (empty($reshook)) } else { - $result=$object->createFromClone($object->id, $_REQUEST["clone_content"], $_REQUEST["clone_receivers"]); + $result=$object->createFromClone($user, $object->id, $_REQUEST["clone_content"], $_REQUEST["clone_receivers"]); if ($result > 0) { header("Location: ".$_SERVER['PHP_SELF'].'?id='.$result); diff --git a/htdocs/comm/mailing/class/advtargetemailing.class.php b/htdocs/comm/mailing/class/advtargetemailing.class.php index b450f5a0872..ed04192d0e9 100644 --- a/htdocs/comm/mailing/class/advtargetemailing.class.php +++ b/htdocs/comm/mailing/class/advtargetemailing.class.php @@ -114,22 +114,17 @@ class AdvanceTargetingMailing extends CommonObject $error=0; // Clean parameters - if (isset($this->fk_element)) $this->fk_element=trim($this->fk_element); + if (isset($this->fk_element)) $this->fk_element=(int) $this->fk_element; if (isset($this->type_element)) $this->type_element=trim($this->type_element); if (isset($this->name)) $this->name=trim($this->name); if (isset($this->filtervalue)) $this->filtervalue=trim($this->filtervalue); - if (isset($this->fk_user_author)) $this->fk_user_author=trim($this->fk_user_author); - if (isset($this->fk_user_mod)) $this->fk_user_mod=trim($this->fk_user_mod); - - // Check parameters // Put here code to add control on parameters values // Insert request $sql = "INSERT INTO ".MAIN_DB_PREFIX."advtargetemailing("; - $sql.= "name,"; $sql.= "entity,"; $sql.= "fk_element,"; @@ -138,10 +133,7 @@ class AdvanceTargetingMailing extends CommonObject $sql.= "fk_user_author,"; $sql.= "datec,"; $sql.= "fk_user_mod"; - - $sql.= ") VALUES ("; - $sql.= " ".(! isset($this->name)?'NULL':"'".$this->db->escape($this->name)."'").","; $sql.= " ".$conf->entity.","; $sql.= " ".(! isset($this->fk_element)?'NULL':"'".$this->db->escape($this->fk_element)."'").","; @@ -149,9 +141,7 @@ class AdvanceTargetingMailing extends CommonObject $sql.= " ".(! isset($this->filtervalue)?'NULL':"'".$this->db->escape($this->filtervalue)."'").","; $sql.= " ".$user->id.","; $sql.= " '".$this->db->idate(dol_now())."',"; - $sql.= " ".$user->id; - - + $sql.= " null"; $sql.= ")"; $this->db->begin(); @@ -396,14 +386,10 @@ class AdvanceTargetingMailing extends CommonObject $error=0; // Clean parameters - if (isset($this->fk_element)) $this->fk_element=trim($this->fk_element); + if (isset($this->fk_element)) $this->fk_element=(int) $this->fk_element; if (isset($this->type_element)) $this->type_element=trim($this->type_element); if (isset($this->name)) $this->name=trim($this->name); if (isset($this->filtervalue)) $this->filtervalue=trim($this->filtervalue); - if (isset($this->fk_user_author)) $this->fk_user_author=trim($this->fk_user_author); - if (isset($this->fk_user_mod)) $this->fk_user_mod=trim($this->fk_user_mod); - - // Check parameters // Put here code to add a control on parameters values diff --git a/htdocs/comm/mailing/class/mailing.class.php b/htdocs/comm/mailing/class/mailing.class.php index 0fd41c9dc02..d82ec07612d 100644 --- a/htdocs/comm/mailing/class/mailing.class.php +++ b/htdocs/comm/mailing/class/mailing.class.php @@ -266,14 +266,15 @@ class Mailing extends CommonObject /** * Load an object from its id and create a new one in database * + * @param User $user User making the clone * @param int $fromid Id of object to clone * @param int $option1 1=Copy content, 0=Forget content * @param int $option2 Not used * @return int New id of clone */ - public function createFromClone($fromid, $option1, $option2) + public function createFromClone(User $user, $fromid, $option1, $option2) { - global $user,$langs; + global $langs; $error=0; diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php index 264905776cd..abed072bc2c 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -192,7 +192,7 @@ if (empty($reshook)) } } - $result = $object->createFromClone($socid); + $result = $object->createFromClone($user, $socid); if ($result > 0) { header("Location: " . $_SERVER['PHP_SELF'] . '?id=' . $result); exit(); @@ -839,6 +839,7 @@ if (empty($reshook)) $qty = GETPOST('qty' . $predef); $remise_percent = GETPOST('remise_percent' . $predef); + if (empty($remise_percent)) $remise_percent=0; // Extrafields $extrafieldsline = new ExtraFields($db); diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index 388433222e0..0b9863f287b 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -473,7 +473,7 @@ class Propal extends CommonObject // Check parameters if ($type < 0) return -1; - + if ($date_start && $date_end && $date_start > $date_end) { $langs->load("errors"); $this->error=$langs->trans('ErrorStartDateGreaterEnd'); @@ -690,7 +690,7 @@ class Propal extends CommonObject if (empty($qty) && empty($special_code)) $special_code=3; // Set option tag if (! empty($qty) && $special_code == 3) $special_code=0; // Remove option tag if (empty($type)) $type=0; - + if ($date_start && $date_end && $date_start > $date_end) { $langs->load("errors"); $this->error=$langs->trans('ErrorStartDateGreaterEnd'); @@ -1226,12 +1226,13 @@ class Propal extends CommonObject /** * Load an object from its id and create a new one in database * - * @param int $socid Id of thirdparty - * @return int New id of clone + * @param User $user User making the clone + * @param int $socid Id of thirdparty + * @return int New id of clone */ - public function createFromClone($socid = 0) + public function createFromClone(User $user, $socid = 0) { - global $user,$conf,$hookmanager; + global $conf,$hookmanager; dol_include_once('/projet/class/project.class.php'); diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index 9e48fd2303a..05d02c487c0 100755 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -142,7 +142,7 @@ if (empty($reshook)) // Because createFromClone modifies the object, we must clone it so that we can restore it later $orig = clone $object; - $result=$object->createFromClone($socid); + $result=$object->createFromClone($user, $socid); if ($result > 0) { header("Location: ".$_SERVER['PHP_SELF'].'?id='.$result); diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index 5506d8a4770..35cb8335232 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -1070,10 +1070,11 @@ class Commande extends CommonOrder /** * Load an object from its id and create a new one in database * - * @param int $socid Id of thirdparty - * @return int New id of clone + * @param User $user User making the clone + * @param int $socid Id of thirdparty + * @return int New id of clone */ - public function createFromClone($socid = 0) + public function createFromClone(User $user, $socid = 0) { global $conf, $user,$hookmanager; diff --git a/htdocs/compta/bank/class/bankcateg.class.php b/htdocs/compta/bank/class/bankcateg.class.php index dc9c1d242e8..cb74bf54ca8 100644 --- a/htdocs/compta/bank/class/bankcateg.class.php +++ b/htdocs/compta/bank/class/bankcateg.class.php @@ -269,13 +269,12 @@ class BankCateg // extends CommonObject /** * Load an object from its id and create a new one in database * - * @param int $fromid Id of object to clone - * @return int New id of clone + * @param User $user User making the clone + * @param int $fromid Id of object to clone + * @return int New id of clone */ - public function createFromClone($fromid) + public function createFromClone(User $user, $fromid) { - global $user; - $error = 0; $object = new BankCateg($this->db); diff --git a/htdocs/compta/bank/various_payment/document.php b/htdocs/compta/bank/various_payment/document.php index 36e8546a897..02c3b331544 100644 --- a/htdocs/compta/bank/various_payment/document.php +++ b/htdocs/compta/bank/various_payment/document.php @@ -57,7 +57,7 @@ if (! $sortfield) $sortfield="name"; $object = new PaymentVarious($db); $object->fetch($id, $ref); -$upload_dir = $conf->banque->dir_output.'/'.dol_sanitizeFileName($object->id); +$upload_dir = $conf->bank->dir_output.'/'.dol_sanitizeFileName($object->id); $modulepart='banque'; diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index c0da8f364fc..cf27f54a82b 100755 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -1543,14 +1543,16 @@ if (empty($reshook)) $datefacture = dol_mktime(12, 0, 0, $_POST['remonth'], $_POST['reday'], $_POST['reyear']); if (empty($datefacture)) { $error++; - $mesg = '
' . $langs->trans("ErrorFieldRequired", $langs->trans("Date")) . '
'; + $mesg = $langs->trans("ErrorFieldRequired", $langs->trans("Date")); + setEventMessages($mesg, null, 'errors'); } $date_pointoftax = dol_mktime(12, 0, 0, $_POST['date_pointoftaxmonth'], $_POST['date_pointoftaxday'], $_POST['date_pointoftaxyear']); if (!($_POST['situations'] > 0)) { $error++; - $mesg = '
' . $langs->trans("ErrorFieldRequired", $langs->trans("InvoiceSituation")) . '
'; + $mesg = $langs->trans("ErrorFieldRequired", $langs->trans("InvoiceSituation")); + setEventMessages($mesg, null, 'errors'); } if (!$error) { @@ -2192,11 +2194,13 @@ $result = $object->updateline(GETPOST('lineid'), $description, $pu_ht, $qty, GET if (!$object->fetch($id) > 0) dol_print_error($db); if (!is_null(GETPOST('all_progress')) && GETPOST('all_progress') != "") { + $all_progress = GETPOST('all_progress', 'int'); foreach ($object->lines as $line) { $percent = $line->get_prev_progress($object->id); - if (GETPOST('all_progress') < $percent) { - $mesg = '
' . $langs->trans("CantBeLessThanMinPercent") . '
'; + if (floatval($all_progress) < floatval($percent)) { + $mesg = $langs->trans("Line") . ' ' . $i . ' '. $line->ref .' : ' . $langs->trans("CantBeLessThanMinPercent"); + setEventMessages($mesg, null, 'warnings'); $result = -1; } else $object->update_percent($line, $_POST['all_progress']); @@ -4453,7 +4457,9 @@ elseif ($id > 0 || ! empty($ref)) // Show global modifiers if (! empty($conf->global->INVOICE_USE_SITUATION)) { - if ($object->situation_cycle_ref && $object->statut == 0) { + if ($object->situation_cycle_ref && $object->statut == 0) + { + print ''."\n"; print '
'; print ''; @@ -4469,38 +4475,19 @@ elseif ($id > 0 || ! empty($ref)) if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER)) { print '
'; } - print ''; - print ''; - print ''; - if ($inputalsopricewithtax) print ''; - print ''; - print ''; - print ''; - if (! empty($conf->margin->enabled) && empty($user->societe_id)) - { - print ''; - if ((! empty($conf->global->DISPLAY_MARGIN_RATES) || ! empty($conf->global->DISPLAY_MARK_RATES)) && $usercanreadallmargin) { - print ''; - } - } - print ''; + print ''; + print ''; print ''; - print ''; - print ''; print "\n"; + print ''; // Adds a line numbering column if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER)) { - print ''; + print ''; } - print ''; print ''; - print ''; - print ''; - print ''; - print ''; print ''; - print ''; + print ''; print ''; print '
'.$langs->trans("DateCreation").''.$langs->trans("Type").''.$langs->trans("DateStart").''.$langs->trans("DateEnd").''.$langs->trans("Amount").'
'.$subscriptionstatic->getNomUrl(1).''.dol_print_date($db->jdate($objp->datec), 'dayhour')."'; + if ($objp->cfk_type > 0) + { + print $adht->getNomUrl(1); + } + print ''.dol_print_date($db->jdate($objp->dateh), 'day')."'.dol_print_date($db->jdate($objp->datef), 'day')."'.price($objp->subscription).'
'.$langs->trans("Ref").''.$langs->trans("Label").''.$langs->trans("Nature").''.$langs->trans("SubscriptionRequired").''.$langs->trans("VoteAllowed").''.$langs->trans("Status").''.dol_escape_htmltag($objp->label).''; + if ($objp->morphy == 'phy') { print $langs->trans("Physical"); } + elseif ($objp->morphy == 'mor') { print $langs->trans("Moral"); } + else print $langs->trans("Physical & Morale"); + print ''.yn($objp->subscription).''.yn($objp->vote).''; @@ -330,6 +340,14 @@ if ($action == 'create') print '
'.$langs->trans("Status").''; print $form->selectarray('statut', array('0'=>$langs->trans('ActivityCeased'),'1'=>$langs->trans('InActivity')), 1); print '
'.$langs->trans("Nature").''; + print $form->selectarray("morphy", $morphys, isset($_POST["morphy"])?$_POST["morphy"]:$object->morphy); + print "
'.$langs->trans("SubscriptionRequired").''; print $form->selectyesno("subscription", 1, 1); @@ -411,6 +429,10 @@ if ($rowid > 0) print img_picto($langs->trans('TypeStatusInactive'), 'statut5').' '.$langs->trans("ActivityCeased"); } print '
'.$langs->trans("Nature").''.$object->getmorphylib($object->morphy).'
'.$langs->trans("SubscriptionRequired").''; print yn($object->subscription); @@ -751,6 +773,14 @@ if ($rowid > 0) print '
'.$langs->trans("Status").''; print $form->selectarray('statut', array('0'=>$langs->trans('ActivityCeased'),'1'=>$langs->trans('InActivity')), $object->statut); print '
'.$langs->trans("Nature").''; + print $form->selectarray("morphy", $morphys, isset($_POST["morphy"])?$_POST["morphy"]:$object->morphy); + print "
'.$langs->trans("SubscriptionRequired").''; print $form->selectyesno("subscription", $object->subscription, 1); diff --git a/htdocs/admin/emailcollector_card.php b/htdocs/admin/emailcollector_card.php index f05bf937169..e71299b65e3 100644 --- a/htdocs/admin/emailcollector_card.php +++ b/htdocs/admin/emailcollector_card.php @@ -48,6 +48,8 @@ $cancel = GETPOST('cancel', 'aZ09'); $contextpage= GETPOST('contextpage', 'aZ')?GETPOST('contextpage', 'aZ'):'myobjectcard'; // To manage different context of search $backtopage = GETPOST('backtopage', 'alpha'); +$operationid = GETPOST('operationid', 'int'); + // Initialize technical objects $object = new EmailCollector($db); $extrafields = new ExtraFields($db); @@ -64,6 +66,7 @@ foreach ($object->fields as $key => $val) { if (GETPOST('search_'.$key, 'alpha')) $search[$key]=GETPOST('search_'.$key, 'alpha'); } +if (GETPOST('saveoperation2')) $action = 'updateoperation'; if (empty($action) && empty($id) && empty($ref)) $action='view'; // Load object @@ -165,6 +168,24 @@ if (GETPOST('addoperation', 'alpha')) } } +if ($action == 'updateoperation') +{ + $emailcollectoroperation = new EmailCollectorAction($db); + $emailcollectoroperation->fetch(GETPOST('rowidoperation2', 'int')); + + $emailcollectoroperation->actionparam = GETPOST('operationparam2', 'none'); + + $result = $emailcollectoroperation->update($user); + + if ($result > 0) + { + $object->fetchActions(); + } + else + { + setEventMessages($emailcollectoroperation->errors, $emailcollectoroperation->error, 'errors'); + } +} if ($action == 'deleteoperation') { $emailcollectoroperation = new EmailCollectorAction($db); @@ -452,19 +473,25 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print '
'; $arrayoftypes=array( - 'from'=>array('label'=>'MailFrom', 'data-placeholder'=>'SearchString'), - 'to'=>array('label'=>'MailTo', 'data-placeholder'=>'SearchString'), - 'cc'=>array('label'=>'Cc', 'data-placeholder'=>'SearchString'), - 'bcc'=>array('label'=>'Bcc', 'data-placeholder'=>'SearchString'), - 'subject'=>array('label'=>'Subject', 'data-placeholder'=>'SearchString'), - 'body'=>array('label'=>'Body', 'data-placeholder'=>'SearchString'), - 'header'=>array('label'=>'Header', 'data-placeholder'=>'HeaderKey SearchString'), // HEADER key value - 'X1'=>'---', + 'from'=>array('label'=>'MailFrom', 'data-placeholder'=>$langs->trans('SearchString')), + 'to'=>array('label'=>'MailTo', 'data-placeholder'=>$langs->trans('SearchString')), + 'cc'=>array('label'=>'Cc', 'data-placeholder'=>$langs->trans('SearchString')), + 'bcc'=>array('label'=>'Bcc', 'data-placeholder'=>$langs->trans('SearchString')), + 'subject'=>array('label'=>'Subject', 'data-placeholder'=>$langs->trans('SearchString')), + 'body'=>array('label'=>'Body', 'data-placeholder'=>$langs->trans('SearchString')), + // disabled because PHP imap_search is not compatible IMAPv4, only IMAPv2 + //'header'=>array('label'=>'Header', 'data-placeholder'=>'HeaderKey SearchString'), // HEADER key value + //'X1'=>'---', + //'notinsubject'=>array('label'=>'SubjectNotIn', 'data-placeholder'=>'SearchString'), + //'notinbody'=>array('label'=>'BodyNotIn', 'data-placeholder'=>'SearchString'), + 'X2'=>'---', 'seen'=>array('label'=>'AlreadyRead', 'data-noparam'=>1), 'unseen'=>array('label'=>'NotRead', 'data-noparam'=>1), - 'smaller'=>array('label'=>'SmallerThan', 'data-placeholder'=>'NumberOfBytes'), - 'larger'=>array('label'=>'LargerThan', 'data-placeholder'=>'NumberOfBytes'), - 'X2'=>'---', + 'unanswered'=>array('label'=>'Unanswered', 'data-noparam'=>1), + 'answered'=>array('label'=>'Answered', 'data-noparam'=>1), + 'smaller'=>array('label'=>'SmallerThan', 'data-placeholder'=>$langs->trans('NumberOfBytes')), + 'larger'=>array('label'=>'LargerThan', 'data-placeholder'=>$langs->trans('NumberOfBytes')), + 'X3'=>'---', 'withtrackingid'=>array('label'=>'WithDolTrackingID', 'data-noparam'=>1), 'withouttrackingid'=>array('label'=>'WithoutDolTrackingID', 'data-noparam'=>1) ); @@ -530,7 +557,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea 'recordevent'=>'RecordEvent'); if ($conf->projet->enabled) $arrayoftypes['project']='CreateLeadAndThirdParty'; if ($conf->ticket->enabled) $arrayoftypes['ticket']='CreateTicketAndThirdParty'; - print $form->selectarray('operationtype', $arrayoftypes, '', 1, 0, 0, '', 1); + print $form->selectarray('operationtype', $arrayoftypes, '', 1, 0, 0, '', 1, 0, 0, '', 'maxwidth300'); print ''; print ''; $htmltext=$langs->transnoentitiesnoconv("OperationParamDesc"); @@ -558,7 +585,18 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print $form->textwithpicto('', $langs->transnoentitiesnoconv('IfTrackingIDFoundEventWillBeLinked')); } print ''.$ruleaction['actionparam'].''; + if ($action == 'editoperation' && $ruleaction['id'] == $operationid) + { + print '
'; + print '
'; + print ' '; + } + else + { + print $ruleaction['actionparam']; + } + print '
'; if ($i > 0) @@ -571,6 +609,8 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print ''; + print ' '.img_edit().''; + print '   '; print ' '.img_delete().''; print '
 ' . $langs->trans('ModifyAllLines') . '     ' . $langs->trans('Progress') . '   ' . $langs->trans('ModifyAllLines') . '' . $langs->trans('Progress') . '   
  
     %
'; diff --git a/htdocs/compta/facture/class/paymentterm.class.php b/htdocs/compta/facture/class/paymentterm.class.php index 707b6586b83..d3b4bd83743 100644 --- a/htdocs/compta/facture/class/paymentterm.class.php +++ b/htdocs/compta/facture/class/paymentterm.class.php @@ -393,13 +393,12 @@ class PaymentTerm // extends CommonObject /** * Load an object from its id and create a new one in database * + * @param User $user User making the clone * @param int $fromid Id of object to clone * @return int New id of clone */ - public function createFromClone($fromid) + public function createFromClone(User $user, $fromid) { - global $user,$langs; - $error=0; $object=new PaymentTerm($this->db); diff --git a/htdocs/compta/localtax/class/localtax.class.php b/htdocs/compta/localtax/class/localtax.class.php index b0178bd09e1..247db26715a 100644 --- a/htdocs/compta/localtax/class/localtax.class.php +++ b/htdocs/compta/localtax/class/localtax.class.php @@ -97,9 +97,6 @@ class Localtax extends CommonObject $this->amount=trim($this->amount); $this->label=trim($this->label); $this->note=trim($this->note); - $this->fk_bank=trim($this->fk_bank); - $this->fk_user_creat=trim($this->fk_user_creat); - $this->fk_user_modif=trim($this->fk_user_modif); // Insert request $sql = "INSERT INTO ".MAIN_DB_PREFIX."localtax("; @@ -121,9 +118,9 @@ class Localtax extends CommonObject $sql.= " '".$this->db->escape($this->amount)."',"; $sql.= " '".$this->db->escape($this->label)."',"; $sql.= " '".$this->db->escape($this->note)."',"; - $sql.= " ".($this->fk_bank <= 0 ? "NULL" : "'".$this->db->escape($this->fk_bank)."'").","; - $sql.= " '".$this->db->escape($this->fk_user_creat)."',"; - $sql.= " '".$this->db->escape($this->fk_user_modif)."'"; + $sql.= " ".($this->fk_bank <= 0 ? "NULL" : (int) $this->fk_bank).","; + $sql.= " ".((int) $this->fk_user_creat).","; + $sql.= " ".((int) $this->fk_user_modif); $sql.= ")"; dol_syslog(get_class($this)."::create", LOG_DEBUG); @@ -173,9 +170,6 @@ class Localtax extends CommonObject $this->amount=trim($this->amount); $this->label=trim($this->label); $this->note=trim($this->note); - $this->fk_bank=trim($this->fk_bank); - $this->fk_user_creat=trim($this->fk_user_creat); - $this->fk_user_modif=trim($this->fk_user_modif); $this->db->begin(); @@ -188,9 +182,9 @@ class Localtax extends CommonObject $sql.= " amount=".price2num($this->amount).","; $sql.= " label='".$this->db->escape($this->label)."',"; $sql.= " note='".$this->db->escape($this->note)."',"; - $sql.= " fk_bank=".$this->fk_bank.","; - $sql.= " fk_user_creat=".$this->fk_user_creat.","; - $sql.= " fk_user_modif=".$this->fk_user_modif; + $sql.= " fk_bank=".(int) $this->fk_bank.","; + $sql.= " fk_user_creat=".(int) $this->fk_user_creat.","; + $sql.= " fk_user_modif=".(int) $this->fk_user_modif; $sql.= " WHERE rowid=".$this->id; dol_syslog(get_class($this)."::update", LOG_DEBUG); @@ -299,7 +293,6 @@ class Localtax extends CommonObject if ($result < 0) return -1; // End call triggers - $sql = "DELETE FROM ".MAIN_DB_PREFIX."localtax"; $sql.= " WHERE rowid=".$this->id; @@ -324,6 +317,8 @@ class Localtax extends CommonObject */ public function initAsSpecimen() { + global $user; + $this->id=0; $this->tms=''; @@ -333,9 +328,9 @@ class Localtax extends CommonObject $this->amount=''; $this->label=''; $this->note=''; - $this->fk_bank=''; - $this->fk_user_creat=''; - $this->fk_user_modif=''; + $this->fk_bank=0; + $this->fk_user_creat=$user->id; + $this->fk_user_modif=$user->id; } @@ -347,7 +342,6 @@ class Localtax extends CommonObject */ public function solde($year = 0) { - $reglee = $this->localtax_sum_reglee($year); $payee = $this->localtax_sum_payee($year); @@ -528,7 +522,7 @@ class Localtax extends CommonObject $sql.= "'".$this->db->idate($this->datev)."'," . $this->amount; if ($this->note) $sql.=", '".$this->db->escape($this->note)."'"; if ($this->label) $sql.=", '".$this->db->escape($this->label)."'"; - $sql.=", '".$user->id."', NULL"; + $sql.=", ".((int) $user->id).", NULL"; $sql.= ")"; dol_syslog(get_class($this)."::addPayment", LOG_DEBUG); diff --git a/htdocs/compta/salaries/class/paymentsalary.class.php b/htdocs/compta/salaries/class/paymentsalary.class.php index 40cec40ecad..1d0bad641fc 100644 --- a/htdocs/compta/salaries/class/paymentsalary.class.php +++ b/htdocs/compta/salaries/class/paymentsalary.class.php @@ -115,13 +115,9 @@ class PaymentSalary extends CommonObject $error=0; // Clean parameters - $this->fk_user=trim($this->fk_user); $this->amount=trim($this->amount); $this->label=trim($this->label); $this->note=trim($this->note); - $this->fk_bank=trim($this->fk_bank); - $this->fk_user_author=trim($this->fk_user_author); - $this->fk_user_modif=trim($this->fk_user_modif); // Check parameters if (empty($this->fk_user) || $this->fk_user < 0) @@ -140,16 +136,16 @@ class PaymentSalary extends CommonObject $sql.= " datep='".$this->db->idate($this->datep)."',"; $sql.= " datev='".$this->db->idate($this->datev)."',"; $sql.= " amount=".price2num($this->amount).","; - $sql.= " fk_projet='".$this->db->escape($this->fk_project)."',"; + $sql.= " fk_projet=".((int) $this->fk_project).","; $sql.= " fk_typepayment=".$this->fk_typepayment."',"; $sql.= " num_payment='".$this->db->escape($this->num_payment)."',"; $sql.= " label='".$this->db->escape($this->label)."',"; $sql.= " datesp='".$this->db->idate($this->datesp)."',"; $sql.= " dateep='".$this->db->idate($this->dateep)."',"; $sql.= " note='".$this->db->escape($this->note)."',"; - $sql.= " fk_bank=".($this->fk_bank > 0 ? "'".$this->db->escape($this->fk_bank)."'":"null").","; - $sql.= " fk_user_author=".$this->fk_user_author.","; - $sql.= " fk_user_modif=".$this->fk_user_modif; + $sql.= " fk_bank=".($this->fk_bank > 0 ? (int) $this->fk_bank : "null").","; + $sql.= " fk_user_author=".((int) $this->fk_user_author).","; + $sql.= " fk_user_modif=".($this->fk_user_modif > 0 ? (int) $this->fk_user_modif : 'null'); $sql.= " WHERE rowid=".$this->id; diff --git a/htdocs/compta/sociales/class/cchargesociales.class.php b/htdocs/compta/sociales/class/cchargesociales.class.php index 1cb304fe519..3c2efbd6141 100644 --- a/htdocs/compta/sociales/class/cchargesociales.class.php +++ b/htdocs/compta/sociales/class/cchargesociales.class.php @@ -346,15 +346,14 @@ class Cchargesociales /** * Load an object from its id and create a new one in database * - * @param int $fromid Id of object to clone - * - * @return int New id of clone + * @param User $user User making the clone + * @param int $fromid Id of object to clone + * @return int New id of clone */ - public function createFromClone($fromid) + public function createFromClone(User $user, $fromid) { dol_syslog(__METHOD__, LOG_DEBUG); - global $user; $error = 0; $object = new Cchargesociales($this->db); diff --git a/htdocs/compta/sociales/class/paymentsocialcontribution.class.php b/htdocs/compta/sociales/class/paymentsocialcontribution.class.php index a2a6009cd6a..86dda559061 100644 --- a/htdocs/compta/sociales/class/paymentsocialcontribution.class.php +++ b/htdocs/compta/sociales/class/paymentsocialcontribution.class.php @@ -448,13 +448,12 @@ class PaymentSocialContribution extends CommonObject /** * Load an object from its id and create a new one in database * + * @param User $user User making the clone * @param int $fromid Id of object to clone * @return int New id of clone */ - public function createFromClone($fromid) + public function createFromClone(User $user, $fromid) { - global $user,$langs; - $error=0; $object=new PaymentSocialContribution($this->db); diff --git a/htdocs/compta/stats/cabyprodserv.php b/htdocs/compta/stats/cabyprodserv.php index cb8a3cc451d..27cf35c1379 100644 --- a/htdocs/compta/stats/cabyprodserv.php +++ b/htdocs/compta/stats/cabyprodserv.php @@ -51,6 +51,7 @@ if (! $sortfield) $sortfield="ref"; // Category $selected_cat = (int) GETPOST('search_categ', 'int'); +$selected_soc = (int) GETPOST('search_soc', 'int'); $subcat = false; if (GETPOST('subcat', 'alpha') === 'yes') { $subcat = true; @@ -137,6 +138,7 @@ $headerparams['q'] = $q; $tableparams = array(); $tableparams['search_categ'] = $selected_cat; +$tableparams['search_soc'] = $selected_soc; $tableparams['search_type'] = $selected_type; $tableparams['subcat'] = ($subcat === true)?'yes':''; @@ -225,7 +227,9 @@ if ($modecompta == 'CREANCES-DETTES') $sql = "SELECT DISTINCT p.rowid as rowid, p.ref as ref, p.label as label, p.fk_product_type as product_type,"; $sql.= " SUM(l.total_ht) as amount, SUM(l.total_ttc) as amount_ttc,"; $sql.= " SUM(CASE WHEN f.type = 2 THEN -l.qty ELSE l.qty END) as qty"; - $sql.= " FROM ".MAIN_DB_PREFIX."facture as f, ".MAIN_DB_PREFIX."facturedet as l"; + $sql.= " FROM ".MAIN_DB_PREFIX."facture as f"; + if($selected_soc > 0) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as soc ON (soc.rowid = f.fk_soc)"; + $sql.= ",".MAIN_DB_PREFIX."facturedet as l"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON l.fk_product = p.rowid"; if ($selected_cat === -2) // Without any category { @@ -259,6 +263,7 @@ if ($modecompta == 'CREANCES-DETTES') $sql.= ")"; $sql.= " AND cp.fk_categorie = c.rowid AND cp.fk_product = p.rowid"; } + if($selected_soc > 0) $sql .= " AND soc.rowid=".$selected_soc; $sql.= " AND f.entity IN (".getEntity('invoice').")"; $sql.= " GROUP BY p.rowid, p.ref, p.label, p.fk_product_type"; $sql.= $db->order($sortfield, $sortorder); @@ -313,6 +318,10 @@ if ($modecompta == 'CREANCES-DETTES') print ' '; print $langs->trans("Type"). ': '; $form->select_type_of_lines(isset($selected_type)?$selected_type:-1, 'search_type', 1, 1, 1); + + //select thirdparty + print '
'; + print $langs->trans("ThirdParty") . ': ' . $form->select_thirdparty_list($selected_soc, 'search_soc', '', 1); print ''; print ''; diff --git a/htdocs/contact/list.php b/htdocs/contact/list.php index c8014e900b9..246fd172dc7 100644 --- a/htdocs/contact/list.php +++ b/htdocs/contact/list.php @@ -146,6 +146,8 @@ $fieldstosearchall = array( 'p.email'=>'EMail', 's.nom'=>"ThirdParty", 'p.phone'=>"Phone", + 'p.note_public'=>"NotePublic", + 'p.note_private'=>"NotePrivate", ); // Definition of fields for list diff --git a/htdocs/contrat/card.php b/htdocs/contrat/card.php index 443cf984f79..687dc2c7f2f 100644 --- a/htdocs/contrat/card.php +++ b/htdocs/contrat/card.php @@ -1072,7 +1072,7 @@ if (empty($reshook)) else { if ($object->id > 0) { - $result = $object->createFromClone($socid); + $result = $object->createFromClone($user, $socid); if ($result > 0) { header("Location: " . $_SERVER['PHP_SELF'] . '?id=' . $result); exit(); diff --git a/htdocs/contrat/class/contrat.class.php b/htdocs/contrat/class/contrat.class.php index 2cd4f472f95..87830593714 100644 --- a/htdocs/contrat/class/contrat.class.php +++ b/htdocs/contrat/class/contrat.class.php @@ -2388,13 +2388,14 @@ class Contrat extends CommonObject /** * Load an object from its id and create a new one in database * - * @param int $socid Id of thirdparty - * @param int $notrigger 1=Does not execute triggers, 0= execute triggers - * @return int New id of clone + * @param User $user User making the clone + * @param int $socid Id of thirdparty + * @param int $notrigger 1=Does not execute triggers, 0= execute triggers + * @return int New id of clone */ - public function createFromClone($socid = 0, $notrigger = 0) + public function createFromClone(User $user, $socid = 0, $notrigger = 0) { - global $db, $user, $langs, $conf, $hookmanager, $extrafields; + global $db, $langs, $conf, $hookmanager, $extrafields; dol_include_once('/projet/class/project.class.php'); diff --git a/htdocs/core/actions_addupdatedelete.inc.php b/htdocs/core/actions_addupdatedelete.inc.php index 5c5e7752b49..3bd33c94c15 100644 --- a/htdocs/core/actions_addupdatedelete.inc.php +++ b/htdocs/core/actions_addupdatedelete.inc.php @@ -195,23 +195,6 @@ if ($action == 'confirm_delete' && ! empty($permissiontodelete)) } } -// Action clone object -if ($action == 'confirm_clone' && $confirm == 'yes' && $permissiontoadd) -{ - $objectutil = dol_clone($object); // To avoid to denaturate loaded object when setting some properties for clone - //$objectutil->date = dol_mktime(12, 0, 0, GETPOST('newdatemonth', 'int'), GETPOST('newdateday', 'int'), GETPOST('newdateyear', 'int')); - - $result = $objectutil->createFromClone($id); - if ($result > 0) { - header("Location: " . $_SERVER['PHP_SELF'] . '?facid=' . $result); - exit(); - } else { - $langs->load("errors"); - setEventMessages($objectutil->error, $objectutil->errors, 'errors'); - $action = ''; - } -} - // Action clone object if ($action == 'confirm_clone' && $confirm == 'yes' && $permissiontoadd) { diff --git a/htdocs/core/actions_massactions.inc.php b/htdocs/core/actions_massactions.inc.php index 55dda5a5934..973dae1bbee 100644 --- a/htdocs/core/actions_massactions.inc.php +++ b/htdocs/core/actions_massactions.inc.php @@ -345,6 +345,7 @@ if (! $error && $massaction == 'confirm_presend') if ($objectclass == 'Supplier_Proposal') $sendtobcc .= (empty($conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_PROPOSAL_TO) ? '' : (($sendtobcc?", ":"").$conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_PROPOSAL_TO)); if ($objectclass == 'CommandeFournisseur') $sendtobcc .= (empty($conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_ORDER_TO) ? '' : (($sendtobcc?", ":"").$conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_ORDER_TO)); if ($objectclass == 'FactureFournisseur') $sendtobcc .= (empty($conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_INVOICE_TO) ? '' : (($sendtobcc?", ":"").$conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_INVOICE_TO)); + if ($objectclass == 'Project') $sendtobcc .= (empty($conf->global->MAIN_MAIL_AUTOCOPY_PROJECT_TO) ? '' : (($sendtobcc?", ":"").$conf->global->MAIN_MAIL_AUTOCOPY_PROJECT_TO)); // $listofqualifiedobj is array with key = object id and value is instance of qualified objects, for the current thirdparty (but thirdparty property is not loaded yet) // $looparray will be an array with number of email to send for the current thirdparty (so 1 or n if n object for same thirdparty) diff --git a/htdocs/core/ajax/ajaxdirpreview.php b/htdocs/core/ajax/ajaxdirpreview.php index 4490d7bff3c..538b398296d 100644 --- a/htdocs/core/ajax/ajaxdirpreview.php +++ b/htdocs/core/ajax/ajaxdirpreview.php @@ -179,7 +179,7 @@ if ($type == 'directory') $sorting = (strtolower($sortorder)=='desc'?SORT_DESC:SORT_ASC); // Right area. If module is defined here, we are in automatic ecm. - $automodules = array('company', 'invoice', 'invoice_supplier', 'propal', 'supplier_proposal', 'order', 'order_supplier', 'contract', 'product', 'tax', 'project', 'fichinter', 'user', 'expensereport', 'holiday'); + $automodules = array('company', 'invoice', 'invoice_supplier', 'propal', 'supplier_proposal', 'order', 'order_supplier', 'contract', 'product', 'tax', 'project', 'fichinter', 'user', 'expensereport', 'holiday', 'banque'); // TODO change for multicompany sharing // Auto area for suppliers invoices @@ -212,12 +212,14 @@ if ($type == 'directory') elseif ($module == 'expensereport') $upload_dir = $conf->expensereport->dir_output; // Auto area for holiday elseif ($module == 'holiday') $upload_dir = $conf->holiday->dir_output; + // Auto area for holiday + elseif ($module == 'banque') $upload_dir = $conf->bank->dir_output; // Automatic list if (in_array($module, $automodules)) { $param.='&module='.$module; - if (isset($search_doc_ref) && $search_doc_ref != '') $param.='&search_doc_ref='.$search_doc_ref; + if (isset($search_doc_ref) && $search_doc_ref != '') $param.='&search_doc_ref='.urlencode($search_doc_ref); $textifempty=($section?$langs->trans("NoFileFound"):($showonrightsize=='featurenotyetavailable'?$langs->trans("FeatureNotYetAvailable"):$langs->trans("NoFileFound"))); @@ -335,8 +337,8 @@ if ($useajax || $action == 'delete') $formquestion['section_id']=array('type'=>'hidden','value'=>$section_id,'name'=>'section_id'); // We must always put field, even if empty because it is fille by javascript later $formquestion['section_dir']=array('type'=>'hidden','value'=>$section_dir,'name'=>'section_dir'); // We must always put field, even if empty because it is fille by javascript later if (! empty($action) && $action == 'file_manager') $formquestion['file_manager']=array('type'=>'hidden','value'=>1,'name'=>'file_manager'); - if (! empty($websitekey)) $formquestion['website']=array('type'=>'hidden','value'=>$websitekey,'name'=>'website'); - if (! empty($pageid) && $pageid > 0) $formquestion['pageid']=array('type'=>'hidden','value'=>$pageid,'name'=>'pageid'); + if (! empty($websitekey)) $formquestion['website'] =array('type'=>'hidden','value'=>$websitekey,'name'=>'website'); + if (! empty($pageid) && $pageid > 0) $formquestion['pageid'] =array('type'=>'hidden','value'=>$pageid,'name'=>'pageid'); print $form->formconfirm($url, $langs->trans("DeleteFile"), $langs->trans("ConfirmDeleteFile"), 'confirm_deletefile', $formquestion, "no", ($useajax?'deletefile':0)); } diff --git a/htdocs/core/class/antivir.class.php b/htdocs/core/class/antivir.class.php index 55bd3a8381d..4be4d175b47 100644 --- a/htdocs/core/class/antivir.class.php +++ b/htdocs/core/class/antivir.class.php @@ -94,6 +94,8 @@ class AntiVir // Run CLI command. If run of Windows, you can get return with echo %ERRORLEVEL% $lastline=exec($fullcommand, $output, $return_var); + if (is_null($output)) $output=array(); + //print "x".$lastline." - ".join(',',$output)." - ".$return_var."y";exit; /* diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 60bfd1e5305..454936d2998 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -3963,8 +3963,10 @@ abstract class CommonObject // Reduction short print ''.$langs->trans('ReductionShort').''; + // Fields for situation invoice if ($this->situation_cycle_ref) { print '' . $langs->trans('Progress') . ''; + print '' . $langs->trans('TotalHT100Short') . ''; } if ($usemargins && ! empty($conf->margin->enabled) && empty($user->societe_id)) diff --git a/htdocs/core/class/ctyperesource.class.php b/htdocs/core/class/ctyperesource.class.php index a4eed8f8b66..0571af1d5fa 100644 --- a/htdocs/core/class/ctyperesource.class.php +++ b/htdocs/core/class/ctyperesource.class.php @@ -404,15 +404,14 @@ class Ctyperesource /** * Load an object from its id and create a new one in database * - * @param int $fromid Id of object to clone - * - * @return int New id of clone + * @param User $user User making the clone + * @param int $fromid Id of object to clone + * @return int New id of clone */ - public function createFromClone($fromid) + public function createFromClone(User $user, $fromid) { dol_syslog(__METHOD__, LOG_DEBUG); - global $user; $error = 0; $object = new Ctyperesource($this->db); diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php index 865aa50b679..26acdf50fcc 100644 --- a/htdocs/core/class/extrafields.class.php +++ b/htdocs/core/class/extrafields.class.php @@ -1837,7 +1837,7 @@ class ExtraFields $out=''; // Only if something to display (perf) - if ($value) // If we have -1 here, pb is into sert, not into ouptu + if ($value) // If we have -1 here, pb is into insert, not into ouptut (fix insert instead of changing code here to compensate) { $param_list=array_keys($param['options']); // $param_list='ObjectName:classPath' diff --git a/htdocs/core/class/fiscalyear.class.php b/htdocs/core/class/fiscalyear.class.php index 5c6a5b4cf4d..5593b4a90a4 100644 --- a/htdocs/core/class/fiscalyear.class.php +++ b/htdocs/core/class/fiscalyear.class.php @@ -195,7 +195,6 @@ class Fiscalyear extends CommonObject $sql .= ", date_start = '".$this->db->idate($this->date_start)."'"; $sql .= ", date_end = ".($this->date_end ? "'".$this->db->idate($this->date_end)."'" : "null"); $sql .= ", statut = '".$this->db->escape($this->statut?$this->statut:0)."'"; - $sql .= ", datec = " . ($this->datec != '' ? "'".$this->db->idate($this->datec)."'" : 'null'); $sql .= ", fk_user_modif = " . $user->id; $sql .= " WHERE rowid = ".$this->id; diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index ea8663cab31..93cbdb138a0 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -237,9 +237,9 @@ class Form } elseif (preg_match('/^ckeditor/', $typeofdata)) { - $tmp=explode(':', $typeofdata); // Example: ckeditor:dolibarr_zzz:width:height:savemethod:toolbarstartexpanded:rows:cols + $tmp=explode(':', $typeofdata); // Example: ckeditor:dolibarr_zzz:width:height:savemethod:toolbarstartexpanded:rows:cols:uselocalbrowser require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $doleditor=new DolEditor($htmlname, ($editvalue?$editvalue:$value), ($tmp[2]?$tmp[2]:''), ($tmp[3]?$tmp[3]:'100'), ($tmp[1]?$tmp[1]:'dolibarr_notes'), 'In', ($tmp[5]?$tmp[5]:0), true, true, ($tmp[6]?$tmp[6]:'20'), ($tmp[7]?$tmp[7]:'100')); + $doleditor=new DolEditor($htmlname, ($editvalue?$editvalue:$value), ($tmp[2]?$tmp[2]:''), ($tmp[3]?$tmp[3]:'100'), ($tmp[1]?$tmp[1]:'dolibarr_notes'), 'In', ($tmp[5]?$tmp[5]:0), (isset($tmp[8])?($tmp[8]?true:false):true), true, ($tmp[6]?$tmp[6]:'20'), ($tmp[7]?$tmp[7]:'100')); $ret.=$doleditor->Create(1); } if (empty($notabletag)) $ret.=''; @@ -5146,7 +5146,7 @@ class Form * - local date in user area, if set_time is '' (so if set_time is '', output may differs when done from two different location) * - Empty (fields empty), if set_time is -1 (in this case, parameter empty must also have value 1) * - * @param timestamp $set_time Pre-selected date (must be a local PHP server timestamp), -1 to keep date not preselected, '' to use current date with 00:00 hour (Parameter 'empty' must be 0 or 2). + * @param integer $set_time Pre-selected date (must be a local PHP server timestamp), -1 to keep date not preselected, '' to use current date with 00:00 hour (Parameter 'empty' must be 0 or 2). * @param string $prefix Prefix for fields name * @param int $h 1 or 2=Show also hours (2=hours on a new line), -1 has same effect but hour and minutes are prefilled with 23:59 if date is empty, 3 show hour always empty * @param int $m 1=Show also minutes, -1 has same effect but hour and minutes are prefilled with 23:59 if date is empty, 3 show minutes always empty diff --git a/htdocs/core/class/html.formfile.class.php b/htdocs/core/class/html.formfile.class.php index ccf5c9de6b2..d161f32d92a 100644 --- a/htdocs/core/class/html.formfile.class.php +++ b/htdocs/core/class/html.formfile.class.php @@ -1464,7 +1464,7 @@ class FormFile print ''; print ''; // Action column - print ''; + print ''; $searchpicto=$form->showFilterButtons(); print $searchpicto; print ''; @@ -1474,10 +1474,10 @@ class FormFile print ''; $sortref="fullname"; if ($modulepart == 'invoice_supplier') $sortref='level1name'; - print_liste_field_titre("Ref", $url, $sortref, "", $param, 'class="left"', $sortfield, $sortorder); - print_liste_field_titre("Documents2", $url, "name", "", $param, 'class="left"', $sortfield, $sortorder); - print_liste_field_titre("Size", $url, "size", "", $param, 'class="right"', $sortfield, $sortorder); - print_liste_field_titre("Date", $url, "date", "", $param, 'class="center"', $sortfield, $sortorder); + print_liste_field_titre("Ref", $url, $sortref, "", $param, '', $sortfield, $sortorder); + print_liste_field_titre("Documents2", $url, "name", "", $param, '', $sortfield, $sortorder); + print_liste_field_titre("Size", $url, "size", "", $param, '', $sortfield, $sortorder, 'right '); + print_liste_field_titre("Date", $url, "date", "", $param, '', $sortfield, $sortorder, 'center '); print_liste_field_titre('', '', ''); print ''."\n"; @@ -1557,6 +1557,11 @@ class FormFile include_once DOL_DOCUMENT_ROOT.'/holiday/class/holiday.class.php'; $object_instance=new Holiday($this->db); } + elseif ($modulepart == 'banque') + { + include_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; + $object_instance=new Account($this->db); + } foreach($filearray as $key => $file) { @@ -1569,17 +1574,20 @@ class FormFile // Define relative path used to store the file $relativefile=preg_replace('/'.preg_quote($upload_dir.'/', '/').'/', '', $file['fullname']); - //var_dump($file); $id=0; $ref=''; $label=''; // To show ref or specific information according to view to show (defined by $module) if ($modulepart == 'company' || $modulepart == 'tax') { preg_match('/(\d+)\/[^\/]+$/', $relativefile, $reg); $id=(isset($reg[1])?$reg[1]:''); } elseif ($modulepart == 'invoice_supplier') { preg_match('/([^\/]+)\/[^\/]+$/', $relativefile, $reg); $ref=(isset($reg[1])?$reg[1]:''); if (is_numeric($ref)) { $id=$ref; $ref=''; } } // $ref may be also id with old supplier invoices elseif ($modulepart == 'user' || $modulepart == 'holiday') { preg_match('/(.*)\/[^\/]+$/', $relativefile, $reg); $id=(isset($reg[1])?$reg[1]:''); } - elseif (in_array($modulepart, array('invoice', 'propal', 'supplier_proposal', 'order', 'order_supplier', 'contract', 'product', 'project', 'fichinter', 'expensereport'))) + elseif (in_array($modulepart, array('invoice', 'propal', 'supplier_proposal', 'order', 'order_supplier', 'contract', 'product', 'project', 'fichinter', 'expensereport', 'banque'))) { preg_match('/(.*)\/[^\/]+$/', $relativefile, $reg); $ref=(isset($reg[1])?$reg[1]:''); } + else + { + //print 'Error: Value for modulepart = '.$modulepart.' is not yet implemented in function list_of_autoecmfiles'."\n"; + } if (! $id && ! $ref) continue; $found=0; @@ -1597,13 +1605,13 @@ class FormFile //fetchOneLike looks for objects with wildcards in its reference. //It is useful for those masks who get underscores instead of their actual symbols //fetchOneLike requires some info in the object. If it doesn't have it, then 0 is returned - //that's why we look only look fetchOneLike when fetch returns 0 + //that's why we look only into fetchOneLike when fetch returns 0 if (!$result = $object_instance->fetch('', $ref)) { $result = $object_instance->fetchOneLike($ref); } } - if ($result > 0) { // Save object into a cache + if ($result > 0) { // Save object loaded into a cache $found=1; $this->cache_objects[$modulepart.'_'.$id.'_'.$ref] = clone $object_instance; } if ($result == 0) { $found=1; $this->cache_objects[$modulepart.'_'.$id.'_'.$ref]='notfound'; unset($filearray[$key]); } diff --git a/htdocs/core/class/html.formmail.class.php b/htdocs/core/class/html.formmail.class.php index 31eeb08e0a6..22683ab0993 100644 --- a/htdocs/core/class/html.formmail.class.php +++ b/htdocs/core/class/html.formmail.class.php @@ -1037,9 +1037,12 @@ class FormMail extends Form $showinfobcc=''; if (! empty($conf->global->MAIN_MAIL_AUTOCOPY_PROPOSAL_TO) && ! empty($this->param['models']) && $this->param['models'] == 'propal_send') $showinfobcc=$conf->global->MAIN_MAIL_AUTOCOPY_PROPOSAL_TO; - if (! empty($conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_PROPOSAL_TO) && ! empty($this->param['models']) && $this->param['models'] == 'supplier_proposal_send') $showinfobcc=$conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_PROPOSAL_TO; if (! empty($conf->global->MAIN_MAIL_AUTOCOPY_ORDER_TO) && ! empty($this->param['models']) && $this->param['models'] == 'order_send') $showinfobcc=$conf->global->MAIN_MAIL_AUTOCOPY_ORDER_TO; if (! empty($conf->global->MAIN_MAIL_AUTOCOPY_INVOICE_TO) && ! empty($this->param['models']) && $this->param['models'] == 'facture_send') $showinfobcc=$conf->global->MAIN_MAIL_AUTOCOPY_INVOICE_TO; + if (! empty($conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_PROPOSAL_TO) && ! empty($this->param['models']) && $this->param['models'] == 'supplier_proposal_send') $showinfobcc=$conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_PROPOSAL_TO; + if (! empty($conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_ORDER_TO) && ! empty($this->param['models']) && $this->param['models'] == 'order_supplier_send') $showinfobcc=$conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_ORDER_TO; + if (! empty($conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_INVOICE_TO) && ! empty($this->param['models']) && $this->param['models'] == 'invoice_supplier_send') $showinfobcc=$conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_INVOICE_TO; + if (! empty($conf->global->MAIN_MAIL_AUTOCOPY_PROJECT_TO) && ! empty($this->param['models']) && $this->param['models'] == 'project') $showinfobcc=$conf->global->MAIN_MAIL_AUTOCOPY_PROJECT_TO; if ($showinfobcc) $out.=' + '.$showinfobcc; $out.= "\n"; return $out; diff --git a/htdocs/core/class/translate.class.php b/htdocs/core/class/translate.class.php index f8cb32896f2..40c5ef8c048 100644 --- a/htdocs/core/class/translate.class.php +++ b/htdocs/core/class/translate.class.php @@ -466,7 +466,9 @@ class Translate if (! $found && ! empty($conf->global->MAIN_ENABLE_OVERWRITE_TRANSLATION)) { // Overwrite translation with database read - $sql="SELECT transkey, transvalue FROM ".MAIN_DB_PREFIX."overwrite_trans where lang='".$db->escape($this->defaultlang)."'"; + $sql ="SELECT transkey, transvalue FROM ".MAIN_DB_PREFIX."overwrite_trans where lang='".$db->escape($this->defaultlang)."' OR lang IS NULL"; + $sql.=" AND entity IN (0, ".getEntity('overwrite_trans').")"; + $sql.=$db->order("lang", "DESC"); $resql=$db->query($sql); if ($resql) diff --git a/htdocs/core/class/utils.class.php b/htdocs/core/class/utils.class.php index 0c16deab43b..9e0063ac414 100644 --- a/htdocs/core/class/utils.class.php +++ b/htdocs/core/class/utils.class.php @@ -239,36 +239,37 @@ class Utils dol_mkdir($conf->admin->dir_output.'/backup'); // Parameteres execution - $command=$cmddump; - if (preg_match("/\s/", $command)) $command=escapeshellarg($command); // Use quotes on command + $command = $cmddump; + $command = preg_replace('/(\$|%)/', '', $command); // We removed chars that can be used to inject vars that contains space inside path of command without seeing there is a space to bypass the escapeshellarg. + if (preg_match("/\s/", $command)) $command=escapeshellarg($command); // If there is spaces, we add quotes on command to be sure $command is only a program and not a program+parameters //$param=escapeshellarg($dolibarr_main_db_name)." -h ".escapeshellarg($dolibarr_main_db_host)." -u ".escapeshellarg($dolibarr_main_db_user)." -p".escapeshellarg($dolibarr_main_db_pass); $param=$dolibarr_main_db_name." -h ".$dolibarr_main_db_host; $param.=" -u ".$dolibarr_main_db_user; if (! empty($dolibarr_main_db_port)) $param.=" -P ".$dolibarr_main_db_port; - if (! GETPOST("use_transaction")) $param.=" -l --single-transaction"; - if (GETPOST("disable_fk") || $usedefault) $param.=" -K"; - if (GETPOST("sql_compat") && GETPOST("sql_compat") != 'NONE') $param.=" --compatible=".escapeshellarg(GETPOST("sql_compat", "alpha")); - if (GETPOST("drop_database")) $param.=" --add-drop-database"; - if (GETPOST("sql_structure") || $usedefault) + if (! GETPOST("use_transaction", "alpha")) $param.=" -l --single-transaction"; + if (GETPOST("disable_fk", "alpha") || $usedefault) $param.=" -K"; + if (GETPOST("sql_compat", "alpha") && GETPOST("sql_compat", "alpha") != 'NONE') $param.=" --compatible=".escapeshellarg(GETPOST("sql_compat", "alpha")); + if (GETPOST("drop_database", "alpha")) $param.=" --add-drop-database"; + if (GETPOST("sql_structure", "alpha") || $usedefault) { - if (GETPOST("drop") || $usedefault) $param.=" --add-drop-table=TRUE"; - else $param.=" --add-drop-table=FALSE"; + if (GETPOST("drop", "alpha") || $usedefault) $param.=" --add-drop-table=TRUE"; + else $param.=" --add-drop-table=FALSE"; } else { $param.=" -t"; } - if (GETPOST("disable-add-locks")) $param.=" --add-locks=FALSE"; - if (GETPOST("sql_data") || $usedefault) + if (GETPOST("disable-add-locks", "alpha")) $param.=" --add-locks=FALSE"; + if (GETPOST("sql_data", "alpha") || $usedefault) { $param.=" --tables"; - if (GETPOST("showcolumns") || $usedefault) $param.=" -c"; - if (GETPOST("extended_ins") || $usedefault) $param.=" -e"; + if (GETPOST("showcolumns", "alpha") || $usedefault) $param.=" -c"; + if (GETPOST("extended_ins", "alpha") || $usedefault) $param.=" -e"; else $param.=" --skip-extended-insert"; - if (GETPOST("delayed")) $param.=" --delayed-insert"; - if (GETPOST("sql_ignore")) $param.=" --insert-ignore"; - if (GETPOST("hexforbinary") || $usedefault) $param.=" --hex-blob"; + if (GETPOST("delayed", "alpha")) $param.=" --delayed-insert"; + if (GETPOST("sql_ignore", "alpha")) $param.=" --insert-ignore"; + if (GETPOST("hexforbinary", "alpha") || $usedefault) $param.=" --hex-blob"; } else { @@ -436,8 +437,9 @@ class Utils dol_mkdir($conf->admin->dir_output.'/backup'); // Parameteres execution - $command=$cmddump; - if (preg_match("/\s/", $command)) $command=escapeshellarg($command); // Use quotes on command + $command = $cmddump; + $command = preg_replace('/(\$|%)/', '', $command); // We removed chars that can be used to inject vars that contains space inside path of command without seeing there is a space to bypass the escapeshellarg. + if (preg_match("/\s/", $command)) $command=escapeshellarg($command); // If there is spaces, we add quotes on command to be sure $command is only a program and not a program+parameters //$param=escapeshellarg($dolibarr_main_db_name)." -h ".escapeshellarg($dolibarr_main_db_host)." -u ".escapeshellarg($dolibarr_main_db_user)." -p".escapeshellarg($dolibarr_main_db_pass); //$param="-F c"; diff --git a/htdocs/core/js/timesheet.js b/htdocs/core/js/timesheet.js index 3bd93555d76..0a4aa9989ff 100644 --- a/htdocs/core/js/timesheet.js +++ b/htdocs/core/js/timesheet.js @@ -90,24 +90,20 @@ function pad(n) { /* function from http://www.timlabonne.com/2013/07/parsing-a-time-string-with-javascript/ */ +/* timeStr must be a duration with format XX:YY (AM/PM not supported) */ function parseTime(timeStr, dt) { if (!dt) { dt = new Date(); } - var time = timeStr.match(/(\d+)(?::(\d\d))?\s*(p?)/i); + //var time = timeStr.match(/(\d+)(?::(\d\d))?\s*(p?)/i); + var time = timeStr.match(/(\d+)(?::(\d\d))?/i); if (!time) { return -1; } var hours = parseInt(time[1], 10); - if (hours == 12 && !time[3]) { - hours = 0; - } - else { - hours += (hours < 12 && time[3]) ? 12 : 0; - } - + dt.setHours(hours); dt.setMinutes(parseInt(time[2], 10) || 0); dt.setSeconds(0, 0); diff --git a/htdocs/core/lib/accounting.lib.php b/htdocs/core/lib/accounting.lib.php index 0a1a69a758d..889d9da8a2c 100644 --- a/htdocs/core/lib/accounting.lib.php +++ b/htdocs/core/lib/accounting.lib.php @@ -108,7 +108,7 @@ function length_accountg($account) */ function length_accounta($accounta) { - global $conf, $langs; + global $conf; if ($accounta < 0 || empty($accounta)) return ''; @@ -156,12 +156,11 @@ function journalHead($nom, $variante, $period, $periodlink, $description, $build { global $langs; - if (empty($hselected)) $hselected='report'; - print "\n\n\n"; if(! empty($varlink)) $varlink = '?'.$varlink; + $head=array(); $h=0; $head[$h][0] = $_SERVER["PHP_SELF"].$varlink; $head[$h][1] = $langs->trans("Journalization"); @@ -180,10 +179,8 @@ function journalHead($nom, $variante, $period, $periodlink, $description, $build // Ligne de titre print ''; print ''.$langs->trans("Name").''; - if (! $variantexxx) print ''; - else print ''; + print ''; print $nom; - if ($variantexxx) print ''.$variantexxx; print ''; print ''; diff --git a/htdocs/core/lib/admin.lib.php b/htdocs/core/lib/admin.lib.php index ddab337dd26..62271148ff0 100644 --- a/htdocs/core/lib/admin.lib.php +++ b/htdocs/core/lib/admin.lib.php @@ -160,6 +160,7 @@ function run_sql($sqlfile, $silent = 1, $entity = '', $usesavepoint = 1, $handle else $buf = fgets($fp); // Test if request must be ran only for particular database or version (if yes, we must remove the -- comment) + $reg=array(); if (preg_match('/^--\sV(MYSQL|PGSQL)([^\s]*)/i', $buf, $reg)) { $qualified=1; @@ -794,8 +795,9 @@ function listOfSessions() { $tmp=explode('_', $file); $idsess=$tmp[1]; - $login = preg_match('/dol_login\|s:[0-9]+:"([A-Za-z0-9]+)"/i', $sessValues, $regs); - $arrayofSessions[$idsess]["login"] = $regs[1]; + $regs=array(); + $loginfound = preg_match('/dol_login\|s:[0-9]+:"([A-Za-z0-9]+)"/i', $sessValues, $regs); + if ($loginfound) $arrayofSessions[$idsess]["login"] = $regs[1]; $arrayofSessions[$idsess]["age"] = time()-filectime($fullpath); $arrayofSessions[$idsess]["creation"] = filectime($fullpath); $arrayofSessions[$idsess]["modification"] = filemtime($fullpath); @@ -820,7 +822,6 @@ function purgeSessions($mysessionid) { global $conf; - $arrayofSessions = array(); $sessPath = ini_get("session.save_path")."/"; dol_syslog('admin.lib:purgeSessions mysessionid='.$mysessionid.' sessPath='.$sessPath); @@ -868,7 +869,9 @@ function purgeSessions($mysessionid) */ function activateModule($value, $withdeps = 1) { - global $db, $modules, $langs, $conf, $mysoc; + global $db, $langs, $conf, $mysoc; + + $ret=array(); // Check parameters if (empty($value)) { @@ -1689,8 +1692,10 @@ function phpinfo_array() foreach($info_lines as $line) { // new cat? + $title = array(); preg_match("~

(.*)

~", $line, $title) ? $cat = $title[1] : null; - if(preg_match("~]+>([^<]*)]+>([^<]*)~", $line, $val)) + $val = array(); + if (preg_match("~]+>([^<]*)]+>([^<]*)~", $line, $val)) { $info_arr[trim($cat)][trim($val[1])] = $val[2]; } @@ -1709,7 +1714,7 @@ function phpinfo_array() */ function company_admin_prepare_head() { - global $langs, $conf, $user; + global $langs, $conf; $h = 0; $head = array(); diff --git a/htdocs/core/lib/bank.lib.php b/htdocs/core/lib/bank.lib.php index 6985c421062..f117bc24daf 100644 --- a/htdocs/core/lib/bank.lib.php +++ b/htdocs/core/lib/bank.lib.php @@ -182,7 +182,7 @@ function various_payment_prepare_head($object) require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php'; - $upload_dir = $conf->banque->dir_output . "/" . dol_sanitizeFileName($object->ref); + $upload_dir = $conf->bank->dir_output . "/" . dol_sanitizeFileName($object->ref); $nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$')); $nbLinks=Link::count($db, $object->element, $object->id); $head[$h][0] = DOL_URL_ROOT.'/compta/bank/various_payment/document.php?id='.$object->id; diff --git a/htdocs/core/lib/files.lib.php b/htdocs/core/lib/files.lib.php index dd96cfdb31f..e00f79b27bc 100644 --- a/htdocs/core/lib/files.lib.php +++ b/htdocs/core/lib/files.lib.php @@ -2701,7 +2701,7 @@ function dol_check_secure_access_document($modulepart, $original_file, $entity, } // Wrapping pour les remises de cheques - elseif ($modulepart == 'remisecheque' && !empty($conf->banque->dir_output)) + elseif ($modulepart == 'remisecheque' && !empty($conf->bank->dir_output)) { if ($fuser->rights->banque->{$lire} || preg_match('/^specimen/i', $original_file)) { @@ -2712,7 +2712,7 @@ function dol_check_secure_access_document($modulepart, $original_file, $entity, } // Wrapping for bank - elseif ($modulepart == 'bank' && !empty($conf->bank->dir_output)) + elseif (($modulepart == 'banque' || $modulepart == 'bank') && !empty($conf->bank->dir_output)) { if ($fuser->rights->banque->{$lire}) { diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 2e938121c8a..4c0b15c8d46 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -3754,6 +3754,11 @@ function dol_print_error($db = '', $error = '', $errors = null) $syslog.="pid=".dol_getmypid(); } + if (! empty($conf->modules)) + { + $out.="".$langs->trans("Modules").": ".join(', ', $conf->modules)."
\n"; + } + if (is_object($db)) { if ($_SERVER['DOCUMENT_ROOT']) // Mode web @@ -6102,6 +6107,7 @@ $substitutionarray=array_merge($substitutionarray, array( { $substitutionarray['__DOL_MAIN_URL_ROOT__']=DOL_MAIN_URL_ROOT; $substitutionarray['__(AnyTranslationKey)__']=$outputlangs->trans('TranslationOfKey'); + $substitutionarray['__(AnyTranslationKey|langfile)__']=$outputlangs->trans('TranslationOfKey').' (load also language file before)'; $substitutionarray['__[AnyConstantKey]__']=$outputlangs->trans('ValueOfConstantKey'); } @@ -6130,7 +6136,7 @@ function make_substitutions($text, $substitutionarray, $outputlangs = null) if (empty($outputlangs)) $outputlangs=$langs; - // Make substitution for language keys + // Make substitution for language keys: __(AnyTranslationKey)__ or __(AnyTranslationKey|langfile)__ if (is_object($outputlangs)) { while (preg_match('/__\(([^\)]+)\)__/', $text, $reg)) @@ -6146,8 +6152,8 @@ function make_substitutions($text, $substitutionarray, $outputlangs = null) } } - // Make substitution for constant keys. Must be after the substitution of translation, so if text of translation contains a constant, - // it is also converted. + // Make substitution for constant keys. + // Must be after the substitution of translation, so if the text of translation contains a string __[xxx]__, it is also converted. while (preg_match('/__\[([^\]]+)\]__/', $text, $reg)) { $msgishtml = 0; diff --git a/htdocs/core/lib/functions2.lib.php b/htdocs/core/lib/functions2.lib.php index 45fea25224b..16fb210ee4d 100644 --- a/htdocs/core/lib/functions2.lib.php +++ b/htdocs/core/lib/functions2.lib.php @@ -564,6 +564,28 @@ function isValidUrl($url, $http = 0, $pass = 0, $port = 0, $path = 0, $query = 0 return $ValidUrl; } +/** + * Check if VAT numero is valid (check done on syntax only, no database or remote access) + * + * @param Societe $company VAT number + * @return int 1=Check is OK, 0=Check is KO + */ +function isValidVATID($company) +{ + if ($company->isInEEC()) // Syntax check rules for EEC countries + { + $vatprefix = $company->country_code; + if ($vatprefix == 'GR') $vatprefix = '(EL|GR)'; + else $vatprefix = preg_quote($vatprefix, '/'); + if (! preg_match('/^'.$vatprefix.'[a-zA-Z0-9\-\.]{5,10}$/', $company->tva_intra)) + { + return 0; + } + } + + return 1; +} + /** * Clean an url string * @@ -2496,7 +2518,7 @@ function autoOrManual($automaticmanual, $case = 1, $color = 0) /** * Convert links to local wrapper to medias files into a string into a public external URL readable on internet - * + * * @param string $notetoshow Text to convert * @return string String */ @@ -2504,7 +2526,7 @@ function convertBackOfficeMediasLinksToPublicLinks($notetoshow) { global $dolibarr_main_url_root; // Define $urlwithroot - $urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT,'/').'$/i','',trim($dolibarr_main_url_root)); + $urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root)); $urlwithroot=$urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file //$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current $notetoshow=preg_replace('/src="[a-zA-Z0-9_\/\-\.]*(viewimage\.php\?modulepart=medias[^"]*)"/', 'src="'.$urlwithroot.'/\1"', $notetoshow); diff --git a/htdocs/core/lib/geturl.lib.php b/htdocs/core/lib/geturl.lib.php index 9a78e7a3dbf..c161eb056fe 100644 --- a/htdocs/core/lib/geturl.lib.php +++ b/htdocs/core/lib/geturl.lib.php @@ -22,10 +22,10 @@ */ /** - * Function get content from an URL (use proxy if proxy defined) + * Function to get a content from an URL (use proxy if proxy defined) * * @param string $url URL to call. - * @param string $postorget 'POST', 'GET', 'HEAD', 'PUT', 'PUTALREADYFORMATED', 'DELETE' + * @param string $postorget 'POST', 'GET', 'HEAD', 'PUT', 'PUTALREADYFORMATED', 'POSTALREADYFORMATED', 'DELETE' * @param string $param Parameters of URL (x=value1&y=value2) or may be a formated content with PUTALREADYFORMATED * @param integer $followlocation 1=Follow location, 0=Do not follow * @param string[] $addheaders Array of string to add into header. Example: ('Accept: application/xrds+xml', ....) @@ -34,7 +34,7 @@ function getURLContent($url, $postorget = 'GET', $param = '', $followlocation = 1, $addheaders = array()) { //declaring of global variables - global $conf, $langs; + global $conf; $USE_PROXY=empty($conf->global->MAIN_PROXY_USE)?0:$conf->global->MAIN_PROXY_USE; $PROXY_HOST=empty($conf->global->MAIN_PROXY_HOST)?0:$conf->global->MAIN_PROXY_HOST; $PROXY_PORT=empty($conf->global->MAIN_PROXY_PORT)?0:$conf->global->MAIN_PROXY_PORT; @@ -85,6 +85,7 @@ function getURLContent($url, $postorget = 'GET', $param = '', $followlocation = } elseif ($postorget == 'PUT') { + $array_param=null; curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT'); // HTTP request is 'PUT' if (! is_array($param)) parse_str($param, $array_param); else @@ -195,6 +196,7 @@ function getRootURLFromURL($url) { $prefix=''; $tmpurl = $url; + $reg = null; if (preg_match('/^(https?:\/\/)/i', $tmpurl, $reg)) $prefix = $reg[1]; $tmpurl = preg_replace('/^https?:\/\//i', '', $tmpurl); // Remove http(s):// $tmpurl = preg_replace('/\/.*$/i', '', $tmpurl); // Remove part after domain diff --git a/htdocs/core/lib/payments.lib.php b/htdocs/core/lib/payments.lib.php index 70f3e87eaf9..5d88f3e26ea 100644 --- a/htdocs/core/lib/payments.lib.php +++ b/htdocs/core/lib/payments.lib.php @@ -142,23 +142,32 @@ function showOnlinePaymentUrl($type, $ref) /** * Return string with full Url * - * @param int $mode 0=True url, 1=Url formated with colors - * @param string $type Type of URL ('free', 'order', 'invoice', 'contractline', 'membersubscription' ...) - * @param string $ref Ref of object - * @param int $amount Amount (required for $type='free' only) - * @param string $freetag Free tag - * @return string Url string + * @param int $mode 0=True url, 1=Url formated with colors + * @param string $type Type of URL ('free', 'order', 'invoice', 'contractline', 'membersubscription' ...) + * @param string $ref Ref of object + * @param int $amount Amount (required for $type='free' only) + * @param string $freetag Free tag + * @param string $localorexternal 0=Url for browser, 1=Url for external access + * @return string Url string */ -function getOnlinePaymentUrl($mode, $type, $ref = '', $amount = '9.99', $freetag = 'your_free_tag') +function getOnlinePaymentUrl($mode, $type, $ref = '', $amount = '9.99', $freetag = 'your_free_tag', $localorexternal = 0) { - global $conf; + global $conf, $dolibarr_main_url_root; $ref=str_replace(' ', '', $ref); $out=''; + // Define $urlwithroot + $urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root)); + $urlwithroot=$urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file + //$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current + + $urltouse = DOL_MAIN_URL_ROOT; + if ($localorexternal) $urltouse = $urlwithroot; + if ($type == 'free') { - $out=DOL_MAIN_URL_ROOT.'/public/payment/newpayment.php?amount='.($mode?'':'').$amount.($mode?'':'').'&tag='.($mode?'':'').$freetag.($mode?'':''); + $out=$urltouse.'/public/payment/newpayment.php?amount='.($mode?'':'').$amount.($mode?'':'').'&tag='.($mode?'':'').$freetag.($mode?'':''); if (! empty($conf->global->PAYMENT_SECURITY_TOKEN)) { if (empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) $out.='&securekey='.$conf->global->PAYMENT_SECURITY_TOKEN; @@ -167,7 +176,7 @@ function getOnlinePaymentUrl($mode, $type, $ref = '', $amount = '9.99', $freetag } elseif ($type == 'order') { - $out=DOL_MAIN_URL_ROOT.'/public/payment/newpayment.php?source=order&ref='.($mode?'':''); + $out=$urltouse.'/public/payment/newpayment.php?source=order&ref='.($mode?'':''); if ($mode == 1) $out.='order_ref'; if ($mode == 0) $out.=urlencode($ref); $out.=($mode?'':''); @@ -185,7 +194,7 @@ function getOnlinePaymentUrl($mode, $type, $ref = '', $amount = '9.99', $freetag } elseif ($type == 'invoice') { - $out=DOL_MAIN_URL_ROOT.'/public/payment/newpayment.php?source=invoice&ref='.($mode?'':''); + $out=$urltouse.'/public/payment/newpayment.php?source=invoice&ref='.($mode?'':''); if ($mode == 1) $out.='invoice_ref'; if ($mode == 0) $out.=urlencode($ref); $out.=($mode?'':''); @@ -203,7 +212,7 @@ function getOnlinePaymentUrl($mode, $type, $ref = '', $amount = '9.99', $freetag } elseif ($type == 'contractline') { - $out=DOL_MAIN_URL_ROOT.'/public/payment/newpayment.php?source=contractline&ref='.($mode?'':''); + $out=$urltouse.'/public/payment/newpayment.php?source=contractline&ref='.($mode?'':''); if ($mode == 1) $out.='contractline_ref'; if ($mode == 0) $out.=urlencode($ref); $out.=($mode?'':''); @@ -221,7 +230,7 @@ function getOnlinePaymentUrl($mode, $type, $ref = '', $amount = '9.99', $freetag } elseif ($type == 'member' || $type == 'membersubscription') { - $out=DOL_MAIN_URL_ROOT.'/public/payment/newpayment.php?source=membersubscription&ref='.($mode?'':''); + $out=$urltouse.'/public/payment/newpayment.php?source=membersubscription&ref='.($mode?'':''); if ($mode == 1) $out.='member_ref'; if ($mode == 0) $out.=urlencode($ref); $out.=($mode?'':''); @@ -239,7 +248,7 @@ function getOnlinePaymentUrl($mode, $type, $ref = '', $amount = '9.99', $freetag } if ($type == 'donation') { - $out=DOL_MAIN_URL_ROOT.'/public/payment/newpayment.php?source=donation&ref='.($mode?'':''); + $out=$urltouse.'/public/payment/newpayment.php?source=donation&ref='.($mode?'':''); if ($mode == 1) $out.='donation_ref'; if ($mode == 0) $out.=urlencode($ref); $out.=($mode?'':''); diff --git a/htdocs/core/lib/pdf.lib.php b/htdocs/core/lib/pdf.lib.php index 2d6e41abe59..cc40fcb9272 100644 --- a/htdocs/core/lib/pdf.lib.php +++ b/htdocs/core/lib/pdf.lib.php @@ -341,14 +341,14 @@ function pdfBuildThirdpartyName($thirdparty, Translate $outputlangs, $includeali /** * Return a string with full address formated for output on documents * - * @param Translate $outputlangs Output langs object - * @param Societe $sourcecompany Source company object - * @param Societe|string $targetcompany Target company object - * @param Contact|string $targetcontact Target contact object - * @param int $usecontact Use contact instead of company - * @param string $mode Address type ('source', 'target', 'targetwithdetails', 'targetwithdetails_xxx': target but include also phone/fax/email/url) - * @param Object $object Object we want to build document for - * @return string String with full address + * @param Translate $outputlangs Output langs object + * @param Societe $sourcecompany Source company object + * @param Societe|string|null $targetcompany Target company object + * @param Contact|string|null $targetcontact Target contact object + * @param int $usecontact Use contact instead of company + * @param string $mode Address type ('source', 'target', 'targetwithdetails', 'targetwithdetails_xxx': target but include also phone/fax/email/url) + * @param Object $object Object we want to build document for + * @return string String with full address */ function pdf_build_address($outputlangs, $sourcecompany, $targetcompany = '', $targetcontact = '', $usecontact = 0, $mode = 'source', $object = null) { @@ -364,7 +364,7 @@ function pdf_build_address($outputlangs, $sourcecompany, $targetcompany = '', $t $stringaddress = ''; if (is_object($hookmanager)) { - $parameters = array('sourcecompany'=>&$sourcecompany,'targetcompany'=>&$targetcompany,'targetcontact'=>$targetcontact,'outputlangs'=>$outputlangs,'mode'=>$mode,'usecontact'=>$usecontact); + $parameters = array('sourcecompany'=>&$sourcecompany, 'targetcompany'=>&$targetcompany, 'targetcontact'=>&$targetcontact, 'outputlangs'=>$outputlangs, 'mode'=>$mode, 'usecontact'=>$usecontact); $action=''; $reshook = $hookmanager->executeHooks('pdf_build_address', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks $stringaddress.=$hookmanager->resPrint; @@ -1954,6 +1954,7 @@ function pdf_getlinetotalexcltax($object, $i, $outputlangs, $hidedetails = 0) $total_ht = ($conf->multicurrency->enabled && $object->multicurrency_tx != 1 ? $object->lines[$i]->multicurrency_total_ht : $object->lines[$i]->total_ht); if ($object->lines[$i]->situation_percent > 0) { + // TODO Remove this. The total should be saved correctly in database instead of being modified here. $prev_progress = 0; $progress = 1; if (method_exists($object->lines[$i], 'get_prev_progress')) @@ -1964,7 +1965,9 @@ function pdf_getlinetotalexcltax($object, $i, $outputlangs, $hidedetails = 0) $result.=price($sign * ($total_ht/($object->lines[$i]->situation_percent/100)) * $progress, 0, $outputlangs); } else - $result.=price($sign * $total_ht, 0, $outputlangs); + { + $result.=price($sign * $total_ht, 0, $outputlangs); + } } } return $result; diff --git a/htdocs/core/lib/price.lib.php b/htdocs/core/lib/price.lib.php index 9d3aa99f306..a649d9d225e 100644 --- a/htdocs/core/lib/price.lib.php +++ b/htdocs/core/lib/price.lib.php @@ -39,7 +39,7 @@ * @param int $qty Quantity * @param float $pu Unit price (HT or TTC selon price_base_type) * @param float $remise_percent_ligne Discount for line - * @param float $txtva 0=do not apply standard tax, Vat rate=apply + * @param float $txtva 0=do not apply VAT tax, VAT rate=apply (this is VAT rate only without text code, we don't need text code because we alreaydy have all tax info into $localtaxes_array) * @param float $uselocaltax1_rate 0=do not use this localtax, >0=apply and get value from localtaxes_array (or database if empty), -1=autodetect according to seller if we must apply, get value from localtaxes_array (or database if empty). Try to always use -1. * @param float $uselocaltax2_rate 0=do not use this localtax, >0=apply and get value from localtaxes_array (or database if empty), -1=autodetect according to seller if we must apply, get value from localtaxes_array (or database if empty). Try to always use -1. * @param float $remise_percent_global 0 @@ -82,7 +82,7 @@ * 25=multicurrency_total_tax1 for total_ht * 26=multicurrency_total_tax2 for total_ht */ -function calcul_price_total($qty, $pu, $remise_percent_ligne, $txtva, $uselocaltax1_rate, $uselocaltax2_rate, $remise_percent_global, $price_base_type, $info_bits, $type, $seller = '', $localtaxes_array = '', $progress = 100, $multicurrency_tx = 1, $pu_devise = 0) +function calcul_price_total($qty, $pu, $remise_percent_ligne, $txtva, $uselocaltax1_rate, $uselocaltax2_rate, $remise_percent_global, $price_base_type, $info_bits, $type, $seller = '', $localtaxes_array='', $progress=100, $multicurrency_tx=1, $pu_devise=0) { global $conf,$mysoc,$db; @@ -131,13 +131,14 @@ function calcul_price_total($qty, $pu, $remise_percent_ligne, $txtva, $uselocalt $localtax2_type = $localtaxes_array[2]; $localtax2_rate = $localtaxes_array[3]; } - else // deprecated method. values and type for localtaxes must be provided by caller and loaded with getLocalTaxesFromRate + else // deprecated method. values and type for localtaxes must be provided by caller and loaded with getLocalTaxesFromRate using the full vat rate (including text code) { - $sql = "SELECT taux, localtax1, localtax2, localtax1_type, localtax2_type"; + dol_syslog("Price.lib::calcul_price_total search vat information using old deprecated method", LOG_WARNING); + + $sql = "SELECT taux, localtax1, localtax2, localtax1_type, localtax2_type"; $sql.= " FROM ".MAIN_DB_PREFIX."c_tva as cv"; $sql.= " WHERE cv.taux = ".$txtva; $sql.= " AND cv.fk_pays = ".$countryid; - dol_syslog("Price.lib::calcul_price_total search vat information using old deprecated method", LOG_WARNING); $resql = $db->query($sql); if ($resql) { @@ -187,9 +188,9 @@ function calcul_price_total($qty, $pu, $remise_percent_ligne, $txtva, $uselocalt //If input unit price is 'HT', we need to have the totals with main VAT for a correct calculation if ($price_base_type != 'TTC') { - $tot_sans_remise_wt = price2num($tot_sans_remise * (1 + ($txtva / 100)), 'MU'); - $tot_avec_remise_wt = price2num($tot_avec_remise * (1 + ($txtva / 100)), 'MU'); - $pu_wt = price2num($pu * (1 + ($txtva / 100)), 'MU'); + $tot_sans_remise_wt = price2num($tot_sans_remise * (1 + ($txtva / 100)),'MU'); + $tot_avec_remise_wt = price2num($tot_avec_remise * (1 + ($txtva / 100)),'MU'); + $pu_wt = price2num($pu * (1 + ($txtva / 100)),'MU'); } else { @@ -291,9 +292,9 @@ function calcul_price_total($qty, $pu, $remise_percent_ligne, $txtva, $uselocalt //If input unit price is 'TTC', we need to have the totals without main VAT for a correct calculation if ($price_base_type == 'TTC') { - $tot_sans_remise= price2num($tot_sans_remise / (1 + ($txtva / 100)), 'MU'); - $tot_avec_remise= price2num($tot_avec_remise / (1 + ($txtva / 100)), 'MU'); - $pu = price2num($pu / (1 + ($txtva / 100)), 'MU'); + $tot_sans_remise= price2num($tot_sans_remise / (1 + ($txtva / 100)),'MU'); + $tot_avec_remise= price2num($tot_avec_remise / (1 + ($txtva / 100)),'MU'); + $pu = price2num($pu / (1 + ($txtva / 100)),'MU'); } $apply_tax = false; @@ -410,3 +411,4 @@ function calcul_price_total($qty, $pu, $remise_percent_ligne, $txtva, $uselocalt return $result; } + diff --git a/htdocs/core/lib/project.lib.php b/htdocs/core/lib/project.lib.php index cf1a21fce39..efcfeca61dd 100644 --- a/htdocs/core/lib/project.lib.php +++ b/htdocs/core/lib/project.lib.php @@ -474,7 +474,7 @@ function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$t } // Ref of task - print ''; + print ''; if ($showlineingray) { print ''.img_object('', 'projecttask').' '.$lines[$i]->ref.''; diff --git a/htdocs/core/lib/security.lib.php b/htdocs/core/lib/security.lib.php index 8392b857061..0dbbb7f0829 100644 --- a/htdocs/core/lib/security.lib.php +++ b/htdocs/core/lib/security.lib.php @@ -109,7 +109,7 @@ function dol_decode($chain, $key = '1') * @param string $chain String to hash * @param string $type Type of hash ('0':auto will use MAIN_SECURITY_HASH_ALGO else md5, '1':sha1, '2':sha1+md5, '3':md5, '4':md5 for OpenLdap, '5':sha256). Use '3' here, if hash is not needed for security purpose, for security need, prefer '0'. * @return string Hash of string - * @getRandomPassword + * @see getRandomPassword() */ function dol_hash($chain, $type = '0') { diff --git a/htdocs/core/lib/security2.lib.php b/htdocs/core/lib/security2.lib.php index f98985d0f74..0e0d4a37946 100644 --- a/htdocs/core/lib/security2.lib.php +++ b/htdocs/core/lib/security2.lib.php @@ -131,8 +131,8 @@ if (! function_exists('dol_loginfunction')) */ function dol_loginfunction($langs, $conf, $mysoc) { - global $dolibarr_main_demo,$db; - global $smartphone,$hookmanager; + global $dolibarr_main_demo, $db; + global $hookmanager; $langs->loadLangs(array("main","other","help","admin")); @@ -207,11 +207,7 @@ if (! function_exists('dol_loginfunction')) // Execute hook getLoginPageOptions (for table) $parameters=array('entity' => GETPOST('entity', 'int')); $reshook = $hookmanager->executeHooks('getLoginPageOptions', $parameters); // Note that $action and $object may have been modified by some hooks. - if (is_array($hookmanager->resArray) && ! empty($hookmanager->resArray)) { - $morelogincontent = $hookmanager->resArray; // (deprecated) For compatibility - } else { - $morelogincontent = $hookmanager->resPrint; - } + $morelogincontent = $hookmanager->resPrint; // Execute hook getLoginPageExtraOptions (eg for js) $parameters=array('entity' => GETPOST('entity', 'int')); @@ -445,17 +441,17 @@ function encodedecode_dbpassconf($level = 0) * * @param boolean $generic true=Create generic password (32 chars/numbers), false=Use the configured password generation module * @param array $replaceambiguouschars Discard ambigous characters. For example array('I'). - * @return string New value for password + * @param int $length Length of random string (Used only if $generic is true) + * @return string New value for password * @see dol_hash() */ -function getRandomPassword($generic = false, $replaceambiguouschars = null) +function getRandomPassword($generic = false, $replaceambiguouschars = null, $length = 32) { global $db,$conf,$langs,$user; $generated_password=''; if ($generic) { - $length = 32; $lowercase = "qwertyuiopasdfghjklzxcvbnm"; $uppercase = "ASDFGHJKLZXCVBNMQWERTYUIOP"; $numbers = "1234567890"; diff --git a/htdocs/core/lib/sendings.lib.php b/htdocs/core/lib/sendings.lib.php index 97d8a318e5c..d6ca8cba830 100644 --- a/htdocs/core/lib/sendings.lib.php +++ b/htdocs/core/lib/sendings.lib.php @@ -51,7 +51,7 @@ function shipping_prepare_head($object) { // delivery link $object->fetchObjectLinked($object->id, $object->element); - if (count($object->linkedObjectsIds['delivery']) > 0) // If there is a delivery + if (is_array($object->linkedObjectsIds['delivery']) && count($object->linkedObjectsIds['delivery']) > 0) // If there is a delivery { // Take first one element of array $tmp = reset($object->linkedObjectsIds['delivery']); @@ -176,7 +176,7 @@ function delivery_prepare_head($object) */ function show_list_sending_receive($origin, $origin_id, $filter = '') { - global $db, $conf, $langs, $bc; + global $db, $conf, $langs; global $form; $product_static=new Product($db); @@ -218,8 +218,8 @@ function show_list_sending_receive($origin, $origin_id, $filter = '') print ''; print ''; //print ''; - print ''; - print ''; + print ''; + print ''; print ''; print ''; print ''; diff --git a/htdocs/core/lib/website.lib.php b/htdocs/core/lib/website.lib.php index 4aac8cfda5a..56f6cdf97a3 100644 --- a/htdocs/core/lib/website.lib.php +++ b/htdocs/core/lib/website.lib.php @@ -100,6 +100,7 @@ function dolWebsiteReplacementOfLinks($website, $content, $removephppart = 0) * @param string $str String to clean * @param string $replacewith String to use as replacement * @return string Result string without php code + * @see dolKeepOnlyPhpCode() */ function dolStripPhpCode($str, $replacewith = '') { @@ -132,6 +133,44 @@ function dolStripPhpCode($str, $replacewith = '') return $newstr; } +/** + * Keep only PHP code part from a HTML string page. + * + * @param string $str String to clean + * @return string Result string with php code only + * @see dolStripPhpCode() + */ +function dolKeepOnlyPhpCode($str) +{ + $newstr = ''; + + //split on each opening tag + $parts = explode('', $part, 2); + if (!empty($partlings)) + { + $newstr .= $partlings[0].'?>'; + } + else + { + $newstr .= $part.'?>'; + } + } + } + return $newstr; +} /** * Render a string of an HTML content and output it. diff --git a/htdocs/core/menus/init_menu_auguria.sql b/htdocs/core/menus/init_menu_auguria.sql index fe4f7e3c17a..3a4ec85ec58 100644 --- a/htdocs/core/menus/init_menu_auguria.sql +++ b/htdocs/core/menus/init_menu_auguria.sql @@ -5,16 +5,16 @@ delete from llx_menu where menu_handler=__HANDLER__ and entity=__ENTITY__; --- +-- -- table llx_menu --- +-- insert into llx_menu (module, enabled, rowid, menu_handler, type, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '1', 1__+MAX_llx_menu__, __HANDLER__, 'top', 'home', '', 0, '/index.php?mainmenu=home&leftmenu=', 'Home', -1, '', '', '', 2, 10, __ENTITY__); insert into llx_menu (module, enabled, rowid, menu_handler, type, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('societe|fournisseur', '( ! empty($conf->societe->enabled) && (empty($conf->global->SOCIETE_DISABLE_PROSPECTS) || empty($conf->global->SOCIETE_DISABLE_CUSTOMERS))) || ! empty($conf->fournisseur->enabled)', 2__+MAX_llx_menu__, __HANDLER__, 'top', 'companies', '', 0, '/societe/index.php?mainmenu=companies&leftmenu=', 'ThirdParties', -1, 'companies', '$user->rights->societe->lire || $user->rights->societe->contact->lire', '', 2, 20, __ENTITY__); insert into llx_menu (module, enabled, rowid, menu_handler, type, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('product|service', '$conf->product->enabled || $conf->service->enabled', 3__+MAX_llx_menu__, __HANDLER__, 'top', 'products', '', 0, '/product/index.php?mainmenu=products&leftmenu=', 'ProductsPipeServices', -1, 'products', '$user->rights->produit->lire||$user->rights->service->lire', '', 0, 30, __ENTITY__); insert into llx_menu (module, enabled, rowid, menu_handler, type, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('propal|commande|fournisseur|contrat|ficheinter', '$conf->propal->enabled || $conf->commande->enabled || $conf->supplier_order->enabled || $conf->contrat->enabled || $conf->ficheinter->enabled', 5__+MAX_llx_menu__, __HANDLER__, 'top', 'commercial', '', 0, '/comm/index.php?mainmenu=commercial&leftmenu=', 'Commercial', -1, 'commercial', '$user->rights->societe->lire || $user->rights->societe->contact->lire', '', 2, 40, __ENTITY__); insert into llx_menu (module, enabled, rowid, menu_handler, type, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('facture|don|tax|salaries|loan|banque', '$conf->comptabilite->enabled || $conf->accounting->enabled || $conf->facture->enabled || $conf->don->enabled || $conf->tax->enabled || $conf->salaries->enabled || $conf->supplier_invoice->enabled || $conf->loan->enabled || $conf->banque->enabled', 6__+MAX_llx_menu__, __HANDLER__, 'top', 'billing', '', 0, '/compta/index.php?mainmenu=billing&leftmenu=', 'MenuFinancial', -1, 'compta', '$user->rights->facture->lire|| $user->rights->don->lire || $user->rights->tax->charges->lire || $user->rights->salaries->read || $user->rights->loan->read || $user->rights->banque->lire', '', 2, 50, __ENTITY__); insert into llx_menu (module, enabled, rowid, menu_handler, type, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('banque|prelevement', '$conf->banque->enabled || $conf->prelevement->enabled', 14__+MAX_llx_menu__, __HANDLER__, 'top', 'bank', '', 0, '/compta/bank/list.php?mainmenu=bank&leftmenu=bank', 'MenuBankCash', -1, 'banks', '$user->rights->banque->lire || $user->rights->prelevement->bons->lire', '', 0, 52, __ENTITY__); -insert into llx_menu (module, enabled, rowid, menu_handler, type, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('comptabilite|accounting|assets', '$conf->comptabilite->enabled || $conf->accounting->enabled || $conf->accounting->assets', 9__+MAX_llx_menu__, __HANDLER__, 'top', 'accountancy', '', 0, '/compta/index.php?mainmenu=accountancy&leftmenu=accountancy', 'Accountancy', -1, 'compta', '$user->rights->compta->resultat->lire || $user->rights->accounting->mouvements->lire || $user->rights->assets->read', '', 2, 54, __ENTITY__); +insert into llx_menu (module, enabled, rowid, menu_handler, type, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('comptabilite|accounting|asset', '$conf->comptabilite->enabled || $conf->accounting->enabled || $conf->asset->enabled', 9__+MAX_llx_menu__, __HANDLER__, 'top', 'accountancy', '', 0, '/compta/index.php?mainmenu=accountancy&leftmenu=accountancy', 'MenuAccountancy', -1, 'main', '$user->rights->compta->resultat->lire || $user->rights->accounting->mouvements->lire || $user->rights->asset->read', '', 2, 54, __ENTITY__); insert into llx_menu (module, enabled, rowid, menu_handler, type, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('projet', '$conf->projet->enabled', 7__+MAX_llx_menu__, __HANDLER__, 'top', 'project', '', 0, '/projet/index.php?mainmenu=project&leftmenu=', 'Projects', -1, 'projects', '$user->rights->projet->lire', '', 2, 70, __ENTITY__); insert into llx_menu (module, enabled, rowid, menu_handler, type, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '', 8__+MAX_llx_menu__, __HANDLER__, 'top', 'tools', '', 0, '/core/tools.php?mainmenu=tools&leftmenu=', 'Tools', -1, 'other', '', '', 2, 90, __ENTITY__); insert into llx_menu (module, enabled, rowid, menu_handler, type, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('adherent', '$conf->adherent->enabled', 13__+MAX_llx_menu__, __HANDLER__, 'top', 'members', '', 0, '/adherents/index.php?mainmenu=members&leftmenu=', 'Members', -1, 'members', '$user->rights->adherent->lire', '', 2, 110, __ENTITY__); @@ -238,8 +238,8 @@ insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, left insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->banque->enabled && empty($conf->global->BANK_USE_OLD_VARIOUS_PAYMENT)', __HANDLER__, 'left', 2350__+MAX_llx_menu__, 'billing', 'tax_various', 2200__+MAX_llx_menu__, '/compta/bank/various_payment/list.php?mainmenu=billing&leftmenu=tax_various', 'MenuVariousPayment', 1, 'banks', '$user->rights->banque->lire', '', 0, 1, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->banque->enabled && $leftmenu=="tax_various"', __HANDLER__, 'left', 2351__+MAX_llx_menu__, 'billing', '', 2350__+MAX_llx_menu__, '/compta/bank/various_payment/card.php?mainmenu=billing&leftmenu=tax_various&action=create', 'New', 2, 'various_payment', '$user->rights->banque->modifier', '', 0, 2, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->banque->enabled && $leftmenu=="tax_various"', __HANDLER__, 'left', 2352__+MAX_llx_menu__, 'billing', '', 2350__+MAX_llx_menu__, '/compta/bank/various_payment/list.php?mainmenu=billing&leftmenu=tax_various', 'List', 2, 'various_payment', '$user->rights->banque->lire', '', 0, 3, __ENTITY__); --- Accounting Expert -insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled', __HANDLER__, 'left', 2400__+MAX_llx_menu__, 'accountancy', 'accountancy', 9__+MAX_llx_menu__, '/accountancy/index.php?mainmenu=accountancy&leftmenu=accountancy', 'MenuAccountancy', 0, 'accountancy', '! empty($conf->accounting->enabled) || $user->rights->accounting->bind->write || $user->rights->accounting->bind->write || $user->rights->compta->resultat->lire', '', 0, 7, __ENTITY__); +-- Accounting (Double entries) +insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled', __HANDLER__, 'left', 2400__+MAX_llx_menu__, 'accountancy', 'accountancy', 9__+MAX_llx_menu__, '/accountancy/index.php?mainmenu=accountancy&leftmenu=accountancy', 'MenuAccountancy', 0, 'main', '! empty($conf->accounting->enabled) || $user->rights->accounting->bind->write || $user->rights->accounting->bind->write || $user->rights->compta->resultat->lire', '', 0, 7, __ENTITY__); -- Setup insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled', __HANDLER__, 'left', 2451__+MAX_llx_menu__, 'accountancy', 'accountancy_admin', 2400__+MAX_llx_menu__, '/accountancy/index.php?mainmenu=accountancy&leftmenu=accountancy_admin', 'Setup', 1, 'accountancy', '$user->rights->accounting->chartofaccount', '', 0, 1, __ENTITY__); @@ -299,10 +299,12 @@ insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, left insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->comptabilite->enabled && $leftmenu=="ca"', __HANDLER__, 'left', 2715__+MAX_llx_menu__, 'accountancy', '', 2703__+MAX_llx_menu__, '/compta/stats/cabyuser.php?mainmenu=accountancy&leftmenu=ca', 'ByUsers', 2, 'main', '$user->rights->compta->resultat->lire || $user->rights->accounting->comptarapport->lire', '', 0, 1, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->comptabilite->enabled && $leftmenu=="ca"', __HANDLER__, 'left', 2716__+MAX_llx_menu__, 'accountancy', '', 2703__+MAX_llx_menu__, '/compta/stats/cabyprodserv.php?mainmenu=accountancy&leftmenu=ca', 'ByProductsAndServices', 2, 'main', '$user->rights->compta->resultat->lire || $user->rights->accounting->comptarapport->lire', '', 0, 1, __ENTITY__); -- Assets -insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->assets->enabled', __HANDLER__, 'left', 3000__+MAX_llx_menu__, 'accountancy', 'assets', 10__+MAX_llx_menu__, '/assets/list.php?mainmenu=accountancy&leftmenu=assets', 'MenuAssets', 0, 'assets', '$user->rights->assets->read', '', 2, 4, __ENTITY__); -insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->assets->enabled && $leftmenu=="assets"', __HANDLER__, 'left', 3001__+MAX_llx_menu__, 'accountancy', '', 3000__+MAX_llx_menu__, '/assets/card.php?mainmenu=accountancy&leftmenu=assets&action=create', 'MenuNewAsset', 1, 'assets', '$user->rights->assets->write', '', 2, 0, __ENTITY__); -insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->assets->enabled && $leftmenu=="assets"', __HANDLER__, 'left', 3002__+MAX_llx_menu__, 'accountancy', '', 3000__+MAX_llx_menu__, '/assets/type.php?mainmenu=accountancy&leftmenu=assets&action=create', 'MenuTypeAssets', 1, 'assets', '$user->rights->assets->write', '', 2, 0, __ENTITY__); -insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->assets->enabled && $leftmenu=="assets"', __HANDLER__, 'left', 3003__+MAX_llx_menu__, 'accountancy', '', 3000__+MAX_llx_menu__, '/assets/list.php?mainmenu=accountancy&leftmenu=assets', 'MenuListAssets', 1, 'assets', '$user->rights->assets->read', '', 2, 1, __ENTITY__); +insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->asset->enabled', __HANDLER__, 'left', 3000__+MAX_llx_menu__, 'accountancy', 'asset', 9__+MAX_llx_menu__, '/asset/list.php?mainmenu=accountancy&leftmenu=asset', 'MenuAssets', 1, 'assets', '$user->rights->asset->read', '', 0, 20, __ENTITY__); +insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->asset->enabled && $leftmenu=="asset"', __HANDLER__, 'left', 3001__+MAX_llx_menu__, 'asset', '', 3000__+MAX_llx_menu__, '/asset/card.php?mainmenu=accountancy&leftmenu=asset&action=create', 'MenuNewAsset', 2, 'assets', '$user->rights->asset->write', '', 0, 21, __ENTITY__); +insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->asset->enabled && $leftmenu=="asset"', __HANDLER__, 'left', 3003__+MAX_llx_menu__, 'asset', '', 3000__+MAX_llx_menu__, '/asset/list.php?mainmenu=accountancy&leftmenu=asset', 'MenuListAssets', 2, 'assets', '$user->rights->asset->read', '', 0, 22, __ENTITY__); +insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->asset->enabled && $leftmenu=="asset"', __HANDLER__, 'left', 3004__+MAX_llx_menu__, 'asset', 'asset_type', 3000__+MAX_llx_menu__, '/asset/type.php?mainmenu=accountancy&leftmenu=asset', 'MenuTypeAssets', 2, 'assets', '$user->rights->asset->read', '', 0, 23, __ENTITY__); +insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->asset->enabled && $leftmenu=="asset"', __HANDLER__, 'left', 3005__+MAX_llx_menu__, 'asset', '', 3004__+MAX_llx_menu__, '/asset/type.php?mainmenu=accountancy&action=create', 'MenuNewTypeAssets', 3, 'assets', '$user->rights->asset->configurer', '', 0, 24, __ENTITY__); +insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->asset->enabled && $leftmenu=="asset"', __HANDLER__, 'left', 3006__+MAX_llx_menu__, 'asset', '', 3004__+MAX_llx_menu__, '/asset/type.php?mainmenu=accountancy', 'MenuListTypeAssets', 3, 'assets', '$user->rights->asset->read', '', 0, 25, __ENTITY__); -- Check deposit insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', 'empty($conf->global->BANK_DISABLE_CHECK_DEPOSIT) && ! empty($conf->banque->enabled) && (! empty($conf->facture->enabled) || ! empty($conf->global->MAIN_MENU_CHEQUE_DEPOSIT_ON))', __HANDLER__, 'left', 1711__+MAX_llx_menu__, 'accountancy', 'checks', 14__+MAX_llx_menu__, '/compta/paiement/cheque/index.php?mainmenu=bank&leftmenu=checks', 'MenuChequeDeposits', 0, 'bills', '$user->rights->banque->lire', '', 2, 9, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', 'empty($conf->global->BANK_DISABLE_CHECK_DEPOSIT) && ! empty($conf->banque->enabled) && (! empty($conf->facture->enabled) || ! empty($conf->global->MAIN_MENU_CHEQUE_DEPOSIT_ON))', __HANDLER__, 'left', 1712__+MAX_llx_menu__, 'accountancy', '', 1711__+MAX_llx_menu__, '/compta/paiement/cheque/card.php?mainmenu=bank&leftmenu=checks&action=new', 'NewCheckDeposit', 1, 'compta', '$user->rights->banque->lire', '', 2, 0, __ENTITY__); diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index 7491556bebd..dcee245f257 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -87,20 +87,17 @@ function print_eldy_menu($db, $atarget, $type_user, &$tabMenu, &$menu, $noout = ); // Members + $tmpentry = array( + 'enabled' => (! empty($conf->adherent->enabled) ) , + 'perms' => (! empty($user->rights->adherent->lire) ), + 'module' => 'adherent' + ); $menu_arr[] = array( 'name' => 'Members', 'link' => '/adherents/index.php?mainmenu=members&leftmenu=', 'title' => "MenuMembers", 'level' => 0, - 'enabled' => $showmode = isVisibleToUserType( - $type_user, - $tmpentry = array( - 'enabled' => (! empty($conf->adherent->enabled) ) , - 'perms' => (! empty($user->rights->adherent->lire) ), - 'module' => 'adherent', - ), - $listofmodulesforexternal - ), + 'enabled' => $showmode = isVisibleToUserType($type_user, $tmpentry, $listofmodulesforexternal), 'target' => $atarget, 'mainmenu' => "members", 'leftmenu' => '', @@ -115,24 +112,21 @@ function print_eldy_menu($db, $atarget, $type_user, &$tabMenu, &$menu, $noout = ); // Third parties + $tmpentry = array( + 'enabled'=> ( ( ! empty($conf->societe->enabled) && + ( empty($conf->global->SOCIETE_DISABLE_PROSPECTS) || empty($conf->global->SOCIETE_DISABLE_CUSTOMERS) ) + ) + || ! empty($conf->fournisseur->enabled) + ), + 'perms'=> (! empty($user->rights->societe->lire) || ! empty($user->rights->fournisseur->lire)), + 'module'=>'societe|fournisseur' + ); $menu_arr[] = array( 'name' => 'Companies', 'link' => '/societe/index.php?mainmenu=companies&leftmenu=', 'title' => "ThirdParties", 'level' => 0, - 'enabled' => $showmode = isVisibleToUserType( - $type_user, - $tmpentry = array( - 'enabled'=> ( ( ! empty($conf->societe->enabled) && - ( empty($conf->global->SOCIETE_DISABLE_PROSPECTS) || empty($conf->global->SOCIETE_DISABLE_CUSTOMERS) ) - ) - || ! empty($conf->fournisseur->enabled) - ), - 'perms'=> (! empty($user->rights->societe->lire) || ! empty($user->rights->fournisseur->lire)), - 'module'=>'societe|fournisseur', - ), - $listofmodulesforexternal - ), + 'enabled' => $showmode = isVisibleToUserType($type_user, $tmpentry, $listofmodulesforexternal), 'target' => $atarget, 'mainmenu' => "companies", 'leftmenu' => '', @@ -147,6 +141,15 @@ function print_eldy_menu($db, $atarget, $type_user, &$tabMenu, &$menu, $noout = ); // Products-Services + $tmpentry = array( + 'enabled'=> (( ! empty($conf->societe->enabled) && + ( empty($conf->global->SOCIETE_DISABLE_PROSPECTS) || empty($conf->global->SOCIETE_DISABLE_CUSTOMERS) ) + ) + || ! empty($conf->fournisseur->enabled) + ), + 'perms'=> (! empty($user->rights->societe->lire) || ! empty($user->rights->fournisseur->lire)), + 'module'=>'product|service' + ); $menu_arr[] = array( 'name' => 'Products', 'link' => '/product/index.php?mainmenu=products&leftmenu=', @@ -154,19 +157,7 @@ function print_eldy_menu($db, $atarget, $type_user, &$tabMenu, &$menu, $noout = ? ( array("TMenuProducts" , " | " ,"TMenuServices") ) : (! empty($conf->product->enabled)? "TMenuProducts" : "TMenuServices" ), 'level' => 0, - 'enabled' => $showmode = isVisibleToUserType( - $type_user, - $tmpentry = array( - 'enabled'=> (( ! empty($conf->societe->enabled) && - ( empty($conf->global->SOCIETE_DISABLE_PROSPECTS) || empty($conf->global->SOCIETE_DISABLE_CUSTOMERS) ) - ) - || ! empty($conf->fournisseur->enabled) - ), - 'perms'=> (! empty($user->rights->societe->lire) || ! empty($user->rights->fournisseur->lire)), - 'module'=>'product|service', - ), - $listofmodulesforexternal - ), + 'enabled' => $showmode = isVisibleToUserType($type_user, $tmpentry, $listofmodulesforexternal), 'target' => $atarget, 'mainmenu' => "products", 'leftmenu' => '', @@ -181,20 +172,17 @@ function print_eldy_menu($db, $atarget, $type_user, &$tabMenu, &$menu, $noout = ); // MRP + $tmpentry = array( + 'enabled'=>(! empty($conf->bom->enabled) || ! empty($conf->mrp->enabled)), + 'perms'=>(! empty($user->rights->bom->read) || ! empty($user->rights->mrp->read)), + 'module'=>'bom|mrp' + ); $menu_arr[] = array( 'name' => 'TMenuMRP', 'link' => '/mrp/index.php?mainmenu=mrp&leftmenu=', 'title' => $langs->trans("TMenuMRP"), 'level' => 0, - 'enabled' => $showmode = isVisibleToUserType( - $type_user, - $tmpentry = array( - 'enabled'=>(! empty($conf->bom->enabled) || ! empty($conf->mrp->enabled)), - 'perms'=>(! empty($user->rights->bom->read) || ! empty($user->rights->mrp->read)), - 'module'=>'bom|mrp', - ), - $listofmodulesforexternal - ), + 'enabled' => $showmode = isVisibleToUserType($type_user, $tmpentry, $listofmodulesforexternal), 'target' => $atarget, 'mainmenu' => "mrp", 'leftmenu' => '', @@ -209,6 +197,11 @@ function print_eldy_menu($db, $atarget, $type_user, &$tabMenu, &$menu, $noout = ); // Projects + $tmpentry = array( + 'enabled'=> ( ! empty($conf->projet->enabled) ? 1 : 0), + 'perms'=> (! empty($user->rights->projet->lire) ? 1 : 0), + 'module'=>'projet' + ); $menu_arr[] = array( 'name' => 'Projet', 'link' => '/projet/index.php?mainmenu=project&leftmenu=', @@ -216,15 +209,7 @@ function print_eldy_menu($db, $atarget, $type_user, &$tabMenu, &$menu, $noout = ? (($conf->global->PROJECT_USE_OPPORTUNITIES == 2)?"Leads":"Projects") : "LeadsOrProjects", 'level' => 0, - 'enabled' => $showmode = isVisibleToUserType( - $type_user, - $tmpentry = array( - 'enabled'=> ( ! empty($conf->projet->enabled) ? 1 : 0), - 'perms'=> (! empty($user->rights->projet->lire) ? 1 : 0), - 'module'=>'projet', - ), - $listofmodulesforexternal - ), + 'enabled' => $showmode = isVisibleToUserType($type_user, $tmpentry, $listofmodulesforexternal), 'target' => $atarget, 'mainmenu' => "project", 'leftmenu' => '', @@ -239,26 +224,23 @@ function print_eldy_menu($db, $atarget, $type_user, &$tabMenu, &$menu, $noout = ); // Commercial + $tmpentry = array( + 'enabled'=>(! empty($conf->propal->enabled) || + ! empty($conf->commande->enabled) || + ! empty($conf->supplier_order->enabled) || + ! empty($conf->supplier_proposal->enabled) || + ! empty($conf->contrat->enabled) || + ! empty($conf->ficheinter->enabled) + )?1:0, + 'perms'=>(! empty($user->rights->societe->lire) || ! empty($user->rights->societe->contact->lire)), + 'module'=>'propal|commande|supplier_order|contrat|ficheinter' + ); $menu_arr[] = array( 'name' => 'Commercial', 'link' => '/comm/index.php?mainmenu=commercial&leftmenu=', 'title' => "Commercial", 'level' => 0, - 'enabled' => $showmode = isVisibleToUserType( - $type_user, - $tmpentry = array( - 'enabled'=>(! empty($conf->propal->enabled) || - ! empty($conf->commande->enabled) || - ! empty($conf->supplier_order->enabled) || - ! empty($conf->supplier_proposal->enabled) || - ! empty($conf->contrat->enabled) || - ! empty($conf->ficheinter->enabled) - )?1:0, - 'perms'=>(! empty($user->rights->societe->lire) || ! empty($user->rights->societe->contact->lire)), - 'module'=>'propal|commande|supplier_order|contrat|ficheinter', - ), - $listofmodulesforexternal - ), + 'enabled' => $showmode = isVisibleToUserType($type_user, $tmpentry, $listofmodulesforexternal), 'target' => $atarget, 'mainmenu' => "commercial", 'leftmenu' => '', @@ -273,28 +255,25 @@ function print_eldy_menu($db, $atarget, $type_user, &$tabMenu, &$menu, $noout = ); // Billing - Financial + $tmpentry = array( + 'enabled'=>(! empty($conf->facture->enabled) || + ! empty($conf->don->enabled) || + ! empty($conf->tax->enabled) || + ! empty($conf->salaries->enabled) || + ! empty($conf->supplier_invoice->enabled) || + ! empty($conf->loan->enabled) + )?1:0, + 'perms'=>(! empty($user->rights->facture->lire) || ! empty($user->rights->don->contact->lire) + || ! empty($user->rights->tax->charges->lire) || ! empty($user->rights->salaries->read) + || ! empty($user->rights->fournisseur->facture->lire) || ! empty($user->rights->loan->read)), + 'module'=>'facture|supplier_invoice|don|tax|salaries|loan' + ); $menu_arr[] = array( 'name' => 'Compta', 'link' => '/compta/index.php?mainmenu=billing&leftmenu=', 'title' => "MenuFinancial", 'level' => 0, - 'enabled' => $showmode = isVisibleToUserType( - $type_user, - $tmpentry = array( - 'enabled'=>(! empty($conf->facture->enabled) || - ! empty($conf->don->enabled) || - ! empty($conf->tax->enabled) || - ! empty($conf->salaries->enabled) || - ! empty($conf->supplier_invoice->enabled) || - ! empty($conf->loan->enabled) - )?1:0, - 'perms'=>(! empty($user->rights->facture->lire) || ! empty($user->rights->don->contact->lire) - || ! empty($user->rights->tax->charges->lire) || ! empty($user->rights->salaries->read) - || ! empty($user->rights->fournisseur->facture->lire) || ! empty($user->rights->loan->read)), - 'module'=>'facture|supplier_invoice|don|tax|salaries|loan', - ), - $listofmodulesforexternal - ), + 'enabled' => $showmode = isVisibleToUserType($type_user, $tmpentry, $listofmodulesforexternal), 'target' => $atarget, 'mainmenu' => "billing", 'leftmenu' => '', @@ -309,20 +288,17 @@ function print_eldy_menu($db, $atarget, $type_user, &$tabMenu, &$menu, $noout = ); // Bank + $tmpentry = array( + 'enabled'=>(! empty($conf->banque->enabled) || ! empty($conf->prelevement->enabled)), + 'perms'=>(! empty($user->rights->banque->lire) || ! empty($user->rights->prelevement->lire)), + 'module'=>'banque|prelevement' + ); $menu_arr[] = array( 'name' => 'Bank', 'link' => '/compta/bank/list.php?mainmenu=bank&leftmenu=', 'title' => "MenuBankCash", 'level' => 0, - 'enabled' => $showmode = isVisibleToUserType( - $type_user, - $tmpentry = array( - 'enabled'=>(! empty($conf->banque->enabled) || ! empty($conf->prelevement->enabled)), - 'perms'=>(! empty($user->rights->banque->lire) || ! empty($user->rights->prelevement->lire)), - 'module'=>'banque|prelevement', - ), - $listofmodulesforexternal - ), + 'enabled' => $showmode = isVisibleToUserType($type_user, $tmpentry, $listofmodulesforexternal), 'target' => $atarget, 'mainmenu' => "bank", 'leftmenu' => '', @@ -339,20 +315,17 @@ function print_eldy_menu($db, $atarget, $type_user, &$tabMenu, &$menu, $noout = ); // Accounting + $tmpentry = array( + 'enabled'=>(! empty($conf->comptabilite->enabled) || ! empty($conf->accounting->enabled) || ! empty($conf->asset->enabled)), + 'perms'=>(! empty($user->rights->compta->resultat->lire) || ! empty($user->rights->accounting->mouvements->lire) || ! empty($user->rights->asset->read)), + 'comptabilite|accounting|asset' + ); $menu_arr[] = array( 'name' => 'Accounting', 'link' => '/accountancy/index.php?mainmenu=accountancy&leftmenu=', 'title' => "MenuAccountancy", 'level' => 0, - 'enabled' => $showmode = isVisibleToUserType( - $type_user, - $tmpentry = array( - 'enabled'=>(! empty($conf->comptabilite->enabled) || ! empty($conf->accounting->enabled) || ! empty($conf->asset->enabled)), - 'perms'=>(! empty($user->rights->compta->resultat->lire) || ! empty($user->rights->accounting->mouvements->lire) || ! empty($user->rights->asset->read)), - 'comptabilite|accounting', - ), - $listofmodulesforexternal - ), + 'enabled' => $showmode = isVisibleToUserType($type_user, $tmpentry, $listofmodulesforexternal), 'target' => $atarget, 'mainmenu' => "accountancy", 'leftmenu' => '', @@ -369,20 +342,17 @@ function print_eldy_menu($db, $atarget, $type_user, &$tabMenu, &$menu, $noout = ); // HRM + $tmpentry = array( + 'enabled'=>(! empty($conf->hrm->enabled) || ! empty($conf->holiday->enabled) || ! empty($conf->deplacement->enabled) || ! empty($conf->expensereport->enabled)), + 'perms'=>(! empty($user->rights->hrm->employee->read) || ! empty($user->rights->holiday->write) || ! empty($user->rights->deplacement->lire) || ! empty($user->rights->expensereport->lire)), + 'module'=>'hrm|holiday|deplacement|expensereport' + ); $menu_arr[] = array( 'name' => 'HRM', 'link' => '/hrm/index.php?mainmenu=hrm&leftmenu=', 'title' => "HRM", 'level' => 0, - 'enabled' => $showmode = isVisibleToUserType( - $type_user, - $tmpentry = array( - 'enabled'=>(! empty($conf->hrm->enabled) || ! empty($conf->holiday->enabled) || ! empty($conf->deplacement->enabled) || ! empty($conf->expensereport->enabled)), - 'perms'=>(! empty($user->rights->hrm->employee->read) || ! empty($user->rights->holiday->write) || ! empty($user->rights->deplacement->lire) || ! empty($user->rights->expensereport->lire)), - 'module'=>'hrm|holiday|deplacement|expensereport', - ), - $listofmodulesforexternal - ), + 'enabled' => $showmode = isVisibleToUserType($type_user, $tmpentry, $listofmodulesforexternal), 'target' => $atarget, 'mainmenu' => "hrm", 'leftmenu' => '', @@ -399,20 +369,17 @@ function print_eldy_menu($db, $atarget, $type_user, &$tabMenu, &$menu, $noout = ); // Tools + $tmpentry = array( + 'enabled'=>1, + 'perms'=>1, + 'module'=>'' + ); $menu_arr[] = array( 'name' => 'Tools', 'link' => '/core/tools.php?mainmenu=tools&leftmenu=', 'title' => "Tools", 'level' => 0, - 'enabled' => $showmode = isVisibleToUserType( - $type_user, - $tmpentry = array( - 'enabled'=>1, - 'perms'=>1, - 'module'=>'', - ), - $listofmodulesforexternal - ), + 'enabled' => $showmode = isVisibleToUserType($type_user, $tmpentry, $listofmodulesforexternal), 'target' => $atarget, 'mainmenu' => "tools", 'leftmenu' => '', @@ -641,7 +608,7 @@ function print_end_menu_array() */ function print_left_eldy_menu($db, $menu_array_before, $menu_array_after, &$tabMenu, &$menu, $noout = 0, $forcemainmenu = '', $forceleftmenu = '', $moredata = null) { - global $user,$conf,$langs,$dolibarr_main_db_name,$mysoc; + global $user, $conf, $langs, $dolibarr_main_db_name, $mysoc; //var_dump($tabMenu); @@ -1184,7 +1151,7 @@ function print_left_eldy_menu($db, $menu_array_before, $menu_array_after, &$tabM { $langs->load("companies"); - // Accounting Expert + // Accounting (Double entries) if (! empty($conf->accounting->enabled)) { $langs->load("accountancy"); @@ -1335,42 +1302,6 @@ function print_left_eldy_menu($db, $menu_array_before, $menu_array_after, &$tabM } } - // Accountancy (simple) - if (! empty($conf->comptabilite->enabled)) - { - $langs->load("compta"); - - // Bilan, resultats - $newmenu->add("/compta/resultat/index.php?leftmenu=report&mainmenu=accountancy", $langs->trans("Reportings"), 0, $user->rights->compta->resultat->lire, '', $mainmenu, 'ca'); - - if ($usemenuhider || empty($leftmenu) || preg_match('/report/', $leftmenu)) { - $newmenu->add("/compta/resultat/index.php?leftmenu=report", $langs->trans("MenuReportInOut"), 1, $user->rights->compta->resultat->lire); - $newmenu->add("/compta/resultat/clientfourn.php?leftmenu=report", $langs->trans("ByCompanies"), 2, $user->rights->compta->resultat->lire); - /* On verra ca avec module compabilite expert - $newmenu->add("/compta/resultat/compteres.php?leftmenu=report","Compte de resultat",2,$user->rights->compta->resultat->lire); - $newmenu->add("/compta/resultat/bilan.php?leftmenu=report","Bilan",2,$user->rights->compta->resultat->lire); - */ - $newmenu->add("/compta/stats/index.php?leftmenu=report", $langs->trans("ReportTurnover"), 1, $user->rights->compta->resultat->lire); - - /* - $newmenu->add("/compta/stats/cumul.php?leftmenu=report","Cumule",2,$user->rights->compta->resultat->lire); - if (! empty($conf->propal->enabled)) { - $newmenu->add("/compta/stats/prev.php?leftmenu=report","Previsionnel",2,$user->rights->compta->resultat->lire); - $newmenu->add("/compta/stats/comp.php?leftmenu=report","Transforme",2,$user->rights->compta->resultat->lire); - } - */ - $newmenu->add("/compta/stats/casoc.php?leftmenu=report", $langs->trans("ByCompanies"), 2, $user->rights->compta->resultat->lire); - $newmenu->add("/compta/stats/cabyuser.php?leftmenu=report", $langs->trans("ByUsers"), 2, $user->rights->compta->resultat->lire); - $newmenu->add("/compta/stats/cabyprodserv.php?leftmenu=report", $langs->trans("ByProductsAndServices"), 2, $user->rights->compta->resultat->lire); - $newmenu->add("/compta/stats/byratecountry.php?leftmenu=report", $langs->trans("ByVatRate"), 2, $user->rights->compta->resultat->lire); - - // Journaux - $newmenu->add("/compta/journal/sellsjournal.php?leftmenu=report", $langs->trans("SellsJournal"), 1, $user->rights->compta->resultat->lire, '', '', '', 50); - $newmenu->add("/compta/journal/purchasesjournal.php?leftmenu=report", $langs->trans("PurchasesJournal"), 1, $user->rights->compta->resultat->lire, '', '', '', 51); - } - //if ($leftmenu=="ca") $newmenu->add("/compta/journaux/index.php?leftmenu=ca",$langs->trans("Journaux"),1,$user->rights->compta->resultat->lire||$user->rights->accounting->comptarapport->lire); - } - // Configuration $newmenu->add("/accountancy/index.php?leftmenu=accountancy_admin", $langs->trans("Setup"), 0, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin', 1); if ($usemenuhider || empty($leftmenu) || preg_match('/accountancy_admin/', $leftmenu)) { @@ -1402,18 +1333,54 @@ function print_left_eldy_menu($db, $menu_array_before, $menu_array_after, &$tabM $newmenu->add("/accountancy/admin/closure.php?mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("MenuClosureAccounts"), 1, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_closure', 120); $newmenu->add("/accountancy/admin/export.php?mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("ExportOptions"), 1, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_export', 130); } - } + } + // Accountancy (simple) + if (! empty($conf->comptabilite->enabled)) + { + $langs->load("compta"); + + // Bilan, resultats + $newmenu->add("/compta/resultat/index.php?leftmenu=report&mainmenu=accountancy", $langs->trans("Reportings"), 0, $user->rights->compta->resultat->lire, '', $mainmenu, 'ca'); + + if ($usemenuhider || empty($leftmenu) || preg_match('/report/', $leftmenu)) { + $newmenu->add("/compta/resultat/index.php?leftmenu=report", $langs->trans("MenuReportInOut"), 1, $user->rights->compta->resultat->lire); + $newmenu->add("/compta/resultat/clientfourn.php?leftmenu=report", $langs->trans("ByCompanies"), 2, $user->rights->compta->resultat->lire); + /* On verra ca avec module compabilite expert + $newmenu->add("/compta/resultat/compteres.php?leftmenu=report","Compte de resultat",2,$user->rights->compta->resultat->lire); + $newmenu->add("/compta/resultat/bilan.php?leftmenu=report","Bilan",2,$user->rights->compta->resultat->lire); + */ + $newmenu->add("/compta/stats/index.php?leftmenu=report", $langs->trans("ReportTurnover"), 1, $user->rights->compta->resultat->lire); + + /* + $newmenu->add("/compta/stats/cumul.php?leftmenu=report","Cumule",2,$user->rights->compta->resultat->lire); + if (! empty($conf->propal->enabled)) { + $newmenu->add("/compta/stats/prev.php?leftmenu=report","Previsionnel",2,$user->rights->compta->resultat->lire); + $newmenu->add("/compta/stats/comp.php?leftmenu=report","Transforme",2,$user->rights->compta->resultat->lire); + } + */ + $newmenu->add("/compta/stats/casoc.php?leftmenu=report", $langs->trans("ByCompanies"), 2, $user->rights->compta->resultat->lire); + $newmenu->add("/compta/stats/cabyuser.php?leftmenu=report", $langs->trans("ByUsers"), 2, $user->rights->compta->resultat->lire); + $newmenu->add("/compta/stats/cabyprodserv.php?leftmenu=report", $langs->trans("ByProductsAndServices"), 2, $user->rights->compta->resultat->lire); + $newmenu->add("/compta/stats/byratecountry.php?leftmenu=report", $langs->trans("ByVatRate"), 2, $user->rights->compta->resultat->lire); + + // Journaux + $newmenu->add("/compta/journal/sellsjournal.php?leftmenu=report", $langs->trans("SellsJournal"), 1, $user->rights->compta->resultat->lire, '', '', '', 50); + $newmenu->add("/compta/journal/purchasesjournal.php?leftmenu=report", $langs->trans("PurchasesJournal"), 1, $user->rights->compta->resultat->lire, '', '', '', 51); + } + //if ($leftmenu=="ca") $newmenu->add("/compta/journaux/index.php?leftmenu=ca",$langs->trans("Journaux"),1,$user->rights->compta->resultat->lire||$user->rights->accounting->comptarapport->lire); + } + // Assets if (! empty($conf->asset->enabled)) { $langs->load("assets"); $newmenu->add("/asset/list.php?leftmenu=asset&mainmenu=accountancy", $langs->trans("MenuAssets"), 0, $user->rights->asset->read, '', $mainmenu, 'asset'); - $newmenu->add("/asset/card.php?action=create", $langs->trans("MenuNewAsset"), 1, $user->rights->asset->write); + $newmenu->add("/asset/card.php?leftmenu=asset&action=create", $langs->trans("MenuNewAsset"), 1, $user->rights->asset->write); $newmenu->add("/asset/list.php?leftmenu=asset&mainmenu=accountancy", $langs->trans("MenuListAssets"), 1, $user->rights->asset->read); $newmenu->add("/asset/type.php?leftmenu=asset_type", $langs->trans("MenuTypeAssets"), 1, $user->rights->asset->read, '', $mainmenu, 'asset_type'); if ($usemenuhider || empty($leftmenu) || preg_match('/asset_type/', $leftmenu)) { - $newmenu->add("/asset/type.php?leftmenu=asset_type&action=create", $langs->trans("MenuNewTypeAssets"), 2, $user->rights->asset->write); + $newmenu->add("/asset/type.php?leftmenu=asset_type&action=create", $langs->trans("MenuNewTypeAssets"), 2, $user->rights->asset->configurer); $newmenu->add("/asset/type.php?leftmenu=asset_type", $langs->trans("MenuListTypeAssets"), 2, $user->rights->asset->read); } } @@ -1638,7 +1605,7 @@ function print_left_eldy_menu($db, $menu_array_before, $menu_array_after, &$tabM $tmpentry = array( 'enabled'=>(! empty($conf->projet->enabled)), 'perms'=>(! empty($user->rights->projet->lire)), - 'module'=>'projet', + 'module'=>'projet' ); $showmode=isVisibleToUserType($type_user, $tmpentry, $listofmodulesforexternal); diff --git a/htdocs/core/modules/bank/doc/pdf_sepamandate.modules.php b/htdocs/core/modules/bank/doc/pdf_sepamandate.modules.php index bbd5858192c..1c10871eae1 100644 --- a/htdocs/core/modules/bank/doc/pdf_sepamandate.modules.php +++ b/htdocs/core/modules/bank/doc/pdf_sepamandate.modules.php @@ -43,7 +43,7 @@ class pdf_sepamandate extends ModeleBankAccountDoc /** * Dolibarr version of the loaded document - * @public string + * @var string */ public $version = 'dolibarr'; diff --git a/htdocs/core/modules/barcode/doc/phpbarcode.modules.php b/htdocs/core/modules/barcode/doc/phpbarcode.modules.php index 19744177e40..96cf345ff09 100644 --- a/htdocs/core/modules/barcode/doc/phpbarcode.modules.php +++ b/htdocs/core/modules/barcode/doc/phpbarcode.modules.php @@ -34,7 +34,7 @@ class modPhpbarcode extends ModeleBarCode { /** * Dolibarr version of the loaded document - * @public string + * @var string */ public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' diff --git a/htdocs/core/modules/barcode/doc/tcpdfbarcode.modules.php b/htdocs/core/modules/barcode/doc/tcpdfbarcode.modules.php index 17793a5dfd4..1b39fe16095 100644 --- a/htdocs/core/modules/barcode/doc/tcpdfbarcode.modules.php +++ b/htdocs/core/modules/barcode/doc/tcpdfbarcode.modules.php @@ -33,7 +33,7 @@ class modTcpdfbarcode extends ModeleBarCode { /** * Dolibarr version of the loaded document - * @public string + * @var string */ public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' diff --git a/htdocs/core/modules/barcode/mod_barcode_product_standard.php b/htdocs/core/modules/barcode/mod_barcode_product_standard.php index 516df2ee6ef..b5f0e76ef3f 100644 --- a/htdocs/core/modules/barcode/mod_barcode_product_standard.php +++ b/htdocs/core/modules/barcode/mod_barcode_product_standard.php @@ -45,7 +45,7 @@ class mod_barcode_product_standard extends ModeleNumRefBarCode /** * Dolibarr version of the loaded document - * @public string + * @var string */ public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' diff --git a/htdocs/core/modules/bom/mod_bom_advanced.php b/htdocs/core/modules/bom/mod_bom_advanced.php index f6492b3c78f..ba5c437f0a0 100644 --- a/htdocs/core/modules/bom/mod_bom_advanced.php +++ b/htdocs/core/modules/bom/mod_bom_advanced.php @@ -1,8 +1,9 @@ - * Copyright (C) 2004-2007 Laurent Destailleur - * Copyright (C) 2005-2009 Regis Houssin - * Copyright (C) 2008 Raphael Bertrand (Resultic) +/* Copyright (C) 2003-2007 Rodolphe Quiedeville + * Copyright (C) 2004-2007 Laurent Destailleur + * Copyright (C) 2005-2009 Regis Houssin + * Copyright (C) 2008 Raphael Bertrand (Resultic) + * Copyright (C) 2019 Frédéric France * * 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 @@ -35,7 +36,7 @@ class mod_bom_advanced extends ModeleNumRefboms { /** * Dolibarr version of the loaded document - * @public string + * @var string */ public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' @@ -57,11 +58,11 @@ class mod_bom_advanced extends ModeleNumRefboms */ public function info() { - global $conf, $langs; + global $conf, $langs, $db; $langs->load("bills"); - $form = new Form($this->db); + $form = new Form($db); $texte = $langs->trans('GenericNumRefModelDesc')."
\n"; $texte.= ''; diff --git a/htdocs/core/modules/bom/mod_bom_standard.php b/htdocs/core/modules/bom/mod_bom_standard.php index 00a20898712..39af3ecc7e1 100644 --- a/htdocs/core/modules/bom/mod_bom_standard.php +++ b/htdocs/core/modules/bom/mod_bom_standard.php @@ -31,7 +31,7 @@ class mod_bom_standard extends ModeleNumRefboms { /** * Dolibarr version of the loaded document - * @public string + * @var string */ public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' diff --git a/htdocs/core/modules/cheque/mod_chequereceipt_mint.php b/htdocs/core/modules/cheque/mod_chequereceipt_mint.php index 0183300c4ad..0169ce04a70 100644 --- a/htdocs/core/modules/cheque/mod_chequereceipt_mint.php +++ b/htdocs/core/modules/cheque/mod_chequereceipt_mint.php @@ -31,7 +31,7 @@ class mod_chequereceipt_mint extends ModeleNumRefChequeReceipts { /** * Dolibarr version of the loaded document - * @public string + * @var string */ public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' diff --git a/htdocs/core/modules/cheque/mod_chequereceipt_thyme.php b/htdocs/core/modules/cheque/mod_chequereceipt_thyme.php index 7ec2a775b96..7ff3bc6f6cc 100644 --- a/htdocs/core/modules/cheque/mod_chequereceipt_thyme.php +++ b/htdocs/core/modules/cheque/mod_chequereceipt_thyme.php @@ -1,5 +1,6 @@ +/* Copyright (C) 2015 Juanjo Menent + * Copyright (C) 2019 Frédéric France * * 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 @@ -32,7 +33,7 @@ class mod_chequereceipt_thyme extends ModeleNumRefChequeReceipts { /** * Dolibarr version of the loaded document - * @public string + * @var string */ public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' @@ -51,11 +52,11 @@ class mod_chequereceipt_thyme extends ModeleNumRefChequeReceipts */ public function info() { - global $conf, $langs; + global $conf, $langs, $db; $langs->load("bills"); - $form = new Form($this->db); + $form = new Form($db); $texte = $langs->trans('GenericNumRefModelDesc')."
\n"; $texte.= ''; diff --git a/htdocs/core/modules/commande/doc/pdf_einstein.modules.php b/htdocs/core/modules/commande/doc/pdf_einstein.modules.php index e076245f3be..9d73384cf3a 100644 --- a/htdocs/core/modules/commande/doc/pdf_einstein.modules.php +++ b/htdocs/core/modules/commande/doc/pdf_einstein.modules.php @@ -75,7 +75,7 @@ class pdf_einstein extends ModelePDFCommandes /** * Dolibarr version of the loaded document - * @public string + * @var string */ public $version = 'dolibarr'; @@ -379,7 +379,7 @@ class pdf_einstein extends ModelePDFCommandes complete_substitutions_array($substitutionarray, $outputlangs, $object); $notetoshow = make_substitutions($notetoshow, $substitutionarray, $outputlangs); $notetoshow = convertBackOfficeMediasLinksToPublicLinks($notetoshow); - + $pdf->SetFont('', '', $default_font_size - 1); $pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top-1, dol_htmlentitiesbr($notetoshow), 0, 1); $nexY = $pdf->GetY(); diff --git a/htdocs/core/modules/commande/mod_commande_marbre.php b/htdocs/core/modules/commande/mod_commande_marbre.php index 620ab210f31..28d488eb6fb 100644 --- a/htdocs/core/modules/commande/mod_commande_marbre.php +++ b/htdocs/core/modules/commande/mod_commande_marbre.php @@ -31,7 +31,7 @@ class mod_commande_marbre extends ModeleNumRefCommandes { /** * Dolibarr version of the loaded document - * @public string + * @var string */ public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' diff --git a/htdocs/core/modules/commande/mod_commande_saphir.php b/htdocs/core/modules/commande/mod_commande_saphir.php index fbe741ac2f8..8c96c237a0f 100644 --- a/htdocs/core/modules/commande/mod_commande_saphir.php +++ b/htdocs/core/modules/commande/mod_commande_saphir.php @@ -1,8 +1,9 @@ - * Copyright (C) 2004-2007 Laurent Destailleur - * Copyright (C) 2005-2009 Regis Houssin - * Copyright (C) 2008 Raphael Bertrand (Resultic) +/* Copyright (C) 2003-2007 Rodolphe Quiedeville + * Copyright (C) 2004-2007 Laurent Destailleur + * Copyright (C) 2005-2009 Regis Houssin + * Copyright (C) 2008 Raphael Bertrand (Resultic) + * Copyright (C) 2019 Frédéric France * * 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 @@ -35,7 +36,7 @@ class mod_commande_saphir extends ModeleNumRefCommandes { /** * Dolibarr version of the loaded document - * @public string + * @var string */ public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' @@ -57,11 +58,11 @@ class mod_commande_saphir extends ModeleNumRefCommandes */ public function info() { - global $conf, $langs; + global $conf, $langs, $db; $langs->load("bills"); - $form = new Form($this->db); + $form = new Form($db); $texte = $langs->trans('GenericNumRefModelDesc')."
\n"; $texte.= ''; diff --git a/htdocs/core/modules/contract/doc/pdf_strato.modules.php b/htdocs/core/modules/contract/doc/pdf_strato.modules.php index e592e893437..03dae9cbe5e 100644 --- a/htdocs/core/modules/contract/doc/pdf_strato.modules.php +++ b/htdocs/core/modules/contract/doc/pdf_strato.modules.php @@ -68,7 +68,7 @@ class pdf_strato extends ModelePDFContract /** * Dolibarr version of the loaded document - * @public string + * @var string */ public $version = 'dolibarr'; diff --git a/htdocs/core/modules/contract/mod_contract_magre.php b/htdocs/core/modules/contract/mod_contract_magre.php index 97f07b677dd..1ee6d36803e 100644 --- a/htdocs/core/modules/contract/mod_contract_magre.php +++ b/htdocs/core/modules/contract/mod_contract_magre.php @@ -1,5 +1,6 @@ +/* Copyright (C) 2011 Juanjo Menent + * Copyright (C) 2019 Frédéric France * * 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 @@ -31,7 +32,7 @@ class mod_contract_magre extends ModelNumRefContracts { /** * Dolibarr version of the loaded document - * @public string + * @var string */ public $version = 'dolibarr'; @@ -61,11 +62,11 @@ class mod_contract_magre extends ModelNumRefContracts */ public function info() { - global $conf,$langs; + global $conf,$langs, $db; $langs->load("bills"); - $form = new Form($this->db); + $form = new Form($db); $texte = $langs->trans('GenericNumRefModelDesc')."
\n"; $texte.= ''; diff --git a/htdocs/core/modules/contract/mod_contract_olive.php b/htdocs/core/modules/contract/mod_contract_olive.php index d87e383d109..612c13cf99c 100644 --- a/htdocs/core/modules/contract/mod_contract_olive.php +++ b/htdocs/core/modules/contract/mod_contract_olive.php @@ -54,7 +54,7 @@ class mod_contract_olive extends ModelNumRefContracts /** * Dolibarr version of the loaded document - * @public string + * @var string */ public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' diff --git a/htdocs/core/modules/contract/mod_contract_serpis.php b/htdocs/core/modules/contract/mod_contract_serpis.php index e62386fbca7..dd468402585 100644 --- a/htdocs/core/modules/contract/mod_contract_serpis.php +++ b/htdocs/core/modules/contract/mod_contract_serpis.php @@ -30,7 +30,7 @@ class mod_contract_serpis extends ModelNumRefContracts { /** * Dolibarr version of the loaded document - * @public string + * @var string */ public $version = 'dolibarr'; diff --git a/htdocs/core/modules/expedition/doc/pdf_espadon.modules.php b/htdocs/core/modules/expedition/doc/pdf_espadon.modules.php index f84afc7e55c..87f04dca016 100644 --- a/htdocs/core/modules/expedition/doc/pdf_espadon.modules.php +++ b/htdocs/core/modules/expedition/doc/pdf_espadon.modules.php @@ -64,7 +64,7 @@ class pdf_espadon extends ModelePdfExpedition /** * Dolibarr version of the loaded document - * @public string + * @var string */ public $version = 'dolibarr'; diff --git a/htdocs/core/modules/expedition/doc/pdf_merou.modules.php b/htdocs/core/modules/expedition/doc/pdf_merou.modules.php index be4a25a1a7d..8696bc21a02 100644 --- a/htdocs/core/modules/expedition/doc/pdf_merou.modules.php +++ b/htdocs/core/modules/expedition/doc/pdf_merou.modules.php @@ -65,7 +65,7 @@ class pdf_merou extends ModelePdfExpedition /** * Dolibarr version of the loaded document - * @public string + * @var string */ public $version = 'dolibarr'; diff --git a/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php b/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php index 3b3d79adb92..e8de6ffdb73 100644 --- a/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php +++ b/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php @@ -64,7 +64,7 @@ class pdf_rouget extends ModelePdfExpedition /** * Dolibarr version of the loaded document - * @public string + * @var string */ public $version = 'dolibarr'; diff --git a/htdocs/core/modules/expedition/mod_expedition_ribera.php b/htdocs/core/modules/expedition/mod_expedition_ribera.php index fd2a5b5612c..4ffde92649e 100644 --- a/htdocs/core/modules/expedition/mod_expedition_ribera.php +++ b/htdocs/core/modules/expedition/mod_expedition_ribera.php @@ -1,5 +1,6 @@ +/* Copyright (C) 2011 Juanjo Menent + * Copyright (C) 2019 Frédéric France * * 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 @@ -31,7 +32,7 @@ class mod_expedition_ribera extends ModelNumRefExpedition { /** * Dolibarr version of the loaded document - * @public string + * @var string */ public $version = 'dolibarr'; @@ -59,11 +60,11 @@ class mod_expedition_ribera extends ModelNumRefExpedition */ public function info() { - global $conf, $langs; + global $conf, $langs, $db; $langs->load("bills"); - $form = new Form($this->db); + $form = new Form($db); $texte = $langs->trans('GenericNumRefModelDesc')."
\n"; $texte.= ''; diff --git a/htdocs/core/modules/expedition/mod_expedition_safor.php b/htdocs/core/modules/expedition/mod_expedition_safor.php index 4cfada1740c..08e0268ef7e 100644 --- a/htdocs/core/modules/expedition/mod_expedition_safor.php +++ b/htdocs/core/modules/expedition/mod_expedition_safor.php @@ -30,7 +30,7 @@ class mod_expedition_safor extends ModelNumRefExpedition { /** * Dolibarr version of the loaded document - * @public string + * @var string */ public $version = 'dolibarr'; diff --git a/htdocs/core/modules/expensereport/doc/pdf_standard.modules.php b/htdocs/core/modules/expensereport/doc/pdf_standard.modules.php index 96665e1b819..ff6a0abb72b 100644 --- a/htdocs/core/modules/expensereport/doc/pdf_standard.modules.php +++ b/htdocs/core/modules/expensereport/doc/pdf_standard.modules.php @@ -112,7 +112,7 @@ class pdf_standard extends ModeleExpenseReport /** * Issuer - * @var Company object that emits + * @var Societe */ public $emetteur; @@ -326,7 +326,7 @@ class pdf_standard extends ModeleExpenseReport complete_substitutions_array($substitutionarray, $outputlangs, $object); $notetoshow = make_substitutions($notetoshow, $substitutionarray, $outputlangs); $notetoshow = convertBackOfficeMediasLinksToPublicLinks($notetoshow); - + $tab_top = 95; $pdf->SetFont('', '', $default_font_size - 1); @@ -767,11 +767,10 @@ class pdf_standard extends ModeleExpenseReport $pdf->MultiCell(80, 4, $expense_receiver, 0, 'L'); } - if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->marge_gauche; - // Show recipient $posy=50; - $posx=10; + $posx=100; + if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->marge_gauche; // Show recipient frame $pdf->SetTextColor(0, 0, 0); @@ -1054,18 +1053,18 @@ class pdf_standard extends ModeleExpenseReport $pdf->SetXY($tab3_posx+17, $tab3_top+$y); $pdf->MultiCell(15, 3, price($totalpaid), 0, 'R', 0); $pdf->SetXY($tab3_posx+35, $tab3_top+$y); - $pdf->MultiCell(30, 4, $outputlangs->trans("AlreadyPaid"), 0, 'L', 0); + $pdf->MultiCell(30, 4, $outputlangs->transnoentitiesnoconv("AlreadyPaid"), 0, 'L', 0); $y+=$tab3_height-2; $pdf->SetXY($tab3_posx+17, $tab3_top+$y); $pdf->MultiCell(15, 3, price($object->total_ttc), 0, 'R', 0); $pdf->SetXY($tab3_posx+35, $tab3_top+$y); - $pdf->MultiCell(30, 4, $outputlangs->trans("AmountExpected"), 0, 'L', 0); + $pdf->MultiCell(30, 4, $outputlangs->transnoentitiesnoconv("AmountExpected"), 0, 'L', 0); $y+=$tab3_height-2; $remaintopay = $object->total_ttc - $totalpaid; $pdf->SetXY($tab3_posx+17, $tab3_top+$y); $pdf->MultiCell(15, 3, price($remaintopay), 0, 'R', 0); $pdf->SetXY($tab3_posx+35, $tab3_top+$y); - $pdf->MultiCell(30, 4, $outputlangs->trans("RemainderToPay"), 0, 'L', 0); + $pdf->MultiCell(30, 4, $outputlangs->transnoentitiesnoconv("RemainderToPay"), 0, 'L', 0); } } else diff --git a/htdocs/core/modules/expensereport/mod_expensereport_jade.php b/htdocs/core/modules/expensereport/mod_expensereport_jade.php index a878fb1325c..176c3a46dcb 100644 --- a/htdocs/core/modules/expensereport/mod_expensereport_jade.php +++ b/htdocs/core/modules/expensereport/mod_expensereport_jade.php @@ -30,7 +30,7 @@ class mod_expensereport_jade extends ModeleNumRefExpenseReport { /** * Dolibarr version of the loaded document - * @public string + * @var string */ public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' diff --git a/htdocs/core/modules/expensereport/mod_expensereport_sand.php b/htdocs/core/modules/expensereport/mod_expensereport_sand.php index b0749462d7e..c0a5aa0a031 100644 --- a/htdocs/core/modules/expensereport/mod_expensereport_sand.php +++ b/htdocs/core/modules/expensereport/mod_expensereport_sand.php @@ -32,7 +32,7 @@ class mod_expensereport_sand extends ModeleNumRefExpenseReport { /** * Dolibarr version of the loaded document - * @public string + * @var string */ public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' diff --git a/htdocs/core/modules/export/export_csv.modules.php b/htdocs/core/modules/export/export_csv.modules.php index 5bdc2f384ac..c3c8431962e 100644 --- a/htdocs/core/modules/export/export_csv.modules.php +++ b/htdocs/core/modules/export/export_csv.modules.php @@ -33,7 +33,7 @@ set_time_limit(0); class ExportCsv extends ModeleExports { /** - * @var int ID + * @var string ID ex: csv, tsv, excel... */ public $id; @@ -46,7 +46,7 @@ class ExportCsv extends ModeleExports /** * Dolibarr version of the loaded document - * @public string + * @var string */ public $version = 'dolibarr'; diff --git a/htdocs/core/modules/export/export_excel.modules.php b/htdocs/core/modules/export/export_excel.modules.php index 28357c0a09a..3eafc454530 100644 --- a/htdocs/core/modules/export/export_excel.modules.php +++ b/htdocs/core/modules/export/export_excel.modules.php @@ -33,7 +33,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; class ExportExcel extends ModeleExports { /** - * @var int ID + * @var string ID */ public $id; @@ -46,7 +46,7 @@ class ExportExcel extends ModeleExports /** * Dolibarr version of the loaded document - * @public string + * @var string */ public $version = 'dolibarr'; diff --git a/htdocs/core/modules/export/export_excel2007.modules.php b/htdocs/core/modules/export/export_excel2007.modules.php index 1b6b973632a..e33849427b1 100644 --- a/htdocs/core/modules/export/export_excel2007.modules.php +++ b/htdocs/core/modules/export/export_excel2007.modules.php @@ -34,7 +34,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; class ExportExcel2007 extends ExportExcel { /** - * @var int ID + * @var string ID */ public $id; @@ -47,7 +47,7 @@ class ExportExcel2007 extends ExportExcel /** * Dolibarr version of the loaded document - * @public string + * @var string */ public $version = 'dolibarr'; diff --git a/htdocs/core/modules/export/export_excel2007new.modules.php b/htdocs/core/modules/export/export_excel2007new.modules.php index 10dbb2fa28c..32b6029a294 100644 --- a/htdocs/core/modules/export/export_excel2007new.modules.php +++ b/htdocs/core/modules/export/export_excel2007new.modules.php @@ -35,7 +35,7 @@ use PhpOffice\PhpSpreadsheet\Writer\Xlsx; class ExportExcel2007new extends ModeleExports { /** - * @var int ID + * @var string ID */ public $id; @@ -48,7 +48,7 @@ class ExportExcel2007new extends ModeleExports /** * Dolibarr version of the loaded document - * @public string + * @var string */ public $version = 'dolibarr'; diff --git a/htdocs/core/modules/export/export_tsv.modules.php b/htdocs/core/modules/export/export_tsv.modules.php index 33d7d860368..b40da3cd539 100644 --- a/htdocs/core/modules/export/export_tsv.modules.php +++ b/htdocs/core/modules/export/export_tsv.modules.php @@ -32,7 +32,7 @@ require_once DOL_DOCUMENT_ROOT .'/core/modules/export/modules_export.php'; class ExportTsv extends ModeleExports { /** - * @var int ID + * @var string ID */ public $id; @@ -45,7 +45,7 @@ class ExportTsv extends ModeleExports /** * Dolibarr version of the loaded document - * @public string + * @var string */ public $version = 'dolibarr'; diff --git a/htdocs/core/modules/facture/mod_facture_mars.php b/htdocs/core/modules/facture/mod_facture_mars.php index 0933d38306c..752a80669c5 100644 --- a/htdocs/core/modules/facture/mod_facture_mars.php +++ b/htdocs/core/modules/facture/mod_facture_mars.php @@ -32,7 +32,7 @@ class mod_facture_mars extends ModeleNumRefFactures { /** * Dolibarr version of the loaded document - * @public string + * @var string */ public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' diff --git a/htdocs/core/modules/facture/mod_facture_mercure.php b/htdocs/core/modules/facture/mod_facture_mercure.php index b6f36f69e9d..8c921d982bf 100644 --- a/htdocs/core/modules/facture/mod_facture_mercure.php +++ b/htdocs/core/modules/facture/mod_facture_mercure.php @@ -35,7 +35,7 @@ class mod_facture_mercure extends ModeleNumRefFactures { /** * Dolibarr version of the loaded document - * @public string + * @var string */ public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' diff --git a/htdocs/core/modules/fichinter/mod_arctic.php b/htdocs/core/modules/fichinter/mod_arctic.php index db7b2febbb2..1902ffc70af 100644 --- a/htdocs/core/modules/fichinter/mod_arctic.php +++ b/htdocs/core/modules/fichinter/mod_arctic.php @@ -34,7 +34,7 @@ class mod_arctic extends ModeleNumRefFicheinter { /** * Dolibarr version of the loaded document - * @public string + * @var string */ public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' diff --git a/htdocs/core/modules/fichinter/mod_pacific.php b/htdocs/core/modules/fichinter/mod_pacific.php index 4f66d6940f1..7d636a8b8e0 100644 --- a/htdocs/core/modules/fichinter/mod_pacific.php +++ b/htdocs/core/modules/fichinter/mod_pacific.php @@ -32,7 +32,7 @@ class mod_pacific extends ModeleNumRefFicheinter { /** * Dolibarr version of the loaded document - * @public string + * @var string */ public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' diff --git a/htdocs/core/modules/holiday/mod_holiday_immaculate.php b/htdocs/core/modules/holiday/mod_holiday_immaculate.php index 9d1fa644c0a..890c6b933c6 100644 --- a/htdocs/core/modules/holiday/mod_holiday_immaculate.php +++ b/htdocs/core/modules/holiday/mod_holiday_immaculate.php @@ -32,7 +32,7 @@ class mod_holiday_immaculate extends ModelNumRefHolidays { /** * Dolibarr version of the loaded document - * @public string + * @var string */ public $version = 'dolibarr'; diff --git a/htdocs/core/modules/holiday/mod_holiday_madonna.php b/htdocs/core/modules/holiday/mod_holiday_madonna.php index 187eb19d80d..d214d8d79dd 100644 --- a/htdocs/core/modules/holiday/mod_holiday_madonna.php +++ b/htdocs/core/modules/holiday/mod_holiday_madonna.php @@ -31,7 +31,7 @@ class mod_holiday_madonna extends ModelNumRefHolidays { /** * Dolibarr version of the loaded document - * @public string + * @var string */ public $version = 'dolibarr'; diff --git a/htdocs/core/modules/import/import_csv.modules.php b/htdocs/core/modules/import/import_csv.modules.php index dbb8fadfe12..6eba74b17e4 100644 --- a/htdocs/core/modules/import/import_csv.modules.php +++ b/htdocs/core/modules/import/import_csv.modules.php @@ -64,7 +64,7 @@ class ImportCsv extends ModeleImports /** * Dolibarr version of driver - * @public string + * @var string */ public $version = 'dolibarr'; diff --git a/htdocs/core/modules/import/import_xlsx.modules.php b/htdocs/core/modules/import/import_xlsx.modules.php index 44134281fb4..e83e22bd8ca 100644 --- a/htdocs/core/modules/import/import_xlsx.modules.php +++ b/htdocs/core/modules/import/import_xlsx.modules.php @@ -64,7 +64,7 @@ class ImportXlsx extends ModeleImports /** * Dolibarr version of driver - * @public string + * @var string */ public $version = 'dolibarr'; diff --git a/htdocs/core/modules/import/modules_import.php b/htdocs/core/modules/import/modules_import.php index 7595c3c6c52..d901a53865e 100644 --- a/htdocs/core/modules/import/modules_import.php +++ b/htdocs/core/modules/import/modules_import.php @@ -56,7 +56,7 @@ class ModeleImports /** * Dolibarr version of driver - * @public string + * @var string */ public $version = 'dolibarr'; diff --git a/htdocs/core/modules/livraison/mod_livraison_jade.php b/htdocs/core/modules/livraison/mod_livraison_jade.php index 2241d9ba678..531ff26a354 100644 --- a/htdocs/core/modules/livraison/mod_livraison_jade.php +++ b/htdocs/core/modules/livraison/mod_livraison_jade.php @@ -36,7 +36,7 @@ class mod_livraison_jade extends ModeleNumRefDeliveryOrder { /** * Dolibarr version of the loaded document - * @public string + * @var string */ public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' diff --git a/htdocs/core/modules/livraison/mod_livraison_saphir.php b/htdocs/core/modules/livraison/mod_livraison_saphir.php index 9fcbff04d6f..f05900600c2 100644 --- a/htdocs/core/modules/livraison/mod_livraison_saphir.php +++ b/htdocs/core/modules/livraison/mod_livraison_saphir.php @@ -33,7 +33,7 @@ class mod_livraison_saphir extends ModeleNumRefDeliveryOrder { /** * Dolibarr version of the loaded document - * @public string + * @var string */ public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' diff --git a/htdocs/core/modules/modAsset.class.php b/htdocs/core/modules/modAsset.class.php index d856ad05091..71ce8c128e2 100644 --- a/htdocs/core/modules/modAsset.class.php +++ b/htdocs/core/modules/modAsset.class.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2004-2019 Laurent Destailleur * Copyright (C) 2018 Alexandre Spangaro * * This program is free software; you can redistribute it and/or modify @@ -39,15 +39,13 @@ class modAsset extends DolibarrModules */ public function __construct($db) { - global $langs,$conf; + global $langs, $conf; $this->db = $db; // Id for module (must be unique). // Use here a free id (See in Home -> System information -> Dolibarr for list of used modules id). $this->numero = 51000; // TODO Go on page https://wiki.dolibarr.org/index.php/List_of_modules_id to reserve id number for your module - // Key text used to identify module (for permissions, menus, etc...) - $this->rights_class = 'asset'; // Family can be 'crm','financial','hr','projects','products','ecm','technic','interface','other' // It is used to group modules by family in module setup page @@ -147,20 +145,6 @@ class modAsset extends DolibarrModules // Dictionaries $this->dictionaries=array(); - /* Example: - $this->dictionaries=array( - 'langs'=>'mylangfile@assets', - '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->assets->enabled,$conf->assets->enabled,$conf->assets->enabled) // Condition to show each dictionary - ); - */ // Boxes/Widgets @@ -184,132 +168,44 @@ class modAsset extends DolibarrModules // Permissions $this->rights = array(); // Permission array used by this module + $this->rights_class = 'asset'; + $r=0; - $r=0; - $this->rights[$r][0] = $this->numero + $r; // Permission id (must not be already used) + $r++; + $this->rights[$r][0] = 51001; // Permission id (must not be already used) $this->rights[$r][1] = 'Read assets'; // Permission label - $this->rights[$r][3] = 1; // Permission by default for new user (0/1) + $this->rights[$r][2] = 'r'; + $this->rights[$r][3] = 0; // Permission by default for new user (0/1) $this->rights[$r][4] = 'read'; // In php code, permission will be checked by test if ($user->rights->asset->level1->level2) $this->rights[$r][5] = ''; // In php code, permission will be checked by test if ($user->rights->asset->level1->level2) $r++; - $this->rights[$r][0] = $this->numero + $r; // Permission id (must not be already used) + $this->rights[$r][0] = 51002; // Permission id (must not be already used) $this->rights[$r][1] = 'Create/Update assets'; // Permission label - $this->rights[$r][3] = 1; // Permission by default for new user (0/1) + $this->rights[$r][2] = 'w'; + $this->rights[$r][3] = 0; // Permission by default for new user (0/1) $this->rights[$r][4] = 'write'; // In php code, permission will be checked by test if ($user->rights->asset->level1->level2) $this->rights[$r][5] = ''; // In php code, permission will be checked by test if ($user->rights->asset->level1->level2) $r++; - $this->rights[$r][0] = $this->numero + $r; // Permission id (must not be already used) + $this->rights[$r][0] = 51003; // Permission id (must not be already used) $this->rights[$r][1] = 'Delete assets'; // Permission label - $this->rights[$r][3] = 1; // Permission by default for new user (0/1) + $this->rights[$r][2] = 'd'; + $this->rights[$r][3] = 0; // Permission by default for new user (0/1) $this->rights[$r][4] = 'delete'; // In php code, permission will be checked by test if ($user->rights->asset->level1->level2) $this->rights[$r][5] = ''; // In php code, permission will be checked by test if ($user->rights->asset->level1->level2) - - // Main menu entries - $this->menu = array(); // List of menus to add - $r=0; - - // Add here entries to declare new menus - $this->menu = 1; // This module add menu entries. They are coded into menu manager. - - // Exports - //-------- - $r=1; - - // $this->export_code[$r] Unique code identifying the export (all modules combined) - // $this->export_label[$r] Libelle by default if translation of key "ExportXXX" not found (XXX = Code) - // $this->export_permission[$r] List of permission codes required to export - // $this->export_fields_sql[$r] List of exportable fields in SQL codiffication - // $this->export_fields_name[$r] List of exportable fields in translation codiffication - // $this->export_sql[$r] SQL query that offers data for export - - /* - $r++; - $this->export_code[$r]=$this->rights_class.'_'.$r; - $this->export_label[$r]='AssetsLines'; - $this->export_permission[$r]=array(array("asset","export")); - $this->export_fields_array[$r]=array( - 'a.rowid'=>'Id','a.civility'=>"UserTitle",'a.lastname'=>"Lastname",'a.firstname'=>"Firstname",'a.login'=>"Login",'a.morphy'=>'Nature', - 'a.societe'=>'Company','a.address'=>"Address",'a.zip'=>"Zip",'a.town'=>"Town",'d.nom'=>"State",'co.code'=>"CountryCode",'co.label'=>"Country", - 'a.phone'=>"PhonePro",'a.phone_perso'=>"PhonePerso",'a.phone_mobile'=>"PhoneMobile",'a.email'=>"Email",'a.birth'=>"Birthday",'a.statut'=>"Status", - 'a.photo'=>"Photo",'a.note_public'=>"NotePublic",'a.note_private'=>"NotePrivate",'a.datec'=>'DateCreation','a.datevalid'=>'DateValidation', - 'a.tms'=>'DateLastModification','a.datefin'=>'DateEndSubscription','ta.rowid'=>'AssetTypeId','ta.label'=>'AssetTypeLabel', - 'ta.accountancy_code_asset'=>'AccountancyCodeAsset','ta.accountancy_code_depreciation_asset'=>'AccountancyCodeDepreciationAsset', - 'ta.accountancy_code_depreciation_expense'=>'AccountancyCodeDepreciationExpense' - ); - $this->export_TypeFields_array[$r]=array( - 'a.civility'=>"Text",'a.lastname'=>"Text",'a.firstname'=>"Text",'a.login'=>"Text",'a.morphy'=>'Text','a.societe'=>'Text','a.address'=>"Text", - 'a.zip'=>"Text",'a.town'=>"Text",'d.nom'=>"Text",'co.code'=>'Text','co.label'=>"Text",'a.phone'=>"Text",'a.phone_perso'=>"Text",'a.phone_mobile'=>"Text", - 'a.email'=>"Text",'a.birth'=>"Date",'a.statut'=>"Status",'a.note_public'=>"Text",'a.note_private'=>"Text",'a.datec'=>'Date','a.datevalid'=>'Date', - 'a.tms'=>'Date','a.datefin'=>'Date','ta.rowid'=>'List:asset_type:label','ta.label'=>'Text','ta.accountancy_code_asset'=>'Text','ta.accountancy_code_depreciation_asset'=>'Text', - 'ta.accountancy_code_depreciation_expense'=>'Text' - ); - $this->export_entities_array[$r]=array( - 'a.rowid'=>'member','a.civility'=>"member",'a.lastname'=>"member",'a.firstname'=>"member",'a.login'=>"member",'a.morphy'=>'member', - 'a.societe'=>'member','a.address'=>"member",'a.zip'=>"member",'a.town'=>"member",'d.nom'=>"member",'co.code'=>"member",'co.label'=>"member", - 'a.phone'=>"member",'a.phone_perso'=>"member",'a.phone_mobile'=>"member",'a.email'=>"member",'a.birth'=>"member",'a.statut'=>"member", - 'a.photo'=>"member",'a.note_public'=>"member",'a.note_private'=>"member",'a.datec'=>'member','a.datevalid'=>'member','a.tms'=>'member', - 'a.datefin'=>'member','ta.rowid'=>'asset_type','ta.label'=>'asset_type','ta.accountancy_code_asset'=>'asset_type','ta.accountancy_code_depreciation_asset'=>'asset_type', - 'ta.accountancy_code_depreciation_expense'=>'asset_type' - ); - // Add extra fields - $keyforselect='asset'; $keyforelement='asset'; $keyforaliasextra='extra'; - include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; - // End add axtra fields - $this->export_sql_start[$r]='SELECT DISTINCT '; - $this->export_sql_end[$r] =' FROM ('.MAIN_DB_PREFIX.'asset_type as ta, '.MAIN_DB_PREFIX.'asset as a)'; - $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'asset_extrafields as extra ON a.rowid = extra.fk_object'; - $this->export_sql_end[$r] .=' WHERE a.fk_asset_type = ta.rowid AND ta.entity IN ('.getEntity('asset_type').') '; - - // Imports - //-------- - $r=0; - - $now=dol_now(); - require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; - - $r++; - $this->import_code[$r]=$this->rights_class.'_'.$r; - $this->import_label[$r]="Assets"; // Translation key - $this->import_icon[$r]=$this->picto; - $this->import_entities_array[$r]=array(); // We define here only fields that use another icon that the one defined into import_icon - $this->import_tables_array[$r]=array('a'=>MAIN_DB_PREFIX.'asset','extra'=>MAIN_DB_PREFIX.'asset_extrafields'); - $this->import_tables_creator_array[$r]=array('a'=>'fk_user_author'); // Fields to store import user id - $this->import_fields_array[$r]=array( - 'a.civility'=>"UserTitle",'a.lastname'=>"Lastname*",'a.firstname'=>"Firstname",'a.login'=>"Login*","a.pass"=>"Password", - "a.fk_adherent_type"=>"MemberType*",'a.morphy'=>'Nature*','a.societe'=>'Company','a.address'=>"Address",'a.zip'=>"Zip",'a.town'=>"Town", - 'a.state_id'=>'StateId','a.country'=>"CountryId",'a.phone'=>"PhonePro",'a.phone_perso'=>"PhonePerso",'a.phone_mobile'=>"PhoneMobile", - 'a.email'=>"Email",'a.birth'=>"Birthday",'a.statut'=>"Status*",'a.photo'=>"Photo",'a.note_public'=>"NotePublic",'a.note_private'=>"NotePrivate", - 'a.datec'=>'DateCreation','a.datefin'=>'DateEndSubscription' - ); - // Add extra fields - $sql="SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'asset' AND entity = ".$conf->entity; - $resql=$this->db->query($sql); - if ($resql) // This can fail when class is used on old database (during migration for example) - { - while ($obj=$this->db->fetch_object($resql)) - { - $fieldname='extra.'.$obj->name; - $fieldlabel=ucfirst($obj->label); - $this->import_fields_array[$r][$fieldname]=$fieldlabel.($obj->fieldrequired?'*':''); - } - } - // End add extra fields - $this->import_fieldshidden_array[$r]=array('extra.fk_object'=>'lastrowid-'.MAIN_DB_PREFIX.'asset'); // aliastable.field => ('user->id' or 'lastrowid-'.tableparent) - $this->import_regex_array[$r]=array( - 'a.civility'=>'code@'.MAIN_DB_PREFIX.'c_civility','a.fk_adherent_type'=>'rowid@'.MAIN_DB_PREFIX.'adherent_type', - 'a.morphy'=>'(phy|mor)','a.statut'=>'^[0|1]','a.datec'=>'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$', - 'a.datefin'=>'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$' - ); - $this->import_examplevalues_array[$r]=array( - 'a.civility'=>"MR",'a.lastname'=>'Smith','a.firstname'=>'John','a.login'=>'jsmith','a.pass'=>'passofjsmith','a.fk_adherent_type'=>'1', - 'a.morphy'=>'"mor" or "phy"','a.societe'=>'JS company','a.address'=>'21 jump street','a.zip'=>'55000','a.town'=>'New York','a.country'=>'1', - 'a.email'=>'jsmith@example.com','a.birth'=>'1972-10-10','a.statut'=>"0 or 1",'a.note_public'=>"This is a public comment on member", - 'a.note_private'=>"This is private comment on member",'a.datec'=>dol_print_date($now,'%Y-%m__%d'),'a.datefin'=>dol_print_date(dol_time_plus_duree($now, 1, 'y'),'%Y-%m-%d') - ); - */ + $r++; + $this->rights[$r][0] = 51005; // Permission id (must not be already used) + $this->rights[$r][1] = 'Setup types of asset'; // Permission label + $this->rights[$r][2] = 'w'; + $this->rights[$r][3] = 0; // Permission by default for new user (0/1) + $this->rights[$r][4] = 'advanced_configurer'; // In php code, permission will be checked by test if ($user->rights->asset->level1->level2) + $this->rights[$r][5] = ''; // In php code, permission will be checked by test if ($user->rights->asset->level1->level2) + + // Menus + //------- + $this->menu = 1; // This module add menu entries. They are coded into menu manager. } /** @@ -322,8 +218,6 @@ class modAsset extends DolibarrModules */ public function init($options = '') { - global $conf; - // Permissions $this->remove($options); diff --git a/htdocs/core/modules/modDebugBar.class.php b/htdocs/core/modules/modDebugBar.class.php index cef0ae2d1ad..8d51a102251 100644 --- a/htdocs/core/modules/modDebugBar.class.php +++ b/htdocs/core/modules/modDebugBar.class.php @@ -1,5 +1,7 @@ + * + * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. @@ -103,19 +105,4 @@ class modDebugBar extends DolibarrModules return $this->_init($sql, $options); } - - /** - * Function called after module configuration. - * - * @return void - */ - public function loadSettings() - { - $this->addPermission("use", "UseDebugBar", "u"); - - $this->enableHooks(array( - 'main', - 'login' - )); - } } diff --git a/htdocs/core/modules/modEmailCollector.class.php b/htdocs/core/modules/modEmailCollector.class.php index 2ca7ac73f08..b3daf4ade09 100644 --- a/htdocs/core/modules/modEmailCollector.class.php +++ b/htdocs/core/modules/modEmailCollector.class.php @@ -64,7 +64,7 @@ class modEmailCollector extends DolibarrModules $this->descriptionlong = "EmailCollectorDescription"; // Possible values for version are: 'development', 'experimental', 'dolibarr', 'dolibarr_deprecated' or a version string like 'x.y.z' - $this->version = 'experimental'; + $this->version = 'dolibarr'; // Key used in llx_const table to save module status enabled/disabled (where DAV is value of property name of module in uppercase) $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); // Name of image file used for this module. diff --git a/htdocs/core/modules/modProduct.class.php b/htdocs/core/modules/modProduct.class.php index f9cb16fc9c0..3358728d095 100644 --- a/htdocs/core/modules/modProduct.class.php +++ b/htdocs/core/modules/modProduct.class.php @@ -201,6 +201,11 @@ class modProduct extends DolibarrModules if (! empty($conf->fournisseur->enabled)) $this->export_entities_array[$r]=array_merge($this->export_entities_array[$r], array('s.nom'=>'product_supplier_ref','pf.ref_fourn'=>'product_supplier_ref','pf.unitprice'=>'product_supplier_ref','pf.quantity'=>'product_supplier_ref','pf.remise_percent'=>'product_supplier_ref','pf.delivery_time_days'=>'product_supplier_ref')); if (! empty($conf->global->MAIN_MULTILANGS)) $this->export_entities_array[$r]=array_merge($this->export_entities_array[$r], array('l.lang'=>'translation', 'l.label'=>'translation','l.description'=>'translation','l.note'=>'translation')); if (! empty($conf->global->EXPORTTOOL_CATEGORIES)) $this->export_dependencies_array[$r]=array('category'=>'p.rowid'); + if (! empty($conf->stock->enabled)) $this->export_entities_array[$r]=array_merge($this->export_entities_array[$r],array('p.stock'=>'product','p.pmp'=>'product')); + if (! empty($conf->barcode->enabled)) $this->export_entities_array[$r]=array_merge($this->export_entities_array[$r],array('p.barcode'=>'product')); + if (! empty($conf->fournisseur->enabled)) $this->export_entities_array[$r]=array_merge($this->export_entities_array[$r],array('s.nom'=>'product_supplier_ref','pf.ref_fourn'=>'product_supplier_ref','pf.unitprice'=>'product_supplier_ref','pf.quantity'=>'product_supplier_ref','pf.remise_percent'=>'product_supplier_ref','pf.delivery_time_days'=>'product_supplier_ref')); + if (! empty($conf->global->MAIN_MULTILANGS)) $this->export_entities_array[$r]=array_merge($this->export_entities_array[$r],array('l.lang'=>'translation', 'l.label'=>'translation','l.description'=>'translation','l.note'=>'translation')); + if (! empty($conf->global->EXPORTTOOL_CATEGORIES)) $this->export_dependencies_array[$r]=array('category'=>'p.rowid'); $this->export_sql_start[$r]='SELECT DISTINCT '; $this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'product as p'; if (! empty($conf->global->EXPORTTOOL_CATEGORIES)) $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'categorie_product as cp ON cp.fk_product = p.rowid LEFT JOIN '.MAIN_DB_PREFIX.'categorie as cat ON cp.fk_categorie = cat.rowid'; @@ -218,7 +223,7 @@ class modProduct extends DolibarrModules $this->export_label[$r]="ProductsMultiPrice"; // Translation key (used only if key ExportDataset_xxx_z not found) $this->export_permission[$r]=array(array("produit","export")); $this->export_fields_array[$r]=array('p.rowid'=>"Id",'p.ref'=>"Ref", - 'pr.price_base_type'=>"PriceLevelPriceBase",'pr.price_level'=>"PriceLevel", + 'pr.price_base_type'=>"PriceBase",'pr.price_level'=>"PriceLevel", 'pr.price'=>"PriceLevelUnitPriceHT",'pr.price_ttc'=>"PriceLevelUnitPriceTTC", 'pr.price_min'=>"MinPriceLevelUnitPriceHT",'pr.price_min_ttc'=>"MinPriceLevelUnitPriceTTC", 'pr.tva_tx'=>'PriceLevelVATRate', @@ -240,7 +245,39 @@ class modProduct extends DolibarrModules $this->export_sql_start[$r]='SELECT DISTINCT '; $this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'product as p'; $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'product_price as pr ON p.rowid = pr.fk_product AND pr.entity = '.$conf->entity; // export prices only for the current entity - $this->export_sql_end[$r] .=' WHERE p.fk_product_type = 0 AND p.entity IN ('.getEntity('product').')'; + $this->export_sql_end[$r] .=' WHERE p.entity IN ('.getEntity('product').')'; // For product and service profile + } + + if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) + { + // Exports product multiprice + $r++; + $this->export_code[$r]=$this->rights_class.'_'.$r; + $this->export_label[$r]="ProductsPricePerCustomer"; // Translation key (used only if key ExportDataset_xxx_z not found) + $this->export_permission[$r]=array(array("produit","export")); + $this->export_fields_array[$r]=array('p.rowid'=>"Id",'p.ref'=>"Ref", + 's.nom'=>'ThirdParty', + 'pr.price_base_type'=>"PriceBase", + 'pr.price'=>"PriceUnitPriceHT",'pr.price_ttc'=>"PriceUnitPriceTTC", + 'pr.price_min'=>"MinPriceUnitPriceHT",'pr.price_min_ttc'=>"MinPriceUnitPriceTTC", + 'pr.tva_tx'=>'PriceVATRate', + 'pr.default_vat_code'=>'PriceVATCode', + 'pr.datec'=>'DateCreation'); + if (is_object($mysoc) && $mysoc->useNPR()) $this->export_fields_array[$r]['pr.recuperableonly']='NPR'; + $this->export_entities_array[$r]=array('p.rowid'=>"product",'p.ref'=>"product", + 's.nom'=>'company', + 'pr.price_base_type'=>"product",'pr.price'=>"product", + 'pr.price_ttc'=>"product", + 'pr.price_min'=>"product",'pr.price_min_ttc'=>"product", + 'pr.tva_tx'=>'product', + 'pr.default_vat_code'=>'product', + 'pr.recuperableonly'=>'product', + 'pr.datec'=>"product"); + $this->export_sql_start[$r]='SELECT DISTINCT '; + $this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'product as p'; + $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'product_customer_price as pr ON p.rowid = pr.fk_product AND pr.entity = '.$conf->entity; // export prices only for the current entity + $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'societe as s ON pr.fk_soc = s.rowid'; + $this->export_sql_end[$r] .=' WHERE p.entity IN ('.getEntity('product').')'; // For product and service profile } if (! empty($conf->global->PRODUIT_SOUSPRODUITS)) @@ -287,7 +324,7 @@ class modProduct extends DolibarrModules $this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'product as p'; $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'product_extrafields as extra ON p.rowid = extra.fk_object,'; $this->export_sql_end[$r] .=' '.MAIN_DB_PREFIX.'product_association as pa, '.MAIN_DB_PREFIX.'product as p2'; - $this->export_sql_end[$r] .=' WHERE p.fk_product_type = 0 AND p.entity IN ('.getEntity('product').')'; + $this->export_sql_end[$r] .=' WHERE p.entity IN ('.getEntity('product').')'; // For product and service profile $this->export_sql_end[$r] .=' AND p.rowid = pa.fk_product_pere AND p2.rowid = pa.fk_product_fils'; } @@ -546,12 +583,15 @@ class modProduct extends DolibarrModules ); $this->import_examplevalues_array[$r]=array( - 'sp.fk_product' => "My Ref. eg: PREF123456", + 'sp.fk_product' => "PRODUCT_REF or id:123456", 'sp.fk_soc' => "My Supplier", 'sp.ref_fourn' => "eg: XYZ-F123456", - 'sp.quantity' => "eg: 5", + 'sp.quantity' => "5", 'sp.tva_tx' => 'one of the defined rates eg. 21', - 'sp.default_vat_code' => '', + 'sp.price'=>"50", + 'sp.unitprice'=>'50', + 'sp.remise_percent'=>'0', + 'sp.default_vat_code' => '', 'sp.delivery_time_days' => 'eg. 5', 'sp.supplier_reputation' => 'FAVORITE / NOTTHGOOD / DONOTORDER' ); @@ -589,16 +629,19 @@ class modProduct extends DolibarrModules $this->import_entities_array[$r]=array(); // We define here only fields that use another icon that the one defined into import_icon $this->import_tables_array[$r]=array('pr'=>MAIN_DB_PREFIX.'product_price'); $this->import_tables_creator_array[$r]=array('pr'=>'fk_user_author'); // Fields to store import user id - $this->import_fields_array[$r]=array('pr.fk_product'=>"ProductRowid*", - 'pr.price_base_type'=>"PriceLevelPriceBase",'pr.price_level'=>"PriceLevel", + $this->import_fields_array[$r]=array('pr.fk_product'=>"ProductOrService*", + 'pr.price_base_type'=>"PriceBase",'pr.price_level'=>"PriceLevel", 'pr.price'=>"PriceLevelUnitPriceHT",'pr.price_ttc'=>"PriceLevelUnitPriceTTC", 'pr.price_min'=>"MinPriceLevelUnitPriceHT",'pr.price_min_ttc'=>"MinPriceLevelUnitPriceTTC", - 'pr.tva_tx'=>'PriceLevelVATRate', 'pr.date_price'=>'DateCreation*'); + if (! empty($conf->global->PRODUIT_MULTIPRICES_USE_VAT_PER_LEVEL)) $this->import_fields_array[$r]['pr.tva_tx']='VATRate'; if (is_object($mysoc) && $mysoc->useNPR()) $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r], array('pr.recuperableonly'=>'NPR')); $this->import_regex_array[$r]=array('pr.datec'=>'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$','pr.recuperableonly'=>'^[0|1]$'); - $this->import_examplevalues_array[$r]=array('pr.fk_product'=>"1", - 'pr.price_base_type'=>"HT",'pr.price_level'=>"1", + $this->import_convertvalue_array[$r]=array( + 'pr.fk_product'=>array('rule'=>'fetchidfromref','classfile'=>'/product/class/product.class.php','class'=>'Product','method'=>'fetch','element'=>'Product') + ); + $this->import_examplevalues_array[$r]=array('pr.fk_product'=>"PRODUCT_REF or id:123456", + 'pr.price_base_type'=>"HT (for excl tax) or TTC (for inc tax)",'pr.price_level'=>"1", 'pr.price'=>"100",'pr.price_ttc'=>"110", 'pr.price_min'=>"100",'pr.price_min_ttc'=>"110", 'pr.tva_tx'=>'20', @@ -616,13 +659,13 @@ class modProduct extends DolibarrModules $this->import_entities_array[$r]=array(); // We define here only fields that use another icon that the one defined into import_icon $this->import_tables_array[$r]=array('l'=>MAIN_DB_PREFIX.'product_lang'); // multiline translation, one line per translation - $this->import_fields_array[$r]=array('l.fk_product'=>'Ref', 'l.lang'=>'Language', 'l.label'=>'TranslatedLabel', 'l.description'=>'TranslatedDescription'); + $this->import_fields_array[$r]=array('l.fk_product'=>'ProductOrService*', 'l.lang'=>'Language*', 'l.label'=>'TranslatedLabel', 'l.description'=>'TranslatedDescription'); //$this->import_fields_array[$r]['l.note']='TranslatedNote'; $this->import_convertvalue_array[$r]=array( 'l.fk_product'=>array('rule'=>'fetchidfromref','classfile'=>'/product/class/product.class.php','class'=>'Product','method'=>'fetch','element'=>'Product') ); - $this->import_examplevalues_array[$r]=array('l.fk_product'=>'MyProductRef','l.lang'=>'en_US','l.label'=>'Label in en_US','l.description'=>'Desc in en_US'); - $this->import_updatekeys_array[$r]=array('l.fk_product'=>'Ref','l.lang'=>'Language'); + $this->import_examplevalues_array[$r]=array('l.fk_product'=>'PRODUCT_REF or id:123456','l.lang'=>'en_US','l.label'=>'Label in en_US','l.description'=>'Desc in en_US'); + $this->import_updatekeys_array[$r]=array('l.fk_product'=>'ProductOrService','l.lang'=>'Language'); } } diff --git a/htdocs/core/modules/modService.class.php b/htdocs/core/modules/modService.class.php index 9fa79683a7f..119339d6022 100644 --- a/htdocs/core/modules/modService.class.php +++ b/htdocs/core/modules/modService.class.php @@ -141,30 +141,34 @@ class modService extends DolibarrModules $this->export_code[$r]=$this->rights_class.'_'.$r; $this->export_label[$r]="Services"; // Translation key (used only if key ExportDataset_xxx_z not found) $this->export_permission[$r]=array(array("service","export")); - $this->export_fields_array[$r]=array('p.rowid'=>"Id",'p.ref'=>"Ref",'p.label'=>"Label",'p.description'=>"Description",'p.accountancy_code_sell'=>"ProductAccountancySellCode",'p.accountancy_code_buy'=>"ProductAccountancyBuyCode",'p.note'=>"Note",'p.price_base_type'=>"PriceBase",'p.price'=>"UnitPriceHT",'p.price_ttc'=>"UnitPriceTTC",'p.tva_tx'=>'VATRate','p.tosell'=>"OnSell",'p.tobuy'=>"OnBuy",'p.duration'=>"Duration",'p.datec'=>'DateCreation','p.tms'=>'DateModification'); - if (! empty($conf->stock->enabled)) $this->export_fields_array[$r]=array_merge($this->export_fields_array[$r], array('p.stock'=>'Stock')); - if (! empty($conf->global->PRODUCT_USE_UNITS)) $this->export_fields_array[$r]['p.fk_unit'] = 'Unit'; + $this->export_fields_array[$r]=array('p.rowid'=>"Id",'p.ref'=>"Ref",'p.label'=>"Label",'p.description'=>"Description",'p.url'=>"PublicUrl",'p.accountancy_code_sell'=>"ProductAccountancySellCode",'p.accountancy_code_buy'=>"ProductAccountancyBuyCode",'p.note'=>"Note",'p.price_base_type'=>"PriceBase",'p.price'=>"UnitPriceHT",'p.price_ttc'=>"UnitPriceTTC",'p.tva_tx'=>'VATRate','p.tosell'=>"OnSell",'p.tobuy'=>"OnBuy",'p.duration'=>"Duration",'p.datec'=>'DateCreation','p.tms'=>'DateModification'); + if (is_object($mysoc) && $mysoc->useNPR()) $this->export_fields_array[$r]['p.recuperableonly']='NPR'; + if (! empty($conf->stock->enabled)) $this->export_fields_array[$r]=array_merge($this->export_fields_array[$r],array('p.stock'=>'Stock','p.seuil_stock_alerte'=>'StockLimit','p.desiredstock'=>'DesiredStock','p.pmp'=>'PMPValue')); + if (! empty($conf->barcode->enabled)) $this->export_fields_array[$r]=array_merge($this->export_fields_array[$r],array('p.barcode'=>'BarCode')); + if (! empty($conf->fournisseur->enabled) || !empty($conf->margin->enabled)) $this->export_fields_array[$r]=array_merge($this->export_fields_array[$r],array('p.cost_price'=>'CostPrice')); $keyforselect='product'; $keyforelement='product'; $keyforaliasextra='extra'; include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; - if (! empty($conf->fournisseur->enabled)) $this->export_fields_array[$r]=array_merge($this->export_fields_array[$r], array('s.nom'=>'Supplier','pf.ref_fourn'=>'SupplierRef','pf.quantity'=>'QtyMin','pf.remise_percent'=>'DiscountQtyMin','pf.unitprice'=>'BuyingPrice','pf.delivery_time_days'=>'NbDaysToDelivery')); - if (! empty($conf->global->EXPORTTOOL_CATEGORIES)) $this->export_fields_array[$r]=array_merge($this->export_fields_array[$r], array('group_concat(cat.label)'=>'Categories')); - if (! empty($conf->global->MAIN_MULTILANGS)) $this->export_fields_array[$r]=array_merge($this->export_fields_array[$r], array('l.lang'=>'Language', 'l.label'=>'TranslatedLabel','l.description'=>'TranslatedDescription','l.note'=>'TranslatedNote')); + if (! empty($conf->fournisseur->enabled)) $this->export_fields_array[$r]=array_merge($this->export_fields_array[$r],array('s.nom'=>'Supplier','pf.ref_fourn'=>'SupplierRef','pf.quantity'=>'QtyMin','pf.remise_percent'=>'DiscountQtyMin','pf.unitprice'=>'BuyingPrice','pf.delivery_time_days'=>'NbDaysToDelivery')); + if (! empty($conf->global->EXPORTTOOL_CATEGORIES)) $this->export_fields_array[$r]=array_merge($this->export_fields_array[$r],array('group_concat(cat.label)'=>'Categories')); + if (! empty($conf->global->MAIN_MULTILANGS)) $this->export_fields_array[$r]=array_merge($this->export_fields_array[$r],array('l.lang'=>'Language', 'l.label'=>'TranslatedLabel','l.description'=>'TranslatedDescription','l.note'=>'TranslatedNote')); if (! empty($conf->global->PRODUCT_USE_UNITS)) $this->export_fields_array[$r]['p.fk_unit'] = 'Unit'; - $this->export_TypeFields_array[$r]=array( - 'p.ref'=>"Text",'p.label'=>"Text",'p.description'=>"Text",'p.accountancy_code_sell'=>"Text",'p.accountancy_code_buy'=>"Text",'p.note'=>"Text",'p.price_base_type'=>"Text",'p.price'=>"Numeric",'p.price_ttc'=>"Numeric",'p.tva_tx'=>'Numeric','p.tosell'=>"Boolean",'p.tobuy'=>"Boolean",'p.duration'=>"Duree",'p.datec'=>'Date','p.tms'=>'Date' - ); - if (! empty($conf->global->EXPORTTOOL_CATEGORIES)) $this->export_entities_array[$r]=array_merge($this->export_entities_array[$r], array("group_concat(cat.label)"=>'category')); - if (! empty($conf->stock->enabled)) $this->export_TypeFields_array[$r]=array_merge($this->export_TypeFields_array[$r], array('p.stock'=>'Numeric','p.seuil_stock_alerte'=>'Numeric','p.desiredstock'=>'Numeric','p.pmp'=>'Numeric','p.cost_price'=>'Numeric')); - if (! empty($conf->barcode->enabled)) $this->export_TypeFields_array[$r]=array_merge($this->export_TypeFields_array[$r], array('p.barcode'=>'Text')); - if (! empty($conf->fournisseur->enabled)) $this->export_TypeFields_array[$r]=array_merge($this->export_TypeFields_array[$r], array('s.nom'=>'Text','pf.ref_fourn'=>'Text','pf.unitprice'=>'Numeric','pf.quantity'=>'Numeric','pf.remise_percent'=>'Numeric','pf.delivery_time_days'=>'Numeric')); - if (! empty($conf->global->MAIN_MULTILANGS)) $this->export_TypeFields_array[$r]=array_merge($this->export_TypeFields_array[$r], array('l.lang'=>'Text', 'l.label'=>'Text','l.description'=>'Text','l.note'=>'Text')); - if (! empty($conf->global->EXPORTTOOL_CATEGORIES)) $this->export_TypeFields_array[$r]=array_merge($this->export_TypeFields_array[$r], array("group_concat(cat.label)"=>'Text')); - $this->export_entities_array[$r]=array('p.rowid'=>"service",'p.ref'=>"service",'p.label'=>"service",'p.description'=>"service",'p.accountancy_code_sell'=>'service','p.note'=>"service",'p.price_base_type'=>"service",'p.price'=>"service",'p.price_ttc'=>"service",'p.tva_tx'=>"service",'p.tosell'=>"service",'p.tobuy'=>"service",'p.duration'=>"service",'p.datec'=>"service",'p.tms'=>"service"); - if (! empty($conf->global->EXPORTTOOL_CATEGORIES)) $this->export_entities_array[$r]=array_merge($this->export_entities_array[$r], array("group_concat(cat.label)"=>'category')); - if (! empty($conf->stock->enabled)) $this->export_entities_array[$r]=array_merge($this->export_entities_array[$r], array('p.stock'=>'service')); - if (! empty($conf->barcode->enabled)) $this->export_entities_array[$r]=array_merge($this->export_entities_array[$r], array('p.barcode'=>'service')); - if (! empty($conf->fournisseur->enabled)) $this->export_entities_array[$r]=array_merge($this->export_entities_array[$r], array('s.nom'=>'product_supplier_ref','pf.ref_fourn'=>'product_supplier_ref','pf.unitprice'=>'product_supplier_ref','pf.quantity'=>'product_supplier_ref','pf.remise_percent'=>'product_supplier_ref','pf.delivery_time_days'=>'product_supplier_ref')); - if (! empty($conf->global->MAIN_MULTILANGS)) $this->export_entities_array[$r]=array_merge($this->export_entities_array[$r], array('l.lang'=>'translation', 'l.label'=>'translation','l.description'=>'translation','l.note'=>'translation')); + $this->export_TypeFields_array[$r]=array('p.ref'=>"Text",'p.label'=>"Text",'p.description'=>"Text",'p.url'=>"Text",'p.accountancy_code_sell'=>"Text",'p.accountancy_code_buy'=>"Text",'p.note'=>"Text",'p.price_base_type'=>"Text",'p.price'=>"Numeric",'p.price_ttc'=>"Numeric",'p.tva_tx'=>'Numeric','p.tosell'=>"Boolean",'p.tobuy'=>"Boolean",'p.duration'=>"Duree",'p.datec'=>'Date','p.tms'=>'Date'); + if (! empty($conf->stock->enabled)) $this->export_TypeFields_array[$r]=array_merge($this->export_TypeFields_array[$r],array('p.stock'=>'Numeric')); + if (! empty($conf->barcode->enabled)) $this->export_TypeFields_array[$r]=array_merge($this->export_TypeFields_array[$r],array('p.barcode'=>'Text')); + if (! empty($conf->fournisseur->enabled)) $this->export_TypeFields_array[$r]=array_merge($this->export_TypeFields_array[$r],array('s.nom'=>'Text','pf.ref_fourn'=>'Text','pf.unitprice'=>'Numeric','pf.quantity'=>'Numeric','pf.remise_percent'=>'Numeric','pf.delivery_time_days'=>'Numeric')); + if (! empty($conf->global->MAIN_MULTILANGS)) $this->export_TypeFields_array[$r]=array_merge($this->export_TypeFields_array[$r],array('l.lang'=>'Text', 'l.label'=>'Text','l.description'=>'Text','l.note'=>'Text')); + if (! empty($conf->global->EXPORTTOOL_CATEGORIES)) $this->export_TypeFields_array[$r]=array_merge($this->export_TypeFields_array[$r],array("group_concat(cat.label)"=>'Text')); + $this->export_entities_array[$r]=array(); // We define here only fields that use another icon that the one defined into import_icon + if (! empty($conf->global->EXPORTTOOL_CATEGORIES)) $this->export_entities_array[$r]=array_merge($this->export_entities_array[$r],array("group_concat(cat.label)"=>'category')); + if (! empty($conf->stock->enabled)) $this->export_entities_array[$r]=array_merge($this->export_entities_array[$r],array('p.stock'=>'product','p.pmp'=>'product')); + if (! empty($conf->barcode->enabled)) $this->export_entities_array[$r]=array_merge($this->export_entities_array[$r],array('p.barcode'=>'product')); + if (! empty($conf->fournisseur->enabled)) $this->export_entities_array[$r]=array_merge($this->export_entities_array[$r],array('s.nom'=>'product_supplier_ref','pf.ref_fourn'=>'product_supplier_ref','pf.unitprice'=>'product_supplier_ref','pf.quantity'=>'product_supplier_ref','pf.remise_percent'=>'product_supplier_ref','pf.delivery_time_days'=>'product_supplier_ref')); + if (! empty($conf->global->MAIN_MULTILANGS)) $this->export_entities_array[$r]=array_merge($this->export_entities_array[$r],array('l.lang'=>'translation', 'l.label'=>'translation','l.description'=>'translation','l.note'=>'translation')); + if (! empty($conf->global->EXPORTTOOL_CATEGORIES)) $this->export_dependencies_array[$r]=array('category'=>'p.rowid'); + if (! empty($conf->stock->enabled)) $this->export_entities_array[$r]=array_merge($this->export_entities_array[$r],array('p.stock'=>'product','p.pmp'=>'product')); + if (! empty($conf->barcode->enabled)) $this->export_entities_array[$r]=array_merge($this->export_entities_array[$r],array('p.barcode'=>'product')); + if (! empty($conf->fournisseur->enabled)) $this->export_entities_array[$r]=array_merge($this->export_entities_array[$r],array('s.nom'=>'product_supplier_ref','pf.ref_fourn'=>'product_supplier_ref','pf.unitprice'=>'product_supplier_ref','pf.quantity'=>'product_supplier_ref','pf.remise_percent'=>'product_supplier_ref','pf.delivery_time_days'=>'product_supplier_ref')); + if (! empty($conf->global->MAIN_MULTILANGS)) $this->export_entities_array[$r]=array_merge($this->export_entities_array[$r],array('l.lang'=>'translation', 'l.label'=>'translation','l.description'=>'translation','l.note'=>'translation')); if (! empty($conf->global->EXPORTTOOL_CATEGORIES)) $this->export_dependencies_array[$r]=array('category'=>'p.rowid'); $this->export_sql_start[$r]='SELECT DISTINCT '; $this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'product as p'; @@ -185,7 +189,7 @@ class modService extends DolibarrModules $this->export_label[$r]="ProductsMultiPrice"; // Translation key (used only if key ExportDataset_xxx_z not found) $this->export_permission[$r]=array(array("produit","export")); $this->export_fields_array[$r]=array('p.rowid'=>"Id",'p.ref'=>"Ref", - 'pr.price_base_type'=>"PriceLevelPriceBase",'pr.price_level'=>"PriceLevel", + 'pr.price_base_type'=>"PriceBase",'pr.price_level'=>"PriceLevel", 'pr.price'=>"PriceLevelUnitPriceHT",'pr.price_ttc'=>"PriceLevelUnitPriceTTC", 'pr.price_min'=>"MinPriceLevelUnitPriceHT",'pr.price_min_ttc'=>"MinPriceLevelUnitPriceTTC", 'pr.tva_tx'=>'PriceLevelVATRate', @@ -207,9 +211,89 @@ class modService extends DolibarrModules $this->export_sql_start[$r]='SELECT DISTINCT '; $this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'product as p'; $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'product_price as pr ON p.rowid = pr.fk_product AND pr.entity = '.$conf->entity; // export prices only for the current entity - $this->export_sql_end[$r] .=' WHERE p.fk_product_type = 0 AND p.entity IN ('.getEntity('product').')'; + $this->export_sql_end[$r] .=' WHERE p.entity IN ('.getEntity('product').')'; } - + + if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) + { + // Exports product multiprice + $r++; + $this->export_code[$r]=$this->rights_class.'_'.$r; + $this->export_label[$r]="ProductsPricePerCustomer"; // Translation key (used only if key ExportDataset_xxx_z not found) + $this->export_permission[$r]=array(array("produit","export")); + $this->export_fields_array[$r]=array('p.rowid'=>"Id",'p.ref'=>"Ref", + 's.nom'=>'ThirdParty', + 'pr.price_base_type'=>"PriceBase", + 'pr.price'=>"PriceUnitPriceHT",'pr.price_ttc'=>"PriceUnitPriceTTC", + 'pr.price_min'=>"MinPriceUnitPriceHT",'pr.price_min_ttc'=>"MinPriceUnitPriceTTC", + 'pr.tva_tx'=>'PriceVATRate', + 'pr.default_vat_code'=>'PriceVATCode', + 'pr.datec'=>'DateCreation'); + if (is_object($mysoc) && $mysoc->useNPR()) $this->export_fields_array[$r]['pr.recuperableonly']='NPR'; + $this->export_entities_array[$r]=array('p.rowid'=>"product",'p.ref'=>"product", + 's.nom'=>'company', + 'pr.price_base_type'=>"product",'pr.price'=>"product", + 'pr.price_ttc'=>"product", + 'pr.price_min'=>"product",'pr.price_min_ttc'=>"product", + 'pr.tva_tx'=>'product', + 'pr.default_vat_code'=>'product', + 'pr.recuperableonly'=>'product', + 'pr.datec'=>"product"); + $this->export_sql_start[$r]='SELECT DISTINCT '; + $this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'product as p'; + $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'product_customer_price as pr ON p.rowid = pr.fk_product AND pr.entity = '.$conf->entity; // export prices only for the current entity + $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'societe as s ON pr.fk_soc = s.rowid'; + $this->export_sql_end[$r] .=' WHERE p.entity IN ('.getEntity('product').')'; + } + + if (! empty($conf->global->PRODUIT_SOUSPRODUITS)) + { + // Exports virtual products + $r++; + $this->export_code[$r]=$this->rights_class.'_'.$r; + $this->export_label[$r]="AssociatedProducts"; // Translation key (used only if key ExportDataset_xxx_z not found) + $this->export_permission[$r]=array(array("produit","export")); + $this->export_fields_array[$r]=array( + 'p.rowid'=>"Id",'p.ref'=>"Ref",'p.label'=>"Label",'p.description'=>"Description",'p.url'=>"PublicUrl", + 'p.accountancy_code_sell'=>"ProductAccountancySellCode",'p.accountancy_code_buy'=>"ProductAccountancyBuyCode",'p.note'=>"Note", + 'p.length'=>"Length",'p.surface'=>"Surface",'p.volume'=>"Volume",'p.weight'=>"Weight",'p.customcode'=>'CustomCode', + 'p.price_base_type'=>"PriceBase",'p.price'=>"UnitPriceHT",'p.price_ttc'=>"UnitPriceTTC",'p.tva_tx'=>'VATRate','p.tosell'=>"OnSell", + 'p.tobuy'=>"OnBuy",'p.datec'=>'DateCreation','p.tms'=>'DateModification' + ); + if (! empty($conf->stock->enabled)) $this->export_fields_array[$r]=array_merge($this->export_fields_array[$r],array('p.stock'=>'Stock','p.seuil_stock_alerte'=>'StockLimit','p.desiredstock'=>'DesiredStock','p.pmp'=>'PMPValue')); + if (! empty($conf->barcode->enabled)) $this->export_fields_array[$r]=array_merge($this->export_fields_array[$r],array('p.barcode'=>'BarCode')); + $this->export_fields_array[$r]=array_merge($this->export_fields_array[$r],array('pa.qty'=>'Qty','pa.incdec'=>'ComposedProductIncDecStock')); + $this->export_TypeFields_array[$r]=array( + 'p.ref'=>"Text",'p.label'=>"Text",'p.description'=>"Text",'p.url'=>"Text",'p.accountancy_code_sell'=>"Text",'p.accountancy_code_buy'=>"Text", + 'p.note'=>"Text",'p.length'=>"Numeric",'p.surface'=>"Numeric",'p.volume'=>"Numeric",'p.weight'=>"Numeric",'p.customcode'=>'Text', + 'p.price_base_type'=>"Text",'p.price'=>"Numeric",'p.price_ttc'=>"Numeric",'p.tva_tx'=>'Numeric','p.tosell'=>"Boolean",'p.tobuy'=>"Boolean", + 'p.datec'=>'Date','p.tms'=>'Date' + ); + if (! empty($conf->stock->enabled)) $this->export_TypeFields_array[$r]=array_merge($this->export_TypeFields_array[$r],array('p.stock'=>'Numeric','p.seuil_stock_alerte'=>'Numeric','p.desiredstock'=>'Numeric','p.pmp'=>'Numeric','p.cost_price'=>'Numeric')); + if (! empty($conf->barcode->enabled)) $this->export_TypeFields_array[$r]=array_merge($this->export_TypeFields_array[$r],array('p.barcode'=>'Text')); + $this->export_TypeFields_array[$r]=array_merge($this->export_TypeFields_array[$r],array('pa.qty'=>'Numeric')); + $this->export_entities_array[$r]=array( + 'p.rowid'=>"virtualproduct",'p.ref'=>"virtualproduct",'p.label'=>"virtualproduct",'p.description'=>"virtualproduct",'p.url'=>"virtualproduct", + 'p.accountancy_code_sell'=>'virtualproduct','p.accountancy_code_buy'=>'virtualproduct','p.note'=>"virtualproduct",'p.length'=>"virtualproduct", + 'p.surface'=>"virtualproduct",'p.volume'=>"virtualproduct",'p.weight'=>"virtualproduct",'p.customcode'=>'virtualproduct', + 'p.price_base_type'=>"virtualproduct",'p.price'=>"virtualproduct",'p.price_ttc'=>"virtualproduct",'p.tva_tx'=>"virtualproduct", + 'p.tosell'=>"virtualproduct",'p.tobuy'=>"virtualproduct",'p.datec'=>"virtualproduct",'p.tms'=>"virtualproduct" + ); + if (! empty($conf->stock->enabled)) $this->export_entities_array[$r]=array_merge($this->export_entities_array[$r],array('p.stock'=>'virtualproduct','p.seuil_stock_alerte'=>'virtualproduct','p.desiredstock'=>'virtualproduct','p.pmp'=>'virtualproduct')); + if (! empty($conf->barcode->enabled)) $this->export_entities_array[$r]=array_merge($this->export_entities_array[$r],array('p.barcode'=>'virtualproduct')); + $this->export_entities_array[$r]=array_merge($this->export_entities_array[$r],array('pa.qty'=>"subproduct",'pa.incdec'=>'subproduct')); + $keyforselect='product'; $keyforelement='product'; $keyforaliasextra='extra'; + include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; + $this->export_fields_array[$r]=array_merge($this->export_fields_array[$r],array('p2.rowid'=>"Id",'p2.ref'=>"Ref",'p2.label'=>"Label",'p2.description'=>"Description")); + $this->export_entities_array[$r]=array_merge($this->export_entities_array[$r],array('p2.rowid'=>"subproduct",'p2.ref'=>"subproduct",'p2.label'=>"subproduct",'p2.description'=>"subproduct")); + $this->export_sql_start[$r]='SELECT DISTINCT '; + $this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'product as p'; + $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'product_extrafields as extra ON p.rowid = extra.fk_object,'; + $this->export_sql_end[$r] .=' '.MAIN_DB_PREFIX.'product_association as pa, '.MAIN_DB_PREFIX.'product as p2'; + $this->export_sql_end[$r] .=' WHERE p.entity IN ('.getEntity('product').')'; + $this->export_sql_end[$r] .=' AND p.rowid = pa.fk_product_pere AND p2.rowid = pa.fk_product_fils'; + } + if (! empty($conf->global->PRODUIT_SOUSPRODUITS)) { // Exports virtual products @@ -259,13 +343,12 @@ class modService extends DolibarrModules } } - // Imports //-------- $r=0; // Import list of services - + $r++; $this->import_code[$r]=$this->rights_class.'_'.$r; $this->import_label[$r]="Products"; // Translation key @@ -277,13 +360,14 @@ class modService extends DolibarrModules 'p.ref'=>"Ref*",'p.label'=>"Label*",'p.description'=>"Description",'p.url'=>"PublicUrl",'p.accountancy_code_sell'=>"ProductAccountancySellCode", 'p.accountancy_code_buy'=>"ProductAccountancyBuyCode",'p.note'=>"Note",'p.length'=>"Length",'p.surface'=>"Surface",'p.volume'=>"Volume", 'p.weight'=>"Weight",'p.duration'=>"Duration",'p.customcode'=>'CustomCode','p.price'=>"SellingPriceHT",'p.price_ttc'=>"SellingPriceTTC", - 'p.tva_tx'=>'VAT','p.tosell'=>"OnSell*",'p.tobuy'=>"OnBuy*",'p.fk_product_type'=>"Type*",'p.finished'=>'Nature','p.datec'=>'DateCreation' + 'p.tva_tx'=>'VATRate','p.tosell'=>"OnSell*",'p.tobuy'=>"OnBuy*",'p.fk_product_type'=>"Type*",'p.finished'=>'Nature','p.datec'=>'DateCreation' ); - if (! empty($conf->fournisseur->enabled) || !empty($conf->margin->enabled)) $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r], array('p.cost_price'=>'CostPrice')); - if (is_object($mysoc) && $mysoc->useNPR()) $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r], array('p.recuperableonly'=>'NPR')); - if (is_object($mysoc) && $mysoc->useLocalTax(1)) $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r], array('p.localtax1_tx'=>'LT1', 'p.localtax1_type'=>'LT1Type')); - if (is_object($mysoc) && $mysoc->useLocalTax(2)) $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r], array('p.localtax2_tx'=>'LT2', 'p.localtax2_type'=>'LT2Type')); - if (! empty($conf->barcode->enabled)) $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r], array('p.barcode'=>'BarCode')); + //if (! empty($conf->stock->enabled)) $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r],array('p.seuil_stock_alerte'=>'StockLimit','p.desiredstock'=>'DesiredStock','p.pmp'=>'PMPValue')); + if (! empty($conf->fournisseur->enabled) || !empty($conf->margin->enabled)) $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r],array('p.cost_price'=>'CostPrice')); + if (is_object($mysoc) && $mysoc->useNPR()) $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r],array('p.recuperableonly'=>'NPR')); + if (is_object($mysoc) && $mysoc->useLocalTax(1)) $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r],array('p.localtax1_tx'=>'LT1', 'p.localtax1_type'=>'LT1Type')); + if (is_object($mysoc) && $mysoc->useLocalTax(2)) $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r],array('p.localtax2_tx'=>'LT2', 'p.localtax2_type'=>'LT2Type')); + if (! empty($conf->barcode->enabled)) $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r],array('p.barcode'=>'BarCode')); if (! empty($conf->global->PRODUCT_USE_UNITS)) $this->import_fields_array[$r]['p.fk_unit'] = 'Unit'; // Add extra fields $import_extrafield_sample=array(); @@ -296,24 +380,24 @@ class modService extends DolibarrModules $fieldname='extra.'.$obj->name; $fieldlabel=ucfirst($obj->label); $this->import_fields_array[$r][$fieldname]=$fieldlabel.($obj->fieldrequired?'*':''); + $import_extrafield_sample[$fieldname]=$fieldlabel; } } // End add extra fields $this->import_fieldshidden_array[$r]=array('extra.fk_object'=>'lastrowid-'.MAIN_DB_PREFIX.'product'); // aliastable.field => ('user->id' or 'lastrowid-'.tableparent) $this->import_regex_array[$r]=array( - 'p.ref' => '[^ ]', - 'p.price_base_type' => '\AHT\z|\ATTC\z', - 'p.tosell' => '^[0|1]$', - 'p.tobuy' => '^[0|1]$', - 'p.fk_product_type' => '^[0|1]$', - 'p.datec' => '^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$', - 'p.recuperableonly' => '^[0|1]$', - 'p.finished' => '^[0|1]$' - ); - $this->import_examplevalues_array[$r]=array('p.ref'=>"PREF123456",'p.label'=>"My product",'p.description'=>"This is a description example for record",'p.note'=>"Some note",'p.price'=>"100",'p.price_ttc'=>"110",'p.tva_tx'=>'10','p.tosell'=>"0 or 1",'p.tobuy'=>"0 or 1",'p.fk_product_type'=>"0 for product/1 for service",'p.finished'=>'','p.duration'=>"1y",'p.datec'=>'2008-12-31'); + 'p.ref'=>'[^ ]', + 'p.tosell'=>'^[0|1]$', + 'p.tobuy'=>'^[0|1]$', + 'p.fk_product_type'=>'^[0|1]$', + 'p.datec'=>'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$', + 'p.recuperableonly'=>'^[0|1]$' + ); + $import_sample=array('p.ref'=>"SERVICE_REF or id:123456",'p.label'=>"My product",'p.description'=>"This is a description example for record",'p.note'=>"Some note",'p.price'=>"100",'p.price_ttc'=>"110",'p.tva_tx'=>'10','p.tosell'=>"0 or 1",'p.tobuy'=>"0 or 1",'p.fk_product_type'=>"0 for product/1 for service",'p.finished'=>'','p.duration'=>"1y",'p.datec'=>'2008-12-31','p.recuperableonly'=>'0 or 1'); + $this->import_examplevalues_array[$r]=array_merge($import_sample,$import_extrafield_sample); $this->import_updatekeys_array[$r] = array('p.ref'=>'Ref'); if (! empty($conf->barcode->enabled)) $this->import_updatekeys_array[$r]=array_merge($this->import_updatekeys_array[$r], array('p.barcode'=>'BarCode'));//only show/allow barcode as update key if Barcode module enabled - + if (empty($conf->product->enabled)) // We enable next import templates only if module product not already enabled (to avoid duplicate entries) { if (! empty($conf->fournisseur->enabled)) @@ -355,18 +439,19 @@ class modService extends DolibarrModules 'sp.multicurrency_price'=>'CurrencyPrice', )); } - + $this->import_convertvalue_array[$r]=array( 'sp.fk_soc'=>array('rule'=>'fetchidfromref','classfile'=>'/societe/class/societe.class.php','class'=>'Societe','method'=>'fetch','element'=>'ThirdParty'), 'sp.fk_product'=>array('rule'=>'fetchidfromref','classfile'=>'/product/class/product.class.php','class'=>'Product','method'=>'fetch','element'=>'Product') ); $this->import_examplevalues_array[$r]=array( - 'sp.fk_product'=>"PREF123456", + 'sp.fk_product'=>"SERVICE_REF or id:123456", 'sp.fk_soc'=>"My Supplier",'sp.ref_fourn'=>"SupplierRef", 'sp.quantity'=>"1", 'sp.tva_tx'=>'21', 'sp.price'=>"50", 'sp.unitprice'=>'50', 'sp.remise_percent'=>'0' ); + $this->import_updatekeys_array[$r]=array('sp.fk_product'=>'ProductOrService','sp.ref_fourn'=>'SupplierRef','sp.fk_soc'=>'Supplier'); } if (! empty($conf->global->PRODUIT_MULTIPRICES)) @@ -379,21 +464,24 @@ class modService extends DolibarrModules $this->import_entities_array[$r]=array(); // We define here only fields that use another icon that the one defined into import_icon $this->import_tables_array[$r]=array('pr'=>MAIN_DB_PREFIX.'product_price'); $this->import_tables_creator_array[$r]=array('pr'=>'fk_user_author'); // Fields to store import user id - $this->import_fields_array[$r]=array('pr.fk_product'=>"ProductRowid*", - 'pr.price_base_type'=>"PriceLevelPriceBase",'pr.price_level'=>"PriceLevel", + $this->import_fields_array[$r]=array('pr.fk_product'=>"ProductOrService*", + 'pr.price_base_type'=>"PriceBase",'pr.price_level'=>"PriceLevel", 'pr.price'=>"PriceLevelUnitPriceHT",'pr.price_ttc'=>"PriceLevelUnitPriceTTC", 'pr.price_min'=>"MinPriceLevelUnitPriceHT",'pr.price_min_ttc'=>"MinPriceLevelUnitPriceTTC", - 'pr.tva_tx'=>'PriceLevelVATRate', 'pr.date_price'=>'DateCreation*'); - if (is_object($mysoc) && $mysoc->useNPR()) $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r], array('pr.recuperableonly'=>'NPR')); - $this->import_regex_array[$r]=array('pr.datec'=>'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$'); - $this->import_examplevalues_array[$r]=array('pr.fk_product'=>"1", - 'pr.price_base_type'=>"HT",'pr.price_level'=>"1", + if (! empty($conf->global->PRODUIT_MULTIPRICES_USE_VAT_PER_LEVEL)) $this->import_fields_array[$r]['pr.tva_tx']='VATRate'; + if (is_object($mysoc) && $mysoc->useNPR()) $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r],array('pr.recuperableonly'=>'NPR')); + $this->import_regex_array[$r]=array('pr.datec'=>'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$','pr.recuperableonly'=>'^[0|1]$'); + $this->import_convertvalue_array[$r]=array( + 'pr.fk_product'=>array('rule'=>'fetchidfromref','classfile'=>'/product/class/product.class.php','class'=>'Product','method'=>'fetch','element'=>'Product') + ); + $this->import_examplevalues_array[$r]=array('pr.fk_product'=>"SERVICE_REF or id:123456", + 'pr.price_base_type'=>"HT (for excl tax) or TTC (for inc tax)",'pr.price_level'=>"1", 'pr.price'=>"100",'pr.price_ttc'=>"110", 'pr.price_min'=>"100",'pr.price_min_ttc'=>"110", - 'pr.tva_tx'=>'20', + 'pr.tva_tx'=>'20', 'pr.recuperableonly'=>'0', - 'pr.date_price'=>'2013-04-10'); + 'pr.date_price'=>'2013-04-10'); } if (! empty($conf->global->MAIN_MULTILANGS)) @@ -406,13 +494,13 @@ class modService extends DolibarrModules $this->import_entities_array[$r]=array(); // We define here only fields that use another icon that the one defined into import_icon $this->import_tables_array[$r]=array('l'=>MAIN_DB_PREFIX.'product_lang'); // multiline translation, one line per translation - $this->import_fields_array[$r]=array('l.fk_product'=>'Ref', 'l.lang'=>'Language', 'l.label'=>'TranslatedLabel', 'l.description'=>'TranslatedDescription'); + $this->import_fields_array[$r]=array('l.fk_product'=>'ProductOrService*', 'l.lang'=>'Language*', 'l.label'=>'TranslatedLabel', 'l.description'=>'TranslatedDescription'); //$this->import_fields_array[$r]['l.note']='TranslatedNote'; $this->import_convertvalue_array[$r]=array( 'l.fk_product'=>array('rule'=>'fetchidfromref','classfile'=>'/product/class/product.class.php','class'=>'Product','method'=>'fetch','element'=>'Product') ); - $this->import_examplevalues_array[$r]=array('l.fk_product'=>'MyProductRef','l.lang'=>'en_US','l.label'=>'Label in en_US','l.description'=>'Desc in en_US'); - $this->import_updatekeys_array[$r]=array('l.fk_product'=>'Ref','l.lang'=>'Language'); + $this->import_examplevalues_array[$r]=array('l.fk_product'=>'SERVICE_REF or id:123456','l.lang'=>'en_US','l.label'=>'Label in en_US','l.description'=>'Desc in en_US'); + $this->import_updatekeys_array[$r]=array('l.fk_product'=>'ProductOrService','l.lang'=>'Language'); } } } diff --git a/htdocs/core/modules/modWebsite.class.php b/htdocs/core/modules/modWebsite.class.php index 6f882f082ad..24a929c82a0 100644 --- a/htdocs/core/modules/modWebsite.class.php +++ b/htdocs/core/modules/modWebsite.class.php @@ -92,12 +92,18 @@ class modWebsite extends DolibarrModules $r++; $this->rights[$r][0] = 10002; - $this->rights[$r][1] = 'Create/modify website content'; + $this->rights[$r][1] = 'Create/modify website content (html and javascript content)'; $this->rights[$r][3] = 0; $this->rights[$r][4] = 'write'; $r++; $this->rights[$r][0] = 10003; + $this->rights[$r][1] = 'Create/modify website content (dynamic php code). Dangerous, must be reserved to restricted developers.'; + $this->rights[$r][3] = 0; + $this->rights[$r][4] = 'writephp'; + $r++; + + $this->rights[$r][0] = 10005; $this->rights[$r][1] = 'Delete website content'; $this->rights[$r][3] = 0; $this->rights[$r][4] = 'delete'; diff --git a/htdocs/core/modules/payment/mod_payment_ant.php b/htdocs/core/modules/payment/mod_payment_ant.php index 2f3114bfd09..21ad0d91b9e 100644 --- a/htdocs/core/modules/payment/mod_payment_ant.php +++ b/htdocs/core/modules/payment/mod_payment_ant.php @@ -32,7 +32,7 @@ class mod_payment_ant extends ModeleNumRefPayments { /** * Dolibarr version of the loaded document - * @public string + * @var string */ public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' diff --git a/htdocs/core/modules/payment/mod_payment_cicada.php b/htdocs/core/modules/payment/mod_payment_cicada.php index a6cfca7e1df..a6f1eee1ef7 100644 --- a/htdocs/core/modules/payment/mod_payment_cicada.php +++ b/htdocs/core/modules/payment/mod_payment_cicada.php @@ -31,7 +31,7 @@ class mod_payment_cicada extends ModeleNumRefPayments { /** * Dolibarr version of the loaded document - * @public string + * @var string */ public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' diff --git a/htdocs/core/modules/product/mod_codeproduct_elephant.php b/htdocs/core/modules/product/mod_codeproduct_elephant.php index e7e20db532f..9d41cef78cb 100644 --- a/htdocs/core/modules/product/mod_codeproduct_elephant.php +++ b/htdocs/core/modules/product/mod_codeproduct_elephant.php @@ -56,7 +56,7 @@ class mod_codeproduct_elephant extends ModeleProductCode /** * Dolibarr version of the loaded document - * @public string + * @var string */ public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' diff --git a/htdocs/core/modules/product/mod_codeproduct_leopard.php b/htdocs/core/modules/product/mod_codeproduct_leopard.php index a7b03eed2f0..a6242dd336c 100644 --- a/htdocs/core/modules/product/mod_codeproduct_leopard.php +++ b/htdocs/core/modules/product/mod_codeproduct_leopard.php @@ -61,7 +61,7 @@ class mod_codeproduct_leopard extends ModeleProductCode /** * Dolibarr version of the loaded document - * @public string + * @var string */ public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' diff --git a/htdocs/core/modules/project/mod_project_simple.php b/htdocs/core/modules/project/mod_project_simple.php index 25553fb19c9..faab6523820 100644 --- a/htdocs/core/modules/project/mod_project_simple.php +++ b/htdocs/core/modules/project/mod_project_simple.php @@ -33,7 +33,7 @@ class mod_project_simple extends ModeleNumRefProjects { /** * Dolibarr version of the loaded document - * @public string + * @var string */ public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' diff --git a/htdocs/core/modules/project/mod_project_universal.php b/htdocs/core/modules/project/mod_project_universal.php index be8a9c3f362..d9287109d6e 100644 --- a/htdocs/core/modules/project/mod_project_universal.php +++ b/htdocs/core/modules/project/mod_project_universal.php @@ -32,7 +32,7 @@ class mod_project_universal extends ModeleNumRefProjects { /** * Dolibarr version of the loaded document - * @public string + * @var string */ public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' diff --git a/htdocs/core/modules/project/task/doc/doc_generic_task_odt.modules.php b/htdocs/core/modules/project/task/doc/doc_generic_task_odt.modules.php index 4d2e47f0593..f6da1061c89 100644 --- a/htdocs/core/modules/project/task/doc/doc_generic_task_odt.modules.php +++ b/htdocs/core/modules/project/task/doc/doc_generic_task_odt.modules.php @@ -69,7 +69,7 @@ class doc_generic_task_odt extends ModelePDFTask /** * Dolibarr version of the loaded document - * @public string + * @var string */ public $version = 'dolibarr'; diff --git a/htdocs/core/modules/project/task/mod_task_simple.php b/htdocs/core/modules/project/task/mod_task_simple.php index 4632fedec4a..7619c9b6834 100644 --- a/htdocs/core/modules/project/task/mod_task_simple.php +++ b/htdocs/core/modules/project/task/mod_task_simple.php @@ -33,7 +33,7 @@ class mod_task_simple extends ModeleNumRefTask { /** * Dolibarr version of the loaded document - * @public string + * @var string */ public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' diff --git a/htdocs/core/modules/project/task/mod_task_universal.php b/htdocs/core/modules/project/task/mod_task_universal.php index a9dc2846ad6..f08067541e8 100644 --- a/htdocs/core/modules/project/task/mod_task_universal.php +++ b/htdocs/core/modules/project/task/mod_task_universal.php @@ -32,7 +32,7 @@ class mod_task_universal extends ModeleNumRefTask { /** * Dolibarr version of the loaded document - * @public string + * @var string */ public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' diff --git a/htdocs/core/modules/propale/doc/pdf_cyan.modules.php b/htdocs/core/modules/propale/doc/pdf_cyan.modules.php index 62e268874e8..5a71c060a51 100644 --- a/htdocs/core/modules/propale/doc/pdf_cyan.modules.php +++ b/htdocs/core/modules/propale/doc/pdf_cyan.modules.php @@ -74,7 +74,7 @@ class pdf_cyan extends ModelePDFPropales /** * Dolibarr version of the loaded document - * @public string + * @var string */ public $version = 'development'; @@ -434,7 +434,7 @@ class pdf_cyan extends ModelePDFPropales complete_substitutions_array($substitutionarray, $outputlangs, $object); $notetoshow = make_substitutions($notetoshow, $substitutionarray, $outputlangs); $notetoshow = convertBackOfficeMediasLinksToPublicLinks($notetoshow); - + $pdf->startTransaction(); $pdf->SetFont('', '', $default_font_size - 1); @@ -549,11 +549,11 @@ class pdf_cyan extends ModelePDFPropales $pdf->startTransaction(); $this->pdfTabTitles($pdf, $tab_top, $tab_height, $outputlangs, $hidetop); $pdf->rollbackTransaction(true); - + $iniY = $tab_top + $this->tabTitleHeight + 2; $curY = $tab_top + $this->tabTitleHeight + 2; $nexY = $tab_top + $this->tabTitleHeight + 2; - + // Loop on each lines $pageposbeforeprintlines=$pdf->getPage(); $pagenb = $pageposbeforeprintlines; @@ -1460,7 +1460,7 @@ class pdf_cyan extends ModelePDFPropales $this->pdfTabTitles($pdf, $tab_top, $tab_height, $outputlangs, $hidetop); - + if (empty($hidetop)){ $pdf->line($this->marge_gauche, $tab_top+$this->tabTitleHeight, $this->page_largeur-$this->marge_droite, $tab_top+$this->tabTitleHeight); // line prend une position y en 2eme param et 4eme param } diff --git a/htdocs/core/modules/propale/mod_propale_marbre.php b/htdocs/core/modules/propale/mod_propale_marbre.php index 0e03574a3d4..4fba93d7a8d 100644 --- a/htdocs/core/modules/propale/mod_propale_marbre.php +++ b/htdocs/core/modules/propale/mod_propale_marbre.php @@ -33,7 +33,7 @@ class mod_propale_marbre extends ModeleNumRefPropales { /** * Dolibarr version of the loaded document - * @public string + * @var string */ public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' diff --git a/htdocs/core/modules/propale/mod_propale_saphir.php b/htdocs/core/modules/propale/mod_propale_saphir.php index ddf856d5003..99c82217a87 100644 --- a/htdocs/core/modules/propale/mod_propale_saphir.php +++ b/htdocs/core/modules/propale/mod_propale_saphir.php @@ -35,7 +35,7 @@ class mod_propale_saphir extends ModeleNumRefPropales { /** * Dolibarr version of the loaded document - * @public string + * @var string */ public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' diff --git a/htdocs/core/modules/societe/mod_codeclient_elephant.php b/htdocs/core/modules/societe/mod_codeclient_elephant.php index 4be4ea5d50e..b4e9f5d5258 100644 --- a/htdocs/core/modules/societe/mod_codeclient_elephant.php +++ b/htdocs/core/modules/societe/mod_codeclient_elephant.php @@ -56,7 +56,7 @@ class mod_codeclient_elephant extends ModeleThirdPartyCode /** * Dolibarr version of the loaded document - * @public string + * @var string */ public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' diff --git a/htdocs/core/modules/societe/mod_codeclient_leopard.php b/htdocs/core/modules/societe/mod_codeclient_leopard.php index c7d204a5010..727d2e09299 100644 --- a/htdocs/core/modules/societe/mod_codeclient_leopard.php +++ b/htdocs/core/modules/societe/mod_codeclient_leopard.php @@ -60,7 +60,7 @@ class mod_codeclient_leopard extends ModeleThirdPartyCode /** * Dolibarr version of the loaded document - * @public string + * @var string */ public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' diff --git a/htdocs/core/modules/societe/mod_codeclient_monkey.php b/htdocs/core/modules/societe/mod_codeclient_monkey.php index 69ee75911a6..f86be2ed96c 100644 --- a/htdocs/core/modules/societe/mod_codeclient_monkey.php +++ b/htdocs/core/modules/societe/mod_codeclient_monkey.php @@ -54,7 +54,7 @@ class mod_codeclient_monkey extends ModeleThirdPartyCode /** * Dolibarr version of the loaded document - * @public string + * @var string */ public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' diff --git a/htdocs/core/modules/societe/mod_codecompta_aquarium.php b/htdocs/core/modules/societe/mod_codecompta_aquarium.php index 1472bd982c7..e9c60b699cc 100644 --- a/htdocs/core/modules/societe/mod_codecompta_aquarium.php +++ b/htdocs/core/modules/societe/mod_codecompta_aquarium.php @@ -45,7 +45,7 @@ class mod_codecompta_aquarium extends ModeleAccountancyCode /** * Dolibarr version of the loaded document - * @public string + * @var string */ public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' diff --git a/htdocs/core/modules/societe/mod_codecompta_panicum.php b/htdocs/core/modules/societe/mod_codecompta_panicum.php index 373e20b8eb6..4c5ffcd66c5 100644 --- a/htdocs/core/modules/societe/mod_codecompta_panicum.php +++ b/htdocs/core/modules/societe/mod_codecompta_panicum.php @@ -44,7 +44,7 @@ class mod_codecompta_panicum extends ModeleAccountancyCode /** * Dolibarr version of the loaded document - * @public string + * @var string */ public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' diff --git a/htdocs/core/modules/supplier_invoice/mod_facture_fournisseur_cactus.php b/htdocs/core/modules/supplier_invoice/mod_facture_fournisseur_cactus.php index 8302db4ab31..5b6dee443d9 100644 --- a/htdocs/core/modules/supplier_invoice/mod_facture_fournisseur_cactus.php +++ b/htdocs/core/modules/supplier_invoice/mod_facture_fournisseur_cactus.php @@ -35,7 +35,7 @@ class mod_facture_fournisseur_cactus extends ModeleNumRefSuppliersInvoices { /** * Dolibarr version of the loaded document - * @public string + * @var string */ public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' diff --git a/htdocs/core/modules/supplier_invoice/mod_facture_fournisseur_tulip.php b/htdocs/core/modules/supplier_invoice/mod_facture_fournisseur_tulip.php index 8ab95ab3336..6925278c08e 100644 --- a/htdocs/core/modules/supplier_invoice/mod_facture_fournisseur_tulip.php +++ b/htdocs/core/modules/supplier_invoice/mod_facture_fournisseur_tulip.php @@ -38,7 +38,7 @@ class mod_facture_fournisseur_tulip extends ModeleNumRefSuppliersInvoices { /** * Dolibarr version of the loaded document - * @public string + * @var string */ public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' diff --git a/htdocs/core/modules/supplier_order/mod_commande_fournisseur_muguet.php b/htdocs/core/modules/supplier_order/mod_commande_fournisseur_muguet.php index 6f0cb59ca89..96dc9fbfd99 100644 --- a/htdocs/core/modules/supplier_order/mod_commande_fournisseur_muguet.php +++ b/htdocs/core/modules/supplier_order/mod_commande_fournisseur_muguet.php @@ -33,7 +33,7 @@ class mod_commande_fournisseur_muguet extends ModeleNumRefSuppliersOrders { /** * Dolibarr version of the loaded document - * @public string + * @var string */ public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' diff --git a/htdocs/core/modules/supplier_order/mod_commande_fournisseur_orchidee.php b/htdocs/core/modules/supplier_order/mod_commande_fournisseur_orchidee.php index 1d1bc920237..6154ba5e1d9 100644 --- a/htdocs/core/modules/supplier_order/mod_commande_fournisseur_orchidee.php +++ b/htdocs/core/modules/supplier_order/mod_commande_fournisseur_orchidee.php @@ -34,7 +34,7 @@ class mod_commande_fournisseur_orchidee extends ModeleNumRefSuppliersOrders { /** * Dolibarr version of the loaded document - * @public string + * @var string */ public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' diff --git a/htdocs/core/modules/supplier_payment/mod_supplier_payment_brodator.php b/htdocs/core/modules/supplier_payment/mod_supplier_payment_brodator.php index 2b29a18e2f0..e2407877a7b 100644 --- a/htdocs/core/modules/supplier_payment/mod_supplier_payment_brodator.php +++ b/htdocs/core/modules/supplier_payment/mod_supplier_payment_brodator.php @@ -32,7 +32,7 @@ class mod_supplier_payment_brodator extends ModeleNumRefSupplierPayments { /** * Dolibarr version of the loaded document - * @public string + * @var string */ public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' diff --git a/htdocs/core/modules/supplier_payment/mod_supplier_payment_bronan.php b/htdocs/core/modules/supplier_payment/mod_supplier_payment_bronan.php index e071f8d5505..e01c82cb445 100644 --- a/htdocs/core/modules/supplier_payment/mod_supplier_payment_bronan.php +++ b/htdocs/core/modules/supplier_payment/mod_supplier_payment_bronan.php @@ -31,7 +31,7 @@ class mod_supplier_payment_bronan extends ModeleNumRefSupplierPayments { /** * Dolibarr version of the loaded document - * @public string + * @var string */ public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' diff --git a/htdocs/core/modules/supplier_proposal/mod_supplier_proposal_marbre.php b/htdocs/core/modules/supplier_proposal/mod_supplier_proposal_marbre.php index 21c2a68e629..db9cec8e2c3 100644 --- a/htdocs/core/modules/supplier_proposal/mod_supplier_proposal_marbre.php +++ b/htdocs/core/modules/supplier_proposal/mod_supplier_proposal_marbre.php @@ -33,7 +33,7 @@ class mod_supplier_proposal_marbre extends ModeleNumRefSupplierProposal { /** * Dolibarr version of the loaded document - * @public string + * @var string */ public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' diff --git a/htdocs/core/modules/supplier_proposal/mod_supplier_proposal_saphir.php b/htdocs/core/modules/supplier_proposal/mod_supplier_proposal_saphir.php index d3a9de6c72b..343e16df8ed 100644 --- a/htdocs/core/modules/supplier_proposal/mod_supplier_proposal_saphir.php +++ b/htdocs/core/modules/supplier_proposal/mod_supplier_proposal_saphir.php @@ -35,7 +35,7 @@ class mod_supplier_proposal_saphir extends ModeleNumRefSupplierProposal { /** * Dolibarr version of the loaded document - * @public string + * @var string */ public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' diff --git a/htdocs/core/modules/ticket/mod_ticket_simple.php b/htdocs/core/modules/ticket/mod_ticket_simple.php index d121748c285..299c9c6a485 100644 --- a/htdocs/core/modules/ticket/mod_ticket_simple.php +++ b/htdocs/core/modules/ticket/mod_ticket_simple.php @@ -32,7 +32,7 @@ class mod_ticket_simple extends ModeleNumRefTicket { /** * Dolibarr version of the loaded document - * @public string + * @var string */ public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' diff --git a/htdocs/core/modules/ticket/mod_ticket_universal.php b/htdocs/core/modules/ticket/mod_ticket_universal.php index deb7c4481cc..361ecdd0c9d 100644 --- a/htdocs/core/modules/ticket/mod_ticket_universal.php +++ b/htdocs/core/modules/ticket/mod_ticket_universal.php @@ -31,7 +31,7 @@ class mod_ticket_universal extends ModeleNumRefTicket { /** * Dolibarr version of the loaded document - * @public string + * @var string */ public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' diff --git a/htdocs/core/tpl/card_presend.tpl.php b/htdocs/core/tpl/card_presend.tpl.php index 658ac2a98a5..27d6b8ca913 100644 --- a/htdocs/core/tpl/card_presend.tpl.php +++ b/htdocs/core/tpl/card_presend.tpl.php @@ -174,7 +174,7 @@ if ($action == 'presend') $listeuser=array(); $fuserdest = new User($db); - $result= $fuserdest->fetchAll('ASC', 't.lastname', 0, 0, array('customsql'=>'t.statut=1 AND t.employee=1 AND t.email IS NOT NULL AND t.email<>\'\'')); + $result= $fuserdest->fetchAll('ASC', 't.lastname', 0, 0, array('customsql'=>'t.statut=1 AND t.employee=1 AND t.email IS NOT NULL AND t.email<>\'\''), 'AND', true); if ($result>0 && is_array($fuserdest->users) && count($fuserdest->users)>0) { foreach($fuserdest->users as $uuserdest) { $listeuser[$uuserdest->id] = $uuserdest->user_get_property($uuserdest->id, 'email'); diff --git a/htdocs/core/tpl/commonfields_view.tpl.php b/htdocs/core/tpl/commonfields_view.tpl.php index 8e04f22166b..129c1a70575 100644 --- a/htdocs/core/tpl/commonfields_view.tpl.php +++ b/htdocs/core/tpl/commonfields_view.tpl.php @@ -49,7 +49,7 @@ foreach($object->fields as $key => $val) print '
'; if (! empty($val['help'])) print $form->textwithpicto($langs->trans($val['label']), $langs->trans($val['help'])); diff --git a/htdocs/core/tpl/notes.tpl.php b/htdocs/core/tpl/notes.tpl.php index 65876c7f1e5..fa972d38c71 100644 --- a/htdocs/core/tpl/notes.tpl.php +++ b/htdocs/core/tpl/notes.tpl.php @@ -70,7 +70,7 @@ elseif ($module == 'shipping') { $permission=$user->rights->expedition->cr elseif ($module == 'product') { $permission=$user->rights->produit->creer;} //else dol_print_error('','Bad value '.$module.' for param module'); -if (! empty($conf->fckeditor->enabled) && ! empty($conf->global->FCKEDITOR_ENABLE_SOCIETE)) $typeofdata='ckeditor:dolibarr_notes:100%:200::1:12:95%'; // Rem: This var is for all notes, not only thirdparties note. +if (! empty($conf->fckeditor->enabled) && ! empty($conf->global->FCKEDITOR_ENABLE_SOCIETE)) $typeofdata='ckeditor:dolibarr_notes:100%:200::1:12:95%:0'; // Rem: This var is for all notes, not only thirdparties note. else $typeofdata='textarea:12:95%'; print ''."\n"; diff --git a/htdocs/core/tpl/objectline_create.tpl.php b/htdocs/core/tpl/objectline_create.tpl.php index 388a9228024..04911584809 100644 --- a/htdocs/core/tpl/objectline_create.tpl.php +++ b/htdocs/core/tpl/objectline_create.tpl.php @@ -131,8 +131,10 @@ if ($nolinesbefore) { ?> situation_cycle_ref) { print ''; + print ''; } if (! empty($usemargins)) { @@ -161,18 +163,18 @@ if ($nolinesbefore) { ?> global->MAIN_VIEW_LINE_NUMBER)) { - $coldisplay=2; + $coldisplay++; ?> + } + $coldisplay++; + ?> - - multicurrency->enabled) && $this->multicurrency_code != $conf->currency) { ?> + multicurrency->enabled) && $this->multicurrency_code != $conf->currency) { + $coldisplay++; + ?> - + - + global->PRODUCT_USE_UNITS) { + $coldisplay++; print ''; } $remise_percent = $buyer->remise_percent; - if($object->element == 'supplier_proposal' || $object->element == 'order_supplier' || $object->element == 'invoice_supplier') { + if($object->element == 'supplier_proposal' || $object->element == 'order_supplier' || $object->element == 'invoice_supplier') + { $remise_percent = $seller->remise_supplier_percent; } + + $coldisplay++; ?> situation_cycle_ref) { $coldisplay++; print ''; + $coldisplay++; + print ''; } + if (! empty($usemargins)) { if (!empty($user->rights->margins->creer)) { + $coldisplay++; ?> rights->margins->creer) @@ -425,12 +445,9 @@ else { $coldisplay++; } } - else - { - if (! empty($conf->global->DISPLAY_MARGIN_RATES)) $coldisplay++; - if (! empty($conf->global->DISPLAY_MARK_RATES)) $coldisplay++; - } } + + $coldisplay+=$colspan; ?> > global->MAIN_VIEW_LINE_NUMBER)) { print ''; } ?> - global->MAIN_VIEW_LINE_NUMBER)) { ?> - + '; if (!empty($conf->multicurrency->enabled) && $this->multicurrency_code != $conf->currency) { + $coldisplay++; print ''; } @@ -182,6 +188,7 @@ $coldisplay=-1; // We remove first td global->PRODUCT_USE_UNITS) { + $coldisplay++; print ''; @@ -200,16 +207,17 @@ $coldisplay=-1; // We remove first td situation_cycle_ref) { $coldisplay++; - print ''; + print ''; + $coldisplay++; + print ''; } if (! empty($usemargins)) { - if (!empty($user->rights->margins->creer)) { -?> - - -rights->margins->creer) { if (! empty($conf->global->DISPLAY_MARGIN_RATES)) { @@ -245,7 +253,7 @@ $coldisplay=-1; // We remove first td ?> - @@ -262,9 +270,9 @@ if (!empty($extrafieldsline)) service->enabled) && $line->product_type == 1 && $dateSelector) { ?> global->MAIN_VIEW_LINE_NUMBER)) { ?> - + - situation_cycle_ref) { + $rounding = min($conf->global->MAIN_MAX_DECIMALS_UNIT, $conf->global->MAIN_MAX_DECIMALS_TOT); + + // Fields for situation invoices + if ($this->situation_cycle_ref) + { + include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php'; $coldisplay++; print ''; + $coldisplay++; + $locataxes_array = getLocalTaxesFromRate($line->tva.($line->vat_src_code ? ' ('.$line->vat_src_code.')' : ''), 0, ($senderissupplier?$mysoc:$object->thirdparty), ($senderissupplier?$object->thirdparty:$mysoc)); + $tmp = calcul_price_total($line->qty, $line->pu, $line->remise_percent, $line->txtva, -1, -1, 0, 'HT', $line->info_bits, $line->type, ($senderissupplier?$object->thirdparty:$mysoc), $locataxes_array, 100, $object->multicurrency_tx, $line->multicurrency_subprice); + print ''; } if ($usemargins && ! empty($conf->margin->enabled) && empty($user->societe_id)) { - $rounding = min($conf->global->MAIN_MAX_DECIMALS_UNIT, $conf->global->MAIN_MAX_DECIMALS_TOT); ?> rights->margins->creer)) { ?> diff --git a/htdocs/core/tpl/onlinepaymentlinks.tpl.php b/htdocs/core/tpl/onlinepaymentlinks.tpl.php index b32fcf3658a..990368d8738 100644 --- a/htdocs/core/tpl/onlinepaymentlinks.tpl.php +++ b/htdocs/core/tpl/onlinepaymentlinks.tpl.php @@ -29,21 +29,22 @@ print ''; // Url list print ''.$langs->trans("FollowingUrlAreAvailableToMakePayments").':

'; print img_picto('', 'object_globe.png').' '.$langs->trans("ToOfferALinkForOnlinePaymentOnFreeAmount", $servicename).':
'; -print ''.getOnlinePaymentUrl(1, 'free')."

\n"; +print ''.getOnlinePaymentUrl(1, 'free')."

\n"; if (! empty($conf->commande->enabled)) { - print img_picto('', 'object_globe.png').' '.$langs->trans("ToOfferALinkForOnlinePaymentOnOrder", $servicename).':
'; - print ''.getOnlinePaymentUrl(1, 'order')."
\n"; + print '
'; + print img_picto('', 'object_globe.png').' '.$langs->trans("ToOfferALinkForOnlinePaymentOnOrder", $servicename).':
'; + print ''.getOnlinePaymentUrl(1, 'order')."
\n"; if (! empty($conf->global->PAYMENT_SECURITY_TOKEN) && ! empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) { $langs->load("orders"); - print ''; + print ''; print $langs->trans("EnterRefToBuildUrl", $langs->transnoentitiesnoconv("Order")).': '; print ''; print ''; if (GETPOST('generate_order_ref', 'alpha')) { - print '
-> '; + print '
-> '; $url=getOnlinePaymentUrl(0, 'order', GETPOST('generate_order_ref', 'alpha')); print $url; print "
\n"; @@ -54,18 +55,19 @@ if (! empty($conf->commande->enabled)) } if (! empty($conf->facture->enabled)) { - print img_picto('', 'object_globe.png').' '.$langs->trans("ToOfferALinkForOnlinePaymentOnInvoice", $servicename).':
'; - print ''.getOnlinePaymentUrl(1, 'invoice')."
\n"; + print '
'; + print img_picto('', 'object_globe.png').' '.$langs->trans("ToOfferALinkForOnlinePaymentOnInvoice", $servicename).':
'; + print ''.getOnlinePaymentUrl(1, 'invoice')."
\n"; if (! empty($conf->global->PAYMENT_SECURITY_TOKEN) && ! empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) { $langs->load("bills"); - print ''; + print ''; print $langs->trans("EnterRefToBuildUrl", $langs->transnoentitiesnoconv("Invoice")).': '; print ''; print ''; if (GETPOST('generate_invoice_ref', 'alpha')) { - print '
-> '; + print '
-> '; $url=getOnlinePaymentUrl(0, 'invoice', GETPOST('generate_invoice_ref', 'alpha')); print $url; print "
\n"; @@ -76,18 +78,19 @@ if (! empty($conf->facture->enabled)) } if (! empty($conf->contrat->enabled)) { - print img_picto('', 'object_globe.png').' '.$langs->trans("ToOfferALinkForOnlinePaymentOnContractLine", $servicename).':
'; - print ''.getOnlinePaymentUrl(1, 'contractline')."
\n"; + print '
'; + print img_picto('', 'object_globe.png').' '.$langs->trans("ToOfferALinkForOnlinePaymentOnContractLine", $servicename).':
'; + print ''.getOnlinePaymentUrl(1, 'contractline')."
\n"; if (! empty($conf->global->PAYMENT_SECURITY_TOKEN) && ! empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) { $langs->load("contracts"); - print ''; + print ''; print $langs->trans("EnterRefToBuildUrl", $langs->transnoentitiesnoconv("ContractLine")).': '; print ''; print ''; if (GETPOST('generate_contract_ref')) { - print '
-> '; + print '
-> '; $url=getOnlinePaymentUrl(0, 'contractline', GETPOST('generate_contract_ref', 'alpha')); print $url; print "
\n"; @@ -98,18 +101,19 @@ if (! empty($conf->contrat->enabled)) } if (! empty($conf->adherent->enabled)) { - print img_picto('', 'object_globe.png').' '.$langs->trans("ToOfferALinkForOnlinePaymentOnMemberSubscription", $servicename).':
'; - print ''.getOnlinePaymentUrl(1, 'membersubscription')."
\n"; + print '
'; + print img_picto('', 'object_globe.png').' '.$langs->trans("ToOfferALinkForOnlinePaymentOnMemberSubscription", $servicename).':
'; + print ''.getOnlinePaymentUrl(1, 'membersubscription')."
\n"; if (! empty($conf->global->PAYMENT_SECURITY_TOKEN) && ! empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) { $langs->load("members"); - print ''; + print ''; print $langs->trans("EnterRefToBuildUrl", $langs->transnoentitiesnoconv("Member")).': '; print ''; print ''; if (GETPOST('generate_member_ref')) { - print '
-> '; + print '
-> '; $url=getOnlinePaymentUrl(0, 'membersubscription', GETPOST('generate_member_ref', 'alpha')); print $url; print "
\n"; @@ -120,18 +124,19 @@ if (! empty($conf->adherent->enabled)) } if (! empty($conf->don->enabled)) { + print '
'; print img_picto('', 'object_globe.png').' '.$langs->trans("ToOfferALinkForOnlinePaymentOnDonation", $servicename).':
'; - print ''.getOnlinePaymentUrl(1, 'donation')."
\n"; + print ''.getOnlinePaymentUrl(1, 'donation')."
\n"; if (! empty($conf->global->PAYMENT_SECURITY_TOKEN) && ! empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) { $langs->load("members"); - print ''; + print ''; print $langs->trans("EnterRefToBuildUrl", $langs->transnoentitiesnoconv("Don")).': '; print ''; print ''; if (GETPOST('generate_donation_ref')) { - print '
-> '; + print '
-> '; $url=getOnlinePaymentUrl(0, 'donation', GETPOST('generate_donation_ref', 'alpha')); print $url; print "
\n"; diff --git a/htdocs/core/triggers/interface_20_modWorkflow_WorkflowManager.class.php b/htdocs/core/triggers/interface_20_modWorkflow_WorkflowManager.class.php index 5e16b7cd582..2c5c27bc939 100644 --- a/htdocs/core/triggers/interface_20_modWorkflow_WorkflowManager.class.php +++ b/htdocs/core/triggers/interface_20_modWorkflow_WorkflowManager.class.php @@ -307,7 +307,7 @@ class InterfaceWorkflowManager extends DolibarrTriggers $diff_array=array_diff_assoc($qtyordred, $qtyshipped); if (count($diff_array)==0) { //No diff => mean everythings is shipped - $ret=$object->setStatut(Commande::STATUS_CLOSED, $object->origin_id, $object->origin); + $ret=$object->setStatut(Commande::STATUS_CLOSED, $object->origin_id, $object->origin, 'ORDER_CLOSE'); if ($ret<0) { $this->error=$object->error; $this->errors=$object->errors; return $ret; diff --git a/htdocs/core/website.inc.php b/htdocs/core/website.inc.php index 93ae53dc461..e09cf08480b 100644 --- a/htdocs/core/website.inc.php +++ b/htdocs/core/website.inc.php @@ -25,6 +25,8 @@ // Load website class include_once DOL_DOCUMENT_ROOT.'/website/class/website.class.php'; +include_once DOL_DOCUMENT_ROOT.'/website/class/websitepage.class.php'; + // Define $website if (! is_object($website)) { @@ -40,11 +42,15 @@ if (! is_object($weblangs)) if (! $pageid && ! empty($websitepagefile)) { $pageid = str_replace(array('.tpl.php', 'page'), array('', ''), basename($websitepagefile)); + if ($pageid == 'index.php') $pageid = $website->fk_default_home; } +if (! is_object($websitepage)) +{ + $websitepage=new WebsitePage($db); +} + if ($pageid > 0) { - include_once DOL_DOCUMENT_ROOT.'/website/class/websitepage.class.php'; - $websitepage=new WebsitePage($db); $websitepage->fetch($pageid); } diff --git a/htdocs/cron/class/cronjob.class.php b/htdocs/cron/class/cronjob.class.php index dafe772a0eb..4345385f16d 100644 --- a/htdocs/cron/class/cronjob.class.php +++ b/htdocs/cron/class/cronjob.class.php @@ -736,13 +736,12 @@ class Cronjob extends CommonObject /** * Load an object from its id and create a new one in database * + * @param User $user User making the clone * @param int $fromid Id of object to clone * @return int New id of clone */ - public function createFromClone($fromid) + public function createFromClone(User $user, $fromid) { - global $user,$langs; - $error=0; $object=new Cronjob($this->db); @@ -851,7 +850,6 @@ class Cronjob extends CommonObject if (! empty($conf->dol_no_mouse_hover)) $notooltip=1; // Force disable tooltips $result = ''; - $companylink = ''; $label = '' . $langs->trans("CronJob") . ''; $label.= '
'; diff --git a/htdocs/document.php b/htdocs/document.php index e784949c042..57897786f0d 100644 --- a/htdocs/document.php +++ b/htdocs/document.php @@ -169,6 +169,7 @@ $refname=basename(dirname($original_file)."/"); // Security check if (empty($modulepart)) accessforbidden('Bad value for parameter modulepart'); +// Check security and set return info with full path of file $check_access = dol_check_secure_access_document($modulepart, $original_file, $entity, $refname); $accessallowed = $check_access['accessallowed']; $sqlprotectagainstexternals = $check_access['sqlprotectagainstexternals']; diff --git a/htdocs/don/class/paymentdonation.class.php b/htdocs/don/class/paymentdonation.class.php index 4ec7c4aa874..b96719e01aa 100644 --- a/htdocs/don/class/paymentdonation.class.php +++ b/htdocs/don/class/paymentdonation.class.php @@ -408,13 +408,12 @@ class PaymentDonation extends CommonObject /** * Load an object from its id and create a new one in database * + * @param User $user User making the clone * @param int $fromid Id of object to clone * @return int New id of clone */ - public function createFromClone($fromid) + public function createFromClone(User $user, $fromid) { - global $user,$langs; - $error=0; $object=new PaymentDonation($this->db); diff --git a/htdocs/ecm/class/ecmfiles.class.php b/htdocs/ecm/class/ecmfiles.class.php index 4f4c8dfea61..57a18f5c339 100644 --- a/htdocs/ecm/class/ecmfiles.class.php +++ b/htdocs/ecm/class/ecmfiles.class.php @@ -707,15 +707,14 @@ class EcmFiles extends CommonObject /** * Load an object from its id and create a new one in database * - * @param int $fromid Id of object to clone - * - * @return int New id of clone + * @param User $user User making the clone + * @param int $fromid Id of object to clone + * @return int New id of clone */ - public function createFromClone($fromid) + public function createFromClone(User $user, $fromid) { dol_syslog(__METHOD__, LOG_DEBUG); - global $user; $error = 0; $object = new Ecmfiles($this->db); diff --git a/htdocs/ecm/index_auto.php b/htdocs/ecm/index_auto.php index 5f43426ae63..f068eed1319 100644 --- a/htdocs/ecm/index_auto.php +++ b/htdocs/ecm/index_auto.php @@ -332,6 +332,7 @@ if (! empty($conf->global->ECM_AUTO_TREE_ENABLED)) if (! empty($conf->ficheinter->enabled)) { $langs->load("interventions"); $rowspan++; $sectionauto[]=array('level'=>1, 'module'=>'fichinter', 'test'=>$conf->ficheinter->enabled, 'label'=>$langs->trans("Interventions"), 'desc'=>$langs->trans("ECMDocsByInterventions")); } if (! empty($conf->expensereport->enabled)) { $langs->load("trips"); $rowspan++; $sectionauto[]=array('level'=>1, 'module'=>'expensereport', 'test'=>$conf->expensereport->enabled, 'label'=>$langs->trans("ExpenseReports"), 'desc'=>$langs->trans("ECMDocsByExpenseReports")); } if (! empty($conf->holiday->enabled)) { $langs->load("holiday"); $rowspan++; $sectionauto[]=array('level'=>1, 'module'=>'holiday', 'test'=>$conf->holiday->enabled, 'label'=>$langs->trans("Holidays"), 'desc'=>$langs->trans("ECMDocsByHolidays")); } + if (! empty($conf->banque->enabled)) { $langs->load("banks"); $rowspan++; $sectionauto[]=array('level'=>1, 'module'=>'banque', 'test'=>$conf->banque->enabled, 'label'=>$langs->trans("BankAccount"), 'desc'=>$langs->trans("ECMDocsByBankAccount")); } $rowspan++; $sectionauto[]=array('level'=>1, 'module'=>'user', 'test'=>1, 'label'=>$langs->trans("Users"), 'desc'=>$langs->trans("ECMDocsByUsers")); } diff --git a/htdocs/emailcollector/class/emailcollector.class.php b/htdocs/emailcollector/class/emailcollector.class.php index 46fe3aed185..710afc05cec 100644 --- a/htdocs/emailcollector/class/emailcollector.class.php +++ b/htdocs/emailcollector/class/emailcollector.class.php @@ -92,8 +92,8 @@ class EmailCollector extends CommonObject */ public $fields=array( 'rowid' => array('type'=>'integer', 'label'=>'TechnicalID','visible'=>2, 'enabled'=>1, 'position'=>1, 'notnull'=>1, 'index'=>1), - 'entity' =>array('type'=>'integer', 'label'=>'Entity', 'enabled'=>1, 'visible'=>0, 'default'=>1, 'notnull'=>1, 'index'=>1, 'position'=>20), - 'ref' =>array('type'=>'varchar(128)', 'label'=>'Ref', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'showoncombobox'=>1, 'index'=>1, 'position'=>10, 'searchall'=>1, 'help'=>'Example: MyCollector1'), + 'entity' => array('type'=>'integer', 'label'=>'Entity', 'enabled'=>1, 'visible'=>0, 'default'=>1, 'notnull'=>1, 'index'=>1, 'position'=>20), + 'ref' => array('type'=>'varchar(128)', 'label'=>'Ref', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'showoncombobox'=>1, 'index'=>1, 'position'=>10, 'searchall'=>1, 'help'=>'Example: MyCollector1'), 'label' => array('type'=>'varchar(255)', 'label'=>'Label', 'visible'=>1, 'enabled'=>1, 'position'=>30, 'notnull'=>-1, 'searchall'=>1, 'help'=>'Example: My Email collector'), 'description' => array('type'=>'text', 'label'=>'Description', 'visible'=>-1, 'enabled'=>1, 'position'=>60, 'notnull'=>-1), 'host' => array('type'=>'varchar(255)', 'label'=>'EMailHost', 'visible'=>1, 'enabled'=>1, 'position'=>100, 'notnull'=>1, 'searchall'=>1, 'comment'=>"IMAP server", 'help'=>'Example: imap.gmail.com'), @@ -103,6 +103,7 @@ class EmailCollector extends CommonObject //'filter' => array('type'=>'text', 'label'=>'Filter', 'visible'=>1, 'enabled'=>1, 'position'=>105), //'actiontodo' => array('type'=>'varchar(255)', 'label'=>'ActionToDo', 'visible'=>1, 'enabled'=>1, 'position'=>106), 'target_directory' => array('type'=>'varchar(255)', 'label'=>'MailboxTargetDirectory', 'visible'=>1, 'enabled'=>1, 'position'=>110, 'notnull'=>0, 'comment'=>"Where to store messages once processed"), + 'maxemailpercollect' => array('type'=>'integer', 'label'=>'MaxEmailCollectPerCollect','visible'=>-1, 'enabled'=>1, 'position'=>111, 'default'=>100), 'datelastresult' => array('type'=>'datetime', 'label'=>'DateLastCollectResult', 'visible'=>1, 'enabled'=>'$action != "create" && $action != "edit"', 'position'=>121, 'notnull'=>-1,), 'codelastresult' => array('type'=>'varchar(16)', 'label'=>'CodeLastResult', 'visible'=>1, 'enabled'=>'$action != "create" && $action != "edit"', 'position'=>122, 'notnull'=>-1,), 'lastresult' => array('type'=>'varchar(255)', 'label'=>'LastResult', 'visible'=>1, 'enabled'=>'$action != "create" && $action != "edit"', 'position'=>123, 'notnull'=>-1,), @@ -167,6 +168,7 @@ class EmailCollector extends CommonObject public $password; public $source_directory; public $target_directory; + public $maxemailpercollect; public $datelastresult; public $lastresult; // END MODULEBUILDER PROPERTIES @@ -184,7 +186,7 @@ class EmailCollector extends CommonObject */ public function __construct(DoliDB $db) { - global $conf, $langs, $user; + global $conf, $langs; $this->db = $db; @@ -234,7 +236,7 @@ class EmailCollector extends CommonObject */ public function createFromClone(User $user, $fromid) { - global $langs, $hookmanager, $extrafields; + global $langs, $extrafields; $error = 0; dol_syslog(__METHOD__, LOG_DEBUG); @@ -337,8 +339,6 @@ class EmailCollector extends CommonObject $obj_ret = array(); - $socid = $user->societe_id ? $user->societe_id : ''; - $sql = "SELECT s.rowid"; $sql.= " FROM ".MAIN_DB_PREFIX."emailcollector_emailcollector as s"; $sql.= ' WHERE s.entity IN ('.getEntity('emailcollector').')'; @@ -358,6 +358,7 @@ class EmailCollector extends CommonObject $result = $this->db->query($sql); if ($result) { $num = $this->db->num_rows($result); + $i = 0; while ($i < $num) { $obj = $this->db->fetch_object($result); @@ -415,14 +416,11 @@ class EmailCollector extends CommonObject */ public function getNomUrl($withpicto = 0, $option = '', $notooltip = 0, $morecss = '', $save_lastsearch_value = -1) { - global $db, $conf, $langs, $hookmanager; - global $dolibarr_main_authentication, $dolibarr_main_demo; - global $menumanager; + global $conf, $langs, $hookmanager; if (! empty($conf->dol_no_mouse_hover)) $notooltip=1; // Force disable tooltips $result = ''; - $companylink = ''; $label = '' . $langs->trans("EmailCollector") . ''; $label.= '
'; @@ -721,12 +719,6 @@ class EmailCollector extends CommonObject return $nberror; } - /** - * overwitePropertiesOfObject - * - * @return int 0=OK, Nb of error if error - */ - /** * overwitePropertiesOfObject * @@ -759,7 +751,8 @@ class EmailCollector extends CommonObject } if ($tmpclass && ($tmpclass != $object->element)) continue; // Property is for another type of object - if (property_exists($object, $tmpproperty) || preg_match('/^options_/', $tmpproperty)) + //if (property_exists($object, $tmpproperty) || preg_match('/^options_/', $tmpproperty)) + if ($tmpproperty) { $sourcestring=''; $sourcefield=''; @@ -786,8 +779,12 @@ class EmailCollector extends CommonObject if ($sourcestring) { $regforval=array(); - //var_dump($regexstring);var_dump($sourcestring); - if (preg_match('/'.$regexstring.'/ms', $sourcestring, $regforval)) + $regexoptions=''; + if (strtolower($sourcefield) == 'body') $regexoptions='ms'; // The m means ^ and $ char is valid at each new line. The s means the char '.' is valid for new lines char too + if (strtolower($sourcefield) == 'header') $regexoptions='m'; // The m means ^ and $ char is valid at each new line. + + //var_dump($tmpproperty.' - '.$regexstring.' - '.$regexoptions.' - '.$sourcestring); + if (preg_match('/'.$regexstring.'/'.$regexoptions, $sourcestring, $regforval)) { //var_dump($regforval[1]);exit; // Overwrite param $tmpproperty @@ -798,7 +795,6 @@ class EmailCollector extends CommonObject // Regex not found $object->$tmpproperty = null; } - //var_dump($object->$tmpproperty);exit; } else { @@ -808,10 +804,36 @@ class EmailCollector extends CommonObject $this->errors[] = $this->error; } } - elseif (preg_match('/^SET:(.*)$/', $valueforproperty, $reg)) + elseif (preg_match('/^(SET|SETIFEMPTY):(.*)$/', $valueforproperty, $regforregex)) { - if (preg_match('/^options_/', $tmpproperty)) $object->array_options[preg_replace('/^options_/', '', $tmpproperty)] = $reg[1]; - else $object->$tmpproperty = $reg[1]; + $valuecurrent=''; + if (preg_match('/^options_/', $tmpproperty)) $valuecurrent = $object->array_options[preg_replace('/^options_/', '', $tmpproperty)]; + else $valuecurrent = $object->$tmpproperty; + + if ($regforregex[1] == 'SET' || empty($valuecurrent)) + { + $valuetouse = $regforregex[2]; + $substitutionarray=array(); + $matcharray=array(); + preg_match_all('/__([a-z0-9]+(?:_[a-z0-9]+)?)__/i', $valuetouse, $matcharray); + //var_dump($tmpproperty.' - '.$object->$tmpproperty.' - '.$valuetouse); var_dump($matcharray); + if (is_array($matcharray[1])) // $matcharray[1] is array with list of substitution key found without the __ + { + foreach($matcharray[1] as $keytoreplace) + { + if ($keytoreplace && isset($object->$keytoreplace)) + { + $substitutionarray['__'.$keytoreplace.'__']=$object->$keytoreplace; + } + } + } + //var_dump($substitutionarray); + dol_syslog(var_export($substitutionarray, true)); + //var_dump($substitutionarray); + $valuetouse = make_substitutions($valuetouse, $substitutionarray); + if (preg_match('/^options_/', $tmpproperty)) $object->array_options[preg_replace('/^options_/', '', $tmpproperty)] = $valuetouse; + else $object->$tmpproperty = $valuetouse; + } } else { @@ -891,7 +913,8 @@ class EmailCollector extends CommonObject $host=dol_getprefix('email'); // Define the IMAP search string - // See https://tools.ietf.org/html/rfc3501#section-6.4.4 + // See https://tools.ietf.org/html/rfc3501#section-6.4.4 for IMAPv4 (PHP not yet compatible) + // See https://tools.ietf.org/html/rfc1064 page 13 for IMAPv2 //$search='ALL'; $search='UNDELETED'; // Seems not supported by some servers $searchhead=''; @@ -909,8 +932,13 @@ class EmailCollector extends CommonObject if ($rule['type'] == 'body') $search.=($search?' ':'').'BODY "'.str_replace('"', '', $rule['rulevalue']).'"'; if ($rule['type'] == 'header') $search.=($search?' ':'').'HEADER '.$rule['rulevalue']; + if ($rule['type'] == 'notinsubject') $search.=($search?' ':'').'SUBJECT NOT "'.str_replace('"', '', $rule['rulevalue']).'"'; + if ($rule['type'] == 'notinbody') $search.=($search?' ':'').'BODY NOT "'.str_replace('"', '', $rule['rulevalue']).'"'; + if ($rule['type'] == 'seen') $search.=($search?' ':'').'SEEN'; if ($rule['type'] == 'unseen') $search.=($search?' ':'').'UNSEEN'; + if ($rule['type'] == 'unanswered') $search.=($search?' ':'').'UNANSWERED'; + if ($rule['type'] == 'answered') $search.=($search?' ':'').'ANSWERED'; if ($rule['type'] == 'smaller') $search.=($search?' ':'').'SMALLER "'.str_replace('"', '', $rule['rulevalue']).'"'; if ($rule['type'] == 'larger') $search.=($search?' ':'').'LARGER "'.str_replace('"', '', $rule['rulevalue']).'"'; @@ -949,9 +977,87 @@ class EmailCollector extends CommonObject // Loop on each email found if (! $error && ! empty($arrayofemail) && count($arrayofemail) > 0) { + // Loop to get part html and plain + /* + 0 multipart/mixed + 1 multipart/alternative + 1.1 text/plain + 1.2 text/html + 2 message/rfc822 + 2 multipart/mixed + 2.1 multipart/alternative + 2.1.1 text/plain + 2.1.2 text/html + 2.2 message/rfc822 + 2.2 multipart/alternative + 2.2.1 text/plain + 2.2.2 text/html + */ + /** + * create_part_array + * + * @param Object $structure Structure + * @param string $prefix prefix + * @return array Array with number and object + */ + /*function createPartArray($structure, $prefix = "") + { + //print_r($structure); + $part_array=array(); + if (count($structure->parts) > 0) { // There some sub parts + foreach ($structure->parts as $count => $part) { + addPartToArray($part, $prefix.($count+1), $part_array); + } + }else{ // Email does not have a seperate mime attachment for text + $part_array[] = array('part_number' => $prefix.'1', 'part_object' => $structure); + } + return $part_array; + }*/ + + /** + * Sub function for createPartArray(). Only called by createPartArray() and itself. + * + * @param Object $obj Structure + * @param string $partno Part no + * @param array $part_array array + * @return void + */ + /*function addPartToArray($obj, $partno, &$part_array) + { + $part_array[] = array('part_number' => $partno, 'part_object' => $obj); + if ($obj->type == 2) { // Check to see if the part is an attached email message, as in the RFC-822 type + //print_r($obj); + if (array_key_exists('parts', $obj)) { // Check to see if the email has parts + foreach ($obj->parts as $count => $part) { + // Iterate here again to compensate for the broken way that imap_fetchbody() handles attachments + if (count($part->parts) > 0) { + foreach ($part->parts as $count2 => $part2) { + addPartToArray($part2, $partno.".".($count2+1), $part_array); + } + }else{ // Attached email does not have a seperate mime attachment for text + $part_array[] = array('part_number' => $partno.'.'.($count+1), 'part_object' => $obj); + } + } + }else{ // Not sure if this is possible + $part_array[] = array('part_number' => $partno.'.1', 'part_object' => $obj); + } + }else{ // If there are more sub-parts, expand them out. + if (array_key_exists('parts', $obj)) { + foreach ($obj->parts as $count => $p) { + addPartToArray($p, $partno.".".($count+1), $part_array); + } + } + } + }*/ + + dol_syslog("Start of loop on email", LOG_INFO, 1); + foreach($arrayofemail as $imapemail) { - if ($nbemailprocessed > 100) break; // Do not process more than 100 email per launch + if ($nbemailprocessed > 1000) + { + break; // Do not process more than 1000 email per launch (this is a different protection than maxnbcollectedpercollect + } $header = imap_fetchheader($connection, $imapemail, 0); $matches=array(); @@ -992,124 +1098,63 @@ class EmailCollector extends CommonObject $this->db->begin(); - //$message = imap_body($connection, $imapemail, 0); + // GET Email meta datas $overview = imap_fetch_overview($connection, $imapemail, 0); + + dol_syslog("** Process email - msgid=".$overview[0]->message_id." date=".dol_print_date($overview[0]->udate, 'dayrfc', 'gmt')." subject=".$overview[0]->subject); + + // Parse IMAP email structure + global $htmlmsg, $plainmsg, $charset, $attachments; + $this->getmsg($connection, $imapemail); + + //$htmlmsg,$plainmsg,$charset,$attachments + $messagetext = $plainmsg ? $plainmsg : dol_string_nohtmltag($htmlmsg, 0); + /*var_dump($plainmsg); + var_dump($htmlmsg); + var_dump($messagetext);*/ + /*var_dump($charset); + var_dump($attachments); + exit;*/ + + // Parse IMAP email structure + /* $structure = imap_fetchstructure($connection, $imapemail, 0); $partplain = $parthtml = -1; - // Loop to get part html and plain - /* - 0 multipart/mixed - 1 multipart/alternative - 1.1 text/plain - 1.2 text/html - 2 message/rfc822 - 2 multipart/mixed - 2.1 multipart/alternative - 2.1.1 text/plain - 2.1.2 text/html - 2.2 message/rfc822 - 2.2 multipart/alternative - 2.2.1 text/plain - 2.2.2 text/html - */ - /** - * create_part_array - * - * @param Object $structure Structure - * @param string $prefix prefix - * @return array Array with number and object - */ - function createPartArray($structure, $prefix = "") - { - //print_r($structure); - if (count($structure->parts) > 0) { // There some sub parts - foreach ($structure->parts as $count => $part) { - add_part_to_array($part, $prefix.($count+1), $part_array); - } - }else{ // Email does not have a seperate mime attachment for text - $part_array[] = array('part_number' => $prefix.'1', 'part_object' => $obj); - } - return $part_array; - } - - /** - * Sub function for createPartArray(). Only called by createPartArray() and itself. - * - * @param Object $obj Structure - * @param string $partno Part no - * @param array $part_array array - * @return void - */ - function addPartToArray($obj, $partno, &$part_array) - { - $part_array[] = array('part_number' => $partno, 'part_object' => $obj); - if ($obj->type == 2) { // Check to see if the part is an attached email message, as in the RFC-822 type - //print_r($obj); - if (array_key_exists('parts', $obj)) { // Check to see if the email has parts - foreach ($obj->parts as $count => $part) { - // Iterate here again to compensate for the broken way that imap_fetchbody() handles attachments - if (count($part->parts) > 0) { - foreach ($part->parts as $count2 => $part2) { - addPartToArray($part2, $partno.".".($count2+1), $part_array); - } - }else{ // Attached email does not have a seperate mime attachment for text - $part_array[] = array('part_number' => $partno.'.'.($count+1), 'part_object' => $obj); - } - } - }else{ // Not sure if this is possible - $part_array[] = array('part_number' => $partno.'.1', 'part_object' => $obj); - } - }else{ // If there are more sub-parts, expand them out. - if (array_key_exists('parts', $obj)) { - foreach ($obj->parts as $count => $p) { - addPartToArray($p, $partno.".".($count+1), $part_array); - } - } - } - } + $encodingplain = $encodinghtml = ''; $result = createPartArray($structure, ''); - //var_dump($result);exit; + foreach($result as $part) { - if ($part['part_object']->subtype == 'HTML') $parthtml=$part['part_number']; - if ($part['part_object']->subtype == 'PLAIN') $partplain=$part['part_number']; + // $part['part_object']->type seems 0 for content + // $part['part_object']->type seems 5 for attachment + if (empty($part['part_object'])) continue; + if ($part['part_object']->subtype == 'HTML') + { + $parthtml=$part['part_number']; + if ($part['part_object']->encoding == 4) + { + $encodinghtml = 'aaa'; + } + } + if ($part['part_object']->subtype == 'PLAIN') + { + $partplain=$part['part_number']; + if ($part['part_object']->encoding == 4) + { + $encodingplain = 'rr'; + } + } } + //var_dump($result); var_dump($partplain); var_dump($parthtml); - /* OLD CODE to get parthtml and partplain - if (count($structure->parts) > 0) { // There some sub parts - foreach($structure->parts as $key => $part) - { - if ($part->subtype == 'HTML') $parthtml=($key+1); // For example: $parthtml = 1 or 2 - if ($part->subtype == 'PLAIN') $partplain=($key+1); - if ($part->subtype == 'ALTERNATIVE') - { - if (count($part->parts) > 0) - { - foreach($part->parts as $key2 => $part2) - { - if ($part2->subtype == 'HTML') $parthtml=($key+1).'.'.($key2+1); // For example: $parthtml = 1.1 or 1.2 - if ($part2->subtype == 'PLAIN') $partplain=($key+1).'.'.($key2+1); - } - } - else - { - $partplain=($key+1).'.1'; - } - } - } - } - else - { - $partplain=1; - }*/ - - /*var_dump($structure); + var_dump($structure); var_dump($parthtml); - var_dump($partplain);*/ + var_dump($partplain); $messagetext = imap_fetchbody($connection, $imapemail, ($parthtml != '-1' ? $parthtml : ($partplain != '-1' ? $partplain : 1)), FT_PEEK); + */ //var_dump($messagetext); //var_dump($structure->parts[0]->parts); @@ -1285,12 +1330,12 @@ class EmailCollector extends CommonObject elseif ($operation['type'] == 'ticket') $descriptiontitle = $langs->trans("TicketCreatedByEmailCollector", $msgid); else $descriptiontitle = $langs->trans("ActionAC_".$actioncode).' - '.$langs->trans("MailFrom").' '.$from; - $descriptionmeta = dol_concatdesc($descriptionmeta, $langs->trans("Topic").' : '.$subject); - $descriptionmeta = dol_concatdesc($descriptionmeta, $langs->trans("From").' : '.$fromstring); - if ($sender) $descriptionmeta = dol_concatdesc($descriptionmeta, $langs->trans("Sender").' : '.$sender); - $descriptionmeta = dol_concatdesc($descriptionmeta, $langs->trans("To").' : '.$to); - //if ($cc) $descriptionmeta = dol_concatdesc($descriptionmeta, $langs->trans("Cc").' : '.$cc); - //if ($bcc) $descriptionmeta = dol_concatdesc($descriptionmeta, $langs->trans("Bcc").' : '.$bcc); + $descriptionmeta = dol_concatdesc($descriptionmeta, $langs->trans("MailTopic").' : '.dol_escape_htmltag($subject)); + $descriptionmeta = dol_concatdesc($descriptionmeta, $langs->trans("MailFrom").($langs->trans("MailFrom") != 'From' ? ' (From)':'').' : '.dol_escape_htmltag($fromstring)); + if ($sender) $descriptionmeta = dol_concatdesc($descriptionmeta, $langs->trans("Sender").($langs->trans("Sender") != 'Sender' ? ' (Sender)':'').' : '.dol_escape_htmltag($sender)); + $descriptionmeta = dol_concatdesc($descriptionmeta, $langs->trans("MailTo").($langs->trans("MailTo") != 'To' ? ' (To)':'').' : '.dol_escape_htmltag($to)); + if ($sendtocc) $descriptionmeta = dol_concatdesc($descriptionmeta, $langs->trans("MailCC").($langs->trans("MailCC") != 'CC' ? ' (CC)':'').' : '.dol_escape_htmltag($sendtocc)); + //if ($bcc) $descriptionmeta = dol_concatdesc($descriptionmeta, $langs->trans("Bcc").' : '.dol_escape_htmltag($bcc)); } // Search and create thirdparty @@ -1348,20 +1393,20 @@ class EmailCollector extends CommonObject else { // Nothing can be done for this param - $errorforaction++; + $errorforactions++; $this->error = 'The extract rule to use to load thirdparty has on an unknown source (must be HEADER, SUBJECT or BODY)'; $this->errors[] = $this->error; } } - elseif (preg_match('/^SET:(.*)$/', $valueforproperty, $reg)) + elseif (preg_match('/^(SET|SETIFEMPTY):(.*)$/', $valueforproperty, $reg)) { //if (preg_match('/^options_/', $tmpproperty)) $object->array_options[preg_replace('/^options_/', '', $tmpproperty)] = $reg[1]; //else $object->$tmpproperty = $reg[1]; - $nametouseforthirdparty = $reg[1]; + $nametouseforthirdparty = $reg[2]; } else { - $errorforaction++; + $errorforactions++; $this->error = 'Bad syntax for description of action parameters: '.$actionparam; $this->errors[] = $this->error; break; @@ -1424,15 +1469,15 @@ class EmailCollector extends CommonObject { if ($projectstatic->id > 0) { - if ($projectfoundby) $descriptionmeta .= dol_concatdesc($descriptionmeta, 'Project found from '.$projectfoundby); + if ($projectfoundby) $descriptionmeta = dol_concatdesc($descriptionmeta, 'Project found from '.$projectfoundby); } if ($thirdpartystatic->id > 0) { - if ($thirdpartyfoundby) $descriptionmeta .= dol_concatdesc($descriptionmeta, 'Third party found from '.$thirdpartyfoundby); + if ($thirdpartyfoundby) $descriptionmeta = dol_concatdesc($descriptionmeta, 'Third party found from '.$thirdpartyfoundby); } if ($contactstatic->id > 0) { - if ($contactfoundby) $descriptionmeta .= dol_concatdesc($descriptionmeta, 'Contact/address found from '.$contactfoundby); + if ($contactfoundby) $descriptionmeta = dol_concatdesc($descriptionmeta, 'Contact/address found from '.$contactfoundby); } $description = $descriptiontitle; @@ -1502,12 +1547,12 @@ class EmailCollector extends CommonObject if ($thirdpartystatic->id > 0) { $projecttocreate->socid = $thirdpartystatic->id; - if ($thirdpartyfoundby) $descriptionmeta .= dol_concatdesc($descriptionmeta, 'Third party found from '.$thirdpartyfoundby); + if ($thirdpartyfoundby) $descriptionmeta = dol_concatdesc($descriptionmeta, 'Third party found from '.$thirdpartyfoundby); } if ($contactstatic->id > 0) { $projecttocreate->contact_id = $contactstatic->id; - if ($contactfoundby) $descriptionmeta .= dol_concatdesc($descriptionmeta, 'Contact/address found from '.$contactfoundby); + if ($contactfoundby) $descriptionmeta = dol_concatdesc($descriptionmeta, 'Contact/address found from '.$contactfoundby); } $description = $descriptiontitle; @@ -1524,45 +1569,65 @@ class EmailCollector extends CommonObject $percent_opp_status = dol_getIdFromCode($this->db, 'PROSP', 'c_lead_status', 'code', 'percent'); $projecttocreate->title = $subject; - $projecttocreate->date_start = $now; + $projecttocreate->date_start = $date; $projecttocreate->date_end = ''; $projecttocreate->opp_status = $id_opp_status; $projecttocreate->opp_percent = $percent_opp_status; $projecttocreate->description = dol_concatdesc(dolGetFirstLineOfText(dol_string_nohtmltag($description, 2), 10), '...'.$langs->transnoentities("SeePrivateNote").'...'); - $projecttocreate->note_private = dol_concatdesc($descriptionfull, dol_string_nohtmltag($descriptionfull, 2)); + $projecttocreate->note_private = $descriptionfull; $projecttocreate->entity = $conf->entity; - // Get next project Ref - $defaultref=''; - $modele = empty($conf->global->PROJECT_ADDON)?'mod_project_simple':$conf->global->PROJECT_ADDON; - - // Search template files - $file=''; $classname=''; $filefound=0; $reldir=''; - $dirmodels=array_merge(array('/'), (array) $conf->modules_parts['models']); - foreach($dirmodels as $reldir) - { - $file=dol_buildpath($reldir."core/modules/project/".$modele.'.php', 0); - if (file_exists($file)) - { - $filefound=1; - $classname = $modele; - break; - } - } - - if ($filefound) - { - $result=dol_include_once($reldir."core/modules/project/".$modele.'.php'); - $modProject = new $classname; - - $defaultref = $modProject->getNextValue(($thirdpartystatic->id > 0 ? $thirdpartystatic : null), $projecttocreate); - } - - $projecttocreate->ref = $defaultref; - - // Overwrite values with values extracted from source email + // Overwrite values with values extracted from source email. + // This may overwrite any $projecttocreate->xxx properties. + $savesocid = $projecttocreate->socid; $errorforthisaction = $this->overwritePropertiesOfObject($projecttocreate, $operation['actionparam'], $messagetext, $subject, $header); + // Set project ref if not yet defined + if (empty($projecttocreate->ref)) + { + // Get next project Ref + $defaultref=''; + $modele = empty($conf->global->PROJECT_ADDON)?'mod_project_simple':$conf->global->PROJECT_ADDON; + + // Search template files + $file=''; $classname=''; $filefound=0; $reldir=''; + $dirmodels=array_merge(array('/'), (array) $conf->modules_parts['models']); + foreach($dirmodels as $reldir) + { + $file=dol_buildpath($reldir."core/modules/project/".$modele.'.php', 0); + if (file_exists($file)) + { + $filefound=1; + $classname = $modele; + break; + } + } + + if ($filefound) + { + $result=dol_include_once($reldir."core/modules/project/".$modele.'.php'); + $modProject = new $classname; + + if ($savesocid > 0) + { + if ($savesocid != $projecttocreate->socid) + { + $errorforactions++; + setEventMessages('You loaded a thirdparty (id='.$savesocid.') and you force another thirdparty id (id='.$projecttocreate->socid.') by setting socid in operation with a different value'); + } + } + else { + if ($projecttocreate->socid > 0) + { + $thirdpartystatic->fetch($projecttocreate->socid); + } + } + + $defaultref = $modProject->getNextValue(($thirdpartystatic->id > 0 ? $thirdpartystatic : null), $projecttocreate); + } + $projecttocreate->ref = $defaultref; + } + if ($errorforthisaction) { $errorforactions++; @@ -1572,7 +1637,7 @@ class EmailCollector extends CommonObject if (empty($projecttocreate->ref) || (is_numeric($projecttocreate->ref) && $projecttocreate->ref <= 0)) { $errorforactions++; - $this->error = 'Failed to create project: Can\'t get a valid value for project Ref with numbering template '.$modele; + $this->error = 'Failed to create project: Can\'t get a valid value for the field ref with numbering template = '.$modele.', thirdparty id = '.$thirdpartystatic->id; } else { @@ -1594,12 +1659,12 @@ class EmailCollector extends CommonObject if ($thirdpartystatic->id > 0) { $tickettocreate->socid = $thirdpartystatic->id; - if ($thirdpartyfoundby) $descriptionmeta .= dol_concatdesc($descriptionmeta, 'Third party found from '.$thirdpartyfoundby); + if ($thirdpartyfoundby) $descriptionmeta = dol_concatdesc($descriptionmeta, 'Third party found from '.$thirdpartyfoundby); } if ($contactstatic->id > 0) { $tickettocreate->contact_id = $contactstatic->id; - if ($contactfoundby) $descriptionmeta .= dol_concatdesc($descriptionmeta, 'Contact/address found from '.$contactfoundby); + if ($contactfoundby) $descriptionmeta = dol_concatdesc($descriptionmeta, 'Contact/address found from '.$contactfoundby); } $description = $descriptiontitle; @@ -1619,44 +1684,65 @@ class EmailCollector extends CommonObject $tickettocreate->severity_code = 0; $tickettocreate->origin_email = $from; $tickettocreate->fk_user_create = $user->id; - $tickettocreate->entity = $conf->entity; $tickettocreate->datec = $date; $tickettocreate->fk_project = $projectstatic->id; $tickettocreate->fk_soc = $thirdpartystatic->id; $tickettocreate->notify_tiers_at_create = 0; + $tickettocreate->note_private = $descriptionfull; + $tickettocreate->entity = $conf->entity; //$tickettocreate->fk_contact = $contactstatic->id; - // Get next project Ref - $defaultref=''; - $modele = empty($conf->global->TICKET_ADDON)?'mod_ticket_simple':$conf->global->TICKET_ADDON; - - // Search template files - $file=''; $classname=''; $filefound=0; $reldir=''; - $dirmodels=array_merge(array('/'), (array) $conf->modules_parts['models']); - foreach($dirmodels as $reldir) - { - $file=dol_buildpath($reldir."core/modules/ticket/".$modele.'.php', 0); - if (file_exists($file)) - { - $filefound=1; - $classname = $modele; - break; - } - } - - if ($filefound) - { - $result=dol_include_once($reldir."core/modules/ticket/".$modele.'.php'); - $modTicket = new $classname; - - $defaultref = $modTicket->getNextValue(($thirdpartystatic->id > 0 ? $thirdpartystatic : null), $tickettocreate); - } - - $tickettocreate->ref = $defaultref; - - // Overwrite values with values extracted from source email + // Overwrite values with values extracted from source email. + // This may overwrite any $projecttocreate->xxx properties. + $savesocid = $tickettocreate->socid; $errorforthisaction = $this->overwritePropertiesOfObject($tickettocreate, $operation['actionparam'], $messagetext, $subject, $header); + // Set ticket ref if not yet defined + if (empty($tickettocreate->ref)) + { + // Get next project Ref + $defaultref=''; + $modele = empty($conf->global->TICKET_ADDON)?'mod_ticket_simple':$conf->global->TICKET_ADDON; + + // Search template files + $file=''; $classname=''; $filefound=0; $reldir=''; + $dirmodels=array_merge(array('/'), (array) $conf->modules_parts['models']); + foreach($dirmodels as $reldir) + { + $file=dol_buildpath($reldir."core/modules/ticket/".$modele.'.php', 0); + if (file_exists($file)) + { + $filefound=1; + $classname = $modele; + break; + } + } + + if ($filefound) + { + $result=dol_include_once($reldir."core/modules/ticket/".$modele.'.php'); + $modProject = new $classname; + + if ($savesocid > 0) + { + if ($savesocid != $tickettocreate->socid) + { + $errorforactions++; + setEventMessages('You loaded a thirdparty (id='.$savesocid.') and you force another thirdparty id (id='.$tickettocreate->socid.') by setting socid in operation with a different value'); + } + } + else { + if ($tickettocreate->socid > 0) + { + $thirdpartystatic->fetch($tickettocreate->socid); + } + } + + $defaultref = $modTicket->getNextValue(($thirdpartystatic->id > 0 ? $thirdpartystatic : null), $projecttocreate); + } + $tickettocreate->ref = $defaultref; + } + if ($errorforthisaction) { $errorforactions++; @@ -1666,7 +1752,7 @@ class EmailCollector extends CommonObject if (is_numeric($tickettocreate->ref) && $tickettocreate->ref <= 0) { $errorforactions++; - $this->error = "Failed to create ticket: Can't get a valid value for ticket Ref. Check the numbering module used to generate the reference in setup of module Ticket."; + $this->error = 'Failed to create ticket: Can\'t get a valid value for the field ref with numbering template = '.$modele.', thirdparty id = '.$thirdpartystatic->id; } else { @@ -1712,12 +1798,26 @@ class EmailCollector extends CommonObject $errorforemail++; } + unset($objectemail); + unset($projectstatic); + unset($thirdpartystatic); + unset($contactstatic); + + $nbemailprocessed++; + if (! $errorforemail) { $nbactiondone += $nbactiondoneforemail; $nbemailok++; $this->db->commit(); + + // Stop the loop to process email if we reach maximum collected per collect + if ($this->maxemailpercollect > 0 && $nbemailok >= $this->maxemailpercollect) + { + dol_syslog("EmailCollect::doCollectOneCollector We reach maximum of ".$nbemailok." collected with success, so we stop this collector now."); + break; + } } else { @@ -1725,16 +1825,11 @@ class EmailCollector extends CommonObject $this->db->rollback(); } - - $nbemailprocessed++; - - unset($objectemail); - unset($projectstatic); - unset($thirdpartystatic); - unset($contactstatic); } $output=$langs->trans('XEmailsDoneYActionsDone', $nbemailprocessed, $nbemailok, $nbactiondone); + + dol_syslog("End of loop on emails", LOG_INFO, -1); } else { @@ -1760,4 +1855,136 @@ class EmailCollector extends CommonObject return $error?-1:1; } + + + + // Loop to get part html and plain. Code found on PHP imap_fetchstructure documentation + + /** + * getmsg + * + * @param Object $mbox Structure + * @param string $mid prefix + * @return array Array with number and object + */ + private function getmsg($mbox, $mid) + { + // input $mbox = IMAP stream, $mid = message id + // output all the following: + global $charset,$htmlmsg,$plainmsg,$attachments; + $htmlmsg = $plainmsg = $charset = ''; + $attachments = array(); + + // HEADER + //$h = imap_header($mbox,$mid); + // add code here to get date, from, to, cc, subject... + + // BODY + $s = imap_fetchstructure($mbox, $mid); + + if (!$s->parts) // simple + $this->getpart($mbox, $mid, $s, 0); // pass 0 as part-number + else { // multipart: cycle through each part + foreach ($s->parts as $partno0=>$p) + { + $this->getpart($mbox, $mid, $p, $partno0+1); + } + } + } + + /* partno string + 0 multipart/mixed + 1 multipart/alternative + 1.1 text/plain + 1.2 text/html + 2 message/rfc822 + 2 multipart/mixed + 2.1 multipart/alternative + 2.1.1 text/plain + 2.1.2 text/html + 2.2 message/rfc822 + 2.2 multipart/alternative + 2.2.1 text/plain + 2.2.2 text/html + */ + /** + * Sub function for getpart(). Only called by createPartArray() and itself. + * + * @param Object $mbox Structure + * @param string $mid Part no + * @param Object $p Object p + * @param string $partno Partno + * @return void + */ + private function getpart($mbox, $mid, $p, $partno) + { + // $partno = '1', '2', '2.1', '2.1.3', etc for multipart, 0 if simple + global $htmlmsg,$plainmsg,$charset,$attachments; + + // DECODE DATA + $data = ($partno)? + imap_fetchbody($mbox, $mid, $partno): // multipart + imap_body($mbox, $mid); // simple + // Any part may be encoded, even plain text messages, so check everything. + if ($p->encoding==4) + $data = quoted_printable_decode($data); + elseif ($p->encoding==3) + $data = base64_decode($data); + + // PARAMETERS + // get all parameters, like charset, filenames of attachments, etc. + $params = array(); + if ($p->parameters) + { + foreach ($p->parameters as $x) + { + $params[strtolower($x->attribute)] = $x->value; + } + } + if ($p->dparameters) + { + foreach ($p->dparameters as $x) + { + $params[strtolower($x->attribute)] = $x->value; + } + } + + // ATTACHMENT + // Any part with a filename is an attachment, + // so an attached text file (type 0) is not mistaken as the message. + if ($params['filename'] || $params['name']) { + // filename may be given as 'Filename' or 'Name' or both + $filename = ($params['filename'])? $params['filename'] : $params['name']; + // filename may be encoded, so see imap_mime_header_decode() + $attachments[$filename] = $data; // this is a problem if two files have same name + } + + // TEXT + if ($p->type==0 && $data) { + // Messages may be split in different parts because of inline attachments, + // so append parts together with blank row. + if (strtolower($p->subtype)=='plain') + $plainmsg .= trim($data) ."\n\n"; + else + $htmlmsg .= $data ."

"; + $charset = $params['charset']; // assume all parts are same charset + } + + // EMBEDDED MESSAGE + // Many bounce notifications embed the original message as type 2, + // but AOL uses type 1 (multipart), which is not handled here. + // There are no PHP functions to parse embedded messages, + // so this just appends the raw source to the main message. + elseif ($p->type==2 && $data) { + $plainmsg .= $data."\n\n"; + } + + // SUBPART RECURSION + if ($p->parts) { + foreach ($p->parts as $partno0=>$p2) + { + $this->getpart($mbox, $mid, $p2, $partno.'.'.($partno0+1)); // 1.2, 1.2.1, etc. + } + } + } } diff --git a/htdocs/emailcollector/class/emailcollectorfilter.class.php b/htdocs/emailcollector/class/emailcollectorfilter.class.php index 75a94436ff9..f93ac51f673 100644 --- a/htdocs/emailcollector/class/emailcollectorfilter.class.php +++ b/htdocs/emailcollector/class/emailcollectorfilter.class.php @@ -159,7 +159,7 @@ class EmailCollectorFilter extends CommonObject $this->errors[]=$langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Type")); return -1; } - if (! in_array($this->type, array('seen','unseen','withtrackingid','withouttrackingid')) && empty($this->rulevalue)) + if (! in_array($this->type, array('seen', 'unseen', 'unanswered', 'answered', 'withtrackingid', 'withouttrackingid')) && empty($this->rulevalue)) { $langs->load("errors"); $this->errors[]=$langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("SearchString")); diff --git a/htdocs/expensereport/card.php b/htdocs/expensereport/card.php index 8f6f7c98c56..e6354c01105 100644 --- a/htdocs/expensereport/card.php +++ b/htdocs/expensereport/card.php @@ -145,7 +145,11 @@ if (empty($reshook)) include DOL_DOCUMENT_ROOT.'/core/actions_linkedfiles.inc.php'; - if (GETPOST('sendit', 'alpha')) $action=''; + if (GETPOSTISSET('sendit')) // If we just submit a file + { + if ($action == 'updateline') $action='editline'; // To avoid to make the updateline now + else $action=''; // To avoid to make the addline now + } include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not include_once @@ -167,7 +171,7 @@ if (empty($reshook)) // Because createFromClone modifies the object, we must clone it so that we can restore it later if it fails $orig = clone $object; - $result=$object->createFromClone(GETPOST('fk_user_author', 'int')); + $result=$object->createFromClone($user, GETPOST('fk_user_author', 'int')); if ($result > 0) { header("Location: ".$_SERVER['PHP_SELF'].'?id='.$result); @@ -2004,7 +2008,7 @@ else print '
'; print ''; - print ''; + print ''; $db->free($resql); } @@ -2209,7 +2213,7 @@ else { print ''; - print ''; + + print 'global->MAIN_OPTIMIZEFORTEXTBROWSER)?' style="display: none"':'').'>'; print ''; } else diff --git a/htdocs/fichinter/card.php b/htdocs/fichinter/card.php index 47e7dd48589..20d9d786354 100644 --- a/htdocs/fichinter/card.php +++ b/htdocs/fichinter/card.php @@ -134,7 +134,7 @@ if (empty($reshook)) // Because createFromClone modifies the object, we must clone it so that we can restore it later $orig = clone $object; - $result=$object->createFromClone($socid); + $result=$object->createFromClone($user, $socid); if ($result > 0) { header("Location: ".$_SERVER['PHP_SELF'].'?id='.$result); diff --git a/htdocs/fichinter/class/fichinter.class.php b/htdocs/fichinter/class/fichinter.class.php index db0ae47f7d2..807b547a4bc 100644 --- a/htdocs/fichinter/class/fichinter.class.php +++ b/htdocs/fichinter/class/fichinter.class.php @@ -1144,12 +1144,13 @@ class Fichinter extends CommonObject /** * Load an object from its id and create a new one in database * - * @param int $socid Id of thirdparty - * @return int New id of clone + * @param User $user User making the clone + * @param int $socid Id of thirdparty + * @return int New id of clone */ - public function createFromClone($socid = 0) + public function createFromClone(User $user, $socid = 0) { - global $user,$hookmanager; + global $hookmanager; $error=0; diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index f29fab91e45..f1910c5ab38 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -1409,11 +1409,12 @@ class CommandeFournisseur extends CommonOrder /** * Load an object from its id and create a new one in database * - * @return int New id of clone + * @param User $user User making the clone + * @return int New id of clone */ - public function createFromClone() + public function createFromClone(User $user) { - global $conf,$user,$langs,$hookmanager; + global $hookmanager; $error=0; diff --git a/htdocs/fourn/class/fournisseur.commande.dispatch.class.php b/htdocs/fourn/class/fournisseur.commande.dispatch.class.php index 6db4607573c..14c114efdbf 100644 --- a/htdocs/fourn/class/fournisseur.commande.dispatch.class.php +++ b/htdocs/fourn/class/fournisseur.commande.dispatch.class.php @@ -472,13 +472,12 @@ class CommandeFournisseurDispatch extends CommonObject /** * Load an object from its id and create a new one in database * - * @param int $fromid Id of object to clone + * @param User $user User making the clone + * @param int $fromid Id of object to clone * @return int New id of clone */ - public function createFromClone($fromid) + public function createFromClone(User $user, $fromid) { - global $user,$langs; - $error=0; $object=new Commandefournisseurdispatch($this->db); diff --git a/htdocs/fourn/commande/card.php b/htdocs/fourn/commande/card.php index a6abd723355..d1c8d444283 100644 --- a/htdocs/fourn/commande/card.php +++ b/htdocs/fourn/commande/card.php @@ -955,7 +955,7 @@ $result = $object->updateline( { if ($object->id > 0) { - $result=$object->createFromClone(); + $result=$object->createFromClone($user); if ($result > 0) { header("Location: ".$_SERVER['PHP_SELF'].'?id='.$result); @@ -2467,8 +2467,8 @@ elseif (! empty($object->id)) } // Create bill - if (! empty($conf->facture->enabled)) - { + //if (! empty($conf->facture->enabled)) + //{ if (! empty($conf->fournisseur->enabled) && ($object->statut >= 2 && $object->statut != 7 && $object->billed != 1)) // statut 2 means approved, 7 means canceled { if ($user->rights->fournisseur->facture->creer) @@ -2476,7 +2476,7 @@ elseif (! empty($object->id)) print ''.$langs->trans("CreateBill").''; } } - } + //} // Classify billed manually (need one invoice if module invoice is on, no condition on invoice if not) if ($user->rights->fournisseur->commande->creer && $object->statut >= 2 && $object->statut != 7 && $object->billed != 1) // statut 2 means approved @@ -2843,6 +2843,7 @@ elseif (! empty($object->id)) $modelmail='order_supplier_send'; $defaulttopic='SendOrderRef'; $diroutput = $conf->fournisseur->commande->dir_output; + $autocopy='MAIN_MAIL_AUTOCOPY_SUPPLIER_ORDER_TO'; $trackid = 'sor'.$object->id; include DOL_DOCUMENT_ROOT.'/core/tpl/card_presend.tpl.php'; diff --git a/htdocs/fourn/commande/orderstoinvoice.php b/htdocs/fourn/commande/orderstoinvoice.php index 6e3a30507dc..093e0fd331b 100644 --- a/htdocs/fourn/commande/orderstoinvoice.php +++ b/htdocs/fourn/commande/orderstoinvoice.php @@ -216,7 +216,7 @@ if (($action == 'create' || $action == 'add') && ! $error) { $fk_parent_line = 0; } // FIXME Missing $lines[$i]->ref_supplier and $lines[$i]->label into addline and updateline methods. They are filled when coming from order for example. - $result = $object->addline($desc, $lines[$i]->subprice, $lines[$i]->tva_tx, $lines[$i]->localtax1_tx, $lines[$i]->localtax2_tx, $lines[$i]->qty, $lines[$i]->fk_product, $lines[$i]->remise_percent, $date_start, $date_end, 0, $lines[$i]->info_bits, 'HT', $product_type, -1, false, 0, $lines[$i]->fk_unit); + $result = $object->addline($desc, $lines[$i]->subprice, $lines[$i]->tva_tx, $lines[$i]->localtax1_tx, $lines[$i]->localtax2_tx, $lines[$i]->qty, $lines[$i]->fk_product, $lines[$i]->remise_percent, $date_start, $date_end, 0, $lines[$i]->info_bits, 'HT', $product_type, -1, false, 0, $lines[$i]->fk_unit, $line[$i]->id); if ($result > 0) { $lineid = $result; @@ -298,11 +298,23 @@ if ($action == 'create' && !$error) { if ($socid) $res = $soc->fetch($socid); if ($res) { - $cond_reglement_id = $soc->cond_reglement_id; - $mode_reglement_id = $soc->mode_reglement_id; + $cond_reglement_id = $soc->cond_reglement_supplier_id; + $mode_reglement_id = $soc->mode_reglement_supplier_id; } $dateinvoice = empty($conf->global->MAIN_AUTOFILL_DATE) ? - 1 : ''; + $objectsrc = new CommandeFournisseur($db); + $listoforders = array(); + foreach ($selected as $sel) { + $result = $objectsrc->fetch($sel); + if ($result > 0) { + $listoforders[] = $objectsrc->ref; + } + + if (empty($cond_reglement_id)) $cond_reglement_id = $objectsrc->cond_reglement_id; + if (empty($mode_reglement_id)) $mode_reglement_id = $objectsrc->mode_reglement_id; + } + print ''; print ''; print ''; @@ -350,15 +362,6 @@ if ($action == 'create' && !$error) { print ''; } - $objectsrc = new CommandeFournisseur($db); - $listoforders = array (); - foreach ($selected as $sel) { - $result = $objectsrc->fetch($sel); - if ($result > 0) { - $listoforders[] = $objectsrc->ref; - } - } - // Other attributes $parameters = array ( 'objectsrc' => $objectsrc, diff --git a/htdocs/fourn/facture/card.php b/htdocs/fourn/facture/card.php index 6dc48d88753..5c47aa41f40 100644 --- a/htdocs/fourn/facture/card.php +++ b/htdocs/fourn/facture/card.php @@ -3228,6 +3228,7 @@ else $modelmail='invoice_supplier_send'; $defaulttopic='SendBillRef'; $diroutput = $conf->fournisseur->facture->dir_output; + $autocopy='MAIN_MAIL_AUTOCOPY_SUPPLIER_INVOICE_TO'; $trackid = 'sin'.$object->id; include DOL_DOCUMENT_ROOT.'/core/tpl/card_presend.tpl.php'; diff --git a/htdocs/includes/odtphp/odf.php b/htdocs/includes/odtphp/odf.php index 2c2d90e96d9..6b3a6400bc3 100644 --- a/htdocs/includes/odtphp/odf.php +++ b/htdocs/includes/odtphp/odf.php @@ -584,7 +584,7 @@ IMG; // using windows libreoffice that must be in path // using linux/mac libreoffice that must be in path // Note PHP Config "fastcgi.impersonate=0" must set to 0 - Default is 1 - $command ='soffice -headless -convert-to pdf -outdir '. escapeshellarg(dirname($name)). " ".escapeshellarg($name); + $command ='soffice --headless --convert-to pdf --outdir '. escapeshellarg(dirname($name)). " ".escapeshellarg($name); } elseif (preg_match('/unoconv/', $conf->global->MAIN_ODT_AS_PDF)) { @@ -635,6 +635,7 @@ IMG; //$command = DOL_DOCUMENT_ROOT.'/includes/odtphp/odt2pdf.sh '.$name.' '.$dirname; dol_syslog(get_class($this).'::exportAsAttachedPDF $execmethod='.$execmethod.' Run command='.$command,LOG_DEBUG); + $retval=0; $output_arr=array(); if ($execmethod == 1) { exec($command, $output_arr, $retval); @@ -665,6 +666,7 @@ IMG; if ($retval == 0) { dol_syslog(get_class($this).'::exportAsAttachedPDF $ret_val='.$retval, LOG_DEBUG); + $filename=''; $linenum=0; if (headers_sent($filename, $linenum)) { throw new OdfException("headers already sent ($filename at $linenum)"); } @@ -681,16 +683,17 @@ IMG; } } else { dol_syslog(get_class($this).'::exportAsAttachedPDF $ret_val='.$retval, LOG_DEBUG); - dol_syslog(get_class($this).'::exportAsAttachedPDF $output_arr='.var_export($output_arr,true), LOG_DEBUG); + dol_syslog(get_class($this).'::exportAsAttachedPDF $output_arr='.var_export($output_arr, true), LOG_DEBUG); if ($retval==126) { throw new OdfException('Permission execute convert script : ' . $command); } else { + $errorstring=''; foreach($output_arr as $line) { - $errors.= $line."
"; + $errorstring.= $line."
"; } - throw new OdfException('ODT to PDF convert fail : ' . $errors); + throw new OdfException('ODT to PDF convert fail (option MAIN_ODT_AS_PDF is '.$conf->global->MAIN_ODT_AS_PDF.', command was '.$command.', retval='.$retval.') : ' . $errorstring); } } } diff --git a/htdocs/index.php b/htdocs/index.php index bc918ab76f4..9c78693a68e 100644 --- a/htdocs/index.php +++ b/htdocs/index.php @@ -36,7 +36,6 @@ $action=GETPOST('action', 'aZ09'); $hookmanager->initHooks(array('index')); - /* * Actions */ diff --git a/htdocs/install/check.php b/htdocs/install/check.php index 8b1fbba0c1b..55331634aff 100644 --- a/htdocs/install/check.php +++ b/htdocs/install/check.php @@ -569,7 +569,7 @@ else if (count($notavailable_choices)) { print '
'; - print ' '.$langs->trans('ShowNotAvailableOptions').'...'; + print '> '.$langs->trans('ShowNotAvailableOptions').'...'; print '
'; print '
'; } @@ -1218,21 +1218,19 @@ else print ''; - if ($conf->global->MAIN_FEATURES_LEVEL) + // Accountancy_code_sell_intra + if ($mysoc->isInEEC()) { - // Accountancy_code_sell_intra - if ($mysoc->isInEEC()) { - print ''; - print ''; - } - - // Accountancy_code_sell_export - print ''; - print ''; + print ''; } + // Accountancy_code_sell_export + print ''; + print ''; + // Accountancy_code_buy print ''; print ''; } @@ -1514,24 +1512,21 @@ else print $formaccounting->select_account($object->accountancy_code_sell, 'accountancy_code_sell', 1, '', 1, 1); print ''; - if ($conf->global->MAIN_FEATURES_LEVEL) + // Accountancy_code_sell_intra + if ($mysoc->isInEEC()) { - // Accountancy_code_sell_intra - if ($mysoc->isInEEC()) - { - print ''; - print ''; - } - - // Accountancy_code_sell_export - print ''; + print ''; print ''; } + // Accountancy_code_sell_export + print ''; + print ''; + // Accountancy_code_buy print ''; print ''; - if ($conf->global->MAIN_FEATURES_LEVEL) + // Accountancy_code_sell_intra + if ($mysoc->isInEEC()) { - // Accountancy_code_sell_intra - if ($mysoc->isInEEC()) - { - print ''; - print ''; - } - - // Accountancy_code_sell_export - print ''; - print ''; + print ''; } + // Accountancy_code_sell_export + print ''; + print ''; + // Accountancy_code_buy print ''; print ''; - if ($conf->global->MAIN_FEATURES_LEVEL) + // Accountancy sell code intra-community + if ($mysoc->isInEEC()) { - // Accountancy sell code intra-community - if ($mysoc->isInEEC()) - { - print ''; - } - - // Accountancy sell code export print ''; } + // Accountancy sell code export + print ''; + // Accountancy buy code print ''; // Accountancy code sell - if (! empty($arrayfields['p.accountancy_code_sell']['checked'])) print ''; - // Accountancy code sell + if (! empty($arrayfields['p.accountancy_code_sell']['checked'])) print ''; + if (! empty($arrayfields['p.accountancy_code_sell_intra']['checked'])) print ''; + if (! empty($arrayfields['p.accountancy_code_sell_export']['checked'])) print ''; + // Accountancy code buy if (! empty($arrayfields['p.accountancy_code_buy']['checked'])) print ''; // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php'; @@ -723,7 +737,13 @@ if ($resql) if (! empty($arrayfields['p.accountancy_code_sell']['checked'])) { print_liste_field_titre($arrayfields['p.accountancy_code_sell']['label'], $_SERVER["PHP_SELF"], "p.accountancy_code_sell", "", $param, '', $sortfield, $sortorder); } - if (! empty($arrayfields['p.accountancy_code_buy']['checked'])) { + if (! empty($arrayfields['p.accountancy_code_sell_intra']['checked'])) { + print_liste_field_titre($arrayfields['p.accountancy_code_sell_intra']['label'], $_SERVER["PHP_SELF"], "p.accountancy_code_sell_intra", "", $param, '', $sortfield, $sortorder); + } + if (! empty($arrayfields['p.accountancy_code_sell_export']['checked'])) { + print_liste_field_titre($arrayfields['p.accountancy_code_sell_export']['label'], $_SERVER["PHP_SELF"], "p.accountancy_code_sell_export", "", $param, '', $sortfield, $sortorder); + } + if (! empty($arrayfields['p.accountancy_code_buy']['checked'])) { print_liste_field_titre($arrayfields['p.accountancy_code_buy']['label'], $_SERVER["PHP_SELF"], "p.accountancy_code_buy", "", $param, '', $sortfield, $sortorder); } // Extra fields @@ -1032,7 +1052,17 @@ if ($resql) print ''; if (! $i) $totalarray['nbfield']++; } - // Accountancy code sell + if (! empty($arrayfields['p.accountancy_code_sell_intra']['checked'])) + { + print ''; + if (! $i) $totalarray['nbfield']++; + } + if (! empty($arrayfields['p.accountancy_code_sell_export']['checked'])) + { + print ''; + if (! $i) $totalarray['nbfield']++; + } + // Accountancy code buy if (! empty($arrayfields['p.accountancy_code_buy']['checked'])) { print ''; diff --git a/htdocs/product/stock/class/productlot.class.php b/htdocs/product/stock/class/productlot.class.php index 9dc1856c64e..f3cec8f9a98 100644 --- a/htdocs/product/stock/class/productlot.class.php +++ b/htdocs/product/stock/class/productlot.class.php @@ -426,15 +426,14 @@ class Productlot extends CommonObject /** * Load an object from its id and create a new one in database * - * @param int $fromid Id of object to clone - * - * @return int New id of clone + * @param User $user User making the clone + * @param int $fromid Id of object to clone + * @return int New id of clone */ - public function createFromClone($fromid) + public function createFromClone(User $user, $fromid) { dol_syslog(__METHOD__, LOG_DEBUG); - global $user; $error = 0; $object = new Productlot($this->db); diff --git a/htdocs/product/stock/class/productstockentrepot.class.php b/htdocs/product/stock/class/productstockentrepot.class.php index 36e302bf661..0cbedb6d347 100644 --- a/htdocs/product/stock/class/productstockentrepot.class.php +++ b/htdocs/product/stock/class/productstockentrepot.class.php @@ -420,15 +420,14 @@ class ProductStockEntrepot extends CommonObject /** * Load an object from its id and create a new one in database * - * @param int $fromid Id of object to clone - * - * @return int New id of clone + * @param User $user User making the clone + * @param int $fromid Id of object to clone + * @return int New id of clone */ - public function createFromClone($fromid) + public function createFromClone(User $user, $fromid) { dol_syslog(__METHOD__, LOG_DEBUG); - global $user; $error = 0; $object = new ProductStockEntrepot($this->db); diff --git a/htdocs/projet/card.php b/htdocs/projet/card.php index 7023f2d871e..88bda602721 100644 --- a/htdocs/projet/card.php +++ b/htdocs/projet/card.php @@ -429,7 +429,7 @@ if (empty($reshook)) $move_date=GETPOST('move_date')?1:0; $clone_thirdparty=GETPOST('socid', 'int')?GETPOST('socid', 'int'):0; - $result=$object->createFromClone($object->id, $clone_contacts, $clone_tasks, $clone_project_files, $clone_task_files, $clone_notes, $move_date, 0, $clone_thirdparty); + $result=$object->createFromClone($user, $object->id, $clone_contacts, $clone_tasks, $clone_project_files, $clone_task_files, $clone_notes, $move_date, 0, $clone_thirdparty); if ($result <= 0) { setEventMessages($object->error, $object->errors, 'errors'); @@ -450,7 +450,7 @@ if (empty($reshook)) // Actions to send emails $trigger_name='PROJECT_SENTBYMAIL'; $paramname='id'; - $autocopy='MAIN_MAIL_AUTOCOPY_ORDER_TO'; // used to know the automatic BCC to add + $autocopy='MAIN_MAIL_AUTOCOPY_PROJECT_TO'; // used to know the automatic BCC to add $trackid='proj'.$object->id; include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php'; } @@ -1295,6 +1295,7 @@ elseif ($object->id > 0) $modelmail='project'; $defaulttopic='SendProjectRef'; $diroutput = $conf->projet->dir_output; + $autocopy='MAIN_MAIL_AUTOCOPY_PROJECT_TO'; // used to know the automatic BCC to add $trackid = 'proj'.$object->id; include DOL_DOCUMENT_ROOT.'/core/tpl/card_presend.tpl.php'; diff --git a/htdocs/projet/class/project.class.php b/htdocs/projet/class/project.class.php index 59d24e5eb3d..09eadbbc8ea 100644 --- a/htdocs/projet/class/project.class.php +++ b/htdocs/projet/class/project.class.php @@ -1274,20 +1274,21 @@ class Project extends CommonObject /** * Load an object from its id and create a new one in database * - * @param int $fromid Id of object to clone - * @param bool $clone_contact Clone contact of project - * @param bool $clone_task Clone task of project - * @param bool $clone_project_file Clone file of project - * @param bool $clone_task_file Clone file of task (if task are copied) - * @param bool $clone_note Clone note of project - * @param bool $move_date Move task date on clone - * @param integer $notrigger No trigger flag - * @param int $newthirdpartyid New thirdparty id - * @return int New id of clone + * @param User $user User making the clone + * @param int $fromid Id of object to clone + * @param bool $clone_contact Clone contact of project + * @param bool $clone_task Clone task of project + * @param bool $clone_project_file Clone file of project + * @param bool $clone_task_file Clone file of task (if task are copied) + * @param bool $clone_note Clone note of project + * @param bool $move_date Move task date on clone + * @param integer $notrigger No trigger flag + * @param int $newthirdpartyid New thirdparty id + * @return int New id of clone */ - public function createFromClone($fromid, $clone_contact = false, $clone_task = true, $clone_project_file = false, $clone_task_file = false, $clone_note = true, $move_date = true, $notrigger = 0, $newthirdpartyid = 0) + public function createFromClone(User $user, $fromid, $clone_contact = false, $clone_task = true, $clone_project_file = false, $clone_task_file = false, $clone_note = true, $move_date = true, $notrigger = 0, $newthirdpartyid = 0) { - global $user,$langs,$conf; + global $langs,$conf; $error=0; @@ -1477,7 +1478,7 @@ class Project extends CommonObject // Loop on each task, to clone it foreach ($tasksarray as $tasktoclone) { - $result_clone = $taskstatic->createFromClone($tasktoclone->id, $clone_project_id, $tasktoclone->fk_parent, $move_date, true, false, $clone_task_file, true, false); + $result_clone = $taskstatic->createFromClone($user, $tasktoclone->id, $clone_project_id, $tasktoclone->fk_parent, $move_date, true, false, $clone_task_file, true, false); if ($result_clone <= 0) { $this->error.=$result_clone->error; diff --git a/htdocs/projet/class/task.class.php b/htdocs/projet/class/task.class.php index 8c12131ce50..a5f63e32826 100644 --- a/htdocs/projet/class/task.class.php +++ b/htdocs/projet/class/task.class.php @@ -1587,6 +1587,7 @@ class Task extends CommonObject /** Load an object from its id and create a new one in database * + * @param User $user User making the clone * @param int $fromid Id of object to clone * @param int $project_id Id of project to attach clone task * @param int $parent_task_id Id of task to attach clone task @@ -1598,9 +1599,9 @@ class Task extends CommonObject * @param bool $clone_prog clone progress of project * @return int New id of clone */ - public function createFromClone($fromid, $project_id, $parent_task_id, $clone_change_dt = false, $clone_affectation = false, $clone_time = false, $clone_file = false, $clone_note = false, $clone_prog = false) + public function createFromClone(User $user, $fromid, $project_id, $parent_task_id, $clone_change_dt = false, $clone_affectation = false, $clone_time = false, $clone_file = false, $clone_note = false, $clone_prog = false) { - global $user,$langs,$conf; + global $langs,$conf; $error=0; diff --git a/htdocs/projet/element.php b/htdocs/projet/element.php index 0169d1d9018..a2c2ea36f7d 100644 --- a/htdocs/projet/element.php +++ b/htdocs/projet/element.php @@ -474,7 +474,7 @@ $listofreferent=array( 'lang'=>'banks', 'buttonnew'=>'AddVariousPayment', 'testnew'=>$user->rights->banque->modifier, - 'test'=>$conf->banque->enabled && $user->rights->banque->lire), + 'test'=>$conf->banque->enabled && $user->rights->banque->lire && empty($conf->global->BANK_USE_OLD_VARIOUS_PAYMENT)), /* No need for this, available on dedicated tab "Agenda/Events" 'agenda'=>array( 'name'=>"Agenda", diff --git a/htdocs/projet/list.php b/htdocs/projet/list.php index 1a7fb9317e1..c58ac17f980 100644 --- a/htdocs/projet/list.php +++ b/htdocs/projet/list.php @@ -279,7 +279,7 @@ if (count($listofprojectcontacttype) == 0) $listofprojectcontacttype[0]='0'; $distinct='DISTINCT'; // We add distinct until we are added a protection to be sure a contact of a project and task is only once. $sql = "SELECT ".$distinct." p.rowid as id, p.ref, p.title, p.fk_statut, p.fk_opp_status, p.public, p.fk_user_creat"; $sql.= ", p.datec as date_creation, p.dateo as date_start, p.datee as date_end, p.opp_amount, p.opp_percent, p.tms as date_update, p.budget_amount, p.bill_time"; -$sql.= ", s.nom as name, s.rowid as socid"; +$sql.= ", s.rowid as socid, s.nom as name, s.email"; $sql.= ", cls.code as opp_status_code"; // We'll need these fields in order to filter by categ if ($search_categ) $sql .= ", cs.fk_categorie, cs.fk_project"; @@ -706,6 +706,10 @@ while ($i < min($num, $limit)) $userAccess = $object->restrictedProjectArea($user); // why this ? if ($userAccess >= 0) { + $socstatic->id=$obj->socid; + $socstatic->name=$obj->name; + $socstatic->email=$obj->email; + print ''; // Project url @@ -731,8 +735,6 @@ while ($i < min($num, $limit)) print ''; diff --git a/htdocs/public/payment/newpayment.php b/htdocs/public/payment/newpayment.php index ac873ad13b5..f06228291ef 100644 --- a/htdocs/public/payment/newpayment.php +++ b/htdocs/public/payment/newpayment.php @@ -263,7 +263,7 @@ elseif (! empty($conf->global->$paramcreditor)) $creditor=$conf->global->$paramc * Actions */ -// Action dopayment is called after choosing the payment mode +// Action dopayment is called after clicking/choosing the payment mode if ($action == 'dopayment') { if ($paymentmethod == 'paypal') @@ -395,7 +395,8 @@ if ($action == 'dopayment') } -// Called when choosing Stripe mode, after the 'dopayment' +// Called when choosing Stripe mode, after clicking the 'dopayment' with the Charge API architecture. +// When using the PaymentItent architecture, we dont need this, the Stripe customer is created when creating PaymentItent when showing payment page. if ($action == 'charge' && ! empty($conf->stripe->enabled)) { $amountstripe = $amount; @@ -484,8 +485,8 @@ if ($action == 'charge' && ! empty($conf->stripe->enabled)) 'metadata' => $metadata, 'customer' => $customer->id, 'source' => $card, - 'statement_descriptor' => dol_trunc(dol_trunc(dol_string_unaccent($mysoc->name), 6, 'right', 'UTF-8', 1).' '.$FULLTAG, 22, 'right', 'UTF-8', 1) // 22 chars that appears on bank receipt - ), array("idempotency_key" => "$ref", "stripe_account" => "$stripeacc")); + 'statement_descriptor' => dol_trunc($FULLTAG, 10, 'right', 'UTF-8', 1), // 22 chars that appears on bank receipt (company + description) + ), array("idempotency_key" => "$FULLTAG", "stripe_account" => "$stripeacc")); // Return $charge = array('id'=>'ch_XXXX', 'status'=>'succeeded|pending|failed', 'failure_code'=>, 'failure_message'=>...) if (empty($charge)) { @@ -509,7 +510,7 @@ if ($action == 'charge' && ! empty($conf->stripe->enabled)) if (empty($vatcleaned)) $taxinfo=null; dol_syslog("Create anonymous customer card profile", LOG_DEBUG, 0, '_stripe'); -$customer = \Stripe\Customer::create(array( + $customer = \Stripe\Customer::create(array( 'email' => $email, 'description' => ($email?'Anonymous customer for '.$email:'Anonymous customer'), 'metadata' => $metadata, @@ -525,15 +526,15 @@ $customer = \Stripe\Customer::create(array( // The customer was just created with a source, so we can make a charge // with no card defined, the source just used for customer creation will be used. dol_syslog("Create charge", LOG_DEBUG, 0, '_stripe'); -$charge = \Stripe\Charge::create(array( + $charge = \Stripe\Charge::create(array( 'customer' => $customer->id, 'amount' => price2num($amountstripe, 'MU'), 'currency' => $currency, 'capture' => true, // Charge immediatly 'description' => 'Stripe payment: '.$FULLTAG.' ref='.$ref, 'metadata' => $metadata, - 'statement_descriptor' => dol_trunc(dol_trunc(dol_string_unaccent($mysoc->name), 6, 'right', 'UTF-8', 1).' '.$FULLTAG, 22, 'right', 'UTF-8', 1) // 22 chars that appears on bank receipt - ), array("idempotency_key" => "$ref", "stripe_account" => "$stripeacc")); + 'statement_descriptor' => dol_trunc($FULLTAG, 10, 'right', 'UTF-8', 1), // 22 chars that appears on bank receipt (company + description) + ), array("idempotency_key" => "$FULLTAG", "stripe_account" => "$stripeacc")); // Return $charge = array('id'=>'ch_XXXX', 'status'=>'succeeded|pending|failed', 'failure_code'=>, 'failure_message'=>...) if (empty($charge)) { @@ -1658,7 +1659,7 @@ print '
'; if (preg_match('/^dopayment/', $action)) { - // Strip + // Stripe if (GETPOST('dopayment_stripe', 'alpha')) { // Simple checkout @@ -1727,26 +1728,28 @@ if (preg_match('/^dopayment/', $action))
'.$langs->trans("QtyOrdered").''.$langs->trans("SendingSheet").''.$langs->trans("Description").''.$langs->trans("SendingSheet").''.$langs->trans("Description").''.$langs->trans("DateCreation").''.$langs->trans("DateDeliveryPlanned").''.$langs->trans("QtyPreparedOrShipped").'
trans('ReductionShort'); ?> ' . $langs->trans('Progress') . '
global->MAIN_INPUT_DESC_HEIGHT)) $nbrows=$conf->global->MAIN_INPUT_DESC_HEIGHT; $toolbarname='dolibarr_details'; 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=new DolEditor('dp_desc', GETPOST('dp_desc', 'none'), '', (empty($conf->global->MAIN_DOLEDITOR_HEIGHT)?100:$conf->global->MAIN_DOLEDITOR_HEIGHT), $toolbarname, '', false, true, $enabled, $nbrows, '98%'); $doleditor->Create(); // Show autofill date for recurring invoices @@ -353,52 +355,71 @@ else { if ($object->element == 'supplier_proposal' || $object->element == 'order_supplier' || $object->element == 'invoice_supplier') // We must have same test in printObjectLines { ?> + $coldisplay++; "> tva_assuj == "0") echo ''.vatrate(0, true); else echo $form->load_tva('tva_tx', (isset($_POST["tva_tx"])?GETPOST("tva_tx", 'alpha', 2):-1), $seller, $buyer, 0, 0, '', false, 1); ?> + + "> "> "> "> '; print $form->selectUnits($line->fk_unit, "units"); print '">% % @@ -409,7 +430,6 @@ else { "> @@ -439,62 +456,18 @@ else { showOptionals($extrafieldsline, 'edit', array('style'=>$bcnd[$var], 'colspan'=>$coldisplay+8), '', '', empty($conf->global->MAIN_EXTRAFIELDS_IN_ONE_TD)?0:1); + print $objectline->showOptionals($extrafieldsline, 'edit', array('style'=>$bcnd[$var], 'colspan'=>$coldisplay), '', '', empty($conf->global->MAIN_EXTRAFIELDS_IN_ONE_TD)?0:1); } ?> service->enabled) || ($object->element == 'contrat')) && $dateSelector && GETPOST('type') != '0') // We show date field if required { - $colspan = 6; - - if ($object->element == 'supplier_proposal' || $object->element == 'order_supplier' || $object->element == 'invoice_supplier') // We must have same test in printObjectLines - { - $colspan++; - } - if ($this->situation_cycle_ref) { - $colspan++; - } - // We add 1 if col total ttc - if (!empty($inputalsopricewithtax)) { - $colspan++; - } - if ($conf->global->PRODUCT_USE_UNITS) { - $colspan++; - } - if (count($object->lines)) { - //There will be an edit and a delete button - $colspan += 2; - - // With this, there is a column move button ONLY if lines > 1 - if (in_array($object->element, array( - 'propal', - 'supplier_proposal', - 'facture', - 'facturerec', - 'invoice', - 'commande', - 'order', - 'order_supplier', - 'invoice_supplier' - ))) { - $colspan++; - } - } - - if (!empty($conf->multicurrency->enabled) && $this->multicurrency_code != $conf->currency) $colspan+=2; - - if (! empty($usemargins)) - { - if (!empty($user->rights->margins->creer)) $colspan++; // For the buying price - if (! empty($conf->global->DISPLAY_MARGIN_RATES)) $colspan++; - if (! empty($conf->global->DISPLAY_MARK_RATES)) $colspan++; - } ?>
+ multicurrency->enabled) && $this->multicurrency_code != $conf-
@@ -113,7 +116,8 @@ $coldisplay=-1; // We remove first td $enable=(isset($conf->global->FCKEDITOR_ENABLE_DETAILS)?$conf->global->FCKEDITOR_ENABLE_DETAILS:0); $toolbarname='dolibarr_details'; if (! empty($conf->global->FCKEDITOR_ENABLE_DETAILS_FULL)) $toolbarname='dolibarr_notes'; - $doleditor=new DolEditor('product_desc', $line->description, '', 164, $toolbarname, '', false, true, $enable, $nbrows, '98%'); + $doleditor=new DolEditor('product_desc', $line->description, '', (empty($conf->global->MAIN_DOLEDITOR_HEIGHT)?164:$conf->global->MAIN_DOLEDITOR_HEIGHT), $toolbarname, '', false, true, $enable, $nbrows, '98%'); + $doleditor=new DolEditor('product_desc', $line->description, '', (empty($conf->global->MAIN_DOLEDITOR_HEIGHT)?164:$conf->global->MAIN_DOLEDITOR_HEIGHT), $toolbarname, '', false, true, $enable, $nbrows, '98%'); $doleditor->Create(); } else { print ''; @@ -136,6 +140,7 @@ $coldisplay=-1; // We remove first td element == 'supplier_proposal' || $object->element == 'order_supplier' || $object->element == 'invoice_supplier') // We must have same test in printObjectLines { + $coldisplay++; ?>
'; print $form->selectUnits($line->fk_unit, "units"); print '%% -rights->margins->creer)) + { $coldisplay++; -?> + ?> + product->enabled) || ! empty($conf->service->enabled)) { ?> @@ -217,8 +225,8 @@ $coldisplay=-1; // We remove first td + ">
">
trans('ServiceLimitedDuration').' '.$langs->trans('From').' '; ?> + trans('ServiceLimitedDuration').' '.$langs->trans('From').' '; ?> global->MAIN_USE_HOURMIN_IN_DATE_RANGE)?$conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE:''); print $form->selectDate($line->date_start, 'date_start', $hourmin, $hourmin, $line->date_start?0:1, "updateline", 1, 0); diff --git a/htdocs/core/tpl/objectline_view.tpl.php b/htdocs/core/tpl/objectline_view.tpl.php index a3bf7d587af..09bedf2ec53 100644 --- a/htdocs/core/tpl/objectline_view.tpl.php +++ b/htdocs/core/tpl/objectline_view.tpl.php @@ -237,14 +237,22 @@ $domData .= ' data-product_type="'.$line->product_type.'"';   ' . $line->situation_percent . '%' . price($tmp[0]) . '
'.$langs->trans("AmountExpected").':'.price($object->total_ttc).'
'.$langs->trans("RemainderToPay").':'.price($resteapayeraffiche).'
'.price($resteapayeraffiche).'
'; - print 'rowid.'#'.$line->rowid.'">'; + print 'rowid.'">'; print img_edit(); print '   '; print 'rowid.'">'; @@ -2224,14 +2228,18 @@ else if ($action == 'editline' && $line->rowid == GETPOST('rowid', 'int')) { - - // Add line with link to add new file or attach to an existing file - $colspan = 12; + // Add line with link to add new file or attach line to an existing file + $colspan = 10; if (! empty($conf->projet->enabled)) $colspan++; if (!empty($conf->global->MAIN_USE_EXPENSE_IK)) $colspan++; print '
'; + + print ''; + print $numline; + print ''; print ''.$langs->trans("UploadANewFileNow"); print img_picto($langs->trans("UploadANewFileNow"), 'chevron-down', '', false, 0, 0, '', 'marginleftonly'); print ''; @@ -2355,7 +2363,9 @@ else } // Add a line - if (($object->fk_statut == ExpenseReport::STATUS_DRAFT || $object->fk_statut == ExpenseReport::STATUS_REFUSED) && $action != 'editline' && $user->rights->expensereport->creer) + if (($object->fk_statut == ExpenseReport::STATUS_DRAFT || $object->fk_statut == ExpenseReport::STATUS_REFUSED) + && $action != 'editline' + && $user->rights->expensereport->creer) { $colspan = 11; if (! empty($conf->global->MAIN_USE_EXPENSE_IK)) $colspan++; @@ -2399,10 +2409,10 @@ else jQuery(".trattachnewfilenow").toggle(); jQuery(".truploadnewfilenow").hide(); return false; - });'; - if (is_array(GETPOST('attachfile', 'array')) && count(GETPOST('attachfile', 'array'))) + });'."\n"; + if (is_array(GETPOST('attachfile', 'array')) && count(GETPOST('attachfile', 'array')) && $action != 'updateline') { - print 'jQuery(".trattachnewfilenow").toggle();'."\n"; + print 'jQuery(".trattachnewfilenow").show();'."\n"; } print ' }); diff --git a/htdocs/expensereport/class/expensereport.class.php b/htdocs/expensereport/class/expensereport.class.php index 55a411cf1c7..c09d2897980 100644 --- a/htdocs/expensereport/class/expensereport.class.php +++ b/htdocs/expensereport/class/expensereport.class.php @@ -314,12 +314,13 @@ class ExpenseReport extends CommonObject /** * Load an object from its id and create a new one in database * - * @param int $fk_user_author Id of new user - * @return int New id of clone + * @param User $user User making the clone + * @param int $fk_user_author Id of new user + * @return int New id of clone */ - public function createFromClone($fk_user_author) + public function createFromClone(User $user, $fk_user_author) { - global $user,$hookmanager; + global $hookmanager; $error=0; diff --git a/htdocs/expensereport/class/paymentexpensereport.class.php b/htdocs/expensereport/class/paymentexpensereport.class.php index f731638ea1d..deec87887d7 100644 --- a/htdocs/expensereport/class/paymentexpensereport.class.php +++ b/htdocs/expensereport/class/paymentexpensereport.class.php @@ -414,13 +414,12 @@ class PaymentExpenseReport extends CommonObject /** * Load an object from its id and create a new one in database * + * @param User $user User making the clone * @param int $fromid Id of object to clone * @return int New id of clone */ - public function createFromClone($fromid) + public function createFromClone(User $user, $fromid) { - global $user,$langs; - $error=0; $object=new PaymentExpenseReport($this->db); diff --git a/htdocs/expensereport/tpl/expensereport_linktofile.tpl.php b/htdocs/expensereport/tpl/expensereport_linktofile.tpl.php index 4ea23418db8..48f21bc3dc2 100644 --- a/htdocs/expensereport/tpl/expensereport_linktofile.tpl.php +++ b/htdocs/expensereport/tpl/expensereport_linktofile.tpl.php @@ -17,35 +17,41 @@ if ($conf->global->MAIN_FEATURES_LEVEL >= 2) print '
'; //print ''.$langs->trans("AttachTheNewLineToTheDocument").'
'; - $modulepart='expensereport';$maxheightmini=48; + $modulepart='expensereport'; $maxheightmini=48; $relativepath=(! empty($object->ref)?dol_sanitizeFileName($object->ref):'').'/'; + $filei=0; foreach($arrayoffiles as $file) { - print '
'; - $fileinfo = pathinfo($file['name']); + $urlforhref=array(); + $filei++; + + print '
'; + $fileinfo = pathinfo($file['fullname']); if (image_format_supported($file['name']) > 0) { $minifile=getImageFileNameForSize($file['name'], '_mini'); // For new thumbs using same ext (in lower case however) than original //print $file['path'].'/'.$minifile.'
'; - $urlforhref=getAdvancedPreviewUrl($modulepart, $fileinfo['relativename'].'.'.strtolower($fileinfo['extension']), 1, '&entity='.(!empty($object->entity)?$object->entity:$conf->entity)); + $urlforhref=getAdvancedPreviewUrl($modulepart, $relativepath.$fileinfo['filename'].'.'.strtolower($fileinfo['extension']), 1, '&entity='.(!empty($object->entity)?$object->entity:$conf->entity)); if (empty($urlforhref)) { $urlforhref=DOL_URL_ROOT.'/viewimage.php?modulepart='.$modulepart.'&entity='.(!empty($object->entity)?$object->entity:$conf->entity).'&file='.urlencode($fileinfo['relativename'].'.'.strtolower($fileinfo['extension'])); print ''; } else { print ''; } - print '
'.$langs->trans("Duration").''; - print ''; + print ''; print $formproduct->selectMeasuringUnits("duration_unit", "time", GETPOST('duration_value', 'alpha'), 0, 1); print '
'; print '
'.$langs->trans("ProductAccountancySellIntraCode").''; - print '
'.$langs->trans("ProductAccountancySellExportCode").''; + print '
'.$langs->trans("ProductAccountancySellIntraCode").''; print '
'.$langs->trans("ProductAccountancySellExportCode").''; + print '
'.$langs->trans("ProductAccountancyBuyCode").''; @@ -1401,7 +1399,7 @@ else { // Duration print '
'.$langs->trans("Duration").''; - print ' '; + print ' '; print $formproduct->selectMeasuringUnits("duration_unit", "time", $object->duration_unit, 0, 1); print '
'.$langs->trans("ProductAccountancySellIntraCode").''; - print $formaccounting->select_account($object->accountancy_code_sell_intra, 'accountancy_code_sell_intra', 1, '', 1, 1); - print '
'.$langs->trans("ProductAccountancySellExportCode").'
'.$langs->trans("ProductAccountancySellIntraCode").''; - print $formaccounting->select_account($object->accountancy_code_sell_export, 'accountancy_code_sell_export', 1, '', 1, 1); + print $formaccounting->select_account($object->accountancy_code_sell_intra, 'accountancy_code_sell_intra', 1, '', 1, 1); print '
'.$langs->trans("ProductAccountancySellExportCode").''; + print $formaccounting->select_account($object->accountancy_code_sell_export, 'accountancy_code_sell_export', 1, '', 1, 1); + print '
'.$langs->trans("ProductAccountancyBuyCode").''; @@ -1545,22 +1540,19 @@ else print ''; print '
'.$langs->trans("ProductAccountancySellIntraCode").''; - print '
'.$langs->trans("ProductAccountancySellExportCode").''; + print '
'.$langs->trans("ProductAccountancySellIntraCode").''; print '
'.$langs->trans("ProductAccountancySellExportCode").''; + print '
'.$langs->trans("ProductAccountancyBuyCode").''; @@ -1687,48 +1679,45 @@ else } print '
'; - print $langs->trans("ProductAccountancySellIntraCode"); - print ''; - if (! empty($conf->accounting->enabled)) - { - if (! empty($object->accountancy_code_sell_intra)) - { - $accountingaccount2 = new AccountingAccount($db); - $accountingaccount2->fetch('', $object->accountancy_code_sell_intra, 1); - - print $accountingaccount2->getNomUrl(0, 1, 1, '', 1); - } - } else { - print $object->accountancy_code_sell_intra; - } - print '
'; - print $langs->trans("ProductAccountancySellExportCode"); + print $langs->trans("ProductAccountancySellIntraCode"); print ''; if (! empty($conf->accounting->enabled)) { - if (! empty($object->accountancy_code_sell_export)) + if (! empty($object->accountancy_code_sell_intra)) { - $accountingaccount3 = new AccountingAccount($db); - $accountingaccount3->fetch('', $object->accountancy_code_sell_export, 1); + $accountingaccount2 = new AccountingAccount($db); + $accountingaccount2->fetch('', $object->accountancy_code_sell_intra, 1); - print $accountingaccount3->getNomUrl(0, 1, 1, '', 1); + print $accountingaccount2->getNomUrl(0, 1, 1, '', 1); } } else { - print $object->accountancy_code_sell_export; + print $object->accountancy_code_sell_intra; } print '
'; + print $langs->trans("ProductAccountancySellExportCode"); + print ''; + if (! empty($conf->accounting->enabled)) + { + if (! empty($object->accountancy_code_sell_export)) + { + $accountingaccount3 = new AccountingAccount($db); + $accountingaccount3->fetch('', $object->accountancy_code_sell_export, 1); + + print $accountingaccount3->getNomUrl(0, 1, 1, '', 1); + } + } else { + print $object->accountancy_code_sell_export; + } + print '
'; print $langs->trans("ProductAccountancyBuyCode"); diff --git a/htdocs/product/class/productbatch.class.php b/htdocs/product/class/productbatch.class.php index aac30bce813..4b1e5232abb 100644 --- a/htdocs/product/class/productbatch.class.php +++ b/htdocs/product/class/productbatch.class.php @@ -327,13 +327,12 @@ class Productbatch extends CommonObject /** * Load an object from its id and create a new one in database * + * @param User $user User making the clone * @param int $fromid Id of object to clone * @return int New id of clone */ - public function createFromClone($fromid) + public function createFromClone(User $user, $fromid) { - global $user,$langs; - $error=0; $object=new Productbatch($this->db); diff --git a/htdocs/product/class/productcustomerprice.class.php b/htdocs/product/class/productcustomerprice.class.php index 424cb8ce39b..8405120ddef 100644 --- a/htdocs/product/class/productcustomerprice.class.php +++ b/htdocs/product/class/productcustomerprice.class.php @@ -895,14 +895,12 @@ class Productcustomerprice extends CommonObject /** * Load an object from its id and create a new one in database * - * @param int $fromid of object to clone - * @return int id of clone + * @param User $user User making the clone + * @param int $fromid ID of object to clone + * @return int id of clone */ - public function createFromClone($fromid) + public function createFromClone(User $user, $fromid) { - - global $user, $langs; - $error = 0; $object = new Productcustomerprice($this->db); diff --git a/htdocs/product/class/propalmergepdfproduct.class.php b/htdocs/product/class/propalmergepdfproduct.class.php index 0882490446d..2d350eb0c77 100644 --- a/htdocs/product/class/propalmergepdfproduct.class.php +++ b/htdocs/product/class/propalmergepdfproduct.class.php @@ -560,13 +560,12 @@ class Propalmergepdfproduct extends CommonObject /** * Load an object from its id and create a new one in database * + * @param User $user User making the clone * @param int $fromid Id of object to clone * @return int New id of clone */ - public function createFromClone($fromid) + public function createFromClone(User $user, $fromid) { - global $user,$langs; - $error=0; $object=new Propalmergepdfproduct($this->db); diff --git a/htdocs/product/fournisseurs.php b/htdocs/product/fournisseurs.php index 2fcb54d43f0..cc922cb724b 100644 --- a/htdocs/product/fournisseurs.php +++ b/htdocs/product/fournisseurs.php @@ -149,6 +149,8 @@ if (empty($reshook)) if (empty($id_fourn)) $id_fourn=GETPOST("search_id_fourn"); $ref_fourn=GETPOST("ref_fourn"); if (empty($ref_fourn)) $ref_fourn=GETPOST("search_ref_fourn"); + $ref_fourn_old=GETPOST("ref_fourn_old"); + if (empty($ref_fourn_old)) $ref_fourn_old = $ref_fourn; $quantity=GETPOST("qty"); $remise_percent=price2num(GETPOST('remise_percent', 'alpha')); $npr = preg_match('/\*/', $_POST['tva_tx']) ? 1 : 0 ; @@ -228,7 +230,7 @@ if (empty($reshook)) if (! $error) { - $ret=$object->add_fournisseur($user, $id_fourn, $ref_fourn, $quantity); // This insert record with no value for price. Values are update later with update_buyprice + $ret=$object->add_fournisseur($user, $id_fourn, $ref_fourn_old, $quantity); // This insert record with no value for price. Values are update later with update_buyprice if ($ret == -3) { $error++; @@ -427,7 +429,6 @@ if ($id > 0 || $ref) $supplier->fetch($socid); print $supplier->getNomUrl(1); print ''; - print ''; print ''; print ''; print ''; @@ -454,7 +455,8 @@ if ($id > 0 || $ref) print '
'.$langs->trans("SupplierRef").''; if ($rowid) { - print $object->fourn_ref; + print ''; + print ''; } else { diff --git a/htdocs/product/inventory/class/inventory.class.php b/htdocs/product/inventory/class/inventory.class.php index b9e4d8bd090..7f535a2eac0 100644 --- a/htdocs/product/inventory/class/inventory.class.php +++ b/htdocs/product/inventory/class/inventory.class.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2007-2019 Laurent Destailleur * Copyright (C) 2014-2016 Juanjo Menent * Copyright (C) 2015 Florian Henry * Copyright (C) 2015 Raphaël Doursenaud @@ -81,8 +81,8 @@ class Inventory extends CommonObject 'ref' => array('type'=>'varchar(64)', 'label'=>'Ref', 'visible'=>1, 'enabled'=>1, 'position'=>10, 'notnull'=>1, 'index'=>1, 'searchall'=>1, 'comment'=>'Reference of object', 'css'=>'maxwidth200'), 'entity' => array('type'=>'integer', 'label'=>'Entity', 'visible'=>0, 'enabled'=>1, 'position'=>20, 'notnull'=>1, 'index'=>1,), 'title' => array('type'=>'varchar(255)', 'label'=>'Label', 'visible'=>1, 'enabled'=>1, 'position'=>25, 'css'=>'minwidth300'), - 'fk_warehouse' => array('type'=>'integer:Entrepot:product/stock/class/entrepot.class.php', 'label'=>'Warehouse', 'visible'=>1, 'enabled'=>1, 'position'=>30, 'index'=>1, 'help'=>'LinkToThirparty'), - 'fk_product' => array('type'=>'integer:Product:product/class/product.class.php', 'label'=>'Product', 'visible'=>1, 'enabled'=>1, 'position'=>32, 'index'=>1, 'help'=>'LinkToProduct'), + 'fk_warehouse' => array('type'=>'integer:Entrepot:product/stock/class/entrepot.class.php', 'label'=>'Warehouse', 'visible'=>1, 'enabled'=>1, 'position'=>30, 'index'=>1, 'help'=>'InventoryForASpecificWarehouse'), + 'fk_product' => array('type'=>'integer:Product:product/class/product.class.php', 'label'=>'Product', 'visible'=>1, 'enabled'=>1, 'position'=>32, 'index'=>1, 'help'=>'InventoryForASpecificProduct'), 'date_inventory' => array('type'=>'date', 'label'=>'DateValue', 'visible'=>1, 'enabled'=>1, 'position'=>35), 'date_validation' => array('type'=>'datetime', 'label'=>'DateValidation', 'visible'=>-2, 'enabled'=>1, 'position'=>502,), @@ -501,20 +501,105 @@ class Inventory extends CommonObject /** * Class InventoryLine */ -class InventoryLine +class InventoryLine extends CommonObjectLine { - /** - * @var int ID - */ - public $id; + /** + * @var string ID to identify managed object + */ + public $element = 'inventoryline'; + + /** + * @var string Name of table without prefix where object is stored + */ + public $table_element = 'inventorydet'; + + /** + * @var array Does inventory support multicompany module ? 0=No test on entity, 1=Test with field entity, 2=Test with link by societe + */ + public $ismultientitymanaged = 0; + + /** + * @var string String with name of icon for inventory + */ + public $picto = 'stock'; + + + /** + * 'type' if the field format. + * 'label' the translation key. + * 'enabled' is a condition when the field must be managed. + * 'visible' says if field is visible in list (Examples: 0=Not visible, 1=Visible on list and create/update/view forms, 2=Visible on list only. Using a negative value means field is not shown by default on list but can be selected for viewing) + * 'notnull' is set to 1 if not null in database. Set to -1 if we must set data to null if empty ('' or 0). + * 'index' if we want an index in database. + * 'foreignkey'=>'tablename.field' if the field is a foreign key (it is recommanded to name the field fk_...). + * 'position' is the sort order of field. + * 'searchall' is 1 if we want to search in this field when making a search from the quick search button. + * 'isameasure' must be set to 1 if you want to have a total on list for this field. Field type must be summable like integer or double(24,8). + * 'help' is a string visible as a tooltip on field + * 'comment' is not used. You can store here any text of your choice. It is not used by application. + * 'default' is a default value for creation (can still be replaced by the global setup of default values) + * 'showoncombobox' if field must be shown into the label of combobox + */ + + // BEGIN MODULEBUILDER PROPERTIES + /** + * @var array Array with all fields and their property + */ + public $fields=array( + 'rowid' => array('type'=>'integer', 'label'=>'TechnicalID', 'visible'=>-1, 'enabled'=>1, 'position'=>1, 'notnull'=>1, 'index'=>1, 'comment'=>'Id',), + 'fk_inventory' => array('type'=>'integer:Inventory:product/inventory/class/inventory.class.php', 'label'=>'Inventory', 'visible'=>1, 'enabled'=>1, 'position'=>30, 'index'=>1, 'help'=>'LinkToInventory'), + 'fk_warehouse' => array('type'=>'integer:Entrepot:product/stock/class/entrepot.class.php', 'label'=>'Warehouse', 'visible'=>1, 'enabled'=>1, 'position'=>30, 'index'=>1, 'help'=>'LinkToThirparty'), + 'fk_product' => array('type'=>'integer:Product:product/class/product.class.php', 'label'=>'Product', 'visible'=>1, 'enabled'=>1, 'position'=>32, 'index'=>1, 'help'=>'LinkToProduct'), + 'batch' => array('type'=>'string', 'label'=>'Batch', 'visible'=>1, 'enabled'=>1, 'position'=>32, 'index'=>1, 'help'=>'LinkToProduct'), + 'datec' => array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>500), + 'tms' => array('type'=>'timestamp', 'label'=>'DateModification', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>501), + 'qty_stock' => array('type'=>'double', 'label'=>'QtyFound', 'visible'=>1, 'enabled'=>1, 'position'=>32, 'index'=>1, 'help'=>'Qty we found/want (to define during draft edition)'), + 'qty_view' => array('type'=>'double', 'label'=>'QtyBefore', 'visible'=>1, 'enabled'=>1, 'position'=>33, 'index'=>1, 'help'=>'Qty before (filled once movements are validated)'), + 'qty_regulated' => array('type'=>'double', 'label'=>'QtyDelta', 'visible'=>1, 'enabled'=>1, 'position'=>34, 'index'=>1, 'help'=>'Qty aadded or removed (filled once movements are validated)'), + ); + + /** + * @var int ID + */ + public $rowid; + /** - * @var mixed Sample line property 1 + * 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 */ - public $prop1; + public function fetch($id, $ref = null) + { + $result = $this->fetchCommon($id, $ref); + //if ($result > 0 && ! empty($this->table_element_line)) $this->fetchLines(); + return $result; + } /** - * @var mixed Sample line property 2 + * Update object into database + * + * @param User $user User that modifies + * @param bool $notrigger false=launch triggers after, true=disable triggers + * @return int <0 if KO, >0 if OK */ - public $prop2; + public function update(User $user, $notrigger = false) + { + return $this->updateCommon($user, $notrigger); + } + + /** + * Delete object in database + * + * @param User $user User that deletes + * @param bool $notrigger false=launch triggers after, true=disable triggers + * @return int <0 if KO, >0 if OK + */ + public function delete(User $user, $notrigger = false) + { + return $this->deleteCommon($user, $notrigger); + //return $this->deleteCommon($user, $notrigger, 1); + } } diff --git a/htdocs/product/list.php b/htdocs/product/list.php index 56d8b0bc504..39e98730365 100644 --- a/htdocs/product/list.php +++ b/htdocs/product/list.php @@ -62,6 +62,8 @@ $fourn_id = GETPOST("fourn_id", 'int'); $catid = GETPOST('catid', 'int'); $search_tobatch = GETPOST("search_tobatch", 'int'); $search_accountancy_code_sell = GETPOST("search_accountancy_code_sell", 'alpha'); +$search_accountancy_code_sell_intra = GETPOST("search_accountancy_code_sell_intra", 'alpha'); +$search_accountancy_code_sell_export = GETPOST("search_accountancy_code_sell_export", 'alpha'); $search_accountancy_code_buy = GETPOST("search_accountancy_code_buy", 'alpha'); $optioncss = GETPOST('optioncss', 'alpha'); $type=GETPOST("type", "int"); @@ -154,6 +156,8 @@ if (empty($conf->global->PRODUIT_MULTIPRICES)) } } +$isInEEC=isInEEC($mysoc); + // Definition of fields for lists $arrayfields=array( 'p.ref'=>array('label'=>$langs->trans("Ref"), 'checked'=>1), @@ -175,8 +179,10 @@ $arrayfields=array( 'p.stock'=>array('label'=>$langs->trans("PhysicalStock"), 'checked'=>1, 'enabled'=>(! empty($conf->stock->enabled) && $user->rights->stock->lire && $contextpage != 'service')), 'stock_virtual'=>array('label'=>$langs->trans("VirtualStock"), 'checked'=>1, 'enabled'=>(! empty($conf->stock->enabled) && $user->rights->stock->lire && $contextpage != 'service' && $virtualdiffersfromphysical)), 'p.tobatch'=>array('label'=>$langs->trans("ManageLotSerial"), 'checked'=>0, 'enabled'=>(! empty($conf->productbatch->enabled))), - 'p.accountancy_code_sell'=>array('label'=>$langs->trans("ProductAccountancySellCode"), 'checked'=>0), - 'p.accountancy_code_buy'=>array('label'=>$langs->trans("ProductAccountancyBuyCode"), 'checked'=>0), + 'p.accountancy_code_sell'=>array('label'=>$langs->trans("ProductAccountancySellCode"), 'checked'=>0, 'position'=>400), + 'p.accountancy_code_sell_intra'=>array('label'=>$langs->trans("ProductAccountancySellIntraCode"), 'checked'=>0, 'enabled'=>$isInEEC, 'position'=>401), + 'p.accountancy_code_sell_export'=>array('label'=>$langs->trans("ProductAccountancySellExportCode"), 'checked'=>0, 'position'=>402), + 'p.accountancy_code_buy'=>array('label'=>$langs->trans("ProductAccountancyBuyCode"), 'checked'=>0, 'position'=>403), 'p.datec'=>array('label'=>$langs->trans("DateCreation"), 'checked'=>0, 'position'=>500), 'p.tms'=>array('label'=>$langs->trans("DateModificationShort"), 'checked'=>0, 'position'=>500), 'p.tosell'=>array('label'=>$langs->trans("Status").' ('.$langs->trans("Sell").')', 'checked'=>1, 'position'=>1000), @@ -227,6 +233,8 @@ if (empty($reshook)) $show_childproducts = ''; $search_accountancy_code_sell=''; + $search_accountancy_code_sell_intra=''; + $search_accountancy_code_sell_export=''; $search_accountancy_code_buy=''; $search_array_options=array(); } @@ -321,8 +329,10 @@ if ($search_categ > 0) $sql.= " AND cp.fk_categorie = ".$db->escape($search_ca if ($search_categ == -2) $sql.= " AND cp.fk_categorie IS NULL"; if ($fourn_id > 0) $sql.= " AND pfp.fk_soc = ".$fourn_id; if ($search_tobatch != '' && $search_tobatch >= 0) $sql.= " AND p.tobatch = ".$db->escape($search_tobatch); -if ($search_accountancy_code_sell) $sql.= natural_search('p.accountancy_code_sell', $search_accountancy_code_sell); -if ($search_accountancy_code_buy) $sql.= natural_search('p.accountancy_code_buy', $search_accountancy_code_buy); +if ($search_accountancy_code_sell) $sql.= natural_search('p.accountancy_code_sell', $search_accountancy_code_sell); +if ($search_accountancy_code_sell_intra) $sql.= natural_search('p.accountancy_code_sell_intra', $search_accountancy_code_sell_intra); +if ($search_accountancy_code_sell_export) $sql.= natural_search('p.accountancy_code_sell_export', $search_accountancy_code_sell_export); +if ($search_accountancy_code_buy) $sql.= natural_search('p.accountancy_code_buy', $search_accountancy_code_buy); // Add where from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php'; @@ -418,6 +428,8 @@ if ($resql) if ($optioncss != '') $param.='&optioncss='.urlencode($optioncss); if ($search_tobatch) $param="&search_ref_supplier=".urlencode($search_ref_supplier); if ($search_accountancy_code_sell) $param="&search_accountancy_code_sell=".urlencode($search_accountancy_code_sell); + if ($search_accountancy_code_sell_intra) $param="&search_accountancy_code_sell_intra=".urlencode($search_accountancy_code_sell_intra); + if ($search_accountancy_code_sell_export) $param="&search_accountancy_code_sell_export=".urlencode($search_accountancy_code_sell_export); if ($search_accountancy_code_buy) $param="&search_accountancy_code_buy=".urlencode($search_accountancy_code_buy); // Add $param from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; @@ -630,8 +642,10 @@ if ($resql) // To batch if (! empty($arrayfields['p.tobatch']['checked'])) print ''.$form->selectyesno($search_tobatch, '', '', '', 1).''.$obj->accountancy_code_sell.''.$obj->accountancy_code_sell_intra.''.$obj->accountancy_code_sell_export.''.$obj->accountancy_code_buy.'
'; if ($obj->socid) { - $socstatic->id=$obj->socid; - $socstatic->name=$obj->name; print $socstatic->getNomUrl(1); } else diff --git a/htdocs/projet/tasks/list.php b/htdocs/projet/tasks/list.php index 1279a5191fd..94ca4d436d5 100644 --- a/htdocs/projet/tasks/list.php +++ b/htdocs/projet/tasks/list.php @@ -523,7 +523,7 @@ if (! empty($arrayfields['t.label']['checked'])) // Start date if (! empty($arrayfields['t.dateo']['checked'])) { - print ''; + print ''; if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print ''; print ''; $formother->select_year($search_syear?$search_syear:-1, 'search_syear', 1, 20, 5); @@ -532,7 +532,7 @@ if (! empty($arrayfields['t.dateo']['checked'])) // End date if (! empty($arrayfields['t.datee']['checked'])) { - print ''; + print ''; if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print ''; print ''; $formother->select_year($search_eyear?$search_eyear:-1, 'search_eyear', 1, 20, 5); @@ -657,7 +657,7 @@ while ($i < min($num, $limit)) // Ref if (! empty($arrayfields['t.ref']['checked'])) { - print ''; + print ''; print $object->getNomUrl(1, 'withproject'); if ($object->hasDelay()) print img_warning("Late"); print '
- + +
+ +
+
- + '."\n"; - - - '."\n"; + // Code to ask the credit card. This use the default "API version". No way to force API version when using JS code. + print '