Scrutinizer Auto-Fixes

This commit consists of patches automatically generated for this project on https://scrutinizer-ci.com
This commit is contained in:
Scrutinizer Auto-Fixer 2017-10-16 06:47:05 +00:00
parent f853dbc152
commit bd5bffa72c
19 changed files with 8785 additions and 8785 deletions

View File

@ -33,12 +33,12 @@ include_once DOL_DOCUMENT_ROOT."/core/lib/date.lib.php";
*/ */
class lettering extends BookKeeping class lettering extends BookKeeping
{ {
/** /**
* lettrageTiers * lettrageTiers
* *
* @param int $socid Thirdparty id * @param int $socid Thirdparty id
* @return int <0 if KO, >0 if OK * @return int <0 if KO, >0 if OK
*/ */
public function lettrageTiers($socid) { public function lettrageTiers($socid) {
$db = $this->db; $db = $this->db;
@ -121,7 +121,7 @@ class lettering extends BookKeeping
/** /**
Prise en charge des lettering complexe avec prelevment , virement Prise en charge des lettering complexe avec prelevment , virement
*/ */
$sql = "SELECT bk.rowid, bk.doc_date, bk.doc_type, bk.doc_ref, bk.code_tiers, bk.numero_compte , bk.label_compte, bk.debit , bk.credit, bk.montant , bk.sens , bk.code_journal , bk.piece_num, bk.date_lettering, bu.url_id , bu.type "; $sql = "SELECT bk.rowid, bk.doc_date, bk.doc_type, bk.doc_ref, bk.code_tiers, bk.numero_compte , bk.label_compte, bk.debit , bk.credit, bk.montant , bk.sens , bk.code_journal , bk.piece_num, bk.date_lettering, bu.url_id , bu.type ";
$sql .= " FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping as bk"; $sql .= " FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping as bk";
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "bank_url as bu ON(bk.fk_doc = bu.fk_bank AND bu.type IN ('payment', 'payment_supplier') ) "; $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "bank_url as bu ON(bk.fk_doc = bu.fk_bank AND bu.type IN ('payment', 'payment_supplier') ) ";

View File

@ -25,119 +25,119 @@ include_once DOL_DOCUMENT_ROOT.'/admin/dolistore/class/PSWebServiceLibrary.class
*/ */
class Dolistore class Dolistore
{ {
// params // params
public $start; // beginning of pagination public $start; // beginning of pagination
public $end; // end of pagination public $end; // end of pagination
public $per_page; // pagination: display per page public $per_page; // pagination: display per page
public $categorie; // the current categorie public $categorie; // the current categorie
public $search; // the search keywords public $search; // the search keywords
// setups // setups
public $url; // the url of this page public $url; // the url of this page
public $shop_url; // the url of the shop public $shop_url; // the url of the shop
public $vat_rate; // the vat rate used in the shop (prices are provided without vat) public $vat_rate; // the vat rate used in the shop (prices are provided without vat)
public $lang; // the integer representing the lang in the store public $lang; // the integer representing the lang in the store
public $debug_api; // usefull if no dialog public $debug_api; // usefull if no dialog
/** /**
* Constructor * Constructor
*/ */
function __construct() function __construct()
{ {
global $conf, $langs; global $conf, $langs;
$this->url = DOL_URL_ROOT.'/admin/modules.php?mode=marketplace'; $this->url = DOL_URL_ROOT.'/admin/modules.php?mode=marketplace';
$this->shop_url = 'https://www.dolistore.com/index.php?controller=product&id_product='; $this->shop_url = 'https://www.dolistore.com/index.php?controller=product&id_product=';
$this->vat_rate = 1.2; // 20% de TVA $this->vat_rate = 1.2; // 20% de TVA
$this->debug_api = false; $this->debug_api = false;
$langtmp = explode('_', $langs->defaultlang); $langtmp = explode('_', $langs->defaultlang);
$lang = $langtmp[0]; $lang = $langtmp[0];
$lang_array = array('en'=>0, 'fr'=>1, 'es'=>2, 'it'=>3, 'de'=>4); // Into table ps_lang of Prestashop - 1 $lang_array = array('en'=>0, 'fr'=>1, 'es'=>2, 'it'=>3, 'de'=>4); // Into table ps_lang of Prestashop - 1
if (! in_array($lang, array_keys($lang_array))) $lang = 'en'; if (! in_array($lang, array_keys($lang_array))) $lang = 'en';
$this->lang = $lang_array[$lang]; $this->lang = $lang_array[$lang];
} }
/** /**
* Load data from remote Dolistore market place. * Load data from remote Dolistore market place.
* This fills ->categories * This fills ->categories
* *
* @param array $options Options * @param array $options Options
* @return void * @return void
*/ */
function getRemoteData($options = array('start' => 0, 'end' => 10, 'per_page' => 50, 'categorie' => 0)) function getRemoteData($options = array('start' => 0, 'end' => 10, 'per_page' => 50, 'categorie' => 0))
{ {
global $conf, $langs; global $conf, $langs;
$this->start = $options['start']; $this->start = $options['start'];
$this->end = $options['end']; $this->end = $options['end'];
$this->per_page = $options['per_page']; $this->per_page = $options['per_page'];
$this->categorie = $options['categorie']; $this->categorie = $options['categorie'];
$this->search = $options['search']; $this->search = $options['search'];
if ($this->end == 0) { if ($this->end == 0) {
$this->end = $this->per_page; $this->end = $this->per_page;
} }
try { try {
$this->api = new PrestaShopWebservice($conf->global->MAIN_MODULE_DOLISTORE_API_SRV, $this->api = new PrestaShopWebservice($conf->global->MAIN_MODULE_DOLISTORE_API_SRV,
$conf->global->MAIN_MODULE_DOLISTORE_API_KEY, $this->debug_api); $conf->global->MAIN_MODULE_DOLISTORE_API_KEY, $this->debug_api);
// Here we set the option array for the Webservice : we want products resources // Here we set the option array for the Webservice : we want products resources
$opt = array(); $opt = array();
$opt['resource'] = 'products'; $opt['resource'] = 'products';
// make a search to limit the id returned. // make a search to limit the id returned.
if ($this->search != '') { if ($this->search != '') {
$opt2 = array(); $opt2 = array();
$opt2['url'] = $conf->global->MAIN_MODULE_DOLISTORE_API_SRV.'/api/search?query='.$this->search.'&language='.$this->lang; $opt2['url'] = $conf->global->MAIN_MODULE_DOLISTORE_API_SRV.'/api/search?query='.$this->search.'&language='.$this->lang;
// Call // Call
$xml = $this->api->get($opt2); $xml = $this->api->get($opt2);
$products = array(); $products = array();
foreach ($xml->products->children() as $product) { foreach ($xml->products->children() as $product) {
$products[] = (int) $product['id']; $products[] = (int) $product['id'];
} }
$opt['filter[id]'] = '['.implode('|', $products).']'; $opt['filter[id]'] = '['.implode('|', $products).']';
} elseif ($this->categorie != 0) { } elseif ($this->categorie != 0) {
$opt2 = array(); $opt2 = array();
$opt2['resource'] = 'categories'; $opt2['resource'] = 'categories';
$opt2['id'] = $this->categorie; $opt2['id'] = $this->categorie;
// Call // Call
$xml = $this->api->get($opt2); $xml = $this->api->get($opt2);
$products = array(); $products = array();
foreach ($xml->category->associations->products->children() as $product) { foreach ($xml->category->associations->products->children() as $product) {
$products[] = (int) $product->id; $products[] = (int) $product->id;
} }
$opt['filter[id]'] = '['.implode('|', $products).']'; $opt['filter[id]'] = '['.implode('|', $products).']';
} }
$opt['display'] = '[id,name,id_default_image,id_category_default,reference,price,condition,show_price,date_add,date_upd,description_short,description,module_version,dolibarr_min,dolibarr_max]'; $opt['display'] = '[id,name,id_default_image,id_category_default,reference,price,condition,show_price,date_add,date_upd,description_short,description,module_version,dolibarr_min,dolibarr_max]';
$opt['sort'] = 'id_desc'; $opt['sort'] = 'id_desc';
$opt['filter[active]'] = '[1]'; $opt['filter[active]'] = '[1]';
$opt['limit'] = "$this->start,$this->end"; $opt['limit'] = "$this->start,$this->end";
// $opt['filter[id]'] contais list of product id that are result of search // $opt['filter[id]'] contais list of product id that are result of search
// Call API to get the detail // Call API to get the detail
$xml = $this->api->get($opt); $xml = $this->api->get($opt);
$this->products = $xml->products->children(); $this->products = $xml->products->children();
// Here we set the option array for the Webservice : we want categories resources // Here we set the option array for the Webservice : we want categories resources
$opt = array(); $opt = array();
$opt['resource'] = 'categories'; $opt['resource'] = 'categories';
$opt['display'] = '[id,id_parent,nb_products_recursive,active,is_root_category,name,description]'; $opt['display'] = '[id,id_parent,nb_products_recursive,active,is_root_category,name,description]';
$opt['sort'] = 'id_asc'; $opt['sort'] = 'id_asc';
// Call // Call
$xml = $this->api->get($opt); $xml = $this->api->get($opt);
$this->categories = $xml->categories->children(); $this->categories = $xml->categories->children();
} catch (PrestaShopWebserviceException $e) { } catch (PrestaShopWebserviceException $e) {
// Here we are dealing with errors // Here we are dealing with errors
$trace = $e->getTrace(); $trace = $e->getTrace();
if ($trace[0]['args'][0] == 404) die('Bad ID'); if ($trace[0]['args'][0] == 404) die('Bad ID');
else if ($trace[0]['args'][0] == 401) die('Bad auth key'); else if ($trace[0]['args'][0] == 401) die('Bad auth key');
else die('Can not access to '.$conf->global->MAIN_MODULE_DOLISTORE_API_SRV); else die('Can not access to '.$conf->global->MAIN_MODULE_DOLISTORE_API_SRV);
} }
} }
/** /**
* Return tree of Dolistore categories. $this->categories must have been loaded before. * Return tree of Dolistore categories. $this->categories must have been loaded before.
@ -145,199 +145,199 @@ class Dolistore
* @param int $parent Id of parent category * @param int $parent Id of parent category
* @return string * @return string
*/ */
function get_categories($parent = 0) function get_categories($parent = 0)
{ {
if (!isset($this->categories)) die('not possible'); if (!isset($this->categories)) die('not possible');
if ($parent != 0) { if ($parent != 0) {
$html = '<ul>'; $html = '<ul>';
} else { } else {
$html = ''; $html = '';
} }
$nbofcateg = count($this->categories); $nbofcateg = count($this->categories);
for ($i = 0; $i < $nbofcateg; $i++) for ($i = 0; $i < $nbofcateg; $i++)
{ {
$cat = $this->categories[$i]; $cat = $this->categories[$i];
if ($cat->is_root_category == 1 && $parent == 0) { if ($cat->is_root_category == 1 && $parent == 0) {
$html .= '<li class="root"><h3 class="nomargesupinf"><a class="nomargesupinf link2cat" href="?mode=marketplace&categorie='.$cat->id.'" ' $html .= '<li class="root"><h3 class="nomargesupinf"><a class="nomargesupinf link2cat" href="?mode=marketplace&categorie='.$cat->id.'" '
.'title="'.dol_escape_htmltag(strip_tags($cat->description->language[$this->lang])).'"' .'title="'.dol_escape_htmltag(strip_tags($cat->description->language[$this->lang])).'"'
.'>'.$cat->name->language[$this->lang].' <sup>'.$cat->nb_products_recursive.'</sup></a></h3>'; .'>'.$cat->name->language[$this->lang].' <sup>'.$cat->nb_products_recursive.'</sup></a></h3>';
$html .= self::get_categories($cat->id); $html .= self::get_categories($cat->id);
$html .= "</li>\n"; $html .= "</li>\n";
} elseif (trim($cat->id_parent) == $parent && $cat->active == 1 && trim($cat->id_parent) != 0) { // si cat est de ce niveau } elseif (trim($cat->id_parent) == $parent && $cat->active == 1 && trim($cat->id_parent) != 0) { // si cat est de ce niveau
$select = ($cat->id == $this->categorie) ? ' selected' : ''; $select = ($cat->id == $this->categorie) ? ' selected' : '';
$html .= '<li><a class="link2cat'.$select.'" href="?mode=marketplace&categorie='.$cat->id.'"' $html .= '<li><a class="link2cat'.$select.'" href="?mode=marketplace&categorie='.$cat->id.'"'
.' title="'.dol_escape_htmltag(strip_tags($cat->description->language[$this->lang])).'" ' .' title="'.dol_escape_htmltag(strip_tags($cat->description->language[$this->lang])).'" '
.'>'.$cat->name->language[$this->lang].' <sup>'.$cat->nb_products_recursive.'</sup></a>'; .'>'.$cat->name->language[$this->lang].' <sup>'.$cat->nb_products_recursive.'</sup></a>';
$html .= self::get_categories($cat->id); $html .= self::get_categories($cat->id);
$html .= "</li>\n"; $html .= "</li>\n";
} else { } else {
} }
} }
if ($html == '<ul>') { if ($html == '<ul>') {
return ''; return '';
} }
if ($parent != 0) { if ($parent != 0) {
return $html.'</ul>'; return $html.'</ul>';
} else { } else {
return $html; return $html;
} }
} }
/** /**
* Return list of product formated for output * Return list of product formated for output
* *
* @return string HTML output * @return string HTML output
*/ */
function get_products() function get_products()
{ {
global $langs, $conf; global $langs, $conf;
$html = ""; $html = "";
$parity = "pair"; $parity = "pair";
$last_month = time() - (30 * 24 * 60 * 60); $last_month = time() - (30 * 24 * 60 * 60);
foreach ($this->products as $product) { foreach ($this->products as $product) {
$parity = ($parity == "impair") ? 'pair' : 'impair'; $parity = ($parity == "impair") ? 'pair' : 'impair';
// check new product ? // check new product ?
$newapp = ''; $newapp = '';
if ($last_month < strtotime($product->date_add)) { if ($last_month < strtotime($product->date_add)) {
$newapp .= '<span class="newApp">'.$langs->trans('New').'</span> '; $newapp .= '<span class="newApp">'.$langs->trans('New').'</span> ';
} }
// check updated ? // check updated ?
if ($last_month < strtotime($product->date_upd) && $newapp == '') { if ($last_month < strtotime($product->date_upd) && $newapp == '') {
$newapp .= '<span class="updatedApp">'.$langs->trans('Updated').'</span> '; $newapp .= '<span class="updatedApp">'.$langs->trans('Updated').'</span> ';
} }
// add image or default ? // add image or default ?
if ($product->id_default_image != '') { if ($product->id_default_image != '') {
$image_url = DOL_URL_ROOT.'/admin/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 = '<a href="'.$image_url.'" class="fancybox" rel="gallery'.$product->id.'" title="'.$product->name->language[$this->lang].', '.$langs->trans('Version').' '.$product->module_version.'">'. $images = '<a href="'.$image_url.'" class="fancybox" rel="gallery'.$product->id.'" title="'.$product->name->language[$this->lang].', '.$langs->trans('Version').' '.$product->module_version.'">'.
'<img src="'.$image_url.'&quality=home_default" style="max-height:250px;max-width: 210px;" alt="" /></a>'; '<img src="'.$image_url.'&quality=home_default" style="max-height:250px;max-width: 210px;" alt="" /></a>';
} else { } else {
$images = '<img src="'.DOL_URL_ROOT.'/admin/dolistore/img/NoImageAvailable.png" />'; $images = '<img src="'.DOL_URL_ROOT.'/admin/dolistore/img/NoImageAvailable.png" />';
} }
// free or pay ? // free or pay ?
if ($product->price > 0) { if ($product->price > 0) {
$price = '<h3>'.price(round((float) $product->price * $this->vat_rate, 2)).'&nbsp;&euro;</h3>'; $price = '<h3>'.price(round((float) $product->price * $this->vat_rate, 2)).'&nbsp;&euro;</h3>';
$download_link = '<a target="_blank" href="'.$this->shop_url.$product->id.'"><img width="32" src="'.DOL_URL_ROOT.'/admin/dolistore/img/follow.png" /></a>'; $download_link = '<a target="_blank" href="'.$this->shop_url.$product->id.'"><img width="32" src="'.DOL_URL_ROOT.'/admin/dolistore/img/follow.png" /></a>';
} else { } else {
$price = '<h3>'.$langs->trans('Free').'</h3>'; $price = '<h3>'.$langs->trans('Free').'</h3>';
$download_link = '<a target="_blank" href="'.$this->shop_url.$product->id.'"><img width="32" src="'.DOL_URL_ROOT.'/admin/dolistore/img/Download-128.png" /></a>'; $download_link = '<a target="_blank" href="'.$this->shop_url.$product->id.'"><img width="32" src="'.DOL_URL_ROOT.'/admin/dolistore/img/Download-128.png" /></a>';
$download_link.= '<br><br><a target="_blank" href="'.$this->shop_url.$product->id.'"><img width="32" src="'.DOL_URL_ROOT.'/admin/dolistore/img/follow.png" /></a>'; $download_link.= '<br><br><a target="_blank" href="'.$this->shop_url.$product->id.'"><img width="32" src="'.DOL_URL_ROOT.'/admin/dolistore/img/follow.png" /></a>';
} }
//checking versions //checking versions
if ($this->version_compare($product->dolibarr_min, DOL_VERSION) <= 0) { if ($this->version_compare($product->dolibarr_min, DOL_VERSION) <= 0) {
if ($this->version_compare($product->dolibarr_max, DOL_VERSION) >= 0) { if ($this->version_compare($product->dolibarr_max, DOL_VERSION) >= 0) {
//compatible //compatible
$version = '<span class="compatible">'.$langs->trans('CompatibleUpTo', $product->dolibarr_max, $version = '<span class="compatible">'.$langs->trans('CompatibleUpTo', $product->dolibarr_max,
$product->dolibarr_min, $product->dolibarr_max).'</span>'; $product->dolibarr_min, $product->dolibarr_max).'</span>';
$compatible = ''; $compatible = '';
} else { } else {
//never compatible, module expired //never compatible, module expired
$version = '<span class="notcompatible">'.$langs->trans('NotCompatible', DOL_VERSION, $version = '<span class="notcompatible">'.$langs->trans('NotCompatible', DOL_VERSION,
$product->dolibarr_min, $product->dolibarr_max).'</span>'; $product->dolibarr_min, $product->dolibarr_max).'</span>';
$compatible = 'NotCompatible'; $compatible = 'NotCompatible';
} }
} else { } else {
//need update //need update
$version = '<span class="compatibleafterupdate">'.$langs->trans('CompatibleAfterUpdate', DOL_VERSION, $version = '<span class="compatibleafterupdate">'.$langs->trans('CompatibleAfterUpdate', DOL_VERSION,
$product->dolibarr_min, $product->dolibarr_max).'</span>'; $product->dolibarr_min, $product->dolibarr_max).'</span>';
$compatible = 'NotCompatible'; $compatible = 'NotCompatible';
} }
//.'<br><a class="inline-block valignmiddle" target="_blank" href="'.$this->shop_url.$product->id.'"><span class="details button">'.$langs->trans("SeeInMarkerPlace").'</span></a> //.'<br><a class="inline-block valignmiddle" target="_blank" href="'.$this->shop_url.$product->id.'"><span class="details button">'.$langs->trans("SeeInMarkerPlace").'</span></a>
//output template //output template
$html .= '<tr class="app '.$parity.' '.$compatible.'"> $html .= '<tr class="app '.$parity.' '.$compatible.'">
<td align="center" width="210"><div class="newAppParent">'.$newapp.$images.'</div></td> <td align="center" width="210"><div class="newAppParent">'.$newapp.$images.'</div></td>
<td class="margeCote"><h2 class="appTitle">'.$product->name->language[$this->lang] <td class="margeCote"><h2 class="appTitle">'.$product->name->language[$this->lang]
.'<br/><small>'.$version.'</small></h2> .'<br/><small>'.$version.'</small></h2>
<small> '.dol_print_date(dol_stringtotime($product->date_upd), 'dayhour').' - '.$langs->trans('Ref').': '.$product->reference.' - '.$langs->trans('Id').': '.$product->id.'</small><br><br>'.$product->description_short->language[$this->lang].'</td> <small> '.dol_print_date(dol_stringtotime($product->date_upd), 'dayhour').' - '.$langs->trans('Ref').': '.$product->reference.' - '.$langs->trans('Id').': '.$product->id.'</small><br><br>'.$product->description_short->language[$this->lang].'</td>
<td style="display:none;" class="long_description">'.$product->description->language[$this->lang].'</td> <td style="display:none;" class="long_description">'.$product->description->language[$this->lang].'</td>
<td class="margeCote" align="center">'.$price.' <td class="margeCote" align="center">'.$price.'
</td> </td>
<td class="margeCote">'.$download_link.'</td> <td class="margeCote">'.$download_link.'</td>
</tr>'; </tr>';
} }
return $html; return $html;
} }
function get_previous_link($text = '<<') function get_previous_link($text = '<<')
{ {
return '<a href="'.$this->get_previous_url().'" class="button">'.$text.'</a>'; return '<a href="'.$this->get_previous_url().'" class="button">'.$text.'</a>';
} }
function get_next_link($text = '>>') function get_next_link($text = '>>')
{ {
return '<a href="'.$this->get_next_url().'" class="button">'.$text.'</a>'; return '<a href="'.$this->get_next_url().'" class="button">'.$text.'</a>';
} }
function get_previous_url() function get_previous_url()
{ {
$param_array = array(); $param_array = array();
if ($this->start < $this->per_page) { if ($this->start < $this->per_page) {
$sub = 0; $sub = 0;
} else { } else {
$sub = $this->per_page; $sub = $this->per_page;
} }
$param_array['start'] = $this->start - $sub; $param_array['start'] = $this->start - $sub;
$param_array['end'] = $this->end - $sub; $param_array['end'] = $this->end - $sub;
if ($this->categorie != 0) { if ($this->categorie != 0) {
$param_array['categorie'] = $this->categorie; $param_array['categorie'] = $this->categorie;
} }
$param = http_build_query($param_array); $param = http_build_query($param_array);
return $this->url."&".$param; return $this->url."&".$param;
} }
function get_next_url() function get_next_url()
{ {
$param_array = array(); $param_array = array();
if (count($this->products) < $this->per_page) { if (count($this->products) < $this->per_page) {
$add = 0; $add = 0;
} else { } else {
$add = $this->per_page; $add = $this->per_page;
} }
$param_array['start'] = $this->start + $add; $param_array['start'] = $this->start + $add;
$param_array['end'] = $this->end + $add; $param_array['end'] = $this->end + $add;
if ($this->categorie != 0) { if ($this->categorie != 0) {
$param_array['categorie'] = $this->categorie; $param_array['categorie'] = $this->categorie;
} }
$param = http_build_query($param_array); $param = http_build_query($param_array);
return $this->url."&".$param; return $this->url."&".$param;
} }
function version_compare($v1, $v2) function version_compare($v1, $v2)
{ {
$v1 = explode('.', $v1); $v1 = explode('.', $v1);
$v2 = explode('.', $v2); $v2 = explode('.', $v2);
$ret = 0; $ret = 0;
$level = 0; $level = 0;
$count1 = count($v1); $count1 = count($v1);
$count2 = count($v2); $count2 = count($v2);
$maxcount = max($count1, $count2); $maxcount = max($count1, $count2);
while ($level < $maxcount) { while ($level < $maxcount) {
$operande1 = isset($v1[$level]) ? $v1[$level] : 'x'; $operande1 = isset($v1[$level]) ? $v1[$level] : 'x';
$operande2 = isset($v2[$level]) ? $v2[$level] : 'x'; $operande2 = isset($v2[$level]) ? $v2[$level] : 'x';
$level++; $level++;
if (strtoupper($operande1) == 'X' || strtoupper($operande2) == 'X' || $operande1 == '*' || $operande2 == '*') { if (strtoupper($operande1) == 'X' || strtoupper($operande2) == 'X' || $operande1 == '*' || $operande2 == '*') {
break; break;
} }
if ($operande1 < $operande2) { if ($operande1 < $operande2) {
$ret = -$level; $ret = -$level;
break; break;
} }
if ($operande1 > $operande2) { if ($operande1 > $operande2) {
$ret = $level; $ret = $level;
break; break;
} }
} }
//print join('.',$versionarray1).'('.count($versionarray1).') / '.join('.',$versionarray2).'('.count($versionarray2).') => '.$ret.'<br>'."\n"; //print join('.',$versionarray1).'('.count($versionarray1).') / '.join('.',$versionarray2).'('.count($versionarray2).') => '.$ret.'<br>'."\n";
return $ret; return $ret;
} }
} }

View File

@ -85,7 +85,7 @@ if (! $sortorder) $sortorder="ASC";
$socid=0; $socid=0;
if ($user->societe_id > 0) if ($user->societe_id > 0)
{ {
//$socid = $user->societe_id; //$socid = $user->societe_id;
accessforbidden(); accessforbidden();
} }
@ -94,14 +94,14 @@ $search_all=trim(GETPOST("search_all",'alpha'));
$search=array(); $search=array();
foreach($object->fields as $key => $val) foreach($object->fields as $key => $val)
{ {
if (GETPOST('search_'.$key,'alpha')) $search[$key]=GETPOST('search_'.$key,'alpha'); if (GETPOST('search_'.$key,'alpha')) $search[$key]=GETPOST('search_'.$key,'alpha');
} }
// List of fields to search into when doing a "search in all" // List of fields to search into when doing a "search in all"
$fieldstosearchall = array(); $fieldstosearchall = array();
foreach($object->fields as $key => $val) foreach($object->fields as $key => $val)
{ {
if ($val['searchall']) $fieldstosearchall['t.'.$key]=$val['label']; if ($val['searchall']) $fieldstosearchall['t.'.$key]=$val['label'];
} }
// Definition of fields for list // Definition of fields for list
@ -109,15 +109,15 @@ $arrayfields=array();
foreach($object->fields as $key => $val) foreach($object->fields as $key => $val)
{ {
// If $val['visible']==0, then we never show the field // If $val['visible']==0, then we never show the field
if (! empty($val['visible'])) $arrayfields['t.'.$key]=array('label'=>$val['label'], 'checked'=>(($val['visible']<0)?0:1), 'enabled'=>$val['enabled']); if (! empty($val['visible'])) $arrayfields['t.'.$key]=array('label'=>$val['label'], 'checked'=>(($val['visible']<0)?0:1), 'enabled'=>$val['enabled']);
} }
// Extra fields // Extra fields
if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label))
{ {
foreach($extrafields->attribute_label as $key => $val) foreach($extrafields->attribute_label as $key => $val)
{ {
if (! empty($extrafields->attribute_list[$key])) $arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>(($extrafields->attribute_list[$key]<0)?0:1), 'position'=>$extrafields->attribute_pos[$key], 'enabled'=>$extrafields->attribute_perms[$key]); if (! empty($extrafields->attribute_list[$key])) $arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>(($extrafields->attribute_list[$key]<0)?0:1), 'position'=>$extrafields->attribute_pos[$key], 'enabled'=>$extrafields->attribute_perms[$key]);
} }
} }
@ -136,32 +136,32 @@ if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'e
if (empty($reshook)) if (empty($reshook))
{ {
// Selection of new fields // Selection of new fields
include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
// Purge search criteria // Purge search criteria
if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x','alpha') ||GETPOST('button_removefilter','alpha')) // All tests are required to be compatible with all browsers if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x','alpha') ||GETPOST('button_removefilter','alpha')) // All tests are required to be compatible with all browsers
{ {
foreach($object->fields as $key => $val) foreach($object->fields as $key => $val)
{ {
$search[$key]=''; $search[$key]='';
} }
$toselect=''; $toselect='';
$search_array_options=array(); $search_array_options=array();
} }
if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x','alpha') || GETPOST('button_removefilter','alpha') if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x','alpha') || GETPOST('button_removefilter','alpha')
|| GETPOST('button_search_x','alpha') || GETPOST('button_search.x','alpha') || GETPOST('button_search','alpha')) || GETPOST('button_search_x','alpha') || GETPOST('button_search.x','alpha') || GETPOST('button_search','alpha'))
{ {
$massaction=''; // Protection to avoid mass action if we force a new search during a mass action confirmation $massaction=''; // Protection to avoid mass action if we force a new search during a mass action confirmation
} }
// Mass actions // Mass actions
$objectclass='EmailSenderProfile'; $objectclass='EmailSenderProfile';
$objectlabel='EmailSenderProfile'; $objectlabel='EmailSenderProfile';
$permtoread = $user->admin; $permtoread = $user->admin;
$permtodelete = $user->admin; $permtodelete = $user->admin;
$uploaddir = $conf->admin->dir_output.'/senderprofiles'; $uploaddir = $conf->admin->dir_output.'/senderprofiles';
include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
} }
@ -196,7 +196,7 @@ dol_fiche_head($head, 'senderprofiles', '', -1);
$sql = 'SELECT '; $sql = 'SELECT ';
foreach($object->fields as $key => $val) foreach($object->fields as $key => $val)
{ {
$sql.='t.'.$key.', '; $sql.='t.'.$key.', ';
} }
// Add fields from extrafields // Add fields from extrafields
foreach ($extrafields->attribute_label as $key => $val) $sql.=($extrafields->attribute_type[$key] != 'separate' ? ", ef.".$key.' as options_'.$key : ''); foreach ($extrafields->attribute_label as $key => $val) $sql.=($extrafields->attribute_type[$key] != 'separate' ? ", ef.".$key.' as options_'.$key : '');
@ -217,16 +217,16 @@ if ($search_all) $sql.= natural_search(array_keys($fieldstosearchall), $search_a
// Add where from extra fields // Add where from extra fields
foreach ($search_array_options as $key => $val) foreach ($search_array_options as $key => $val)
{ {
$crit=$val; $crit=$val;
$tmpkey=preg_replace('/search_options_/','',$key); $tmpkey=preg_replace('/search_options_/','',$key);
$typ=$extrafields->attribute_type[$tmpkey]; $typ=$extrafields->attribute_type[$tmpkey];
$mode_search=0; $mode_search=0;
if (in_array($typ, array('int','double','real'))) $mode_search=1; // Search on a numeric if (in_array($typ, array('int','double','real'))) $mode_search=1; // Search on a numeric
if (in_array($typ, array('sellist')) && $crit != '0' && $crit != '-1') $mode_search=2; // Search on a foreign key int if (in_array($typ, array('sellist')) && $crit != '0' && $crit != '-1') $mode_search=2; // Search on a foreign key int
if ($crit != '' && (! in_array($typ, array('select','sellist')) || $crit != '0')) if ($crit != '' && (! in_array($typ, array('select','sellist')) || $crit != '0'))
{ {
$sql .= natural_search('ef.'.$tmpkey, $crit, $mode_search); $sql .= natural_search('ef.'.$tmpkey, $crit, $mode_search);
} }
} }
// Add where from hooks // Add where from hooks
$parameters=array(); $parameters=array();
@ -263,8 +263,8 @@ dol_syslog($script_file, LOG_DEBUG);
$resql=$db->query($sql); $resql=$db->query($sql);
if (! $resql) if (! $resql)
{ {
dol_print_error($db); dol_print_error($db);
exit; exit;
} }
$num = $db->num_rows($resql); $num = $db->num_rows($resql);
@ -272,10 +272,10 @@ $num = $db->num_rows($resql);
// Direct jump if only one record found // Direct jump if only one record found
if ($num == 1 && ! empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $search_all) if ($num == 1 && ! empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $search_all)
{ {
$obj = $db->fetch_object($resql); $obj = $db->fetch_object($resql);
$id = $obj->rowid; $id = $obj->rowid;
header("Location: ".DOL_URL_ROOT.'/monmodule/emailsenderprofile_card.php?id='.$id); header("Location: ".DOL_URL_ROOT.'/monmodule/emailsenderprofile_card.php?id='.$id);
exit; exit;
} }
@ -301,21 +301,21 @@ if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&con
if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.urlencode($limit); if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.urlencode($limit);
foreach($search as $key => $val) foreach($search as $key => $val)
{ {
$param.= '&search_'.$key.'='.urlencode($search[$key]); $param.= '&search_'.$key.'='.urlencode($search[$key]);
} }
if ($optioncss != '') $param.='&optioncss='.urlencode($optioncss); if ($optioncss != '') $param.='&optioncss='.urlencode($optioncss);
// Add $param from extra fields // Add $param from extra fields
foreach ($search_array_options as $key => $val) foreach ($search_array_options as $key => $val)
{ {
$crit=$val; $crit=$val;
$tmpkey=preg_replace('/search_options_/','',$key); $tmpkey=preg_replace('/search_options_/','',$key);
if ($val != '') $param.='&search_options_'.$tmpkey.'='.urlencode($val); if ($val != '') $param.='&search_options_'.$tmpkey.'='.urlencode($val);
} }
// List of mass actions available // List of mass actions available
$arrayofmassactions = array( $arrayofmassactions = array(
//'presend'=>$langs->trans("SendByMail"), //'presend'=>$langs->trans("SendByMail"),
//'builddoc'=>$langs->trans("PDFMerge"), //'builddoc'=>$langs->trans("PDFMerge"),
); );
if ($user->rights->monmodule->delete) $arrayofmassactions['delete']=$langs->trans("Delete"); if ($user->rights->monmodule->delete) $arrayofmassactions['delete']=$langs->trans("Delete");
if ($massaction == 'presend') $arrayofmassactions=array(); if ($massaction == 'presend') $arrayofmassactions=array();
@ -347,7 +347,7 @@ if (! empty($moreforfilter))
{ {
print '<div class="liste_titre liste_titre_bydiv centpercent">'; print '<div class="liste_titre liste_titre_bydiv centpercent">';
print $moreforfilter; print $moreforfilter;
print '</div>'; print '</div>';
} }
$varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage; $varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage;
@ -363,35 +363,35 @@ print '<table class="tagtable liste'.($moreforfilter?" listwithfilterbefore":"")
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
foreach($object->fields as $key => $val) foreach($object->fields as $key => $val)
{ {
if (in_array($key, array('date_creation', 'tms', 'import_key', 'status'))) continue; if (in_array($key, array('date_creation', 'tms', 'import_key', 'status'))) continue;
$align=''; $align='';
if (in_array($val['type'], array('date','datetime','timestamp'))) $align='center'; if (in_array($val['type'], array('date','datetime','timestamp'))) $align='center';
if (in_array($val['type'], array('timestamp'))) $align.=' nowrap'; if (in_array($val['type'], array('timestamp'))) $align.=' nowrap';
if ($key == 'status') $align.=($align?' ':'').'center'; if ($key == 'status') $align.=($align?' ':'').'center';
if (! empty($arrayfields['t.'.$key]['checked'])) print '<td class="liste_titre'.($align?' '.$align:'').'"><input type="text" class="flat maxwidth75" name="search_'.$key.'" value="'.dol_escape_htmltag($search[$key]).'"></td>'; if (! empty($arrayfields['t.'.$key]['checked'])) print '<td class="liste_titre'.($align?' '.$align:'').'"><input type="text" class="flat maxwidth75" name="search_'.$key.'" value="'.dol_escape_htmltag($search[$key]).'"></td>';
} }
// Extra fields // Extra fields
if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label))
{ {
foreach($extrafields->attribute_label as $key => $val) foreach($extrafields->attribute_label as $key => $val)
{ {
if (! empty($arrayfields["ef.".$key]['checked'])) if (! empty($arrayfields["ef.".$key]['checked']))
{ {
$align=$extrafields->getAlignFlag($key); $align=$extrafields->getAlignFlag($key);
$typeofextrafield=$extrafields->attribute_type[$key]; $typeofextrafield=$extrafields->attribute_type[$key];
print '<td class="liste_titre'.($align?' '.$align:'').'">'; print '<td class="liste_titre'.($align?' '.$align:'').'">';
if (in_array($typeofextrafield, array('varchar', 'int', 'double', 'select')) && empty($extrafields->attribute_computed[$key])) if (in_array($typeofextrafield, array('varchar', 'int', 'double', 'select')) && empty($extrafields->attribute_computed[$key]))
{ {
$crit=$val; $crit=$val;
$tmpkey=preg_replace('/search_options_/','',$key); $tmpkey=preg_replace('/search_options_/','',$key);
$searchclass=''; $searchclass='';
if (in_array($typeofextrafield, array('varchar', 'select'))) $searchclass='searchstring'; if (in_array($typeofextrafield, array('varchar', 'select'))) $searchclass='searchstring';
if (in_array($typeofextrafield, array('int', 'double'))) $searchclass='searchnum'; if (in_array($typeofextrafield, array('int', 'double'))) $searchclass='searchnum';
print '<input class="flat'.($searchclass?' '.$searchclass:'').'" size="4" type="text" name="search_options_'.$tmpkey.'" value="'.dol_escape_htmltag($search_array_options['search_options_'.$tmpkey]).'">'; print '<input class="flat'.($searchclass?' '.$searchclass:'').'" size="4" type="text" name="search_options_'.$tmpkey.'" value="'.dol_escape_htmltag($search_array_options['search_options_'.$tmpkey]).'">';
} }
print '</td>'; print '</td>';
} }
} }
} }
// Fields from hook // Fields from hook
$parameters=array('arrayfields'=>$arrayfields); $parameters=array('arrayfields'=>$arrayfields);
@ -400,12 +400,12 @@ print $hookmanager->resPrint;
// Rest of fields search // Rest of fields search
foreach($object->fields as $key => $val) foreach($object->fields as $key => $val)
{ {
if (! in_array($key, array('date_creation', 'tms', 'import_key', 'status'))) continue; if (! in_array($key, array('date_creation', 'tms', 'import_key', 'status'))) continue;
$align=''; $align='';
if (in_array($val['type'], array('date','datetime','timestamp'))) $align='center'; if (in_array($val['type'], array('date','datetime','timestamp'))) $align='center';
if (in_array($val['type'], array('timestamp'))) $align.=' nowrap'; if (in_array($val['type'], array('timestamp'))) $align.=' nowrap';
if ($key == 'status') $align.=($align?' ':'').'center'; if ($key == 'status') $align.=($align?' ':'').'center';
if (! empty($arrayfields['t.'.$key]['checked'])) print '<td class="liste_titre'.($align?' '.$align:'').'"><input type="text" class="flat maxwidth75" name="search_'.$key.'" value="'.dol_escape_htmltag($search[$key]).'"></td>'; if (! empty($arrayfields['t.'.$key]['checked'])) print '<td class="liste_titre'.($align?' '.$align:'').'"><input type="text" class="flat maxwidth75" name="search_'.$key.'" value="'.dol_escape_htmltag($search[$key]).'"></td>';
} }
// Action column // Action column
print '<td class="liste_titre" align="right">'; print '<td class="liste_titre" align="right">';
@ -420,25 +420,25 @@ print '</tr>'."\n";
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
foreach($object->fields as $key => $val) foreach($object->fields as $key => $val)
{ {
if (in_array($key, array('date_creation', 'tms', 'import_key', 'status'))) continue; if (in_array($key, array('date_creation', 'tms', 'import_key', 'status'))) continue;
$align=''; $align='';
if (in_array($val['type'], array('date','datetime','timestamp'))) $align='center'; if (in_array($val['type'], array('date','datetime','timestamp'))) $align='center';
if (in_array($val['type'], array('timestamp'))) $align.='nowrap'; if (in_array($val['type'], array('timestamp'))) $align.='nowrap';
if ($key == 'status') $align.=($align?' ':'').'center'; if ($key == 'status') $align.=($align?' ':'').'center';
if (! empty($arrayfields['t.'.$key]['checked'])) print getTitleFieldOfList($arrayfields['t.'.$key]['label'], 0, $_SERVER['PHP_SELF'], 't.'.$key, '', $param, ($align?'class="'.$align.'"':''), $sortfield, $sortorder, $align.' ')."\n"; if (! empty($arrayfields['t.'.$key]['checked'])) print getTitleFieldOfList($arrayfields['t.'.$key]['label'], 0, $_SERVER['PHP_SELF'], 't.'.$key, '', $param, ($align?'class="'.$align.'"':''), $sortfield, $sortorder, $align.' ')."\n";
} }
// Extra fields // Extra fields
if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label))
{ {
foreach($extrafields->attribute_label as $key => $val) foreach($extrafields->attribute_label as $key => $val)
{ {
if (! empty($arrayfields["ef.".$key]['checked'])) if (! empty($arrayfields["ef.".$key]['checked']))
{ {
$align=$extrafields->getAlignFlag($key); $align=$extrafields->getAlignFlag($key);
$sortonfield = "ef.".$key; $sortonfield = "ef.".$key;
if (! empty($extrafields->attribute_computed[$key])) $sortonfield=''; if (! empty($extrafields->attribute_computed[$key])) $sortonfield='';
print getTitleFieldOfList($langs->trans($extralabels[$key]), 0, $_SERVER["PHP_SELF"], $sortonfield, "", $param, ($align?'align="'.$align.'"':''), $sortfield, $sortorder)."\n"; print getTitleFieldOfList($langs->trans($extralabels[$key]), 0, $_SERVER["PHP_SELF"], $sortonfield, "", $param, ($align?'align="'.$align.'"':''), $sortfield, $sortorder)."\n";
} }
} }
} }
// Hook fields // Hook fields
@ -448,12 +448,12 @@ print $hookmanager->resPrint;
// Rest of fields title // Rest of fields title
foreach($object->fields as $key => $val) foreach($object->fields as $key => $val)
{ {
if (! in_array($key, array('date_creation', 'tms', 'import_key', 'status'))) continue; if (! in_array($key, array('date_creation', 'tms', 'import_key', 'status'))) continue;
$align=''; $align='';
if (in_array($val['type'], array('date','datetime','timestamp'))) $align='center'; if (in_array($val['type'], array('date','datetime','timestamp'))) $align='center';
if (in_array($val['type'], array('timestamp'))) $align.=' nowrap'; if (in_array($val['type'], array('timestamp'))) $align.=' nowrap';
if ($key == 'status') $align.=($align?' ':'').'center'; if ($key == 'status') $align.=($align?' ':'').'center';
if (! empty($arrayfields['t.'.$key]['checked'])) print getTitleFieldOfList($arrayfields['t.'.$key]['label'], 0, $_SERVER['PHP_SELF'], 't.'.$key, '', $param, ($align?'class="'.$align.'"':''), $sortfield, $sortorder, $align.' ')."\n"; if (! empty($arrayfields['t.'.$key]['checked'])) print getTitleFieldOfList($arrayfields['t.'.$key]['label'], 0, $_SERVER['PHP_SELF'], 't.'.$key, '', $param, ($align?'class="'.$align.'"':''), $sortfield, $sortorder, $align.' ')."\n";
} }
print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"],"",'','','align="center"',$sortfield,$sortorder,'maxwidthsearch ')."\n"; print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"],"",'','','align="center"',$sortfield,$sortorder,'maxwidthsearch ')."\n";
print '</tr>'."\n"; print '</tr>'."\n";
@ -463,7 +463,7 @@ print '</tr>'."\n";
$needToFetchEachLine=0; $needToFetchEachLine=0;
foreach ($extrafields->attribute_computed as $key => $val) foreach ($extrafields->attribute_computed as $key => $val)
{ {
if (preg_match('/\$object/',$val)) $needToFetchEachLine++; // There is at least one compute field that use $object if (preg_match('/\$object/',$val)) $needToFetchEachLine++; // There is at least one compute field that use $object
} }
@ -473,42 +473,42 @@ $i=0;
$totalarray=array(); $totalarray=array();
while ($i < min($num, $limit)) while ($i < min($num, $limit))
{ {
$obj = $db->fetch_object($resql); $obj = $db->fetch_object($resql);
if (empty($obj)) break; // Should not happen if (empty($obj)) break; // Should not happen
// Store properties in $object // Store properties in $object
$object->id = $obj->rowid; $object->id = $obj->rowid;
foreach($object->fields as $key => $val) foreach($object->fields as $key => $val)
{ {
if (isset($obj->$key)) $object->$key = $obj->$key; if (isset($obj->$key)) $object->$key = $obj->$key;
} }
// Show here line of result // Show here line of result
print '<tr class="oddeven">'; print '<tr class="oddeven">';
foreach($object->fields as $key => $val) foreach($object->fields as $key => $val)
{ {
if (in_array($key, array('date_creation', 'tms', 'import_key', 'status'))) continue; if (in_array($key, array('date_creation', 'tms', 'import_key', 'status'))) continue;
$align=''; $align='';
if (in_array($val['type'], array('date','datetime','timestamp'))) $align='center'; if (in_array($val['type'], array('date','datetime','timestamp'))) $align='center';
if (in_array($val['type'], array('timestamp'))) $align.='nowrap'; if (in_array($val['type'], array('timestamp'))) $align.='nowrap';
if ($key == 'status') $align.=($align?' ':'').'center'; if ($key == 'status') $align.=($align?' ':'').'center';
if (! empty($arrayfields['t.'.$key]['checked'])) if (! empty($arrayfields['t.'.$key]['checked']))
{ {
print '<td'.($align?' class="'.$align.'"':'').'>'; print '<td'.($align?' class="'.$align.'"':'').'>';
if (in_array($val['type'], array('date','datetime','timestamp'))) print dol_print_date($db->jdate($obj->$key), 'dayhour'); if (in_array($val['type'], array('date','datetime','timestamp'))) print dol_print_date($db->jdate($obj->$key), 'dayhour');
elseif ($key == 'ref') print $object->getNomUrl(1, '', 0, '', 1); elseif ($key == 'ref') print $object->getNomUrl(1, '', 0, '', 1);
elseif ($key == 'status') print $object->getLibStatut(3); elseif ($key == 'status') print $object->getLibStatut(3);
else print $obj->$key; else print $obj->$key;
print '</td>'; print '</td>';
if (! $i) $totalarray['nbfield']++; if (! $i) $totalarray['nbfield']++;
if (! empty($val['isameasure'])) if (! empty($val['isameasure']))
{ {
if (! $i) $totalarray['pos'][$totalarray['nbfield']]='t.'.$key; if (! $i) $totalarray['pos'][$totalarray['nbfield']]='t.'.$key;
$totalarray['val']['t.'.$key] += $obj->$key; $totalarray['val']['t.'.$key] += $obj->$key;
} }
} }
} }
// Extra fields // Extra fields
if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label))
{ {
foreach($extrafields->attribute_label as $key => $val) foreach($extrafields->attribute_label as $key => $val)
@ -522,86 +522,86 @@ while ($i < min($num, $limit))
$tmpkey='options_'.$key; $tmpkey='options_'.$key;
print $extrafields->showOutputField($key, $obj->$tmpkey, '', 1); print $extrafields->showOutputField($key, $obj->$tmpkey, '', 1);
print '</td>'; print '</td>';
if (! $i) $totalarray['nbfield']++; if (! $i) $totalarray['nbfield']++;
if (! empty($val['isameasure'])) if (! empty($val['isameasure']))
{ {
if (! $i) $totalarray['pos'][$totalarray['nbfield']]='ef.'.$tmpkey; if (! $i) $totalarray['pos'][$totalarray['nbfield']]='ef.'.$tmpkey;
$totalarray['val']['ef.'.$tmpkey] += $obj->$tmpkey; $totalarray['val']['ef.'.$tmpkey] += $obj->$tmpkey;
} }
} }
} }
} }
// Fields from hook // Fields from hook
$parameters=array('arrayfields'=>$arrayfields, 'obj'=>$obj); $parameters=array('arrayfields'=>$arrayfields, 'obj'=>$obj);
$reshook=$hookmanager->executeHooks('printFieldListValue', $parameters, $object); // Note that $action and $object may have been modified by hook $reshook=$hookmanager->executeHooks('printFieldListValue', $parameters, $object); // Note that $action and $object may have been modified by hook
print $hookmanager->resPrint; print $hookmanager->resPrint;
// Rest of fields // Rest of fields
foreach($object->fields as $key => $val) foreach($object->fields as $key => $val)
{ {
if (! in_array($key, array('date_creation', 'tms', 'import_key', 'status'))) continue; if (! in_array($key, array('date_creation', 'tms', 'import_key', 'status'))) continue;
$align=''; $align='';
if (in_array($val['type'], array('date','datetime','timestamp'))) $align.=($align?' ':'').'center'; if (in_array($val['type'], array('date','datetime','timestamp'))) $align.=($align?' ':'').'center';
if (in_array($val['type'], array('timestamp'))) $align.=($align?' ':'').'nowrap'; if (in_array($val['type'], array('timestamp'))) $align.=($align?' ':'').'nowrap';
if ($key == 'status') $align.=($align?' ':'').'center'; if ($key == 'status') $align.=($align?' ':'').'center';
if (! empty($arrayfields['t.'.$key]['checked'])) if (! empty($arrayfields['t.'.$key]['checked']))
{ {
print '<td'.($align?' class="'.$align.'"':'').'>'; print '<td'.($align?' class="'.$align.'"':'').'>';
if (in_array($val['type'], array('date','datetime','timestamp'))) print dol_print_date($db->jdate($obj->$key), 'dayhour'); if (in_array($val['type'], array('date','datetime','timestamp'))) print dol_print_date($db->jdate($obj->$key), 'dayhour');
elseif ($key == 'status') print $object->getLibStatut(3); elseif ($key == 'status') print $object->getLibStatut(3);
else print $obj->$key; else print $obj->$key;
print '</td>'; print '</td>';
if (! $i) $totalarray['nbfield']++; if (! $i) $totalarray['nbfield']++;
if (! empty($val['isameasure'])) if (! empty($val['isameasure']))
{ {
if (! $i) $totalarray['pos'][$totalarray['nbfield']]='t.'.$key; if (! $i) $totalarray['pos'][$totalarray['nbfield']]='t.'.$key;
$totalarray['val']['t.'.$key] += $obj->$key; $totalarray['val']['t.'.$key] += $obj->$key;
} }
} }
} }
// Action column // Action column
print '<td class="nowrap" align="center">'; print '<td class="nowrap" align="center">';
if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
{ {
$selected=0; $selected=0;
if (in_array($obj->rowid, $arrayofselected)) $selected=1; if (in_array($obj->rowid, $arrayofselected)) $selected=1;
print '<input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected?' checked="checked"':'').'>'; print '<input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected?' checked="checked"':'').'>';
} }
print '</td>'; print '</td>';
if (! $i) $totalarray['nbfield']++; if (! $i) $totalarray['nbfield']++;
print '</tr>'; print '</tr>';
$i++; $i++;
} }
// Show total line // Show total line
if (isset($totalarray['pos'])) if (isset($totalarray['pos']))
{ {
print '<tr class="liste_total">'; print '<tr class="liste_total">';
$i=0; $i=0;
while ($i < $totalarray['nbfield']) while ($i < $totalarray['nbfield'])
{ {
$i++; $i++;
if (! empty($totalarray['pos'][$i])) print '<td align="right">'.price($totalarray['val'][$totalarray['pos'][$i]]).'</td>'; if (! empty($totalarray['pos'][$i])) print '<td align="right">'.price($totalarray['val'][$totalarray['pos'][$i]]).'</td>';
else else
{ {
if ($i == 1) if ($i == 1)
{ {
if ($num < $limit) print '<td align="left">'.$langs->trans("Total").'</td>'; if ($num < $limit) print '<td align="left">'.$langs->trans("Total").'</td>';
else print '<td align="left">'.$langs->trans("Totalforthispage").'</td>'; else print '<td align="left">'.$langs->trans("Totalforthispage").'</td>';
} }
else print '<td></td>'; else print '<td></td>';
} }
} }
print '</tr>'; print '</tr>';
} }
// If no record found // If no record found
if ($num == 0) if ($num == 0)
{ {
$colspan=1; $colspan=1;
foreach($arrayfields as $key => $val) { if (! empty($val['checked'])) $colspan++; } foreach($arrayfields as $key => $val) { if (! empty($val['checked'])) $colspan++; }
print '<tr><td colspan="'.$colspan.'" class="opacitymedium">'.$langs->trans("NoRecordFound").'</td></tr>'; print '<tr><td colspan="'.$colspan.'" class="opacitymedium">'.$langs->trans("NoRecordFound").'</td></tr>';
} }
@ -618,25 +618,25 @@ print '</form>'."\n";
if (in_array('builddoc',$arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords)) if (in_array('builddoc',$arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords))
{ {
if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files)
{ {
require_once(DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'); require_once(DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php');
$formfile = new FormFile($db); $formfile = new FormFile($db);
// Show list of available documents // Show list of available documents
$urlsource=$_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder; $urlsource=$_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder;
$urlsource.=str_replace('&amp;','&',$param); $urlsource.=str_replace('&amp;','&',$param);
$filedir=$diroutputmassaction; $filedir=$diroutputmassaction;
$genallowed=$user->rights->monmodule->read; $genallowed=$user->rights->monmodule->read;
$delallowed=$user->rights->monmodule->read; $delallowed=$user->rights->monmodule->read;
print $formfile->showdocuments('massfilesarea_monmodule','',$filedir,$urlsource,0,$delallowed,'',1,1,0,48,1,$param,$title,''); print $formfile->showdocuments('massfilesarea_monmodule','',$filedir,$urlsource,0,$delallowed,'',1,1,0,48,1,$param,$title,'');
} }
else else
{ {
print '<br><a name="show_files"></a><a href="'.$_SERVER["PHP_SELF"].'?show_files=1'.$param.'#show_files">'.$langs->trans("ShowTempMassFilesArea").'</a>'; print '<br><a name="show_files"></a><a href="'.$_SERVER["PHP_SELF"].'?show_files=1'.$param.'#show_files">'.$langs->trans("ShowTempMassFilesArea").'</a>';
} }
} }
dol_fiche_end(); dol_fiche_end();

