diff --git a/ChangeLog b/ChangeLog index 69005b0c492..1235a85e097 100644 --- a/ChangeLog +++ b/ChangeLog @@ -11,9 +11,10 @@ NEW: complete_head_from_modules() in ldap_prepare_head() WARNING: -Following changes may create regression for some external modules, but were necessary to make Dolibarr better: +Following changes may create regressions for some external modules, but were necessary to make Dolibarr better: * The methode "cloture" on contact were renamed into "closeAll". - +* The substitution key for reference of object is now __REF__ whatever is the object (it replaces __ORDERREF__, + __PROPALREF__, ...) ***** ChangeLog for 6.0.0 compared to 5.0.* ***** diff --git a/build/makepack-dolibarr.pl b/build/makepack-dolibarr.pl index 80cc9b0856c..e0fa89d924d 100755 --- a/build/makepack-dolibarr.pl +++ b/build/makepack-dolibarr.pl @@ -366,7 +366,9 @@ if ($nboftargetok) { } else # For a maintenance release { - print 'cd ~/git/dolibarr_'.$MAJOR.'.'.$MINOR.'; git log '.$MAJOR.'.'.$MINOR.'.'.($BUILD-1).'.. --no-merges --pretty=short --oneline | sed -e "s/^[0-9a-z]* //" | grep -e \'^FIX\|NEW\' | sort -u | sed \'s/FIXED:/FIX:/g\' | sed \'s/FIXED :/FIX:/g\' | sed \'s/FIX :/FIX:/g\' | sed \'s/FIX /FIX: /g\' | sed \'s/NEW :/NEW:/g\' | sed \'s/NEW /NEW: /g\' > /tmp/aaa'; + #print 'cd ~/git/dolibarr_'.$MAJOR.'.'.$MINOR.'; git log '.$MAJOR.'.'.$MINOR.'.'.($BUILD-1).'.. --no-merges --pretty=short --oneline | sed -e "s/^[0-9a-z]* //" | grep -e \'^FIX\|NEW\' | sort -u | sed \'s/FIXED:/FIX:/g\' | sed \'s/FIXED :/FIX:/g\' | sed \'s/FIX :/FIX:/g\' | sed \'s/FIX /FIX: /g\' | sed \'s/NEW :/NEW:/g\' | sed \'s/NEW /NEW: /g\' > /tmp/aaa'; + print 'cd ~/git/dolibarr_'.$MAJOR.'.'.$MINOR.'; git log '.$MAJOR.'.'.$MINOR.'.'.($BUILD-1).'.. | grep -v "Merge branch" | grep -v "Merge pull" | grep "^ " | sed -e "s/^[0-9a-z]* *//" | grep -e \'^FIX\|NEW\' | sort -u | sed \'s/FIXED:/FIX:/g\' | sed \'s/FIXED :/FIX:/g\' | sed \'s/FIX :/FIX:/g\' | sed \'s/FIX /FIX: /g\' | sed \'s/NEW :/NEW:/g\' | sed \'s/NEW /NEW: /g\' > /tmp/aaa'; + } print "\n"; if (! $ret) diff --git a/dev/examples/code/create_user.php b/dev/examples/code/create_user.php index f745032f575..20173eb914a 100755 --- a/dev/examples/code/create_user.php +++ b/dev/examples/code/create_user.php @@ -60,14 +60,14 @@ $db->begin(); require_once(DOL_DOCUMENT_ROOT."/user/class/user.class.php"); -// Create invoice object +// Create user object $obj = new User($db); //$obj->initAsSpecimen(); $obj->login = 'ABCDEF'; $obj->nom = 'ABCDEF'; -// Create invoice +// Create user $idobject=$obj->create($user); if ($idobject > 0) { diff --git a/dev/examples/code/get_contracts.php b/dev/examples/code/get_contracts.php index 1262fe3eebd..fbe512300e8 100755 --- a/dev/examples/code/get_contracts.php +++ b/dev/examples/code/get_contracts.php @@ -67,7 +67,7 @@ $db->begin(); require_once(DOL_DOCUMENT_ROOT."/contrat/class/contrat.class.php"); -// Create invoice object +// Create contract object $obj = new Contrat($db); $obj->socid=$argv[1]; diff --git a/htdocs/accountancy/admin/accountmodel.php b/htdocs/accountancy/admin/accountmodel.php index cf2b9080ee2..5c17f07183e 100644 --- a/htdocs/accountancy/admin/accountmodel.php +++ b/htdocs/accountancy/admin/accountmodel.php @@ -740,15 +740,6 @@ if ($id) print ''; print ""; - if ($tabname[$id] == MAIN_DB_PREFIX.'c_email_templates') - { - print '* '.$langs->trans("AvailableVariables").": "; - require_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php'; - $tmp=FormMail::getAvailableSubstitKey('formemail'); - print implode(', ', $tmp); - print ''; - } - $colspan=count($fieldlist)+3; if ($id == 4) $colspan++; diff --git a/htdocs/accountancy/admin/export.php b/htdocs/accountancy/admin/export.php index 433448fa688..9a8a659db99 100644 --- a/htdocs/accountancy/admin/export.php +++ b/htdocs/accountancy/admin/export.php @@ -1,6 +1,6 @@ - * Copyright (C) 2013-2015 Alexandre Spangaro + * Copyright (C) 2013-2017 Alexandre Spangaro * Copyright (C) 2014 Florian Henry * Copyright (C) 2014 Marcos GarcĂ­a * Copyright (C) 2014 Juanjo Menent @@ -37,10 +37,10 @@ $langs->load("bills"); $langs->load("admin"); $langs->load("accountancy"); -// Security check -if (empty($user->admin) && empty($user->rights->accounting->chartofaccount)) +// Security access +if (empty($user->rights->accounting->chartofaccount)) { - accessforbidden(); + accessforbidden(); } $action = GETPOST('action', 'alpha'); @@ -53,13 +53,6 @@ $main_option = array ( $model_option = array ( 'ACCOUNTING_EXPORT_SEPARATORCSV', 'ACCOUNTING_EXPORT_DATE' - /* - 'ACCOUNTING_EXPORT_PIECE', - 'ACCOUNTING_EXPORT_GLOBAL_ACCOUNT', - 'ACCOUNTING_EXPORT_LABEL', - 'ACCOUNTING_EXPORT_AMOUNT', - 'ACCOUNTING_EXPORT_DEVISE' - */ ); /* @@ -121,17 +114,13 @@ llxHeader(); $form = new Form($db); -$linkback = '' . $langs->trans("BackToModuleList") . ''; +// $linkback = '' . $langs->trans("BackToModuleList") . ''; print load_fiche_titre($langs->trans('ConfigAccountingExpert'), $linkback, 'title_setup'); -$head = admin_accounting_prepare_head(); - print '
'; print ''; print ''; -dol_fiche_head($head, 'export', $langs->trans("Configuration"), -1, 'cron'); - $var = true; /* @@ -245,8 +234,6 @@ if ($num2) { print "\n"; } -dol_fiche_end(); - print '
'; print '
'; diff --git a/htdocs/accountancy/admin/index.php b/htdocs/accountancy/admin/index.php index b6aceb52ad4..bc078c062c6 100644 --- a/htdocs/accountancy/admin/index.php +++ b/htdocs/accountancy/admin/index.php @@ -37,10 +37,9 @@ $langs->load("compta"); $langs->load("bills"); $langs->load("admin"); $langs->load("accountancy"); -$langs->load("salaries"); -// Security check -if (empty($user->admin)) +// Security access +if (empty($user->rights->accounting->chartofaccount)) { accessforbidden(); } @@ -160,18 +159,13 @@ llxHeader(); $form = new Form($db); -$linkback = '' . $langs->trans("BackToModuleList") . ''; +//$linkback = '' . $langs->trans("BackToModuleList") . ''; print load_fiche_titre($langs->trans('ConfigAccountingExpert'), $linkback, 'title_setup'); -$head = admin_accounting_prepare_head($accounting); - print '
'; print ''; print ''; -dol_fiche_head($head, 'general', $langs->trans("Configuration"), -1, 'cron'); - - // Default mode for calculating turnover (parameter ACCOUNTING_MODE) print ''; @@ -287,18 +281,11 @@ foreach ($list as $key) print '
'; - - - -dol_fiche_end(); - print '
'; print '
'; print '
'; -print '
'.$langs->trans("AccountancySetupDoneFromAccountancyMenu", $langs->transnoentitiesnoconv("MenuFinancial").'-'.$langs->transnoentitiesnoconv("MenuAccountancy")).'
'; - print '
'; print '
'; diff --git a/htdocs/accountancy/expensereport/list.php b/htdocs/accountancy/expensereport/list.php index ee17976ca30..c7ebb5ed5af 100644 --- a/htdocs/accountancy/expensereport/list.php +++ b/htdocs/accountancy/expensereport/list.php @@ -114,11 +114,11 @@ if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x', } // Mass actions -$objectclass='Skeleton'; -$objectlabel='Skeleton'; -$permtoread = $user->rights->accounting->read; -$permtodelete = $user->rights->accounting->delete; -$uploaddir = $conf->accounting->dir_output; +$objectclass='ExpenseReport'; +$objectlabel='ExpenseReport'; +$permtoread = $user->rights->expensereport->read; +$permtodelete = $user->rights->expensereport->delete; +$uploaddir = $conf->expensereport->dir_output; include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; if ($massaction == 'ventil') { diff --git a/htdocs/adherents/cartes/carte.php b/htdocs/adherents/cartes/carte.php index db4c631c0c9..63fd59f01e9 100644 --- a/htdocs/adherents/cartes/carte.php +++ b/htdocs/adherents/cartes/carte.php @@ -46,6 +46,10 @@ $mesg=''; $adherentstatic=new Adherent($db); +$extrafields = new ExtraFields($db); +// fetch optionals attributes and labels +$extralabels = $extrafields->fetch_name_optionals_label('adherent'); + /* * Actions @@ -65,9 +69,14 @@ if ((! empty($foruserid) || ! empty($foruserlogin) || ! empty($mode)) && ! $mesg $sql.= " d.address, d.zip, d.town, d.country, d.birth, d.email, d.photo,"; $sql.= " t.libelle as type,"; $sql.= " c.code as country_code, c.label as country"; + // Add fields from extrafields + foreach ($extrafields->attribute_label as $key => $val) + $sql.=($extrafields->attribute_type[$key] != 'separate' ? ",ef.".$key.' as options_'.$key : ''); $sql.= " FROM ".MAIN_DB_PREFIX."adherent_type as t, ".MAIN_DB_PREFIX."adherent as d"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON d.country = c.rowid"; + if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."adherent_extrafields as ef on (d.rowid = ef.fk_object)"; $sql.= " WHERE d.fk_adherent_type = t.rowid AND d.statut = 1"; + $sql.= " AND d.entity IN (".getEntity('adherent').")"; if (is_numeric($foruserid)) $sql.=" AND d.rowid=".$foruserid; if ($foruserlogin) $sql.=" AND d.login='".$db->escape($foruserlogin)."'"; $sql.= " ORDER BY d.rowid ASC"; @@ -84,9 +93,27 @@ if ((! empty($foruserid) || ! empty($foruserlogin) || ! empty($mode)) && ! $mesg if ($objp->country == '-') $objp->country=''; + $adherentstatic->id=$objp->rowid; $adherentstatic->lastname=$objp->lastname; $adherentstatic->firstname=$objp->firstname; + // format extrafiled so they can be parsed in function complete_substitutions_array + if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) + { + $adherentstatic->array_options = array(); + foreach($extrafields->attribute_label as $key => $val) + { + $tmpkey='options_'.$key; + if (!empty($objp->$tmpkey)) + { + $adherentstatic->array_options[$tmpkey] = $objp->$tmpkey; + } + //if (!empty($objp->$key)) + // $objp->array_options[$tmpkey] = $objp->$key; + //$objp->array_options[$tmpkey] = $extrafields->showOutputField($key, $objp->$tmpkey, '', 1); //$objp->$tmpkey; + } + } + // List of values to scan for a replacement $substitutionarray = array ( '%ID%'=>$objp->rowid, @@ -109,7 +136,7 @@ if ((! empty($foruserid) || ! empty($foruserlogin) || ! empty($mode)) && ! $mesg '%DOL_MAIN_URL_ROOT%'=>DOL_MAIN_URL_ROOT, '%SERVER%'=>"http://".$_SERVER["SERVER_NAME"]."/" ); - complete_substitutions_array($substitutionarray, $langs); + complete_substitutions_array($substitutionarray, $langs, $adherentstatic); // For business cards if (empty($mode) || $mode=='card' || $mode=='cardlogin') @@ -123,7 +150,7 @@ if ((! empty($foruserid) || ! empty($foruserlogin) || ! empty($mode)) && ! $mesg { $nb = $_Avery_Labels[$model]['NX'] * $_Avery_Labels[$model]['NY']; if ($nb <= 0) $nb=1; // Protection to avoid empty page - + for($j=0;$j<$nb;$j++) { $arrayofmembers[]=array( diff --git a/htdocs/admin/agenda.php b/htdocs/admin/agenda.php index fa2c11849fb..50676e4c3af 100644 --- a/htdocs/admin/agenda.php +++ b/htdocs/admin/agenda.php @@ -165,6 +165,8 @@ if (! empty($triggers)) if ($module == 'shipping') $module = 'expedition_bon'; if ($module == 'member') $module = 'adherent'; if ($module == 'project') $module = 'projet'; + if ($module == 'proposal_supplier') $module = 'supplier_proposal'; + //print 'module='.$module.'
'; if (! empty($conf->$module->enabled)) { diff --git a/htdocs/admin/agenda_other.php b/htdocs/admin/agenda_other.php index a5e37f620f7..a999db51857 100644 --- a/htdocs/admin/agenda_other.php +++ b/htdocs/admin/agenda_other.php @@ -373,11 +373,12 @@ $formactions->select_type_actions($conf->global->AGENDA_DEFAULT_FILTER_TYPE, "AG print ''."\n"; // AGENDA_DEFAULT_FILTER_STATUS +// TODO Remove to use the default generic feature print ''."\n"; print ''.$langs->trans("AGENDA_DEFAULT_FILTER_STATUS").''."\n"; print ' '."\n"; print ''."\n"; -$formactions->form_select_status_action('agenda', $conf->global->AGENDA_DEFAULT_FILTER_STATUS, 1, 'AGENDA_DEFAULT_FILTER_STATUS', 1, 2); +$formactions->form_select_status_action('agenda', $conf->global->AGENDA_DEFAULT_FILTER_STATUS, 1, 'AGENDA_DEFAULT_FILTER_STATUS', 1, 2, 'minwidth100'); print ''."\n"; // AGENDA_DEFAULT_VIEW diff --git a/htdocs/admin/dolistore/class/dolistore.class.php b/htdocs/admin/dolistore/class/dolistore.class.php index aff21ce58e8..f437dc66975 100644 --- a/htdocs/admin/dolistore/class/dolistore.class.php +++ b/htdocs/admin/dolistore/class/dolistore.class.php @@ -211,11 +211,11 @@ class Dolistore // add image or default ? if ($product->id_default_image != '') { - $image_url = DOL_URL_ROOT.'/dolistore/ajax/image.php?id_product='.$product->id.'&id_image='.$product->id_default_image; + $image_url = DOL_URL_ROOT.'/admin/dolistore/ajax/image.php?id_product='.$product->id.'&id_image='.$product->id_default_image; $images = ''. ''; } else { - $images = ''; + $images = ''; } // free or pay ? diff --git a/htdocs/admin/dolistore/class/init.php b/htdocs/admin/dolistore/class/init.php deleted file mode 100644 index 4a94e08002c..00000000000 --- a/htdocs/admin/dolistore/class/init.php +++ /dev/null @@ -1,72 +0,0 @@ -CRUD Tutorial - Customer's list - -* @copyright 2007-2013 PrestaShop SA -* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) -* International Registered Trademark & Property of PrestaShop SA -* PrestaShop Webservice Library -* @package PrestaShopWebservice -*/ -// Here we define constants /!\ You need to replace this parameters -//https://dolistorecatalogpublickey1234567@vmdevwww.dolistore.com/api/ -define('DEBUG', true); // Debug mode -define('PS_SHOP_PATH', 'https://www.dolistore.com/'); // Root path of your PrestaShop store -define('PS_WS_AUTH_KEY', 'dolistorecatalogpublickey1234567'); // Auth key (Get it in your Back Office) -require_once('./PSWebServiceLibrary.php'); -// Here we make the WebService Call -try -{ - $webService = new PrestaShopWebservice(PS_SHOP_PATH, PS_WS_AUTH_KEY, DEBUG); - - // Here we set the option array for the Webservice : we want customers resources - $opt['resource'] = 'categories'; - $opt['id'] = '1'; - - // Call - $xml = $webService->get($opt); - // Here we get the elements from children of customers markup "customer" - $resources = $xml->categories->children(); -} -catch (PrestaShopWebserviceException $e) -{ - // Here we are dealing with errors - $trace = $e->getTrace(); - if ($trace[0]['args'][0] == 404) echo 'Bad ID'; - else if ($trace[0]['args'][0] == 401) echo 'Bad auth key'; - else echo 'Other error'; -} -// We set the Title -echo "

