diff --git a/htdocs/adherents/card.php b/htdocs/adherents/card.php index d2755c9acd8..b33eb3564bf 100644 --- a/htdocs/adherents/card.php +++ b/htdocs/adherents/card.php @@ -81,6 +81,9 @@ if (!empty($canvas)) { $objcanvas->getCanvas('adherent', 'membercard', $canvas); } +// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context +$hookmanager->initHooks(array('membercard', 'globalcard')); + // Security check $result = restrictedArea($user, 'adherent', $id, '', '', 'socid', 'rowid', 0); @@ -107,9 +110,6 @@ if ($id) { $caneditfieldmember = $user->rights->adherent->creer; } -// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context -$hookmanager->initHooks(array('membercard', 'globalcard')); - /* diff --git a/htdocs/adherents/subscription/card.php b/htdocs/adherents/subscription/card.php index 1be08bb5b34..c2e2bfd1d44 100644 --- a/htdocs/adherents/subscription/card.php +++ b/htdocs/adherents/subscription/card.php @@ -55,6 +55,11 @@ $permissionnote = $user->rights->adherent->cotisation->creer; // Used by the inc $permissiondellink = $user->rights->adherent->cotisation->creer; // Used by the include of actions_dellink.inc.php $permissiontoedit = $user->rights->adherent->cotisation->creer; // Used by the include of actions_lineupdonw.inc.php +$hookmanager->initHooks(array('subscriptioncard', 'globalcard')); + +// Security check +$result = restrictedArea($user, 'subscription', 0); // TODO Check on object id + /* * Actions diff --git a/htdocs/compta/bank/bankentries_list.php b/htdocs/compta/bank/bankentries_list.php index 37c125668ec..85b9bbbbf26 100644 --- a/htdocs/compta/bank/bankentries_list.php +++ b/htdocs/compta/bank/bankentries_list.php @@ -91,7 +91,7 @@ $search_dt_start = dol_mktime(0, 0, 0, GETPOST('search_start_dtmonth', 'int'), G $search_dt_end = dol_mktime(0, 0, 0, GETPOST('search_end_dtmonth', 'int'), GETPOST('search_end_dtday', 'int'), GETPOST('search_end_dtyear', 'int')); $search_dv_start = dol_mktime(0, 0, 0, GETPOST('search_start_dvmonth', 'int'), GETPOST('search_start_dvday', 'int'), GETPOST('search_start_dvyear', 'int')); $search_dv_end = dol_mktime(0, 0, 0, GETPOST('search_end_dvmonth', 'int'), GETPOST('search_end_dvday', 'int'), GETPOST('search_end_dvyear', 'int')); -$search_thirdparty = GETPOST("search_thirdparty", 'alpha') ?GETPOST("search_thirdparty", 'alpha') : GETPOST("thirdparty", 'alpha'); +$search_thirdparty_user = GETPOST("search_thirdparty", 'alpha') ?GETPOST("search_thirdparty", 'alpha') : GETPOST("thirdparty", 'alpha'); $search_req_nb = GETPOST("req_nb", 'alpha'); $search_num_releve = GETPOST("search_num_releve", 'alpha'); $search_conciliated = GETPOST("search_conciliated", 'int'); @@ -142,16 +142,16 @@ $extrafields->fetch_name_optionals_label('banktransaction'); $search_array_options = $extrafields->getOptionalsFromPost('banktransaction', '', 'search_'); $arrayfields = array( - 'b.rowid'=>array('label'=>$langs->trans("Ref"), 'checked'=>1), - 'b.label'=>array('label'=>$langs->trans("Description"), 'checked'=>1), - 'b.dateo'=>array('label'=>$langs->trans("DateOperationShort"), 'checked'=>1), - 'b.datev'=>array('label'=>$langs->trans("DateValueShort"), 'checked'=>1), - 'type'=>array('label'=>$langs->trans("Type"), 'checked'=>1), - 'b.num_chq'=>array('label'=>$langs->trans("Numero"), 'checked'=>1), - 'bu.label'=>array('label'=>$langs->trans("ThirdParty"), 'checked'=>1, 'position'=>500), - 'ba.ref'=>array('label'=>$langs->trans("BankAccount"), 'checked'=>(($id > 0 || !empty($ref)) ? 0 : 1), 'position'=>1000), - 'b.debit'=>array('label'=>$langs->trans("Debit"), 'checked'=>1, 'position'=>600), - 'b.credit'=>array('label'=>$langs->trans("Credit"), 'checked'=>1, 'position'=>605), + 'b.rowid'=>array('label'=>$langs->trans("Ref"), 'checked'=>1), + 'b.label'=>array('label'=>$langs->trans("Description"), 'checked'=>1), + 'b.dateo'=>array('label'=>$langs->trans("DateOperationShort"), 'checked'=>1), + 'b.datev'=>array('label'=>$langs->trans("DateValueShort"), 'checked'=>1), + 'type'=>array('label'=>$langs->trans("Type"), 'checked'=>1), + 'b.num_chq'=>array('label'=>$langs->trans("Numero"), 'checked'=>1), + 'bu.label'=>array('label'=>$langs->trans("ThirdParty").'/'.$langs->trans("User"), 'checked'=>1, 'position'=>500), + 'ba.ref'=>array('label'=>$langs->trans("BankAccount"), 'checked'=>(($id > 0 || !empty($ref)) ? 0 : 1), 'position'=>1000), + 'b.debit'=>array('label'=>$langs->trans("Debit"), 'checked'=>1, 'position'=>600), + 'b.credit'=>array('label'=>$langs->trans("Credit"), 'checked'=>1, 'position'=>605), 'balancebefore'=>array('label'=>$langs->trans("BalanceBefore"), 'checked'=>0, 'position'=>1000), 'balance'=>array('label'=>$langs->trans("Balance"), 'checked'=>1, 'position'=>1001), 'b.num_releve'=>array('label'=>$langs->trans("AccountStatement"), 'checked'=>1, 'position'=>1010), @@ -191,7 +191,7 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x' $search_ref = ""; $search_req_nb = ''; $search_description = ''; - $search_thirdparty = ''; + $search_thirdparty_user = ''; $search_num_releve = ''; $search_conciliated = ''; $thirdparty = ''; @@ -255,7 +255,7 @@ if ((GETPOST('confirm_savestatement', 'alpha') || GETPOST('confirm_reconcile', ' $param .= '&search_conciliated='.urlencode($search_conciliated); if ($page) $param .= '&page='.urlencode($page); if ($offset) $param .= '&offset='.urlencode($offset); - if ($search_thirdparty) $param .= '&search_thirdparty='.urlencode($search_thirdparty); + if ($search_thirdparty_user) $param .= '&search_thirdparty='.urlencode($search_thirdparty_user); if ($search_num_releve) $param .= '&search_num_releve='.urlencode($search_num_releve); if ($search_description) $param .= '&search_description='.urlencode($search_description); if ($search_start_dt) $param .= '&search_start_dt='.urlencode($search_start_dt); @@ -359,6 +359,7 @@ $formaccounting = new FormAccounting($db); $companystatic = new Societe($db); $bankaccountstatic = new Account($db); +$userstatic= new User($db); $banktransferstatic = new BonPrelevement($db); $societestatic = new Societe($db); @@ -390,7 +391,7 @@ if (!empty($ref)) $param .= '&ref='.urlencode($ref); if (!empty($search_ref)) $param .= '&search_ref='.urlencode($search_ref); if (!empty($search_description)) $param .= '&search_description='.urlencode($search_description); if (!empty($search_type)) $param .= '&type='.urlencode($search_type); -if (!empty($search_thirdparty)) $param .= '&search_thirdparty='.urlencode($search_thirdparty); +if (!empty($search_thirdparty_user)) $param .= '&search_thirdparty='.urlencode($search_thirdparty_user); if (!empty($search_debit)) $param .= '&search_debit='.urlencode($search_debit); if (!empty($search_credit)) $param .= '&search_credit='.urlencode($search_credit); if (!empty($search_account)) $param .= '&search_account='.urlencode($search_account); @@ -482,7 +483,7 @@ if ($id > 0 || !empty($ref)) $sql = "SELECT b.rowid, b.dateo as do, b.datev as dv, b.amount, b.label, b.rappro as conciliated, b.num_releve, b.num_chq,"; $sql .= " b.fk_account, b.fk_type,"; $sql .= " ba.rowid as bankid, ba.ref as bankref,"; -$sql .= " bu.url_id,"; +$sql .= " bu.url_id, bu.type as type_url,"; $sql .= " s.nom, s.name_alias, s.client, s.fournisseur, s.email, s.code_client, s.code_fournisseur, s.code_compta, s.code_compta_fournisseur"; // Add fields from extrafields if (!empty($extrafields->attributes[$object->table_element]['label'])) { @@ -512,7 +513,7 @@ if ($search_ref) $sql .= natural_search("b.rowid", $search_ref, 1); if ($search_req_nb) $sql .= natural_search("b.num_chq", $search_req_nb); if ($search_num_releve) $sql .= natural_search("b.num_releve", $search_num_releve); if ($search_conciliated != '' && $search_conciliated != '-1') $sql .= " AND b.rappro = ".urlencode($search_conciliated); -if ($search_thirdparty) $sql .= natural_search("s.nom", $search_thirdparty); +if ($search_thirdparty_user) $sql .= natural_search(array("s.nom", "u.firstname", "u.lastname"), $search_thirdparty_user); if ($search_description) { $search_description_to_use = $search_description; @@ -587,7 +588,7 @@ if (!empty($search_description)) $mode_balance_ok = false; if (!empty($search_type)) $mode_balance_ok = false; if (!empty($search_debit)) $mode_balance_ok = false; if (!empty($search_credit)) $mode_balance_ok = false; -if (!empty($search_thirdparty)) $mode_balance_ok = false; +if (!empty($search_thirdparty_user)) $mode_balance_ok = false; if ($search_conciliated != '' && $search_conciliated != '-1') $mode_balance_ok = false; if (!empty($search_num_releve)) $mode_balance_ok = false; @@ -1012,6 +1013,8 @@ if ($resql) while ($i < min($num, $limit)) { $objp = $db->fetch_object($resql); + $links = $bankaccountstatic->get_url($objp->rowid); + // If we are in a situation where we need/can show balance, we calculate the start of balance if (!$balancecalculated && (!empty($arrayfields['balancebefore']['checked']) || !empty($arrayfields['balance']['checked'])) && ($mode_balance_ok || $search_conciliated === '0')) { @@ -1202,7 +1205,6 @@ if ($resql) //print " "; // Add links after description - $links = $bankaccountstatic->get_url($objp->rowid); $cachebankaccount = array(); foreach ($links as $key=>$val) { @@ -1369,24 +1371,51 @@ if ($resql) } // Third party - if (!empty($arrayfields['bu.label']['checked'])) - { - print ''; + if (!empty($arrayfields['bu.label']['checked'])) + { + print ''; if ($objp->url_id) { - $companystatic->id = $objp->url_id; - $companystatic->name = $objp->nom; - $companystatic->name_alias = $objp->name_alias; - $companystatic->client = $objp->client; - $companystatic->email = $objp->email; - $companystatic->fournisseur = $objp->fournisseur; - $companystatic->code_client = $objp->code_client; - $companystatic->code_fournisseur = $objp->code_fournisseur; - $companystatic->code_compta = $objp->code_compta; - $companystatic->code_compta_fournisseur = $objp->code_compta_fournisseur; - print $companystatic->getNomUrl(1); - } else { - print ' '; + if ($objp->type_url == 'company') { + $companystatic->id = $objp->url_id; + $companystatic->name = $objp->nom; + $companystatic->name_alias = $objp->name_alias; + $companystatic->client = $objp->client; + $companystatic->email = $objp->email; + $companystatic->fournisseur = $objp->fournisseur; + $companystatic->code_client = $objp->code_client; + $companystatic->code_fournisseur = $objp->code_fournisseur; + $companystatic->code_compta = $objp->code_compta; + $companystatic->code_compta_fournisseur = $objp->code_compta_fournisseur; + print $companystatic->getNomUrl(1); + } + } + else //display user or nothing + { + //payment line type to define user display + foreach ($links as $key=>$value){ + if ($links[$key]['type'] == 'payment_sc') $type_link = 'payment_sc'; + if ($links[$key]['type'] == 'payment_salary') $type_link = 'payment_salary'; + } + + $sqlu = "SELECT url_id FROM ".MAIN_DB_PREFIX."bank_url WHERE fk_bank=".$objp->rowid." AND type='user'"; + $resqlu = $db->query($sqlu); + + if ($resqlu) { + if ($db->num_rows($resqlu) > 0 && + (($type_link == 'payment_salary' && !empty($user->rights->salaries->read)) + || ($type_link == 'payment_sc' && !empty($user->rights->tax->charges->lire)))) { + $obj = $db->fetch_object($resqlu); + $userstatic->fetch($obj->url_id); + print $userstatic->getNomUrl(1); + } + + else { + print ' '; + } + } else { + dol_print_error($db); + } } print ''; if (!$i) $totalarray['nbfield']++; diff --git a/htdocs/compta/sociales/class/paymentsocialcontribution.class.php b/htdocs/compta/sociales/class/paymentsocialcontribution.class.php index 9258ff63fc3..c4999c0765f 100644 --- a/htdocs/compta/sociales/class/paymentsocialcontribution.class.php +++ b/htdocs/compta/sociales/class/paymentsocialcontribution.class.php @@ -567,6 +567,25 @@ class PaymentSocialContribution extends CommonObject $socialcontrib->fetch($key); $result = $acc->add_url_line($bank_line_id, $socialcontrib->id, DOL_URL_ROOT.'/compta/charges.php?id=', $socialcontrib->type_label.(($socialcontrib->lib && $socialcontrib->lib != $socialcontrib->type_label) ? ' ('.$socialcontrib->lib.')' : ''), 'sc'); if ($result <= 0) dol_print_error($this->db); + + if ($socialcontrib->fk_user) { + $fuser = new User($this->db); + $fuser->fetch($socialcontrib->fk_user); + + // Add link 'user' in bank_url between operation and bank transaction + $result = $acc->add_url_line( + $bank_line_id, + $socialcontrib->fk_user, + DOL_URL_ROOT . '/user/card.php?id=', + $fuser->getFullName($langs), + 'user' + ); + + if ($result <= 0) { + $this->error = $acc->error; + $error++; + } + } } } } else { diff --git a/htdocs/core/class/dolreceiptprinter.class.php b/htdocs/core/class/dolreceiptprinter.class.php index 4dfca1186c0..8091d5debbe 100644 --- a/htdocs/core/class/dolreceiptprinter.class.php +++ b/htdocs/core/class/dolreceiptprinter.class.php @@ -825,7 +825,7 @@ class dolReceiptPrinter extends Printer if ($this->printer->connector instanceof DummyPrintConnector || $conf->global->TAKEPOS_PRINT_METHOD == "takeposconnector") { $data = $this->printer->connector->getData(); - if ($conf->global->TAKEPOS_PRINT_METHOD == "takeposconnector") echo base64_encode($data); + if ($conf->global->TAKEPOS_PRINT_METHOD == "takeposconnector") echo rtrim(strtr(base64_encode($data), '+/', '-_'), '='); dol_syslog($data); } // Close and print diff --git a/htdocs/cron/class/cronjob.class.php b/htdocs/cron/class/cronjob.class.php index 9d084ec4f24..d41d055b996 100644 --- a/htdocs/cron/class/cronjob.class.php +++ b/htdocs/cron/class/cronjob.class.php @@ -50,8 +50,19 @@ class Cronjob extends CommonObject */ public $entity; + /** + * @var string Job type + */ public $jobtype; + + /** + * @var string|int Date for last cron object update + */ public $tms = ''; + + /** + * @var string|int Date for cron job create + */ public $datec = ''; /** @@ -59,6 +70,9 @@ class Cronjob extends CommonObject */ public $label; + /** + * @var string Job command + */ public $command; public $classesname; public $objectname; @@ -67,20 +81,50 @@ class Cronjob extends CommonObject public $md5params; public $module_name; public $priority; + /** * @var string|int Date for last job execution */ public $datelastrun = ''; + /** * @var string|int Date for next job execution */ public $datenextrun = ''; + + /** + * @var string|int Date for end job execution + */ public $dateend = ''; + + /** + * @var string|int Date for first start job execution + */ public $datestart = ''; + + /** + * @var string|int Date for last result job execution + */ public $datelastresult = ''; + + /** + * @var string Last result from end job execution + */ public $lastresult; + + /** + * @var string Last output from end job execution + */ public $lastoutput; + + /** + * @var string Unit frequency of job execution + */ public $unitfrequency; + + /** + * @var int Frequency of job execution + */ public $frequency; /** @@ -88,6 +132,9 @@ class Cronjob extends CommonObject */ public $status; + /** + * @var int Is job processing + */ public $processing; /** @@ -100,9 +147,25 @@ class Cronjob extends CommonObject */ public $fk_user_mod; + /** + * @var int Number of run job execution + */ public $nbrun; + + /** + * @var int Maximum run job execution + */ + public $maxrun; + + /** + * @var string Libname + */ public $libname; - public $test; // A test condition to know if job is visible/qualified + + /** + * @var string A test condition to know if job is visible/qualified + */ + public $test; const STATUS_DISABLED = 0; const STATUS_ENABLED = 1; @@ -152,7 +215,12 @@ class Cronjob extends CommonObject if (isset($this->frequency)) $this->frequency = trim($this->frequency); if (isset($this->status)) $this->status = trim($this->status); if (isset($this->note_private)) $this->note_private = trim($this->note_private); - if (isset($this->nbrun)) $this->nbrun = trim($this->nbrun); + if (isset($this->nbrun)) { + $this->nbrun = (int) $this->nbrun; + } + if (isset($this->maxrun)) { + $this->maxrun = (int) $this->maxrun; + } if (isset($this->libname)) $this->libname = trim($this->libname); if (isset($this->test)) $this->test = trim($this->test); @@ -262,7 +330,10 @@ class Cronjob extends CommonObject dol_syslog(get_class($this)."::create", LOG_DEBUG); $resql = $this->db->query($sql); - if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); } + if (!$resql) { + $error++; + $this->errors[] = "Error ".$this->db->lasterror(); + } if (!$error) { @@ -1253,8 +1324,7 @@ class Cronjob extends CommonObject } $result = $this->update($user); - if ($result < 0) - { + if ($result < 0) { dol_syslog(get_class($this)."::reprogram_jobs ".$this->error, LOG_ERR); return -1; } @@ -1289,14 +1359,16 @@ class Cronjob extends CommonObject $this->labelStatus = array(); // Force reset o array because label depends on other fields $this->labelStatusShort = array(); - if (empty($this->labelStatus) || empty($this->labelStatusShort)) - { + if (empty($this->labelStatus) || empty($this->labelStatusShort)) { global $langs; $langs->load('users'); $moretext = ''; - if ($processing) $moretext = ' ('.$langs->trans("Running").')'; - elseif ($lastresult) $moretext .= ' ('.$langs->trans("Error").')'; + if ($processing) { + $moretext = ' ('.$langs->trans("Running").')'; + } elseif ($lastresult) { + $moretext .= ' ('.$langs->trans("Error").')'; + } $this->labelStatus[self::STATUS_DISABLED] = $langs->trans('Disabled').$moretext; $this->labelStatus[self::STATUS_ENABLED] = $langs->trans('Scheduled').$moretext; diff --git a/htdocs/langs/en_US/stocks.lang b/htdocs/langs/en_US/stocks.lang index ad4946ee9f9..aabbe1791b3 100644 --- a/htdocs/langs/en_US/stocks.lang +++ b/htdocs/langs/en_US/stocks.lang @@ -99,6 +99,7 @@ VirtualStock=Virtual stock VirtualStockAtDate=Virtual stock at date VirtualStockAtDateDesc=Virtual stock once all pending orders that are planned to be done before the date will be finished VirtualStockDesc=Virtual stock is the calculated stock available once all open/pending actions (that affect stocks) are closed (purchase orders received, sales orders shipped, manufacturing orders produced, etc) +AtDate=At date IdWarehouse=Id warehouse DescWareHouse=Description warehouse LieuWareHouse=Localisation warehouse diff --git a/htdocs/modulebuilder/index.php b/htdocs/modulebuilder/index.php index f0e56d1a426..7838581fdc4 100644 --- a/htdocs/modulebuilder/index.php +++ b/htdocs/modulebuilder/index.php @@ -1701,17 +1701,18 @@ if (is_array($listofmodules) && count($listofmodules) > 0) { foreach ($objMod->config_page_url as $page) { $urlpage = $page; - if ($i++) - { + if ($i++) { $linktoenabledisable .= ' '.img_picto(ucfirst($page), "setup").''; // print ''.ucfirst($page).' '; } else { if (preg_match('/^([^@]+)@([^@]+)$/i', $urlpage, $regs)) { + $urltouse = dol_buildpath('/'.$regs[2].'/admin/'.$regs[1], 1); $linktoenabledisable .= '   '.img_picto($langs->trans("Setup"), "setup", 'style="padding-right: 6px"').''; } else { - // Case standard admin page (not a page provided by the module but a page + // Case standard admin page (not a page provided by the + // module but a page provided by dolibarr) $urltouse = DOL_URL_ROOT.'/admin/'.$urlpage; $linktoenabledisable .= '   '.img_picto($langs->trans("Setup"), "setup", 'style="padding-right: 6px"').''; } diff --git a/htdocs/modulebuilder/template/admin/setup.php b/htdocs/modulebuilder/template/admin/setup.php index e93b8686d79..93bbc8a6612 100644 --- a/htdocs/modulebuilder/template/admin/setup.php +++ b/htdocs/modulebuilder/template/admin/setup.php @@ -61,8 +61,11 @@ $scandir = GETPOST('scan_dir', 'alpha'); $type = 'myobject'; $arrayofparameters = array( - 'MYMODULE_MYPARAM1'=>array('css'=>'minwidth200', 'enabled'=>1), - 'MYMODULE_MYPARAM2'=>array('css'=>'minwidth500', 'enabled'=>1) + 'MYMODULE_MYPARAM1'=>array('type'=>'string', 'css'=>'minwidth500' ,'enabled'=>1), + 'MYMODULE_MYPARAM2'=>array('type'=>'textarea','enabled'=>1), + //'MYMODULE_MYPARAM3'=>array('type'=>'category:'.Categorie::TYPE_CUSTOMER, 'enabled'=>1), + //'MYMODULE_MYPARAM4'=>array('type'=>'emailtemplate:thirdparty', 'enabled'=>1), + //'MYMODULE_MYPARAM5'=>array('type'=>'yesno', 'enabled'=>1), ); $error = 0; @@ -208,11 +211,57 @@ if ($action == 'edit') { print ''; print ''; - foreach ($arrayofparameters as $key => $val) { - print ''; + foreach ($arrayofparameters as $constname => $val) { + if ($val['enabled']==1) { + $setupnotempty++; + print ''; + } } print '
'.$langs->trans("Parameter").''.$langs->trans("Value").'
'; - $tooltiphelp = (($langs->trans($key.'Tooltip') != $key.'Tooltip') ? $langs->trans($key.'Tooltip') : ''); - print $form->textwithpicto($langs->trans($key), $tooltiphelp); - print '
'; + $tooltiphelp = (($langs->trans($constname . 'Tooltip') != $constname . 'Tooltip') ? $langs->trans($constname . 'Tooltip') : ''); + print ''.$form->textwithpicto($langs->trans($constname), $tooltiphelp, 1, 'info', '', 0, 3, 'tootips'.$constname).''; + print ''; + + if ($val['type'] == 'textarea') { + print '\n"; + } elseif ($val['type']== 'html') { + require_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php'; + $doleditor = new DolEditor($constname, $conf->global->{$constname}, '', 160, 'dolibarr_notes', '', false, false, $conf->fckeditor->enabled, ROWS_5, '90%'); + $doleditor->Create(); + } elseif ($val['type'] == 'yesno') { + print $form->selectyesno($constname, $conf->global->{$constname}, 1); + } elseif (preg_match('/emailtemplate:/', $val['type'])) { + include_once DOL_DOCUMENT_ROOT . '/core/class/html.formmail.class.php'; + $formmail = new FormMail($db); + + $tmp = explode(':', $val['type']); + $nboftemplates = $formmail->fetchAllEMailTemplate($tmp[1], $user, null, 1); // We set lang=null to get in priority record with no lang + //$arraydefaultmessage = $formmail->getEMailTemplate($db, $tmp[1], $user, null, 0, 1, ''); + $arrayofmessagename = array(); + if (is_array($formmail->lines_model)) { + foreach ($formmail->lines_model as $modelmail) { + //var_dump($modelmail); + $moreonlabel = ''; + if (!empty($arrayofmessagename[$modelmail->label])) { + $moreonlabel = ' (' . $langs->trans("SeveralLangugeVariatFound") . ')'; + } + // The 'label' is the key that is unique if we exclude the language + $arrayofmessagename[$modelmail->id] = $langs->trans(preg_replace('/\(|\)/', '', $modelmail->label)) . $moreonlabel; + } + } + print $form->selectarray($constname, $arrayofmessagename, $conf->global->{$constname}, 'None', 0, 0, '', 0, 0, 0, '', '', 1); + } elseif (preg_match('/category:/', $val['type'])) { + require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; + require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; + $formother = new FormOther($db); + + $tmp = explode(':', $val['type']); + print img_picto('', 'category', 'class="pictofixedwidth"'); + print $formother->select_categories($tmp[1], $conf->global->{$constname}, $constname, 0, $langs->trans('CustomersProspectsCategoriesShort')); + } else { + print ''; + } + print '
'; @@ -227,13 +276,48 @@ if ($action == 'edit') { print ''; print ''; - foreach ($arrayofparameters as $key => $val) { - $setupnotempty++; + foreach ($arrayofparameters as $constname => $val) { + if ($val['enabled']==1) { + $setupnotempty++; + print ''; + if ($val['type'] == 'textarea') { + print dol_nl2br($conf->global->{$constname}); + } elseif ($val['type']== 'html') { + print $conf->global->{$constname}; + } elseif ($val['type'] == 'yesno') { + print ajax_constantonoff($constname); + } elseif (preg_match('/emailtemplate:/', $val['type'])) { + include_once DOL_DOCUMENT_ROOT . '/core/class/html.formmail.class.php'; + $formmail = new FormMail($db); + + $tmp = explode(':', $val['type']); + + $template = $formmail->getEMailTemplate($db, $tmp[1], $user, $langs, $conf->global->{$constname}); + if ($template<0) { + setEventMessages(null, $formmail->errors, 'errors'); + } + print $langs->trans($template->label); + } elseif (preg_match('/category:/', $val['type'])) { + $c = new Categorie($db); + $result = $c->fetch($conf->global->{$constname}); + if ($result < 0) { + setEventMessages(null, $c->errors, 'errors'); + } + $ways = $c->print_all_ways(' >> ', 'none', 0, 1); // $ways[0] = "ccc2 >> ccc2a >> ccc2a1" with html formated text + $toprint = array(); + foreach ($ways as $way) { + $toprint[] = '
  • color ? ' style="background: #' . $c->color . ';"' : ' style="background: #bbb"') . '>' . $way . '
  • '; + } + print '
    '; + } else { + print $conf->global->{$constname}; + } + print ''; + } } print '
    '.$langs->trans("Parameter").''.$langs->trans("Value").'
    '; + $tooltiphelp = (($langs->trans($constname . 'Tooltip') != $constname . 'Tooltip') ? $langs->trans($constname . 'Tooltip') : ''); + print $form->textwithpicto($langs->trans($constname), $tooltiphelp); + print ''; - print '
    '; - $tooltiphelp = (($langs->trans($key.'Tooltip') != $key.'Tooltip') ? $langs->trans($key.'Tooltip') : ''); - print $form->textwithpicto($langs->trans($key), $tooltiphelp); - print ''.$conf->global->$key.'
    '; diff --git a/htdocs/product/stock/movement_list.php b/htdocs/product/stock/movement_list.php index 6ab8a99ac76..d67a72d2d63 100644 --- a/htdocs/product/stock/movement_list.php +++ b/htdocs/product/stock/movement_list.php @@ -66,8 +66,14 @@ $toselect = GETPOST('toselect', 'array'); // Array of ids of elements selected $result = restrictedArea($user, 'stock'); $idproduct = GETPOST('idproduct', 'int'); -$year = GETPOST("year"); -$month = GETPOST("month"); +$search_date_startday = GETPOST('search_date_startday', 'int'); +$search_date_startmonth = GETPOST('search_date_startmonth', 'int'); +$search_date_startyear = GETPOST('search_date_startyear', 'int'); +$search_date_endday = GETPOST('search_date_endday', 'int'); +$search_date_endmonth = GETPOST('search_date_endmonth', 'int'); +$search_date_endyear = GETPOST('search_date_endyear', 'int'); +$search_date_start = dol_mktime(0, 0, 0, GETPOST('search_date_startmonth', 'int'), GETPOST('search_date_startday', 'int'), GETPOST('search_date_startyear', 'int'), 'tzuserrel'); +$search_date_end = dol_mktime(23, 59, 59, GETPOST('search_date_endmonth', 'int'), GETPOST('search_date_endday', 'int'), GETPOST('search_date_endyear', 'int'), 'tzuserrel'); $search_ref = GETPOST('search_ref', 'alpha'); $search_movement = GETPOST("search_movement"); $search_product_ref = trim(GETPOST("search_product_ref")); @@ -105,7 +111,7 @@ $arrayfields = array( 'm.rowid'=>array('label'=>$langs->trans("Ref"), 'checked'=>1), 'm.datem'=>array('label'=>$langs->trans("Date"), 'checked'=>1), 'p.ref'=>array('label'=>$langs->trans("ProductRef"), 'checked'=>1, 'css'=>'maxwidth100'), - 'p.label'=>array('label'=>$langs->trans("ProductLabel"), 'checked'=>1), + 'p.label'=>array('label'=>$langs->trans("ProductLabel"), 'checked'=>0), 'm.batch'=>array('label'=>$langs->trans("BatchNumberShort"), 'checked'=>1, 'enabled'=>(!empty($conf->productbatch->enabled))), 'pl.eatby'=>array('label'=>$langs->trans("EatByDate"), 'checked'=>0, 'enabled'=>(!empty($conf->productbatch->enabled))), 'pl.sellby'=>array('label'=>$langs->trans("SellByDate"), 'checked'=>0, 'position'=>10, 'enabled'=>(!empty($conf->productbatch->enabled))), @@ -113,7 +119,7 @@ $arrayfields = array( 'm.fk_user_author'=>array('label'=>$langs->trans("Author"), 'checked'=>0), 'm.inventorycode'=>array('label'=>$langs->trans("InventoryCodeShort"), 'checked'=>1), 'm.label'=>array('label'=>$langs->trans("MovementLabel"), 'checked'=>1), - 'm.type_mouvement'=>array('label'=>$langs->trans("TypeMovement"), 'checked'=>1), + 'm.type_mouvement'=>array('label'=>$langs->trans("TypeMovement"), 'checked'=>0), 'origin'=>array('label'=>$langs->trans("Origin"), 'checked'=>1), 'm.value'=>array('label'=>$langs->trans("Qty"), 'checked'=>1), 'm.price'=>array('label'=>$langs->trans("UnitPurchaseValue"), 'checked'=>0), @@ -162,8 +168,14 @@ if (empty($reshook)) // Do we click on purge search criteria ? if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // Both test are required to be compatible with all browsers { - $year = ''; - $month = ''; + $search_date_startday = ''; + $search_date_startmonth = ''; + $search_date_startyear = ''; + $search_date_endday = ''; + $search_date_endmonth = ''; + $search_date_endyear = ''; + $search_date_start = ''; + $search_date_end = ''; $search_ref = ''; $search_movement = ""; $search_type_mouvement = ""; @@ -461,7 +473,7 @@ $sql .= " m.batch, m.price,"; $sql .= " m.type_mouvement,"; $sql .= " m.fk_projet as fk_project,"; $sql .= " pl.rowid as lotid, pl.eatby, pl.sellby,"; -$sql .= " u.login, u.photo, u.lastname, u.firstname"; +$sql .= " u.login, u.photo, u.lastname, u.firstname, u.email as user_email, u.statut as user_status"; // Add fields from extrafields if (!empty($extrafields->attributes[$object->table_element]['label'])) { foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key.' as options_'.$key : ''); @@ -482,17 +494,18 @@ $sql .= " AND m.fk_entrepot = e.rowid"; $sql .= " AND e.entity IN (".getEntity('stock').")"; if (empty($conf->global->STOCK_SUPPORTS_SERVICES)) $sql .= " AND p.fk_product_type = 0"; if ($id > 0) $sql .= " AND e.rowid ='".$id."'"; -$sql .= dolSqlDateFilter('m.datem', 0, $month, $year); +if (!empty($search_date_start)) $sql .= " AND m.datem >= '" . $db->idate($search_date_start) . "'"; +if (!empty($search_date_end)) $sql .= " AND m.datem <= '" . $db->idate($search_date_end) . "'"; if ($idproduct > 0) $sql .= " AND p.rowid = ".((int) $idproduct); if (!empty($search_ref)) $sql .= natural_search('m.rowid', $search_ref, 1); -if (!empty($search_movement)) $sql .= natural_search('m.label', $search_movement); -if (!empty($search_inventorycode)) $sql .= natural_search('m.inventorycode', $search_inventorycode); -if (!empty($search_product_ref)) $sql .= natural_search('p.ref', $search_product_ref); -if (!empty($search_product)) $sql .= natural_search('p.label', $search_product); +if (!empty($search_movement)) $sql .= natural_search('m.label', $search_movement); +if (!empty($search_inventorycode)) $sql .= natural_search('m.inventorycode', $search_inventorycode); +if (!empty($search_product_ref)) $sql .= natural_search('p.ref', $search_product_ref); +if (!empty($search_product)) $sql .= natural_search('p.label', $search_product); if ($search_warehouse != '' && $search_warehouse != '-1') $sql .= natural_search('e.rowid', $search_warehouse, 2); -if (!empty($search_user)) $sql .= natural_search('u.login', $search_user); -if (!empty($search_batch)) $sql .= natural_search('m.batch', $search_batch); -if (!empty($product_id)) $sql .= natural_search('p.rowid', $product_id); +if (!empty($search_user)) $sql .= natural_search('u.login', $search_user); +if (!empty($search_batch)) $sql .= natural_search('m.batch', $search_batch); +if (!empty($product_id)) $sql .= natural_search('p.rowid', $product_id); if ($search_qty != '') $sql .= natural_search('m.value', $search_qty, 1); if ($search_type_mouvement != '' && $search_type_mouvement != '-1') $sql .= natural_search('m.type_mouvement', $search_type_mouvement, 2); // Add where from extra fields @@ -711,6 +724,12 @@ if ($resql) if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage); if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit); if ($id > 0) $param .= '&id='.urlencode($id); + if ($search_date_startday) $param .= '&search_date_startday='.urlencode($search_date_startday); + if ($search_date_startmonth) $param .= '&search_date_startmonth='.urlencode($search_date_startmonth); + if ($search_date_startyear) $param .= '&search_date_startyear='.urlencode($search_date_startyear); + if ($search_date_endday) $param .= '&search_date_endday='.urlencode($search_date_endday); + if ($search_date_endmonth) $param .= '&search_date_endmonth='.urlencode($search_date_endmonth); + if ($search_date_endyear) $param .= '&search_date_endyear='.urlencode($search_date_endyear); if ($search_movement) $param .= '&search_movement='.urlencode($search_movement); if ($search_inventorycode) $param .= '&search_inventorycode='.urlencode($search_inventorycode); if ($search_type_mouvement) $param .= '&search_type_mouvement='.urlencode($search_type_mouvement); @@ -789,16 +808,15 @@ if ($resql) print ''; print ''; } - if (!empty($arrayfields['m.datem']['checked'])) + if (! empty($arrayfields['m.datem']['checked'])) { - // Date - print ''; - print ''; - if (empty($conf->productbatch->enabled)) print ' '; - //else print '
    '; - $syear = $year ? $year : -1; - print ''; - //print $formother->selectyear($syear,'year',1, 20, 5); + print ''; + print '
    '; + print $form->selectDate($search_date_start?$search_date_start:-1, 'search_date_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'), 'tzuserrel'); + print '
    '; + print '
    '; + print $form->selectDate($search_date_end?$search_date_end:-1, 'search_date_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to'), 'tzuserrel'); + print '
    '; print ''; } if (!empty($arrayfields['p.ref']['checked'])) @@ -1013,6 +1031,8 @@ if ($resql) $userstatic->lastname = $objp->lastname; $userstatic->firstname = $objp->firstname; $userstatic->photo = $objp->photo; + $userstatic->email = $objp->user_email; + $userstatic->statut = $objp->user_status; $productstatic->id = $objp->rowid; $productstatic->ref = $objp->product_ref; @@ -1063,11 +1083,7 @@ if ($resql) if (!empty($arrayfields['p.label']['checked'])) { // Product label - print ''; - /*$productstatic->id=$objp->rowid; - $productstatic->ref=$objp->produit; - $productstatic->type=$objp->type; - print $productstatic->getNomUrl(1,'',16);*/ + print ''; print $productstatic->label; print "\n"; } @@ -1089,7 +1105,7 @@ if ($resql) // Warehouse if (!empty($arrayfields['e.ref']['checked'])) { - print ''; + print ''; print $warehousestatic->getNomUrl(1); print "\n"; } diff --git a/htdocs/product/stock/stockatdate.php b/htdocs/product/stock/stockatdate.php index 91159984a35..f115bafbdf4 100644 --- a/htdocs/product/stock/stockatdate.php +++ b/htdocs/product/stock/stockatdate.php @@ -243,9 +243,12 @@ $title = $langs->trans('StockAtDate'); $sql = 'SELECT p.rowid, p.ref, p.label, p.description, p.price,'; $sql .= ' p.price_ttc, p.price_base_type, p.fk_product_type, p.desiredstock, p.seuil_stock_alerte,'; -$sql .= ' p.tms as datem, p.duration, p.tobuy, p.stock'; +$sql .= ' p.tms as datem, p.duration, p.tobuy, p.stock, '; if ($fk_warehouse > 0) { + $sql .= " SUM(p.pmp * ps.reel) as estimatedvalue, SUM(p.price * ps.reel) as sellvalue"; $sql .= ', SUM(ps.reel) as stock_reel'; +} else { + $sql .= " SUM(p.pmp * p.stock) as estimatedvalue, SUM(p.price * p.stock) as sellvalue"; } // Add fields from hooks $parameters = array(); @@ -271,6 +274,9 @@ if (!empty($canvas)) $sql .= ' AND p.canvas = "'.$db->escape($canvas).'"'; if ($fk_warehouse > 0) { $sql .= ' GROUP BY p.rowid, p.ref, p.label, p.description, p.price, p.price_ttc, p.price_base_type, p.fk_product_type, p.desiredstock, p.seuil_stock_alerte,'; $sql .= ' p.tms, p.duration, p.tobuy, p.stock'; +} else { + $sql .= ' GROUP BY p.rowid, p.ref, p.label, p.description, p.price, p.price_ttc, p.price_base_type, p.fk_product_type, p.desiredstock, p.seuil_stock_alerte,'; + $sql .= ' p.tms, p.duration, p.tobuy, p.stock'; } // Add where from hooks $parameters = array(); @@ -403,6 +409,9 @@ print ''; print ''; if ($mode == 'future') { print ''; +} else { + print ''; + print ''; } // Fields from hook $parameters = array('param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder); @@ -424,6 +433,7 @@ if ($fk_warehouse > 0) { print ''; print_liste_field_titre('Ref', $_SERVER["PHP_SELF"], 'p.ref', $param, '', '', $sortfield, $sortorder); print_liste_field_titre('Label', $_SERVER["PHP_SELF"], 'p.label', $param, '', '', $sortfield, $sortorder); + if ($mode == 'future') { print_liste_field_titre('CurrentStock', $_SERVER["PHP_SELF"], $fieldtosortcurrentstock, $param, '', '', $sortfield, $sortorder, 'right '); print_liste_field_titre('', $_SERVER["PHP_SELF"]); @@ -431,6 +441,8 @@ if ($mode == 'future') { print_liste_field_titre('VirtualStock', $_SERVER["PHP_SELF"], '', $param, '', '', $sortfield, $sortorder, 'right ', 'VirtualStockDesc'); } else { print_liste_field_titre($stocklabel, $_SERVER["PHP_SELF"], '', $param, '', '', $sortfield, $sortorder, 'right '); + print_liste_field_titre("EstimatedStockValue", $_SERVER["PHP_SELF"], "estimatedvalue", '', $param, '', $sortfield, $sortorder, 'right ', $langs->trans("AtDate"), 1); + print_liste_field_titre("EstimatedStockValueSell", $_SERVER["PHP_SELF"], "", '', $param, '', $sortfield, $sortorder, 'right ', $langs->trans("AtDate"), 1); print_liste_field_titre('', $_SERVER["PHP_SELF"]); print_liste_field_titre('CurrentStock', $_SERVER["PHP_SELF"], $fieldtosortcurrentstock, $param, '', '', $sortfield, $sortorder, 'right '); } @@ -531,6 +543,21 @@ while ($i < ($limit ? min($num, $limit) : $num)) // Stock at date print ''.($stock ? $stock : ''.$stock.'').''; + // PMP value + print ''; + if (price2num($objp->estimatedvalue, 'MT')) print price(price2num($objp->estimatedvalue, 'MT'), 1); + else print ''; + print ''; + + // Selling value + print ''; + if (empty($conf->global->PRODUIT_MULTIPRICES)) print price(price2num($objp->sellvalue, 'MT'), 1); + else { + $htmltext = $langs->trans("OptionMULTIPRICESIsOn"); + print $form->textwithtooltip($langs->trans("Variable"), $htmltext); + } + print''; + print ''; if ($nbofmovement > 0) { print ''.$langs->trans("Movements").''; @@ -560,7 +587,7 @@ $reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters); // N print $hookmanager->resPrint; if (empty($date) || ! $dateIsValid) { - $colspan = 6; + $colspan = 8; if ($mode == 'future') $colspan++; print ''.$langs->trans("EnterADateCriteria").''; }