View File

@ -36,7 +36,7 @@ if (! $user->admin) accessforbidden();
if (! ((GETPOST('testmenuhider','int') || ! empty($conf->global->MAIN_TESTMENUHIDER)) && empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER))) if (! ((GETPOST('testmenuhider','int') || ! empty($conf->global->MAIN_TESTMENUHIDER)) && empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)))
{ {
$conf->dol_hide_leftmenu = 1; // Force hide of left menu. $conf->dol_hide_leftmenu = 1; // Force hide of left menu.
} }
$error=0; $error=0;
@ -71,33 +71,33 @@ if (GETPOST('refreshpage')) $action='preview';
// Add a collab page // Add a collab page
if ($action == 'add') if ($action == 'add')
{ {
$db->begin(); $db->begin();
$objectpage->title = GETPOST('WEBSITE_TITLE'); $objectpage->title = GETPOST('WEBSITE_TITLE');
$objectpage->pageurl = GETPOST('WEBSITE_PAGENAME'); $objectpage->pageurl = GETPOST('WEBSITE_PAGENAME');
$objectpage->description = GETPOST('WEBSITE_DESCRIPTION'); $objectpage->description = GETPOST('WEBSITE_DESCRIPTION');
$objectpage->keywords = GETPOST('WEBSITE_KEYWORD'); $objectpage->keywords = GETPOST('WEBSITE_KEYWORD');
if (empty($objectpage->title)) if (empty($objectpage->title))
{ {
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("WEBSITE_PAGENAME")), null, 'errors'); setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("WEBSITE_PAGENAME")), null, 'errors');
$error++; $error++;
} }
if (! $error) if (! $error)
{ {
$res = $objectpage->create($user); $res = $objectpage->create($user);
if ($res <= 0) if ($res <= 0)
{ {
$error++; $error++;
setEventMessages($objectpage->error, $objectpage->errors, 'errors'); setEventMessages($objectpage->error, $objectpage->errors, 'errors');
} }
} }
if (! $error) if (! $error)
{ {
$db->commit(); $db->commit();
setEventMessages($langs->trans("PageAdded", $objectpage->pageurl), null, 'mesgs'); setEventMessages($langs->trans("PageAdded", $objectpage->pageurl), null, 'mesgs');
$action=''; $action='';
} }
else else
{ {
@ -111,38 +111,38 @@ if ($action == 'add')
// Update page // Update page
if ($action == 'delete') if ($action == 'delete')
{ {
$db->begin(); $db->begin();
$res = $object->fetch(0, $website); $res = $object->fetch(0, $website);
$res = $objectpage->fetch($pageid, $object->fk_website); $res = $objectpage->fetch($pageid, $object->fk_website);
if ($res > 0) if ($res > 0)
{ {
$res = $objectpage->delete($user); $res = $objectpage->delete($user);
if (! $res > 0) if (! $res > 0)
{ {
$error++; $error++;
setEventMessages($objectpage->error, $objectpage->errors, 'errors'); setEventMessages($objectpage->error, $objectpage->errors, 'errors');
} }
if (! $error) if (! $error)
{ {
$db->commit(); $db->commit();
setEventMessages($langs->trans("PageDeleted", $objectpage->pageurl, $website), null, 'mesgs'); setEventMessages($langs->trans("PageDeleted", $objectpage->pageurl, $website), null, 'mesgs');
header("Location: ".$_SERVER["PHP_SELF"].'?website='.$website); header("Location: ".$_SERVER["PHP_SELF"].'?website='.$website);
exit; exit;
} }
else else
{ {
$db->rollback(); $db->rollback();
} }
} }
else else
{ {
dol_print_error($db); dol_print_error($db);
} }
} }
@ -161,7 +161,7 @@ print "\n".'<form action="'.$_SERVER["PHP_SELF"].'" method="POST"><div>';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
if ($action == 'create') if ($action == 'create')
{ {
print '<input type="hidden" name="action" value="add">'; print '<input type="hidden" name="action" value="add">';
} }
@ -174,225 +174,225 @@ print '<div class="centpercent websitebar">';
if (count($object->records) > 0) if (count($object->records) > 0)
{ {
// ***** Part for web sites // ***** Part for web sites
print '<div class="websiteselection hideonsmartphoneimp">'; print '<div class="websiteselection hideonsmartphoneimp">';
print $langs->trans("Website").': '; print $langs->trans("Website").': ';
print '</div>'; print '</div>';
// List of websites // List of websites
print '<div class="websiteselection">'; print '<div class="websiteselection">';
$out=''; $out='';
$out.='<select name="website" class="minwidth100" id="website">'; $out.='<select name="website" class="minwidth100" id="website">';
if (empty($object->records)) $out.='<option value="-1">&nbsp;</option>'; if (empty($object->records)) $out.='<option value="-1">&nbsp;</option>';
// Loop on each sites // Loop on each sites
$i=0; $i=0;
foreach($object->records as $key => $valwebsite) foreach($object->records as $key => $valwebsite)
{ {
if (empty($website)) $website=$valwebsite->ref; if (empty($website)) $website=$valwebsite->ref;
$out.='<option value="'.$valwebsite->ref.'"'; $out.='<option value="'.$valwebsite->ref.'"';
if ($website == $valwebsite->ref) $out.=' selected'; // To preselect a value if ($website == $valwebsite->ref) $out.=' selected'; // To preselect a value
$out.='>'; $out.='>';
$out.=$valwebsite->ref; $out.=$valwebsite->ref;
$out.='</option>'; $out.='</option>';
$i++; $i++;
} }
$out.='</select>'; $out.='</select>';
$out.=ajax_combobox('website'); $out.=ajax_combobox('website');
print $out; print $out;
print '<input type="submit" class="button" name="refreshsite" value="'.$langs->trans("Load").'">'; print '<input type="submit" class="button" name="refreshsite" value="'.$langs->trans("Load").'">';
if ($website) if ($website)
{ {
$virtualurl=''; $virtualurl='';
$dataroot=DOL_DATA_ROOT.'/websites/'.$website; $dataroot=DOL_DATA_ROOT.'/websites/'.$website;
if (! empty($object->virtualhost)) $virtualurl=$object->virtualhost; if (! empty($object->virtualhost)) $virtualurl=$object->virtualhost;
} }
if ($website && $action == 'preview') if ($website && $action == 'preview')
{ {
$disabled=''; $disabled='';
if (empty($user->rights->websites->write)) $disabled=' disabled="disabled"'; if (empty($user->rights->websites->write)) $disabled=' disabled="disabled"';
print ' &nbsp; '; print ' &nbsp; ';
//print '<input type="submit" class="button"'.$disabled.' value="'.dol_escape_htmltag($langs->trans("MediaFiles")).'" name="editmedia">'; //print '<input type="submit" class="button"'.$disabled.' value="'.dol_escape_htmltag($langs->trans("MediaFiles")).'" name="editmedia">';
print '<input type="submit" class="button"'.$disabled.' value="'.dol_escape_htmltag($langs->trans("EditCss")).'" name="editcss">'; print '<input type="submit" class="button"'.$disabled.' value="'.dol_escape_htmltag($langs->trans("EditCss")).'" name="editcss">';
print '<input type="submit" class="button"'.$disabled.' value="'.dol_escape_htmltag($langs->trans("EditMenu")).'" name="editmenu">'; print '<input type="submit" class="button"'.$disabled.' value="'.dol_escape_htmltag($langs->trans("EditMenu")).'" name="editmenu">';
print '<input type="submit"'.$disabled.' class="button" value="'.dol_escape_htmltag($langs->trans("AddPage")).'" name="create">'; print '<input type="submit"'.$disabled.' class="button" value="'.dol_escape_htmltag($langs->trans("AddPage")).'" name="create">';
} }
print '</div>'; print '</div>';
// Button for websites // Button for websites
print '<div class="websitetools">'; print '<div class="websitetools">';
if ($action == 'preview') if ($action == 'preview')
{ {
print '<div class="websiteinputurl">'; print '<div class="websiteinputurl">';
print '<input type="text" id="previewsiteurl" class="minwidth200imp" name="previewsite" placeholder="'.$langs->trans("http://myvirtualhost").'" value="'.$virtualurl.'">'; print '<input type="text" id="previewsiteurl" class="minwidth200imp" name="previewsite" placeholder="'.$langs->trans("http://myvirtualhost").'" value="'.$virtualurl.'">';
//print '<input type="submit" class="button" name="previewwebsite" target="tab'.$website.'" value="'.$langs->trans("ViewSiteInNewTab").'">'; //print '<input type="submit" class="button" name="previewwebsite" target="tab'.$website.'" value="'.$langs->trans("ViewSiteInNewTab").'">';
$htmltext=$langs->trans("SetHereVirtualHost", $dataroot); $htmltext=$langs->trans("SetHereVirtualHost", $dataroot);
print $form->textwithpicto('', $htmltext); print $form->textwithpicto('', $htmltext);
print '</div>'; print '</div>';
$urlext=$virtualurl; $urlext=$virtualurl;
$urlint=$urlwithroot.'/public/websites/index.php?website='.$website; $urlint=$urlwithroot.'/public/websites/index.php?website='.$website;
//if (! empty($object->virtualhost)) //if (! empty($object->virtualhost))
//{ //{
print '<a class="websitebuttonsitepreview" id="previewsiteext" href="'.$urlext.'" target="tab'.$website.'" alt="'.dol_escape_htmltag($langs->trans("PreviewSiteServedByWebServer", $langs->transnoentitiesnoconv("Site"), $langs->transnoentitiesnoconv("Site"), $dataroot, $urlext)).'">'; print '<a class="websitebuttonsitepreview" id="previewsiteext" href="'.$urlext.'" target="tab'.$website.'" alt="'.dol_escape_htmltag($langs->trans("PreviewSiteServedByWebServer", $langs->transnoentitiesnoconv("Site"), $langs->transnoentitiesnoconv("Site"), $dataroot, $urlext)).'">';
print $form->textwithpicto('', $langs->trans("PreviewSiteServedByWebServer", $langs->transnoentitiesnoconv("Site"), $langs->transnoentitiesnoconv("Site"), $dataroot, $urlext?$urlext:$langs->trans("VirtualHostUrlNotDefined")), 1, 'preview_ext'); print $form->textwithpicto('', $langs->trans("PreviewSiteServedByWebServer", $langs->transnoentitiesnoconv("Site"), $langs->transnoentitiesnoconv("Site"), $dataroot, $urlext?$urlext:$langs->trans("VirtualHostUrlNotDefined")), 1, 'preview_ext');
print '</a>'; print '</a>';
//} //}
print '<a class="websitebuttonsitepreview" id="previewsite" href="'.$urlwithroot.'/public/websites/index.php?website='.$website.'" target="tab'.$website.'" alt="'.dol_escape_htmltag($langs->trans("PreviewSiteServedByDolibarr", $langs->transnoentitiesnoconv("Site"), $langs->transnoentitiesnoconv("Site"), $urlint)).'">'; print '<a class="websitebuttonsitepreview" id="previewsite" href="'.$urlwithroot.'/public/websites/index.php?website='.$website.'" target="tab'.$website.'" alt="'.dol_escape_htmltag($langs->trans("PreviewSiteServedByDolibarr", $langs->transnoentitiesnoconv("Site"), $langs->transnoentitiesnoconv("Site"), $urlint)).'">';
print $form->textwithpicto('', $langs->trans("PreviewSiteServedByDolibarr", $langs->transnoentitiesnoconv("Site"), $langs->transnoentitiesnoconv("Site"), $urlint, $dataroot), 1, 'preview'); print $form->textwithpicto('', $langs->trans("PreviewSiteServedByDolibarr", $langs->transnoentitiesnoconv("Site"), $langs->transnoentitiesnoconv("Site"), $urlint, $dataroot), 1, 'preview');
print '</a>'; print '</a>';
} }
if (in_array($action, array('editcss','editmenu','create'))) if (in_array($action, array('editcss','editmenu','create')))
{ {
if ($action != 'preview') print '<input type="submit" class="button" value="'.dol_escape_htmltag($langs->trans("Cancel")).'" name="preview">'; if ($action != 'preview') print '<input type="submit" class="button" value="'.dol_escape_htmltag($langs->trans("Cancel")).'" name="preview">';
if (preg_match('/^create/',$action)) print '<input type="submit" class="button" value="'.dol_escape_htmltag($langs->trans("Save")).'" name="update">'; if (preg_match('/^create/',$action)) print '<input type="submit" class="button" value="'.dol_escape_htmltag($langs->trans("Save")).'" name="update">';
if (preg_match('/^edit/',$action)) print '<input type="submit" class="button" value="'.dol_escape_htmltag($langs->trans("Save")).'" name="update">'; if (preg_match('/^edit/',$action)) print '<input type="submit" class="button" value="'.dol_escape_htmltag($langs->trans("Save")).'" name="update">';
} }
print '</div>'; print '</div>';
// ***** Part for pages // ***** Part for pages
if ($website) if ($website)
{ {
print '</div>'; print '</div>';
$array=$objectpage->fetchAll($object->id); $array=$objectpage->fetchAll($object->id);
if (! is_array($array) && $array < 0) dol_print_error('', $objectpage->error, $objectpage->errors); if (! is_array($array) && $array < 0) dol_print_error('', $objectpage->error, $objectpage->errors);
$atleastonepage=(is_array($array) && count($array) > 0); $atleastonepage=(is_array($array) && count($array) > 0);
print '<div class="centpercent websitebar"'.($style?' style="'.$style.'"':'').'">'; print '<div class="centpercent websitebar"'.($style?' style="'.$style.'"':'').'">';
print '<div class="websiteselection hideonsmartphoneimp">'; print '<div class="websiteselection hideonsmartphoneimp">';
print $langs->trans("Page").': '; print $langs->trans("Page").': ';
print '</div>'; print '</div>';
print '<div class="websiteselection">'; print '<div class="websiteselection">';
if ($action != 'add') if ($action != 'add')
{ {
$out=''; $out='';
$out.='<select name="pageid" id="pageid" class="minwidth200">'; $out.='<select name="pageid" id="pageid" class="minwidth200">';
if ($atleastonepage) if ($atleastonepage)
{ {
if (empty($pageid) && $action != 'create') // Page id is not defined, we try to take one if (empty($pageid) && $action != 'create') // Page id is not defined, we try to take one
{ {
$firstpageid=0;$homepageid=0; $firstpageid=0;$homepageid=0;
foreach($array as $key => $valpage) foreach($array as $key => $valpage)
{ {
if (empty($firstpageid)) $firstpageid=$valpage->id; if (empty($firstpageid)) $firstpageid=$valpage->id;
if ($object->fk_default_home && $key == $object->fk_default_home) $homepageid=$valpage->id; if ($object->fk_default_home && $key == $object->fk_default_home) $homepageid=$valpage->id;
} }
$pageid=$homepageid?$homepageid:$firstpageid; // We choose home page and if not defined yet, we take first page $pageid=$homepageid?$homepageid:$firstpageid; // We choose home page and if not defined yet, we take first page
} }
foreach($array as $key => $valpage) foreach($array as $key => $valpage)
{ {
$out.='<option value="'.$key.'"'; $out.='<option value="'.$key.'"';
if ($pageid > 0 && $pageid == $key) $out.=' selected'; // To preselect a value if ($pageid > 0 && $pageid == $key) $out.=' selected'; // To preselect a value
$out.='>'; $out.='>';
$out.=$valpage->title; $out.=$valpage->title;
if ($object->fk_default_home && $key == $object->fk_default_home) $out.=' ('.$langs->trans("HomePage").')'; if ($object->fk_default_home && $key == $object->fk_default_home) $out.=' ('.$langs->trans("HomePage").')';
$out.='</option>'; $out.='</option>';
} }
} }
else $out.='<option value="-1">&nbsp;</option>'; else $out.='<option value="-1">&nbsp;</option>';
$out.='</select>'; $out.='</select>';
$out.=ajax_combobox('pageid'); $out.=ajax_combobox('pageid');
print $out; print $out;
} }
else else
{ {
print $langs->trans("New"); print $langs->trans("New");
} }
print '<input type="submit" class="button" name="refreshpage" value="'.$langs->trans("Load").'"'.($atleastonepage?'':' disabled="disabled"').'>'; print '<input type="submit" class="button" name="refreshpage" value="'.$langs->trans("Load").'"'.($atleastonepage?'':' disabled="disabled"').'>';
//print $form->selectarray('page', $array); //print $form->selectarray('page', $array);
if ($action == 'preview') if ($action == 'preview')
{ {
$disabled=''; $disabled='';
if (empty($user->rights->websites->write)) $disabled=' disabled="disabled"'; if (empty($user->rights->websites->write)) $disabled=' disabled="disabled"';
if ($pageid > 0) if ($pageid > 0)
{ {
print ' &nbsp; '; print ' &nbsp; ';
if ($object->fk_default_home > 0 && $pageid == $object->fk_default_home) print '<input type="submit" class="button" disabled="disabled" value="'.dol_escape_htmltag($langs->trans("SetAsHomePage")).'" name="setashome">'; if ($object->fk_default_home > 0 && $pageid == $object->fk_default_home) print '<input type="submit" class="button" disabled="disabled" value="'.dol_escape_htmltag($langs->trans("SetAsHomePage")).'" name="setashome">';
else print '<input type="submit" class="button"'.$disabled.' value="'.dol_escape_htmltag($langs->trans("SetAsHomePage")).'" name="setashome">'; else print '<input type="submit" class="button"'.$disabled.' value="'.dol_escape_htmltag($langs->trans("SetAsHomePage")).'" name="setashome">';
print '<input type="submit" class="button"'.$disabled.' value="'.dol_escape_htmltag($langs->trans("EditPageMeta")).'" name="editmeta">'; print '<input type="submit" class="button"'.$disabled.' value="'.dol_escape_htmltag($langs->trans("EditPageMeta")).'" name="editmeta">';
print '<input type="submit" class="button"'.$disabled.' value="'.dol_escape_htmltag($langs->trans("EditPageContent")).'" name="editcontent">'; print '<input type="submit" class="button"'.$disabled.' value="'.dol_escape_htmltag($langs->trans("EditPageContent")).'" name="editcontent">';
//print '<a href="'.$_SERVER["PHP_SELF"].'?action=editmeta&website='.urlencode($website).'&pageid='.urlencode($pageid).'" class="button">'.dol_escape_htmltag($langs->trans("EditPageMeta")).'</a>'; //print '<a href="'.$_SERVER["PHP_SELF"].'?action=editmeta&website='.urlencode($website).'&pageid='.urlencode($pageid).'" class="button">'.dol_escape_htmltag($langs->trans("EditPageMeta")).'</a>';
//print '<a href="'.$_SERVER["PHP_SELF"].'?action=editcontent&website='.urlencode($website).'&pageid='.urlencode($pageid).'" class="button">'.dol_escape_htmltag($langs->trans("EditPageContent")).'</a>'; //print '<a href="'.$_SERVER["PHP_SELF"].'?action=editcontent&website='.urlencode($website).'&pageid='.urlencode($pageid).'" class="button">'.dol_escape_htmltag($langs->trans("EditPageContent")).'</a>';
print '<input type="submit" class="buttonDelete" name="delete" value="'.$langs->trans("Delete").'"'.($atleastonepage?'':' disabled="disabled"').'>'; print '<input type="submit" class="buttonDelete" name="delete" value="'.$langs->trans("Delete").'"'.($atleastonepage?'':' disabled="disabled"').'>';
} }
} }
print '</div>'; print '</div>';
print '<div class="websiteselection">'; print '<div class="websiteselection">';
print '</div>'; print '</div>';
print '<div class="websitetools">'; print '<div class="websitetools">';
if ($website && $pageid > 0 && $action == 'preview') if ($website && $pageid > 0 && $action == 'preview')
{ {
$websitepage = new WebSitePage($db); $websitepage = new WebSitePage($db);
$websitepage->fetch($pageid); $websitepage->fetch($pageid);
$realpage=$urlwithroot.'/public/websites/index.php?website='.$website.'&page='.$pageid; $realpage=$urlwithroot.'/public/websites/index.php?website='.$website.'&page='.$pageid;
$pagealias = $websitepage->pageurl; $pagealias = $websitepage->pageurl;
print '<div class="websiteinputurl">'; print '<div class="websiteinputurl">';
print '<input type="text" id="previewpageurl" class="minwidth200imp" name="previewsite" value="'.$pagealias.'" disabled="disabled">'; print '<input type="text" id="previewpageurl" class="minwidth200imp" name="previewsite" value="'.$pagealias.'" disabled="disabled">';
//print '<input type="submit" class="button" name="previewwebsite" target="tab'.$website.'" value="'.$langs->trans("ViewSiteInNewTab").'">'; //print '<input type="submit" class="button" name="previewwebsite" target="tab'.$website.'" value="'.$langs->trans("ViewSiteInNewTab").'">';
$htmltext=$langs->trans("WEBSITE_PAGENAME", $pagealias); $htmltext=$langs->trans("WEBSITE_PAGENAME", $pagealias);
print $form->textwithpicto('', $htmltext); print $form->textwithpicto('', $htmltext);
print '</div>'; print '</div>';
if (! empty($object->virtualhost)) if (! empty($object->virtualhost))
{ {
$urlext=$virtualurl.'/'.$pagealias.'.php'; $urlext=$virtualurl.'/'.$pagealias.'.php';
print '<a class="websitebuttonsitepreview" id="previewpageext" href="'.$urlext.'" target="tab'.$website.'" alt="'.dol_escape_htmltag($langs->trans("PreviewSiteServedByWebServer", $langs->transnoentitiesnoconv("Page"), $langs->transnoentitiesnoconv("Page"), $dataroot, $urlext)).'">'; print '<a class="websitebuttonsitepreview" id="previewpageext" href="'.$urlext.'" target="tab'.$website.'" alt="'.dol_escape_htmltag($langs->trans("PreviewSiteServedByWebServer", $langs->transnoentitiesnoconv("Page"), $langs->transnoentitiesnoconv("Page"), $dataroot, $urlext)).'">';
print $form->textwithpicto('', $langs->trans("PreviewSiteServedByWebServer", $langs->transnoentitiesnoconv("Page"), $langs->transnoentitiesnoconv("Page"), $dataroot, $urlext?$urlext:$langs->trans("VirtualHostUrlNotDefined")), 1, 'preview_ext'); print $form->textwithpicto('', $langs->trans("PreviewSiteServedByWebServer", $langs->transnoentitiesnoconv("Page"), $langs->transnoentitiesnoconv("Page"), $dataroot, $urlext?$urlext:$langs->trans("VirtualHostUrlNotDefined")), 1, 'preview_ext');
print '</a>'; print '</a>';
} }
else else
{ {
print '<a class="websitebuttonsitepreview" id="previewpageextnoclick" href="#">'; print '<a class="websitebuttonsitepreview" id="previewpageextnoclick" href="#">';
print $form->textwithpicto('', $langs->trans("PreviewSiteServedByWebServer", $langs->transnoentitiesnoconv("Page"), $langs->transnoentitiesnoconv("Page"), $dataroot, $urlext?$urlext:$langs->trans("VirtualHostUrlNotDefined")), 1, 'preview_ext'); print $form->textwithpicto('', $langs->trans("PreviewSiteServedByWebServer", $langs->transnoentitiesnoconv("Page"), $langs->transnoentitiesnoconv("Page"), $dataroot, $urlext?$urlext:$langs->trans("VirtualHostUrlNotDefined")), 1, 'preview_ext');
print '</a>'; print '</a>';
} }
print '<a class="websitebuttonsitepreview" id="previewpage" href="'.$realpage.'&nocache='.dol_now().'" class="button" target="tab'.$website.'" alt="'.dol_escape_htmltag($langs->trans("PreviewSiteServedByDolibarr", $langs->transnoentitiesnoconv("Page"), $langs->transnoentitiesnoconv("Page"), $realpage)).'">'; print '<a class="websitebuttonsitepreview" id="previewpage" href="'.$realpage.'&nocache='.dol_now().'" class="button" target="tab'.$website.'" alt="'.dol_escape_htmltag($langs->trans("PreviewSiteServedByDolibarr", $langs->transnoentitiesnoconv("Page"), $langs->transnoentitiesnoconv("Page"), $realpage)).'">';
print $form->textwithpicto('', $langs->trans("PreviewSiteServedByDolibarr", $langs->transnoentitiesnoconv("Page"), $langs->transnoentitiesnoconv("Page"), $realpage, $dataroot), 1, 'preview'); print $form->textwithpicto('', $langs->trans("PreviewSiteServedByDolibarr", $langs->transnoentitiesnoconv("Page"), $langs->transnoentitiesnoconv("Page"), $realpage, $dataroot), 1, 'preview');
print '</a>'; // View page in new Tab print '</a>'; // View page in new Tab
//print '<input type="submit" class="button" name="previewpage" target="tab'.$website.'"value="'.$langs->trans("ViewPageInNewTab").'">'; //print '<input type="submit" class="button" name="previewpage" target="tab'.$website.'"value="'.$langs->trans("ViewPageInNewTab").'">';
// TODO Add js to save alias like we save virtual host name and use dynamic virtual host for url of id=previewpageext // TODO Add js to save alias like we save virtual host name and use dynamic virtual host for url of id=previewpageext
} }
if (! in_array($action, array('editcss','editmenu','create'))) if (! in_array($action, array('editcss','editmenu','create')))
{ {
if ($action != 'preview') print '<input type="submit" class="button" value="'.dol_escape_htmltag($langs->trans("Cancel")).'" name="preview">'; if ($action != 'preview') print '<input type="submit" class="button" value="'.dol_escape_htmltag($langs->trans("Cancel")).'" name="preview">';
if (preg_match('/^create/',$action)) print '<input type="submit" class="button" value="'.dol_escape_htmltag($langs->trans("Save")).'" name="update">'; if (preg_match('/^create/',$action)) print '<input type="submit" class="button" value="'.dol_escape_htmltag($langs->trans("Save")).'" name="update">';
if (preg_match('/^edit/',$action)) print '<input type="submit" class="button" value="'.dol_escape_htmltag($langs->trans("Save")).'" name="update">'; if (preg_match('/^edit/',$action)) print '<input type="submit" class="button" value="'.dol_escape_htmltag($langs->trans("Save")).'" name="update">';
} }
print '</div>'; print '</div>';
if ($action == 'preview') if ($action == 'preview')
{ {
// Adding jquery code to change on the fly url of preview ext // Adding jquery code to change on the fly url of preview ext
if (! empty($conf->use_javascript_ajax)) if (! empty($conf->use_javascript_ajax))
{ {
print '<script type="text/javascript" language="javascript"> print '<script type="text/javascript" language="javascript">
jQuery(document).ready(function() { jQuery(document).ready(function() {
jQuery("#previewsiteext,#previewpageext").click(function() { jQuery("#previewsiteext,#previewpageext").click(function() {
newurl=jQuery("#previewsiteurl").val(); newurl=jQuery("#previewsiteurl").val();
@ -417,17 +417,17 @@ if (count($object->records) > 0)
}); });
}); });
</script>'; </script>';
} }
} }
} }
} }
else else
{ {
print '<div class="websiteselection">'; print '<div class="websiteselection">';
$langs->load("errors"); $langs->load("errors");
print $langs->trans("ErrorModuleSetupNotComplete"); print $langs->trans("ErrorModuleSetupNotComplete");
print '<div>'; print '<div>';
$action=''; $action='';
} }
@ -437,21 +437,21 @@ $head = array();
if ($action == 'editcontent') if ($action == 'editcontent')
{ {
/* /*
* Editing global variables not related to a specific theme * Editing global variables not related to a specific theme
*/ */
$csscontent = @file_get_contents($filecss); $csscontent = @file_get_contents($filecss);
$contentforedit = ''; $contentforedit = '';
/*$contentforedit.='<style scoped>'."\n"; // "scoped" means "apply to parent element only". Not yet supported by browsers /*$contentforedit.='<style scoped>'."\n"; // "scoped" means "apply to parent element only". Not yet supported by browsers
$contentforedit.=$csscontent; $contentforedit.=$csscontent;
$contentforedit.='</style>'."\n";*/ $contentforedit.='</style>'."\n";*/
$contentforedit .= $objectpage->content; $contentforedit .= $objectpage->content;
require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
$doleditor=new DolEditor('PAGE_CONTENT',$contentforedit,'',500,'Full','',true,true,true,ROWS_5,'90%'); $doleditor=new DolEditor('PAGE_CONTENT',$contentforedit,'',500,'Full','',true,true,true,ROWS_5,'90%');
$doleditor->Create(0, '', false); $doleditor->Create(0, '', false);
} }
print "</div>\n</form>\n"; print "</div>\n</form>\n";

View File

@ -170,7 +170,7 @@ if (empty($reshook))
$result = $object->set_reopen($user); $result = $object->set_reopen($user);
if ($result > 0) if ($result > 0)
{ {
setEventMessages($langs->trans('OrderReopened', $object->ref), null); setEventMessages($langs->trans('OrderReopened', $object->ref), null);
} }
else else
{ {
@ -264,12 +264,12 @@ if (empty($reshook))
$object->modelpdf = GETPOST('model'); $object->modelpdf = GETPOST('model');
$object->cond_reglement_id = GETPOST('cond_reglement_id'); $object->cond_reglement_id = GETPOST('cond_reglement_id');
$object->mode_reglement_id = GETPOST('mode_reglement_id'); $object->mode_reglement_id = GETPOST('mode_reglement_id');
$object->fk_account = GETPOST('fk_account', 'int'); $object->fk_account = GETPOST('fk_account', 'int');
$object->availability_id = GETPOST('availability_id'); $object->availability_id = GETPOST('availability_id');
$object->demand_reason_id = GETPOST('demand_reason_id'); $object->demand_reason_id = GETPOST('demand_reason_id');
$object->date_livraison = $datelivraison; $object->date_livraison = $datelivraison;
$object->shipping_method_id = GETPOST('shipping_method_id', 'int'); $object->shipping_method_id = GETPOST('shipping_method_id', 'int');
$object->warehouse_id = GETPOST('warehouse_id', 'int'); $object->warehouse_id = GETPOST('warehouse_id', 'int');
$object->fk_delivery_address = GETPOST('fk_address'); $object->fk_delivery_address = GETPOST('fk_address');
$object->contactid = GETPOST('contactid'); $object->contactid = GETPOST('contactid');
$object->fk_incoterms = GETPOST('incoterm_id', 'int'); $object->fk_incoterms = GETPOST('incoterm_id', 'int');
@ -279,8 +279,8 @@ if (empty($reshook))
// Fill array 'array_options' with data from add form // Fill array 'array_options' with data from add form
if (! $error) if (! $error)
{ {
$ret = $extrafields->setOptionalsFromPost($extralabels, $object); $ret = $extrafields->setOptionalsFromPost($extralabels, $object);
if ($ret < 0) $error++; if ($ret < 0) $error++;
} }
// If creation from another object of another module (Example: origin=propal, originid=1) // If creation from another object of another module (Example: origin=propal, originid=1)
@ -366,7 +366,7 @@ if (empty($reshook))
// Extrafields // Extrafields
if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && method_exists($lines[$i], 'fetch_optionals')) // For avoid conflicts if if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && method_exists($lines[$i], 'fetch_optionals')) // For avoid conflicts if
// trigger used // trigger used
{ {
$lines[$i]->fetch_optionals($lines[$i]->rowid); $lines[$i]->fetch_optionals($lines[$i]->rowid);
$array_options = $lines[$i]->array_options; $array_options = $lines[$i]->array_options;
@ -423,7 +423,7 @@ if (empty($reshook))
$reshook = $hookmanager->executeHooks('createFrom', $parameters, $object, $action); // Note that $action and $object may have been $reshook = $hookmanager->executeHooks('createFrom', $parameters, $object, $action); // Note that $action and $object may have been
// modified by hook // modified by hook
if ($reshook < 0) if ($reshook < 0)
$error++; $error++;
} else { } else {
setEventMessages($object->error, $object->errors, 'errors'); setEventMessages($object->error, $object->errors, 'errors');
@ -491,10 +491,10 @@ if (empty($reshook))
} }
else if ($action == 'classifyunbilled' && $user->rights->commande->creer) else if ($action == 'classifyunbilled' && $user->rights->commande->creer)
{ {
$ret=$object->classifyUnBilled(); $ret=$object->classifyUnBilled();
if ($ret < 0) { if ($ret < 0) {
setEventMessages($object->error, $object->errors, 'errors'); setEventMessages($object->error, $object->errors, 'errors');
} }
} }
// Positionne ref commande client // Positionne ref commande client
@ -502,7 +502,7 @@ if (empty($reshook))
$result = $object->set_ref_client($user, GETPOST('ref_client')); $result = $object->set_ref_client($user, GETPOST('ref_client'));
if ($result < 0) if ($result < 0)
{ {
setEventMessages($object->error, $object->errors, 'errors'); setEventMessages($object->error, $object->errors, 'errors');
} }
} }
@ -510,7 +510,7 @@ if (empty($reshook))
$result = $object->set_remise($user, GETPOST('remise')); $result = $object->set_remise($user, GETPOST('remise'));
if ($result < 0) if ($result < 0)
{ {
setEventMessages($object->error, $object->errors, 'errors'); setEventMessages($object->error, $object->errors, 'errors');
} }
} }
@ -563,7 +563,7 @@ if (empty($reshook))
else if ($action == 'setavailability' && $user->rights->commande->creer) { else if ($action == 'setavailability' && $user->rights->commande->creer) {
$result = $object->availability(GETPOST('availability_id')); $result = $object->availability(GETPOST('availability_id'));
if ($result < 0) if ($result < 0)
setEventMessages($object->error, $object->errors, 'errors'); setEventMessages($object->error, $object->errors, 'errors');
} }
else if ($action == 'setdemandreason' && $user->rights->commande->creer) { else if ($action == 'setdemandreason' && $user->rights->commande->creer) {
@ -596,36 +596,36 @@ if (empty($reshook))
// Set incoterm // Set incoterm
elseif ($action == 'set_incoterms' && !empty($conf->incoterm->enabled)) elseif ($action == 'set_incoterms' && !empty($conf->incoterm->enabled))
{ {
$result = $object->setIncoterms(GETPOST('incoterm_id', 'int'), GETPOST('location_incoterms', 'alpha')); $result = $object->setIncoterms(GETPOST('incoterm_id', 'int'), GETPOST('location_incoterms', 'alpha'));
if ($result < 0) { if ($result < 0) {
setEventMessages($object->error, $object->errors, 'errors'); setEventMessages($object->error, $object->errors, 'errors');
} }
} }
// bank account // bank account
else if ($action == 'setbankaccount' && $user->rights->commande->creer) { else if ($action == 'setbankaccount' && $user->rights->commande->creer) {
$result=$object->setBankAccount(GETPOST('fk_account', 'int')); $result=$object->setBankAccount(GETPOST('fk_account', 'int'));
if ($result < 0) { if ($result < 0) {
setEventMessages($object->error, $object->errors, 'errors'); setEventMessages($object->error, $object->errors, 'errors');
} }
} }
// shipping method // shipping method
else if ($action == 'setshippingmethod' && $user->rights->commande->creer) { else if ($action == 'setshippingmethod' && $user->rights->commande->creer) {
$result = $object->setShippingMethod(GETPOST('shipping_method_id', 'int')); $result = $object->setShippingMethod(GETPOST('shipping_method_id', 'int'));
if ($result < 0) { if ($result < 0) {
setEventMessages($object->error, $object->errors, 'errors'); setEventMessages($object->error, $object->errors, 'errors');
} }
} }
// warehouse // warehouse
else if ($action == 'setwarehouse' && $user->rights->commande->creer) { else if ($action == 'setwarehouse' && $user->rights->commande->creer) {
$result = $object->setWarehouse(GETPOST('warehouse_id', 'int')); $result = $object->setWarehouse(GETPOST('warehouse_id', 'int'));
if ($result < 0) { if ($result < 0) {
setEventMessages($object->error, $object->errors, 'errors'); setEventMessages($object->error, $object->errors, 'errors');
} }
} }
else if ($action == 'setremisepercent' && $user->rights->commande->creer) { else if ($action == 'setremisepercent' && $user->rights->commande->creer) {
$result = $object->set_remise($user, GETPOST('remise_percent')); $result = $object->set_remise($user, GETPOST('remise_percent'));
@ -898,18 +898,18 @@ if (empty($reshook))
unset($_POST['idprod']); unset($_POST['idprod']);
unset($_POST['units']); unset($_POST['units']);
unset($_POST['date_starthour']); unset($_POST['date_starthour']);
unset($_POST['date_startmin']); unset($_POST['date_startmin']);
unset($_POST['date_startsec']); unset($_POST['date_startsec']);
unset($_POST['date_startday']); unset($_POST['date_startday']);
unset($_POST['date_startmonth']); unset($_POST['date_startmonth']);
unset($_POST['date_startyear']); unset($_POST['date_startyear']);
unset($_POST['date_endhour']); unset($_POST['date_endhour']);
unset($_POST['date_endmin']); unset($_POST['date_endmin']);
unset($_POST['date_endsec']); unset($_POST['date_endsec']);
unset($_POST['date_endday']); unset($_POST['date_endday']);
unset($_POST['date_endmonth']); unset($_POST['date_endmonth']);
unset($_POST['date_endyear']); unset($_POST['date_endyear']);
} else { } else {
setEventMessages($object->error, $object->errors, 'errors'); setEventMessages($object->error, $object->errors, 'errors');
} }
@ -1062,13 +1062,13 @@ if (empty($reshook))
} }
else if ($action == 'confirm_validate' && $confirm == 'yes' && else if ($action == 'confirm_validate' && $confirm == 'yes' &&
((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->commande->creer)) ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->commande->creer))
|| (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->commande->order_advance->validate))) || (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->commande->order_advance->validate)))
) )
{ {
$idwarehouse = GETPOST('idwarehouse'); $idwarehouse = GETPOST('idwarehouse');
$qualified_for_stock_change=0; $qualified_for_stock_change=0;
if (empty($conf->global->STOCK_SUPPORTS_SERVICES)) if (empty($conf->global->STOCK_SUPPORTS_SERVICES))
{ {
$qualified_for_stock_change=$object->hasProductsOrServices(2); $qualified_for_stock_change=$object->hasProductsOrServices(2);
@ -1121,7 +1121,7 @@ if (empty($reshook))
else if ($action == 'confirm_modif' && $user->rights->commande->creer) { else if ($action == 'confirm_modif' && $user->rights->commande->creer) {
$idwarehouse = GETPOST('idwarehouse'); $idwarehouse = GETPOST('idwarehouse');
$qualified_for_stock_change=0; $qualified_for_stock_change=0;
if (empty($conf->global->STOCK_SUPPORTS_SERVICES)) if (empty($conf->global->STOCK_SUPPORTS_SERVICES))
{ {
$qualified_for_stock_change=$object->hasProductsOrServices(2); $qualified_for_stock_change=$object->hasProductsOrServices(2);
@ -1174,13 +1174,13 @@ if (empty($reshook))
} }
else if ($action == 'confirm_cancel' && $confirm == 'yes' && else if ($action == 'confirm_cancel' && $confirm == 'yes' &&
((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->commande->creer)) ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->commande->creer))
|| (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->commande->order_advance->validate))) || (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->commande->order_advance->validate)))
) )
{ {
$idwarehouse = GETPOST('idwarehouse'); $idwarehouse = GETPOST('idwarehouse');
$qualified_for_stock_change=0; $qualified_for_stock_change=0;
if (empty($conf->global->STOCK_SUPPORTS_SERVICES)) if (empty($conf->global->STOCK_SUPPORTS_SERVICES))
{ {
$qualified_for_stock_change=$object->hasProductsOrServices(2); $qualified_for_stock_change=$object->hasProductsOrServices(2);
@ -1223,7 +1223,7 @@ if (empty($reshook))
$hookmanager->initHooks(array('orderdao')); $hookmanager->initHooks(array('orderdao'));
$parameters = array('id' => $object->id); $parameters = array('id' => $object->id);
$reshook = $hookmanager->executeHooks('insertExtraFields', $parameters, $object, $action); // Note that $action and $object may have been modified by $reshook = $hookmanager->executeHooks('insertExtraFields', $parameters, $object, $action); // Note that $action and $object may have been modified by
// some hooks // some hooks
if (empty($reshook)) { if (empty($reshook)) {
$result = $object->insertExtraFields(); $result = $object->insertExtraFields();
if ($result < 0) { if ($result < 0) {
@ -1393,10 +1393,10 @@ if ($action == 'create' && $user->rights->commande->creer)
$soc = $objectsrc->thirdparty; $soc = $objectsrc->thirdparty;
$cond_reglement_id = (!empty($objectsrc->cond_reglement_id)?$objectsrc->cond_reglement_id:(!empty($soc->cond_reglement_id)?$soc->cond_reglement_id:1)); $cond_reglement_id = (!empty($objectsrc->cond_reglement_id)?$objectsrc->cond_reglement_id:(!empty($soc->cond_reglement_id)?$soc->cond_reglement_id:1));
$mode_reglement_id = (!empty($objectsrc->mode_reglement_id)?$objectsrc->mode_reglement_id:(!empty($soc->mode_reglement_id)?$soc->mode_reglement_id:0)); $mode_reglement_id = (!empty($objectsrc->mode_reglement_id)?$objectsrc->mode_reglement_id:(!empty($soc->mode_reglement_id)?$soc->mode_reglement_id:0));
$fk_account = (! empty($objectsrc->fk_account)?$objectsrc->fk_account:(! empty($soc->fk_account)?$soc->fk_account:0)); $fk_account = (! empty($objectsrc->fk_account)?$objectsrc->fk_account:(! empty($soc->fk_account)?$soc->fk_account:0));
$availability_id = (!empty($objectsrc->availability_id)?$objectsrc->availability_id:(!empty($soc->availability_id)?$soc->availability_id:0)); $availability_id = (!empty($objectsrc->availability_id)?$objectsrc->availability_id:(!empty($soc->availability_id)?$soc->availability_id:0));
$shipping_method_id = (! empty($objectsrc->shipping_method_id)?$objectsrc->shipping_method_id:(! empty($soc->shipping_method_id)?$soc->shipping_method_id:0)); $shipping_method_id = (! empty($objectsrc->shipping_method_id)?$objectsrc->shipping_method_id:(! empty($soc->shipping_method_id)?$soc->shipping_method_id:0));
$warehouse_id = (! empty($objectsrc->warehouse_id)?$objectsrc->warehouse_id:(! empty($soc->warehouse_id)?$soc->warehouse_id:0)); $warehouse_id = (! empty($objectsrc->warehouse_id)?$objectsrc->warehouse_id:(! empty($soc->warehouse_id)?$soc->warehouse_id:0));
$demand_reason_id = (!empty($objectsrc->demand_reason_id)?$objectsrc->demand_reason_id:(!empty($soc->demand_reason_id)?$soc->demand_reason_id:0)); $demand_reason_id = (!empty($objectsrc->demand_reason_id)?$objectsrc->demand_reason_id:(!empty($soc->demand_reason_id)?$soc->demand_reason_id:0));
$remise_percent = (!empty($objectsrc->remise_percent)?$objectsrc->remise_percent:(!empty($soc->remise_percent)?$soc->remise_percent:0)); $remise_percent = (!empty($objectsrc->remise_percent)?$objectsrc->remise_percent:(!empty($soc->remise_percent)?$soc->remise_percent:0));
$remise_absolue = (!empty($objectsrc->remise_absolue)?$objectsrc->remise_absolue:(!empty($soc->remise_absolue)?$soc->remise_absolue:0)); $remise_absolue = (!empty($objectsrc->remise_absolue)?$objectsrc->remise_absolue:(!empty($soc->remise_absolue)?$soc->remise_absolue:0));
@ -1421,10 +1421,10 @@ if ($action == 'create' && $user->rights->commande->creer)
{ {
$cond_reglement_id = $soc->cond_reglement_id; $cond_reglement_id = $soc->cond_reglement_id;
$mode_reglement_id = $soc->mode_reglement_id; $mode_reglement_id = $soc->mode_reglement_id;
$fk_account = $soc->fk_account; $fk_account = $soc->fk_account;
$availability_id = $soc->availability_id; $availability_id = $soc->availability_id;
$shipping_method_id = $soc->shipping_method_id; $shipping_method_id = $soc->shipping_method_id;
$warehouse_id = $soc->warehouse_id; $warehouse_id = $soc->warehouse_id;
$demand_reason_id = $soc->demand_reason_id; $demand_reason_id = $soc->demand_reason_id;
$remise_percent = $soc->remise_percent; $remise_percent = $soc->remise_percent;
$remise_absolue = 0; $remise_absolue = 0;
@ -1537,12 +1537,12 @@ if ($action == 'create' && $user->rights->commande->creer)
$form->select_types_paiements($mode_reglement_id, 'mode_reglement_id'); $form->select_types_paiements($mode_reglement_id, 'mode_reglement_id');
print '</td></tr>'; print '</td></tr>';
// Bank Account // Bank Account
if (! empty($conf->global->BANK_ASK_PAYMENT_BANK_DURING_ORDER) && ! empty($conf->banque->enabled)) if (! empty($conf->global->BANK_ASK_PAYMENT_BANK_DURING_ORDER) && ! empty($conf->banque->enabled))
{ {
print '<tr><td>' . $langs->trans('BankAccount') . '</td><td>'; print '<tr><td>' . $langs->trans('BankAccount') . '</td><td>';
$form->select_comptes($fk_account, 'fk_account', 0, '', 1); $form->select_comptes($fk_account, 'fk_account', 0, '', 1);
print '</td></tr>'; print '</td></tr>';
} }
// Delivery delay // Delivery delay
@ -1550,21 +1550,21 @@ if ($action == 'create' && $user->rights->commande->creer)
$form->selectAvailabilityDelay($availability_id, 'availability_id', '', 1); $form->selectAvailabilityDelay($availability_id, 'availability_id', '', 1);
print '</td></tr>'; print '</td></tr>';
// Shipping Method // Shipping Method
if (! empty($conf->expedition->enabled)) { if (! empty($conf->expedition->enabled)) {
print '<tr><td>' . $langs->trans('SendingMethod') . '</td><td>'; print '<tr><td>' . $langs->trans('SendingMethod') . '</td><td>';
print $form->selectShippingMethod($shipping_method_id, 'shipping_method_id', '', 1); print $form->selectShippingMethod($shipping_method_id, 'shipping_method_id', '', 1);
print '</td></tr>'; print '</td></tr>';
} }
// Warehouse // Warehouse
if (! empty($conf->expedition->enabled) && ! empty($conf->global->WAREHOUSE_ASK_WAREHOUSE_DURING_ORDER)) { if (! empty($conf->expedition->enabled) && ! empty($conf->global->WAREHOUSE_ASK_WAREHOUSE_DURING_ORDER)) {
require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php'; require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php';
$formproduct=new FormProduct($db); $formproduct=new FormProduct($db);
print '<tr><td>' . $langs->trans('Warehouse') . '</td><td>'; print '<tr><td>' . $langs->trans('Warehouse') . '</td><td>';
print $formproduct->selectWarehouses($warehouse_id, 'warehouse_id', '', 1); print $formproduct->selectWarehouses($warehouse_id, 'warehouse_id', '', 1);
print '</td></tr>'; print '</td></tr>';
} }
// What trigger creation // What trigger creation
print '<tr><td>' . $langs->trans('Source') . '</td><td>'; print '<tr><td>' . $langs->trans('Source') . '</td><td>';
@ -1590,22 +1590,22 @@ if ($action == 'create' && $user->rights->commande->creer)
{ {
print '<tr>'; print '<tr>';
print '<td><label for="incoterm_id">'.$form->textwithpicto($langs->trans("IncotermLabel"), $objectsrc->libelle_incoterms, 1).'</label></td>'; print '<td><label for="incoterm_id">'.$form->textwithpicto($langs->trans("IncotermLabel"), $objectsrc->libelle_incoterms, 1).'</label></td>';
print '<td class="maxwidthonsmartphone">'; print '<td class="maxwidthonsmartphone">';
$incoterm_id = GETPOST('incoterm_id'); $incoterm_id = GETPOST('incoterm_id');
$incoterm_location = GETPOST('location_incoterms'); $incoterm_location = GETPOST('location_incoterms');
if (empty($incoterm_id)) if (empty($incoterm_id))
{ {
$incoterm_id = (!empty($objectsrc->fk_incoterms) ? $objectsrc->fk_incoterms : $soc->fk_incoterms); $incoterm_id = (!empty($objectsrc->fk_incoterms) ? $objectsrc->fk_incoterms : $soc->fk_incoterms);
$incoterm_location = (!empty($objectsrc->location_incoterms) ? $objectsrc->location_incoterms : $soc->location_incoterms); $incoterm_location = (!empty($objectsrc->location_incoterms) ? $objectsrc->location_incoterms : $soc->location_incoterms);
} }
print $form->select_incoterms($incoterm_id, $incoterm_location); print $form->select_incoterms($incoterm_id, $incoterm_location);
print '</td></tr>'; print '</td></tr>';
} }
// Other attributes // Other attributes
$parameters = array('objectsrc' => $objectsrc, 'socid'=>$socid); $parameters = array('objectsrc' => $objectsrc, 'socid'=>$socid);
$reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by
print $hookmanager->resPrint; print $hookmanager->resPrint;
if (empty($reshook) && ! empty($extrafields->attribute_label)) { if (empty($reshook) && ! empty($extrafields->attribute_label)) {
print $object->showOptionals($extrafields, 'edit'); print $object->showOptionals($extrafields, 'edit');
} }
@ -1623,8 +1623,8 @@ if ($action == 'create' && $user->rights->commande->creer)
{ {
print '<tr>'; print '<tr>';
print '<td>'.fieldLabel('Currency','multicurrency_code').'</td>'; print '<td>'.fieldLabel('Currency','multicurrency_code').'</td>';
print '<td class="maxwidthonsmartphone">'; print '<td class="maxwidthonsmartphone">';
print $form->selectMultiCurrency($currency_code, 'multicurrency_code'); print $form->selectMultiCurrency($currency_code, 'multicurrency_code');
print '</td></tr>'; print '</td></tr>';
} }
@ -1918,69 +1918,69 @@ if ($action == 'create' && $user->rights->commande->creer)
// Ref customer // Ref customer
$morehtmlref.=$form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, $user->rights->commande->creer, 'string', '', 0, 1); $morehtmlref.=$form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, $user->rights->commande->creer, 'string', '', 0, 1);
$morehtmlref.=$form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, $user->rights->commande->creer, 'string', '', null, null, '', 1); $morehtmlref.=$form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, $user->rights->commande->creer, 'string', '', null, null, '', 1);
// Thirdparty // Thirdparty
$morehtmlref.='<br>'.$langs->trans('ThirdParty') . ' : ' . $soc->getNomUrl(1); $morehtmlref.='<br>'.$langs->trans('ThirdParty') . ' : ' . $soc->getNomUrl(1);
if (empty($conf->global->MAIN_DISABLE_OTHER_LINK) && $object->thirdparty->id > 0) $morehtmlref.=' (<a href="'.DOL_URL_ROOT.'/commande/list.php?socid='.$object->thirdparty->id.'">'.$langs->trans("OtherOrders").'</a>)'; if (empty($conf->global->MAIN_DISABLE_OTHER_LINK) && $object->thirdparty->id > 0) $morehtmlref.=' (<a href="'.DOL_URL_ROOT.'/commande/list.php?socid='.$object->thirdparty->id.'">'.$langs->trans("OtherOrders").'</a>)';
// Project // Project
if (! empty($conf->projet->enabled)) if (! empty($conf->projet->enabled))
{ {
$langs->load("projects"); $langs->load("projects");
$morehtmlref.='<br>'.$langs->trans('Project') . ' '; $morehtmlref.='<br>'.$langs->trans('Project') . ' ';
if ($user->rights->commande->creer) if ($user->rights->commande->creer)
{ {
if ($action != 'classify') if ($action != 'classify')
$morehtmlref.='<a href="' . $_SERVER['PHP_SELF'] . '?action=classify&amp;id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : '; $morehtmlref.='<a href="' . $_SERVER['PHP_SELF'] . '?action=classify&amp;id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : ';
if ($action == 'classify') { if ($action == 'classify') {
//$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1);
$morehtmlref.='<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">'; $morehtmlref.='<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">';
$morehtmlref.='<input type="hidden" name="action" value="classin">'; $morehtmlref.='<input type="hidden" name="action" value="classin">';
$morehtmlref.='<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; $morehtmlref.='<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
$morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1);
$morehtmlref.='<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">'; $morehtmlref.='<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">';
$morehtmlref.='</form>'; $morehtmlref.='</form>';
} else { } else {
$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1);
} }
} else { } else {
if (! empty($object->fk_project)) { if (! empty($object->fk_project)) {
$proj = new Project($db); $proj = new Project($db);
$proj->fetch($object->fk_project); $proj->fetch($object->fk_project);
$morehtmlref.='<a href="'.DOL_URL_ROOT.'/projet/card.php?id=' . $object->fk_project . '" title="' . $langs->trans('ShowProject') . '">'; $morehtmlref.='<a href="'.DOL_URL_ROOT.'/projet/card.php?id=' . $object->fk_project . '" title="' . $langs->trans('ShowProject') . '">';
$morehtmlref.=$proj->ref; $morehtmlref.=$proj->ref;
$morehtmlref.='</a>'; $morehtmlref.='</a>';
} else { } else {
$morehtmlref.=''; $morehtmlref.='';
} }
} }
} }
$morehtmlref.='</div>'; $morehtmlref.='</div>';
dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
print '<div class="fichecenter">'; print '<div class="fichecenter">';
print '<div class="fichehalfleft">'; print '<div class="fichehalfleft">';
print '<div class="underbanner clearboth"></div>'; print '<div class="underbanner clearboth"></div>';
print '<table class="border" width="100%">'; print '<table class="border" width="100%">';
if ($soc->outstanding_limit) if ($soc->outstanding_limit)
{ {
// Outstanding Bill // Outstanding Bill
print '<tr><td class="titlefield">'; print '<tr><td class="titlefield">';
print $langs->trans('OutstandingBill'); print $langs->trans('OutstandingBill');
print '</td><td>'; print '</td><td>';
print price($soc->get_OutstandingBill()) . ' / '; print price($soc->get_OutstandingBill()) . ' / ';
print price($soc->outstanding_limit, 0, '', 1, - 1, - 1, $conf->currency); print price($soc->outstanding_limit, 0, '', 1, - 1, - 1, $conf->currency);
print '</td>'; print '</td>';
print '</tr>'; print '</tr>';
} }
// Relative and absolute discounts // Relative and absolute discounts
if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) {
$filterabsolutediscount = "fk_facture_source IS NULL"; // If we want deposit to be substracted to payments only and not to total of final $filterabsolutediscount = "fk_facture_source IS NULL"; // If we want deposit to be substracted to payments only and not to total of final
// invoice // invoice
$filtercreditnote = "fk_facture_source IS NOT NULL"; // If we want deposit to be substracted to payments only and not to total of final invoice $filtercreditnote = "fk_facture_source IS NOT NULL"; // If we want deposit to be substracted to payments only and not to total of final invoice
} else { } else {
$filterabsolutediscount = "fk_facture_source IS NULL OR (fk_facture_source IS NOT NULL AND description LIKE '(DEPOSIT)%')"; $filterabsolutediscount = "fk_facture_source IS NULL OR (fk_facture_source IS NOT NULL AND description LIKE '(DEPOSIT)%')";
@ -2037,7 +2037,7 @@ if ($action == 'create' && $user->rights->commande->creer)
} else { } else {
print $object->date ? dol_print_date($object->date, 'day') : '&nbsp;'; print $object->date ? dol_print_date($object->date, 'day') : '&nbsp;';
if ($object->hasDelay() && ! empty($object->date_livraison)) { if ($object->hasDelay() && ! empty($object->date_livraison)) {
print ' '.img_picto($langs->trans("Late").' : '.$object->showDelay(), "warning"); print ' '.img_picto($langs->trans("Late").' : '.$object->showDelay(), "warning");
} }
} }
print '</td>'; print '</td>';
@ -2062,51 +2062,51 @@ if ($action == 'create' && $user->rights->commande->creer)
} else { } else {
print $object->date_livraison ? dol_print_date($object->date_livraison, 'daytext') : '&nbsp;'; print $object->date_livraison ? dol_print_date($object->date_livraison, 'daytext') : '&nbsp;';
if ($object->hasDelay() && ! empty($object->date_livraison)) { if ($object->hasDelay() && ! empty($object->date_livraison)) {
print ' '.img_picto($langs->trans("Late").' : '.$object->showDelay(), "warning"); print ' '.img_picto($langs->trans("Late").' : '.$object->showDelay(), "warning");
} }
} }
print '</td>'; print '</td>';
print '</tr>'; print '</tr>';
// Shipping Method // Shipping Method
if (! empty($conf->expedition->enabled)) { if (! empty($conf->expedition->enabled)) {
print '<tr><td height="10">'; print '<tr><td height="10">';
print '<table width="100%" class="nobordernopadding"><tr><td>'; print '<table width="100%" class="nobordernopadding"><tr><td>';
print $langs->trans('SendingMethod'); print $langs->trans('SendingMethod');
print '</td>'; print '</td>';
if ($action != 'editshippingmethod' && $user->rights->commande->creer) if ($action != 'editshippingmethod' && $user->rights->commande->creer)
print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editshippingmethod&amp;id='.$object->id.'">'.img_edit($langs->trans('SetShippingMode'),1).'</a></td>'; print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editshippingmethod&amp;id='.$object->id.'">'.img_edit($langs->trans('SetShippingMode'),1).'</a></td>';
print '</tr></table>'; print '</tr></table>';
print '</td><td>'; print '</td><td>';
if ($action == 'editshippingmethod') { if ($action == 'editshippingmethod') {
$form->formSelectShippingMethod($_SERVER['PHP_SELF'].'?id='.$object->id, $object->shipping_method_id, 'shipping_method_id', 1); $form->formSelectShippingMethod($_SERVER['PHP_SELF'].'?id='.$object->id, $object->shipping_method_id, 'shipping_method_id', 1);
} else { } else {
$form->formSelectShippingMethod($_SERVER['PHP_SELF'].'?id='.$object->id, $object->shipping_method_id, 'none'); $form->formSelectShippingMethod($_SERVER['PHP_SELF'].'?id='.$object->id, $object->shipping_method_id, 'none');
} }
print '</td>'; print '</td>';
print '</tr>'; print '</tr>';
} }
// Warehouse // Warehouse
if (! empty($conf->expedition->enabled) && ! empty($conf->global->WAREHOUSE_ASK_WAREHOUSE_DURING_ORDER)) { if (! empty($conf->expedition->enabled) && ! empty($conf->global->WAREHOUSE_ASK_WAREHOUSE_DURING_ORDER)) {
require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php'; require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php';
$formproduct=new FormProduct($db); $formproduct=new FormProduct($db);
print '<tr><td>'; print '<tr><td>';
print '<table width="100%" class="nobordernopadding"><tr><td>'; print '<table width="100%" class="nobordernopadding"><tr><td>';
print $langs->trans('Warehouse'); print $langs->trans('Warehouse');
print '</td>'; print '</td>';
if ($action != 'editwarehouse' && $user->rights->commande->creer) if ($action != 'editwarehouse' && $user->rights->commande->creer)
print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editwarehouse&amp;id='.$object->id.'">'.img_edit($langs->trans('SetWarehouse'),1).'</a></td>'; print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editwarehouse&amp;id='.$object->id.'">'.img_edit($langs->trans('SetWarehouse'),1).'</a></td>';
print '</tr></table>'; print '</tr></table>';
print '</td><td>'; print '</td><td>';
if ($action == 'editwarehouse') { if ($action == 'editwarehouse') {
$formproduct->formSelectWarehouses($_SERVER['PHP_SELF'].'?id='.$object->id, $object->warehouse_id, 'warehouse_id', 1); $formproduct->formSelectWarehouses($_SERVER['PHP_SELF'].'?id='.$object->id, $object->warehouse_id, 'warehouse_id', 1);
} else { } else {
$formproduct->formSelectWarehouses($_SERVER['PHP_SELF'].'?id='.$object->id, $object->warehouse_id, 'none'); $formproduct->formSelectWarehouses($_SERVER['PHP_SELF'].'?id='.$object->id, $object->warehouse_id, 'none');
} }
print '</td>'; print '</td>';
print '</tr>'; print '</tr>';
} }
// Terms of payment // Terms of payment
print '<tr><td>'; print '<tr><td>';
@ -2173,9 +2173,9 @@ if ($action == 'create' && $user->rights->commande->creer)
print '</tr></table>'; print '</tr></table>';
print '</td><td>'; print '</td><td>';
if ($action == 'editmulticurrencyrate' || $action == 'actualizemulticurrencyrate') { if ($action == 'editmulticurrencyrate' || $action == 'actualizemulticurrencyrate') {
if($action == 'actualizemulticurrencyrate') { if($action == 'actualizemulticurrencyrate') {
list($object->fk_multicurrency, $object->multicurrency_tx) = MultiCurrency::getIdAndTxFromCode($object->db, $object->multicurrency_code); list($object->fk_multicurrency, $object->multicurrency_tx) = MultiCurrency::getIdAndTxFromCode($object->db, $object->multicurrency_code);
} }
$form->form_multicurrency_rate($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_tx, 'multicurrency_tx', $object->multicurrency_code); $form->form_multicurrency_rate($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_tx, 'multicurrency_tx', $object->multicurrency_code);
} else { } else {
$form->form_multicurrency_rate($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_tx, 'none', $object->multicurrency_code); $form->form_multicurrency_rate($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_tx, 'none', $object->multicurrency_code);
@ -2243,30 +2243,30 @@ if ($action == 'create' && $user->rights->commande->creer)
$totalVolume=$tmparray['volume']; $totalVolume=$tmparray['volume'];
if ($totalWeight || $totalVolume) if ($totalWeight || $totalVolume)
{ {
print '<tr><td>'.$langs->trans("CalculatedWeight").'</td>'; print '<tr><td>'.$langs->trans("CalculatedWeight").'</td>';
print '<td>'; print '<td>';
print showDimensionInBestUnit($totalWeight, 0, "weight", $langs, isset($conf->global->MAIN_WEIGHT_DEFAULT_ROUND)?$conf->global->MAIN_WEIGHT_DEFAULT_ROUND:-1, isset($conf->global->MAIN_WEIGHT_DEFAULT_UNIT)?$conf->global->MAIN_WEIGHT_DEFAULT_UNIT:'no'); print showDimensionInBestUnit($totalWeight, 0, "weight", $langs, isset($conf->global->MAIN_WEIGHT_DEFAULT_ROUND)?$conf->global->MAIN_WEIGHT_DEFAULT_ROUND:-1, isset($conf->global->MAIN_WEIGHT_DEFAULT_UNIT)?$conf->global->MAIN_WEIGHT_DEFAULT_UNIT:'no');
print '</td></tr>'; print '</td></tr>';
print '<tr><td>'.$langs->trans("CalculatedVolume").'</td>'; print '<tr><td>'.$langs->trans("CalculatedVolume").'</td>';
print '<td>'; print '<td>';
print showDimensionInBestUnit($totalVolume, 0, "volume", $langs, isset($conf->global->MAIN_VOLUME_DEFAULT_ROUND)?$conf->global->MAIN_VOLUME_DEFAULT_ROUND:-1, isset($conf->global->MAIN_VOLUME_DEFAULT_UNIT)?$conf->global->MAIN_VOLUME_DEFAULT_UNIT:'no'); print showDimensionInBestUnit($totalVolume, 0, "volume", $langs, isset($conf->global->MAIN_VOLUME_DEFAULT_ROUND)?$conf->global->MAIN_VOLUME_DEFAULT_ROUND:-1, isset($conf->global->MAIN_VOLUME_DEFAULT_UNIT)?$conf->global->MAIN_VOLUME_DEFAULT_UNIT:'no');
print '</td></tr>'; print '</td></tr>';
} }
// TODO How record was recorded OrderMode (llx_c_input_method) // TODO How record was recorded OrderMode (llx_c_input_method)
// Incoterms // Incoterms
if (!empty($conf->incoterm->enabled)) if (!empty($conf->incoterm->enabled))
{ {
print '<tr><td>'; print '<tr><td>';
print '<table width="100%" class="nobordernopadding"><tr><td>'; print '<table width="100%" class="nobordernopadding"><tr><td>';
print $langs->trans('IncotermLabel'); print $langs->trans('IncotermLabel');
print '<td><td align="right">'; print '<td><td align="right">';
if ($user->rights->commande->creer) print '<a href="'.DOL_URL_ROOT.'/commande/card.php?id='.$object->id.'&action=editincoterm">'.img_edit().'</a>'; if ($user->rights->commande->creer) print '<a href="'.DOL_URL_ROOT.'/commande/card.php?id='.$object->id.'&action=editincoterm">'.img_edit().'</a>';
else print '&nbsp;'; else print '&nbsp;';
print '</td></tr></table>'; print '</td></tr></table>';
print '</td>'; print '</td>';
print '<td>'; print '<td>';
if ($action != 'editincoterm') if ($action != 'editincoterm')
{ {
print $form->textwithpicto($object->display_incoterms(), $object->libelle_incoterms, 1); print $form->textwithpicto($object->display_incoterms(), $object->libelle_incoterms, 1);
@ -2275,27 +2275,27 @@ if ($action == 'create' && $user->rights->commande->creer)
{ {
print $form->select_incoterms((!empty($object->fk_incoterms) ? $object->fk_incoterms : ''), (!empty($object->location_incoterms)?$object->location_incoterms:''), $_SERVER['PHP_SELF'].'?id='.$object->id); print $form->select_incoterms((!empty($object->fk_incoterms) ? $object->fk_incoterms : ''), (!empty($object->location_incoterms)?$object->location_incoterms:''), $_SERVER['PHP_SELF'].'?id='.$object->id);
} }
print '</td></tr>'; print '</td></tr>';
} }
// Bank Account // Bank Account
if (! empty($conf->global->BANK_ASK_PAYMENT_BANK_DURING_ORDER) && ! empty($conf->banque->enabled)) if (! empty($conf->global->BANK_ASK_PAYMENT_BANK_DURING_ORDER) && ! empty($conf->banque->enabled))
{ {
print '<tr><td class="nowrap">'; print '<tr><td class="nowrap">';
print '<table width="100%" class="nobordernopadding"><tr><td class="nowrap">'; print '<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
print $langs->trans('BankAccount'); print $langs->trans('BankAccount');
print '<td>'; print '<td>';
if ($action != 'editbankaccount' && $user->rights->commande->creer) if ($action != 'editbankaccount' && $user->rights->commande->creer)
print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editbankaccount&amp;id='.$object->id.'">'.img_edit($langs->trans('SetBankAccount'),1).'</a></td>'; print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editbankaccount&amp;id='.$object->id.'">'.img_edit($langs->trans('SetBankAccount'),1).'</a></td>';
print '</tr></table>'; print '</tr></table>';
print '</td><td>'; print '</td><td>';
if ($action == 'editbankaccount') { if ($action == 'editbankaccount') {
$form->formSelectAccount($_SERVER['PHP_SELF'].'?id='.$object->id, $object->fk_account, 'fk_account', 1); $form->formSelectAccount($_SERVER['PHP_SELF'].'?id='.$object->id, $object->fk_account, 'fk_account', 1);
} else { } else {
$form->formSelectAccount($_SERVER['PHP_SELF'].'?id='.$object->id, $object->fk_account, 'none'); $form->formSelectAccount($_SERVER['PHP_SELF'].'?id='.$object->id, $object->fk_account, 'none');
} }
print '</td>'; print '</td>';
print '</tr>'; print '</tr>';
} }
// Other attributes // Other attributes
@ -2312,20 +2312,20 @@ if ($action == 'create' && $user->rights->commande->creer)
if (!empty($conf->multicurrency->enabled) && ($object->multicurrency_code != $conf->currency)) if (!empty($conf->multicurrency->enabled) && ($object->multicurrency_code != $conf->currency))
{ {
// Multicurrency Amount HT // Multicurrency Amount HT
print '<tr><td class="titlefieldmiddle">' . fieldLabel('MulticurrencyAmountHT','multicurrency_total_ht') . '</td>'; print '<tr><td class="titlefieldmiddle">' . fieldLabel('MulticurrencyAmountHT','multicurrency_total_ht') . '</td>';
print '<td class="nowrap">' . price($object->multicurrency_total_ht, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)) . '</td>'; print '<td class="nowrap">' . price($object->multicurrency_total_ht, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)) . '</td>';
print '</tr>'; print '</tr>';
// Multicurrency Amount VAT // Multicurrency Amount VAT
print '<tr><td>' . fieldLabel('MulticurrencyAmountVAT','multicurrency_total_tva') . '</td>'; print '<tr><td>' . fieldLabel('MulticurrencyAmountVAT','multicurrency_total_tva') . '</td>';
print '<td class="nowrap">' . price($object->multicurrency_total_tva, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)) . '</td>'; print '<td class="nowrap">' . price($object->multicurrency_total_tva, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)) . '</td>';
print '</tr>'; print '</tr>';
// Multicurrency Amount TTC // Multicurrency Amount TTC
print '<tr><td>' . fieldLabel('MulticurrencyAmountTTC','multicurrency_total_ttc') . '</td>'; print '<tr><td>' . fieldLabel('MulticurrencyAmountTTC','multicurrency_total_ttc') . '</td>';
print '<td class="nowrap">' . price($object->multicurrency_total_ttc, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)) . '</td>'; print '<td class="nowrap">' . price($object->multicurrency_total_ttc, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)) . '</td>';
print '</tr>'; print '</tr>';
} }
// Total HT // Total HT
@ -2357,7 +2357,7 @@ if ($action == 'create' && $user->rights->commande->creer)
// Margin Infos // Margin Infos
if (! empty($conf->margin->enabled)) { if (! empty($conf->margin->enabled)) {
$formmargin->displayMarginInfos($object); $formmargin->displayMarginInfos($object);
} }
@ -2395,7 +2395,7 @@ if ($action == 'create' && $user->rights->commande->creer)
include DOL_DOCUMENT_ROOT . '/core/tpl/ajaxrow.tpl.php'; include DOL_DOCUMENT_ROOT . '/core/tpl/ajaxrow.tpl.php';
} }
print '<div class="div-table-responsive-no-min">'; print '<div class="div-table-responsive-no-min">';
print '<table id="tablelines" class="noborder noshadow" width="100%">'; print '<table id="tablelines" class="noborder noshadow" width="100%">';
// Show object lines // Show object lines
@ -2421,7 +2421,7 @@ if ($action == 'create' && $user->rights->commande->creer)
} }
} }
print '</table>'; print '</table>';
print '</div>'; print '</div>';
print "</form>\n"; print "</form>\n";
@ -2435,7 +2435,7 @@ if ($action == 'create' && $user->rights->commande->creer)
$parameters = array(); $parameters = array();
$reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been
// modified by hook // modified by hook
if (empty($reshook)) { if (empty($reshook)) {
// Send // Send
if ($object->statut > Commande::STATUS_DRAFT) { if ($object->statut > Commande::STATUS_DRAFT) {
@ -2445,10 +2445,10 @@ if ($action == 'create' && $user->rights->commande->creer)
print '<div class="inline-block divButAction"><a class="butActionRefused" href="#">' . $langs->trans('SendByMail') . '</a></div>'; print '<div class="inline-block divButAction"><a class="butActionRefused" href="#">' . $langs->trans('SendByMail') . '</a></div>';
} }
// Valid // Valid
if ($object->statut == Commande::STATUS_DRAFT && $object->total_ttc >= 0 && $numlines > 0 && if ($object->statut == Commande::STATUS_DRAFT && $object->total_ttc >= 0 && $numlines > 0 &&
((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->commande->creer)) ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->commande->creer))
|| (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->commande->order_advance->validate))) || (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->commande->order_advance->validate)))
) )
{ {
print '<div class="inline-block divButAction"><a class="butAction" href="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '&amp;action=validate">' . $langs->trans('Validate') . '</a></div>'; print '<div class="inline-block divButAction"><a class="butAction" href="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '&amp;action=validate">' . $langs->trans('Validate') . '</a></div>';
@ -2459,8 +2459,8 @@ if ($action == 'create' && $user->rights->commande->creer)
} }
// Create event // Create event
if ($conf->agenda->enabled && ! empty($conf->global->MAIN_ADD_EVENT_ON_ELEMENT_CARD)) // Add hidden condition because this is not a if ($conf->agenda->enabled && ! empty($conf->global->MAIN_ADD_EVENT_ON_ELEMENT_CARD)) // Add hidden condition because this is not a
// "workflow" action so should appears somewhere else on // "workflow" action so should appears somewhere else on
// page. // page.
{ {
print '<a class="butAction" href="' . DOL_URL_ROOT . '/comm/action/card.php?action=create&amp;origin=' . $object->element . '&amp;originid=' . $object->id . '&amp;socid=' . $object->socid . '">' . $langs->trans("AddAction") . '</a>'; print '<a class="butAction" href="' . DOL_URL_ROOT . '/comm/action/card.php?action=create&amp;origin=' . $object->element . '&amp;originid=' . $object->id . '&amp;socid=' . $object->socid . '">' . $langs->trans("AddAction") . '</a>';
} }
@ -2480,11 +2480,11 @@ if ($action == 'create' && $user->rights->commande->creer)
// Create contract // Create contract
if ($conf->contrat->enabled && ($object->statut == Commande::STATUS_VALIDATED || $object->statut == Commande::STATUS_SHIPMENTONPROCESS || $object->statut == Commande::STATUS_CLOSED)) { if ($conf->contrat->enabled && ($object->statut == Commande::STATUS_VALIDATED || $object->statut == Commande::STATUS_SHIPMENTONPROCESS || $object->statut == Commande::STATUS_CLOSED)) {
$langs->load("contracts"); $langs->load("contracts");
if ($user->rights->contrat->creer) { if ($user->rights->contrat->creer) {
print '<div class="inline-block divButAction"><a class="butAction" href="' . DOL_URL_ROOT . '/contrat/card.php?action=create&amp;origin=' . $object->element . '&amp;originid=' . $object->id . '&amp;socid=' . $object->socid . '">' . $langs->trans('AddContract') . '</a></div>'; print '<div class="inline-block divButAction"><a class="butAction" href="' . DOL_URL_ROOT . '/contrat/card.php?action=create&amp;origin=' . $object->element . '&amp;originid=' . $object->id . '&amp;socid=' . $object->socid . '">' . $langs->trans('AddContract') . '</a></div>';
} }
} }
// Ship // Ship
@ -2527,9 +2527,9 @@ if ($action == 'create' && $user->rights->commande->creer)
} }
} }
if ($object->statut > Commande::STATUS_DRAFT && $object->billed) { if ($object->statut > Commande::STATUS_DRAFT && $object->billed) {
if ($user->rights->commande->creer && $object->statut >= Commande::STATUS_VALIDATED && empty($conf->global->WORKFLOW_DISABLE_CLASSIFY_BILLED_FROM_ORDER) && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT)) { if ($user->rights->commande->creer && $object->statut >= Commande::STATUS_VALIDATED && empty($conf->global->WORKFLOW_DISABLE_CLASSIFY_BILLED_FROM_ORDER) && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT)) {
print '<div class="inline-block divButAction"><a class="butAction" href="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '&amp;action=classifyunbilled">' . $langs->trans("ClassifyUnBilled") . '</a></div>'; print '<div class="inline-block divButAction"><a class="butAction" href="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '&amp;action=classifyunbilled">' . $langs->trans("ClassifyUnBilled") . '</a></div>';
} }
} }
// Clone // Clone
if ($user->rights->commande->creer) { if ($user->rights->commande->creer) {
@ -2538,8 +2538,8 @@ if ($action == 'create' && $user->rights->commande->creer)
// Cancel order // Cancel order
if ($object->statut == Commande::STATUS_VALIDATED && if ($object->statut == Commande::STATUS_VALIDATED &&
((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->commande->cloturer)) ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->commande->cloturer))
|| (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->commande->order_advance->annuler))) || (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->commande->order_advance->annuler)))
) )
{ {
print '<div class="inline-block divButAction"><a class="butActionDelete" href="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '&amp;action=cancel">' . $langs->trans('Cancel') . '</a></div>'; print '<div class="inline-block divButAction"><a class="butActionDelete" href="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '&amp;action=cancel">' . $langs->trans('Cancel') . '</a></div>';

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -267,22 +267,22 @@ class EmailSenderProfile extends CommonObject
function getNomUrl($withpicto=0) function getNomUrl($withpicto=0)
{ {
global $db, $conf, $langs; global $db, $conf, $langs;
global $dolibarr_main_authentication, $dolibarr_main_demo; global $dolibarr_main_authentication, $dolibarr_main_demo;
global $menumanager; global $menumanager;
$result = ''; $result = '';
$companylink = ''; $companylink = '';
$url=''; $url='';
//$url = dol_buildpath('/monmodule/emailsenderprofile_card.php',1).'?id='.$this->id; //$url = dol_buildpath('/monmodule/emailsenderprofile_card.php',1).'?id='.$this->id;
$linkstart = ''; $linkstart = '';
$linkend=''; $linkend='';
if ($withpicto) if ($withpicto)
{ {
$result.=($linkstart.img_object($label, 'label', 'class="classfortooltip"').$linkend); $result.=($linkstart.img_object($label, 'label', 'class="classfortooltip"').$linkend);
if ($withpicto != 2) $result.=' '; if ($withpicto != 2) $result.=' ';
} }
$result.= $linkstart . $this->label . $linkend; $result.= $linkstart . $this->label . $linkend;
return $result; return $result;

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -96,15 +96,15 @@ class ExpenseReportRule extends CoreObject
/** /**
* Attribute object linked with database * Attribute object linked with database
* @var array * @var array
*/ */
protected $fields=array( protected $fields=array(
'rowid'=>array('type'=>'integer','index'=>true) 'rowid'=>array('type'=>'integer','index'=>true)
,'dates'=>array('type'=>'date') ,'dates'=>array('type'=>'date')
,'datee'=>array('type'=>'date') ,'datee'=>array('type'=>'date')
,'amount'=>array('type'=>'double') ,'amount'=>array('type'=>'double')
,'restrictive'=>array('type'=>'integer') ,'restrictive'=>array('type'=>'integer')
,'fk_user'=>array('type'=>'integer') ,'fk_user'=>array('type'=>'integer')
,'fk_usergroup'=>array('type'=>'integer') ,'fk_usergroup'=>array('type'=>'integer')
@ -114,16 +114,16 @@ class ExpenseReportRule extends CoreObject
,'entity'=>array('type'=>'integer') ,'entity'=>array('type'=>'integer')
); );
/** /**
* Constructor * Constructor
* *
* @param DoliDB $db Database handler * @param DoliDB $db Database handler
*/ */
public function __construct(DoliDB &$db) public function __construct(DoliDB &$db)
{ {
global $conf; global $conf;
parent::__construct($db); parent::__construct($db);
parent::init(); parent::init();
$this->errors = array(); $this->errors = array();

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -540,164 +540,164 @@ if ($socid && $action != 'edit' && $action != "create")
print ' '.img_picto($langs->trans("SwiftValid"),'info'); print ' '.img_picto($langs->trans("SwiftValid"),'info');
} }
} }
print '</td>'; print '</td>';
if (! empty($conf->prelevement->enabled)) if (! empty($conf->prelevement->enabled))
{ {
// RUM // RUM
//print '<td>'.$prelevement->buildRumNumber($object->code_client, $rib->datec, $rib->id).'</td>'; //print '<td>'.$prelevement->buildRumNumber($object->code_client, $rib->datec, $rib->id).'</td>';
print '<td>'.$rib->rum.'</td>'; print '<td>'.$rib->rum.'</td>';
// FRSTRECUR // FRSTRECUR
print '<td>'.$rib->frstrecur.'</td>'; print '<td>'.$rib->frstrecur.'</td>';
} }
// Default // Default
print '<td align="center" width="70">'; print '<td align="center" width="70">';
if (!$rib->default_rib) { if (!$rib->default_rib) {
print '<a href="'.DOL_URL_ROOT.'/societe/rib.php?socid='.$object->id.'&ribid='.$rib->id.'&action=setasdefault">'; print '<a href="'.DOL_URL_ROOT.'/societe/rib.php?socid='.$object->id.'&ribid='.$rib->id.'&action=setasdefault">';
print img_picto($langs->trans("Disabled"),'off'); print img_picto($langs->trans("Disabled"),'off');
print '</a>'; print '</a>';
} else { } else {
print img_picto($langs->trans("Enabled"),'on'); print img_picto($langs->trans("Enabled"),'on');
} }
print '</td>'; print '</td>';
// Generate doc // Generate doc
print '<td align="center">'; print '<td align="center">';
$buttonlabel = $langs->trans("BuildDoc"); $buttonlabel = $langs->trans("BuildDoc");
$forname='builddocrib'.$rib->id; $forname='builddocrib'.$rib->id;
include_once DOL_DOCUMENT_ROOT.'/core/modules/bank/modules_bank.php'; include_once DOL_DOCUMENT_ROOT.'/core/modules/bank/modules_bank.php';
$modellist=ModeleBankAccountDoc::liste_modeles($db); $modellist=ModeleBankAccountDoc::liste_modeles($db);
$out = ''; $out = '';
if (is_array($modellist) && count($modellist)) if (is_array($modellist) && count($modellist))
{ {
$out.= '<form action="'.$urlsource.(empty($conf->global->MAIN_JUMP_TAG)?'':'#builddoc').'" name="'.$forname.'" id="'.$forname.'_form" method="post">'; $out.= '<form action="'.$urlsource.(empty($conf->global->MAIN_JUMP_TAG)?'':'#builddoc').'" name="'.$forname.'" id="'.$forname.'_form" method="post">';
$out.= '<input type="hidden" name="action" value="builddocrib">'; $out.= '<input type="hidden" name="action" value="builddocrib">';
$out.= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; $out.= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
$out.= '<input type="hidden" name="socid" value="'.$object->id.'">'; $out.= '<input type="hidden" name="socid" value="'.$object->id.'">';
$out.= '<input type="hidden" name="companybankid" value="'.$rib->id.'">'; $out.= '<input type="hidden" name="companybankid" value="'.$rib->id.'">';
if (is_array($modellist) && count($modellist) == 1) // If there is only one element if (is_array($modellist) && count($modellist) == 1) // If there is only one element
{ {
$arraykeys=array_keys($modellist); $arraykeys=array_keys($modellist);
$modelselected=$arraykeys[0]; $modelselected=$arraykeys[0];
} }
if (! empty($conf->global->BANKADDON_PDF)) $modelselected = $conf->global->BANKADDON_PDF; if (! empty($conf->global->BANKADDON_PDF)) $modelselected = $conf->global->BANKADDON_PDF;
$out.= $form->selectarray('modelrib'.$rib->id, $modellist, $modelselected, $showempty, 0, 0, '', 0, 0, 0, '', 'minwidth100'); $out.= $form->selectarray('modelrib'.$rib->id, $modellist, $modelselected, $showempty, 0, 0, '', 0, 0, 0, '', 'minwidth100');
$out.= ajax_combobox('modelrib'.$rib->id); $out.= ajax_combobox('modelrib'.$rib->id);
// Language code (if multilang) // Language code (if multilang)
if ($conf->global->MAIN_MULTILANGS) if ($conf->global->MAIN_MULTILANGS)
{ {
include_once DOL_DOCUMENT_ROOT.'/core/class/html.formadmin.class.php'; include_once DOL_DOCUMENT_ROOT.'/core/class/html.formadmin.class.php';
$formadmin=new FormAdmin($db); $formadmin=new FormAdmin($db);
$defaultlang=$codelang?$codelang:$langs->getDefaultLang(); $defaultlang=$codelang?$codelang:$langs->getDefaultLang();
$morecss='maxwidth150'; $morecss='maxwidth150';
if (! empty($conf->browser->phone)) $morecss='maxwidth100'; if (! empty($conf->browser->phone)) $morecss='maxwidth100';
$out.= $formadmin->select_language($defaultlang, 'lang_idrib'.$rib->id, 0, 0, 0, 0, 0, $morecss); $out.= $formadmin->select_language($defaultlang, 'lang_idrib'.$rib->id, 0, 0, 0, 0, 0, $morecss);
} }
// Button // Button
$genbutton = '<input class="button buttongen" id="'.$forname.'_generatebutton" name="'.$forname.'_generatebutton"'; $genbutton = '<input class="button buttongen" id="'.$forname.'_generatebutton" name="'.$forname.'_generatebutton"';
$genbutton.= ' type="submit" value="'.$buttonlabel.'"'; $genbutton.= ' type="submit" value="'.$buttonlabel.'"';
if (! $allowgenifempty && ! is_array($modellist) && empty($modellist)) $genbutton.= ' disabled'; if (! $allowgenifempty && ! is_array($modellist) && empty($modellist)) $genbutton.= ' disabled';
$genbutton.= '>'; $genbutton.= '>';
if ($allowgenifempty && ! is_array($modellist) && empty($modellist) && empty($conf->dol_no_mouse_hover) && $modulepart != 'unpaid') if ($allowgenifempty && ! is_array($modellist) && empty($modellist) && empty($conf->dol_no_mouse_hover) && $modulepart != 'unpaid')
{ {
$langs->load("errors"); $langs->load("errors");
$genbutton.= ' '.img_warning($langs->transnoentitiesnoconv("WarningNoDocumentModelActivated")); $genbutton.= ' '.img_warning($langs->transnoentitiesnoconv("WarningNoDocumentModelActivated"));
} }
if (! $allowgenifempty && ! is_array($modellist) && empty($modellist) && empty($conf->dol_no_mouse_hover) && $modulepart != 'unpaid') $genbutton=''; if (! $allowgenifempty && ! is_array($modellist) && empty($modellist) && empty($conf->dol_no_mouse_hover) && $modulepart != 'unpaid') $genbutton='';
if (empty($modellist) && ! $showempty && $modulepart != 'unpaid') $genbutton=''; if (empty($modellist) && ! $showempty && $modulepart != 'unpaid') $genbutton='';
$out.= $genbutton; $out.= $genbutton;
$out.= '</form>'; $out.= '</form>';
} }
print $out; print $out;
print '</td>'; print '</td>';
// Edit/Delete // Edit/Delete
print '<td align="right">'; print '<td align="right">';
if ($user->rights->societe->creer) if ($user->rights->societe->creer)
{ {
print '<a href="'.DOL_URL_ROOT.'/societe/rib.php?socid='.$object->id.'&id='.$rib->id.'&action=edit">'; print '<a href="'.DOL_URL_ROOT.'/societe/rib.php?socid='.$object->id.'&id='.$rib->id.'&action=edit">';
print img_picto($langs->trans("Modify"),'edit'); print img_picto($langs->trans("Modify"),'edit');
print '</a>'; print '</a>';
print '&nbsp;'; print '&nbsp;';
print '<a href="'.DOL_URL_ROOT.'/societe/rib.php?socid='.$object->id.'&id='.$rib->id.'&action=delete">'; print '<a href="'.DOL_URL_ROOT.'/societe/rib.php?socid='.$object->id.'&id='.$rib->id.'&action=delete">';
print img_picto($langs->trans("Delete"),'delete'); print img_picto($langs->trans("Delete"),'delete');
print '</a>'; print '</a>';
} }
print '</td>'; print '</td>';
print '</tr>'; print '</tr>';
} }
if (count($rib_list) == 0) if (count($rib_list) == 0)
{ {
$colspan=8; $colspan=8;
if (! empty($conf->prelevement->enabled)) $colspan+=2; if (! empty($conf->prelevement->enabled)) $colspan+=2;
print '<tr '.$bc[0].'><td colspan="'.$colspan.'" class="opacitymedium">'.$langs->trans("NoBANRecord").'</td></tr>'; print '<tr '.$bc[0].'><td colspan="'.$colspan.'" class="opacitymedium">'.$langs->trans("NoBANRecord").'</td></tr>';
} }
print '</table>'; print '</table>';
print '</div>'; print '</div>';
} else { } else {
dol_print_error($db); dol_print_error($db);
} }
dol_fiche_end(); dol_fiche_end();
if ($socid && $action != 'edit' && $action != 'create') if ($socid && $action != 'edit' && $action != 'create')
{ {
/* /*
* Barre d'actions * Barre d'actions
*/ */
print '<div class="tabsAction">'; print '<div class="tabsAction">';
if ($user->rights->societe->creer) if ($user->rights->societe->creer)
{ {
print '<a class="butAction" href="rib.php?socid='.$object->id.'&amp;action=create">'.$langs->trans("Add").'</a>'; print '<a class="butAction" href="rib.php?socid='.$object->id.'&amp;action=create">'.$langs->trans("Add").'</a>';
} }
print '</div>'; print '</div>';
} }
if (empty($conf->global->SOCIETE_DISABLE_BUILDDOC)) if (empty($conf->global->SOCIETE_DISABLE_BUILDDOC))
{ {
print '<div class="fichecenter"><div class="fichehalfleft">'; print '<div class="fichecenter"><div class="fichehalfleft">';
print '<a name="builddoc"></a>'; // ancre print '<a name="builddoc"></a>'; // ancre
/* /*
* Documents generes * Documents generes
*/ */
$filedir=$conf->societe->multidir_output[$object->entity].'/'.$object->id; $filedir=$conf->societe->multidir_output[$object->entity].'/'.$object->id;
$urlsource=$_SERVER["PHP_SELF"]."?socid=".$object->id; $urlsource=$_SERVER["PHP_SELF"]."?socid=".$object->id;
$genallowed=$user->rights->societe->creer; $genallowed=$user->rights->societe->creer;
$delallowed=$user->rights->societe->supprimer; $delallowed=$user->rights->societe->supprimer;
$var=true; $var=true;
print $formfile->showdocuments('company', $object->id, $filedir, $urlsource, $genallowed, $delallowed, $object->modelpdf, 0, 0, 0, 28, 0, 'entity='.$object->entity, 0, '', $object->default_lang); print $formfile->showdocuments('company', $object->id, $filedir, $urlsource, $genallowed, $delallowed, $object->modelpdf, 0, 0, 0, 28, 0, 'entity='.$object->entity, 0, '', $object->default_lang);
print '</div><div class="fichehalfright"><div class="ficheaddleft">'; print '</div><div class="fichehalfright"><div class="ficheaddleft">';
print '</div></div></div>'; print '</div></div></div>';
print '<br>'; print '<br>';
} }
/* /*
include_once DOL_DOCUMENT_ROOT.'/core/modules/bank/modules_bank.php'; include_once DOL_DOCUMENT_ROOT.'/core/modules/bank/modules_bank.php';
$modellist=ModeleBankAccountDoc::liste_modeles($db); $modellist=ModeleBankAccountDoc::liste_modeles($db);
//print '<td>'; //print '<td>';

View File

@ -194,8 +194,8 @@ if (empty($reshook))
// Validation // Validation
else if ($action == 'confirm_validate' && $confirm == 'yes' && else if ($action == 'confirm_validate' && $confirm == 'yes' &&
((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->supplier_proposal->creer)) ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->supplier_proposal->creer))
|| (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->supplier_proposal->validate_advance))) || (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->supplier_proposal->validate_advance)))
) )
{ {
$result = $object->valid($user); $result = $object->valid($user);
@ -258,7 +258,7 @@ if (empty($reshook))
if ($object->fetch(GETPOST('copie_supplier_proposal')) > 0) { if ($object->fetch(GETPOST('copie_supplier_proposal')) > 0) {
$object->ref = GETPOST('ref'); $object->ref = GETPOST('ref');
$object->date_livraison = $date_delivery; $object->date_livraison = $date_delivery;
$object->shipping_method_id = GETPOST('shipping_method_id', 'int'); $object->shipping_method_id = GETPOST('shipping_method_id', 'int');
$object->cond_reglement_id = GETPOST('cond_reglement_id'); $object->cond_reglement_id = GETPOST('cond_reglement_id');
$object->mode_reglement_id = GETPOST('mode_reglement_id'); $object->mode_reglement_id = GETPOST('mode_reglement_id');
$object->fk_account = GETPOST('fk_account', 'int'); $object->fk_account = GETPOST('fk_account', 'int');
@ -279,7 +279,7 @@ if (empty($reshook))
$object->ref = GETPOST('ref'); $object->ref = GETPOST('ref');
$object->date_livraison = $date_delivery; $object->date_livraison = $date_delivery;
$object->demand_reason_id = GETPOST('demand_reason_id'); $object->demand_reason_id = GETPOST('demand_reason_id');
$object->shipping_method_id = GETPOST('shipping_method_id', 'int'); $object->shipping_method_id = GETPOST('shipping_method_id', 'int');
$object->cond_reglement_id = GETPOST('cond_reglement_id'); $object->cond_reglement_id = GETPOST('cond_reglement_id');
$object->mode_reglement_id = GETPOST('mode_reglement_id'); $object->mode_reglement_id = GETPOST('mode_reglement_id');
$object->fk_account = GETPOST('fk_account', 'int'); $object->fk_account = GETPOST('fk_account', 'int');
@ -381,7 +381,7 @@ if (empty($reshook))
// Hooks // Hooks
$parameters = array('objFrom' => $srcobject); $parameters = array('objFrom' => $srcobject);
$reshook = $hookmanager->executeHooks('createFrom', $parameters, $object, $action); // Note that $action and $object may have been $reshook = $hookmanager->executeHooks('createFrom', $parameters, $object, $action); // Note that $action and $object may have been
// modified by hook // modified by hook
if ($reshook < 0) if ($reshook < 0)
$error ++; $error ++;
} else { } else {
@ -404,23 +404,23 @@ if (empty($reshook))
{ {
$db->commit(); $db->commit();
// Define output language // Define output language
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE))
{ {
$outputlangs = $langs; $outputlangs = $langs;
$newlang = ''; $newlang = '';
if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id','aZ09')) $newlang = GETPOST('lang_id','aZ09'); if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id','aZ09')) $newlang = GETPOST('lang_id','aZ09');
if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang; if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang;
if (! empty($newlang)) { if (! empty($newlang)) {
$outputlangs = new Translate("", $conf); $outputlangs = new Translate("", $conf);
$outputlangs->setDefaultLang($newlang); $outputlangs->setDefaultLang($newlang);
} }
$model=$object->modelpdf; $model=$object->modelpdf;
$ret = $object->fetch($id); // Reload to get new records $ret = $object->fetch($id); // Reload to get new records
$result=$object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); $result=$object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
if ($result < 0) dol_print_error($db,$result); if ($result < 0) dol_print_error($db,$result);
} }
header('Location: ' . $_SERVER["PHP_SELF"] . '?id=' . $id); header('Location: ' . $_SERVER["PHP_SELF"] . '?id=' . $id);
exit(); exit();
@ -451,8 +451,8 @@ if (empty($reshook))
// Close proposal // Close proposal
else if ($action == 'close' && $user->rights->supplier_proposal->cloturer && ! GETPOST('cancel','alpha')) { else if ($action == 'close' && $user->rights->supplier_proposal->cloturer && ! GETPOST('cancel','alpha')) {
// prevent browser refresh from reopening proposal several times // prevent browser refresh from reopening proposal several times
if ($object->statut == SupplierProposal::STATUS_SIGNED) { if ($object->statut == SupplierProposal::STATUS_SIGNED) {
$object->setStatut(SupplierProposal::STATUS_CLOSE); $object->setStatut(SupplierProposal::STATUS_CLOSE);
} }
} }
@ -465,7 +465,7 @@ if (empty($reshook))
} else { } else {
// prevent browser refresh from closing proposal several times // prevent browser refresh from closing proposal several times
if ($object->statut == SupplierProposal::STATUS_VALIDATED) { if ($object->statut == SupplierProposal::STATUS_VALIDATED) {
$object->cloture($user, GETPOST('statut'), GETPOST('note','none')); $object->cloture($user, GETPOST('statut'), GETPOST('note','none'));
} }
} }
} }
@ -518,12 +518,12 @@ if (empty($reshook))
// Add a product line // Add a product line
if ($action == 'addline' && $user->rights->supplier_proposal->creer) if ($action == 'addline' && $user->rights->supplier_proposal->creer)
{ {
$langs->load('errors'); $langs->load('errors');
$error = 0; $error = 0;
// Set if we used free entry or predefined product // Set if we used free entry or predefined product
$predef=''; $predef='';
$ref_fourn = GETPOST('fourn_ref'); $ref_fourn = GETPOST('fourn_ref');
$product_desc=(GETPOST('dp_desc')?GETPOST('dp_desc'):''); $product_desc=(GETPOST('dp_desc')?GETPOST('dp_desc'):'');
$date_start=dol_mktime(GETPOST('date_start'.$predef.'hour'), GETPOST('date_start'.$predef.'min'), GETPOST('date_start' . $predef . 'sec'), GETPOST('date_start'.$predef.'month'), GETPOST('date_start'.$predef.'day'), GETPOST('date_start'.$predef.'year')); $date_start=dol_mktime(GETPOST('date_start'.$predef.'hour'), GETPOST('date_start'.$predef.'min'), GETPOST('date_start' . $predef . 'sec'), GETPOST('date_start'.$predef.'month'), GETPOST('date_start'.$predef.'day'), GETPOST('date_start'.$predef.'year'));
$date_end=dol_mktime(GETPOST('date_end'.$predef.'hour'), GETPOST('date_end'.$predef.'min'), GETPOST('date_end' . $predef . 'sec'), GETPOST('date_end'.$predef.'month'), GETPOST('date_end'.$predef.'day'), GETPOST('date_end'.$predef.'year')); $date_end=dol_mktime(GETPOST('date_end'.$predef.'hour'), GETPOST('date_end'.$predef.'min'), GETPOST('date_end' . $predef . 'sec'), GETPOST('date_end'.$predef.'month'), GETPOST('date_end'.$predef.'day'), GETPOST('date_end'.$predef.'year'));
@ -583,117 +583,117 @@ if (empty($reshook))
// Ecrase $txtva par celui du produit // Ecrase $txtva par celui du produit
if ((GETPOST('prod_entry_mode') != 'free') && empty($error)) // With combolist mode idprodfournprice is > 0 or -1. With autocomplete, idprodfournprice is > 0 or '' if ((GETPOST('prod_entry_mode') != 'free') && empty($error)) // With combolist mode idprodfournprice is > 0 or -1. With autocomplete, idprodfournprice is > 0 or ''
{ {
$productsupplier = new ProductFournisseur($db); $productsupplier = new ProductFournisseur($db);
if (empty($conf->global->SUPPLIER_PROPOSAL_WITH_NOPRICEDEFINED)) // TODO this test seems useless if (empty($conf->global->SUPPLIER_PROPOSAL_WITH_NOPRICEDEFINED)) // TODO this test seems useless
{ {
$idprod=0; $idprod=0;
if (GETPOST('idprodfournprice') == -1 || GETPOST('idprodfournprice') == '') $idprod=-99; // Same behaviour than with combolist. When not select idprodfournprice is now -99 (to avoid conflict with next action that may return -1, -2, ...) if (GETPOST('idprodfournprice') == -1 || GETPOST('idprodfournprice') == '') $idprod=-99; // Same behaviour than with combolist. When not select idprodfournprice is now -99 (to avoid conflict with next action that may return -1, -2, ...)
} }
if (preg_match('/^idprod_([0-9]+)$/',GETPOST('idprodfournprice'), $reg)) if (preg_match('/^idprod_([0-9]+)$/',GETPOST('idprodfournprice'), $reg))
{ {
$idprod=$reg[1]; $idprod=$reg[1];
$res=$productsupplier->fetch($idprod); $res=$productsupplier->fetch($idprod);
// Call to init properties of $productsupplier // Call to init properties of $productsupplier
// So if a supplier price already exists for another thirdparty (first one found), we use it as reference price // So if a supplier price already exists for another thirdparty (first one found), we use it as reference price
$productsupplier->get_buyprice(0, -1, $idprod, 'none'); // We force qty to -1 to be sure to find if a supplier price exist $productsupplier->get_buyprice(0, -1, $idprod, 'none'); // We force qty to -1 to be sure to find if a supplier price exist
} }
elseif (GETPOST('idprodfournprice') > 0) elseif (GETPOST('idprodfournprice') > 0)
{ {
//$qtytosearch=$qty; // Just to see if a price exists for the quantity. Not used to found vat. //$qtytosearch=$qty; // Just to see if a price exists for the quantity. Not used to found vat.
$qtytosearch=-1; // We force qty to -1 to be sure to find if a supplier price exist $qtytosearch=-1; // We force qty to -1 to be sure to find if a supplier price exist
$idprod=$productsupplier->get_buyprice(GETPOST('idprodfournprice'), $qtytosearch); $idprod=$productsupplier->get_buyprice(GETPOST('idprodfournprice'), $qtytosearch);
$res=$productsupplier->fetch($idprod); $res=$productsupplier->fetch($idprod);
} }
if ($idprod > 0) if ($idprod > 0)
{ {
$pu_ht = $productsupplier->fourn_pu; $pu_ht = $productsupplier->fourn_pu;
$price_base_type = $productsupplier->fourn_price_base_type; $price_base_type = $productsupplier->fourn_price_base_type;
$type = $productsupplier->type; $type = $productsupplier->type;
$label = $productsupplier->label; $label = $productsupplier->label;
$desc = $productsupplier->description; $desc = $productsupplier->description;
if (trim($product_desc) != trim($desc)) $desc = dol_concatdesc($desc, $product_desc); if (trim($product_desc) != trim($desc)) $desc = dol_concatdesc($desc, $product_desc);
$tva_tx = get_default_tva($object->thirdparty, $mysoc, $productsupplier->id, GETPOST('idprodfournprice')); $tva_tx = get_default_tva($object->thirdparty, $mysoc, $productsupplier->id, GETPOST('idprodfournprice'));
$tva_npr = get_default_npr($object->thirdparty, $mysoc, $productsupplier->id, GETPOST('idprodfournprice')); $tva_npr = get_default_npr($object->thirdparty, $mysoc, $productsupplier->id, GETPOST('idprodfournprice'));
if (empty($tva_tx)) $tva_npr=0; if (empty($tva_tx)) $tva_npr=0;
$localtax1_tx= get_localtax($tva_tx, 1, $mysoc, $object->thirdparty, $tva_npr); $localtax1_tx= get_localtax($tva_tx, 1, $mysoc, $object->thirdparty, $tva_npr);
$localtax2_tx= get_localtax($tva_tx, 2, $mysoc, $object->thirdparty, $tva_npr); $localtax2_tx= get_localtax($tva_tx, 2, $mysoc, $object->thirdparty, $tva_npr);
$result=$object->addline( $result=$object->addline(
$desc, $desc,
$pu_ht, $pu_ht,
$qty, $qty,
$tva_tx, $tva_tx,
$localtax1_tx, $localtax1_tx,
$localtax2_tx, $localtax2_tx,
$productsupplier->id, $productsupplier->id,
$remise_percent, $remise_percent,
$price_base_type, $price_base_type,
$pu_ttc, $pu_ttc,
$tva_npr, $tva_npr,
$type, $type,
-1, -1,
0, 0,
GETPOST('fk_parent_line'), GETPOST('fk_parent_line'),
$fournprice, $fournprice,
$buyingprice, $buyingprice,
$label, $label,
$array_options, $array_options,
$ref_fourn, $ref_fourn,
$fk_unit $fk_unit
); );
//var_dump($tva_tx);var_dump($productsupplier->fourn_pu);var_dump($price_base_type);exit; //var_dump($tva_tx);var_dump($productsupplier->fourn_pu);var_dump($price_base_type);exit;
} }
if ($idprod == -99 || $idprod == 0) if ($idprod == -99 || $idprod == 0)
{ {
// Product not selected // Product not selected
$error++; $error++;
$langs->load("errors"); $langs->load("errors");
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("ProductOrService")).' '.$langs->trans("or").' '.$langs->trans("NoPriceDefinedForThisSupplier"), null, 'errors'); setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("ProductOrService")).' '.$langs->trans("or").' '.$langs->trans("NoPriceDefinedForThisSupplier"), null, 'errors');
} }
if ($idprod == -1) if ($idprod == -1)
{ {
// Quantity too low // Quantity too low
$error++; $error++;
$langs->load("errors"); $langs->load("errors");
setEventMessages($langs->trans("ErrorQtyTooLowForThisSupplier"), null, 'errors'); setEventMessages($langs->trans("ErrorQtyTooLowForThisSupplier"), null, 'errors');
} }
} }
else if((GETPOST('price_ht')!=='' || GETPOST('price_ttc')!=='') && empty($error)) // Free product else if((GETPOST('price_ht')!=='' || GETPOST('price_ttc')!=='') && empty($error)) // Free product
{ {
$pu_ht = price2num($price_ht, 'MU'); $pu_ht = price2num($price_ht, 'MU');
$pu_ttc = price2num(GETPOST('price_ttc'), 'MU'); $pu_ttc = price2num(GETPOST('price_ttc'), 'MU');
$tva_npr = (preg_match('/\*/', $tva_tx) ? 1 : 0); $tva_npr = (preg_match('/\*/', $tva_tx) ? 1 : 0);
$tva_tx = str_replace('*', '', $tva_tx); $tva_tx = str_replace('*', '', $tva_tx);
$label = (GETPOST('product_label') ? GETPOST('product_label') : ''); $label = (GETPOST('product_label') ? GETPOST('product_label') : '');
$desc = $product_desc; $desc = $product_desc;
$type = GETPOST('type'); $type = GETPOST('type');
$fk_unit= GETPOST('units', 'alpha'); $fk_unit= GETPOST('units', 'alpha');
$tva_tx = price2num($tva_tx); // When vat is text input field $tva_tx = price2num($tva_tx); // When vat is text input field
// Local Taxes // Local Taxes
$localtax1_tx= get_localtax($tva_tx, 1, $mysoc, $object->thirdparty); $localtax1_tx= get_localtax($tva_tx, 1, $mysoc, $object->thirdparty);
$localtax2_tx= get_localtax($tva_tx, 2, $mysoc, $object->thirdparty); $localtax2_tx= get_localtax($tva_tx, 2, $mysoc, $object->thirdparty);
if (GETPOST('price_ht')!=='') if (GETPOST('price_ht')!=='')
{ {
$price_base_type = 'HT'; $price_base_type = 'HT';
$ht = price2num(GETPOST('price_ht')); $ht = price2num(GETPOST('price_ht'));
$ttc = 0; $ttc = 0;
} }
else else
{ {
$ttc = price2num(GETPOST('price_ttc')); $ttc = price2num(GETPOST('price_ttc'));
$ht = $ttc / (1 + ($tva_tx / 100)); $ht = $ttc / (1 + ($tva_tx / 100));
$price_base_type = 'HT'; $price_base_type = 'HT';
} }
$result = $object->addline($desc, $ht, $qty, $tva_tx, $localtax1_tx, $localtax2_tx, $idprod, $remise_percent, $price_base_type, $ttc, $info_bits, $type, - 1, 0, GETPOST('fk_parent_line'), $fournprice, $buyingprice, $label, $array_options, $ref_fourn, $fk_unit); $result = $object->addline($desc, $ht, $qty, $tva_tx, $localtax1_tx, $localtax2_tx, $idprod, $remise_percent, $price_base_type, $ttc, $info_bits, $type, - 1, 0, GETPOST('fk_parent_line'), $fournprice, $buyingprice, $label, $array_options, $ref_fourn, $fk_unit);
//$result = $object->addline($desc, $ht, $qty, $tva_tx, $localtax1_tx, $localtax2_tx, 0, 0, '', $remise_percent, $price_base_type, $ttc, $type,'','', $date_start, $date_end, $array_options, $fk_unit); //$result = $object->addline($desc, $ht, $qty, $tva_tx, $localtax1_tx, $localtax2_tx, 0, 0, '', $remise_percent, $price_base_type, $ttc, $type,'','', $date_start, $date_end, $array_options, $fk_unit);
} }
@ -706,9 +706,9 @@ if (empty($reshook))
{ {
$outputlangs = $langs; $outputlangs = $langs;
$newlang = ''; $newlang = '';
if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id','aZ09')) $newlang = GETPOST('lang_id','aZ09'); if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id','aZ09')) $newlang = GETPOST('lang_id','aZ09');
if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang; if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang;
if (! empty($newlang)) { if (! empty($newlang)) {
$outputlangs = new Translate("", $conf); $outputlangs = new Translate("", $conf);
$outputlangs->setDefaultLang($newlang); $outputlangs->setDefaultLang($newlang);
} }
@ -716,7 +716,7 @@ if (empty($reshook))
$ret = $object->fetch($id); // Reload to get new records $ret = $object->fetch($id); // Reload to get new records
$result=$object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); $result=$object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
if ($result < 0) dol_print_error($db,$result); if ($result < 0) dol_print_error($db,$result);
} }
unset($_POST['prod_entry_mode']); unset($_POST['prod_entry_mode']);
@ -729,7 +729,7 @@ if (empty($reshook))
unset($_POST['multicurrency_price_ht']); unset($_POST['multicurrency_price_ht']);
unset($_POST['price_ttc']); unset($_POST['price_ttc']);
unset($_POST['tva_tx']); unset($_POST['tva_tx']);
unset($_POST['label']); unset($_POST['label']);
unset($_POST['product_ref']); unset($_POST['product_ref']);
unset($_POST['product_label']); unset($_POST['product_label']);
unset($_POST['product_desc']); unset($_POST['product_desc']);
@ -958,9 +958,9 @@ $now = dol_now();
// Add new askprice // Add new askprice
if ($action == 'create') if ($action == 'create')
{ {
$currency_code = $conf->currency; $currency_code = $conf->currency;
print load_fiche_titre($langs->trans("NewAskPrice")); print load_fiche_titre($langs->trans("NewAskPrice"));
$soc = new Societe($db); $soc = new Societe($db);
if ($socid > 0) if ($socid > 0)
@ -997,8 +997,8 @@ if ($action == 'create')
if (!empty($conf->multicurrency->enabled)) if (!empty($conf->multicurrency->enabled))
{ {
if (!empty($objectsrc->multicurrency_code)) $currency_code = $objectsrc->multicurrency_code; if (!empty($objectsrc->multicurrency_code)) $currency_code = $objectsrc->multicurrency_code;
if (!empty($conf->global->MULTICURRENCY_USE_ORIGIN_TX) && !empty($objectsrc->multicurrency_tx)) $currency_tx = $objectsrc->multicurrency_tx; if (!empty($conf->global->MULTICURRENCY_USE_ORIGIN_TX) && !empty($objectsrc->multicurrency_tx)) $currency_tx = $objectsrc->multicurrency_tx;
} }
} }
else else
@ -1036,7 +1036,7 @@ if ($action == 'create')
} else { } else {
print '<td colspan="2">'; print '<td colspan="2">';
print $form->select_company('', 'socid', 's.fournisseur = 1', 'SelectThirdParty', 0, 0, null, 0, 'minwidth300'); print $form->select_company('', 'socid', 's.fournisseur = 1', 'SelectThirdParty', 0, 0, null, 0, 'minwidth300');
print ' <a href="'.DOL_URL_ROOT.'/societe/card.php?action=create&client=0&fournisseur=1&backtopage='.urlencode($_SERVER["PHP_SELF"].'?action=create').'">'.$langs->trans("AddThirdParty").'</a>'; print ' <a href="'.DOL_URL_ROOT.'/societe/card.php?action=create&client=0&fournisseur=1&backtopage='.urlencode($_SERVER["PHP_SELF"].'?action=create').'">'.$langs->trans("AddThirdParty").'</a>';
print '</td>'; print '</td>';
} }
print '</tr>' . "\n"; print '</tr>' . "\n";
@ -1051,19 +1051,19 @@ if ($action == 'create')
$form->select_types_paiements(GETPOST('mode_reglement_id') > 0 ? GETPOST('mode_reglement_id') : $mode_reglement_id, 'mode_reglement_id'); $form->select_types_paiements(GETPOST('mode_reglement_id') > 0 ? GETPOST('mode_reglement_id') : $mode_reglement_id, 'mode_reglement_id');
print '</td></tr>'; print '</td></tr>';
// Bank Account // Bank Account
if (! empty($conf->global->BANK_ASK_PAYMENT_BANK_DURING_PROPOSAL) && ! empty($conf->banque->enabled)) { if (! empty($conf->global->BANK_ASK_PAYMENT_BANK_DURING_PROPOSAL) && ! empty($conf->banque->enabled)) {
print '<tr><td>' . $langs->trans('BankAccount') . '</td><td colspan="2">'; print '<tr><td>' . $langs->trans('BankAccount') . '</td><td colspan="2">';
$form->select_comptes(GETPOST('fk_account')>0 ? GETPOST('fk_account','int') : $fk_account, 'fk_account', 0, '', 1); $form->select_comptes(GETPOST('fk_account')>0 ? GETPOST('fk_account','int') : $fk_account, 'fk_account', 0, '', 1);
print '</td></tr>'; print '</td></tr>';
} }
// Shipping Method // Shipping Method
if (! empty($conf->expedition->enabled)) { if (! empty($conf->expedition->enabled)) {
print '<tr><td>' . $langs->trans('SendingMethod') . '</td><td colspan="2">'; print '<tr><td>' . $langs->trans('SendingMethod') . '</td><td colspan="2">';
print $form->selectShippingMethod(GETPOST('shipping_method_id') > 0 ? GETPOST('shipping_method_id', 'int') : $shipping_method_id, 'shipping_method_id', '', 1); print $form->selectShippingMethod(GETPOST('shipping_method_id') > 0 ? GETPOST('shipping_method_id', 'int') : $shipping_method_id, 'shipping_method_id', '', 1);
print '</td></tr>'; print '</td></tr>';
} }
// Delivery date (or manufacturing) // Delivery date (or manufacturing)
print '<tr><td>' . $langs->trans("DeliveryDate") . '</td>'; print '<tr><td>' . $langs->trans("DeliveryDate") . '</td>';
@ -1115,15 +1115,15 @@ if ($action == 'create')
{ {
print '<tr>'; print '<tr>';
print '<td>'.fieldLabel('Currency','multicurrency_code').'</td>'; print '<td>'.fieldLabel('Currency','multicurrency_code').'</td>';
print '<td colspan="3" class="maxwidthonsmartphone">'; print '<td colspan="3" class="maxwidthonsmartphone">';
print $form->selectMultiCurrency($currency_code, 'multicurrency_code'); print $form->selectMultiCurrency($currency_code, 'multicurrency_code');
print '</td></tr>'; print '</td></tr>';
} }
// Other attributes // Other attributes
$parameters = array('colspan' => ' colspan="3"'); $parameters = array('colspan' => ' colspan="3"');
$reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
print $hookmanager->resPrint; print $hookmanager->resPrint;
if (empty($reshook) && ! empty($extrafields->attribute_label)) { if (empty($reshook) && ! empty($extrafields->attribute_label)) {
print $object->showOptionals($extrafields, 'edit'); print $object->showOptionals($extrafields, 'edit');
} }
@ -1181,7 +1181,7 @@ if ($action == 'create')
if (! empty($conf->global->SUPPLIER_PROPOSAL_CLONE_ON_CREATE_PAGE)) if (! empty($conf->global->SUPPLIER_PROPOSAL_CLONE_ON_CREATE_PAGE))
{ {
print '<br><table>'; print '<br><table>';
// For backward compatibility // For backward compatibility
print '<tr>'; print '<tr>';
@ -1339,34 +1339,34 @@ if ($action == 'create')
// Project // Project
if (! empty($conf->projet->enabled)) if (! empty($conf->projet->enabled))
{ {
$langs->load("projects"); $langs->load("projects");
$morehtmlref.='<br>'.$langs->trans('Project') . ' '; $morehtmlref.='<br>'.$langs->trans('Project') . ' ';
if ($user->rights->supplier_proposal->creer) if ($user->rights->supplier_proposal->creer)
{ {
if ($action != 'classify') if ($action != 'classify')
$morehtmlref.='<a href="' . $_SERVER['PHP_SELF'] . '?action=classify&amp;id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : '; $morehtmlref.='<a href="' . $_SERVER['PHP_SELF'] . '?action=classify&amp;id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : ';
if ($action == 'classify') { if ($action == 'classify') {
//$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1);
$morehtmlref.='<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">'; $morehtmlref.='<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">';
$morehtmlref.='<input type="hidden" name="action" value="classin">'; $morehtmlref.='<input type="hidden" name="action" value="classin">';
$morehtmlref.='<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; $morehtmlref.='<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
$morehtmlref.=$formproject->select_projects((empty($conf->global->PROJECT_CAN_ALWAYS_LINK_TO_ALL_SUPPLIERS)?$object->socid:-1), $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); $morehtmlref.=$formproject->select_projects((empty($conf->global->PROJECT_CAN_ALWAYS_LINK_TO_ALL_SUPPLIERS)?$object->socid:-1), $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1);
$morehtmlref.='<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">'; $morehtmlref.='<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">';
$morehtmlref.='</form>'; $morehtmlref.='</form>';
} else { } else {
$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1);
} }
} else { } else {
if (! empty($object->fk_project)) { if (! empty($object->fk_project)) {
$proj = new Project($db); $proj = new Project($db);
$proj->fetch($object->fk_project); $proj->fetch($object->fk_project);
$morehtmlref.='<a href="'.DOL_URL_ROOT.'/projet/card.php?id=' . $object->fk_project . '" title="' . $langs->trans('ShowProject') . '">'; $morehtmlref.='<a href="'.DOL_URL_ROOT.'/projet/card.php?id=' . $object->fk_project . '" title="' . $langs->trans('ShowProject') . '">';
$morehtmlref.=$proj->ref; $morehtmlref.=$proj->ref;
$morehtmlref.='</a>'; $morehtmlref.='</a>';
} else { } else {
$morehtmlref.=''; $morehtmlref.='';
} }
} }
} }
$morehtmlref.='</div>'; $morehtmlref.='</div>';
@ -1468,17 +1468,17 @@ if ($action == 'create')
print '</tr></table>'; print '</tr></table>';
print '</td><td colspan="3">'; print '</td><td colspan="3">';
if ($action == 'editmulticurrencyrate' || $action == 'actualizemulticurrencyrate') { if ($action == 'editmulticurrencyrate' || $action == 'actualizemulticurrencyrate') {
if($action == 'actualizemulticurrencyrate') { if($action == 'actualizemulticurrencyrate') {
list($object->fk_multicurrency, $object->multicurrency_tx) = MultiCurrency::getIdAndTxFromCode($object->db, $object->multicurrency_code); list($object->fk_multicurrency, $object->multicurrency_tx) = MultiCurrency::getIdAndTxFromCode($object->db, $object->multicurrency_code);
} }
$form->form_multicurrency_rate($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_tx, 'multicurrency_tx', $object->multicurrency_code); $form->form_multicurrency_rate($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_tx, 'multicurrency_tx', $object->multicurrency_code);
} else { } else {
$form->form_multicurrency_rate($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_tx, 'none', $object->multicurrency_code); $form->form_multicurrency_rate($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_tx, 'none', $object->multicurrency_code);
if($object->statut == $object::STATUS_DRAFT && $object->multicurrency_code && $object->multicurrency_code != $conf->currency) { if($object->statut == $object::STATUS_DRAFT && $object->multicurrency_code && $object->multicurrency_code != $conf->currency) {
print '<div class="inline-block"> &nbsp; &nbsp; &nbsp; &nbsp; '; print '<div class="inline-block"> &nbsp; &nbsp; &nbsp; &nbsp; ';
print '<a href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=actualizemulticurrencyrate">'.$langs->trans("ActualizeCurrency").'</a>'; print '<a href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=actualizemulticurrencyrate">'.$langs->trans("ActualizeCurrency").'</a>';
print '</div>'; print '</div>';
} }
} }
print '</td></tr>'; print '</td></tr>';
} }
@ -1498,22 +1498,22 @@ if ($action == 'create')
if (! empty($conf->global->BANK_ASK_PAYMENT_BANK_DURING_PROPOSAL) && ! empty($conf->banque->enabled)) if (! empty($conf->global->BANK_ASK_PAYMENT_BANK_DURING_PROPOSAL) && ! empty($conf->banque->enabled))
{ {
// Bank Account // Bank Account
print '<tr><td>'; print '<tr><td>';
print '<table width="100%" class="nobordernopadding"><tr><td>'; print '<table width="100%" class="nobordernopadding"><tr><td>';
print $langs->trans('BankAccount'); print $langs->trans('BankAccount');
print '</td>'; print '</td>';
if ($action != 'editbankaccount' && $user->rights->supplier_proposal->creer) if ($action != 'editbankaccount' && $user->rights->supplier_proposal->creer)
print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editbankaccount&amp;id='.$object->id.'">'.img_edit($langs->trans('SetBankAccount'),1).'</a></td>'; print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editbankaccount&amp;id='.$object->id.'">'.img_edit($langs->trans('SetBankAccount'),1).'</a></td>';
print '</tr></table>'; print '</tr></table>';
print '</td><td colspan="3">'; print '</td><td colspan="3">';
if ($action == 'editbankaccount') { if ($action == 'editbankaccount') {
$form->formSelectAccount($_SERVER['PHP_SELF'].'?id='.$object->id, $object->fk_account, 'fk_account', 1); $form->formSelectAccount($_SERVER['PHP_SELF'].'?id='.$object->id, $object->fk_account, 'fk_account', 1);
} else { } else {
$form->formSelectAccount($_SERVER['PHP_SELF'].'?id='.$object->id, $object->fk_account, 'none'); $form->formSelectAccount($_SERVER['PHP_SELF'].'?id='.$object->id, $object->fk_account, 'none');
} }
print '</td>'; print '</td>';
print '</tr>'; print '</tr>';
} }
// Other attributes // Other attributes
@ -1619,7 +1619,7 @@ if ($action == 'create')
include DOL_DOCUMENT_ROOT . '/core/tpl/ajaxrow.tpl.php'; include DOL_DOCUMENT_ROOT . '/core/tpl/ajaxrow.tpl.php';
} }
print '<div class="div-table-responsive-no-min">'; print '<div class="div-table-responsive-no-min">';
print '<table id="tablelines" class="noborder noshadow" width="100%">'; print '<table id="tablelines" class="noborder noshadow" width="100%">';
// Add free products/services form // Add free products/services form
@ -1643,7 +1643,7 @@ if ($action == 'create')
} }
print '</table>'; print '</table>';
print '</div>'; print '</div>';
print "</form>\n"; print "</form>\n";
dol_fiche_end(); dol_fiche_end();
@ -1684,15 +1684,15 @@ if ($action == 'create')
$parameters = array(); $parameters = array();
$reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been
// modified by hook // modified by hook
if (empty($reshook)) if (empty($reshook))
{ {
if ($action != 'statut' && $action != 'editline') if ($action != 'statut' && $action != 'editline')
{ {
// Validate // Validate
if ($object->statut == SupplierProposal::STATUS_DRAFT && $object->total_ttc >= 0 && count($object->lines) > 0 && if ($object->statut == SupplierProposal::STATUS_DRAFT && $object->total_ttc >= 0 && count($object->lines) > 0 &&
((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->supplier_proposal->creer)) ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->supplier_proposal->creer))
|| (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->supplier_proposal->validate_advance))) || (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->supplier_proposal->validate_advance)))
) { ) {
if (count($object->lines) > 0) if (count($object->lines) > 0)
print '<div class="inline-block divButAction"><a class="butAction" href="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '&amp;action=validate">' . $langs->trans('Validate') . '</a></div>'; print '<div class="inline-block divButAction"><a class="butAction" href="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '&amp;action=validate">' . $langs->trans('Validate') . '</a></div>';
@ -1733,8 +1733,8 @@ if ($action == 'create')
// Close // Close
if ($object->statut == SupplierProposal::STATUS_SIGNED && $user->rights->supplier_proposal->cloturer) { if ($object->statut == SupplierProposal::STATUS_SIGNED && $user->rights->supplier_proposal->cloturer) {
print '<div class="inline-block divButAction"><a class="butAction" href="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '&amp;action=close' . (empty($conf->global->MAIN_JUMP_TAG) ? '' : '#close') . '"'; print '<div class="inline-block divButAction"><a class="butAction" href="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '&amp;action=close' . (empty($conf->global->MAIN_JUMP_TAG) ? '' : '#close') . '"';
print '>' . $langs->trans('Close') . '</a></div>'; print '>' . $langs->trans('Close') . '</a></div>';
} }
// Clone // Clone

View File

@ -313,7 +313,7 @@ if ($action == 'add')
} }
*/ */
//$filename = 'image/'.$object->ref.'/'.$objectpage->pageurl.(preg_match('/^\//', $linkwithoutdomain)?'':'/').$linkwithoutdomain; //$filename = 'image/'.$object->ref.'/'.$objectpage->pageurl.(preg_match('/^\//', $linkwithoutdomain)?'':'/').$linkwithoutdomain;
$tmp = preg_replace('/'.preg_quote($regs[0][$key],'/').'/i', '', $tmp); $tmp = preg_replace('/'.preg_quote($regs[0][$key],'/').'/i', '', $tmp);
} }
$objectpage->htmlheader = trim($tmp); $objectpage->htmlheader = trim($tmp);