Categories's List

"; -echo ''; -// if $resources is set we can lists element in it otherwise do nothing cause there's an error -if (isset($resources)) -{ - echo ''; - foreach ($resources as $resource) - { - // Iterates on the found IDs - echo ''; - } -} -echo '
Id
'.$resource->attributes().'
'; -?> - \ No newline at end of file diff --git a/htdocs/admin/modules.php b/htdocs/admin/modules.php index 6b7d839592c..06f7af5b8d6 100644 --- a/htdocs/admin/modules.php +++ b/htdocs/admin/modules.php @@ -254,7 +254,7 @@ if ($action == 'reset' && $user->admin) $form = new Form($db); -$morejs = array("/admin/dolistore/js/dolistore.js.php"); +//$morejs = array("/admin/dolistore/js/dolistore.js.php"); $morecss = array("/admin/dolistore/css/dolistore.css"); // Set dir where external modules are installed diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php index 4d1f0d571e1..cb6da443404 100644 --- a/htdocs/comm/action/class/actioncomm.class.php +++ b/htdocs/comm/action/class/actioncomm.class.php @@ -851,7 +851,8 @@ class ActionComm extends CommonObject } /** - * Load all objects with filters + * Load all objects with filters. + * WARNING: This make a fetch on all records instead of making one request with a join. * * @param DoliDb $db Database handler * @param int $socid Filter by thirdparty diff --git a/htdocs/comm/mailing/card.php b/htdocs/comm/mailing/card.php index b2b7e9cf5cf..c40192723a8 100644 --- a/htdocs/comm/mailing/card.php +++ b/htdocs/comm/mailing/card.php @@ -1224,7 +1224,6 @@ else // Print mail content print load_fiche_titre($langs->trans("EMail"), $form->textwithpicto($langs->trans("AvailableVariables"), $htmltext, 1, 'help', '', 0, 2, 'emailsubstitionhelp'), 'title_generic'); - dol_fiche_head(null, '', '', -1); print ''; diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php index 18add332294..8fb2a102c22 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -125,7 +125,15 @@ if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'e if (empty($reshook)) { - if ($cancel) $action = ''; + if ($cancel) + { + if (! empty($backtopage)) + { + header("Location: ".$backtopage); + exit; + } + $action=''; + } include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not includ_once @@ -638,16 +646,10 @@ if (empty($reshook)) include DOL_DOCUMENT_ROOT.'/core/actions_printing.inc.php'; - - /* - * Send mail - */ - // Actions to send emails $actiontypecode='AC_OTH_AUTO'; $trigger_name='PROPAL_SENTBYMAIL'; - $paramname='id'; - $mode='emailfromproposal'; + $autocopy='MAIN_MAIL_AUTOCOPY_PROPOSAL_TO'; $trackid='pro'.$object->id; include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php'; @@ -2361,123 +2363,13 @@ if ($action == 'create') print ''; } - /* - * Action presend - */ - if ($action == 'presend') - { - $object->fetch_projet(); + // Presend form + $modelmail='propal_send'; + $defaulttopic='SendPropalRef'; + $diroutput = $conf->propal->dir_output; + $trackid = 'pro'.$object->id; - $ref = dol_sanitizeFileName($object->ref); - include_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php'; - $fileparams = dol_most_recent_file($conf->propal->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->propal->dir_output . '/' . $ref, preg_quote($ref, '/').'[^\-]+'); - $file = $fileparams['fullname']; - } - - print '
'; - print '
'; - print '
'; - print load_fiche_titre($langs->trans('SendPropalByMail')); - - dol_fiche_head(''); - - // Create form object - 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='pro'.$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, 'pro'.$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 = (! empty($conf->global->MAIN_EMAIL_USECCC) ? $conf->global->MAIN_EMAIL_USECCC : false); - if (empty($object->ref_client)) { - $formmail->withtopic = $outputlangs->trans('SendPropalRef', '__PROPREF__'); - } else if (! empty($object->ref_client)) { - $formmail->withtopic = $outputlangs->trans('SendPropalRef', '__PROPREF__ (__REFCLIENT__)'); - } - $formmail->withfile = 2; - $formmail->withbody = 1; - $formmail->withdeliveryreceipt = 1; - $formmail->withcancel = 1; - - // Tableau des substitutions - $formmail->setSubstitFromObject($object); - $formmail->substit['__PROPREF__'] = $object->ref; // For backward compatibility - - // Find the good contact adress - $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_propal_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'] = 'propal_send'; - $formmail->param['models_id']=GETPOST('modelmailselected','int'); - $formmail->param['id'] = $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)); - } - - print $formmail->get_form(); - - dol_fiche_end(); - } + include DOL_DOCUMENT_ROOT.'/core/tpl/card_presend.tpl.php'; } // End of page diff --git a/htdocs/comm/propal/list.php b/htdocs/comm/propal/list.php index e0f1caafc81..41002eb9e71 100644 --- a/htdocs/comm/propal/list.php +++ b/htdocs/comm/propal/list.php @@ -96,8 +96,8 @@ $pagenext = $page + 1; if (! $sortfield) $sortfield='p.ref'; if (! $sortorder) $sortorder='DESC'; -// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context -$contextpage='proposallist'; +// Initialize technical object to manage context to save list fields +$contextpage=GETPOST('contextpage','aZ')?GETPOST('contextpage','aZ'):'proposallist'; // Security check $module='propal'; @@ -413,6 +413,7 @@ if ($resql) print ''; print ''; print ''; + print ''; print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'title_commercial.png', 0, '', '', $limit); diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index 040b1e200d8..4c49cef6820 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -118,16 +118,11 @@ if (empty($reshook)) { if ($cancel) { - if ($action != 'addlink' && $action != 'updateline') + if (! empty($backtopage)) { - $urltogo=$backtopage?$backtopage:dol_buildpath('/commande/list.php',1); - header("Location: ".$urltogo); + header("Location: ".$backtopage); exit; } - if ($id > 0 || ! empty($ref)) { - $ret = $object->fetch($id,$ref); - $object->fetch_thirdparty(); - } $action=''; } @@ -1256,13 +1251,13 @@ if (empty($reshook)) exit(); } - include DOL_DOCUMENT_ROOT.'/core/actions_printing.inc.php'; - + // Actions when printing a doc from card + include DOL_DOCUMENT_ROOT.'/core/actions_printing.inc.php'; // Actions to send emails $trigger_name='ORDER_SENTBYMAIL'; $paramname='id'; - $mode='emailfromorder'; + $autocopy='MAIN_MAIL_AUTOCOPY_ORDER_TO'; // used to know the automatic BCC to add $trackid='ord'.$object->id; include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php'; @@ -2596,134 +2591,13 @@ if ($action == 'create' && $user->rights->commande->creer) print ''; } - /* - * Action presend - */ - if ($action == 'presend') - { - $object->fetch_projet(); + // Presend form + $modelmail='order_send'; + $defaulttopic='SendOrderRef'; + $diroutput = $conf->commande->dir_output; + $trackid = 'ord'.$object->id; - $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'); - } - - // Show email form - - // By default if $action=='presend' - $titreform='SendOrderByMail'; - $topicmail=''; - if (empty($object->ref_client)) { - $topicmail = $outputlangs->trans('SendOrderRef', '__ORDERREF__'); - } else if (! empty($object->ref_client)) { - $topicmail = $outputlangs->trans('SendOrderRef', '__ORDERREF__ (__REFCLIENT__)'); - } - $action='send'; - $modelmail='order_send'; - - // 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 '
'; - print load_fiche_titre($langs->trans($titreform)); - - 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; - $formmail->withtopic = $topicmail; - $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'] = $action; - $formmail->param['models'] = $modelmail; - $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(); - } + include DOL_DOCUMENT_ROOT.'/core/tpl/card_presend.tpl.php'; } } diff --git a/htdocs/commande/list.php b/htdocs/commande/list.php index ea1f93d22fb..927460c511a 100644 --- a/htdocs/commande/list.php +++ b/htdocs/commande/list.php @@ -83,6 +83,7 @@ $result = restrictedArea($user, 'commande', $id,''); $diroutputmassaction=$conf->commande->dir_output . '/temp/massgeneration/'.$user->id; +// Load variable for pagination $limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit; $sortfield = GETPOST("sortfield",'alpha'); $sortorder = GETPOST("sortorder",'alpha'); @@ -206,7 +207,8 @@ if (empty($reshook)) $permtoread = $user->rights->commande->lire; $permtodelete = $user->rights->commande->supprimer; $uploaddir = $conf->commande->dir_output; - include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; + $trigger_name='ORDER_SENTBYMAIL'; + include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; // TODO Move this into mass action include if ($massaction == 'confirm_createbills') { @@ -994,8 +996,6 @@ if ($resql) { $obj = $db->fetch_object($resql); - print ''; - $notshippable=0; $warning = 0; $text_info=''; @@ -1018,6 +1018,8 @@ if ($resql) $generic_commande->total_tva = $obj->total_tva; $generic_commande->total_ttc = $obj->total_ttc; + print ''; + // Ref if (! empty($arrayfields['c.ref']['checked'])) { diff --git a/htdocs/compta/bank/card.php b/htdocs/compta/bank/card.php index 7c94e03e339..b32d4ea938e 100644 --- a/htdocs/compta/bank/card.php +++ b/htdocs/compta/bank/card.php @@ -145,7 +145,7 @@ if ($action == 'add') if ($id > 0) { // Category association - $categories = GETPOST('categories'); + $categories = GETPOST('categories', 'array'); $object->setCategories($categories); $_GET["id"]=$id; // Force chargement page en mode visu @@ -239,7 +239,7 @@ if ($action == 'update') if ($result >= 0) { // Category association - $categories = GETPOST('categories'); + $categories = GETPOST('categories', 'array'); $object->setCategories($categories); $_GET["id"]=$_POST["id"]; // Force chargement page en mode visu diff --git a/htdocs/compta/bank/class/account.class.php b/htdocs/compta/bank/class/account.class.php index a25447da224..b575180feed 100644 --- a/htdocs/compta/bank/class/account.class.php +++ b/htdocs/compta/bank/class/account.class.php @@ -1255,6 +1255,7 @@ class Account extends CommonObject $label = '' . $langs->trans("ShowAccount") . ''; $label .= '
' . $langs->trans('BankAccount') . ': ' . $this->label; $label .= '
' . $langs->trans('AccountNumber') . ': ' . $this->number; + $label .= '
' . $langs->trans("AccountCurrency") . ': ' . $this->currency_code; if (! empty($conf->accounting->enabled)) { include_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index 1e387bcd3fa..a01f2de0f31 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -132,7 +132,15 @@ if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'e if (empty($reshook)) { - if ($cancel) $action=''; + if ($cancel) + { + if (! empty($backtopage)) + { + header("Location: ".$backtopage); + exit; + } + $action=''; + } include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not include_once @@ -1957,20 +1965,17 @@ if (empty($reshook)) exit(); } - - /* - * Send mail - */ + // Actions when printing a doc from card + include DOL_DOCUMENT_ROOT.'/core/actions_printing.inc.php'; // Actions to send emails if (empty($id)) $id=$facid; $trigger_name='BILL_SENTBYMAIL'; $paramname='id'; - $mode='emailfrominvoice'; + $autocopy='MAIN_MAIL_AUTOCOPY_INVOICE_TO'; $trackid='inv'.$object->id; include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php'; - // Actions to build doc $upload_dir = $conf->facture->dir_output; $permissioncreate=$user->rights->facture->creer; @@ -2003,8 +2008,6 @@ if (empty($reshook)) $action = 'edit_extras'; } - include DOL_DOCUMENT_ROOT.'/core/actions_printing.inc.php'; - if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB) && $user->rights->facture->creer) { if ($action == 'addcontact') { $result = $object->fetch($id); @@ -4335,143 +4338,15 @@ else if ($id > 0 || ! empty($ref)) print ''; } - else - { - /* - * Action presend (or prerelance) - */ - $object->fetch_projet(); - // By default if $action=='presend' - $titreform = 'SendBillByMail'; - $topicmail = 'SendBillRef'; - $modelmail = 'facture_send'; + // Presend form + $modelmail='facture_send'; + $defaulttopic='SendBillRef'; + $diroutput = $conf->facture->dir_output; + $trackid = 'inv'.$object->id; - if ($action == 'prerelance') // For backward compatibility - { - $titrefrom = 'SendReminderBillByMail'; - $topicmail = 'SendReminderBillRef'; - $modelmail = 'facture_relance'; - $action = 'relance'; - } else - $action = 'send'; - - $ref = dol_sanitizeFileName($object->ref); - include_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php'; - $fileparams = dol_most_recent_file($conf->facture->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('bills'); - } - - // Build document if it not exists - if (! $file || ! is_readable($file)) { - $result = $object->generateDocument(GETPOST('model','alpha') ? GETPOST('model','alpha') : $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); - if ($result <= 0) { - dol_print_error($db, $object->error, $object->errors); - exit(); - } - $fileparams = dol_most_recent_file($conf->facture->dir_output . '/' . $ref, preg_quote($ref, '/').'[^\-]+'); - $file = $fileparams['fullname']; - } - - print '
'; - print '
'; - print '
'; - print load_fiche_titre($langs->trans($titreform)); - - // Cree l'objet formulaire mail - dol_fiche_head(); - - 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','alpha')?GETPOST('fromtype','alpha'):(!empty($conf->global->MAIN_MAIL_DEFAULT_FROMTYPE)?$conf->global->MAIN_MAIL_DEFAULT_FROMTYPE:'user')); - - if($formmail->fromtype === 'user'){ - $formmail->fromid = $user->id; - - } - $formmail->trackid='inv'.$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, 'inv'.$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; // List suggested for send to - $formmail->withtocc = $liste; // List suggested for CC - $formmail->withtoccc = $conf->global->MAIN_EMAIL_USECCC; - if (empty($object->ref_client)) { - $formmail->withtopic = $outputlangs->transnoentities($topicmail, '__REF__'); - } else if (! empty($object->ref_client)) { - $formmail->withtopic = $outputlangs->transnoentities($topicmail, '__REF__ (__REFCLIENT__)'); - } - - $formmail->withfile = 2; - $formmail->withbody = 1; - $formmail->withdeliveryreceipt = 1; - $formmail->withcancel = 1; - // Tableau des substitutions - $formmail->setSubstitFromObject($object, $outputlangs); - $formmail->substit['__INVREF__'] = $object->ref; - - // Find the good contact adress - $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_facture_external_BILLING')) { // TODO Use code and not label - - require_once DOL_DOCUMENT_ROOT . '/contact/class/contact.class.php'; - - $contactstatic = new Contact($db); - $contactstatic->fetch($contact ['id']); - $custcontact = $contactstatic->getFullName($langs, 1); - } - } - - if (! empty($custcontact)) { - $formmail->substit['__CONTACTCIVNAME__'] = $custcontact; - } - } - - // Tableau des parametres complementaires du post - $formmail->param['action'] = $action; - $formmail->param['models'] = $modelmail; - $formmail->param['models_id']=GETPOST('modelmailselected','int'); - $formmail->param['facid'] = $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)); - } - - print $formmail->get_form(); - - dol_fiche_end(); - } + include DOL_DOCUMENT_ROOT.'/core/tpl/card_presend.tpl.php'; } llxFooter(); diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php index 9dd6b8adbe1..5a59b61e8a3 100644 --- a/htdocs/compta/facture/list.php +++ b/htdocs/compta/facture/list.php @@ -110,8 +110,8 @@ if (! $sortfield) $sortfield='f.datef'; $pageprev = $page - 1; $pagenext = $page + 1; -// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context -$contextpage='invoicelist'; +// Initialize technical object to manage context to save list fields +$contextpage=GETPOST('contextpage','aZ')?GETPOST('contextpage','aZ'):'invoicelist'; // Security check $fieldid = (! empty($ref)?'facnumber':'rowid'); @@ -606,6 +606,7 @@ if ($resql) print ''; print ''; print ''; + print ''; print_barre_liste($langs->trans('BillsCustomers').' '.($socid?' '.$soc->name:''), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'title_accountancy.png', 0, '', '', $limit); diff --git a/htdocs/contact/card.php b/htdocs/contact/card.php index 7dffd99f8bf..2d6f728b502 100644 --- a/htdocs/contact/card.php +++ b/htdocs/contact/card.php @@ -224,7 +224,7 @@ if (empty($reshook)) $action = 'create'; } else { // Categories association - $contcats = GETPOST( 'contcats', 'array' ); + $contcats = GETPOST( 'contcats', 'array'); $object->setCategories($contcats); } } @@ -383,7 +383,7 @@ if (empty($reshook)) $db->query( $sql ); // Then we add the associated categories - $categories = GETPOST( 'contcats', 'array' ); + $categories = GETPOST( 'contcats', 'array'); $object->setCategories($categories); $object->old_lastname=''; diff --git a/htdocs/contrat/card.php b/htdocs/contrat/card.php index 0e8722d20b8..16c843466f9 100644 --- a/htdocs/contrat/card.php +++ b/htdocs/contrat/card.php @@ -2242,7 +2242,6 @@ else $formmail->withdeliveryreceipt = 1; $formmail->withcancel = 1; // Array of substitutions - $formmail->withsubstit='AvailableVariables'; $formmail->setSubstitFromObject($object); $datenextexpiration=''; foreach($object->lines as $line) diff --git a/htdocs/contrat/list.php b/htdocs/contrat/list.php index 76b710bc5c8..cfc4d07ab1d 100644 --- a/htdocs/contrat/list.php +++ b/htdocs/contrat/list.php @@ -53,6 +53,7 @@ $search_state=trim(GETPOST("search_state")); $search_country=GETPOST("search_country",'int'); $search_type_thirdparty=GETPOST("search_type_thirdparty",'int'); $search_contract=GETPOST('search_contract'); +$search_ref_customer=GETPOST('search_ref_customer','alpha'); $search_ref_supplier=GETPOST('search_ref_supplier','alpha'); $sall=GETPOST('sall', 'alphanohtml'); $search_status=GETPOST('search_status'); @@ -161,6 +162,7 @@ if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x', $search_type=''; $search_country=''; $search_contract=""; + $search_ref_customer=""; $search_ref_supplier=""; $search_user=''; $search_sale=''; @@ -245,6 +247,7 @@ else if ($year > 0) } if ($search_name) $sql .= natural_search('s.nom', $search_name); if ($search_contract) $sql .= natural_search(array('c.rowid', 'c.ref'), $search_contract); +if (!empty($search_ref_customer)) $sql .= natural_search(array('c.ref_customer'), $search_ref_customer); if (!empty($search_ref_supplier)) $sql .= natural_search(array('c.ref_supplier'), $search_ref_supplier); if ($search_sale > 0) { @@ -431,13 +434,13 @@ if ($resql) if (! empty($arrayfields['c.ref_customer']['checked'])) { print ''; } if (! empty($arrayfields['c.ref_supplier']['checked'])) { print ''; } if (! empty($arrayfields['s.nom']['checked'])) diff --git a/htdocs/contrat/services.php b/htdocs/contrat/services.php index e5a5c21c00b..9d1db86ded6 100644 --- a/htdocs/contrat/services.php +++ b/htdocs/contrat/services.php @@ -285,7 +285,7 @@ if ($num == 1 && ! empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && llxHeader(null, $langs->trans("Services")); $param=''; -if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage; +if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.urlencode($contextpage); if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit; if ($search_contract) $param.='&search_contract='.urlencode($search_contract); if ($search_name) $param.='&search_name='.urlencode($search_name); @@ -326,6 +326,7 @@ print ''; print ''; print ''; print ''; +print ''; $title=$langs->trans("ListOfServices"); if ($mode == "0") $title=$langs->trans("ListOfInactiveServices"); // Must use == "0" diff --git a/htdocs/core/actions_fetchobject.inc.php b/htdocs/core/actions_fetchobject.inc.php index 7c25fbe7981..6a2d7196d0f 100644 --- a/htdocs/core/actions_fetchobject.inc.php +++ b/htdocs/core/actions_fetchobject.inc.php @@ -28,7 +28,7 @@ // $cancel must be defined // $id or $ref must be defined (object is loaded in this file with fetch) -if (($id > 0 || (! empty($ref) && ! in_array($action, array('create', 'createtask', 'add')))) && empty($cancel)) +if (($id > 0 || (! empty($ref) && ! in_array($action, array('create', 'createtask', 'add')))) && (empty($cancel) || $id > 0)) { $ret = $object->fetch($id, $ref); if ($ret > 0) diff --git a/htdocs/core/actions_massactions.inc.php b/htdocs/core/actions_massactions.inc.php index 4c3fe6af317..b17c047860a 100644 --- a/htdocs/core/actions_massactions.inc.php +++ b/htdocs/core/actions_massactions.inc.php @@ -64,36 +64,63 @@ if (! $error && $massaction == 'confirm_presend') $langs->load("mails"); include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; - if (!$error && !isset($user->email)) - { - $error++; - setEventMessages($langs->trans("NoSenderEmailDefined"), null, 'warnings'); - } + $listofobjectid=array(); + $listofobjectthirdparties=array(); + $listofobjectref=array(); if (! $error) { $thirdparty=new Societe($db); + if ($objecttmp->element == 'expensereport') $thirdparty=new User($db); + $objecttmp=new $objectclass($db); - $listofobjectid=array(); - $listofobjectthirdparties=array(); - $listofobjectref=array(); foreach($toselect as $toselectid) { - $objecttmp=new $objectclass($db); // must create new instance because instance is saved into $listofobjectref array for future use + $objecttmp=new $objectclass($db); // we must create new instance because instance is saved into $listofobjectref array for future use $result=$objecttmp->fetch($toselectid); if ($result > 0) { $listofobjectid[$toselectid]=$toselectid; $thirdpartyid=$objecttmp->fk_soc?$objecttmp->fk_soc:$objecttmp->socid; if ($objecttmp->element == 'societe') $thirdpartyid=$objecttmp->id; + if ($objecttmp->element == 'expensereport') $thirdpartyid=$objecttmp->fk_user_author; $listofobjectthirdparties[$thirdpartyid]=$thirdpartyid; $listofobjectref[$thirdpartyid][$toselectid]=$objecttmp; } } - //var_dump($listofobjectthirdparties);exit; + } + // Check mandatory parameters + if (empty($user->email)) + { + $error++; + setEventMessages($langs->trans("NoSenderEmailDefined"), null, 'warnings'); + $massaction='presend'; + } - // Loop on each thirdparty + $receiver=$_POST['receiver']; + if (! is_array($receiver)) + { + if (empty($receiver) || $receiver == '-1') $receiver=array(); + else $receiver=array($receiver); + } + if (count($receiver) == 0 && count($listofobjectthirdparties) == 1) // if only one recipient, receiver is mandatory + { + $error++; + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Recipient")), null, 'warnings'); + $massaction='presend'; + } + + if (! GETPOST('subject','none')) + { + $error++; + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("MailTopic")), null, 'warnings'); + $massaction='presend'; + } + + // Loop on each recipient/thirdparty + if (! $error) + { foreach ($listofobjectthirdparties as $thirdpartyid) { $result = $thirdparty->fetch($thirdpartyid); @@ -109,12 +136,6 @@ if (! $error && $massaction == 'confirm_presend') $sendtoid = array(); // Define $sendto - $receiver=$_POST['receiver']; - if (! is_array($receiver)) - { - if ($receiver == '-1') $receiver=array(); - else $receiver=array($receiver); - } $tmparray=array(); if (trim($_POST['sendto'])) { @@ -203,8 +224,17 @@ if (! $error && $massaction == 'confirm_presend') // Test recipient if (empty($sendto)) // For the case, no recipient were set (multi thirdparties send) { - $object->fetch_thirdparty(); - $sendto = $object->thirdparty->email; + if ($object->element == 'expensereport') + { + $fuser = new User($db); + $fuser->fetch($object->fk_user_author); + $sendto = $fuser->email; + } + else + { + $object->fetch_thirdparty(); + $sendto = $object->thirdparty->email; + } } if (empty($sendto)) @@ -357,18 +387,32 @@ if (! $error && $massaction == 'confirm_presend') $object->fk_element = $objid; $object->elementtype = $object->element; - // Appel des triggers - include_once(DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php"); - $interface=new Interfaces($db); - $result=$interface->run_triggers('BILL_SENTBYMAIL',$object,$user,$langs,$conf); - if ($result < 0) { $error++; $errors=$interface->errors; } - // Fin appel triggers + $triggername = strtoupper(get_class($object)) .'_SENTBYMAIL'; + if ($triggername == 'SOCIETE_SENTBYMAIL') $triggername = 'COMPANY_SENTBYEMAIL'; + if ($triggername == 'CONTRAT_SENTBYMAIL') $triggername = 'CONTRACT_SENTBYEMAIL'; + if ($triggername == 'COMMANDE_SENTBYMAIL') $triggername = 'ORDER_SENTBYEMAIL'; + if ($triggername == 'FACTURE_SENTBYMAIL') $triggername = 'BILL_SENTBYEMAIL'; + if ($triggername == 'EXPEDITION_SENTBYMAIL') $triggername = 'SHIPPING_SENTBYEMAIL'; + if ($triggername == 'COMMANDEFOURNISSEUR_SENTBYMAIL') $triggername = 'ORDER_SUPPLIER_SENTBYMAIL'; + if ($triggername == 'FACTUREFOURNISSEUR_SENTBYMAIL') $triggername = 'BILL_SUPPLIER_SENTBYEMAIL'; + if ($triggername == 'SUPPLIERPROPOSAL_SENTBYMAIL') $triggername = 'PROPOSAL_SUPPLIER_SENTBYEMAIL'; - if ($error) + if (! empty($trigger_name)) { - setEventMessages($db->lasterror(), $errors, 'errors'); - dol_syslog("Error in trigger BILL_SENTBYMAIL ".$db->lasterror(), LOG_ERR); + // Appel des triggers + include_once(DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php"); + $interface=new Interfaces($db); + $result=$interface->run_triggers($trigger_name, $object, $user, $langs, $conf); + if ($result < 0) { $error++; $errors=$interface->errors; } + // Fin appel triggers + + if ($error) + { + setEventMessages($db->lasterror(), $errors, 'errors'); + dol_syslog("Error in trigger ".$trigger_name.' '.$db->lasterror(), LOG_ERR); + } } + $nbsent++; } } @@ -407,10 +451,10 @@ if (! $error && $massaction == 'confirm_presend') //setEventMessages($langs->trans("EMailSentToNRecipients", 0), null, 'warnings'); // May be object has no generated PDF file setEventMessages($resaction, null, 'warnings'); } - } - $action='list'; - $massaction=''; + $action='list'; + $massaction=''; + } } if (! $error && $massaction == "builddoc" && $permtoread && ! GETPOST('button_search')) @@ -592,7 +636,7 @@ if ($action == 'remove_file') $action=''; } -// Validate records +// Validate records if (! $error && $massaction == 'validate' && $permtocreate) { if ($object->element == 'invoice_supplier' && ! empty($conf->stock->enabled) && ! empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_BILL)) @@ -664,8 +708,19 @@ if (! $error && $massaction == 'delete' && $permtodelete) $result=$objecttmp->fetch($toselectid); if ($result > 0) { + // Refuse deletion for some status ? + /* + if ($objectclass == 'Facture' && $objecttmp->status == Facture::STATUS_DRAFT) + { + $langs->load("errors"); + $nbignored++; + $resaction.='
'.$langs->trans('ErrorOnlyDraftStatusCanBeDeletedInMassAction',$object->ref).'

'; + continue; + }*/ + if (in_array($objecttmp->element, array('societe','member'))) $result = $objecttmp->delete($objecttmp->id, $user, 1); else $result = $objecttmp->delete($user); + if ($result <= 0) { setEventMessages($objecttmp->error, $objecttmp->errors, 'errors'); diff --git a/htdocs/core/actions_sendmails.inc.php b/htdocs/core/actions_sendmails.inc.php index 18c951c7763..144cba07779 100644 --- a/htdocs/core/actions_sendmails.inc.php +++ b/htdocs/core/actions_sendmails.inc.php @@ -24,7 +24,7 @@ // $mysoc must be defined // $id must be defined // $paramname must be defined -// $mode must be defined +// $mode must be defined (used to know the automatic BCC to add) // $trigger_name must be set (can be '') // $actiontypecode can be set // $object and $uobject may be defined @@ -268,12 +268,12 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO $message=preg_replace('/()/', '\1'.$urlwithroot.'/viewimage.php\2modulepart=medias\3file=\4\5', $message); $sendtobcc= GETPOST('sendtoccc'); - if ($mode == 'emailfromproposal') $sendtobcc .= (empty($conf->global->MAIN_MAIL_AUTOCOPY_PROPOSAL_TO) ? '' : (($sendtobcc?", ":"").$conf->global->MAIN_MAIL_AUTOCOPY_PROPOSAL_TO)); - if ($mode == 'emailfromorder') $sendtobcc .= (empty($conf->global->MAIN_MAIL_AUTOCOPY_ORDER_TO) ? '' : (($sendtobcc?", ":"").$conf->global->MAIN_MAIL_AUTOCOPY_ORDER_TO)); - if ($mode == 'emailfrominvoice') $sendtobcc .= (empty($conf->global->MAIN_MAIL_AUTOCOPY_INVOICE_TO) ? '' : (($sendtobcc?", ":"").$conf->global->MAIN_MAIL_AUTOCOPY_INVOICE_TO)); - if ($mode == 'emailfromsupplierproposal') $sendtobcc .= (empty($conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_PROPOSAL_TO) ? '' : (($sendtobcc?", ":"").$conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_PROPOSAL_TO)); - if ($mode == 'emailfromsupplierorder') $sendtobcc .= (empty($conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_ORDER_TO) ? '' : (($sendtobcc?", ":"").$conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_ORDER_TO)); - if ($mode == 'emailfromsupplierinvoice') $sendtobcc .= (empty($conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_INVOICE_TO) ? '' : (($sendtobcc?", ":"").$conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_INVOICE_TO)); + // Autocomplete the $sendtobcc + // $autocopy can be MAIN_MAIL_AUTOCOPY_PROPOSAL_TO, MAIN_MAIL_AUTOCOPY_ORDER_TO, MAIN_MAIL_AUTOCOPY_INVOICE_TO, MAIN_MAIL_AUTOCOPY_SUPPLIER_PROPOSAL_TO... + if (! empty($autocopy)) + { + $sendtobcc .= (empty($conf->global->$autocopy) ? '' : (($sendtobcc?", ":"").$conf->global->$autocopy)); + } $deliveryreceipt = $_POST['deliveryreceipt']; diff --git a/htdocs/core/boxes/box_activity.php b/htdocs/core/boxes/box_activity.php index 02b1d1880c8..71a9a4e3125 100644 --- a/htdocs/core/boxes/box_activity.php +++ b/htdocs/core/boxes/box_activity.php @@ -77,7 +77,6 @@ class box_activity extends ModeleBoxes include_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; - $totalMnt = 0; $totalnb = 0; $line = 0; $cachetime = 3600; @@ -95,8 +94,6 @@ class box_activity extends ModeleBoxes // compute the year limit to show $tmpdate= dol_time_plus_duree(dol_now(), -1*$nbofperiod, "m"); - $cumuldata = array(); - // list the summary of the propals if (! empty($conf->propal->enabled) && $user->rights->propale->lire) @@ -146,11 +143,10 @@ class box_activity extends ModeleBoxes $data = dol_readcachefile($cachedir, $filename); } - $cumuldata=array_merge($cumuldata, $data); if (! empty($data)) { $j=0; - while ($line < count($cumuldata)) + while ($j < count($data)) { $this->info_box_contents[$line][0] = array( 'td' => 'align="left" width="16"', @@ -176,7 +172,6 @@ class box_activity extends ModeleBoxes 'td' => 'class="right"', 'text' => price($data[$j]->Mnttot,1,$langs,0,0,-1,$conf->currency), ); - $totalMnt += $data[$j]->Mnttot; $this->info_box_contents[$line][4] = array( 'td' => 'align="right" width="18"', 'text' => $propalstatic->LibStatut($data[$j]->fk_statut,3), @@ -231,10 +226,9 @@ class box_activity extends ModeleBoxes $data = dol_readcachefile($cachedir, $filename); } - $cumuldata=array_merge($cumuldata, $data); if (! empty($data)) { $j=0; - while ($line < count($cumuldata)) { + while ($j < count($data)) { $this->info_box_contents[$line][0] = array( 'td' => 'align="left" width="16"', 'url' => DOL_URL_ROOT."/commande/list.php?mainmenu=commercial&leftmenu=orders&viewstatut=".$data[$j]->fk_statut, @@ -259,7 +253,6 @@ class box_activity extends ModeleBoxes 'td' => 'class="right"', 'text' => price($data[$j]->Mnttot,1,$langs,0,0,-1,$conf->currency), ); - $totalMnt += $data[$j]->Mnttot; $this->info_box_contents[$line][4] = array( 'td' => 'align="right" width="18"', 'text' => $commandestatic->LibStatut($data[$j]->fk_statut,0,3), @@ -290,11 +283,11 @@ class box_activity extends ModeleBoxes $sql.= " FROM (".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture as f"; if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql.= ")"; - $sql.= " WHERE f.entity = ".$conf->entity; + $sql.= " WHERE f.entity IN (".getEntity('facture').')'; if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; if($user->societe_id) $sql.= " AND s.rowid = ".$user->societe_id; $sql.= " AND f.fk_soc = s.rowid"; - $sql.= " AND f.datef >= '".$db->idate($tmpdate)."' AND paye=1"; + $sql.= " AND f.datef >= '".$db->idate($tmpdate)."' AND f.paye=1"; $sql.= " GROUP BY f.fk_statut"; $sql.= " ORDER BY f.fk_statut DESC"; @@ -317,10 +310,9 @@ class box_activity extends ModeleBoxes $data = dol_readcachefile($cachedir, $filename); } - $cumuldata=array_merge($cumuldata, $data); if (! empty($data)) { $j=0; - while ($line < count($cumuldata)) { + while ($j < count($data)) { $billurl="search_status=2&paye=1&year=".$data[$j]->annee; $this->info_box_contents[$line][0] = array( 'td' => 'align="left" width="16"', @@ -347,10 +339,8 @@ class box_activity extends ModeleBoxes ); // We add only for the current year - if ($data[$j]->annee == date("Y")) { - $totalnb += $data[$j]->nb; - $totalMnt += $data[$j]->Mnttot; - } + $totalnb += $data[$j]->nb; + $this->info_box_contents[$line][4] = array( 'td' => 'align="right" width="18"', 'text' => $facturestatic->LibStatut(1,$data[$j]->fk_statut,3), @@ -371,12 +361,13 @@ class box_activity extends ModeleBoxes $refresh = dol_cache_refresh($cachedir, $filename, $cachetime); + $data = array(); if ($refresh) { $sql = "SELECT f.fk_statut, SUM(f.total_ttc) as Mnttot, COUNT(*) as nb"; $sql.= " FROM ".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture as f"; - $sql.= " WHERE f.entity = ".$conf->entity; + $sql.= " WHERE f.entity IN (".getEntity('facture').')'; $sql.= " AND f.fk_soc = s.rowid"; - $sql.= " AND paye=0"; + $sql.= " AND f.datef >= '".$db->idate($tmpdate)."' AND f.paye=0"; $sql.= " GROUP BY f.fk_statut"; $sql.= " ORDER BY f.fk_statut DESC"; @@ -399,11 +390,11 @@ class box_activity extends ModeleBoxes $data = dol_readcachefile($cachedir, $filename); } - $cumuldata=array_merge($cumuldata, $data); if (! empty($data)) { - $j=0; + $alreadypaid=-1; - while ($line < count($cumuldata)) { + $j=0; + while ($j < count($data)) { $billurl="search_status=".$data[$j]->fk_statut."&paye=0"; $this->info_box_contents[$line][0] = array( 'td' => 'align="left" width="16"', @@ -428,10 +419,9 @@ class box_activity extends ModeleBoxes 'td' => 'class="right"', 'text' => price($data[$j]->Mnttot,1,$langs,0,0,-1,$conf->currency), ); - $totalMnt += $objp->Mnttot; $this->info_box_contents[$line][4] = array( 'td' => 'align="right" width="18"', - 'text' => $facturestatic->LibStatut(0,$data[$j]->fk_statut,3), + 'text' => $facturestatic->LibStatut(0,$data[$j]->fk_statut,3, $alreadypaid), ); $line++; $j++; @@ -441,11 +431,6 @@ class box_activity extends ModeleBoxes 'td' => 'align="center"', 'text'=>$langs->trans("NoRecordedInvoices"), ); - } else { - $this->info_box_contents[0][0] = array( - 'td' => '', - 'maxlength'=>500, 'text' => ($db->error().' sql='.$sql), - ); } } diff --git a/htdocs/core/class/commoninvoice.class.php b/htdocs/core/class/commoninvoice.class.php index 4b6d70b1366..6bbde52cb58 100644 --- a/htdocs/core/class/commoninvoice.class.php +++ b/htdocs/core/class/commoninvoice.class.php @@ -51,7 +51,7 @@ abstract class CommonInvoice extends CommonObject const TYPE_DEPOSIT = 3; /** - * Proforma invoice. + * Proforma invoice. * @deprectad Remove this. A "proforma invoice" is an order with a look of invoice, not an invoice ! */ const TYPE_PROFORMA = 4; @@ -89,7 +89,7 @@ abstract class CommonInvoice extends CommonObject */ const STATUS_ABANDONED = 3; - + /** * Return remain amount to pay. Property ->id and ->total_ttc must be set. * This does not include open direct debit requests. @@ -141,7 +141,7 @@ abstract class CommonInvoice extends CommonObject return -1; } } - + /** * Return amount (with tax) of all deposits invoices used by invoice. * Should always be empty, except if option FACTURE_DEPOSITS_ARE_JUST_PAYMENTS is on (not recommended). @@ -154,11 +154,11 @@ abstract class CommonInvoice extends CommonObject if ($this->element == 'facture_fourn' || $this->element == 'invoice_supplier') { // TODO - return 0; + return 0; } - + require_once DOL_DOCUMENT_ROOT.'/core/class/discount.class.php'; - + $discountstatic=new DiscountAbsolute($this->db); $result=$discountstatic->getSumDepositsUsed($this, $multicurrency); if ($result >= 0) @@ -185,9 +185,9 @@ abstract class CommonInvoice extends CommonObject // TODO return 0; } - + require_once DOL_DOCUMENT_ROOT.'/core/class/discount.class.php'; - + $discountstatic=new DiscountAbsolute($this->db); $result=$discountstatic->getSumCreditNotesUsed($this, $multicurrency); if ($result >= 0) @@ -200,7 +200,7 @@ abstract class CommonInvoice extends CommonObject return -1; } } - + /** * Renvoie tableau des ids de facture avoir issus de la facture * @@ -309,7 +309,7 @@ abstract class CommonInvoice extends CommonObject * @param int $paye Status field paye * @param int $status Id status * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=short label + picto, 6=long label + picto - * @param integer $alreadypaid 0=No payment already done, >0=Some payments were already done (we recommand to put here amount payed if you have it, 1 otherwise) + * @param integer $alreadypaid 0=No payment already done, >0=Some payments were already done (we recommand to put here amount payed if you have it, -1 otherwise) * @param int $type Type invoice * @return string Libelle du statut */ @@ -418,7 +418,7 @@ abstract class CommonInvoice extends CommonObject if ($status == 0) return ''.$langs->trans('Bill'.$prefix.'StatusDraft').' '.img_picto($langs->trans('BillStatusDraft'),'statut0'); if (($status == 3 || $status == 2) && $alreadypaid <= 0) return ''.$langs->trans('Bill'.$prefix.'StatusCanceled').' '.img_picto($langs->trans('BillStatusCanceled'),'statut5'); if (($status == 3 || $status == 2) && $alreadypaid > 0) return ''.$langs->trans('Bill'.$prefix.'StatusClosedPaidPartially').' '.img_picto($langs->trans('BillStatusClosedPaidPartially'),'statut7'); - if ($alreadypaid <= 0) + if ($alreadypaid <= 0) { if ($type == self::TYPE_CREDIT_NOTE) return ''.$langs->trans('Bill'.$prefix.'StatusNotRefunded').' '.img_picto($langs->trans('StatusNotRefunded'),'statut1'); return ''.$langs->trans('Bill'.$prefix.'StatusNotPaid').' '.img_picto($langs->trans('BillStatusNotPaid'),'statut1'); @@ -497,13 +497,13 @@ abstract class CommonInvoice extends CommonObject } elseif($cdr_type == 2 && !empty($cdr_nbjour)) // Application de la règle, le N du mois courant ou suivant { - + $date_piece = dol_mktime(0,0,0,date('m', $this->date),date('d', $this->date),date('Y', $this->date)); // Sans les heures minutes et secondes $date_lim_current = dol_mktime(0,0,0,date('m', $this->date),$cdr_nbjour,date('Y', $this->date)); // Sans les heures minutes et secondes $date_lim_next = strtotime(date('Y-m-d', $date_lim_current).' +1month'); - + $diff = $date_piece - $date_lim_current; - + if($diff < 0) $datelim = $date_lim_current; else $datelim = $date_lim_next; diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index e37932ea635..0260effebc6 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -3392,7 +3392,7 @@ class Form require_once DOL_DOCUMENT_ROOT .'/compta/bank/class/account.class.php'; $bankstatic=new Account($this->db); $bankstatic->fetch($selected); - print $this->textwithpicto($bankstatic->getNomUrl(1),$langs->trans("AccountCurrency").' '.$bankstatic->currency_code); + print $bankstatic->getNomUrl(1); } else { print " "; } diff --git a/htdocs/core/class/html.formactions.class.php b/htdocs/core/class/html.formactions.class.php index 579520f7647..f09dab9be38 100644 --- a/htdocs/core/class/html.formactions.class.php +++ b/htdocs/core/class/html.formactions.class.php @@ -250,12 +250,10 @@ class FormActions } print ''; print ''; print '
'; - print ''; + print ''; print ''; - print ''; + print ''; print ''; - if (! empty($action->author->id)) + if (! empty($action->userownerid)) { - $userstatic->id = $action->author->id; - $userstatic->firstname = $action->author->firstname; - $userstatic->lastname = $action->author->lastname; - print $userstatic->getNomUrl(1, '', 0, 0, 16, 0, '', ''); + $userstatic->fetch($action->userownerid); // TODO Introduce a cache on users fetched + print $userstatic->getNomUrl(-1, '', 0, 0, 16, 0, '', ''); } print ''; diff --git a/htdocs/core/class/html.formmail.class.php b/htdocs/core/class/html.formmail.class.php index daf2f9b819f..366247560ac 100644 --- a/htdocs/core/class/html.formmail.class.php +++ b/htdocs/core/class/html.formmail.class.php @@ -343,7 +343,7 @@ class FormMail extends Form if (count($modelmail_array)>0) { $out.= '
'."\n"; - $out.= ''.$langs->trans('SelectMailModel').': '.$this->selectarray('modelmailselected', $modelmail_array, 0, 1); + $out.= ''.$langs->trans('SelectMailModel').': '.$this->selectarray('modelmailselected', $modelmail_array, 0, 1, 0, 0, '', 0, 0, 0, '', 'minwidth100'); if ($user->admin) $out.= info_admin($langs->trans("YouCanChangeValuesForThisListFrom", $langs->transnoentitiesnoconv('Setup').' - '.$langs->transnoentitiesnoconv('EMails')),1); $out.= '   '; $out.= ''; @@ -370,7 +370,7 @@ class FormMail extends Form $out.= ''."\n"; // Substitution array - if (! empty($this->withsubstit)) + if (! empty($this->withsubstit)) // Unset of set ->withsubstit=0 to disable this. { $out.= '\n"; //$out.=''; } @@ -746,24 +746,31 @@ class FormMail extends Form } // Complete substitution array - if (! empty($conf->paypal->enabled) && ! empty($conf->global->PAYPAL_ADD_PAYMENT_URL)) + $paymenturl=''; + if (! empty($conf->global->PAYMENT_ADD_PAYMENT_URL) // Option to enable to add online link into __PERSONALIZED__ + || (! empty($conf->paypal->enabled) && ! empty($conf->global->PAYPAL_ADD_PAYMENT_URL)) + ) { - require_once DOL_DOCUMENT_ROOT.'/paypal/lib/paypal.lib.php'; - - $langs->load('paypal'); - - // Set the paypal message and url link into __PERSONALIZED__ key - if ($this->param["models"]=='order_send') + if (empty($this->substit['__REF__'])) { - $url=getPaypalPaymentUrl(0,'order',$this->substit['__ORDERREF__']?$this->substit['__ORDERREF__']:$this->substit['__REF__']); - $this->substit['__PERSONALIZED__']=str_replace('\n',"\n",$langs->transnoentitiesnoconv("PredefinedMailContentLink",$url)); + //$paymenturl='LinkToPayOnlineNotAvailableInThisContext'; + $paymenturl=''; } - if ($this->param["models"]=='facture_send') + else { - $url=getPaypalPaymentUrl(0,'invoice',$this->substit['__REF__']); - $this->substit['__PERSONALIZED__']=str_replace('\n',"\n",$langs->transnoentitiesnoconv("PredefinedMailContentLink",$url)); + // Set the online payment message and url link into __PERSONALIZED__ key + require_once DOL_DOCUMENT_ROOT.'/core/lib/payments.lib.php'; + $langs->load('paypal'); + $typeforonlinepayment='free'; + if ($this->param["models"]=='order_send') $typeforonlinepayment='order'; // TODO use detection on something else than template + if ($this->param["models"]=='facture_send') $typeforonlinepayment='invoice'; // TODO use detection on something else than template + $url=getOnlinePaymentUrl(0, $typeforonlinepayment, $this->substit['__REF__']); + //$paymenturl=str_replace('\n',"\n",$langs->transnoentitiesnoconv("PredefinedMailContentLink",$url)); + $paymenturl=$url; } } + $this->substit['__PERSONALIZED__']=$paymenturl; + $this->substit['__ONLINE_PAYMENT_URL__']='YY'.$paymenturl; //Add lines substitution key from each line $lines = ''; @@ -849,7 +856,7 @@ class FormMail extends Form { $out.= '
'; //$out.='
'; @@ -380,7 +380,7 @@ class FormMail extends Form $help.=$key.' -> '.$langs->trans(dol_string_nohtmltag($val)).'
'; } if (is_numeric($this->withsubstit)) $out.= $form->textwithpicto($langs->trans("EMailTestSubstitutionReplacedByGenericValues"), $help, 1, 'help', '', 0, 2, 'substittooltip'); // Old usage - else $out.= $form->textwithpicto($langs->trans($this->withsubstit), $help, 1, 'help', '', 0, 2, 'substittooltip'); // New usage + else $out.= $form->textwithpicto($langs->trans('AvailableVariables'), $help, 1, 'help', '', 0, 2, 'substittooltip'); // New usage $out.= "