From c1652169f2f0554e6d4a9234af9f15e193a357ae Mon Sep 17 00:00:00 2001 From: florian HENRY Date: Wed, 30 Nov 2016 16:09:59 +0100 Subject: [PATCH 01/89] NEW : Add in export thirdparty for user limit on view thirpdarty to sales team also to subsidiaries --- htdocs/core/modules/modSociete.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/modules/modSociete.class.php b/htdocs/core/modules/modSociete.class.php index 1943e3f7b20..6e55077b19d 100644 --- a/htdocs/core/modules/modSociete.class.php +++ b/htdocs/core/modules/modSociete.class.php @@ -281,7 +281,7 @@ class modSociete extends DolibarrModules $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_payment_term as payterm ON s.cond_reglement = payterm.rowid'; $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as paymode ON s.mode_reglement = paymode.id'; $this->export_sql_end[$r] .=' WHERE s.entity IN ('.getEntity('societe', 1).')'; - if(!$user->rights->societe->client->voir) $this->export_sql_end[$r] .=' AND sc.fk_user = '.$user->id; + if(!$user->rights->societe->client->voir) $this->export_sql_end[$r] .=' AND (sc.fk_user = '.$user->id.' OR sc.fk_user IN (SELECT rowid FROM '.MAIN_DB_PREFIX.'user where fk_user= '.$user->id.'))'; // Export list of contacts and attributes $r++; @@ -311,7 +311,7 @@ class modSociete extends DolibarrModules $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as co ON c.fk_pays = co.rowid'; $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'socpeople_extrafields as extra ON extra.fk_object = c.rowid'; $this->export_sql_end[$r] .=' WHERE c.entity IN ('.getEntity("societe", 1).')'; - if(!$user->rights->societe->client->voir) $this->export_sql_end[$r] .=' AND sc.fk_user = '.$user->id; + if(!$user->rights->societe->client->voir) $this->export_sql_end[$r] .=' AND (sc.fk_user = '.$user->id.' OR sc.fk_user IN (SELECT rowid FROM '.MAIN_DB_PREFIX.'user where fk_user= '.$user->id.'))'; // Imports From 7ab7149e64910ea7644c615b2d82e3420d8b5112 Mon Sep 17 00:00:00 2001 From: BENKE Charlie Date: Mon, 5 Dec 2016 11:03:12 +0100 Subject: [PATCH 02/89] just little indenting --- htdocs/core/lib/pdf.lib.php | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/htdocs/core/lib/pdf.lib.php b/htdocs/core/lib/pdf.lib.php index 9d6201998db..23c2f5e9bf4 100644 --- a/htdocs/core/lib/pdf.lib.php +++ b/htdocs/core/lib/pdf.lib.php @@ -1234,11 +1234,14 @@ function pdf_getlinedesc($object,$i,$outputlangs,$hideref=0,$hidedesc=0,$issuppl { if ($issupplierline) { - //$ref_prodserv = $prodser->ref.($ref_supplier ? ' ('.$outputlangs->transnoentitiesnoconv("SupplierRef").' '.$ref_supplier.')' : ''); // Show local ref and supplier ref - if (! empty($conf->global->PDF_HIDE_PRODUCT_REF_IN_SUPPLIER_LINES)) $ref_prodserv =$ref_supplier; - else $ref_prodserv = $prodser->ref.($ref_supplier ? ' ('.$outputlangs->transnoentitiesnoconv("SupplierRef").' '.$ref_supplier.')' : ''); // Show local ref and supplier ref + //$ref_prodserv = $prodser->ref.($ref_supplier ? ' ('.$outputlangs->transnoentitiesnoconv("SupplierRef").' '.$ref_supplier.')' : ''); // Show local ref and supplier ref + if (! empty($conf->global->PDF_HIDE_PRODUCT_REF_IN_SUPPLIER_LINES)) + $ref_prodserv =$ref_supplier; + else + $ref_prodserv = $prodser->ref.($ref_supplier ? ' ('.$outputlangs->transnoentitiesnoconv("SupplierRef").' '.$ref_supplier.')' : ''); // Show local ref and supplier ref } - else $ref_prodserv = $prodser->ref; // Show local ref only + else + $ref_prodserv = $prodser->ref; // Show local ref only if (! empty($libelleproduitservice)) $ref_prodserv .= " - "; } From d86503cb66ab7920ee54d732ae36e3bd970a56d5 Mon Sep 17 00:00:00 2001 From: BENKE Charlie Date: Mon, 5 Dec 2016 11:09:47 +0100 Subject: [PATCH 03/89] additionnal feature on supplier ref display we have like this 3 mode of display supplier ref --- htdocs/core/lib/pdf.lib.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/htdocs/core/lib/pdf.lib.php b/htdocs/core/lib/pdf.lib.php index 23c2f5e9bf4..ac08f4c25a4 100644 --- a/htdocs/core/lib/pdf.lib.php +++ b/htdocs/core/lib/pdf.lib.php @@ -1234,11 +1234,12 @@ function pdf_getlinedesc($object,$i,$outputlangs,$hideref=0,$hidedesc=0,$issuppl { if ($issupplierline) { - //$ref_prodserv = $prodser->ref.($ref_supplier ? ' ('.$outputlangs->transnoentitiesnoconv("SupplierRef").' '.$ref_supplier.')' : ''); // Show local ref and supplier ref - if (! empty($conf->global->PDF_HIDE_PRODUCT_REF_IN_SUPPLIER_LINES)) - $ref_prodserv =$ref_supplier; + if ($conf->global->PDF_HIDE_PRODUCT_REF_IN_SUPPLIER_LINES == 1) + $ref_prodserv = $ref_supplier; + elseif ($conf->global->PDF_HIDE_PRODUCT_REF_IN_SUPPLIER_LINES == 2) + $ref_prodserv = $ref_supplier. ' ('.$outputlangs->transnoentitiesnoconv("InternalRef").' '.$prodser->ref.')'; else - $ref_prodserv = $prodser->ref.($ref_supplier ? ' ('.$outputlangs->transnoentitiesnoconv("SupplierRef").' '.$ref_supplier.')' : ''); // Show local ref and supplier ref + $ref_prodserv = $prodser->ref.' ('.$outputlangs->transnoentitiesnoconv("SupplierRef").' '.$ref_supplier.')'; } else $ref_prodserv = $prodser->ref; // Show local ref only From 1e39805945334723dcf00a910b47e77ca20df42d Mon Sep 17 00:00:00 2001 From: florian HENRY Date: Fri, 9 Dec 2016 16:14:43 +0100 Subject: [PATCH 04/89] integrate Eldy remarks --- htdocs/core/modules/modSociete.class.php | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/htdocs/core/modules/modSociete.class.php b/htdocs/core/modules/modSociete.class.php index 6e55077b19d..2de744801f0 100644 --- a/htdocs/core/modules/modSociete.class.php +++ b/htdocs/core/modules/modSociete.class.php @@ -281,7 +281,11 @@ class modSociete extends DolibarrModules $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_payment_term as payterm ON s.cond_reglement = payterm.rowid'; $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as paymode ON s.mode_reglement = paymode.id'; $this->export_sql_end[$r] .=' WHERE s.entity IN ('.getEntity('societe', 1).')'; - if(!$user->rights->societe->client->voir) $this->export_sql_end[$r] .=' AND (sc.fk_user = '.$user->id.' OR sc.fk_user IN (SELECT rowid FROM '.MAIN_DB_PREFIX.'user where fk_user= '.$user->id.'))'; + if(!$user->rights->societe->client->voir) { + $subordinatesids = $user->getAllChildIds(); + var_dump($subordinatesids); + $this->export_sql_end[$r] .=' AND (sc.fk_user = '.$user->id.' '.count($subronidatesids)>0 ? ' OR (sc.fk_user IN ('.implode(',',$subronidatesids).'))' : ''; + } // Export list of contacts and attributes $r++; @@ -311,7 +315,10 @@ class modSociete extends DolibarrModules $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as co ON c.fk_pays = co.rowid'; $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'socpeople_extrafields as extra ON extra.fk_object = c.rowid'; $this->export_sql_end[$r] .=' WHERE c.entity IN ('.getEntity("societe", 1).')'; - if(!$user->rights->societe->client->voir) $this->export_sql_end[$r] .=' AND (sc.fk_user = '.$user->id.' OR sc.fk_user IN (SELECT rowid FROM '.MAIN_DB_PREFIX.'user where fk_user= '.$user->id.'))'; + if(!$user->rights->societe->client->voir) { + $subordinatesids = $user->getAllChildIds(); + $this->export_sql_end[$r] .=' AND (sc.fk_user = '.$user->id.' '.count($subronidatesids)>0 ? ' OR (sc.fk_user IN ('.implode(',',$subronidatesids).'))' : ''; + } // Imports From a797c45e3bf954e9f5ce528c089e1e1504be2b0c Mon Sep 17 00:00:00 2001 From: florian HENRY Date: Fri, 9 Dec 2016 16:28:06 +0100 Subject: [PATCH 05/89] sdf --- htdocs/core/modules/modSociete.class.php | 1 - 1 file changed, 1 deletion(-) diff --git a/htdocs/core/modules/modSociete.class.php b/htdocs/core/modules/modSociete.class.php index 2de744801f0..f0ea5370c6c 100644 --- a/htdocs/core/modules/modSociete.class.php +++ b/htdocs/core/modules/modSociete.class.php @@ -283,7 +283,6 @@ class modSociete extends DolibarrModules $this->export_sql_end[$r] .=' WHERE s.entity IN ('.getEntity('societe', 1).')'; if(!$user->rights->societe->client->voir) { $subordinatesids = $user->getAllChildIds(); - var_dump($subordinatesids); $this->export_sql_end[$r] .=' AND (sc.fk_user = '.$user->id.' '.count($subronidatesids)>0 ? ' OR (sc.fk_user IN ('.implode(',',$subronidatesids).'))' : ''; } From cbfb7df05ea22762ad1c4c9407f579c5a807a671 Mon Sep 17 00:00:00 2001 From: BENKE Charlie Date: Sat, 10 Dec 2016 12:23:02 +0100 Subject: [PATCH 06/89] Add send contract by mail --- htdocs/contrat/card.php | 189 ++++++++++++++++++++++++++++++++++------ 1 file changed, 164 insertions(+), 25 deletions(-) diff --git a/htdocs/contrat/card.php b/htdocs/contrat/card.php index 7ef9924ac00..51a61d911b3 100644 --- a/htdocs/contrat/card.php +++ b/htdocs/contrat/card.php @@ -919,7 +919,19 @@ if (empty($reshook)) else setEventMessages($langs->trans("ErrorFailToDeleteFile", GETPOST('file')), null, 'errors'); } } - + + /* + * Send mail + */ + + // Actions to send emails + $actiontypecode='AC_CONT'; + $trigger_name='CONTRACT_SENTBYMAIL'; + $paramname='id'; + $mode='emailfromcontract'; + $trackid='cont'.$object->id; + include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php'; + if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB) && $user->rights->contrat->creer) { if ($action == 'addcontact') @@ -2026,37 +2038,164 @@ else print ""; } + // Select mail models is same action as presend + if (GETPOST('modelselected')) { + $action = 'presend'; + } - print '
'; + if ($action != 'presend') + { + print '
'; - /* - * Documents generes - */ - $filename = dol_sanitizeFileName($object->ref); - $filedir = $conf->contrat->dir_output . "/" . dol_sanitizeFileName($object->ref); - $urlsource = $_SERVER["PHP_SELF"] . "?id=" . $object->id; - $genallowed = $user->rights->contrat->creer; - $delallowed = $user->rights->contrat->supprimer; + /* + * Documents generes + */ + $filename = dol_sanitizeFileName($object->ref); + $filedir = $conf->contrat->dir_output . "/" . dol_sanitizeFileName($object->ref); + $urlsource = $_SERVER["PHP_SELF"] . "?id=" . $object->id; + $genallowed = $user->rights->contrat->creer; + $delallowed = $user->rights->contrat->supprimer; - $var = true; + $var = true; - print $formfile->showdocuments('contract', $filename, $filedir, $urlsource, $genallowed, $delallowed, $object->modelpdf, 1, 0, 0, 28, 0, '', 0, '', $soc->default_lang); - - - // Show links to link elements - $linktoelem = $form->showLinkToObjectBlock($object, null, array('contrat')); - $somethingshown = $form->showLinkedObjectBlock($object, $linktoelem); + print $formfile->showdocuments('contract', $filename, $filedir, $urlsource, $genallowed, $delallowed, $object->modelpdf, 1, 0, 0, 28, 0, '', 0, '', $soc->default_lang); - print '
'; + // Show links to link elements + $linktoelem = $form->showLinkToObjectBlock($object, null, array('contrat')); + $somethingshown = $form->showLinkedObjectBlock($object, $linktoelem); + + + print '
'; + + // List of actions on element + include_once DOL_DOCUMENT_ROOT . '/core/class/html.formactions.class.php'; + $formactions = new FormActions($db); + $somethingshown = $formactions->showactions($object, 'contract', $socid); + + + print '
'; + } + + /* + * Action presend + */ + if ($action == 'presend') + { + $object->fetch_projet(); + + $ref = dol_sanitizeFileName($object->ref); + include_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php'; + $fileparams = dol_most_recent_file($conf->commande->dir_output . '/' . $ref, preg_quote($ref, '/').'[^\-]+'); + $file = $fileparams['fullname']; + + // Define output language + $outputlangs = $langs; + $newlang = ''; + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST['lang_id'])) + $newlang = $_REQUEST['lang_id']; + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) + $newlang = $object->thirdparty->default_lang; + + if (!empty($newlang)) + { + $outputlangs = new Translate('', $conf); + $outputlangs->setDefaultLang($newlang); + $outputlangs->load('commercial'); + } + + // Build document if it not exists + if (! $file || ! is_readable($file)) { + $result = $object->generateDocument(GETPOST('model') ? GETPOST('model') : $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); + if ($result <= 0) { + dol_print_error($db, $object->error, $object->errors); + exit(); + } + $fileparams = dol_most_recent_file($conf->commande->dir_output . '/' . $ref, preg_quote($ref, '/').'[^\-]+'); + $file = $fileparams['fullname']; + } + + print '
'; + print '
'; + print load_fiche_titre($langs->trans('SendOrderByMail')); + + dol_fiche_head(''); + + // Cree l'objet formulaire mail + include_once DOL_DOCUMENT_ROOT . '/core/class/html.formmail.class.php'; + $formmail = new FormMail($db); + $formmail->param['langsmodels']=(empty($newlang)?$langs->defaultlang:$newlang); + $formmail->fromtype = (GETPOST('fromtype')?GETPOST('fromtype'):(!empty($conf->global->MAIN_MAIL_DEFAULT_FROMTYPE)?$conf->global->MAIN_MAIL_DEFAULT_FROMTYPE:'user')); + + if($formmail->fromtype === 'user'){ + $formmail->fromid = $user->id; + + } + $formmail->trackid='ord'.$object->id; + if (! empty($conf->global->MAIN_EMAIL_ADD_TRACK_ID) && ($conf->global->MAIN_EMAIL_ADD_TRACK_ID & 2)) // If bit 2 is set + { + include DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; + $formmail->frommail=dolAddEmailTrackId($formmail->frommail, 'ord'.$object->id); + } + $formmail->withfrom = 1; + $liste = array(); + foreach ($object->thirdparty->thirdparty_and_contact_email_array(1) as $key => $value) + $liste [$key] = $value; + $formmail->withto = GETPOST('sendto') ? GETPOST('sendto') : $liste; + $formmail->withtocc = $liste; + $formmail->withtoccc = $conf->global->MAIN_EMAIL_USECCC; + if (empty($object->ref_client)) { + $formmail->withtopic = $outputlangs->trans('SendOrderRef', '__ORDERREF__'); + } else if (! empty($object->ref_client)) { + $formmail->withtopic = $outputlangs->trans('SendOrderRef', '__ORDERREF__ (__REFCLIENT__)'); + } + $formmail->withfile = 2; + $formmail->withbody = 1; + $formmail->withdeliveryreceipt = 1; + $formmail->withcancel = 1; + // Tableau des substitutions + $formmail->setSubstitFromObject($object); + $formmail->substit ['__ORDERREF__'] = $object->ref; + + $custcontact = ''; + $contactarr = array(); + $contactarr = $object->liste_contact(- 1, 'external'); + + if (is_array($contactarr) && count($contactarr) > 0) + { + foreach ($contactarr as $contact) + { + if ($contact['libelle'] == $langs->trans('TypeContact_commande_external_CUSTOMER')) { // TODO Use code and not label + $contactstatic = new Contact($db); + $contactstatic->fetch($contact ['id']); + $custcontact = $contactstatic->getFullName($langs, 1); + } + } + + if (! empty($custcontact)) { + $formmail->substit['__CONTACTCIVNAME__'] = $custcontact; + } + } + + // Tableau des parametres complementaires + $formmail->param['action'] = 'send'; + $formmail->param['models'] = 'order_send'; + $formmail->param['models_id']=GETPOST('modelmailselected','int'); + $formmail->param['orderid'] = $object->id; + $formmail->param['returnurl'] = $_SERVER["PHP_SELF"] . '?id=' . $object->id; + + // Init list of files + if (GETPOST("mode") == 'init') { + $formmail->clear_attached_files(); + $formmail->add_attached_files($file, basename($file), dol_mimetype($file)); + } + + // Show form + print $formmail->get_form(); + + dol_fiche_end(); + } - // List of actions on element - include_once DOL_DOCUMENT_ROOT . '/core/class/html.formactions.class.php'; - $formactions = new FormActions($db); - $somethingshown = $formactions->showactions($object, 'contract', $socid); - - - print '
'; } } From ba8deb29c9b97bd79e7ab56c90305075ed51e9e4 Mon Sep 17 00:00:00 2001 From: BENKE Charlie Date: Sat, 10 Dec 2016 12:28:52 +0100 Subject: [PATCH 07/89] Update card.php --- htdocs/contrat/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/contrat/card.php b/htdocs/contrat/card.php index 51a61d911b3..e59f8c95ed2 100644 --- a/htdocs/contrat/card.php +++ b/htdocs/contrat/card.php @@ -2086,7 +2086,7 @@ else $ref = dol_sanitizeFileName($object->ref); include_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php'; - $fileparams = dol_most_recent_file($conf->commande->dir_output . '/' . $ref, preg_quote($ref, '/').'[^\-]+'); + $fileparams = dol_most_recent_file($conf->contrat->dir_output . '/' . $ref, preg_quote($ref, '/').'[^\-]+'); $file = $fileparams['fullname']; // Define output language From 7c7626e445e1845577e2f3925415bbac786ff34e Mon Sep 17 00:00:00 2001 From: BENKE Charlie Date: Sat, 10 Dec 2016 13:19:33 +0100 Subject: [PATCH 08/89] allow to change height and width --- htdocs/product/class/product.class.php | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index 3df1393628a..56b9fc527a6 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -636,6 +636,10 @@ class Product extends CommonObject $this->weight_units = trim($this->weight_units); $this->length = price2num($this->length); $this->length_units = trim($this->length_units); + $this->width = price2num($this->width); + $this->width_units = trim($this->width_units); + $this->height = price2num($this->height); + $this->height_units = trim($this->height_units); $this->surface = price2num($this->surface); $this->surface_units = trim($this->surface_units); $this->volume = price2num($this->volume); @@ -750,6 +754,10 @@ class Product extends CommonObject $sql.= ", weight_units = " . ($this->weight_units!='' ? "'".$this->weight_units."'": 'null'); $sql.= ", length = " . ($this->length!='' ? "'".$this->length."'" : 'null'); $sql.= ", length_units = " . ($this->length_units!='' ? "'".$this->length_units."'" : 'null'); + $sql.= ", width= " . ($this->width!='' ? "'".$this->width."'" : 'null'); + $sql.= ", width_units = " . ($this->width_units!='' ? "'".$this->width_units."'" : 'null'); + $sql.= ", height = " . ($this->height!='' ? "'".$this->height."'" : 'null'); + $sql.= ", height_units = " . ($this->height_units!='' ? "'".$this->height_units."'" : 'null'); $sql.= ", surface = " . ($this->surface!='' ? "'".$this->surface."'" : 'null'); $sql.= ", surface_units = " . ($this->surface_units!='' ? "'".$this->surface_units."'" : 'null'); $sql.= ", volume = " . ($this->volume!='' ? "'".$this->volume."'" : 'null'); @@ -1671,8 +1679,9 @@ class Product extends CommonObject $sql = "SELECT rowid, ref, ref_ext, label, description, url, note as note_private, customcode, fk_country, price, price_ttc,"; $sql.= " price_min, price_min_ttc, price_base_type, cost_price, default_vat_code, tva_tx, recuperableonly as tva_npr, localtax1_tx, localtax2_tx, localtax1_type, localtax2_type, tosell,"; - $sql.= " tobuy, fk_product_type, duration, seuil_stock_alerte, canvas,"; - $sql.= " weight, weight_units, length, length_units, surface, surface_units, volume, volume_units, barcode, fk_barcode_type, finished,"; + $sql.= " tobuy, fk_product_type, duration, seuil_stock_alerte, canvas, weight, weight_units,"; + $sql.= " length, length_units, width, width_units, height, height_units,"; + $sql.= " surface, surface_units, volume, volume_units, barcode, fk_barcode_type, finished,"; $sql.= " accountancy_code_buy, accountancy_code_sell, stock, pmp,"; $sql.= " datec, tms, import_key, entity, desiredstock, tobatch, fk_unit,"; $sql.= " fk_price_expression, price_autogen"; @@ -1734,6 +1743,11 @@ class Product extends CommonObject $this->weight_units = $obj->weight_units; $this->length = $obj->length; $this->length_units = $obj->length_units; + $this->width = $obj->width; + $this->width_units = $obj->width_units; + $this->height = $obj->height; + $this->height_units = $obj->height_units; + $this->surface = $obj->surface; $this->surface_units = $obj->surface_units; $this->volume = $obj->volume; From 300c91fd7fc8495a6d6b8b419373938078930b99 Mon Sep 17 00:00:00 2001 From: BENKE Charlie Date: Sat, 10 Dec 2016 13:25:33 +0100 Subject: [PATCH 09/89] Update card.php --- htdocs/product/card.php | 64 +++++++++++++++++++++++++++++++++++------ 1 file changed, 55 insertions(+), 9 deletions(-) diff --git a/htdocs/product/card.php b/htdocs/product/card.php index 122e80b2e69..eca254eb93e 100644 --- a/htdocs/product/card.php +++ b/htdocs/product/card.php @@ -283,7 +283,11 @@ if (empty($reshook)) $object->weight_units = GETPOST('weight_units'); $object->length = GETPOST('size'); $object->length_units = GETPOST('size_units'); - $object->surface = GETPOST('surface'); + $object->width = GETPOST('sizewidth'); + $object->width_units = GETPOST('sizewidth_units'); + $object->height = GETPOST('sizeheight'); + $object->height_units = GETPOST('sizeheight_units'); + $object->surface = GETPOST('surface'); $object->surface_units = GETPOST('surface_units'); $object->volume = GETPOST('volume'); $object->volume_units = GETPOST('volume_units'); @@ -380,6 +384,11 @@ if (empty($reshook)) $object->weight_units = GETPOST('weight_units'); $object->length = GETPOST('size'); $object->length_units = GETPOST('size_units'); + $object->width = GETPOST('sizewidth'); + $object->width_units = GETPOST('sizewidth_units'); + $object->height = GETPOST('sizeheight'); + $object->height_units = GETPOST('sizeheight_units'); + $object->surface = GETPOST('surface'); $object->surface_units = GETPOST('surface_units'); $object->volume = GETPOST('volume'); @@ -1010,12 +1019,23 @@ else print $formproduct->select_measuring_units("weight_units","weight"); print ''; // Length - if (empty($conf->global->PRODUCT_DISABLE_LENGTH)) + if (empty($conf->global->PRODUCT_DISABLE_SIZE)) { print ''.$langs->trans("Length").''; print ''; print $formproduct->select_measuring_units("size_units","size"); print ''; + + print ''.$langs->trans("Width").''; + print ''; + print $formproduct->select_measuring_units("sizewidth_units","size"); + print ''; + + print ''.$langs->trans("Height").''; + print ''; + print $formproduct->select_measuring_units("sizeheight_units","size"); + print ''; + } if (empty($conf->global->PRODUCT_DISABLE_SURFACE)) { @@ -1324,13 +1344,23 @@ else print ' '; print $formproduct->select_measuring_units("weight_units", "weight", $object->weight_units); print ''; - if (empty($conf->global->PRODUCT_DISABLE_LENGTH)) + if (empty($conf->global->PRODUCT_DISABLE_SIZE)) { - // Length - print ''.$langs->trans("Length").''; - print ' '; - print $formproduct->select_measuring_units("size_units", "size", $object->length_units); - print ''; + // Length + print ''.$langs->trans("Length").''; + print ' '; + print $formproduct->select_measuring_units("size_units", "size", $object->length_units); + print ''; + + print ''.$langs->trans("Width").''; + print ' '; + print $formproduct->select_measuring_units("sizewidth_units","size", $object->width_units); + print ''; + + print ''.$langs->trans("Height").''; + print ' '; + print $formproduct->select_measuring_units("sizeheight_units","size", $object->height_units); + print ''; } if (empty($conf->global->PRODUCT_DISABLE_SURFACE)) { @@ -1634,7 +1664,7 @@ else print ' '; } print "\n"; - if (empty($conf->global->PRODUCT_DISABLE_LENGTH)) + if (empty($conf->global->PRODUCT_DISABLE_SIZE)) { // Length print ''.$langs->trans("Length").''; @@ -1647,6 +1677,22 @@ else print ' '; } print "\n"; + + print ''.$langs->trans("Width").''; + if ($object->width != '') { + print $object->width." ".measuring_units_string($object->width_units,"size"); + } + else + print ' '; + print "\n"; + + print ''.$langs->trans("Height").''; + if ($object->height != '') { + print $object->height." ".measuring_units_string($object->height_units,"size"); + } + else + print ' '; + print "\n"; } if (empty($conf->global->PRODUCT_DISABLE_SURFACE)) { From b7af0461471fff0f9fe782f73bfd6b0e4e077c01 Mon Sep 17 00:00:00 2001 From: BENKE Charlie Date: Sun, 11 Dec 2016 01:53:33 +0100 Subject: [PATCH 10/89] Add automated compute --- htdocs/product/class/product.class.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index 56b9fc527a6..695ab573805 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -640,6 +640,20 @@ class Product extends CommonObject $this->width_units = trim($this->width_units); $this->height = price2num($this->height); $this->height_units = trim($this->height_units); + // Automated compute surface and volume if not filled + if (empty($this->surface) && !empty($this->length) && !empty($this->width) + && $this->length_units == $this->with_units + ) { + $this->surface = $this->length * $this->width; + $this->surface_units = $this->width_units; + if (empty($this->volume) && !empty($this->height) + && $this->length_units == $this->height_units + ) { + $this->volume = $this->surface * $this->height; + $this->volume_units = $this->height_units; + } + } + $this->surface = price2num($this->surface); $this->surface_units = trim($this->surface_units); $this->volume = price2num($this->volume); From a99ac7fb6b0098b1ff2193d28e0aca3ba40b6cc9 Mon Sep 17 00:00:00 2001 From: florian HENRY Date: Tue, 13 Dec 2016 16:52:49 +0100 Subject: [PATCH 11/89] taking account @eldy remarks --- htdocs/core/modules/modSociete.class.php | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/htdocs/core/modules/modSociete.class.php b/htdocs/core/modules/modSociete.class.php index 7984ed7f6a1..af4da616ce9 100644 --- a/htdocs/core/modules/modSociete.class.php +++ b/htdocs/core/modules/modSociete.class.php @@ -282,8 +282,12 @@ class modSociete extends DolibarrModules $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as paymode ON s.mode_reglement = paymode.id'; $this->export_sql_end[$r] .=' WHERE s.entity IN ('.getEntity('societe', 1).')'; if(!$user->rights->societe->client->voir) { - $subordinatesids = $user->getAllChildIds(); - $this->export_sql_end[$r] .=' AND (sc.fk_user = '.$user->id.' '.count($subronidatesids)>0 ? ' OR (sc.fk_user IN ('.implode(',',$subronidatesids).'))' : ''; + $this->export_sql_end[$r] .=' AND (sc.fk_user = '.$user->id.' '; + if ($conf->global->SOCIETE_EXPORT_SUBORDINATES_CHILDS) { + $subordinatesids = $user->getAllChildIds(); + $this->export_sql_end[$r] .=count($subronidatesids)>0 ? ' OR (sc.fk_user IN ('.implode(',',$subronidatesids).')' : ''; + } + $this->export_sql_end[$r] .=')'; } // Export list of contacts and attributes @@ -315,8 +319,12 @@ class modSociete extends DolibarrModules $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'socpeople_extrafields as extra ON extra.fk_object = c.rowid'; $this->export_sql_end[$r] .=' WHERE c.entity IN ('.getEntity("societe", 1).')'; if(!$user->rights->societe->client->voir) { - $subordinatesids = $user->getAllChildIds(); - $this->export_sql_end[$r] .=' AND (sc.fk_user = '.$user->id.' '.count($subronidatesids)>0 ? ' OR (sc.fk_user IN ('.implode(',',$subronidatesids).'))' : ''; + $this->export_sql_end[$r] .=' AND (sc.fk_user = '.$user->id.' '; + if ($conf->global->SOCIETE_EXPORT_SUBORDINATES_CHILDS) { + $subordinatesids = $user->getAllChildIds(); + $this->export_sql_end[$r] .=count($subronidatesids)>0 ? ' OR (sc.fk_user IN ('.implode(',',$subronidatesids).')' : ''; + } + $this->export_sql_end[$r] .=')'; } From 1338237d7c1cf5573a9d888efdde281fa19920dd Mon Sep 17 00:00:00 2001 From: aspangaro Date: Tue, 27 Dec 2016 05:48:18 +0100 Subject: [PATCH 12/89] Expense report - Better presentation - return list order by date --- htdocs/expensereport/card.php | 3 ++- htdocs/expensereport/class/expensereport.class.php | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/htdocs/expensereport/card.php b/htdocs/expensereport/card.php index ea75f7eeab6..c368f15ac4d 100644 --- a/htdocs/expensereport/card.php +++ b/htdocs/expensereport/card.php @@ -2,7 +2,7 @@ /* Copyright (C) 2003 Rodolphe Quiedeville * Copyright (C) 2004-2015 Laurent Destailleur * Copyright (C) 2005-2009 Regis Houssin - * Copyright (C) 2015-2016 Alexandre Spangaro + * Copyright (C) 2015-2016 Alexandre Spangaro * * 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 @@ -1806,6 +1806,7 @@ else $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_type_fees as ctf ON fde.fk_c_type_fees=ctf.id'; $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'projet as pjt ON fde.fk_projet=pjt.rowid'; $sql.= ' WHERE fde.fk_expensereport = '.$object->id; + $sql.= ' ORDER BY fde.date ASC'; print '
'; diff --git a/htdocs/expensereport/class/expensereport.class.php b/htdocs/expensereport/class/expensereport.class.php index 631d1ca548b..60308720231 100644 --- a/htdocs/expensereport/class/expensereport.class.php +++ b/htdocs/expensereport/class/expensereport.class.php @@ -1,7 +1,7 @@ * Copyright (C) 2015 Laurent Destailleur - * Copyright (C) 2015 Alexandre Spangaro + * Copyright (C) 2015 Alexandre Spangaro * Copyright (C) 2016 Ferran Marcet * * This program is free software; you can redistribute it and/or modify @@ -830,6 +830,7 @@ class ExpenseReport extends CommonObject $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_type_fees as ctf ON de.fk_c_type_fees = ctf.id'; $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'projet as p ON de.fk_projet = p.rowid'; $sql.= ' WHERE de.'.$this->fk_element.' = '.$this->id; + $sql.= ' ORDER BY de.date ASC'; dol_syslog('ExpenseReport::fetch_lines sql='.$sql, LOG_DEBUG); $resql = $this->db->query($sql); From c21300f0fa267296aa2715870bd5a797c2ec3d03 Mon Sep 17 00:00:00 2001 From: aspangaro Date: Tue, 27 Dec 2016 06:45:36 +0100 Subject: [PATCH 13/89] Expense report - Remove DEPLACEMENT_TO_CLEAN --- htdocs/expensereport/card.php | 144 ++++++++++++++++------------------ htdocs/langs/en_US/trips.lang | 4 +- 2 files changed, 72 insertions(+), 76 deletions(-) diff --git a/htdocs/expensereport/card.php b/htdocs/expensereport/card.php index ea75f7eeab6..2a0d0bb5d9f 100644 --- a/htdocs/expensereport/card.php +++ b/htdocs/expensereport/card.php @@ -342,11 +342,11 @@ if (empty($reshook)) $filename=array(); $filedir=array(); $mimetype=array(); // SUBJECT - $subject = $langs->trans("ExpenseReportWaitingForApproval"); + $subject = $langs->transnoentities("ExpenseReportWaitingForApproval"); // CONTENT $link = $urlwithroot.'/expensereport/card.php?id='.$object->id; - $message = $langs->trans("ExpenseReportWaitingForApprovalMessage", $expediteur->getFullName($langs), get_date_range($object->date_debut,$object->date_fin,'',$langs), $link); + $message = $langs->transnoentities("ExpenseReportWaitingForApprovalMessage", $expediteur->getFullName($langs), get_date_range($object->date_debut,$object->date_fin,'',$langs), $link); // Rebuild pdf /* @@ -436,81 +436,75 @@ if (empty($reshook)) if ($result > 0) { - if (! empty($conf->global->DEPLACEMENT_TO_CLEAN)) // TODO Translate this so we can remove condition - { - // Send mail + // Send mail + + // TO + $destinataire = new User($db); + $destinataire->fetch($object->fk_user_validator); + $emailTo = $destinataire->email; - // TO - $destinataire = new User($db); - $destinataire->fetch($object->fk_user_validator); - $emailTo = $destinataire->email; + if ($emailTo) + { + // FROM + $expediteur = new User($db); + $expediteur->fetch($object->fk_user_author); + $emailFrom = $expediteur->email; + + // SUBJECT + $subject = $langs->transnoentities("ExpenseReportWaitingForReApproval"); - if ($emailTo) - { - // FROM - $expediteur = new User($db); - $expediteur->fetch($object->fk_user_author); - $emailFrom = $expediteur->email; - - // SUBJECT - $subject = "' ERP - Note de frais à re-approuver"; - - // CONTENT - $dateRefusEx = explode(" ",$object->date_refuse); - - $message = "Bonjour {$destinataire->firstname},\n\n"; - $message.= "Le {$dateRefusEx[0]} à {$dateRefusEx[1]} vous avez refusé d'approuver la note de frais \"{$object->ref}\". Vous aviez émis le motif suivant : {$object->detail_refuse}\n\n"; - $message.= "L'auteur vient de modifier la note de frais, veuillez trouver la nouvelle version en pièce jointe.\n"; - $message.= "- Déclarant : {$expediteur->firstname} {$expediteur->lastname}\n"; - $message.= "- Période : du {$object->date_debut} au {$object->date_fin}\n"; - $message.= "- Lien : {$dolibarr_main_url_root}/expensereport/card.php?id={$object->id}\n\n"; - $message.= "Bien cordialement,\n' SI"; - - // Génération du pdf avant attachement - $object->setDocModel($user,""); - $resultPDF = expensereport_pdf_create($db,$object,'',"",$langs); - - if($resultPDF) - { - // ATTACHMENT - $filename=array(); $filedir=array(); $mimetype=array(); - array_push($filename,dol_sanitizeFileName($object->ref).".pdf"); - array_push($filedir,$conf->expensereport->dir_output . "/" . dol_sanitizeFileName($object->ref) . "/" . dol_sanitizeFileName($object->ref_number).".pdf"); - array_push($mimetype,"application/pdf"); - - // PREPARE SEND - $mailfile = new CMailFile($subject,$emailTo,$emailFrom,$message,$filedir,$mimetype,$filename); - - if (! $mailfile->error) - { - // SEND - $result=$mailfile->sendfile(); - if ($result) - { - Header("Location: ".$_SERVER["PHP_SELF"]."?id=".$id); - exit; - } - else - { - $mesg=$mailfile->error; - setEventMessages($mesg, null, 'errors'); - } - // END - Send mail - } - else - { - dol_print_error($db,$resultPDF); - exit; - } - } - } - } - } - else - { - setEventMessages($object->error, $object->errors, 'errors'); - } - } + // CONTENT + $link = $urlwithroot.'/expensereport/card.php?id='.$object->id; + $dateRefusEx = explode(" ",$object->date_refuse); + $message = $langs->transnoentities("ExpenseReportWaitingForReApprovalMessage", $dateRefusEx[0], $object->detail_refuse, $expediteur->getFullName($langs), $langs), $link); + + // Rebuild pdf + /* + $object->setDocModel($user,""); + $resultPDF = expensereport_pdf_create($db,$object,'',"",$langs); + + if($resultPDF) + { + // ATTACHMENT + $filename=array(); $filedir=array(); $mimetype=array(); + array_push($filename,dol_sanitizeFileName($object->ref).".pdf"); + array_push($filedir,$conf->expensereport->dir_output . "/" . dol_sanitizeFileName($object->ref) . "/" . dol_sanitizeFileName($object->ref_number).".pdf"); + array_push($mimetype,"application/pdf"); + } + */ + + // PREPARE SEND + $mailfile = new CMailFile($subject,$emailTo,$emailFrom,$message,$filedir,$mimetype,$filename); + + if (! $mailfile->error) + { + // SEND + $result=$mailfile->sendfile(); + if ($result) + { + Header("Location: ".$_SERVER["PHP_SELF"]."?id=".$id); + exit; + } + else + { + $mesg=$mailfile->error; + setEventMessages($mesg, null, 'errors'); + } + // END - Send mail + } + else + { + dol_print_error($db,$resultPDF); + exit; + } + } + } + } + else + { + setEventMessages($object->error, $object->errors, 'errors'); + } +} // Approve if ($action == "confirm_approve" && GETPOST("confirm") == "yes" && $id > 0 && $user->rights->expensereport->approve) diff --git a/htdocs/langs/en_US/trips.lang b/htdocs/langs/en_US/trips.lang index 9cb992f6af3..735711a1e58 100644 --- a/htdocs/langs/en_US/trips.lang +++ b/htdocs/langs/en_US/trips.lang @@ -21,7 +21,9 @@ ListToApprove=Waiting for approval ExpensesArea=Expense reports area ClassifyRefunded=Classify 'Refunded' ExpenseReportWaitingForApproval=A new expense report has been submitted for approval -ExpenseReportWaitingForApprovalMessage=A new expense report has been submitted and is waiting for approval.\n- User: %s\n- Period: %s\nClick here to validate: %s +ExpenseReportWaitingForApprovalMessage=A new expense report has been submitted and is waiting for approval.\n - User: %s\n - Period: %s\nClick here to validate: %s +ExpenseReportWaitingForReApproval=An expense report has been submitted for re-approval +ExpenseReportWaitingForReApprovalMessage=An expense report has been submitted and is waiting for re-approval.\nThe %s, you refused to approve the expense report for this reason: %s.\nA new version has been proposed and waiting for your approval.\n - User: %s\n - Period: %s\nClick here to validate: %s TripId=Id expense report AnyOtherInThisListCanValidate=Person to inform for validation. TripSociete=Information company From 8a24f2fc91349c4a3039446d368dfe674bce7470 Mon Sep 17 00:00:00 2001 From: aspangaro Date: Tue, 27 Dec 2016 08:14:05 +0100 Subject: [PATCH 14/89] Work in progress --- htdocs/expensereport/card.php | 528 +++++++++++++++++++--------------- 1 file changed, 296 insertions(+), 232 deletions(-) diff --git a/htdocs/expensereport/card.php b/htdocs/expensereport/card.php index 2a0d0bb5d9f..38c9817d27c 100644 --- a/htdocs/expensereport/card.php +++ b/htdocs/expensereport/card.php @@ -473,38 +473,53 @@ if (empty($reshook)) } */ - // PREPARE SEND - $mailfile = new CMailFile($subject,$emailTo,$emailFrom,$message,$filedir,$mimetype,$filename); - - if (! $mailfile->error) - { - // SEND - $result=$mailfile->sendfile(); - if ($result) - { - Header("Location: ".$_SERVER["PHP_SELF"]."?id=".$id); - exit; - } - else - { - $mesg=$mailfile->error; - setEventMessages($mesg, null, 'errors'); - } - // END - Send mail - } - else - { - dol_print_error($db,$resultPDF); - exit; - } - } - } - } - else - { - setEventMessages($object->error, $object->errors, 'errors'); - } -} + // PREPARE SEND + $mailfile = new CMailFile($subject,$emailTo,$emailFrom,$message,$filedir,$mimetype,$filename); + + if ($mailfile) + { + // SEND + $result=$mailfile->sendfile(); + if ($result) + { + $mesg=$langs->trans('MailSuccessfulySent',$mailfile->getValidAddress($emailFrom,2),$mailfile->getValidAddress($emailTo,2)); + setEventMessages($mesg, null, 'mesgs'); + header("Location: ".$_SERVER["PHP_SELF"]."?id=".$id); + exit; + } + else + { + $langs->load("other"); + if ($mailfile->error) + { + $mesg=''; + $mesg.=$langs->trans('ErrorFailedToSendMail', $emailFrom, $emailTo); + $mesg.='
'.$mailfile->error; + setEventMessages($mesg, null, 'errors'); + } + else + { + setEventMessages('No mail sent. Feature is disabled by option MAIN_DISABLE_ALL_MAILS', null, 'warnings'); + } + } + } + else + { + setEventMessages($mailfile->error,$mailfile->errors,'errors'); + $action=''; + } + } + else + { + setEventMessages($langs->trans("NoEmailSentBadSenderOrRecipientEmail"), null, 'warnings'); + $action=''; + } + } + else + { + setEventMessages($object->error, $object->errors, 'errors'); + } + } // Approve if ($action == "confirm_approve" && GETPOST("confirm") == "yes" && $id > 0 && $user->rights->expensereport->approve) @@ -536,73 +551,83 @@ if (empty($reshook)) if ($result > 0) { - if (! empty($conf->global->DEPLACEMENT_TO_CLEAN)) // TODO Translate this so we can remove condition + // Send mail + + // TO + $destinataire = new User($db); + $destinataire->fetch($object->fk_user_author); + $emailTo = $destinataire->email; + + // CC + $emailCC = $conf->global->NDF_CC_EMAILS; + + // FROM + $expediteur = new User($db); + $expediteur->fetch($object->fk_user_valid); + $emailFrom = $expediteur->email; + + // SUBJECT + $subject = $langs->transnoentities("ExpenseReportApproval"); + + // CONTENT + $link = $urlwithroot.'/expensereport/card.php?id='.$object->id; + $message = $langs->transnoentities("ExpenseReportApprovalMessage", $destinataire->getFullName($langs), $object->ref, $expediteur->getFullName($langs), '', $langs), $link); + + // Rebuilt pdf + /* + $object->setDocModel($user,""); + $resultPDF = expensereport_pdf_create($db,$object,'',"",$langs); + + if($resultPDF + { + // ATTACHMENT + $filename=array(); $filedir=array(); $mimetype=array(); + array_push($filename,dol_sanitizeFileName($object->ref).".pdf"); + array_push($filedir, $conf->expensereport->dir_output."/".dol_sanitizeFileName($object->ref)."/".dol_sanitizeFileName($object->ref).".pdf"); + array_push($mimetype,"application/pdf"); + } + */ + + // PREPARE SEND + $mailfile = new CMailFile($subject,$emailTo,$emailFrom,$message,$filedir,$mimetype,$filename); + + if ($mailfile) + { + // SEND + $result=$mailfile->sendfile(); + if ($result) + { + $mesg=$langs->trans('MailSuccessfulySent',$mailfile->getValidAddress($emailFrom,2),$mailfile->getValidAddress($emailTo,2)); + setEventMessages($mesg, null, 'mesgs'); + header("Location: ".$_SERVER["PHP_SELF"]."?id=".$id); + exit; + } + else + { + $langs->load("other"); + if ($mailfile->error) + { + $mesg=''; + $mesg.=$langs->trans('ErrorFailedToSendMail', $emailFrom, $emailTo); + $mesg.='
'.$mailfile->error; + setEventMessages($mesg, null, 'errors'); + } + else + { + setEventMessages('No mail sent. Feature is disabled by option MAIN_DISABLE_ALL_MAILS', null, 'warnings'); + } + } + } + else + { + setEventMessages($mailfile->error,$mailfile->errors,'errors'); + $action=''; + } + } + else { - // Send mail - - // TO - $destinataire = new User($db); - $destinataire->fetch($object->fk_user_author); - $emailTo = $destinataire->email; - - // CC - $emailCC = $conf->global->NDF_CC_EMAILS; - - // FROM - $expediteur = new User($db); - $expediteur->fetch($object->fk_user_valid); - $emailFrom = $expediteur->email; - - // SUBJECT - $subject = "' ERP - Note de frais validée"; - - // CONTENT - $message = "Bonjour {$destinataire->firstname},\n\n"; - $message.= "Votre note de frais \"{$object->ref}\" vient d'être approuvé!\n"; - $message.= "- Approbateur : {$expediteur->firstname} {$expediteur->lastname}\n"; - $message.= "- Lien : {$dolibarr_main_url_root}/expensereport/card.php?id={$object->id}\n\n"; - $message.= "Bien cordialement,\n' SI"; - - // Génération du pdf avant attachement - $object->setDocModel($user,""); - $resultPDF = expensereport_pdf_create($db,$object,'',"",$langs); - - if($resultPDF): - // ATTACHMENT - $filename=array(); $filedir=array(); $mimetype=array(); - array_push($filename,dol_sanitizeFileName($object->ref).".pdf"); - array_push($filedir, $conf->expensereport->dir_output. - "/". - dol_sanitizeFileName($object->ref) . - "/". - dol_sanitizeFileName($object->ref). - ".pdf" - ); - array_push($mimetype,"application/pdf"); - - // PREPARE SEND - $mailfile = new CMailFile($subject,$emailTo,$emailFrom,$message,$filedir,$mimetype,$filename,$emailCC); - - if(!$mailfile->error): - - // SEND - $result=$mailfile->sendfile(); - if ($result): - setEventMessages($langs->trans("MailSuccessfulySent",$emailFrom,$emailTo), null, 'mesgs'); - Header("Location: ".$_SERVER["PHP_SELF"]."?id=".$id); - exit; - else: - setEventMessages($langs->trans("ErrorFailedToSendMail",$emailFrom,$emailTo), null, 'errors'); - endif; - - else: - setEventMessages($langs->trans("ErrorFailedToSendMail",$emailFrom,$emailTo), null, 'errors'); - endif; - // END - Send mail - else : // if ($resultPDF) - dol_print_error($db,$resultPDF); - exit; - endif; + setEventMessages($langs->trans("NoEmailSentBadSenderOrRecipientEmail"), null, 'warnings'); + $action=''; } } else @@ -640,57 +665,75 @@ if (empty($reshook)) if ($result > 0) { - if (! empty($conf->global->DEPLACEMENT_TO_CLEAN)) // TODO Translate this so we can remove condition + // Send mail + + // TO + $destinataire = new User($db); + $destinataire->fetch($object->fk_user_author); + $emailTo = $destinataire->email; + + // FROM + $expediteur = new User($db); + $expediteur->fetch($object->fk_user_refuse); + $emailFrom = $expediteur->email; + + // SUBJECT + $subject = "' ERP - Note de frais refusée"; + + // CONTENT + $message = "Bonjour {$destinataire->firstname},\n\n"; + $message.= "Votre note de frais \"{$object->ref}\" vient d'être refusée.\n"; + $message.= "- Refuseur : {$expediteur->firstname} {$expediteur->lastname}\n"; + $message.= "- Motif de refus : {$_POST['detail_refuse']}\n"; + $message.= "- Lien : {$dolibarr_main_url_root}/expensereport/card.php?id={$object->id}\n\n"; + $message.= "Bien cordialement,\n' SI"; + + // PREPARE SEND + $mailfile = new CMailFile($subject,$emailTo,$emailFrom,$message,$filedir,$mimetype,$filename); + + if ($mailfile) { - // Send mail - - // TO - $destinataire = new User($db); - $destinataire->fetch($object->fk_user_author); - $emailTo = $destinataire->email; - - // FROM - $expediteur = new User($db); - $expediteur->fetch($object->fk_user_refuse); - $emailFrom = $expediteur->email; - - // SUBJECT - $subject = "' ERP - Note de frais refusée"; - - // CONTENT - $message = "Bonjour {$destinataire->firstname},\n\n"; - $message.= "Votre note de frais \"{$object->ref}\" vient d'être refusée.\n"; - $message.= "- Refuseur : {$expediteur->firstname} {$expediteur->lastname}\n"; - $message.= "- Motif de refus : {$_POST['detail_refuse']}\n"; - $message.= "- Lien : {$dolibarr_main_url_root}/expensereport/card.php?id={$object->id}\n\n"; - $message.= "Bien cordialement,\n' SI"; - - // PREPARE SEND - $mailfile = new CMailFile($subject,$emailTo,$emailFrom,$message); - - if(!$mailfile->error) + // SEND + $result=$mailfile->sendfile(); + if ($result) { - // SEND - $result=$mailfile->sendfile(); - if ($result) + $mesg=$langs->trans('MailSuccessfulySent',$mailfile->getValidAddress($emailFrom,2),$mailfile->getValidAddress($emailTo,2)); + setEventMessages($mesg, null, 'mesgs'); + header("Location: ".$_SERVER["PHP_SELF"]."?id=".$id); + exit; + } + else + { + $langs->load("other"); + if ($mailfile->error) { - setEventMessages($langs->trans("MailSuccessfulySent",$emailFrom,$emailTo), null, 'mesgs'); - Header("Location: ".$_SERVER["PHP_SELF"]."?id=".$id); - exit; + $mesg=''; + $mesg.=$langs->trans('ErrorFailedToSendMail', $emailFrom, $emailTo); + $mesg.='
'.$mailfile->error; + setEventMessages($mesg, null, 'errors'); } else { - setEventMessages($langs->trans("ErrorFailedToSendMail",$emailFrom,$emailTo), null, 'errors'); + setEventMessages('No mail sent. Feature is disabled by option MAIN_DISABLE_ALL_MAILS', null, 'warnings'); } - // END - Send mail } } + else + { + setEventMessages($mailfile->error,$mailfile->errors,'errors'); + $action=''; + } } else { - setEventMessages($object->error, $object->errors, 'errors'); + setEventMessages($langs->trans("NoEmailSentBadSenderOrRecipientEmail"), null, 'warnings'); + $action=''; } } + else + { + setEventMessages($object->error, $object->errors, 'errors'); + } //var_dump($user->id == $object->fk_user_validator);exit; if ($action == "confirm_cancel" && GETPOST('confirm')=="yes" && GETPOST('detail_cancel') && $id > 0 && $user->rights->expensereport->creer) @@ -724,64 +767,74 @@ if (empty($reshook)) if ($result > 0) { - if (! empty($conf->global->DEPLACEMENT_TO_CLEAN)) // TODO Translate this so we can remove condition + // Send mail + + // TO + $destinataire = new User($db); + $destinataire->fetch($object->fk_user_author); + $emailTo = $destinataire->email; + + // FROM + $expediteur = new User($db); + $expediteur->fetch($object->fk_user_cancel); + $emailFrom = $expediteur->email; + + // SUBJECT + $subject = "' ERP - Note de frais annulée"; + + // CONTENT + $message = "Bonjour {$destinataire->firstname},\n\n"; + $message.= "Votre note de frais \"{$object->ref}\" vient d'être annulée.\n"; + $message.= "- Annuleur : {$expediteur->firstname} {$expediteur->lastname}\n"; + $message.= "- Motif d'annulation : {$_POST['detail_cancel']}\n"; + $message.= "- Lien : {$dolibarr_main_url_root}/expensereport/card.php?id={$object->id}\n\n"; + $message.= "Bien cordialement,\n' SI"; + + // PREPARE SEND + $mailfile = new CMailFile($subject,$emailTo,$emailFrom,$message,$filedir,$mimetype,$filename); + + if ($mailfile) { - // Send mail - - // TO - $destinataire = new User($db); - $destinataire->fetch($object->fk_user_author); - $emailTo = $destinataire->email; - - // FROM - $expediteur = new User($db); - $expediteur->fetch($object->fk_user_cancel); - $emailFrom = $expediteur->email; - - // SUBJECT - $subject = "' ERP - Note de frais annulée"; - - // CONTENT - $message = "Bonjour {$destinataire->firstname},\n\n"; - $message.= "Votre note de frais \"{$object->ref}\" vient d'être annulée.\n"; - $message.= "- Annuleur : {$expediteur->firstname} {$expediteur->lastname}\n"; - $message.= "- Motif d'annulation : {$_POST['detail_cancel']}\n"; - $message.= "- Lien : {$dolibarr_main_url_root}/expensereport/card.php?id={$object->id}\n\n"; - $message.= "Bien cordialement,\n' SI"; - - // PREPARE SEND - $mailfile = new CMailFile($subject,$emailTo,$emailFrom,$message); - - if(!$mailfile->error) + // SEND + $result=$mailfile->sendfile(); + if ($result) { - // SEND - $result=$mailfile->sendfile(); - if ($result) - { - header("Location: ".$_SERVER["PHP_SELF"]."?id=".$id); - exit; - } - else - { - $mesg="Impossible d'envoyer l'email."; - setEventMessages($mesg, null, 'errors'); - } - // END - Send mail + $mesg=$langs->trans('MailSuccessfulySent',$mailfile->getValidAddress($emailFrom,2),$mailfile->getValidAddress($emailTo,2)); + setEventMessages($mesg, null, 'mesgs'); + header("Location: ".$_SERVER["PHP_SELF"]."?id=".$id); + exit; } else { - setEventMessages($mail->error, $mail->errors, 'errors'); + $langs->load("other"); + if ($mailfile->error) + { + $mesg=''; + $mesg.=$langs->trans('ErrorFailedToSendMail', $emailFrom, $emailTo); + $mesg.='
'.$mailfile->error; + setEventMessages($mesg, null, 'errors'); + } + else + { + setEventMessages('No mail sent. Feature is disabled by option MAIN_DISABLE_ALL_MAILS', null, 'warnings'); + } } } + else + { + setEventMessages($mailfile->error,$mailfile->errors,'errors'); + $action=''; + } } else { - setEventMessages($object->error, $object->errors, 'errors'); + setEventMessages($langs->trans("NoEmailSentBadSenderOrRecipientEmail"), null, 'warnings'); + $action=''; } } else { - setEventMessages($langs->transnoentitiesnoconv("OnlyOwnerCanCancel"), '', 'errors'); // Should not happened + setEventMessages($object->error, $object->errors, 'errors'); } } @@ -858,68 +911,79 @@ if (empty($reshook)) if ($result > 0) { - if (! empty($conf->global->DEPLACEMENT_TO_CLEAN)) // TODO Translate this so we can remove condition + // Send mail + + // TO + $destinataire = new User($db); + $destinataire->fetch($object->fk_user_author); + $emailTo = $destinataire->email; + + // FROM + $expediteur = new User($db); + $expediteur->fetch($user->id); + $emailFrom = $expediteur->email; + + // SUBJECT + $subject = "'ERP - Note de frais payée"; + + // CONTENT + $message = "Bonjour {$destinataire->firstname},\n\n"; + $message.= "Votre note de frais \"{$object->ref}\" vient d'être payée.\n"; + $message.= "- Payeur : {$expediteur->firstname} {$expediteur->lastname}\n"; + $message.= "- Lien : {$dolibarr_main_url_root}/expensereport/card.php?id={$object->id}\n\n"; + $message.= "Bien cordialement,\n' SI"; + + // Generate pdf before attachment + $object->setDocModel($user,""); + $resultPDF = expensereport_pdf_create($db,$object,'',"",$langs); + + // PREPARE SEND + $mailfile = new CMailFile($subject,$emailTo,$emailFrom,$message,$filedir,$mimetype,$filename); + + if ($mailfile) { - // Send mail - - // TO - $destinataire = new User($db); - $destinataire->fetch($object->fk_user_author); - $emailTo = $destinataire->email; - - // FROM - $expediteur = new User($db); - $expediteur->fetch($user->id); - $emailFrom = $expediteur->email; - - // SUBJECT - $subject = "'ERP - Note de frais payée"; - - // CONTENT - $message = "Bonjour {$destinataire->firstname},\n\n"; - $message.= "Votre note de frais \"{$object->ref}\" vient d'être payée.\n"; - $message.= "- Payeur : {$expediteur->firstname} {$expediteur->lastname}\n"; - $message.= "- Lien : {$dolibarr_main_url_root}/expensereport/card.php?id={$object->id}\n\n"; - $message.= "Bien cordialement,\n' SI"; - - // Generate pdf before attachment - $object->setDocModel($user,""); - $resultPDF = expensereport_pdf_create($db,$object,'',"",$langs); - - // PREPARE SEND - $mailfile = new CMailFile($subject,$emailTo,$emailFrom,$message); - - if(!$mailfile->error): - // SEND - $result=$mailfile->sendfile(); - if ($result): - - // Retour - if($result): - Header("Location: ".$_SERVER["PHP_SELF"]."?id=".$id); + $result=$mailfile->sendfile(); + if ($result) + { + $mesg=$langs->trans('MailSuccessfulySent',$mailfile->getValidAddress($emailFrom,2),$mailfile->getValidAddress($emailTo,2)); + setEventMessages($mesg, null, 'mesgs'); + header("Location: ".$_SERVER["PHP_SELF"]."?id=".$id); exit; - else: - dol_print_error($db); - endif; - - else: - dol_print_error($db,$acct->error); - endif; - - else: - $mesg="Impossible d'envoyer l'email."; - setEventMessages($mesg, null, 'errors'); - endif; - // END - Send mail + } + else + { + $langs->load("other"); + if ($mailfile->error) + { + $mesg=''; + $mesg.=$langs->trans('ErrorFailedToSendMail', $emailFrom, $emailTo); + $mesg.='
'.$mailfile->error; + setEventMessages($mesg, null, 'errors'); + } + else + { + setEventMessages('No mail sent. Feature is disabled by option MAIN_DISABLE_ALL_MAILS', null, 'warnings'); + } + } + } + else + { + setEventMessages($mailfile->error,$mailfile->errors,'errors'); + $action=''; } } else { - setEventMessages($object->error, $object->errors, 'errors'); + setEventMessages($langs->trans("NoEmailSentBadSenderOrRecipientEmail"), null, 'warnings'); + $action=''; } } - + else + { + setEventMessages($object->error, $object->errors, 'errors'); + } + if ($action == "addline" && $user->rights->expensereport->creer) { $error = 0; From 4705a87548c590b7aae0b3bab6d0abf9c3c8ea5c Mon Sep 17 00:00:00 2001 From: aspangaro Date: Tue, 27 Dec 2016 14:48:14 +0100 Subject: [PATCH 15/89] Finish work --- htdocs/expensereport/card.php | 169 +++++++++++++++++++--------------- htdocs/langs/en_US/trips.lang | 8 ++ 2 files changed, 105 insertions(+), 72 deletions(-) diff --git a/htdocs/expensereport/card.php b/htdocs/expensereport/card.php index 38c9817d27c..afc00b60225 100644 --- a/htdocs/expensereport/card.php +++ b/htdocs/expensereport/card.php @@ -456,7 +456,7 @@ if (empty($reshook)) // CONTENT $link = $urlwithroot.'/expensereport/card.php?id='.$object->id; $dateRefusEx = explode(" ",$object->date_refuse); - $message = $langs->transnoentities("ExpenseReportWaitingForReApprovalMessage", $dateRefusEx[0], $object->detail_refuse, $expediteur->getFullName($langs), $langs), $link); + $message = $langs->transnoentities("ExpenseReportWaitingForReApprovalMessage", $dateRefusEx[0], $object->detail_refuse, $expediteur->getFullName($langs), $link); // Rebuild pdf /* @@ -567,11 +567,11 @@ if (empty($reshook)) $emailFrom = $expediteur->email; // SUBJECT - $subject = $langs->transnoentities("ExpenseReportApproval"); + $subject = $langs->transnoentities("ExpenseReportApproved"); // CONTENT $link = $urlwithroot.'/expensereport/card.php?id='.$object->id; - $message = $langs->transnoentities("ExpenseReportApprovalMessage", $destinataire->getFullName($langs), $object->ref, $expediteur->getFullName($langs), '', $langs), $link); + $message = $langs->transnoentities("ExpenseReportApprovedMessage", $object->ref, $destinataire->getFullName($langs), $expediteur->getFullName($langs), $link); // Rebuilt pdf /* @@ -588,53 +588,52 @@ if (empty($reshook)) } */ - // PREPARE SEND - $mailfile = new CMailFile($subject,$emailTo,$emailFrom,$message,$filedir,$mimetype,$filename); - - if ($mailfile) - { - // SEND - $result=$mailfile->sendfile(); - if ($result) - { - $mesg=$langs->trans('MailSuccessfulySent',$mailfile->getValidAddress($emailFrom,2),$mailfile->getValidAddress($emailTo,2)); - setEventMessages($mesg, null, 'mesgs'); - header("Location: ".$_SERVER["PHP_SELF"]."?id=".$id); - exit; - } - else - { - $langs->load("other"); - if ($mailfile->error) - { - $mesg=''; - $mesg.=$langs->trans('ErrorFailedToSendMail', $emailFrom, $emailTo); - $mesg.='
'.$mailfile->error; - setEventMessages($mesg, null, 'errors'); - } - else - { - setEventMessages('No mail sent. Feature is disabled by option MAIN_DISABLE_ALL_MAILS', null, 'warnings'); - } - } - } - else - { - setEventMessages($mailfile->error,$mailfile->errors,'errors'); - $action=''; - } - } - else - { - setEventMessages($langs->trans("NoEmailSentBadSenderOrRecipientEmail"), null, 'warnings'); - $action=''; - } - } - else - { - setEventMessages($object->error, $object->errors, 'errors'); - } - } + // PREPARE SEND + $mailfile = new CMailFile($subject,$emailTo,$emailFrom,$message,$filedir,$mimetype,$filename); + + if ($mailfile) + { + // SEND + $result=$mailfile->sendfile(); + if ($result) + { + $mesg=$langs->trans('MailSuccessfulySent',$mailfile->getValidAddress($emailFrom,2),$mailfile->getValidAddress($emailTo,2)); + setEventMessages($mesg, null, 'mesgs'); + header("Location: ".$_SERVER["PHP_SELF"]."?id=".$id); + exit; + } + else + { + $langs->load("other"); + if ($mailfile->error) + { + $mesg=''; + $mesg.=$langs->trans('ErrorFailedToSendMail', $emailFrom, $emailTo); + $mesg.='
'.$mailfile->error; + setEventMessages($mesg, null, 'errors'); + } + else + { + setEventMessages('No mail sent. Feature is disabled by option MAIN_DISABLE_ALL_MAILS', null, 'warnings'); + } + } + } + else + { + setEventMessages($mailfile->error,$mailfile->errors,'errors'); + $action=''; + } + } + else + { + setEventMessages($langs->trans("NoEmailSentBadSenderOrRecipientEmail"), null, 'warnings'); + $action=''; + } + } + else + { + setEventMessages($object->error, $object->errors, 'errors'); + } if ($action == "confirm_refuse" && GETPOST('confirm')=="yes" && $id > 0 && $user->rights->expensereport->approve) { @@ -677,16 +676,27 @@ if (empty($reshook)) $expediteur->fetch($object->fk_user_refuse); $emailFrom = $expediteur->email; - // SUBJECT - $subject = "' ERP - Note de frais refusée"; + // SUBJECT + $subject = $langs->transnoentities("ExpenseReportRefused"); + + // CONTENT + $link = $urlwithroot.'/expensereport/card.php?id='.$object->id; + $message = $langs->transnoentities("ExpenseReportRefusedMessage", $object->ref, $destinataire->getFullName($langs), $expediteur->getFullName($langs), $_POST['detail_refuse'], $link); + + // Rebuilt pdf + /* + $object->setDocModel($user,""); + $resultPDF = expensereport_pdf_create($db,$object,'',"",$langs); - // CONTENT - $message = "Bonjour {$destinataire->firstname},\n\n"; - $message.= "Votre note de frais \"{$object->ref}\" vient d'être refusée.\n"; - $message.= "- Refuseur : {$expediteur->firstname} {$expediteur->lastname}\n"; - $message.= "- Motif de refus : {$_POST['detail_refuse']}\n"; - $message.= "- Lien : {$dolibarr_main_url_root}/expensereport/card.php?id={$object->id}\n\n"; - $message.= "Bien cordialement,\n' SI"; + if($resultPDF + { + // ATTACHMENT + $filename=array(); $filedir=array(); $mimetype=array(); + array_push($filename,dol_sanitizeFileName($object->ref).".pdf"); + array_push($filedir, $conf->expensereport->dir_output."/".dol_sanitizeFileName($object->ref)."/".dol_sanitizeFileName($object->ref).".pdf"); + array_push($mimetype,"application/pdf"); + } + */ // PREPARE SEND $mailfile = new CMailFile($subject,$emailTo,$emailFrom,$message,$filedir,$mimetype,$filename); @@ -779,17 +789,28 @@ if (empty($reshook)) $expediteur->fetch($object->fk_user_cancel); $emailFrom = $expediteur->email; - // SUBJECT - $subject = "' ERP - Note de frais annulée"; - - // CONTENT - $message = "Bonjour {$destinataire->firstname},\n\n"; - $message.= "Votre note de frais \"{$object->ref}\" vient d'être annulée.\n"; - $message.= "- Annuleur : {$expediteur->firstname} {$expediteur->lastname}\n"; - $message.= "- Motif d'annulation : {$_POST['detail_cancel']}\n"; - $message.= "- Lien : {$dolibarr_main_url_root}/expensereport/card.php?id={$object->id}\n\n"; - $message.= "Bien cordialement,\n' SI"; - + // SUBJECT + $subject = $langs->transnoentities("ExpenseReportCanceled"); + + // CONTENT + $link = $urlwithroot.'/expensereport/card.php?id='.$object->id; + $message = $langs->transnoentities("ExpenseReportCanceledMessage", $object->ref, $destinataire->getFullName($langs), $expediteur->getFullName($langs), $_POST['detail_cancel'], $link); + + // Rebuilt pdf + /* + $object->setDocModel($user,""); + $resultPDF = expensereport_pdf_create($db,$object,'',"",$langs); + + if($resultPDF + { + // ATTACHMENT + $filename=array(); $filedir=array(); $mimetype=array(); + array_push($filename,dol_sanitizeFileName($object->ref).".pdf"); + array_push($filedir, $conf->expensereport->dir_output."/".dol_sanitizeFileName($object->ref)."/".dol_sanitizeFileName($object->ref).".pdf"); + array_push($mimetype,"application/pdf"); + } + */ + // PREPARE SEND $mailfile = new CMailFile($subject,$emailTo,$emailFrom,$message,$filedir,$mimetype,$filename); @@ -923,8 +944,12 @@ if (empty($reshook)) $expediteur->fetch($user->id); $emailFrom = $expediteur->email; - // SUBJECT - $subject = "'ERP - Note de frais payée"; + // SUBJECT + $subject = $langs->transnoentities("ExpenseReportPaid"); + + // CONTENT + $link = $urlwithroot.'/expensereport/card.php?id='.$object->id; + $message = $langs->transnoentities("ExpenseReportPaidMessage", $object->ref, $destinataire->getFullName($langs), $expediteur->getFullName($langs), $link); // CONTENT $message = "Bonjour {$destinataire->firstname},\n\n"; diff --git a/htdocs/langs/en_US/trips.lang b/htdocs/langs/en_US/trips.lang index 735711a1e58..ac650ab98c7 100644 --- a/htdocs/langs/en_US/trips.lang +++ b/htdocs/langs/en_US/trips.lang @@ -24,6 +24,14 @@ ExpenseReportWaitingForApproval=A new expense report has been submitted for appr ExpenseReportWaitingForApprovalMessage=A new expense report has been submitted and is waiting for approval.\n - User: %s\n - Period: %s\nClick here to validate: %s ExpenseReportWaitingForReApproval=An expense report has been submitted for re-approval ExpenseReportWaitingForReApprovalMessage=An expense report has been submitted and is waiting for re-approval.\nThe %s, you refused to approve the expense report for this reason: %s.\nA new version has been proposed and waiting for your approval.\n - User: %s\n - Period: %s\nClick here to validate: %s +ExpenseReportApproved=An expense report was approved +ExpenseReportApprovedMessage=The expense report %s was approved.\n - User: %s\n - Approved by: %s\nClick here to show the expense report: %s +ExpenseReportRefused=An expense report was refused +ExpenseReportRefusedMessage=The expense report %s was refused.\n - User: %s\n - Refused by: %s\n - Motive for refusal: %s\nClick here to show the expense report: %s +ExpenseReportCanceled=An expense report was canceled +ExpenseReportCanceledMessage=The expense report %s was canceled.\n - User: %s\n - Canceled by: %s\n - Motive for cancellation: %s\nClick here to show the expense report: %s +ExpenseReportPaid=An expense report was paid +ExpenseReportPaidMessage=The expense report %s was paid.\n - User: %s\n - Paid by: %s\nClick here to show the expense report: %s TripId=Id expense report AnyOtherInThisListCanValidate=Person to inform for validation. TripSociete=Information company From 65854318490eaf3598297fb6906735a89466751b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 7 Jan 2017 17:32:45 +0100 Subject: [PATCH 16/89] Fix css --- htdocs/loan/index.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/loan/index.php b/htdocs/loan/index.php index a03abce6350..aea84394c1c 100644 --- a/htdocs/loan/index.php +++ b/htdocs/loan/index.php @@ -139,7 +139,7 @@ if ($resql) print ''; print ''; print ' '; - print ''; + print ''; print ''; print ''; print ''; From 37d158f15915aba6ea96823b6bef0a5a30bc5f2a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 7 Jan 2017 21:33:13 +0100 Subject: [PATCH 17/89] FIX Accept spaces around the | criteria --- htdocs/core/lib/functions.lib.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index bb268ffa2d0..d38f765c6f5 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -5737,7 +5737,9 @@ function natural_search($fields, $value, $mode=0, $nofirstand=0) else // $mode=0 { $textcrit = ''; - $tmpcrits = explode('|',$crit); + $tmpcrit = preg_replace('/\s+|/','|',$tmpcrit); + $tmpcrit = preg_replace('/|\s+/','|',$tmpcrit); + $tmpcrits = explode('|',$tmpcrit); $i3 = 0; foreach($tmpcrits as $tmpcrit) { From 3bb1756a13c75de13643a475c5031bc60a3dc778 Mon Sep 17 00:00:00 2001 From: KiteAtao Date: Sat, 7 Jan 2017 21:37:45 +0100 Subject: [PATCH 18/89] Fix Contact Api for REST WebServices --- htdocs/societe/class/api_contact.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/societe/class/api_contact.class.php b/htdocs/societe/class/api_contact.class.php index 884653e044d..211792a2628 100644 --- a/htdocs/societe/class/api_contact.class.php +++ b/htdocs/societe/class/api_contact.class.php @@ -17,7 +17,7 @@ use Luracast\Restler\RestException; -//require_once DOL_DOCUMENT_ROOT . '/contact/class/contact.class.php'; +require_once DOL_DOCUMENT_ROOT . '/contact/class/contact.class.php'; /** * API class for contact object From 5c76229cdf0c296cca52c375deeae3779be21a0b Mon Sep 17 00:00:00 2001 From: KiteAtao Date: Sat, 7 Jan 2017 21:46:49 +0100 Subject: [PATCH 19/89] Fix Commands Api for REST WebServices --- htdocs/commande/class/api_commande.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/commande/class/api_commande.class.php b/htdocs/commande/class/api_commande.class.php index 3a029bc0d00..45ef2d4b4f2 100644 --- a/htdocs/commande/class/api_commande.class.php +++ b/htdocs/commande/class/api_commande.class.php @@ -193,7 +193,7 @@ class CommandeApi extends DolibarrApi * @return array Array of order objects */ function getListForSoc($socid = 0) { - return getList(0,"s.rowid","ASC",0,0,$socid); + return $this->getList(0,"s.rowid","ASC",0,0,$socid); } From 2c1477ecea93d534b62d8bcce05e27c6c8007f6e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 7 Jan 2017 21:50:14 +0100 Subject: [PATCH 20/89] Revert "FIX Accept spaces around the | criteria" This reverts commit 37d158f15915aba6ea96823b6bef0a5a30bc5f2a. --- htdocs/core/lib/functions.lib.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index d38f765c6f5..bb268ffa2d0 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -5737,9 +5737,7 @@ function natural_search($fields, $value, $mode=0, $nofirstand=0) else // $mode=0 { $textcrit = ''; - $tmpcrit = preg_replace('/\s+|/','|',$tmpcrit); - $tmpcrit = preg_replace('/|\s+/','|',$tmpcrit); - $tmpcrits = explode('|',$tmpcrit); + $tmpcrits = explode('|',$crit); $i3 = 0; foreach($tmpcrits as $tmpcrit) { From 76a53dfb7d32739171e31495e85939477549dec2 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 8 Jan 2017 01:00:47 +0100 Subject: [PATCH 21/89] FIX Accept spaces around the | criteria --- htdocs/core/lib/functions.lib.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index bb268ffa2d0..2ce0bd1a524 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -5677,7 +5677,7 @@ function dol_getmypid() * If param $mode is 1, can contains an operator <, > or = like "<10" or ">=100.5 < 1000" * If param $mode is 2, can contains a list of id separated by comma like "1,3,4" * @param integer $mode 0=value is list of keywords, 1=value is a numeric test (Example ">5.5 <10"), 2=value is a list of id separated with comma (Example '1,3,4') - * @param integer $nofirstand 1=Do now output the first 'AND' + * @param integer $nofirstand 1=Do not output the first 'AND' * @return string $res The statement to append to the SQL query */ function natural_search($fields, $value, $mode=0, $nofirstand=0) @@ -5692,6 +5692,9 @@ function natural_search($fields, $value, $mode=0, $nofirstand=0) { $value=preg_replace('/([<>=]+)\s+([0-9'.preg_quote($langs->trans("DecimalSeparator"),'/').'\-])/','\1\2',$value); // Clean string '< 10' into '<10' so we can the explode on space to get all tests to do } + + $value = preg_replace('/\s*\|\s*/','|', $value); + $crits = explode(' ', $value); $res = ''; if (! is_array($fields)) $fields = array($fields); From 8e615a83e5fe9f5ce594b89b61542a272c04a3c7 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 8 Jan 2017 01:07:28 +0100 Subject: [PATCH 22/89] Better tooltip --- htdocs/langs/en_US/main.lang | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/langs/en_US/main.lang b/htdocs/langs/en_US/main.lang index edd72899f3d..a4f396a43b8 100644 --- a/htdocs/langs/en_US/main.lang +++ b/htdocs/langs/en_US/main.lang @@ -788,8 +788,8 @@ SetRef=Set ref Select2ResultFoundUseArrows=Some results found. Use arrows to select. Select2NotFound=No result found Select2Enter=Enter -Select2MoreCharacter=or more characters

SEARCH OPERANDS:
| OR
* Any character
^ Start with
$ End with
-Select2MoreCharacters=or more characters

SEARCH OPERANDS:
| OR
* Any character
^ Start with
$ End with
+Select2MoreCharacter=or more characters

Search syntax:
| OR (a|b)
* Any character (a*b)
^ Start with (^ab)
$ End with (ab$)
+Select2MoreCharacters=or more characters

Search syntax:
| OR (a|b)
* Any character (a*b)
^ Start with (^ab)
$ End with (ab$)
Select2LoadingMoreResults=Loading more results... Select2SearchInProgress=Search in progress... SearchIntoThirdparties=Thirdparties From 3e77fed81515687943fea503cc3fb6a659a84b4d Mon Sep 17 00:00:00 2001 From: Gustavo Novaro Date: Sun, 8 Jan 2017 01:59:04 -0300 Subject: [PATCH 23/89] Fix missing , --- htdocs/install/mysql/tables/llx_loan.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/install/mysql/tables/llx_loan.sql b/htdocs/install/mysql/tables/llx_loan.sql index 0fe0c677ecb..f55b793e5ec 100644 --- a/htdocs/install/mysql/tables/llx_loan.sql +++ b/htdocs/install/mysql/tables/llx_loan.sql @@ -48,6 +48,6 @@ create table llx_loan fk_projet integer DEFAULT NULL, fk_user_author integer DEFAULT NULL, - fk_user_modif integer DEFAULT NULL + fk_user_modif integer DEFAULT NULL, active tinyint DEFAULT 1 NOT NULL )ENGINE=innodb; From dc605c915aa73adad5876f2d404836eec40856cd Mon Sep 17 00:00:00 2001 From: aspangaro Date: Sun, 8 Jan 2017 07:46:30 +0100 Subject: [PATCH 24/89] Fix : Bank - Missing language file --- htdocs/compta/bank/bankentries.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/compta/bank/bankentries.php b/htdocs/compta/bank/bankentries.php index 47405d0e748..5cae7aff723 100644 --- a/htdocs/compta/bank/bankentries.php +++ b/htdocs/compta/bank/bankentries.php @@ -54,6 +54,7 @@ $langs->load("loan"); $langs->load("donations"); $langs->load("trips"); $langs->load("members"); +$langs->load("compta"); $id = GETPOST('id','int'); $ref = GETPOST('ref','alpha'); From 41832a0c2657087d8eeea72fff1cc886e7e19585 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 8 Jan 2017 11:20:29 +0100 Subject: [PATCH 25/89] Fix neutral color on login (no theme yet selected) --- htdocs/theme/eldy/style.css.php | 2 +- htdocs/theme/md/style.css.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/theme/eldy/style.css.php b/htdocs/theme/eldy/style.css.php index d72d303aa32..6da8a7cf935 100644 --- a/htdocs/theme/eldy/style.css.php +++ b/htdocs/theme/eldy/style.css.php @@ -262,7 +262,7 @@ input, input.flat, textarea, textarea.flat, form.flat select, select, select.fla input:focus, textarea:focus, button:focus, select:focus { /* box-shadow: 0 0 4px #8091BF; */ - border-bottom: 1px solid #8091BF !important; + border-bottom: 1px solid #aaa !important; } textarea.cke_source:focus { diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php index 409a902648e..a66727cb3db 100644 --- a/htdocs/theme/md/style.css.php +++ b/htdocs/theme/md/style.css.php @@ -262,7 +262,7 @@ input, input.flat, textarea, textarea.flat, form.flat select, select, select.fla input:focus, textarea:focus, button:focus, select:focus { /* box-shadow: 0 0 4px #8091BF; */ - border-bottom: 1px solid #8091BF !important; + border-bottom: 1px solid #aaa !important; } textarea.cke_source:focus { From 913df73ed918589d6e28fb05f9dc9abb5b677af9 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 8 Jan 2017 11:31:39 +0100 Subject: [PATCH 26/89] Fix css --- htdocs/theme/eldy/style.css.php | 4 ++-- htdocs/theme/md/style.css.php | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/theme/eldy/style.css.php b/htdocs/theme/eldy/style.css.php index 6da8a7cf935..02460670217 100644 --- a/htdocs/theme/eldy/style.css.php +++ b/htdocs/theme/eldy/style.css.php @@ -261,8 +261,8 @@ input, input.flat, textarea, textarea.flat, form.flat select, select, select.fla } input:focus, textarea:focus, button:focus, select:focus { - /* box-shadow: 0 0 4px #8091BF; */ - border-bottom: 1px solid #aaa !important; + box-shadow: 0 0 4px #8091BF; + /* TODO Remove shadow on focus. Use instead border-bottom: 1px solid #aaa !important; To disable with select2 too. */ } textarea.cke_source:focus { diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php index a66727cb3db..7a0d16e4743 100644 --- a/htdocs/theme/md/style.css.php +++ b/htdocs/theme/md/style.css.php @@ -261,8 +261,8 @@ input, input.flat, textarea, textarea.flat, form.flat select, select, select.fla } input:focus, textarea:focus, button:focus, select:focus { - /* box-shadow: 0 0 4px #8091BF; */ - border-bottom: 1px solid #aaa !important; + box-shadow: 0 0 4px #8091BF; + /* TODO Remove shadow on focus. Use instead border-bottom: 1px solid #aaa !important; To disable with select2 too. */ } textarea.cke_source:focus { From 1856b5cfb8790b47472295da1ddacbc62cbacb52 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 8 Jan 2017 11:50:43 +0100 Subject: [PATCH 27/89] Fix filter on status for third parties --- htdocs/societe/list.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/societe/list.php b/htdocs/societe/list.php index 9506c5ad6bd..8982d2db32d 100644 --- a/htdocs/societe/list.php +++ b/htdocs/societe/list.php @@ -226,7 +226,7 @@ if (empty($reshook)) $search_idprof6=''; $search_type=''; $search_type_thirdparty=''; - $search_status=''; + $search_status=-1; $search_stcomm=''; $search_level_from=''; $search_level_to=''; @@ -413,7 +413,7 @@ if ($search_idprof6) $sql.= natural_search("s.idprof6",$search_idprof6); if ($search_type > 0 && in_array($search_type,array('1,3','2,3'))) $sql .= " AND s.client IN (".$db->escape($search_type).")"; if ($search_type > 0 && in_array($search_type,array('4'))) $sql .= " AND s.fournisseur = 1"; if ($search_type == '0') $sql .= " AND s.client = 0 AND s.fournisseur = 0"; -if ($search_status!='') $sql .= " AND s.status = ".$db->escape($search_status); +if ($search_status!='' && $search_status >= 0) $sql .= " AND s.status = ".$db->escape($search_status); if (!empty($conf->barcode->enabled) && $search_barcode) $sql.= " AND s.barcode LIKE '%".$db->escape($search_barcode)."%'"; if ($search_type_thirdparty) $sql .= " AND s.fk_typent IN (".$search_type_thirdparty.')'; if ($search_levels) $sql .= " AND s.fk_prospectlevel IN (".$search_levels.')'; @@ -878,7 +878,7 @@ if (! empty($arrayfields['s.tms']['checked'])) if (! empty($arrayfields['s.status']['checked'])) { print ''; - print $form->selectarray('search_status', array('0'=>$langs->trans('ActivityCeased'),'1'=>$langs->trans('InActivity')),$search_status); + print $form->selectarray('search_status', array('0'=>$langs->trans('ActivityCeased'),'1'=>$langs->trans('InActivity')), $search_status, 1); print ''; } // Action column From dba777c57b1444737a95396aab33ee3e4b35f34f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 8 Jan 2017 12:10:07 +0100 Subject: [PATCH 28/89] Fix missing field alias --- htdocs/societe/soc.php | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/htdocs/societe/soc.php b/htdocs/societe/soc.php index 06413548d9a..020d0aad63f 100644 --- a/htdocs/societe/soc.php +++ b/htdocs/societe/soc.php @@ -290,9 +290,8 @@ if (empty($reshook)) else { $object->name = GETPOST('name', 'alpha'); - $object->name_alias = GETPOST('name_alias'); } - + $object->name_alias = GETPOST('name_alias'); $object->address = GETPOST('address'); $object->zip = GETPOST('zipcode', 'alpha'); $object->town = GETPOST('town', 'alpha'); @@ -920,7 +919,6 @@ else $("#radiocompany").click(function() { $(".individualline").hide(); $("#typent_id").val(0); - $("#name_alias").show(); $("#effectif_id").val(0); $("#TypeName").html(document.formsoc.ThirdPartyName.value); document.formsoc.private.value=0; @@ -928,7 +926,6 @@ else $("#radioprivate").click(function() { $(".individualline").show(); $("#typent_id").val(id_te_private); - $("#name_alias").hide(); $("#effectif_id").val(id_ef15); $("#TypeName").html(document.formsoc.LastName.value); document.formsoc.private.value=1; @@ -970,7 +967,7 @@ else print ''; print ''; print ''; - print ''; + print ''; print ''; if ($modCodeClient->code_auto || $modCodeFournisseur->code_auto) print ''; @@ -982,11 +979,11 @@ else print ''; if ($object->particulier || $private) { - print ''.$langs->trans('LastName','name').''; + print ''.$langs->trans('ThirdPartyName').' / '.$langs->trans('LastName','name').''; } else { - print ''.fieldLabel('ThirdPartyName','name').''; + print ''.fieldLabel('ThirdPartyName','name').''; } print 'global->SOCIETE_USEPREFIX)?' colspan="3"':'').'>'; print ''; From a583fd7a3b43a2d95717dded0b1ee79135a09e7a Mon Sep 17 00:00:00 2001 From: aspangaro Date: Sun, 8 Jan 2017 20:52:42 +0100 Subject: [PATCH 29/89] Fix : Bank - Presentation, no titlefield in a list --- htdocs/compta/bank/index.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/bank/index.php b/htdocs/compta/bank/index.php index 5e3f81bb205..82283547d99 100644 --- a/htdocs/compta/bank/index.php +++ b/htdocs/compta/bank/index.php @@ -449,7 +449,7 @@ foreach ($accounts as $key=>$type) // Ref if (! empty($arrayfields['b.ref']['checked'])) { - print ''.$acc->getNomUrl(1).''; + print ''.$acc->getNomUrl(1).''; if (! $i) $totalarray['nbfield']++; } From 62a668d8997a7eb26375f618f425da73f91c6415 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 9 Jan 2017 10:02:17 +0100 Subject: [PATCH 30/89] Fix https link --- htdocs/main.inc.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index b6a5d904c34..92df8f48f05 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -1025,7 +1025,7 @@ function top_htmlhead($head, $title='', $disablejs=0, $disablehead=0, $arrayofjs print ''."\n"; if (empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER) && ! GETPOST('textbrowser')) print ''."\n"; if (empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER) && ! GETPOST('textbrowser')) print ''."\n"; - if (empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER) && ! GETPOST('textbrowser')) print ''."\n"; + if (empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER) && ! GETPOST('textbrowser')) print ''."\n"; // Displays title $appli=constant('DOL_APPLICATION_TITLE'); From 03aa8343fd1486733b657865b176a506bcd293e7 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 9 Jan 2017 10:21:35 +0100 Subject: [PATCH 31/89] Fix css --- htdocs/cashdesk/tpl/facturation1.tpl.php | 18 +++++++++--------- htdocs/theme/eldy/style.css.php | 2 +- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/htdocs/cashdesk/tpl/facturation1.tpl.php b/htdocs/cashdesk/tpl/facturation1.tpl.php index d20eb4c3299..208727a7644 100644 --- a/htdocs/cashdesk/tpl/facturation1.tpl.php +++ b/htdocs/cashdesk/tpl/facturation1.tpl.php @@ -106,23 +106,23 @@ $langs->load("cashdesk"); trans("VATRate"); ?> - + - + - + - + - + @@ -155,17 +155,17 @@ $langs->load("cashdesk");
trans("Amount"); ?> - +
- + - - +
trans("TotalTicket"); ?>trans("Received"); ?>trans("Change"); ?>
+
diff --git a/htdocs/theme/eldy/style.css.php b/htdocs/theme/eldy/style.css.php index 02460670217..1b5c36bb000 100644 --- a/htdocs/theme/eldy/style.css.php +++ b/htdocs/theme/eldy/style.css.php @@ -4463,7 +4463,7 @@ border-top-right-radius: 6px; color: #fff; text-decoration: none; padding-top: 18px; - : 54px; + padding-left: 54px; font-size: 14px; height: 38px; } From fd008f88b100bcfc6918d3ec2e23969e783503b8 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 9 Jan 2017 10:21:59 +0100 Subject: [PATCH 32/89] Add github tools --- dev/tools/github_authors_peryear.sh | 8 ++++++++ dev/tools/github_commits_perversion.sh | 15 +++++++++++++++ 2 files changed, 23 insertions(+) create mode 100755 dev/tools/github_authors_peryear.sh create mode 100755 dev/tools/github_commits_perversion.sh diff --git a/dev/tools/github_authors_peryear.sh b/dev/tools/github_authors_peryear.sh new file mode 100755 index 00000000000..99b28d4d417 --- /dev/null +++ b/dev/tools/github_authors_peryear.sh @@ -0,0 +1,8 @@ +#!/bin/sh + +FROM=2016-01-01 +TO=2016-12-31 + +echo "git log --since $FROM --before $TO | grep ^Author | sort -u -f -i -b | wc -l" +git log --since $FROM --before $TO | grep ^Author | sort -u -f -i -b | wc -l + diff --git a/dev/tools/github_commits_perversion.sh b/dev/tools/github_commits_perversion.sh new file mode 100755 index 00000000000..40ddafee617 --- /dev/null +++ b/dev/tools/github_commits_perversion.sh @@ -0,0 +1,15 @@ +#/bin/bash +Releases=("3.8" "3.9" "4.0" "5.0", "develop") +Dates=("2010-01-01", "2011-01-01", "2012-01-01", "2013-01-01", "2014-01-01", "2015-01-01", "2016-07-01") +let "counter = 1" + +for i in "${Releases[@]}" +do + git shortlog -s -n --after=${Dates[counter-1]} --before=${Dates[counter]} + echo -n "Total $i: " + git log --pretty=oneline --after=${Dates[counter-1]} --before=${Dates[counter]} | wc -l + echo "=======================" + echo + let "counter +=1" +done + From 8ab0ad3b72732ce53e55756a8b5d2998f9e00e0c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 9 Jan 2017 10:36:24 +0100 Subject: [PATCH 33/89] Fix css --- htdocs/cashdesk/css/style.css | 5 ++++- htdocs/cashdesk/tpl/validation2.tpl.php | 6 +++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/htdocs/cashdesk/css/style.css b/htdocs/cashdesk/css/style.css index e606c8d2807..2931ad7638e 100644 --- a/htdocs/cashdesk/css/style.css +++ b/htdocs/cashdesk/css/style.css @@ -115,7 +115,7 @@ li.menu_choix0 { float: right; } -/* ------------------- R�capitulatif des articles ------------------- */ +/* ------------------- Remind of products ------------------- */ .liste_articles { min-width: 215px; float: right; @@ -212,6 +212,9 @@ p.titre { max-width: 900px; } +.blocksellfinished { + min-width: 215px; +} .titre1 { font-weight: bold; color: #ff9900; diff --git a/htdocs/cashdesk/tpl/validation2.tpl.php b/htdocs/cashdesk/tpl/validation2.tpl.php index b74f5afdd52..844522f55e0 100644 --- a/htdocs/cashdesk/tpl/validation2.tpl.php +++ b/htdocs/cashdesk/tpl/validation2.tpl.php @@ -22,9 +22,10 @@ $langs->load("bills"); ?> -

trans("SellFinished"); ?>


+
+

trans("SellFinished"); ?>