View File

@ -32,7 +32,7 @@ $path=dirname(__FILE__).'/';
// Test if batch mode // Test if batch mode
if (substr($sapi_type, 0, 3) == 'cgi') { if (substr($sapi_type, 0, 3) == 'cgi') {
echo "Error: You are using PHP for CGI. To execute ".$script_file." from command line, you must use PHP for CLI mode.\n"; echo "Error: You are using PHP for CGI. To execute ".$script_file." from command line, you must use PHP for CLI mode.\n";
exit(-1); exit(-1);
} }
@ -116,10 +116,10 @@ if ($resql)
$sql2 = "SELECT mc.rowid, mc.lastname as lastname, mc.firstname as firstname, mc.email, mc.other, mc.source_url, mc.source_id, mc.source_type, mc.tag"; $sql2 = "SELECT mc.rowid, mc.lastname as lastname, mc.firstname as firstname, mc.email, mc.other, mc.source_url, mc.source_id, mc.source_type, mc.tag";
$sql2.= " FROM ".MAIN_DB_PREFIX."mailing_cibles as mc"; $sql2.= " FROM ".MAIN_DB_PREFIX."mailing_cibles as mc";
$sql2.= " WHERE mc.statut < 1 AND mc.fk_mailing = ".$id; $sql2.= " WHERE mc.statut < 1 AND mc.fk_mailing = ".$id;
if ($conf->global->MAILING_LIMIT_SENDBYCLI > 0) if ($conf->global->MAILING_LIMIT_SENDBYCLI > 0)
{ {
$sql2.= " LIMIT ".$conf->global->MAILING_LIMIT_SENDBYCLI; $sql2.= " LIMIT ".$conf->global->MAILING_LIMIT_SENDBYCLI;
} }
$resql2=$db->query($sql2); $resql2=$db->query($sql2);
if ($resql2) if ($resql2)
@ -157,31 +157,31 @@ if ($resql)
// Make subtsitutions on topic and body // Make subtsitutions on topic and body
$other=explode(';',$obj2->other); $other=explode(';',$obj2->other);
$tmpfield=explode('=',$other[0],2); $other1=(isset($tmpfield[1])?$tmpfield[1]:$tmpfield[0]); $tmpfield=explode('=',$other[0],2); $other1=(isset($tmpfield[1])?$tmpfield[1]:$tmpfield[0]);
$tmpfield=explode('=',$other[1],2); $other2=(isset($tmpfield[1])?$tmpfield[1]:$tmpfield[0]); $tmpfield=explode('=',$other[1],2); $other2=(isset($tmpfield[1])?$tmpfield[1]:$tmpfield[0]);
$tmpfield=explode('=',$other[2],2); $other3=(isset($tmpfield[1])?$tmpfield[1]:$tmpfield[0]); $tmpfield=explode('=',$other[2],2); $other3=(isset($tmpfield[1])?$tmpfield[1]:$tmpfield[0]);
$tmpfield=explode('=',$other[3],2); $other4=(isset($tmpfield[1])?$tmpfield[1]:$tmpfield[0]); $tmpfield=explode('=',$other[3],2); $other4=(isset($tmpfield[1])?$tmpfield[1]:$tmpfield[0]);
$tmpfield=explode('=',$other[4],2); $other5=(isset($tmpfield[1])?$tmpfield[1]:$tmpfield[0]); $tmpfield=explode('=',$other[4],2); $other5=(isset($tmpfield[1])?$tmpfield[1]:$tmpfield[0]);
$signature = ((!empty($user->signature) && empty($conf->global->MAIN_MAIL_DO_NOT_USE_SIGN))?$user->signature:''); $signature = ((!empty($user->signature) && empty($conf->global->MAIN_MAIL_DO_NOT_USE_SIGN))?$user->signature:'');
$object = null; // Not defined with mass emailing $object = null; // Not defined with mass emailing
$parameters=array('mode'=>'emailing'); $parameters=array('mode'=>'emailing');
$substitutionarray=getCommonSubstitutionArray($langs, 0, array('object','objectamount'), $object); // Note: On mass emailing, this is null because we don't know object $substitutionarray=getCommonSubstitutionArray($langs, 0, array('object','objectamount'), $object); // Note: On mass emailing, this is null because we don't know object
// Array of possible substitutions (See also file mailing-send.php that should manage same substitutions) // Array of possible substitutions (See also file mailing-send.php that should manage same substitutions)
$substitutionarray['__ID__'] = $obj->source_id; $substitutionarray['__ID__'] = $obj->source_id;
$substitutionarray['__EMAIL__'] = $obj->email; $substitutionarray['__EMAIL__'] = $obj->email;
$substitutionarray['__LASTNAME__'] = $obj->lastname; $substitutionarray['__LASTNAME__'] = $obj->lastname;
$substitutionarray['__FIRSTNAME__'] = $obj->firstname; $substitutionarray['__FIRSTNAME__'] = $obj->firstname;
$substitutionarray['__MAILTOEMAIL__'] = '<a href="mailto:'.$obj->email.'">'.$obj->email.'</a>'; $substitutionarray['__MAILTOEMAIL__'] = '<a href="mailto:'.$obj->email.'">'.$obj->email.'</a>';
$substitutionarray['__OTHER1__'] = $other1; $substitutionarray['__OTHER1__'] = $other1;
$substitutionarray['__OTHER2__'] = $other2; $substitutionarray['__OTHER2__'] = $other2;
$substitutionarray['__OTHER3__'] = $other3; $substitutionarray['__OTHER3__'] = $other3;
$substitutionarray['__OTHER4__'] = $other4; $substitutionarray['__OTHER4__'] = $other4;
$substitutionarray['__OTHER5__'] = $other5; $substitutionarray['__OTHER5__'] = $other5;
$substitutionarray['__USER_SIGNATURE__'] = $signature; // Signature is empty when ran from command line or taken from user in parameter) $substitutionarray['__USER_SIGNATURE__'] = $signature; // Signature is empty when ran from command line or taken from user in parameter)
$substitutionarray['__SIGNATURE__'] = $signature; // For backward compatibility $substitutionarray['__SIGNATURE__'] = $signature; // For backward compatibility
$substitutionarray['__CHECK_READ__'] = '<img src="'.DOL_MAIN_URL_ROOT.'/public/emailing/mailing-read.php?tag='.$obj->tag.'&securitykey='.urlencode($conf->global->MAILING_EMAIL_UNSUBSCRIBE_KEY).'" width="1" height="1" style="width:1px;height:1px" border="0"/>'; $substitutionarray['__CHECK_READ__'] = '<img src="'.DOL_MAIN_URL_ROOT.'/public/emailing/mailing-read.php?tag='.$obj->tag.'&securitykey='.urlencode($conf->global->MAILING_EMAIL_UNSUBSCRIBE_KEY).'" width="1" height="1" style="width:1px;height:1px" border="0"/>';
$substitutionarray['__UNSUBSCRIBE__'] = '<a href="'.DOL_MAIN_URL_ROOT.'/public/emailing/mailing-unsubscribe.php?tag='.$obj->tag.'&unsuscrib=1&securitykey='.urlencode($conf->global->MAILING_EMAIL_UNSUBSCRIBE_KEY).'" target="_blank">'.$langs->trans("MailUnsubcribe").'</a>'; $substitutionarray['__UNSUBSCRIBE__'] = '<a href="'.DOL_MAIN_URL_ROOT.'/public/emailing/mailing-unsubscribe.php?tag='.$obj->tag.'&unsuscrib=1&securitykey='.urlencode($conf->global->MAILING_EMAIL_UNSUBSCRIBE_KEY).'" target="_blank">'.$langs->trans("MailUnsubcribe").'</a>';
$onlinepaymentenabled = 0; $onlinepaymentenabled = 0;
if (! empty($conf->paypal->enabled)) $onlinepaymentenabled++; if (! empty($conf->paypal->enabled)) $onlinepaymentenabled++;
@ -232,22 +232,22 @@ if ($resql)
// Fabrication du mail // Fabrication du mail
$trackid='emailing-'.$obj2->source_type.$obj2->source_id; $trackid='emailing-'.$obj2->source_type.$obj2->source_id;
$mail = new CMailFile( $mail = new CMailFile(
$newsubject, $newsubject,
$sendto, $sendto,
$from, $from,
$newmessage, $newmessage,
array(), array(),
array(), array(),
array(), array(),
'', '',
'', '',
0, 0,
$msgishtml, $msgishtml,
$errorsto, $errorsto,
'', '',
$trackid, $trackid,
'', '',
'emailing' 'emailing'
); );
if ($mail->error) if ($mail->error)
@ -314,7 +314,7 @@ if ($resql)
$error++; $error++;
} }
//Update status communication of contact prospect //Update status communication of contact prospect
$sqlx = "UPDATE ".MAIN_DB_PREFIX."societe SET fk_stcomm=2 WHERE rowid IN (SELECT sc.fk_soc FROM ".MAIN_DB_PREFIX."socpeople AS sc INNER JOIN ".MAIN_DB_PREFIX."mailing_cibles AS mc ON mc.rowid=".$obj2->rowid." AND mc.source_type = 'contact' AND mc.source_id = sc.rowid)"; $sqlx = "UPDATE ".MAIN_DB_PREFIX."societe SET fk_stcomm=2 WHERE rowid IN (SELECT sc.fk_soc FROM ".MAIN_DB_PREFIX."socpeople AS sc INNER JOIN ".MAIN_DB_PREFIX."mailing_cibles AS mc ON mc.rowid=".$obj2->rowid." AND mc.source_type = 'contact' AND mc.source_id = sc.rowid)";
dol_syslog("card.php: set prospect contact status", LOG_DEBUG); dol_syslog("card.php: set prospect contact status", LOG_DEBUG);
@ -326,9 +326,9 @@ if ($resql)
} }
} }
if (!empty($conf->global->MAILING_DELAY)) { if (!empty($conf->global->MAILING_DELAY)) {
sleep($conf->global->MAILING_DELAY); sleep($conf->global->MAILING_DELAY);
} }
} }
} }