';
- print '| '.$langs->trans("LatestCustomerTemplateInvoices", ($num <= $MAXLIST ? "" : $MAXLIST)).' | '.$langs->trans("AllCustomerTemplateInvoices").''.$num.' | ';
+ print ' | ';
print ' ';
}
diff --git a/htdocs/compta/facture/invoicetemplate_list.php b/htdocs/compta/facture/invoicetemplate_list.php
index 370bfe9a8b9..c8b27fa4744 100644
--- a/htdocs/compta/facture/invoicetemplate_list.php
+++ b/htdocs/compta/facture/invoicetemplate_list.php
@@ -33,10 +33,7 @@ require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture-rec.class.php';
require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
-if (!empty($conf->projet->enabled)) {
- require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
- //require_once DOL_DOCUMENT_ROOT . '/core/class/html.formprojet.class.php';
-}
+require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/invoice.lib.php';
@@ -54,6 +51,8 @@ $cancel = GETPOST('cancel', 'alpha');
$toselect = GETPOST('toselect', 'array');
$contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'invoicetemplatelist'; // To manage different context of search
+$socid = GETPOST('socid', 'int');
+
// Security check
$id = (GETPOST('facid', 'int') ?GETPOST('facid', 'int') : GETPOST('id', 'int'));
$lineid = GETPOST('lineid', 'int');
@@ -62,7 +61,6 @@ if ($user->socid) $socid = $user->socid;
$objecttype = 'facture_rec';
if ($action == "create" || $action == "add") $objecttype = '';
$result = restrictedArea($user, 'facture', $id, $objecttype);
-$projectid = GETPOST('projectid', 'int');
$search_ref = GETPOST('search_ref');
$search_societe = GETPOST('search_societe');
@@ -146,6 +144,13 @@ if (is_array($extrafields->attributes[$object->table_element]['label']) && count
$object->fields = dol_sort_array($object->fields, 'position');
$arrayfields = dol_sort_array($arrayfields, 'position');
+if ($socid > 0) {
+ $tmpthirdparty = new Societe($db);
+ $res = $tmpthirdparty->fetch($socid);
+ if ($res > 0) $search_societe = $tmpthirdparty->name;
+}
+
+
/*
* Actions
@@ -218,6 +223,7 @@ $today = dol_mktime(23, 59, 59, $tmparray['mon'], $tmparray['mday'], $tmparray['
/*
* List mode
*/
+
$sql = "SELECT s.nom as name, s.rowid as socid, f.rowid as facid, f.titre as title, f.total, f.tva as total_vat, f.total_ttc, f.frequency, f.unit_frequency,";
$sql .= " f.nb_gen_done, f.nb_gen_max, f.date_last_gen, f.date_when, f.suspended,";
$sql .= " f.datec, f.tms,";
@@ -243,6 +249,7 @@ if (!$user->rights->societe->client->voir && !$socid) {
$sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
}
if ($search_ref) $sql .= natural_search('f.titre', $search_ref);
+if ($socid) $sql .= ' AND s.rowid = '.(int) $socid;
if ($search_societe) $sql .= natural_search('s.nom', $search_societe);
if ($search_montant_ht != '') $sql .= natural_search('f.total', $search_montant_ht, 1);
if ($search_montant_vat != '') $sql .= natural_search('f.tva', $search_montant_vat, 1);
@@ -286,7 +293,7 @@ if ($resql)
$param = '';
if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage);
if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit);
- if ($socid) $param .= '&socid='.urlencode($socid);
+ if ($socid > 0) $param .= '&socid='.urlencode($socid);
if ($search_day) $param .= '&search_day='.urlencode($search_day);
if ($search_month) $param .= '&search_month='.urlencode($search_month);
if ($search_year) $param .= '&search_year='.urlencode($search_year);
@@ -299,12 +306,11 @@ if ($resql)
if ($search_montant_vat != '') $param .= '&search_montant_vat='.urlencode($search_montant_vat);
if ($search_montant_ttc != '') $param .= '&search_montant_ttc='.urlencode($search_montant_ttc);
if ($search_payment_mode != '') $param .= '&search_payment_mode='.urlencode($search_payment_mode);
- if ($search_payment_type != '') $param .= '&search_payment_type='.urlencode($search_payment_type);
+ if ($search_payment_term != '') $param .= '&search_payment_term='.urlencode($search_payment_term);
if ($search_recurring != '' && $search_recurrning != '-1') $param .= '&search_recurring='.urlencode($search_recurring);
if ($search_frequency > 0) $param .= '&search_frequency='.urlencode($search_frequency);
if ($search_unit_frequency != '') $param .= '&search_unit_frequency='.urlencode($search_unit_frequency);
if ($search_status != '') $param .= '&search_status='.urlencode($search_status);
- if ($option) $param .= "&option=".urlencode($option);
if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss);
// Add $param from extra fields
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
@@ -326,12 +332,16 @@ if ($resql)
print '';
print '';
- print_barre_liste($langs->trans("RepeatableInvoices"), $page, $_SERVER['PHP_SELF'], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'invoicing', 0, '', '', $limit);
+ $title = $langs->trans("RepeatableInvoices");
+
+ print_barre_liste($title, $page, $_SERVER['PHP_SELF'], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'invoicing', 0, '', '', $limit);
print ''.$langs->trans("ToCreateAPredefinedInvoice", $langs->transnoentitiesnoconv("ChangeIntoRepeatableInvoice")).'
';
$i = 0;
+ $moreforfilter = '';
+
print '';
print ' '."\n";
@@ -467,7 +477,6 @@ if ($resql)
print '';
print "\n";
-
print '';
if (!empty($arrayfields['f.titre']['checked'])) print_liste_field_titre($arrayfields['f.titre']['label'], $_SERVER['PHP_SELF'], "f.titre", "", $param, "", $sortfield, $sortorder);
if (!empty($arrayfields['s.nom']['checked'])) print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER['PHP_SELF'], "s.nom", "", $param, "", $sortfield, $sortorder);
diff --git a/htdocs/core/class/commondocgenerator.class.php b/htdocs/core/class/commondocgenerator.class.php
index 54dfb294975..5ddd0744ea8 100644
--- a/htdocs/core/class/commondocgenerator.class.php
+++ b/htdocs/core/class/commondocgenerator.class.php
@@ -794,81 +794,84 @@ abstract class CommonDocGenerator
{
// phpcs:enable
global $conf;
- foreach($extrafields->attributes[$object->table_element]['label'] as $key=>$label)
- {
- if($extrafields->attributes[$object->table_element]['type'][$key] == 'price')
+
+ if (is_array($extrafields->attributes[$object->table_element]['label'])) {
+ foreach($extrafields->attributes[$object->table_element]['label'] as $key=>$label)
{
- $object->array_options['options_'.$key] = price2num($object->array_options['options_'.$key]);
- $object->array_options['options_'.$key.'_currency'] = price($object->array_options['options_'.$key], 0, $outputlangs, 0, 0, -1, $conf->currency);
- //Add value to store price with currency
- $array_to_fill=array_merge($array_to_fill, array($array_key.'_options_'.$key.'_currency' => $object->array_options['options_'.$key.'_currency']));
- }
- elseif($extrafields->attributes[$object->table_element]['type'][$key] == 'select')
- {
- $object->array_options['options_'.$key] = $extrafields->attributes[$object->table_element]['param'][$key]['options'][$object->array_options['options_'.$key]];
- }
- elseif($extrafields->attributes[$object->table_element]['type'][$key] == 'checkbox') {
- $valArray=explode(',', $object->array_options['options_'.$key]);
- $output=array();
- foreach($extrafields->attributes[$object->table_element]['param'][$key]['options'] as $keyopt=>$valopt) {
- if (in_array($keyopt, $valArray)) {
- $output[]=$valopt;
+ if($extrafields->attributes[$object->table_element]['type'][$key] == 'price')
+ {
+ $object->array_options['options_'.$key] = price2num($object->array_options['options_'.$key]);
+ $object->array_options['options_'.$key.'_currency'] = price($object->array_options['options_'.$key], 0, $outputlangs, 0, 0, -1, $conf->currency);
+ //Add value to store price with currency
+ $array_to_fill=array_merge($array_to_fill, array($array_key.'_options_'.$key.'_currency' => $object->array_options['options_'.$key.'_currency']));
+ }
+ elseif($extrafields->attributes[$object->table_element]['type'][$key] == 'select')
+ {
+ $object->array_options['options_'.$key] = $extrafields->attributes[$object->table_element]['param'][$key]['options'][$object->array_options['options_'.$key]];
+ }
+ elseif($extrafields->attributes[$object->table_element]['type'][$key] == 'checkbox') {
+ $valArray=explode(',', $object->array_options['options_'.$key]);
+ $output=array();
+ foreach($extrafields->attributes[$object->table_element]['param'][$key]['options'] as $keyopt=>$valopt) {
+ if (in_array($keyopt, $valArray)) {
+ $output[]=$valopt;
+ }
}
+ $object->array_options['options_'.$key] = implode(', ', $output);
}
- $object->array_options['options_'.$key] = implode(', ', $output);
- }
- elseif($extrafields->attributes[$object->table_element]['type'][$key] == 'date')
- {
- if (strlen($object->array_options['options_'.$key])>0)
+ elseif($extrafields->attributes[$object->table_element]['type'][$key] == 'date')
{
- $date = $object->array_options['options_'.$key];
- $object->array_options['options_'.$key] = dol_print_date($date, 'day'); // using company output language
- $object->array_options['options_'.$key.'_locale'] = dol_print_date($date, 'day', 'tzserver', $outputlangs); // using output language format
- $object->array_options['options_'.$key.'_rfc'] = dol_print_date($date, 'dayrfc'); // international format
- }
- else
- {
- $object->array_options['options_'.$key] = '';
- $object->array_options['options_'.$key.'_locale'] = '';
- $object->array_options['options_'.$key.'_rfc'] = '';
- }
- $array_to_fill=array_merge($array_to_fill, array($array_key.'_options_'.$key.'_locale' => $object->array_options['options_'.$key.'_locale']));
- $array_to_fill=array_merge($array_to_fill, array($array_key.'_options_'.$key.'_rfc' => $object->array_options['options_'.$key.'_rfc']));
- }
- elseif($extrafields->attributes[$object->table_element]['label'][$key] == 'datetime')
- {
- $datetime = $object->array_options['options_'.$key];
- $object->array_options['options_'.$key] = ($datetime!="0000-00-00 00:00:00"?dol_print_date($object->array_options['options_'.$key], 'dayhour'):''); // using company output language
- $object->array_options['options_'.$key.'_locale'] = ($datetime!="0000-00-00 00:00:00"?dol_print_date($object->array_options['options_'.$key], 'dayhour', 'tzserver', $outputlangs):''); // using output language format
- $object->array_options['options_'.$key.'_rfc'] = ($datetime!="0000-00-00 00:00:00"?dol_print_date($object->array_options['options_'.$key], 'dayhourrfc'):''); // international format
- $array_to_fill=array_merge($array_to_fill, array($array_key.'_options_'.$key.'_locale' => $object->array_options['options_'.$key.'_locale']));
- $array_to_fill=array_merge($array_to_fill, array($array_key.'_options_'.$key.'_rfc' => $object->array_options['options_'.$key.'_rfc']));
- }
- elseif($extrafields->attributes[$object->table_element]['type'][$key] == 'link')
- {
- $id = $object->array_options['options_'.$key];
- if ($id != "")
- {
- $param = $extrafields->attributes[$object->table_element]['param'][$key];
- $param_list=array_keys($param['options']); // $param_list='ObjectName:classPath'
- $InfoFieldList = explode(":", $param_list[0]);
- $classname=$InfoFieldList[0];
- $classpath=$InfoFieldList[1];
- if (! empty($classpath))
+ if (strlen($object->array_options['options_'.$key])>0)
{
- dol_include_once($InfoFieldList[1]);
- if ($classname && class_exists($classname))
+ $date = $object->array_options['options_'.$key];
+ $object->array_options['options_'.$key] = dol_print_date($date, 'day'); // using company output language
+ $object->array_options['options_'.$key.'_locale'] = dol_print_date($date, 'day', 'tzserver', $outputlangs); // using output language format
+ $object->array_options['options_'.$key.'_rfc'] = dol_print_date($date, 'dayrfc'); // international format
+ }
+ else
+ {
+ $object->array_options['options_'.$key] = '';
+ $object->array_options['options_'.$key.'_locale'] = '';
+ $object->array_options['options_'.$key.'_rfc'] = '';
+ }
+ $array_to_fill=array_merge($array_to_fill, array($array_key.'_options_'.$key.'_locale' => $object->array_options['options_'.$key.'_locale']));
+ $array_to_fill=array_merge($array_to_fill, array($array_key.'_options_'.$key.'_rfc' => $object->array_options['options_'.$key.'_rfc']));
+ }
+ elseif($extrafields->attributes[$object->table_element]['label'][$key] == 'datetime')
+ {
+ $datetime = $object->array_options['options_'.$key];
+ $object->array_options['options_'.$key] = ($datetime!="0000-00-00 00:00:00"?dol_print_date($object->array_options['options_'.$key], 'dayhour'):''); // using company output language
+ $object->array_options['options_'.$key.'_locale'] = ($datetime!="0000-00-00 00:00:00"?dol_print_date($object->array_options['options_'.$key], 'dayhour', 'tzserver', $outputlangs):''); // using output language format
+ $object->array_options['options_'.$key.'_rfc'] = ($datetime!="0000-00-00 00:00:00"?dol_print_date($object->array_options['options_'.$key], 'dayhourrfc'):''); // international format
+ $array_to_fill=array_merge($array_to_fill, array($array_key.'_options_'.$key.'_locale' => $object->array_options['options_'.$key.'_locale']));
+ $array_to_fill=array_merge($array_to_fill, array($array_key.'_options_'.$key.'_rfc' => $object->array_options['options_'.$key.'_rfc']));
+ }
+ elseif($extrafields->attributes[$object->table_element]['type'][$key] == 'link')
+ {
+ $id = $object->array_options['options_'.$key];
+ if ($id != "")
+ {
+ $param = $extrafields->attributes[$object->table_element]['param'][$key];
+ $param_list=array_keys($param['options']); // $param_list='ObjectName:classPath'
+ $InfoFieldList = explode(":", $param_list[0]);
+ $classname=$InfoFieldList[0];
+ $classpath=$InfoFieldList[1];
+ if (! empty($classpath))
{
- $tmpobject = new $classname($this->db);
- $tmpobject->fetch($id);
- // completely replace the id with the linked object name
- $object->array_options['options_'.$key] = $tmpobject->name;
+ dol_include_once($InfoFieldList[1]);
+ if ($classname && class_exists($classname))
+ {
+ $tmpobject = new $classname($this->db);
+ $tmpobject->fetch($id);
+ // completely replace the id with the linked object name
+ $object->array_options['options_'.$key] = $tmpobject->name;
+ }
}
}
}
- }
- $array_to_fill = array_merge($array_to_fill, array($array_key.'_options_'.$key => $object->array_options['options_'.$key]));
+ $array_to_fill = array_merge($array_to_fill, array($array_key.'_options_'.$key => $object->array_options['options_'.$key]));
+ }
}
return $array_to_fill;
diff --git a/htdocs/core/class/discount.class.php b/htdocs/core/class/discount.class.php
index ee9fdf1ca65..f6f18ab3d0c 100644
--- a/htdocs/core/class/discount.class.php
+++ b/htdocs/core/class/discount.class.php
@@ -604,14 +604,14 @@ class DiscountAbsolute
$sql = 'SELECT sum(rc.amount_ttc) as amount, sum(rc.multicurrency_amount_ttc) as multicurrency_amount';
$sql .= ' FROM '.MAIN_DB_PREFIX.'societe_remise_except as rc, '.MAIN_DB_PREFIX.'facture as f';
$sql .= ' WHERE rc.fk_facture_source=f.rowid AND rc.fk_facture = '.$invoice->id;
- $sql .= ' AND f.type IN (' . Facture::TYPE_STANDARD . ', ' . Facture::TYPE_CREDIT_NOTE . ', ' . Facture::TYPE_SITUATION . ')'; // Find discount coming from credit note or excess received
+ $sql .= ' AND f.type IN (' . $invoice::TYPE_STANDARD . ', ' . $invoice::TYPE_CREDIT_NOTE . ', ' . $invoice::TYPE_SITUATION . ')'; // Find discount coming from credit note or excess received
}
elseif ($invoice->element == 'invoice_supplier')
{
$sql = 'SELECT sum(rc.amount_ttc) as amount, sum(rc.multicurrency_amount_ttc) as multicurrency_amount';
$sql .= ' FROM '.MAIN_DB_PREFIX.'societe_remise_except as rc, '.MAIN_DB_PREFIX.'facture_fourn as f';
$sql .= ' WHERE rc.fk_invoice_supplier_source=f.rowid AND rc.fk_invoice_supplier = '.$invoice->id;
- $sql .= ' AND f.type IN (' . Facture::TYPE_STANDARD . ', ' . Facture::TYPE_CREDIT_NOTE . ')'; // Find discount coming from credit note or excess paid
+ $sql .= ' AND f.type IN (' . $invoice::TYPE_STANDARD . ', ' . $invoice::TYPE_CREDIT_NOTE . ')'; // Find discount coming from credit note or excess paid
}
else
{
diff --git a/htdocs/core/tpl/card_presend.tpl.php b/htdocs/core/tpl/card_presend.tpl.php
index 169b7753b92..795483b08ba 100644
--- a/htdocs/core/tpl/card_presend.tpl.php
+++ b/htdocs/core/tpl/card_presend.tpl.php
@@ -189,7 +189,7 @@ if ($action == 'presend')
}
$formmail->withto = $liste;
- $formmail->withtofree = (GETPOSTISSET('sendto') ? (GETPOST('sendto') ? GETPOST('sendto') : '1') : '');
+ $formmail->withtofree = (GETPOSTISSET('sendto') ? (GETPOST('sendto') ? GETPOST('sendto') : '1') : '1');
$formmail->withtocc = $liste;
$formmail->withtoccc = $conf->global->MAIN_EMAIL_USECCC;
$formmail->withtopic = $topicmail;
|