'."\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 '
Id
';
- foreach ($resources as $resource)
- {
- // Iterates on the found IDs
- echo '
'.$resource->attributes().'
';
- }
-}
-echo '
';
-?>
-
\ 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 '
'."\n";
// Substitution array
- if (! empty($this->withsubstit))
+ if (! empty($this->withsubstit)) // Unset of set ->withsubstit=0 to disable this.
{
$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.= "
\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.= '