Merge branch 'develop' of https://github.com/Dolibarr/dolibarr into NEW_Show_Region_in_company_info_&_Global_option_to_show_state_code_MAIN_SHOW_STATE_CODE

This commit is contained in:
Rui Strecht 2017-10-18 09:45:40 +01:00
commit 6e7e11ede4
63 changed files with 9906 additions and 9071 deletions

133
dev/resources/sepa/test.xml Normal file
View File

@ -0,0 +1,133 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Document xmlns="urn:iso:std:iso:20022:tech:xsd:pain.008.001.02" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<CstmrDrctDbtInitn>
<GrpHdr>
<MsgId>PREL20171012/REF10</MsgId>
<CreDtTm>2017-10-12T00:08:30</CreDtTm>
<NbOfTxs>2</NbOfTxs>
<CtrlSum>734.4</CtrlSum>
<InitgPty>
<Nm>MyBigCompany</Nm>
<Id>
<PrvtId>
<Othr>
<Id>FR76AAAAA</Id>
</Othr>
</PrvtId>
</Id>
</InitgPty>
</GrpHdr>
<PmtInf>
<PmtInfId>PREL20171012/ID00010-T171001</PmtInfId>
<PmtMtd>DD</PmtMtd>
<NbOfTxs>2</NbOfTxs>
<CtrlSum>734.4</CtrlSum>
<PmtTpInf>
<SvcLvl>
<Cd>SEPA</Cd>
</SvcLvl>
<LclInstrm>
<Cd>CORE</Cd>
</LclInstrm>
<SeqTp>RCUR</SeqTp>
</PmtTpInf>
<ReqdColltnDt>2017-10-12</ReqdColltnDt>
<Cdtr>
<Nm>MyBigCompany</Nm>
<PstlAdr>
<Ctry>FR</Ctry>
<AdrLine>Address1</AdrLine>
<AdrLine>Address2</AdrLine>
</PstlAdr>
</Cdtr>
<CdtrAcct>
<Id>
<IBAN>FR76123456</IBAN>
</Id>
</CdtrAcct>
<CdtrAgt>
<FinInstnId>
<BIC>BICABCDEF</BIC>
</FinInstnId>
</CdtrAgt>
<ChrgBr>SLEV</ChrgBr>
<CdtrSchmeId>
<Id>
<PrvtId>
<Othr>
<Id>FR76AAAAA</Id>
<SchmeNm>
<Prtry>SEPA</Prtry>
</SchmeNm>
</Othr>
</PrvtId>
</Id>
</CdtrSchmeId>
<DrctDbtTxInf>
<PmtId>
<EndToEndId>AS-FA1710-0416-000679</EndToEndId>
</PmtId>
<InstdAmt Ccy="EUR">540</InstdAmt>
<DrctDbtTx>
<MndtRltdInf>
<MndtId>RUM-CU1610-0001-3-1476058417</MndtId>
<DtOfSgntr>2016-10-10</DtOfSgntr>
<AmdmntInd>false</AmdmntInd>
</MndtRltdInf>
</DrctDbtTx>
<DbtrAgt>
<FinInstnId>
<BIC>BICXYZ</BIC>
</FinInstnId>
</DbtrAgt>
<Dbtr>
<Nm>CUSTOMER A</Nm>
<PstlAdr>
<Ctry>FR</Ctry>
<AdrLine>Mr abc</AdrLine>
</PstlAdr>
</Dbtr>
<DbtrAcct>
<Id>
<IBAN>FR123456</IBAN>
</Id>
</DbtrAcct>
<RmtInf>
<Ustrd>FA1710-0416</Ustrd>
</RmtInf>
</DrctDbtTxInf>
<DrctDbtTxInf>
<PmtId>
<EndToEndId>AS-FA1710-0415-000683</EndToEndId>
</PmtId>
<InstdAmt Ccy="EUR">194.4</InstdAmt>
<DrctDbtTx>
<MndtRltdInf>
<MndtId>RUM-CU1709-0011-4-1506525346</MndtId>
<DtOfSgntr>2017-09-27</DtOfSgntr>
<AmdmntInd>false</AmdmntInd>
</MndtRltdInf>
</DrctDbtTx>
<DbtrAgt>
<FinInstnId>
<BIC>BICJKL</BIC>
</FinInstnId>
</DbtrAgt>
<Dbtr>
<Nm>CUSTOMER2</Nm>
<PstlAdr>
<Ctry>FR</Ctry>
</PstlAdr>
</Dbtr>
<DbtrAcct>
<Id>
<IBAN>FR76123456</IBAN>
</Id>
</DbtrAcct>
<RmtInf>
<Ustrd>FA1710-0415</Ustrd>
</RmtInf>
</DrctDbtTxInf>
</PmtInf>
</CstmrDrctDbtInitn>
</Document>

View File

@ -33,12 +33,12 @@ include_once DOL_DOCUMENT_ROOT."/core/lib/date.lib.php";
*/
class lettering extends BookKeeping
{
/**
* lettrageTiers
*
* @param int $socid Thirdparty id
* @return int <0 if KO, >0 if OK
*/
/**
* lettrageTiers
*
* @param int $socid Thirdparty id
* @return int <0 if KO, >0 if OK
*/
public function lettrageTiers($socid) {
$db = $this->db;
@ -121,7 +121,7 @@ class lettering extends BookKeeping
/**
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 .= " 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') ) ";

View File

@ -100,6 +100,7 @@ $fieldstosearchall = array(
'd.note_public'=>'NotePublic',
'd.note_private'=>'NotePrivate',
);
if($db->type == 'pgsql') unset($fieldstosearchall['d.rowid']);
$arrayfields=array(
'd.ref'=>array('label'=>$langs->trans("Ref"), 'checked'=>1),
'd.lastname'=>array('label'=>$langs->trans("Lastname"), 'checked'=>1),

View File

@ -193,14 +193,20 @@ if (empty($conf->global->MAIN_ENABLE_DEFAULT_VALUES))
{
// Button off, click to enable
$enabledisablehtml.= '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=setMAIN_ENABLE_DEFAULT_VALUES&value=1'.$param.'">';
$enabledisablehtml.= img_picto($langs->trans("Disabled"),'switch_off');
//$enabledisablehtml.= img_picto($langs->trans("Disabled"),'switch_off');
$enabledisablehtml.='<span class="fa fa-toggle-off valignmiddle" style="font-size: 2em; color: #999;" alt="'.$langs->trans("Disabled").'">';
if (! empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) $enabledisablehtml.=$langs->trans("EnableDefaultValues");
$enabledisablehtml.='</span>';
$enabledisablehtml.= '</a>';
}
else
{
// Button on, click to disable
$enabledisablehtml.= '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=setMAIN_ENABLE_DEFAULT_VALUES&value=0'.$param.'">';
$enabledisablehtml.= img_picto($langs->trans("Activated"),'switch_on');
//$enabledisablehtml.= img_picto($langs->trans("Activated"),'switch_on');
$enabledisablehtml.='<span class="fa fa-toggle-on valignmiddle" style="font-size: 2em; color: #227722;" alt="'.$langs->trans("Activated").'">';
if (! empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) $enabledisablehtml.=$langs->trans("DisableDefaultValues");
$enabledisablehtml.='</span>';
$enabledisablehtml.= '</a>';
}

View File

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

View File

@ -85,7 +85,7 @@ if (! $sortorder) $sortorder="ASC";
$socid=0;
if ($user->societe_id > 0)
{
//$socid = $user->societe_id;
//$socid = $user->societe_id;
accessforbidden();
}
@ -94,14 +94,14 @@ $search_all=trim(GETPOST("search_all",'alpha'));
$search=array();
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"
$fieldstosearchall = array();
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
@ -109,15 +109,15 @@ $arrayfields=array();
foreach($object->fields as $key => $val)
{
// 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
if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label))
{
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]);
}
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]);
}
}
@ -136,32 +136,32 @@ if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'e
if (empty($reshook))
{
// Selection of new fields
include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
// Selection of new fields
include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
// 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
{
foreach($object->fields as $key => $val)
{
$search[$key]='';
}
$toselect='';
$search_array_options=array();
}
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'))
{
$massaction=''; // Protection to avoid mass action if we force a new search during a mass action confirmation
}
// 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
{
foreach($object->fields as $key => $val)
{
$search[$key]='';
}
$toselect='';
$search_array_options=array();
}
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'))
{
$massaction=''; // Protection to avoid mass action if we force a new search during a mass action confirmation
}
// Mass actions
$objectclass='EmailSenderProfile';
$objectlabel='EmailSenderProfile';
$permtoread = $user->admin;
$permtodelete = $user->admin;
$uploaddir = $conf->admin->dir_output.'/senderprofiles';
include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
// Mass actions
$objectclass='EmailSenderProfile';
$objectlabel='EmailSenderProfile';
$permtoread = $user->admin;
$permtodelete = $user->admin;
$uploaddir = $conf->admin->dir_output.'/senderprofiles';
include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
}
@ -196,7 +196,7 @@ dol_fiche_head($head, 'senderprofiles', '', -1);
$sql = 'SELECT ';
foreach($object->fields as $key => $val)
{
$sql.='t.'.$key.', ';
$sql.='t.'.$key.', ';
}
// Add fields from extrafields
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
foreach ($search_array_options as $key => $val)
{
$crit=$val;
$tmpkey=preg_replace('/search_options_/','',$key);
$typ=$extrafields->attribute_type[$tmpkey];
$mode_search=0;
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 ($crit != '' && (! in_array($typ, array('select','sellist')) || $crit != '0'))
{
$sql .= natural_search('ef.'.$tmpkey, $crit, $mode_search);
}
$crit=$val;
$tmpkey=preg_replace('/search_options_/','',$key);
$typ=$extrafields->attribute_type[$tmpkey];
$mode_search=0;
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 ($crit != '' && (! in_array($typ, array('select','sellist')) || $crit != '0'))
{
$sql .= natural_search('ef.'.$tmpkey, $crit, $mode_search);
}
}
// Add where from hooks
$parameters=array();
@ -263,8 +263,8 @@ dol_syslog($script_file, LOG_DEBUG);
$resql=$db->query($sql);
if (! $resql)
{
dol_print_error($db);
exit;
dol_print_error($db);
exit;
}
$num = $db->num_rows($resql);
@ -272,10 +272,10 @@ $num = $db->num_rows($resql);
// Direct jump if only one record found
if ($num == 1 && ! empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $search_all)
{
$obj = $db->fetch_object($resql);
$id = $obj->rowid;
header("Location: ".DOL_URL_ROOT.'/monmodule/emailsenderprofile_card.php?id='.$id);
exit;
$obj = $db->fetch_object($resql);
$id = $obj->rowid;
header("Location: ".DOL_URL_ROOT.'/monmodule/emailsenderprofile_card.php?id='.$id);
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);
foreach($search as $key => $val)
{
$param.= '&search_'.$key.'='.urlencode($search[$key]);
$param.= '&search_'.$key.'='.urlencode($search[$key]);
}
if ($optioncss != '') $param.='&optioncss='.urlencode($optioncss);
// Add $param from extra fields
foreach ($search_array_options as $key => $val)
{
$crit=$val;
$tmpkey=preg_replace('/search_options_/','',$key);
if ($val != '') $param.='&search_options_'.$tmpkey.'='.urlencode($val);
$crit=$val;
$tmpkey=preg_replace('/search_options_/','',$key);
if ($val != '') $param.='&search_options_'.$tmpkey.'='.urlencode($val);
}
// List of mass actions available
$arrayofmassactions = array(
//'presend'=>$langs->trans("SendByMail"),
//'builddoc'=>$langs->trans("PDFMerge"),
//'presend'=>$langs->trans("SendByMail"),
//'builddoc'=>$langs->trans("PDFMerge"),
);
if ($user->rights->monmodule->delete) $arrayofmassactions['delete']=$langs->trans("Delete");
if ($massaction == 'presend') $arrayofmassactions=array();
@ -347,7 +347,7 @@ if (! empty($moreforfilter))
{
print '<div class="liste_titre liste_titre_bydiv centpercent">';
print $moreforfilter;
print '</div>';
print '</div>';
}
$varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage;
@ -363,35 +363,35 @@ print '<table class="tagtable liste'.($moreforfilter?" listwithfilterbefore":"")
print '<tr class="liste_titre">';
foreach($object->fields as $key => $val)
{
if (in_array($key, array('date_creation', 'tms', 'import_key', 'status'))) continue;
$align='';
if (in_array($val['type'], array('date','datetime','timestamp'))) $align='center';
if (in_array($val['type'], array('timestamp'))) $align.=' nowrap';
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 (in_array($key, array('date_creation', 'tms', 'import_key', 'status'))) continue;
$align='';
if (in_array($val['type'], array('date','datetime','timestamp'))) $align='center';
if (in_array($val['type'], array('timestamp'))) $align.=' nowrap';
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>';
}
// Extra fields
if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label))
{
foreach($extrafields->attribute_label as $key => $val)
{
if (! empty($arrayfields["ef.".$key]['checked']))
{
$align=$extrafields->getAlignFlag($key);
$typeofextrafield=$extrafields->attribute_type[$key];
print '<td class="liste_titre'.($align?' '.$align:'').'">';
if (in_array($typeofextrafield, array('varchar', 'int', 'double', 'select')) && empty($extrafields->attribute_computed[$key]))
{
$crit=$val;
$tmpkey=preg_replace('/search_options_/','',$key);
$searchclass='';
if (in_array($typeofextrafield, array('varchar', 'select'))) $searchclass='searchstring';
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 '</td>';
}
}
foreach($extrafields->attribute_label as $key => $val)
{
if (! empty($arrayfields["ef.".$key]['checked']))
{
$align=$extrafields->getAlignFlag($key);
$typeofextrafield=$extrafields->attribute_type[$key];
print '<td class="liste_titre'.($align?' '.$align:'').'">';
if (in_array($typeofextrafield, array('varchar', 'int', 'double', 'select')) && empty($extrafields->attribute_computed[$key]))
{
$crit=$val;
$tmpkey=preg_replace('/search_options_/','',$key);
$searchclass='';
if (in_array($typeofextrafield, array('varchar', 'select'))) $searchclass='searchstring';
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 '</td>';
}
}
}
// Fields from hook
$parameters=array('arrayfields'=>$arrayfields);
@ -400,12 +400,12 @@ print $hookmanager->resPrint;
// Rest of fields search
foreach($object->fields as $key => $val)
{
if (! in_array($key, array('date_creation', 'tms', 'import_key', 'status'))) continue;
$align='';
if (in_array($val['type'], array('date','datetime','timestamp'))) $align='center';
if (in_array($val['type'], array('timestamp'))) $align.=' nowrap';
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 (! in_array($key, array('date_creation', 'tms', 'import_key', 'status'))) continue;
$align='';
if (in_array($val['type'], array('date','datetime','timestamp'))) $align='center';
if (in_array($val['type'], array('timestamp'))) $align.=' nowrap';
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>';
}
// Action column
print '<td class="liste_titre" align="right">';
@ -420,25 +420,25 @@ print '</tr>'."\n";
print '<tr class="liste_titre">';
foreach($object->fields as $key => $val)
{
if (in_array($key, array('date_creation', 'tms', 'import_key', 'status'))) continue;
$align='';
if (in_array($val['type'], array('date','datetime','timestamp'))) $align='center';
if (in_array($val['type'], array('timestamp'))) $align.='nowrap';
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 (in_array($key, array('date_creation', 'tms', 'import_key', 'status'))) continue;
$align='';
if (in_array($val['type'], array('date','datetime','timestamp'))) $align='center';
if (in_array($val['type'], array('timestamp'))) $align.='nowrap';
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";
}
// Extra fields
if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label))
{
foreach($extrafields->attribute_label as $key => $val)
{
if (! empty($arrayfields["ef.".$key]['checked']))
{
if (! empty($arrayfields["ef.".$key]['checked']))
{
$align=$extrafields->getAlignFlag($key);
$sortonfield = "ef.".$key;
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";
}
}
}
}
// Hook fields
@ -448,12 +448,12 @@ print $hookmanager->resPrint;
// Rest of fields title
foreach($object->fields as $key => $val)
{
if (! in_array($key, array('date_creation', 'tms', 'import_key', 'status'))) continue;
$align='';
if (in_array($val['type'], array('date','datetime','timestamp'))) $align='center';
if (in_array($val['type'], array('timestamp'))) $align.=' nowrap';
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 (! in_array($key, array('date_creation', 'tms', 'import_key', 'status'))) continue;
$align='';
if (in_array($val['type'], array('date','datetime','timestamp'))) $align='center';
if (in_array($val['type'], array('timestamp'))) $align.=' nowrap';
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";
}
print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"],"",'','','align="center"',$sortfield,$sortorder,'maxwidthsearch ')."\n";
print '</tr>'."\n";
@ -463,7 +463,7 @@ print '</tr>'."\n";
$needToFetchEachLine=0;
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();
while ($i < min($num, $limit))
{
$obj = $db->fetch_object($resql);
if (empty($obj)) break; // Should not happen
$obj = $db->fetch_object($resql);
if (empty($obj)) break; // Should not happen
// Store properties in $object
// Store properties in $object
$object->id = $obj->rowid;
foreach($object->fields as $key => $val)
{
if (isset($obj->$key)) $object->$key = $obj->$key;
}
// Show here line of result
print '<tr class="oddeven">';
foreach($object->fields as $key => $val)
{
if (in_array($key, array('date_creation', 'tms', 'import_key', 'status'))) continue;
$align='';
if (in_array($val['type'], array('date','datetime','timestamp'))) $align='center';
if (in_array($val['type'], array('timestamp'))) $align.='nowrap';
if ($key == 'status') $align.=($align?' ':'').'center';
if (! empty($arrayfields['t.'.$key]['checked']))
{
print '<td'.($align?' class="'.$align.'"':'').'>';
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 == 'status') print $object->getLibStatut(3);
else print $obj->$key;
print '</td>';
if (! $i) $totalarray['nbfield']++;
if (! empty($val['isameasure']))
{
if (! $i) $totalarray['pos'][$totalarray['nbfield']]='t.'.$key;
$totalarray['val']['t.'.$key] += $obj->$key;
}
}
}
// Extra fields
// Show here line of result
print '<tr class="oddeven">';
foreach($object->fields as $key => $val)
{
if (in_array($key, array('date_creation', 'tms', 'import_key', 'status'))) continue;
$align='';
if (in_array($val['type'], array('date','datetime','timestamp'))) $align='center';
if (in_array($val['type'], array('timestamp'))) $align.='nowrap';
if ($key == 'status') $align.=($align?' ':'').'center';
if (! empty($arrayfields['t.'.$key]['checked']))
{
print '<td'.($align?' class="'.$align.'"':'').'>';
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 == 'status') print $object->getLibStatut(3);
else print $obj->$key;
print '</td>';
if (! $i) $totalarray['nbfield']++;
if (! empty($val['isameasure']))
{
if (! $i) $totalarray['pos'][$totalarray['nbfield']]='t.'.$key;
$totalarray['val']['t.'.$key] += $obj->$key;
}
}
}
// Extra fields
if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label))
{
foreach($extrafields->attribute_label as $key => $val)
@ -522,86 +522,86 @@ while ($i < min($num, $limit))
$tmpkey='options_'.$key;
print $extrafields->showOutputField($key, $obj->$tmpkey, '', 1);
print '</td>';
if (! $i) $totalarray['nbfield']++;
if (! empty($val['isameasure']))
{
if (! $i) $totalarray['pos'][$totalarray['nbfield']]='ef.'.$tmpkey;
$totalarray['val']['ef.'.$tmpkey] += $obj->$tmpkey;
}
if (! $i) $totalarray['nbfield']++;
if (! empty($val['isameasure']))
{
if (! $i) $totalarray['pos'][$totalarray['nbfield']]='ef.'.$tmpkey;
$totalarray['val']['ef.'.$tmpkey] += $obj->$tmpkey;
}
}
}
}
// Fields from hook
// Fields from hook
$parameters=array('arrayfields'=>$arrayfields, 'obj'=>$obj);
$reshook=$hookmanager->executeHooks('printFieldListValue', $parameters, $object); // Note that $action and $object may have been modified by hook
print $hookmanager->resPrint;
// Rest of fields
foreach($object->fields as $key => $val)
{
if (! in_array($key, array('date_creation', 'tms', 'import_key', 'status'))) continue;
$align='';
if (in_array($val['type'], array('date','datetime','timestamp'))) $align.=($align?' ':'').'center';
if (in_array($val['type'], array('timestamp'))) $align.=($align?' ':'').'nowrap';
if ($key == 'status') $align.=($align?' ':'').'center';
if (! empty($arrayfields['t.'.$key]['checked']))
{
print '<td'.($align?' class="'.$align.'"':'').'>';
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);
else print $obj->$key;
print '</td>';
if (! $i) $totalarray['nbfield']++;
if (! empty($val['isameasure']))
{
if (! $i) $totalarray['pos'][$totalarray['nbfield']]='t.'.$key;
$totalarray['val']['t.'.$key] += $obj->$key;
}
}
}
// Action column
print '<td class="nowrap" align="center">';
print $hookmanager->resPrint;
// Rest of fields
foreach($object->fields as $key => $val)
{
if (! in_array($key, array('date_creation', 'tms', 'import_key', 'status'))) continue;
$align='';
if (in_array($val['type'], array('date','datetime','timestamp'))) $align.=($align?' ':'').'center';
if (in_array($val['type'], array('timestamp'))) $align.=($align?' ':'').'nowrap';
if ($key == 'status') $align.=($align?' ':'').'center';
if (! empty($arrayfields['t.'.$key]['checked']))
{
print '<td'.($align?' class="'.$align.'"':'').'>';
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);
else print $obj->$key;
print '</td>';
if (! $i) $totalarray['nbfield']++;
if (! empty($val['isameasure']))
{
if (! $i) $totalarray['pos'][$totalarray['nbfield']]='t.'.$key;
$totalarray['val']['t.'.$key] += $obj->$key;
}
}
}
// Action column
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
{
$selected=0;
{
$selected=0;
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 '</td>';
if (! $i) $totalarray['nbfield']++;
if (! $i) $totalarray['nbfield']++;
print '</tr>';
print '</tr>';
$i++;
$i++;
}
// Show total line
if (isset($totalarray['pos']))
{
print '<tr class="liste_total">';
$i=0;
while ($i < $totalarray['nbfield'])
{
$i++;
if (! empty($totalarray['pos'][$i])) print '<td align="right">'.price($totalarray['val'][$totalarray['pos'][$i]]).'</td>';
else
{
if ($i == 1)
{
if ($num < $limit) print '<td align="left">'.$langs->trans("Total").'</td>';
else print '<td align="left">'.$langs->trans("Totalforthispage").'</td>';
}
else print '<td></td>';
}
}
print '</tr>';
print '<tr class="liste_total">';
$i=0;
while ($i < $totalarray['nbfield'])
{
$i++;
if (! empty($totalarray['pos'][$i])) print '<td align="right">'.price($totalarray['val'][$totalarray['pos'][$i]]).'</td>';
else
{
if ($i == 1)
{
if ($num < $limit) print '<td align="left">'.$langs->trans("Total").'</td>';
else print '<td align="left">'.$langs->trans("Totalforthispage").'</td>';
}
else print '<td></td>';
}
}
print '</tr>';
}
// If no record found
if ($num == 0)
{
$colspan=1;
foreach($arrayfields as $key => $val) { if (! empty($val['checked'])) $colspan++; }
print '<tr><td colspan="'.$colspan.'" class="opacitymedium">'.$langs->trans("NoRecordFound").'</td></tr>';
$colspan=1;
foreach($arrayfields as $key => $val) { if (! empty($val['checked'])) $colspan++; }
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 ($massaction == 'builddoc' || $action == 'remove_file' || $show_files)
{
require_once(DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php');
$formfile = new FormFile($db);
if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files)
{
require_once(DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php');
$formfile = new FormFile($db);
// Show list of available documents
$urlsource=$_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder;
$urlsource.=str_replace('&amp;','&',$param);
// Show list of available documents
$urlsource=$_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder;
$urlsource.=str_replace('&amp;','&',$param);
$filedir=$diroutputmassaction;
$genallowed=$user->rights->monmodule->read;
$delallowed=$user->rights->monmodule->read;
$filedir=$diroutputmassaction;
$genallowed=$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,'');
}
else
{
print '<br><a name="show_files"></a><a href="'.$_SERVER["PHP_SELF"].'?show_files=1'.$param.'#show_files">'.$langs->trans("ShowTempMassFilesArea").'</a>';
}
print $formfile->showdocuments('massfilesarea_monmodule','',$filedir,$urlsource,0,$delallowed,'',1,1,0,48,1,$param,$title,'');
}
else
{
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();

View File

@ -1,6 +1,7 @@
<?php
/* Copyright (C) 2007-2016 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2009-2017 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2017 Frédéric France <frederic.france@free.fr>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -170,7 +171,7 @@ if ($action == 'add')
else
{
setEventMessages($db->lasterror(), null, 'errors');
}
}
$action='';
}
}
@ -208,25 +209,34 @@ llxHeader('',$langs->trans("Setup"),$wikihelp);
$param='&mode='.$mode;
$enabledisablehtml = $langs->trans("EnableOverwriteTranslation").' ';
$enabledisablehtml='';
if (empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) $enabledisablehtml.= $langs->trans("EnableOverwriteTranslation").' ';
if (empty($conf->global->MAIN_ENABLE_OVERWRITE_TRANSLATION))
{
// Button off, click to enable
$enabledisablehtml.='<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=setMAIN_ENABLE_OVERWRITE_TRANSLATION&value=1'.$param.'">';
$enabledisablehtml.=img_picto($langs->trans("Disabled"),'switch_off');
//$enabledisablehtml.=img_picto($langs->trans("Disabled"),'switch_off');
$enabledisablehtml.='<span class="fa fa-toggle-off valignmiddle" style="font-size: 2em; color: #999;" alt="'.$langs->trans("Disabled").'">';
if (! empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) $enabledisablehtml.=$langs->trans("EnableOverwriteTranslation");
$enabledisablehtml.='</span>';
$enabledisablehtml.='</a>';
}
else
{
// Button on, click to disable
$enabledisablehtml.='<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=setMAIN_ENABLE_OVERWRITE_TRANSLATION&value=0'.$param.'">';
$enabledisablehtml.=img_picto($langs->trans("Activated"),'switch_on');
//$enabledisablehtml.=img_picto($langs->trans("Activated"),'switch_on');
$enabledisablehtml.='<span class="fa fa-toggle-on valignmiddle" style="font-size: 2em; color: #227722;" alt="'.$langs->trans("Activated").'">';
if (! empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) $enabledisablehtml.=$langs->trans("DisableOverwriteTranslation");
$enabledisablehtml.='</span>';
$enabledisablehtml.='</a>';
}
print load_fiche_titre($langs->trans("Translation"), $enabledisablehtml, 'title_setup');
//print '<span class="opacitymedium">';
print $langs->trans("TranslationDesc")."<br>\n";
//print '</span>';
print "<br>\n";
$current_language_code=$langs->defaultlang;
@ -259,11 +269,14 @@ if ($mode == 'overwrite')
{
//print load_fiche_titre($langs->trans("TranslationOverwriteKey"), '', '')."\n";
print '<div class="justify"><span class="opacitymedium">';
print img_info().' '.$langs->trans("SomeTranslationAreUncomplete");
$urlwikitranslatordoc='https://wiki.dolibarr.org/index.php/Translator_documentation';
print ' ('.$langs->trans("SeeAlso").': <a href="'.$urlwikitranslatordoc.'" target="_blank">'.$urlwikitranslatordoc.'</a>)<br>';
print ' ('.$langs->trans("SeeAlso").': <a href="'.$urlwikitranslatordoc.'" target="_blank">'.$langs->trans("Here").'</a>)<br>';
print $langs->trans("TranslationOverwriteDesc",$langs->transnoentitiesnoconv("Language"),$langs->transnoentitiesnoconv("Key"),$langs->transnoentitiesnoconv("NewTranslationStringToShow"))."\n";
print ' ('.$langs->trans("TranslationOverwriteDesc2").').'."<br>\n";
print '</span></div>';
print '<br>';
@ -291,9 +304,9 @@ if ($mode == 'overwrite')
print $formadmin->select_language(GETPOST('langcode'), 'langcode', 0, null, 1, 0, $disablededit?1:0, 'maxwidthonsmartphone', 1);
print '</td>'."\n";
print '<td>';
print '<input type="text" class="flat maxwidthonsmartphone"'.$disablededit.' name="transkey" value="">';
print '<input type="text" class="flat maxwidthonsmartphone"'.$disablededit.' name="transkey" value="'.(!empty($transkey)?$transkey:"").'">';
print '</td><td>';
print '<input type="text" class="quatrevingtpercent"'.$disablededit.' name="transvalue" value="">';
print '<input type="text" class="quatrevingtpercent"'.$disablededit.' name="transvalue" value="'.(!empty($transvalue)?$transvalue:"").'">';
print '</td>';
// Limit to superadmin
/*if (! empty($conf->multicompany->enabled) && !$user->entity)
@ -319,7 +332,7 @@ if ($mode == 'overwrite')
$sql = "SELECT rowid, entity, lang, transkey, transvalue";
$sql.= " FROM ".MAIN_DB_PREFIX."overwrite_trans";
$sql.= " WHERE 1 = 1";
//$sql.= " AND entity IN (".$user->entity.",".$conf->entity.")";
$sql.= " AND entity IN (".getEntity('overwrite_trans').")";
$sql.= $db->order($sortfield, $sortorder);
dol_syslog("translation::select from table", LOG_DEBUG);
@ -483,7 +496,7 @@ if ($mode == 'searchkey')
//}
print '</td>';
// Action column
print '<td class="liste_titre nowrap" align="right">';
print '<td class="nowrap" align="right">';
$searchpicto=$form->showFilterAndCheckAddButtons($massactionbutton?1:0, 'checkforselect', 1);
print $searchpicto;
print '</td>';
@ -508,9 +521,36 @@ if ($mode == 'searchkey')
{
if ($val != $newlangfileonly->tab_translate[$key])
{
// retrieve rowid
$sql = "SELECT rowid";
$sql.= " FROM " . MAIN_DB_PREFIX . "overwrite_trans";
$sql.= " WHERE transkey = '".$key."'";
$sql.= " AND entity IN (" . getEntity('overwrite_trans') . ")";
dol_syslog("translation::select from table", LOG_DEBUG);
$result = $db->query($sql);
if ($result)
{
$obj = $db->fetch_object($result);
}
print '<a href="' . $_SERVER['PHP_SELF'] . '?rowid=' . $obj->rowid . '&entity=' . $conf->entity . '&action=edit">' . img_edit() . '</a>';
print '&nbsp;&nbsp;';
print '<a href="' . $_SERVER['PHP_SELF'] . '?rowid=' . $obj->rowid . '&entity=' . $conf->entity . '&action=delete">' . img_delete() . '</a>';
print '&nbsp;&nbsp;';
$htmltext = $langs->trans("OriginalValueWas", $newlangfileonly->tab_translate[$key]);
print $form->textwithpicto('', $htmltext, 1, 'info');
}
else if (!empty($conf->global->MAIN_ENABLE_OVERWRITE_TRANSLATION))
{
//print $key.'-'.$val;
print '<a href="' . $_SERVER['PHP_SELF'] . '?mode=overwrite&amp;langcode=' . $langcode . '&amp;transkey=' . $key . '">' . img_edit_add($langs->trans("Overwrite")) . '</a>';
}
if (! empty($conf->global->MAIN_FEATURES_LEVEL))
{
$transifexlangfile='$'; // $ means 'All'
$transifexurl = 'https://www.transifex.com/dolibarr-association/dolibarr/translate/#'.$langcode.'/'.$transifexlangfile.'?key='.$key;
print ' &nbsp; <a href="'.$transifexurl.'" target="transifex">'.img_picto('FixOnTransifex', 'object_globe').'</a>';
}
}
else
{

View File

@ -69,7 +69,7 @@ class DolibarrApiAccess implements iAuthenticate
*/
public function __isAllowed()
{
global $db;
global $conf, $db;
$login = '';
$stored_key = '';
@ -100,11 +100,14 @@ class DolibarrApiAccess implements iAuthenticate
if ($api_key)
{
$userentity = 0;
$sql = "SELECT u.login, u.datec, u.api_key, ";
$sql.= " u.tms as date_modification, u.entity";
$sql.= " FROM ".MAIN_DB_PREFIX."user as u";
$sql.= " WHERE u.api_key = '".$db->escape($api_key)."'";
// TODO Check if 2 users has same API key.
$result = $db->query($sql);
if ($result)
{
@ -113,24 +116,31 @@ class DolibarrApiAccess implements iAuthenticate
$obj = $db->fetch_object($result);
$login = $obj->login;
$stored_key = $obj->api_key;
$userentity = $obj->entity;
if (! defined("DOLENTITY")) // If API was not forced with HTTP_DOLENTITY, we set entity to entity of user
{
$conf->entity = ($obj->entity?$obj->entity:1);
}
}
}
else {
throw new RestException(503, 'Error when fetching user api_key :'.$db->error_msg);
}
if ($stored_key != $api_key) {
if ($stored_key != $api_key) { // This should not happen since we did a search on api_key
$userClass::setCacheIdentifier($api_key);
return false;
}
if (! $login)
{
throw new RestException(503, 'Error when searching logn user fro mapi key');
throw new RestException(503, 'Error when searching login user from api key');
}
$fuser = new User($db);
if(! $fuser->fetch('',$login)) {
throw new RestException(503, 'Error when fetching user :'.$fuser->error);
$result = $fuser->fetch('', $login, '', 0, (empty($userentity) ? -1 : $conf->entity)); // If user is not entity 0, we search in working entity $conf->entity (that may have been forced to a different value than user entity)
if ($result <= 0) {
throw new RestException(503, 'Error when fetching user :'.$fuser->error.' (conf->entity='.$conf->entity.')');
}
$fuser->getrights();
static::$user = $fuser;
@ -143,14 +153,14 @@ class DolibarrApiAccess implements iAuthenticate
}
else
{
throw new RestException(401, "Failed to login to API. No parameter 'DOLAPIKEY' on HTTP header (neither in URL).");
throw new RestException(401, "Failed to login to API. No parameter 'HTTP_DOLAPIKEY' on HTTP header (and no parameter DOLAPIKEY in URL).");
}
$userClass::setCacheIdentifier(static::$role);
Resources::$accessControlFunction = 'DolibarrApiAccess::verifyAccess';
$requirefortest = static::$requires;
if (! is_array($requirefortest)) $requirefortest=explode(',',$requirefortest);
return in_array(static::$role, (array) $requirefortest) || static::$role == 'admin';
$userClass::setCacheIdentifier(static::$role);
Resources::$accessControlFunction = 'DolibarrApiAccess::verifyAccess';
$requirefortest = static::$requires;
if (! is_array($requirefortest)) $requirefortest=explode(',',$requirefortest);
return in_array(static::$role, (array) $requirefortest) || static::$role == 'admin';
}
/**

View File

@ -241,6 +241,7 @@ if (! empty($reg[1]) && ($reg[1] != 'explorer' || ($reg[2] != '/resources.json'
else
{
$classfile = str_replace('_', '', $module);
if ($module == 'contracts') $moduledirforclass = 'contrat';
if ($module == 'supplierinvoices') $classfile = 'supplier_invoices';
if ($module == 'supplierorders') $classfile = 'supplier_orders';
$dir_part_file = dol_buildpath('/'.$moduledirforclass.'/class/api_'.$classfile.'.class.php');

View File

@ -36,7 +36,7 @@ if (! $user->admin) accessforbidden();
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;
@ -71,33 +71,33 @@ if (GETPOST('refreshpage')) $action='preview';
// Add a collab page
if ($action == 'add')
{
$db->begin();
$db->begin();
$objectpage->title = GETPOST('WEBSITE_TITLE');
$objectpage->pageurl = GETPOST('WEBSITE_PAGENAME');
$objectpage->description = GETPOST('WEBSITE_DESCRIPTION');
$objectpage->keywords = GETPOST('WEBSITE_KEYWORD');
$objectpage->title = GETPOST('WEBSITE_TITLE');
$objectpage->pageurl = GETPOST('WEBSITE_PAGENAME');
$objectpage->description = GETPOST('WEBSITE_DESCRIPTION');
$objectpage->keywords = GETPOST('WEBSITE_KEYWORD');
if (empty($objectpage->title))
{
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("WEBSITE_PAGENAME")), null, 'errors');
$error++;
}
if (empty($objectpage->title))
{
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("WEBSITE_PAGENAME")), null, 'errors');
$error++;
}
if (! $error)
{
$res = $objectpage->create($user);
if ($res <= 0)
{
$error++;
setEventMessages($objectpage->error, $objectpage->errors, 'errors');
}
}
if (! $error)
{
$res = $objectpage->create($user);
if ($res <= 0)
{
$error++;
setEventMessages($objectpage->error, $objectpage->errors, 'errors');
}
}
if (! $error)
{
$db->commit();
setEventMessages($langs->trans("PageAdded", $objectpage->pageurl), null, 'mesgs');
$action='';
setEventMessages($langs->trans("PageAdded", $objectpage->pageurl), null, 'mesgs');
$action='';
}
else
{
@ -111,38 +111,38 @@ if ($action == 'add')
// Update page
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)
{
$res = $objectpage->delete($user);
if (! $res > 0)
{
$error++;
setEventMessages($objectpage->error, $objectpage->errors, 'errors');
}
if ($res > 0)
{
$res = $objectpage->delete($user);
if (! $res > 0)
{
$error++;
setEventMessages($objectpage->error, $objectpage->errors, 'errors');
}
if (! $error)
{
$db->commit();
setEventMessages($langs->trans("PageDeleted", $objectpage->pageurl, $website), null, 'mesgs');
if (! $error)
{
$db->commit();
setEventMessages($langs->trans("PageDeleted", $objectpage->pageurl, $website), null, 'mesgs');
header("Location: ".$_SERVER["PHP_SELF"].'?website='.$website);
exit;
}
else
{
$db->rollback();
}
}
else
{
dol_print_error($db);
}
header("Location: ".$_SERVER["PHP_SELF"].'?website='.$website);
exit;
}
else
{
$db->rollback();
}
}
else
{
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'].'">';
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)
{
// ***** Part for web sites
// ***** Part for web sites
print '<div class="websiteselection hideonsmartphoneimp">';
print $langs->trans("Website").': ';
print '</div>';
print '<div class="websiteselection hideonsmartphoneimp">';
print $langs->trans("Website").': ';
print '</div>';
// List of websites
print '<div class="websiteselection">';
$out='';
$out.='<select name="website" class="minwidth100" id="website">';
if (empty($object->records)) $out.='<option value="-1">&nbsp;</option>';
// Loop on each sites
$i=0;
foreach($object->records as $key => $valwebsite)
{
if (empty($website)) $website=$valwebsite->ref;
// List of websites
print '<div class="websiteselection">';
$out='';
$out.='<select name="website" class="minwidth100" id="website">';
if (empty($object->records)) $out.='<option value="-1">&nbsp;</option>';
// Loop on each sites
$i=0;
foreach($object->records as $key => $valwebsite)
{
if (empty($website)) $website=$valwebsite->ref;
$out.='<option value="'.$valwebsite->ref.'"';
if ($website == $valwebsite->ref) $out.=' selected'; // To preselect a value
$out.='>';
$out.=$valwebsite->ref;
$out.='</option>';
$i++;
}
$out.='</select>';
$out.=ajax_combobox('website');
print $out;
print '<input type="submit" class="button" name="refreshsite" value="'.$langs->trans("Load").'">';
$out.='<option value="'.$valwebsite->ref.'"';
if ($website == $valwebsite->ref) $out.=' selected'; // To preselect a value
$out.='>';
$out.=$valwebsite->ref;
$out.='</option>';
$i++;
}
$out.='</select>';
$out.=ajax_combobox('website');
print $out;
print '<input type="submit" class="button" name="refreshsite" value="'.$langs->trans("Load").'">';
if ($website)
{
$virtualurl='';
$dataroot=DOL_DATA_ROOT.'/websites/'.$website;
if (! empty($object->virtualhost)) $virtualurl=$object->virtualhost;
}
if ($website)
{
$virtualurl='';
$dataroot=DOL_DATA_ROOT.'/websites/'.$website;
if (! empty($object->virtualhost)) $virtualurl=$object->virtualhost;
}
if ($website && $action == 'preview')
{
$disabled='';
if (empty($user->rights->websites->write)) $disabled=' disabled="disabled"';
if ($website && $action == 'preview')
{
$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("EditCss")).'" name="editcss">';
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" 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("EditMenu")).'" name="editmenu">';
print '<input type="submit"'.$disabled.' class="button" value="'.dol_escape_htmltag($langs->trans("AddPage")).'" name="create">';
}
print '</div>';
print '</div>';
// Button for websites
print '<div class="websitetools">';
// Button for websites
print '<div class="websitetools">';
if ($action == 'preview')
{
print '<div class="websiteinputurl">';
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").'">';
$htmltext=$langs->trans("SetHereVirtualHost", $dataroot);
print $form->textwithpicto('', $htmltext);
print '</div>';
if ($action == 'preview')
{
print '<div class="websiteinputurl">';
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").'">';
$htmltext=$langs->trans("SetHereVirtualHost", $dataroot);
print $form->textwithpicto('', $htmltext);
print '</div>';
$urlext=$virtualurl;
$urlint=$urlwithroot.'/public/websites/index.php?website='.$website;
//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 $form->textwithpicto('', $langs->trans("PreviewSiteServedByWebServer", $langs->transnoentitiesnoconv("Site"), $langs->transnoentitiesnoconv("Site"), $dataroot, $urlext?$urlext:$langs->trans("VirtualHostUrlNotDefined")), 1, 'preview_ext');
print '</a>';
//}
$urlext=$virtualurl;
$urlint=$urlwithroot.'/public/websites/index.php?website='.$website;
//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 $form->textwithpicto('', $langs->trans("PreviewSiteServedByWebServer", $langs->transnoentitiesnoconv("Site"), $langs->transnoentitiesnoconv("Site"), $dataroot, $urlext?$urlext:$langs->trans("VirtualHostUrlNotDefined")), 1, 'preview_ext');
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 $form->textwithpicto('', $langs->trans("PreviewSiteServedByDolibarr", $langs->transnoentitiesnoconv("Site"), $langs->transnoentitiesnoconv("Site"), $urlint, $dataroot), 1, 'preview');
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 $form->textwithpicto('', $langs->trans("PreviewSiteServedByDolibarr", $langs->transnoentitiesnoconv("Site"), $langs->transnoentitiesnoconv("Site"), $urlint, $dataroot), 1, 'preview');
print '</a>';
}
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 (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 (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 (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">';
}
print '</div>';
print '</div>';
// ***** Part for pages
// ***** Part for pages
if ($website)
{
print '</div>';
if ($website)
{
print '</div>';
$array=$objectpage->fetchAll($object->id);
if (! is_array($array) && $array < 0) dol_print_error('', $objectpage->error, $objectpage->errors);
$atleastonepage=(is_array($array) && count($array) > 0);
$array=$objectpage->fetchAll($object->id);
if (! is_array($array) && $array < 0) dol_print_error('', $objectpage->error, $objectpage->errors);
$atleastonepage=(is_array($array) && count($array) > 0);
print '<div class="centpercent websitebar"'.($style?' style="'.$style.'"':'').'">';
print '<div class="websiteselection hideonsmartphoneimp">';
print $langs->trans("Page").': ';
print '</div>';
print '<div class="websiteselection">';
print '<div class="centpercent websitebar"'.($style?' style="'.$style.'"':'').'">';
print '<div class="websiteselection hideonsmartphoneimp">';
print $langs->trans("Page").': ';
print '</div>';
print '<div class="websiteselection">';
if ($action != 'add')
{
$out='';
$out.='<select name="pageid" id="pageid" class="minwidth200">';
if ($atleastonepage)
{
if (empty($pageid) && $action != 'create') // Page id is not defined, we try to take one
{
$firstpageid=0;$homepageid=0;
foreach($array as $key => $valpage)
{
if (empty($firstpageid)) $firstpageid=$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
}
if ($action != 'add')
{
$out='';
$out.='<select name="pageid" id="pageid" class="minwidth200">';
if ($atleastonepage)
{
if (empty($pageid) && $action != 'create') // Page id is not defined, we try to take one
{
$firstpageid=0;$homepageid=0;
foreach($array as $key => $valpage)
{
if (empty($firstpageid)) $firstpageid=$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
}
foreach($array as $key => $valpage)
{
$out.='<option value="'.$key.'"';
if ($pageid > 0 && $pageid == $key) $out.=' selected'; // To preselect a value
$out.='>';
$out.=$valpage->title;
if ($object->fk_default_home && $key == $object->fk_default_home) $out.=' ('.$langs->trans("HomePage").')';
$out.='</option>';
}
}
else $out.='<option value="-1">&nbsp;</option>';
$out.='</select>';
$out.=ajax_combobox('pageid');
print $out;
}
else
{
print $langs->trans("New");
}
foreach($array as $key => $valpage)
{
$out.='<option value="'.$key.'"';
if ($pageid > 0 && $pageid == $key) $out.=' selected'; // To preselect a value
$out.='>';
$out.=$valpage->title;
if ($object->fk_default_home && $key == $object->fk_default_home) $out.=' ('.$langs->trans("HomePage").')';
$out.='</option>';
}
}
else $out.='<option value="-1">&nbsp;</option>';
$out.='</select>';
$out.=ajax_combobox('pageid');
print $out;
}
else
{
print $langs->trans("New");
}
print '<input type="submit" class="button" name="refreshpage" value="'.$langs->trans("Load").'"'.($atleastonepage?'':' disabled="disabled"').'>';
//print $form->selectarray('page', $array);
print '<input type="submit" class="button" name="refreshpage" value="'.$langs->trans("Load").'"'.($atleastonepage?'':' disabled="disabled"').'>';
//print $form->selectarray('page', $array);
if ($action == 'preview')
{
$disabled='';
if (empty($user->rights->websites->write)) $disabled=' disabled="disabled"';
if ($action == 'preview')
{
$disabled='';
if (empty($user->rights->websites->write)) $disabled=' disabled="disabled"';
if ($pageid > 0)
{
print ' &nbsp; ';
if ($pageid > 0)
{
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">';
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("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=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"').'>';
}
}
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">';
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 '<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 '<input type="submit" class="buttonDelete" name="delete" value="'.$langs->trans("Delete").'"'.($atleastonepage?'':' disabled="disabled"').'>';
}
}
print '</div>';
print '<div class="websiteselection">';
print '</div>';
print '</div>';
print '<div class="websiteselection">';
print '</div>';
print '<div class="websitetools">';
print '<div class="websitetools">';
if ($website && $pageid > 0 && $action == 'preview')
{
$websitepage = new WebSitePage($db);
$websitepage->fetch($pageid);
if ($website && $pageid > 0 && $action == 'preview')
{
$websitepage = new WebSitePage($db);
$websitepage->fetch($pageid);
$realpage=$urlwithroot.'/public/websites/index.php?website='.$website.'&page='.$pageid;
$pagealias = $websitepage->pageurl;
$realpage=$urlwithroot.'/public/websites/index.php?website='.$website.'&page='.$pageid;
$pagealias = $websitepage->pageurl;
print '<div class="websiteinputurl">';
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").'">';
$htmltext=$langs->trans("WEBSITE_PAGENAME", $pagealias);
print $form->textwithpicto('', $htmltext);
print '</div>';
print '<div class="websiteinputurl">';
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").'">';
$htmltext=$langs->trans("WEBSITE_PAGENAME", $pagealias);
print $form->textwithpicto('', $htmltext);
print '</div>';
if (! empty($object->virtualhost))
{
$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 $form->textwithpicto('', $langs->trans("PreviewSiteServedByWebServer", $langs->transnoentitiesnoconv("Page"), $langs->transnoentitiesnoconv("Page"), $dataroot, $urlext?$urlext:$langs->trans("VirtualHostUrlNotDefined")), 1, 'preview_ext');
print '</a>';
}
else
{
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 '</a>';
}
if (! empty($object->virtualhost))
{
$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 $form->textwithpicto('', $langs->trans("PreviewSiteServedByWebServer", $langs->transnoentitiesnoconv("Page"), $langs->transnoentitiesnoconv("Page"), $dataroot, $urlext?$urlext:$langs->trans("VirtualHostUrlNotDefined")), 1, 'preview_ext');
print '</a>';
}
else
{
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 '</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 $form->textwithpicto('', $langs->trans("PreviewSiteServedByDolibarr", $langs->transnoentitiesnoconv("Page"), $langs->transnoentitiesnoconv("Page"), $realpage, $dataroot), 1, 'preview');
print '</a>'; // View page in new Tab
//print '<input type="submit" class="button" name="previewpage" target="tab'.$website.'"value="'.$langs->trans("ViewPageInNewTab").'">';
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 '</a>'; // View page in new Tab
//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
}
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 (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">';
}
// 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 ($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('/^edit/',$action)) print '<input type="submit" class="button" value="'.dol_escape_htmltag($langs->trans("Save")).'" name="update">';
}
print '</div>';
print '</div>';
if ($action == 'preview')
{
// Adding jquery code to change on the fly url of preview ext
if (! empty($conf->use_javascript_ajax))
{
print '<script type="text/javascript" language="javascript">
if ($action == 'preview')
{
// Adding jquery code to change on the fly url of preview ext
if (! empty($conf->use_javascript_ajax))
{
print '<script type="text/javascript" language="javascript">
jQuery(document).ready(function() {
jQuery("#previewsiteext,#previewpageext").click(function() {
newurl=jQuery("#previewsiteurl").val();
@ -417,17 +417,17 @@ if (count($object->records) > 0)
});
});
</script>';
}
}
}
}
}
}
}
else
{
print '<div class="websiteselection">';
$langs->load("errors");
print $langs->trans("ErrorModuleSetupNotComplete");
print '<div>';
$action='';
print '<div class="websiteselection">';
$langs->load("errors");
print $langs->trans("ErrorModuleSetupNotComplete");
print '<div>';
$action='';
}
@ -437,21 +437,21 @@ $head = array();
if ($action == 'editcontent')
{
/*
/*
* Editing global variables not related to a specific theme
*/
$csscontent = @file_get_contents($filecss);
$csscontent = @file_get_contents($filecss);
$contentforedit = '';
/*$contentforedit.='<style scoped>'."\n"; // "scoped" means "apply to parent element only". Not yet supported by browsers
$contentforedit = '';
/*$contentforedit.='<style scoped>'."\n"; // "scoped" means "apply to parent element only". Not yet supported by browsers
$contentforedit.=$csscontent;
$contentforedit.='</style>'."\n";*/
$contentforedit .= $objectpage->content;
$contentforedit .= $objectpage->content;
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->Create(0, '', false);
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->Create(0, '', false);
}
print "</div>\n</form>\n";

View File

@ -199,8 +199,8 @@ if ($action == 'add')
$percentage=in_array(GETPOST('status'),array(-1,100))?GETPOST('status'):(in_array(GETPOST('complete'),array(-1,100))?GETPOST('complete'):GETPOST("percentage")); // If status is -1 or 100, percentage is not defined and we must use status
// Clean parameters
$datep=dol_mktime($fulldayevent?'00':GETPOST("aphour"), $fulldayevent?'00':GETPOST("apmin"), 0, GETPOST("apmonth"), GETPOST("apday"), GETPOST("apyear"));
$datef=dol_mktime($fulldayevent?'23':GETPOST("p2hour"), $fulldayevent?'59':GETPOST("p2min"), $fulldayevent?'59':'0', GETPOST("p2month"), GETPOST("p2day"), GETPOST("p2year"));
$datep=dol_mktime($fulldayevent?'00':GETPOST("aphour",'int'), $fulldayevent?'00':GETPOST("apmin",'int'), $fulldayevent?'00':GETPOST("apsec",'int'), GETPOST("apmonth",'int'), GETPOST("apday",'int'), GETPOST("apyear",'int'));
$datef=dol_mktime($fulldayevent?'23':GETPOST("p2hour",'int'), $fulldayevent?'59':GETPOST("p2min",'int'), $fulldayevent?'59':GETPOST("apsec",'int'), GETPOST("p2month",'int'), GETPOST("p2day",'int'), GETPOST("p2year",'int'));
// Check parameters
if (! $datef && $percentage == 100)

View File

@ -907,7 +907,7 @@ class ActionComm extends CommonObject
return $db->lasterror();
}
}
/**
* Load indicators for dashboard (this->nbtodo and this->nbtodolate)
*
@ -918,7 +918,7 @@ class ActionComm extends CommonObject
function load_board($user, $load_state_board=0)
{
global $conf, $langs;
if(empty($load_state_board)) $sql = "SELECT a.id, a.datep as dp";
else {
$this->nb=array();
@ -934,7 +934,7 @@ class ActionComm extends CommonObject
if (! $user->rights->societe->client->voir && ! $user->societe_id) $sql.= " AND (a.fk_soc IS NULL OR sc.fk_user = " .$user->id . ")";
if ($user->societe_id) $sql.=" AND a.fk_soc = ".$user->societe_id;
if (! $user->rights->agenda->allactions->read) $sql.= " AND (a.fk_user_author = ".$user->id . " OR a.fk_user_action = ".$user->id . " OR a.fk_user_done = ".$user->id . ")";
$resql=$this->db->query($sql);
if ($resql)
{
@ -956,7 +956,7 @@ class ActionComm extends CommonObject
if ($agenda_static->hasDelay()) $response->nbtodolate++;
} else $this->nb["actionscomm"]=$obj->nb;
}
$this->db->free($resql);
if(empty($load_state_board)) return $response;
else return 1;

View File

@ -2284,6 +2284,14 @@ if ($action == 'create')
}
}
// Create an intervention
if (! empty($conf->service->enabled) && ! empty($conf->ficheinter->enabled) && $object->statut == Propal::STATUS_SIGNED) {
if ($user->rights->ficheinter->creer) {
$langs->load("interventions");
print '<div class="inline-block divButAction"><a class="butAction" href="' . DOL_URL_ROOT . '/fichinter/card.php?action=create&amp;origin=' . $object->element . '&amp;originid=' . $object->id . '&amp;socid=' . $object->socid . '">' . $langs->trans("AddIntervention") . '</a></div>';
}
}
// Create contract
if ($conf->contrat->enabled && $object->statut == Propal::STATUS_SIGNED) {
$langs->load("contracts");

View File

@ -287,7 +287,7 @@ class Proposals extends DolibarrApi
);
if ($updateRes > 0) {
return $this->get($id)->line->rowid;
return $updateRes;
}
return false;

View File

@ -170,7 +170,7 @@ if (empty($reshook))
$result = $object->set_reopen($user);
if ($result > 0)
{
setEventMessages($langs->trans('OrderReopened', $object->ref), null);
setEventMessages($langs->trans('OrderReopened', $object->ref), null);
}
else
{
@ -264,12 +264,12 @@ if (empty($reshook))
$object->modelpdf = GETPOST('model');
$object->cond_reglement_id = GETPOST('cond_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->demand_reason_id = GETPOST('demand_reason_id');
$object->date_livraison = $datelivraison;
$object->shipping_method_id = GETPOST('shipping_method_id', 'int');
$object->warehouse_id = GETPOST('warehouse_id', 'int');
$object->shipping_method_id = GETPOST('shipping_method_id', 'int');
$object->warehouse_id = GETPOST('warehouse_id', 'int');
$object->fk_delivery_address = GETPOST('fk_address');
$object->contactid = GETPOST('contactid');
$object->fk_incoterms = GETPOST('incoterm_id', 'int');
@ -279,8 +279,8 @@ if (empty($reshook))
// Fill array 'array_options' with data from add form
if (! $error)
{
$ret = $extrafields->setOptionalsFromPost($extralabels, $object);
if ($ret < 0) $error++;
$ret = $extrafields->setOptionalsFromPost($extralabels, $object);
if ($ret < 0) $error++;
}
// If creation from another object of another module (Example: origin=propal, originid=1)
@ -366,7 +366,7 @@ if (empty($reshook))
// Extrafields
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);
$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
// modified by hook
if ($reshook < 0)
$error++;
$error++;
} else {
setEventMessages($object->error, $object->errors, 'errors');
@ -491,10 +491,10 @@ if (empty($reshook))
}
else if ($action == 'classifyunbilled' && $user->rights->commande->creer)
{
$ret=$object->classifyUnBilled();
if ($ret < 0) {
setEventMessages($object->error, $object->errors, 'errors');
}
$ret=$object->classifyUnBilled();
if ($ret < 0) {
setEventMessages($object->error, $object->errors, 'errors');
}
}
// Positionne ref commande client
@ -502,7 +502,7 @@ if (empty($reshook))
$result = $object->set_ref_client($user, GETPOST('ref_client'));
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'));
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) {
$result = $object->availability(GETPOST('availability_id'));
if ($result < 0)
setEventMessages($object->error, $object->errors, 'errors');
setEventMessages($object->error, $object->errors, 'errors');
}
else if ($action == 'setdemandreason' && $user->rights->commande->creer) {
@ -596,36 +596,36 @@ if (empty($reshook))
// Set incoterm
elseif ($action == 'set_incoterms' && !empty($conf->incoterm->enabled))
{
$result = $object->setIncoterms(GETPOST('incoterm_id', 'int'), GETPOST('location_incoterms', 'alpha'));
if ($result < 0) {
setEventMessages($object->error, $object->errors, 'errors');
}
}
{
$result = $object->setIncoterms(GETPOST('incoterm_id', 'int'), GETPOST('location_incoterms', 'alpha'));
if ($result < 0) {
setEventMessages($object->error, $object->errors, 'errors');
}
}
// bank account
else if ($action == 'setbankaccount' && $user->rights->commande->creer) {
$result=$object->setBankAccount(GETPOST('fk_account', 'int'));
if ($result < 0) {
setEventMessages($object->error, $object->errors, 'errors');
}
$result=$object->setBankAccount(GETPOST('fk_account', 'int'));
if ($result < 0) {
setEventMessages($object->error, $object->errors, 'errors');
}
}
// shipping method
else if ($action == 'setshippingmethod' && $user->rights->commande->creer) {
$result = $object->setShippingMethod(GETPOST('shipping_method_id', 'int'));
if ($result < 0) {
setEventMessages($object->error, $object->errors, 'errors');
}
$result = $object->setShippingMethod(GETPOST('shipping_method_id', 'int'));
if ($result < 0) {
setEventMessages($object->error, $object->errors, 'errors');
}
}
// warehouse
else if ($action == 'setwarehouse' && $user->rights->commande->creer) {
$result = $object->setWarehouse(GETPOST('warehouse_id', 'int'));
if ($result < 0) {
setEventMessages($object->error, $object->errors, 'errors');
}
}
// warehouse
else if ($action == 'setwarehouse' && $user->rights->commande->creer) {
$result = $object->setWarehouse(GETPOST('warehouse_id', 'int'));
if ($result < 0) {
setEventMessages($object->error, $object->errors, 'errors');
}
}
else if ($action == 'setremisepercent' && $user->rights->commande->creer) {
$result = $object->set_remise($user, GETPOST('remise_percent'));
@ -898,18 +898,18 @@ if (empty($reshook))
unset($_POST['idprod']);
unset($_POST['units']);
unset($_POST['date_starthour']);
unset($_POST['date_startmin']);
unset($_POST['date_startsec']);
unset($_POST['date_startday']);
unset($_POST['date_startmonth']);
unset($_POST['date_startyear']);
unset($_POST['date_endhour']);
unset($_POST['date_endmin']);
unset($_POST['date_endsec']);
unset($_POST['date_endday']);
unset($_POST['date_endmonth']);
unset($_POST['date_endyear']);
unset($_POST['date_starthour']);
unset($_POST['date_startmin']);
unset($_POST['date_startsec']);
unset($_POST['date_startday']);
unset($_POST['date_startmonth']);
unset($_POST['date_startyear']);
unset($_POST['date_endhour']);
unset($_POST['date_endmin']);
unset($_POST['date_endsec']);
unset($_POST['date_endday']);
unset($_POST['date_endmonth']);
unset($_POST['date_endyear']);
} else {
setEventMessages($object->error, $object->errors, 'errors');
}
@ -1062,13 +1062,13 @@ if (empty($reshook))
}
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->order_advance->validate)))
((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)))
)
{
$idwarehouse = GETPOST('idwarehouse');
$qualified_for_stock_change=0;
$qualified_for_stock_change=0;
if (empty($conf->global->STOCK_SUPPORTS_SERVICES))
{
$qualified_for_stock_change=$object->hasProductsOrServices(2);
@ -1121,7 +1121,7 @@ if (empty($reshook))
else if ($action == 'confirm_modif' && $user->rights->commande->creer) {
$idwarehouse = GETPOST('idwarehouse');
$qualified_for_stock_change=0;
$qualified_for_stock_change=0;
if (empty($conf->global->STOCK_SUPPORTS_SERVICES))
{
$qualified_for_stock_change=$object->hasProductsOrServices(2);
@ -1174,13 +1174,13 @@ if (empty($reshook))
}
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->order_advance->validate)))
((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)))
)
{
$idwarehouse = GETPOST('idwarehouse');
$qualified_for_stock_change=0;
$qualified_for_stock_change=0;
if (empty($conf->global->STOCK_SUPPORTS_SERVICES))
{
$qualified_for_stock_change=$object->hasProductsOrServices(2);
@ -1223,7 +1223,7 @@ if (empty($reshook))
$hookmanager->initHooks(array('orderdao'));
$parameters = array('id' => $object->id);
$reshook = $hookmanager->executeHooks('insertExtraFields', $parameters, $object, $action); // Note that $action and $object may have been modified by
// some hooks
// some hooks
if (empty($reshook)) {
$result = $object->insertExtraFields();
if ($result < 0) {
@ -1393,10 +1393,10 @@ if ($action == 'create' && $user->rights->commande->creer)
$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));
$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));
$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));
$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));
$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_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;
$mode_reglement_id = $soc->mode_reglement_id;
$fk_account = $soc->fk_account;
$fk_account = $soc->fk_account;
$availability_id = $soc->availability_id;
$shipping_method_id = $soc->shipping_method_id;
$warehouse_id = $soc->warehouse_id;
$shipping_method_id = $soc->shipping_method_id;
$warehouse_id = $soc->warehouse_id;
$demand_reason_id = $soc->demand_reason_id;
$remise_percent = $soc->remise_percent;
$remise_absolue = 0;
@ -1537,12 +1537,12 @@ if ($action == 'create' && $user->rights->commande->creer)
$form->select_types_paiements($mode_reglement_id, 'mode_reglement_id');
print '</td></tr>';
// Bank Account
// Bank Account
if (! empty($conf->global->BANK_ASK_PAYMENT_BANK_DURING_ORDER) && ! empty($conf->banque->enabled))
{
print '<tr><td>' . $langs->trans('BankAccount') . '</td><td>';
$form->select_comptes($fk_account, 'fk_account', 0, '', 1);
print '</td></tr>';
$form->select_comptes($fk_account, 'fk_account', 0, '', 1);
print '</td></tr>';
}
// Delivery delay
@ -1550,21 +1550,21 @@ if ($action == 'create' && $user->rights->commande->creer)
$form->selectAvailabilityDelay($availability_id, 'availability_id', '', 1);
print '</td></tr>';
// Shipping Method
if (! empty($conf->expedition->enabled)) {
print '<tr><td>' . $langs->trans('SendingMethod') . '</td><td>';
print $form->selectShippingMethod($shipping_method_id, 'shipping_method_id', '', 1);
print '</td></tr>';
}
// Shipping Method
if (! empty($conf->expedition->enabled)) {
print '<tr><td>' . $langs->trans('SendingMethod') . '</td><td>';
print $form->selectShippingMethod($shipping_method_id, 'shipping_method_id', '', 1);
print '</td></tr>';
}
// Warehouse
if (! empty($conf->expedition->enabled) && ! empty($conf->global->WAREHOUSE_ASK_WAREHOUSE_DURING_ORDER)) {
require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php';
$formproduct=new FormProduct($db);
print '<tr><td>' . $langs->trans('Warehouse') . '</td><td>';
print $formproduct->selectWarehouses($warehouse_id, 'warehouse_id', '', 1);
print '</td></tr>';
}
// Warehouse
if (! empty($conf->expedition->enabled) && ! empty($conf->global->WAREHOUSE_ASK_WAREHOUSE_DURING_ORDER)) {
require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php';
$formproduct=new FormProduct($db);
print '<tr><td>' . $langs->trans('Warehouse') . '</td><td>';
print $formproduct->selectWarehouses($warehouse_id, 'warehouse_id', '', 1);
print '</td></tr>';
}
// What trigger creation
print '<tr><td>' . $langs->trans('Source') . '</td><td>';
@ -1590,22 +1590,22 @@ if ($action == 'create' && $user->rights->commande->creer)
{
print '<tr>';
print '<td><label for="incoterm_id">'.$form->textwithpicto($langs->trans("IncotermLabel"), $objectsrc->libelle_incoterms, 1).'</label></td>';
print '<td class="maxwidthonsmartphone">';
$incoterm_id = GETPOST('incoterm_id');
$incoterm_location = GETPOST('location_incoterms');
if (empty($incoterm_id))
{
$incoterm_id = (!empty($objectsrc->fk_incoterms) ? $objectsrc->fk_incoterms : $soc->fk_incoterms);
$incoterm_location = (!empty($objectsrc->location_incoterms) ? $objectsrc->location_incoterms : $soc->location_incoterms);
}
print $form->select_incoterms($incoterm_id, $incoterm_location);
print '<td class="maxwidthonsmartphone">';
$incoterm_id = GETPOST('incoterm_id');
$incoterm_location = GETPOST('location_incoterms');
if (empty($incoterm_id))
{
$incoterm_id = (!empty($objectsrc->fk_incoterms) ? $objectsrc->fk_incoterms : $soc->fk_incoterms);
$incoterm_location = (!empty($objectsrc->location_incoterms) ? $objectsrc->location_incoterms : $soc->location_incoterms);
}
print $form->select_incoterms($incoterm_id, $incoterm_location);
print '</td></tr>';
}
// Other attributes
$parameters = array('objectsrc' => $objectsrc, 'socid'=>$socid);
$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)) {
print $object->showOptionals($extrafields, 'edit');
}
@ -1623,8 +1623,8 @@ if ($action == 'create' && $user->rights->commande->creer)
{
print '<tr>';
print '<td>'.fieldLabel('Currency','multicurrency_code').'</td>';
print '<td class="maxwidthonsmartphone">';
print $form->selectMultiCurrency($currency_code, 'multicurrency_code');
print '<td class="maxwidthonsmartphone">';
print $form->selectMultiCurrency($currency_code, 'multicurrency_code');
print '</td></tr>';
}
@ -1686,6 +1686,8 @@ if ($action == 'create' && $user->rights->commande->creer)
}
print '<tr><td>' . $langs->trans($newclassname) . '</td><td>' . $objectsrc->getNomUrl(1) . '</td></tr>';
// Amount
print '<tr><td>' . $langs->trans('TotalHT') . '</td><td>' . price($objectsrc->total_ht) . '</td></tr>';
print '<tr><td>' . $langs->trans('TotalVAT') . '</td><td>' . price($objectsrc->total_tva) . "</td></tr>";
if ($mysoc->localtax1_assuj == "1" || $objectsrc->total_localtax1 != 0) // Localtax1 RE
@ -1918,69 +1920,69 @@ if ($action == 'create' && $user->rights->commande->creer)
// Ref customer
$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);
// Thirdparty
$morehtmlref.='<br>'.$langs->trans('ThirdParty') . ' : ' . $soc->getNomUrl(1);
// Thirdparty
$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>)';
// Project
if (! empty($conf->projet->enabled))
{
$langs->load("projects");
$morehtmlref.='<br>'.$langs->trans('Project') . ' ';
if ($user->rights->commande->creer)
{
if ($action != 'classify')
$morehtmlref.='<a href="' . $_SERVER['PHP_SELF'] . '?action=classify&amp;id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : ';
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 method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">';
$morehtmlref.='<input type="hidden" name="action" value="classin">';
$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.='<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">';
$morehtmlref.='</form>';
} else {
$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1);
}
} else {
if (! empty($object->fk_project)) {
$proj = new Project($db);
$proj->fetch($object->fk_project);
$morehtmlref.='<a href="'.DOL_URL_ROOT.'/projet/card.php?id=' . $object->fk_project . '" title="' . $langs->trans('ShowProject') . '">';
$morehtmlref.=$proj->ref;
$morehtmlref.='</a>';
} else {
$morehtmlref.='';
}
}
}
$morehtmlref.='</div>';
// Project
if (! empty($conf->projet->enabled))
{
$langs->load("projects");
$morehtmlref.='<br>'.$langs->trans('Project') . ' ';
if ($user->rights->commande->creer)
{
if ($action != 'classify')
$morehtmlref.='<a href="' . $_SERVER['PHP_SELF'] . '?action=classify&amp;id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : ';
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 method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">';
$morehtmlref.='<input type="hidden" name="action" value="classin">';
$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.='<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">';
$morehtmlref.='</form>';
} else {
$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1);
}
} else {
if (! empty($object->fk_project)) {
$proj = new Project($db);
$proj->fetch($object->fk_project);
$morehtmlref.='<a href="'.DOL_URL_ROOT.'/projet/card.php?id=' . $object->fk_project . '" title="' . $langs->trans('ShowProject') . '">';
$morehtmlref.=$proj->ref;
$morehtmlref.='</a>';
} else {
$morehtmlref.='';
}
}
}
$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="fichehalfleft">';
print '<div class="underbanner clearboth"></div>';
print '<div class="fichecenter">';
print '<div class="fichehalfleft">';
print '<div class="underbanner clearboth"></div>';
print '<table class="border" width="100%">';
print '<table class="border" width="100%">';
if ($soc->outstanding_limit)
{
// Outstanding Bill
print '<tr><td class="titlefield">';
print $langs->trans('OutstandingBill');
print '</td><td>';
print price($soc->get_OutstandingBill()) . ' / ';
print price($soc->outstanding_limit, 0, '', 1, - 1, - 1, $conf->currency);
print '</td>';
print '</tr>';
// Outstanding Bill
print '<tr><td class="titlefield">';
print $langs->trans('OutstandingBill');
print '</td><td>';
print price($soc->get_OutstandingBill()) . ' / ';
print price($soc->outstanding_limit, 0, '', 1, - 1, - 1, $conf->currency);
print '</td>';
print '</tr>';
}
// Relative and absolute discounts
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
// 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
} else {
$filterabsolutediscount = "fk_facture_source IS NULL OR (fk_facture_source IS NOT NULL AND description LIKE '(DEPOSIT)%')";
@ -2037,7 +2039,7 @@ if ($action == 'create' && $user->rights->commande->creer)
} else {
print $object->date ? dol_print_date($object->date, 'day') : '&nbsp;';
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>';
@ -2062,51 +2064,51 @@ if ($action == 'create' && $user->rights->commande->creer)
} else {
print $object->date_livraison ? dol_print_date($object->date_livraison, 'daytext') : '&nbsp;';
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 '</tr>';
// Shipping Method
if (! empty($conf->expedition->enabled)) {
print '<tr><td height="10">';
print '<table width="100%" class="nobordernopadding"><tr><td>';
print $langs->trans('SendingMethod');
print '</td>';
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 '</tr></table>';
print '</td><td>';
if ($action == 'editshippingmethod') {
$form->formSelectShippingMethod($_SERVER['PHP_SELF'].'?id='.$object->id, $object->shipping_method_id, 'shipping_method_id', 1);
} else {
$form->formSelectShippingMethod($_SERVER['PHP_SELF'].'?id='.$object->id, $object->shipping_method_id, 'none');
}
print '</td>';
print '</tr>';
}
// Shipping Method
if (! empty($conf->expedition->enabled)) {
print '<tr><td height="10">';
print '<table width="100%" class="nobordernopadding"><tr><td>';
print $langs->trans('SendingMethod');
print '</td>';
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 '</tr></table>';
print '</td><td>';
if ($action == 'editshippingmethod') {
$form->formSelectShippingMethod($_SERVER['PHP_SELF'].'?id='.$object->id, $object->shipping_method_id, 'shipping_method_id', 1);
} else {
$form->formSelectShippingMethod($_SERVER['PHP_SELF'].'?id='.$object->id, $object->shipping_method_id, 'none');
}
print '</td>';
print '</tr>';
}
// Warehouse
if (! empty($conf->expedition->enabled) && ! empty($conf->global->WAREHOUSE_ASK_WAREHOUSE_DURING_ORDER)) {
require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php';
$formproduct=new FormProduct($db);
print '<tr><td>';
print '<table width="100%" class="nobordernopadding"><tr><td>';
print $langs->trans('Warehouse');
print '</td>';
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 '</tr></table>';
print '</td><td>';
if ($action == 'editwarehouse') {
$formproduct->formSelectWarehouses($_SERVER['PHP_SELF'].'?id='.$object->id, $object->warehouse_id, 'warehouse_id', 1);
} else {
$formproduct->formSelectWarehouses($_SERVER['PHP_SELF'].'?id='.$object->id, $object->warehouse_id, 'none');
}
print '</td>';
print '</tr>';
}
// Warehouse
if (! empty($conf->expedition->enabled) && ! empty($conf->global->WAREHOUSE_ASK_WAREHOUSE_DURING_ORDER)) {
require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php';
$formproduct=new FormProduct($db);
print '<tr><td>';
print '<table width="100%" class="nobordernopadding"><tr><td>';
print $langs->trans('Warehouse');
print '</td>';
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 '</tr></table>';
print '</td><td>';
if ($action == 'editwarehouse') {
$formproduct->formSelectWarehouses($_SERVER['PHP_SELF'].'?id='.$object->id, $object->warehouse_id, 'warehouse_id', 1);
} else {
$formproduct->formSelectWarehouses($_SERVER['PHP_SELF'].'?id='.$object->id, $object->warehouse_id, 'none');
}
print '</td>';
print '</tr>';
}
// Terms of payment
print '<tr><td>';
@ -2173,9 +2175,9 @@ if ($action == 'create' && $user->rights->commande->creer)
print '</tr></table>';
print '</td><td>';
if ($action == 'editmulticurrencyrate' || $action == 'actualizemulticurrencyrate') {
if($action == 'actualizemulticurrencyrate') {
list($object->fk_multicurrency, $object->multicurrency_tx) = MultiCurrency::getIdAndTxFromCode($object->db, $object->multicurrency_code);
}
if($action == 'actualizemulticurrencyrate') {
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);
} else {
$form->form_multicurrency_rate($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_tx, 'none', $object->multicurrency_code);
@ -2243,30 +2245,30 @@ if ($action == 'create' && $user->rights->commande->creer)
$totalVolume=$tmparray['volume'];
if ($totalWeight || $totalVolume)
{
print '<tr><td>'.$langs->trans("CalculatedWeight").'</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 '</td></tr>';
print '<tr><td>'.$langs->trans("CalculatedVolume").'</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 '</td></tr>';
print '<tr><td>'.$langs->trans("CalculatedWeight").'</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 '</td></tr>';
print '<tr><td>'.$langs->trans("CalculatedVolume").'</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 '</td></tr>';
}
// TODO How record was recorded OrderMode (llx_c_input_method)
// TODO How record was recorded OrderMode (llx_c_input_method)
// Incoterms
if (!empty($conf->incoterm->enabled))
{
print '<tr><td>';
print '<table width="100%" class="nobordernopadding"><tr><td>';
print $langs->trans('IncotermLabel');
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>';
else print '&nbsp;';
print '</td></tr></table>';
print '</td>';
print '<td>';
print '<table width="100%" class="nobordernopadding"><tr><td>';
print $langs->trans('IncotermLabel');
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>';
else print '&nbsp;';
print '</td></tr></table>';
print '</td>';
print '<td>';
if ($action != 'editincoterm')
{
print $form->textwithpicto($object->display_incoterms(), $object->libelle_incoterms, 1);
@ -2275,27 +2277,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 '</td></tr>';
print '</td></tr>';
}
// Bank Account
// Bank Account
if (! empty($conf->global->BANK_ASK_PAYMENT_BANK_DURING_ORDER) && ! empty($conf->banque->enabled))
{
print '<tr><td class="nowrap">';
print '<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
print $langs->trans('BankAccount');
print '<td>';
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 '</tr></table>';
print '</td><td>';
if ($action == 'editbankaccount') {
$form->formSelectAccount($_SERVER['PHP_SELF'].'?id='.$object->id, $object->fk_account, 'fk_account', 1);
} else {
$form->formSelectAccount($_SERVER['PHP_SELF'].'?id='.$object->id, $object->fk_account, 'none');
}
print '</td>';
print '</tr>';
print '<tr><td class="nowrap">';
print '<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
print $langs->trans('BankAccount');
print '<td>';
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 '</tr></table>';
print '</td><td>';
if ($action == 'editbankaccount') {
$form->formSelectAccount($_SERVER['PHP_SELF'].'?id='.$object->id, $object->fk_account, 'fk_account', 1);
} else {
$form->formSelectAccount($_SERVER['PHP_SELF'].'?id='.$object->id, $object->fk_account, 'none');
}
print '</td>';
print '</tr>';
}
// Other attributes
@ -2312,20 +2314,20 @@ if ($action == 'create' && $user->rights->commande->creer)
if (!empty($conf->multicurrency->enabled) && ($object->multicurrency_code != $conf->currency))
{
// Multicurrency Amount HT
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 '</tr>';
// Multicurrency Amount HT
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 '</tr>';
// Multicurrency Amount VAT
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 '</tr>';
// Multicurrency Amount VAT
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 '</tr>';
// Multicurrency Amount TTC
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 '</tr>';
// Multicurrency Amount TTC
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 '</tr>';
}
// Total HT
@ -2357,7 +2359,7 @@ if ($action == 'create' && $user->rights->commande->creer)
// Margin Infos
if (! empty($conf->margin->enabled)) {
$formmargin->displayMarginInfos($object);
$formmargin->displayMarginInfos($object);
}
@ -2395,7 +2397,7 @@ if ($action == 'create' && $user->rights->commande->creer)
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%">';
// Show object lines
@ -2421,7 +2423,7 @@ if ($action == 'create' && $user->rights->commande->creer)
}
}
print '</table>';
print '</div>';
print '</div>';
print "</form>\n";
@ -2435,7 +2437,7 @@ if ($action == 'create' && $user->rights->commande->creer)
$parameters = array();
$reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been
// modified by hook
// modified by hook
if (empty($reshook)) {
// Send
if ($object->statut > Commande::STATUS_DRAFT) {
@ -2445,10 +2447,10 @@ if ($action == 'create' && $user->rights->commande->creer)
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 &&
((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->creer))
|| (! 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>';
@ -2459,8 +2461,8 @@ if ($action == 'create' && $user->rights->commande->creer)
}
// Create event
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
// page.
// "workflow" action so should appears somewhere else on
// 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>';
}
@ -2480,11 +2482,11 @@ if ($action == 'create' && $user->rights->commande->creer)
// Create contract
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) {
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>';
}
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>';
}
}
// Ship
@ -2527,9 +2529,9 @@ if ($action == 'create' && $user->rights->commande->creer)
}
}
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)) {
print '<div class="inline-block divButAction"><a class="butAction" href="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '&amp;action=classifyunbilled">' . $langs->trans("ClassifyUnBilled") . '</a></div>';
}
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>';
}
}
// Clone
if ($user->rights->commande->creer) {
@ -2538,8 +2540,8 @@ if ($action == 'create' && $user->rights->commande->creer)
// Cancel order
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->order_advance->annuler)))
((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)))
)
{
print '<div class="inline-block divButAction"><a class="butActionDelete" href="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '&amp;action=cancel">' . $langs->trans('Cancel') . '</a></div>';

View File

@ -316,7 +316,7 @@ class CommandeApi extends DolibarrApi
);
if ($updateRes > 0) {
return $this->get($id)->line->rowid;
return $updateRes;
}
return false;

View File

@ -286,7 +286,7 @@ class Orders extends DolibarrApi
);
if ($updateRes > 0) {
return $this->get($id)->line->rowid;
return $updateRes;
}
return false;

View File

@ -1240,7 +1240,7 @@ class Commande extends CommonOrder
{
global $mysoc, $conf, $langs, $user;
dol_syslog(get_class($this)."::addline commandeid=$this->id, desc=$desc, pu_ht=$pu_ht, qty=$qty, txtva=$txtva, fk_product=$fk_product, remise_percent=$remise_percent, info_bits=$info_bits, fk_remise_except=$fk_remise_except, price_base_type=$price_base_type, pu_ttc=$pu_ttc, date_start=$date_start, date_end=$date_end, type=$type special_code=$special_code, fk_unit=$fk_unit", LOG_DEBUG);
dol_syslog(get_class($this)."::addline commandeid=$this->id, desc=$desc, pu_ht=$pu_ht, qty=$qty, txtva=$txtva, fk_product=$fk_product, remise_percent=$remise_percent, info_bits=$info_bits, fk_remise_except=$fk_remise_except, price_base_type=$price_base_type, pu_ttc=$pu_ttc, date_start=$date_start, date_end=$date_end, type=$type special_code=$special_code, fk_unit=$fk_unit, origin=$origin, origin_id=$origin_id, pu_ht_devise=$pu_ht_devise", LOG_DEBUG);
include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php';

View File

@ -1114,7 +1114,7 @@ if ($resql)
$bankstatic->id=$banklinestatic->fk_account;
$bankstatic->label=$banklinestatic->bank_account_ref;
print ' ('.$langs->trans("TransferFrom").' ';
print $bankstatic->getNomUrl(1);
print $bankstatic->getNomUrl(1,'transactions');
print ' '.$langs->trans("toward").' ';
$bankstatic->id=$objp->bankid;
$bankstatic->label=$objp->bankref;
@ -1131,7 +1131,7 @@ if ($resql)
$banklinestatic->fetch($links[$key]['url_id']);
$bankstatic->id=$banklinestatic->fk_account;
$bankstatic->label=$banklinestatic->bank_account_ref;
print $bankstatic->getNomUrl(1);
print $bankstatic->getNomUrl(1,'transactions');
print ')';
}
//var_dump($links);

File diff suppressed because it is too large Load Diff

View File

@ -421,7 +421,7 @@ class Invoices extends DolibarrApi
);
if ($updateRes > 0) {
return $this->get($id)->line->rowid;
return $updateRes;
}
throw new RestException(400, 'Unable to insert the new line. Check your inputs.');

View File

@ -39,7 +39,7 @@ class FactureStats extends Stats
var $from;
var $field;
var $where;
/**
* Constructor
@ -56,8 +56,8 @@ class FactureStats extends Stats
$this->db = $db;
$this->socid = ($socid > 0 ? $socid : 0);
$this->userid = $userid;
$this->cachefilesuffix = $mode;
$this->cachefilesuffix = $mode;
if ($mode == 'customer')
{
$object=new Facture($this->db);
@ -195,7 +195,7 @@ class FactureStats extends Stats
return $this->_getAllByYear($sql);
}
/**
* Return nb, amount of predefined product for year
*
@ -218,7 +218,7 @@ class FactureStats extends Stats
return $this->_getAllByProduct($sql);
}
}

File diff suppressed because it is too large Load Diff

View File

@ -84,7 +84,7 @@ dol_mkdir($dir);
$stats = new FactureStats($db, $socid, $mode, ($userid>0?$userid:0));
if ($mode == 'customer')
{
if ($object_status != '' && $object_status >= -1) $stats->where .= ' AND f.fk_statut IN ('.$db->escape($object_status).')';
if ($object_status != '' && $object_status >= 0) $stats->where .= ' AND f.fk_statut IN ('.$db->escape($object_status).')';
}
if ($mode == 'supplier')
{
@ -227,12 +227,13 @@ complete_head_from_modules($conf,$langs,null,$head,$h,$type);
dol_fiche_head($head, 'byyear', $langs->trans("Statistics"), -1);
$tmp_companies = $form->select_thirdparty_list($socid,'socid',$filter,1, 0, 0, array(), '', 1);
// We use select_thirdparty_list instead of select_company so we can use $filter and share same code for customer and supplier.
$tmp_companies = $form->select_thirdparty_list($socid, 'socid', $filter, 1, 0, 0, array(), '', 1);
//Array passed as an argument to Form::selectarray to build a proper select input
$companies = array();
foreach ($tmp_companies as $value) {
$companies[$value['value']] = $value['label'];
$companies[$value['key']] = $value['label'];
}
print '<div class="fichecenter"><div class="fichethirdleft">';

View File

@ -169,6 +169,20 @@ if ($action == 'create')
$charge->paiementtype=$charge->mode_reglement_id?$charge->mode_reglement_id:$charge->paiementtype;
$total = $charge->amount;
if (! empty($conf->use_javascript_ajax))
{
print "\n".'<script type="text/javascript" language="javascript">';
//Add js for AutoFill
print ' $(document).ready(function () {';
print ' $(".AutoFillAmount").on(\'click touchstart\', function(){
var amount = $(this).data("value");
document.getElementById($(this).data(\'rowid\')).value = amount ;
});';
print ' });'."\n";
print ' </script>'."\n";
}
print load_fiche_titre($langs->trans("DoPayment"));
print "<br>\n";
@ -188,14 +202,12 @@ if ($action == 'create')
print '<table class="border" width="100%">';
print "<tr class=\"liste_titre\"><td colspan=\"2\">".$langs->trans("SocialContribution")."</td></tr>";
print '<tr><td>'.$langs->trans("Ref").'</td><td><a href="'.DOL_URL_ROOT.'/compta/sociales/card.php?id='.$chid.'">'.$chid.'</a></td></tr>';
print '<tr><td class="titlefieldcreate">'.$langs->trans("Ref").'</td><td><a href="'.DOL_URL_ROOT.'/compta/sociales/card.php?id='.$chid.'">'.$chid.'</a></td></tr>';
print '<tr><td>'.$langs->trans("Type")."</td><td>".$charge->type_libelle."</td></tr>\n";
print '<tr><td>'.$langs->trans("Period")."</td><td>".dol_print_date($charge->periode,'day')."</td></tr>\n";
print '<tr><td>'.$langs->trans("Label").'</td><td>'.$charge->lib."</td></tr>\n";
print '<tr><td>'.$langs->trans("DateDue")."</td><td>".dol_print_date($charge->date_ech,'day')."</td></tr>\n";
print '<tr><td>'.$langs->trans("Amount")."</td><td>".price($charge->amount,0,$outputlangs,1,-1,-1,$conf->currency).'</td></tr>';
/*print '<tr><td>'.$langs->trans("DateDue")."</td><td>".dol_print_date($charge->date_ech,'day')."</td></tr>\n";
print '<tr><td>'.$langs->trans("Amount")."</td><td>".price($charge->amount,0,$outputlangs,1,-1,-1,$conf->currency).'</td></tr>';*/
$sql = "SELECT sum(p.amount) as total";
$sql.= " FROM ".MAIN_DB_PREFIX."paiementcharge as p";
@ -207,12 +219,8 @@ if ($action == 'create')
$sumpaid = $obj->total;
$db->free();
}
print '<tr><td>'.$langs->trans("AlreadyPaid").'</td><td>'.price($sumpaid,0,$outputlangs,1,-1,-1,$conf->currency).'</td></tr>';
print '<tr><td class="tdtop">'.$langs->trans("RemainderToPay").'</td><td>'.price($total-$sumpaid,0,$outputlangs,1,-1,-1,$conf->currency).'</td></tr>';
print '<tr class="liste_titre">';
print "<td colspan=\"2\">".$langs->trans("Payment").'</td>';
print '</tr>';
/*print '<tr><td>'.$langs->trans("AlreadyPaid").'</td><td>'.price($sumpaid,0,$outputlangs,1,-1,-1,$conf->currency).'</td></tr>';
print '<tr><td class="tdtop">'.$langs->trans("RemainderToPay").'</td><td>'.price($total-$sumpaid,0,$outputlangs,1,-1,-1,$conf->currency).'</td></tr>';*/
print '<tr><td class="fieldrequired">'.$langs->trans("Date").'</td><td>';
$datepaye = dol_mktime(12, 0, 0, $_POST["remonth"], $_POST["reday"], $_POST["reyear"]);
@ -294,7 +302,12 @@ if ($action == 'create')
if ($sumpaid < $objp->amount)
{
$namef = "amount_".$objp->id;
print '<input type="text" size="8" name="'.$namef.'">';
$nameRemain = "remain_".$objp->id;
if (!empty($conf->use_javascript_ajax))
print img_picto("Auto fill",'rightarrow', "class='AutoFillAmount' data-rowid='".$namef."' data-value='".($objp->amount - $sumpaid)."'");
$remaintopay=$objp->amount - $sumpaid;
print '<input type=hidden class="sum_remain" name="'.$nameRemain.'" value="'.$remaintopay.'">';
print '<input type="text" size="8" name="'.$namef.'" id="'.$namef.'">';
}
else
{

View File

@ -654,7 +654,9 @@ if ($id > 0)
else
{
print '<tr class="oddeven"><td colspan="'.$nbcols.'" class="opacitymedium">'.$langs->trans("None").'</td><td></td><td></td><td></td></tr>';
print '<tr class="oddeven"><td class="opacitymedium">'.$langs->trans("None").'</td>';
print '<td></td><td></td><td></td><td></td>';
print '</tr>';
}
print '<tr><td colspan="'.$nbcols.'" align="right">'.$langs->trans("AlreadyPaid")." :</td><td align=\"right\">".price($totalpaye)."</td></tr>\n";

View File

@ -88,6 +88,7 @@ if ($action == 'setlib' && $user->rights->tax->charges->creer)
setEventMessages($object->error, $object->errors, 'errors');
}
/*
* View
*/
@ -125,7 +126,7 @@ if ($object->id)
} else {
$morehtmlref.='';
}
}
}
$morehtmlref.='</div>';
$linkback = '<a href="' . DOL_URL_ROOT . '/compta/sociales/index.php?restore_lastsearch_values=1">' . $langs->trans("BackToList") . '</a>';
@ -153,9 +154,9 @@ if ($object->id)
print '</table>';
print '</div>';
print '<div class="clearboth"></div>';
dol_fiche_end();
$modulepart = 'tax';

View File

@ -42,6 +42,8 @@ $socid = GETPOST('socid','int');
if ($user->societe_id) $socid=$user->societe_id;
$result = restrictedArea($user, 'tax', $id, 'chargesociales','charges');
$object = new ChargeSociales($db);
/*
* Actions
@ -68,7 +70,6 @@ $title = $langs->trans("SocialContribution") . ' - ' . $langs->trans("Info");
$help_url = 'EN:Module_Taxes_and_social_contributions|FR:Module Taxes et dividendes|ES:M&oacute;dulo Impuestos y cargas sociales (IVA, impuestos)';
llxHeader("",$title,$help_url);
$object = new ChargeSociales($db);
$object->fetch($id);
$object->info($id);

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,532 @@
<?php
/* Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr>
* Copyright (C) 2016 Laurent Destailleur <eldy@users.sourceforge.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
use Luracast\Restler\RestException;
require_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php';
/**
* API class for contracts
*
* @access protected
* @class DolibarrApiAccess {@requires user,external}
*/
class Contracts extends DolibarrApi
{
/**
* @var array $FIELDS Mandatory fields, checked when create and update object
*/
static $FIELDS = array(
'socid',
'date_contrat',
'commercial_signature_id',
'commercial_suivi_id'
);
/**
* @var Contract $contract {@type Contrat}
*/
public $contract;
/**
* Constructor
*/
function __construct()
{
global $db, $conf;
$this->db = $db;
$this->contract = new Contrat($this->db);
}
/**
* Get properties of a contrat object
*
* Return an array with contrat informations
*
* @param int $id ID of contract
* @return array|mixed data without useless information
*
* @throws RestException
*/
function get($id)
{
if(! DolibarrApiAccess::$user->rights->contrat->lire) {
throw new RestException(401);
}
$result = $this->contract->fetch($id);
if( ! $result ) {
throw new RestException(404, 'Contract not found');
}
if( ! DolibarrApi::_checkAccessToResource('contrat',$this->contract->id)) {
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
}
$this->contract->fetchObjectLinked();
return $this->_cleanObjectDatas($this->contract);
}
/**
* List contracts
*
* Get a list of contracts
*
* @param string $sortfield Sort field
* @param string $sortorder Sort order
* @param int $limit Limit for list
* @param int $page Page number
* @param string $thirdparty_ids Thirdparty ids to filter contracts of. {@example '1' or '1,2,3'} {@pattern /^[0-9,]*$/i}
* @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.ref:like:'SO-%') and (t.date_creation:<:'20160101')"
* @return array Array of contract objects
*
* @throws RestException
*/
function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $thirdparty_ids = '', $sqlfilters = '') {
global $db, $conf;
$obj_ret = array();
// case of external user, $thirdparty_ids param is ignored and replaced by user's socid
$socids = DolibarrApiAccess::$user->societe_id ? DolibarrApiAccess::$user->societe_id : $thirdparty_ids;
// If the internal user must only see his customers, force searching by him
$search_sale = 0;
if (! DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) $search_sale = DolibarrApiAccess::$user->id;
$sql = "SELECT t.rowid";
if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) $sql .= ", sc.fk_soc, sc.fk_user"; // We need these fields in order to filter by sale (including the case where the user can only see his prospects)
$sql.= " FROM ".MAIN_DB_PREFIX."contrat as t";
if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; // We need this table joined to the select in order to filter by sale
$sql.= ' WHERE t.entity IN ('.getEntity('contrat').')';
if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) $sql.= " AND t.fk_soc = sc.fk_soc";
if ($socids) $sql.= " AND t.fk_soc IN (".$socids.")";
if ($search_sale > 0) $sql.= " AND t.rowid = sc.fk_soc"; // Join for the needed table to filter by sale
// Insert sale filter
if ($search_sale > 0)
{
$sql .= " AND sc.fk_user = ".$search_sale;
}
// Add sql filters
if ($sqlfilters)
{
if (! DolibarrApi::_checkFilters($sqlfilters))
{
throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters);
}
$regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
$sql.=" AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")";
}
$sql.= $db->order($sortfield, $sortorder);
if ($limit) {
if ($page < 0)
{
$page = 0;
}
$offset = $limit * $page;
$sql.= $db->plimit($limit + 1, $offset);
}
dol_syslog("API Rest request");
$result = $db->query($sql);
if ($result)
{
$num = $db->num_rows($result);
$min = min($num, ($limit <= 0 ? $num : $limit));
while ($i < $min)
{
$obj = $db->fetch_object($result);
$contrat_static = new Contrat($db);
if($contrat_static->fetch($obj->rowid)) {
$obj_ret[] = $this->_cleanObjectDatas($contrat_static);
}
$i++;
}
}
else {
throw new RestException(503, 'Error when retrieve contrat list : '.$db->lasterror());
}
if( ! count($obj_ret)) {
throw new RestException(404, 'No contract found');
}
return $obj_ret;
}
/**
* Create contract object
*
* @param array $request_data Request data
* @return int ID of contrat
*/
function post($request_data = NULL)
{
if(! DolibarrApiAccess::$user->rights->contrat->creer) {
throw new RestException(401, "Insuffisant rights");
}
// Check mandatory fields
$result = $this->_validate($request_data);
foreach($request_data as $field => $value) {
$this->contract->$field = $value;
}
/*if (isset($request_data["lines"])) {
$lines = array();
foreach ($request_data["lines"] as $line) {
array_push($lines, (object) $line);
}
$this->contract->lines = $lines;
}*/
if ($this->contract->create(DolibarrApiAccess::$user) < 0) {
throw new RestException(500, "Error creating contract", array_merge(array($this->contract->error), $this->contract->errors));
}
return $this->contract->id;
}
/**
* Get lines of an contract
*
* @param int $id Id of contract
*
* @url GET {id}/lines
*
* @return int
*/
function getLines($id) {
if(! DolibarrApiAccess::$user->rights->contrat->lire) {
throw new RestException(401);
}
$result = $this->contract->fetch($id);
if( ! $result ) {
throw new RestException(404, 'Contract not found');
}
if( ! DolibarrApi::_checkAccessToResource('contrat',$this->contract->id)) {
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
}
$this->contract->getLinesArray();
$result = array();
foreach ($this->contract->lines as $line) {
array_push($result,$this->_cleanObjectDatas($line));
}
return $result;
}
/**
* Add a line to given contract
*
* @param int $id Id of contrat to update
* @param array $request_data Contractline data
*
* @url POST {id}/lines
*
* @return int
*/
function postLine($id, $request_data = NULL) {
if(! DolibarrApiAccess::$user->rights->contrat->creer) {
throw new RestException(401);
}
$result = $this->contract->fetch($id);
if( ! $result ) {
throw new RestException(404, 'Contract not found');
}
if( ! DolibarrApi::_checkAccessToResource('contrat',$this->contract->id)) {
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
}
$request_data = (object) $request_data;
$updateRes = $this->contract->addline(
$request_data->desc,
$request_data->subprice,
$request_data->qty,
$request_data->tva_tx,
$request_data->localtax1_tx,
$request_data->localtax2_tx,
$request_data->fk_product,
$request_data->remise_percent,
$request_data->date_start, // date ouverture = date_start_real
$request_data->date_end, // date_cloture = date_end_real
$request_data->HT,
$request_data->subprice_excl_tax,
$request_data->info_bits,
$request_data->fk_fournprice,
$request_data->pa_ht,
$request_data->array_options,
$request_data->fk_unit,
$request_data->rang
);
if ($updateRes > 0) {
return $updateRes;
}
return false;
}
/**
* Update a line to given contract
*
* @param int $id Id of contrat to update
* @param int $lineid Id of line to update
* @param array $request_data Contractline data
*
* @url PUT {id}/lines/{lineid}
*
* @return object
*/
function putLine($id, $lineid, $request_data = NULL) {
if(! DolibarrApiAccess::$user->rights->contrat->creer) {
throw new RestException(401);
}
$result = $this->contract->fetch($id);
if( ! $result ) {
throw new RestException(404, 'Contrat not found');
}
if( ! DolibarrApi::_checkAccessToResource('contrat',$this->contract->id)) {
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
}
$request_data = (object) $request_data;
$updateRes = $this->contract->updateline(
$lineid,
$request_data->desc,
$request_data->subprice,
$request_data->qty,
$request_data->remise_percent,
$request_data->date_ouveture_prevue,
$request_data->date_fin_validite,
$request_data->tva_tx,
$request_data->localtax1_tx,
$request_data->localtax2_tx,
$request_data->date_ouverture,
$request_data->date_cloture,
'HT',
$request_data->info_bits,
$request_data->fk_fourn_price,
$request_data->pa_ht,
$request_data->array_options,
$request_data->fk_unit
);
if ($updateRes > 0) {
$result = $this->get($id);
unset($result->line);
return $this->_cleanObjectDatas($result);
}
return false;
}
/**
* Delete a line to given contract
*
*
* @param int $id Id of contract to update
* @param int $lineid Id of line to delete
*
* @url DELETE {id}/lines/{lineid}
*
* @return int
* @throws 401
* @throws 404
*/
function deleteLine($id, $lineid) {
if(! DolibarrApiAccess::$user->rights->contrat->creer) {
throw new RestException(401);
}
$result = $this->contract->fetch($id);
if( ! $result ) {
throw new RestException(404, 'Contrat not found');
}
if( ! DolibarrApi::_checkAccessToResource('contrat',$this->contract->id)) {
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
}
$request_data = (object) $request_data;
$updateRes = $this->contract->deleteline($lineid, DolibarrApiAccess::$user);
if ($updateRes > 0) {
return $this->get($id);
}
return false;
}
/**
* Update contract general fields (won't touch lines of contract)
*
* @param int $id Id of contrat to update
* @param array $request_data Datas
*
* @return int
*/
function put($id, $request_data = NULL) {
if(! DolibarrApiAccess::$user->rights->contrat->creer) {
throw new RestException(401);
}
$result = $this->contract->fetch($id);
if( ! $result ) {
throw new RestException(404, 'Contrat not found');
}
if( ! DolibarrApi::_checkAccessToResource('contrat',$this->contract->id)) {
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
}
foreach($request_data as $field => $value) {
if ($field == 'id') continue;
$this->contract->$field = $value;
}
if($this->contract->update(DolibarrApiAccess::$user, 0))
return $this->get($id);
return false;
}
/**
* Delete contract
*
* @param int $id Contract ID
*
* @return array
*/
function delete($id)
{
if(! DolibarrApiAccess::$user->rights->contrat->supprimer) {
throw new RestException(401);
}
$result = $this->contract->fetch($id);
if( ! $result ) {
throw new RestException(404, 'Contract not found');
}
if( ! DolibarrApi::_checkAccessToResource('contrat',$this->contract->id)) {
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
}
if( ! $this->contract->delete(DolibarrApiAccess::$user)) {
throw new RestException(500, 'Error when delete contract : '.$this->contract->error);
}
return array(
'success' => array(
'code' => 200,
'message' => 'Contract deleted'
)
);
}
/**
* Validate an contract
*
* @param int $id Contract ID
* @param int $idwarehouse Warehouse ID
* @param int $notrigger 1=Does not execute triggers, 0= execute triggers
*
* @url POST {id}/validate
*
* @return array
* FIXME An error 403 is returned if the request has an empty body.
* Error message: "Forbidden: Content type `text/plain` is not supported."
* Workaround: send this in the body
* {
* "idwarehouse": 0,
* "notrigger": 0
* }
*/
/*
function validate($id, $idwarehouse=0, $notrigger=0)
{
if(! DolibarrApiAccess::$user->rights->contrat->creer) {
throw new RestException(401);
}
$result = $this->contract->fetch($id);
if( ! $result ) {
throw new RestException(404, 'Contract not found');
}
if( ! DolibarrApi::_checkAccessToResource('contrat',$this->contract->id)) {
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
}
$result = $this->contract->valid(DolibarrApiAccess::$user, $idwarehouse, $notrigger);
if ($result == 0) {
throw new RestException(500, 'Error nothing done. May be object is already validated');
}
if ($result < 0) {
throw new RestException(500, 'Error when validating Contract: '.$this->contract->error);
}
return array(
'success' => array(
'code' => 200,
'message' => 'Contract validated (Ref='.$this->contract->ref.')'
)
);
}
*/
/**
* Clean sensible object datas
*
* @param object $object Object to clean
* @return array Array of cleaned object properties
*/
function _cleanObjectDatas($object) {
$object = parent::_cleanObjectDatas($object);
unset($object->address);
return $object;
}
/**
* Validate fields before create or update object
*
* @param array $data Array with data to verify
* @return array
* @throws RestException
*/
function _validate($data)
{
$contrat = array();
foreach (Contracts::$FIELDS as $field) {
if (!isset($data[$field]))
throw new RestException(400, "$field field missing");
$contrat[$field] = $data[$field];
}
return $contrat;
}
}

View File

@ -1400,13 +1400,14 @@ class Contrat extends CommonObject
* @param int $pa_ht Buying price HT
* @param array $array_options extrafields array
* @param string $fk_unit Code of the unit to use. Null to use the default one
* @return int <0 si erreur, >0 si ok
* @param string $rang Position
* @return int <0 if KO, >0 if OK
*/
function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1, $txlocaltax2, $fk_product, $remise_percent, $date_start, $date_end, $price_base_type='HT', $pu_ttc=0.0, $info_bits=0, $fk_fournprice=null, $pa_ht = 0,$array_options=0, $fk_unit = null)
function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1, $txlocaltax2, $fk_product, $remise_percent, $date_start, $date_end, $price_base_type='HT', $pu_ttc=0.0, $info_bits=0, $fk_fournprice=null, $pa_ht = 0,$array_options=0, $fk_unit = null, $rang=0)
{
global $user, $langs, $conf, $mysoc;
dol_syslog(get_class($this)."::addline $desc, $pu_ht, $qty, $txtva, $txlocaltax1, $txlocaltax2, $fk_product, $remise_percent, $date_start, $date_end, $price_base_type, $pu_ttc, $info_bits");
dol_syslog(get_class($this)."::addline $desc, $pu_ht, $qty, $txtva, $txlocaltax1, $txlocaltax2, $fk_product, $remise_percent, $date_start, $date_end, $price_base_type, $pu_ttc, $info_bits, $rang");
if ($this->statut >= 0)
{
@ -1616,7 +1617,7 @@ class Contrat extends CommonObject
{
global $user, $conf, $langs, $mysoc;
// Nettoyage parametres
// Clean parameters
$qty=trim($qty);
$desc=trim($desc);
$desc=trim($desc);
@ -1625,6 +1626,7 @@ class Contrat extends CommonObject
$localtax1tx = price2num($localtax1tx);
$localtax2tx = price2num($localtax2tx);
$pa_ht=price2num($pa_ht);
if (empty($fk_fournprice)) $fk_fournprice=0;
$subprice = $price;
$remise = 0;
@ -1701,7 +1703,7 @@ class Contrat extends CommonObject
$sql.= ", total_localtax1='".price2num($total_localtax1)."'";
$sql.= ", total_localtax2='".price2num($total_localtax2)."'";
$sql.= ", total_ttc='". price2num($total_ttc)."'";
$sql.= ", fk_product_fournisseur_price='".$fk_fournprice."'";
$sql.= ", fk_product_fournisseur_price=".($fk_fournprice > 0 ? $fk_fournprice : "null");
$sql.= ", buy_price_ht='".price2num($pa_ht)."'";
if ($date_start > 0) { $sql.= ",date_ouverture_prevue='".$this->db->idate($date_start)."'"; }
else { $sql.=",date_ouverture_prevue=null"; }
@ -1772,7 +1774,7 @@ class Contrat extends CommonObject
* @param User $user User that delete
* @return int >0 if OK, <0 if KO
*/
function deleteline($idline,$user)
function deleteline($idline, User $user)
{
global $conf, $langs;
@ -2343,7 +2345,17 @@ class Contrat extends CommonObject
}
}
/**
/**
* Create an array of order lines
*
* @return int >0 if OK, <0 if KO
*/
function getLinesArray()
{
return $this->fetch_lines();
}
/**
* Create a document onto disk according to template module.
*
* @param string $modele Force model to use ('' to not force)
@ -3033,7 +3045,7 @@ class ContratLigne extends CommonObjectLine
$sql.= " info_bits,";
$sql.= " price_ht, remise, fk_product_fournisseur_price, buy_price_ht";
if ($this->date_ouverture_prevue > 0) { $sql.= ",date_ouverture_prevue"; }
if ($this->date_fin_validite > 0) { $sql.= ",date_fin_validite"; }
if ($this->date_fin_validite > 0) { $sql.= ",date_fin_validite"; }
$sql.= ") VALUES ($this->fk_contrat, '', '" . $this->db->escape($this->description) . "',";
$sql.= ($this->fk_product>0 ? $this->fk_product : "null").",";
$sql.= " '".$this->db->escape($this->qty)."',";
@ -3051,8 +3063,8 @@ class ContratLigne extends CommonObjectLine
else $sql.= ' null,';
if ($this->pa_ht > 0) $sql.= ' '.price2num($this->pa_ht);
else $sql.= ' null';
if ($this->date_ouverture_prevue > 0) { $sql.= ",'".$this->db->idate($this->date_ouverture_prevue)."'"; }
if ($this->date_fin_validite > 0) { $sql.= ",'".$this->db->idate($this->date_fin_validite)."'"; }
if ($this->date_ouverture > 0) { $sql.= ",'".$this->db->idate($this->date_ouverture)."'"; }
if ($this->date_cloture > 0) { $sql.= ",'".$this->db->idate($this->date_cloture)."'"; }
$sql.= ")";
dol_syslog(get_class($this)."::insert", LOG_DEBUG);

View File

@ -275,7 +275,8 @@ class CMailFile
// comme des injections mail par les serveurs de messagerie.
$this->headers = preg_replace("/([\r\n]+)$/i","",$this->headers);
$this->message = $this->eol.'This is a message with multiple parts in MIME format.'.$this->eol;
//$this->message = $this->eol.'This is a message with multiple parts in MIME format.'.$this->eol;
$this->message = 'This is a message with multiple parts in MIME format.'.$this->eol;
$this->message.= $text_body . $files_encoded;
$this->message.= "--" . $this->mixed_boundary . "--" . $this->eol;
}
@ -961,8 +962,8 @@ class CMailFile
//$out.= "From: ".$this->getValidAddress($this->addr_from,3,1).$this->eol;
$out.= "Content-Type: multipart/mixed; boundary=\"".$this->mixed_boundary."\"".$this->eol2;
$out.= "Content-Transfer-Encoding: 8bit".$this->eol2;
$out.= "Content-Type: multipart/mixed;".$this->eol2." boundary=\"".$this->mixed_boundary."\"".$this->eol2;
$out.= "Content-Transfer-Encoding: 8bit".$this->eol2; // TODO Seems to be ignored. Header is 7bit once received.
dol_syslog("CMailFile::write_smtpheaders smtp_header=\n".$out);
return $out;
@ -1014,23 +1015,23 @@ class CMailFile
if ($this->atleastoneimage)
{
$out.= "Content-Type: multipart/alternative; boundary=\"".$this->alternative_boundary."\"".$this->eol;
$out.= "Content-Type: multipart/alternative;".$this->eol." boundary=\"".$this->alternative_boundary."\"".$this->eol;
$out.= $this->eol;
$out.= "--" . $this->alternative_boundary . $this->eol;
}
// Make RFC821 Compliant, replace bare linefeeds
$strContent = preg_replace("/(?<!\r)\n/si", "\r\n", $msgtext);
$strContent = preg_replace("/(?<!\r)\n/si", "\r\n", $msgtext); // PCRE modifier /s means new lines are common chars
if (! empty($conf->global->MAIN_FIX_FOR_BUGGED_MTA))
{
$strContent = preg_replace("/\r\n/si", "\n", $strContent);
$strContent = preg_replace("/\r\n/si", "\n", $strContent); // PCRE modifier /s means new lines are common chars
}
$strContentAltText = '';
if ($this->msgishtml)
{
$strContentAltText = html_entity_decode(strip_tags($strContent));
$strContentAltText = rtrim(wordwrap($strContentAltText, 75, "\r\n"));
$strContentAltText = rtrim(wordwrap($strContentAltText, 75, empty($conf->global->MAIN_FIX_FOR_BUGGED_MTA)?"\r\n":"\n"));
// Check if html header already in message, if not complete the message
$strContent = $this->checkIfHTML($strContent);
@ -1038,31 +1039,35 @@ class CMailFile
// Make RFC2045 Compliant, split lines
//$strContent = rtrim(chunk_split($strContent)); // Function chunck_split seems ko if not used on a base64 content
$strContent = rtrim(wordwrap($strContent)); // TODO Using this method creates unexpected line break on text/plain content.
// TODO Encode main content into base64 and use the chunk_split, or quoted-printable
$strContent = rtrim(wordwrap($strContent, 75, empty($conf->global->MAIN_FIX_FOR_BUGGED_MTA)?"\r\n":"\n")); // TODO Using this method creates unexpected line break on text/plain content.
if ($this->msgishtml)
{
if ($this->atleastoneimage)
{
$out.= "Content-Type: text/plain; charset=".$conf->file->character_set_client.$this->eol;
//$out.= "Content-Transfer-Encoding: 7bit".$this->eol;
$out.= $this->eol.($strContentAltText?$strContentAltText:strip_tags($strContent)).$this->eol; // Add plain text message
$out.= "--" . $this->alternative_boundary . $this->eol;
$out.= "Content-Type: multipart/related; boundary=\"".$this->related_boundary."\"".$this->eol;
$out.= "Content-Type: multipart/related;".$this->eol." boundary=\"".$this->related_boundary."\"".$this->eol;
$out.= $this->eol;
$out.= "--" . $this->related_boundary . $this->eol;
}
if (! $this->atleastoneimage && $strContentAltText && ! empty($conf->global->MAIN_MAIL_USE_MULTI_PART)) // Add plain text message part before html part
{
$out.= "Content-Type: multipart/alternative; boundary=\"".$this->alternative_boundary."\"".$this->eol;
$out.= "Content-Type: multipart/alternative;".$this->eol." boundary=\"".$this->alternative_boundary."\"".$this->eol;
$out.= $this->eol;
$out.= "--" . $this->alternative_boundary . $this->eol;
$out.= "Content-Type: text/plain; charset=".$conf->file->character_set_client.$this->eol;
//$out.= "Content-Transfer-Encoding: 7bit".$this->eol;
$out.= $this->eol.$strContentAltText.$this->eol;
$out.= "--" . $this->alternative_boundary . $this->eol;
}
$out.= "Content-Type: text/html; charset=".$conf->file->character_set_client.$this->eol;
//$out.= "Content-Transfer-Encoding: 7bit".$this->eol; // TODO Use base64
$out.= $this->eol.$strContent.$this->eol;
if (! $this->atleastoneimage && $strContentAltText && ! empty($conf->global->MAIN_MAIL_USE_MULTI_PART)) // Add plain text message part after html part
@ -1073,6 +1078,7 @@ class CMailFile
else
{
$out.= "Content-Type: text/plain; charset=".$conf->file->character_set_client.$this->eol;
//$out.= "Content-Transfer-Encoding: 7bit".$this->eol;
$out.= $this->eol.$strContent.$this->eol;
}

View File

@ -3690,11 +3690,12 @@ abstract class CommonObject
* Return HTML table table of source object lines
* TODO Move this and previous function into output html class file (htmlline.class.php).
* If lines are into a template, title must also be into a template
* But for the moment we don't know if it's possible as we keep a method available on overloaded objects.
* But for the moment we don't know if it's possible, so we keep the method available on overloaded objects.
*
* @param string $restrictlist ''=All lines, 'services'=Restrict to services only
* @return void
*/
function printOriginLinesList()
function printOriginLinesList($restrictlist='')
{
global $langs, $hookmanager, $conf;
@ -3716,8 +3717,6 @@ abstract class CommonObject
foreach ($this->lines as $line)
{
if (is_object($hookmanager) && (($line->product_type == 9 && ! empty($line->special_code)) || ! empty($line->fk_parent_line)))
{
if (empty($line->fk_parent_line))
@ -3729,7 +3728,7 @@ abstract class CommonObject
}
else
{
$this->printOriginLine($line,$var);
$this->printOriginLine($line, $var, $restrictlist);
}
$i++;
@ -3742,11 +3741,12 @@ abstract class CommonObject
* If lines are into a template, title must also be into a template
* But for the moment we don't know if it's possible as we keep a method available on overloaded objects.
*
* @param CommonObjectLine $line Line
* @param string $var Var
* @param CommonObjectLine $line Line
* @param string $var Var
* @param string $restrictlist ''=All lines, 'services'=Restrict to services only (strike line if not)
* @return void
*/
function printOriginLine($line,$var)
function printOriginLine($line, $var, $restrictlist='')
{
global $langs, $conf;
@ -3848,6 +3848,10 @@ abstract class CommonObject
if($conf->global->PRODUCT_USE_UNITS) $this->tpl['unit'] = $line->getLabelOfUnit('long');
$this->tpl['remise_percent'] = (($line->info_bits & 2) != 2) ? vatrate($line->remise_percent, true) : '&nbsp;';
// Is the line strike or not
$this->tpl['strike']=0;
if ($restrictlist == 'services' && $line->product_type != Product::TYPE_SERVICE) $this->tpl['strike']=1;
// Output template part (modules that overwrite templates must declare this into descriptor)
// Use global variables + $dateSelector + $seller and $buyer
$dirtpls=array_merge($conf->modules_parts['tpl'],array('/core/tpl'));
@ -4634,17 +4638,18 @@ abstract class CommonObject
else return 0;
}
/**
* Function to show lines of extrafields with output datas
*
* @param Extrafields $extrafields Extrafield Object
* @param string $mode Show output (view) or input (edit) for extrafield
* @param array $params Optional parameters
* @param string $keyprefix Prefix string to add into name and id of field (can be used to avoid duplicate names)
*
* @return string
*/
function showOptionals($extrafields, $mode='view', $params=null, $keyprefix='')
/**
* Function to show lines of extrafields with output datas
*
* @param Extrafields $extrafields Extrafield Object
* @param string $mode Show output (view) or input (edit) for extrafield
* @param array $params Optional parameters
* @param string $keysuffix Suffix string to add into name and id of field (can be used to avoid duplicate names)
* @param string $keyprefix Prefix string to add into name and id of field (can be used to avoid duplicate names)
*
* @return string
*/
function showOptionals($extrafields, $mode='view', $params=null, $keysuffix='', $keyprefix='')
{
global $_POST, $conf, $langs, $action;
@ -4672,12 +4677,12 @@ abstract class CommonObject
switch($mode) {
case "view":
$value=$this->array_options["options_".$key];
$value=$this->array_options["options_".$key.$keysuffix];
break;
case "edit":
$getposttemp = GETPOST('options_'.$key, 'none'); // GETPOST can get value from GET, POST or setup of default values.
$getposttemp = GETPOST($keyprefix.'options_'.$key.$keysuffix, 'none'); // GETPOST can get value from GET, POST or setup of default values.
// GETPOST("options_" . $key) can be 'abc' or array(0=>'abc')
if (is_array($getposttemp) || $getposttemp != '' || GETPOSTISSET('options_'.$key))
if (is_array($getposttemp) || $getposttemp != '' || GETPOSTISSET($keyprefix.'options_'.$key.$keysuffix))
{
if (is_array($getposttemp)) {
// $getposttemp is an array but following code expects a comma separated string
@ -4717,12 +4722,12 @@ abstract class CommonObject
// Convert date into timestamp format (value in memory must be a timestamp)
if (in_array($extrafields->attribute_type[$key],array('date','datetime')))
{
$value = isset($_POST["options_".$key])?dol_mktime($_POST["options_".$key."hour"], $_POST["options_".$key."min"], 0, $_POST["options_".$key."month"], $_POST["options_".$key."day"], $_POST["options_".$key."year"]):$this->db->jdate($this->array_options['options_'.$key]);
$value = GETPOSTISSET($keyprefix.'options_'.$key.$keysuffix)?dol_mktime(GETPOST($keyprefix.'options_'.$key.$keysuffix."hour",'int',3), GETPOST($keyprefix.'options_'.$key.$keysuffix."min",'int',3), 0, GETPOST($keyprefix.'options_'.$key.$keysuffix."month",'int',3), GETPOST($keyprefix.'options_'.$key.$keysuffix."day",'int',3), GETPOST($keyprefix.'options_'.$key.$keysuffix."year",'int',3)):$this->db->jdate($this->array_options['options_'.$key]);
}
// Convert float submited string into real php numeric (value in memory must be a php numeric)
if (in_array($extrafields->attribute_type[$key],array('price','double')))
{
$value = isset($_POST["options_".$key])?price2num($_POST["options_".$key]):$this->array_options['options_'.$key];
$value = GETPOSTISSET($keyprefix.'options_'.$key.$keysuffix)?price2num(GETPOST($keyprefix.'options_'.$key.$keysuffix,'int',3)):$this->array_options['options_'.$key];
}
$labeltoshow = $langs->trans($label);
@ -4741,7 +4746,7 @@ abstract class CommonObject
$out .= $extrafields->showOutputField($key, $value);
break;
case "edit":
$out .= $extrafields->showInputField($key, $value, '', $keyprefix, '', 0, $this->id);
$out .= $extrafields->showInputField($key, $value, '', $keysuffix, '', 0, $this->id);
break;
}
@ -4754,8 +4759,8 @@ abstract class CommonObject
}
$out .= "\n";
// Add code to manage list depending on others
if (! empty($conf->use_javascript_ajax))
$out .= '
if (! empty($conf->use_javascript_ajax)) {
$out .= '
<script type="text/javascript">
jQuery(document).ready(function() {
function showOptions(child_list, parent_list)
@ -4784,11 +4789,13 @@ abstract class CommonObject
setListDependencies();
});
</script>'."\n";
$out .= '<!-- /showOptionalsInput --> '."\n";
$out .= '<!-- /showOptionalsInput --> '."\n";
}
}
return $out;
}
/**
* Returns the rights used for this class
* @return stdClass

View File

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

View File

@ -806,13 +806,13 @@ class ExtraFields
* @param string $key Key of attribute
* @param string $value Preselected value to show (for date type it must be in timestamp format, for amount or price it must be a php numeric value)
* @param string $moreparam To add more parametes on html input tag
* @param string $keyprefix Prefix string to add into name and id of field (can be used to avoid duplicate names)
* @param string $keysuffix Suffix string to add into name and id of field (can be used to avoid duplicate names)
* @param string $keysuffix Prefix string to add into name and id of field (can be used to avoid duplicate names)
* @param string $keyprefix Suffix string to add into name and id of field (can be used to avoid duplicate names)
* @param mixed $showsize Value for css to define size. May also be a numeric.
* @param int $objectid Current object id
* @return string
*/
function showInputField($key, $value, $moreparam='', $keyprefix='', $keysuffix='', $showsize=0, $objectid=0)
function showInputField($key, $value, $moreparam='', $keysuffix='', $keyprefix='', $showsize=0, $objectid=0)
{
global $conf,$langs;
@ -831,51 +831,51 @@ class ExtraFields
if ($computed)
{
if ($keysuffix != 'search_') return '<span class="opacitymedium">'.$langs->trans("AutomaticallyCalculated").'</span>';
else return '';
if ($keyprefix != 'search_') return '<span class="opacitymedium">'.$langs->trans("AutomaticallyCalculated").'</span>';
else return '';
}
if (empty($showsize))
{
if ($type == 'date')
{
//$showsize=10;
$showsize = 'minwidth100imp';
}
if ($type == 'date')
{
//$showsize=10;
$showsize = 'minwidth100imp';
}
elseif ($type == 'datetime')
{
//$showsize=19;
$showsize = 'minwidth200imp';
}
elseif (in_array($type,array('int','double','price')))
{
//$showsize=10;
$showsize = 'maxwidth75';
}
elseif ($type == 'url')
{
$showsize='minwidth400';
}
elseif ($type == 'boolean')
{
$showsize='';
}
else
{
if (round($size) < 12)
{
$showsize = 'minwidth100';
}
else if (round($size) <= 48)
{
$showsize = 'minwidth200';
}
else
{
//$showsize=48;
$showsize = 'minwidth400';
}
}
{
//$showsize=19;
$showsize = 'minwidth200imp';
}
elseif (in_array($type,array('int','double','price')))
{
//$showsize=10;
$showsize = 'maxwidth75';
}
elseif ($type == 'url')
{
$showsize='minwidth400';
}
elseif ($type == 'boolean')
{
$showsize='';
}
else
{
if (round($size) < 12)
{
$showsize = 'minwidth100';
}
else if (round($size) <= 48)
{
$showsize = 'minwidth200';
}
else
{
//$showsize=48;
$showsize = 'minwidth400';
}
}
}
if (in_array($type,array('date','datetime')))
@ -893,26 +893,26 @@ class ExtraFields
if (! is_object($form)) $form=new Form($this->db);
// TODO Must also support $moreparam
$out = $form->select_date($value, $keysuffix.'options_'.$key.$keyprefix, $showtime, $showtime, $required, '', 1, ($keysuffix != 'search_' ? 1 : 0), 1, 0, 1);
$out = $form->select_date($value, $keyprefix.'options_'.$key.$keysuffix, $showtime, $showtime, $required, '', 1, ($keyprefix != 'search_' ? 1 : 0), 1, 0, 1);
}
elseif (in_array($type,array('int')))
{
$tmp=explode(',',$size);
$newsize=$tmp[0];
$out='<input type="text" class="flat '.$showsize.' maxwidthonsmartphone" name="'.$keysuffix.'options_'.$key.$keyprefix.'" maxlength="'.$newsize.'" value="'.$value.'"'.($moreparam?$moreparam:'').'>';
$out='<input type="text" class="flat '.$showsize.' maxwidthonsmartphone" name="'.$keyprefix.'options_'.$key.$keysuffix.'" id="'.$keyprefix.'options_'.$key.$keysuffix.'" maxlength="'.$newsize.'" value="'.$value.'"'.($moreparam?$moreparam:'').'>';
}
elseif ($type == 'varchar')
{
$out='<input type="text" class="flat '.$showsize.' maxwidthonsmartphone" name="'.$keysuffix.'options_'.$key.$keyprefix.'" maxlength="'.$size.'" value="'.dol_escape_htmltag($value).'"'.($moreparam?$moreparam:'').'>';
$out='<input type="text" class="flat '.$showsize.' maxwidthonsmartphone" name="'.$keyprefix.'options_'.$key.$keysuffix.'" id="'.$keyprefix.'options_'.$key.$keysuffix.'" maxlength="'.$size.'" value="'.dol_escape_htmltag($value).'"'.($moreparam?$moreparam:'').'>';
}
elseif (in_array($type, array('mail', 'phone', 'url')))
{
$out='<input type="text" class="flat '.$showsize.' maxwidthonsmartphone" name="'.$keysuffix.'options_'.$key.$keyprefix.'" value="'.$value.'" '.($moreparam?$moreparam:'').'>';
$out='<input type="text" class="flat '.$showsize.' maxwidthonsmartphone" name="'.$keyprefix.'options_'.$key.$keysuffix.'" id="'.$keyprefix.'options_'.$key.$keysuffix.'" value="'.$value.'" '.($moreparam?$moreparam:'').'>';
}
elseif ($type == 'text')
{
require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
$doleditor=new DolEditor($keysuffix.'options_'.$key.$keyprefix,$value,'',200,'dolibarr_notes','In',false,false,! empty($conf->fckeditor->enabled) && $conf->global->FCKEDITOR_ENABLE_SOCIETE,ROWS_5,'90%');
$doleditor=new DolEditor($keyprefix.'options_'.$key.$keysuffix,$value,'',200,'dolibarr_notes','In',false,false,! empty($conf->fckeditor->enabled) && $conf->global->FCKEDITOR_ENABLE_SOCIETE,ROWS_5,'90%');
$out=$doleditor->Create(1);
}
elseif ($type == 'boolean')
@ -923,21 +923,21 @@ class ExtraFields
} else {
$checked=' value="1" ';
}
$out='<input type="checkbox" class="flat '.$showsize.' maxwidthonsmartphone" name="'.$keysuffix.'options_'.$key.$keyprefix.'" '.$checked.' '.($moreparam?$moreparam:'').'>';
$out='<input type="checkbox" class="flat '.$showsize.' maxwidthonsmartphone" name="'.$keyprefix.'options_'.$key.$keysuffix.'" id="'.$keyprefix.'options_'.$key.$keysuffix.'" '.$checked.' '.($moreparam?$moreparam:'').'>';
}
elseif ($type == 'price')
{
if (!empty($value)) { // $value in memory is a php numeric, we format it into user number format.
$value=price($value);
}
$out='<input type="text" class="flat '.$showsize.' maxwidthonsmartphone" name="'.$keysuffix.'options_'.$key.$keyprefix.'" value="'.$value.'" '.($moreparam?$moreparam:'').'> '.$langs->getCurrencySymbol($conf->currency);
$out='<input type="text" class="flat '.$showsize.' maxwidthonsmartphone" name="'.$keyprefix.'options_'.$key.$keysuffix.'" id="'.$keyprefix.'options_'.$key.$keysuffix.'" value="'.$value.'" '.($moreparam?$moreparam:'').'> '.$langs->getCurrencySymbol($conf->currency);
}
elseif ($type == 'double')
{
if (!empty($value)) { // $value in memory is a php numeric, we format it into user number format.
$value=price($value);
}
$out='<input type="text" class="flat '.$showsize.' maxwidthonsmartphone" name="'.$keysuffix.'options_'.$key.$keyprefix.'" value="'.$value.'" '.($moreparam?$moreparam:'').'> ';
$out='<input type="text" class="flat '.$showsize.' maxwidthonsmartphone" name="'.$keyprefix.'options_'.$key.$keysuffix.'" id="'.$keyprefix.'options_'.$key.$keysuffix.'" value="'.$value.'" '.($moreparam?$moreparam:'').'> ';
}
elseif ($type == 'select')
{
@ -945,10 +945,10 @@ class ExtraFields
if (! empty($conf->use_javascript_ajax) && ! empty($conf->global->MAIN_EXTRAFIELDS_USE_SELECT2))
{
include_once DOL_DOCUMENT_ROOT . '/core/lib/ajax.lib.php';
$out.= ajax_combobox($keysuffix.'options_'.$key.$keyprefix, array(), 0);
$out.= ajax_combobox($keyprefix.'options_'.$key.$keysuffix, array(), 0);
}
$out.='<select class="flat '.$showsize.' maxwidthonsmartphone" name="'.$keysuffix.'options_'.$key.$keyprefix.'" id="options_'.$key.$keyprefix.'" '.($moreparam?$moreparam:'').'>';
$out.='<select class="flat '.$showsize.' maxwidthonsmartphone" name="'.$keyprefix.'options_'.$key.$keysuffix.'" id="'.$keyprefix.'options_'.$key.$keysuffix.'" '.($moreparam?$moreparam:'').'>';
$out.='<option value="0">&nbsp;</option>';
foreach ($param['options'] as $key => $val)
{
@ -967,10 +967,10 @@ class ExtraFields
if (! empty($conf->use_javascript_ajax) && ! empty($conf->global->MAIN_EXTRAFIELDS_USE_SELECT2))
{
include_once DOL_DOCUMENT_ROOT . '/core/lib/ajax.lib.php';
$out.= ajax_combobox($keysuffix.'options_'.$key.$keyprefix, array(), 0);
$out.= ajax_combobox($keyprefix.'options_'.$key.$keysuffix, array(), 0);
}
$out.='<select class="flat '.$showsize.' maxwidthonsmartphone" name="'.$keysuffix.'options_'.$key.$keyprefix.'" id="options_'.$key.$keyprefix.'" '.($moreparam?$moreparam:'').'>';
$out.='<select class="flat '.$showsize.' maxwidthonsmartphone" name="'.$keyprefix.'options_'.$key.$keysuffix.'" id="'.$keyprefix.'options_'.$key.$keysuffix.'" '.($moreparam?$moreparam:'').'>';
if (is_array($param['options']))
{
$param_list=array_keys($param['options']);
@ -1132,7 +1132,7 @@ class ExtraFields
$form = new Form($db);
$value_arr=explode(',',$value);
$out=$form->multiselectarray($keysuffix.'options_'.$key.$keyprefix, (empty($param['options'])?null:$param['options']), $value_arr, '', 0, '', 0, '100%');
$out=$form->multiselectarray($keyprefix.'options_'.$key.$keysuffix, (empty($param['options'])?null:$param['options']), $value_arr, '', 0, '', 0, '100%');
}
elseif ($type == 'radio')
@ -1140,11 +1140,11 @@ class ExtraFields
$out='';
foreach ($param['options'] as $keyopt => $val)
{
$out.='<input class="flat '.$showsize.'" type="radio" name="'.$keysuffix.'options_'.$key.$keyprefix.'" '.($moreparam?$moreparam:'');
$out.='<input class="flat '.$showsize.'" type="radio" name="'.$keyprefix.'options_'.$key.$keysuffix.'" id="'.$keyprefix.'options_'.$key.$keysuffix.'" '.($moreparam?$moreparam:'');
$out.=' value="'.$keyopt.'"';
$out.=' id="'.$keysuffix.'options_'.$key.$keyprefix.'_'.$keyopt.'"';
$out.=' id="'.$keyprefix.'options_'.$key.$keysuffix.'_'.$keyopt.'"';
$out.= ($value==$keyopt?'checked':'');
$out.='/><label for="'.$keysuffix.'options_'.$key.$keyprefix.'_'.$keyopt.'">'.$val.'</label><br>';
$out.='/><label for="'.$keyprefix.'options_'.$key.$keysuffix.'_'.$keyopt.'">'.$val.'</label><br>';
}
}
elseif ($type == 'chkbxlst')
@ -1268,15 +1268,15 @@ class ExtraFields
if (empty($labeltoshow))
$labeltoshow = '(not defined)';
if (is_array($value_arr) && in_array($obj->rowid, $value_arr)) {
if (is_array($value_arr) && in_array($obj->rowid, $value_arr)) {
$data[$obj->rowid]=$labeltoshow;
}
if (! empty($InfoFieldList[3])) {
$parent = $parentName . ':' . $obj->{$parentField};
}
$data[$obj->rowid]=$labeltoshow;
}
if (! empty($InfoFieldList[3])) {
$parent = $parentName . ':' . $obj->{$parentField};
}
$data[$obj->rowid]=$labeltoshow;
}
$i ++;
@ -1286,7 +1286,7 @@ class ExtraFields
require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php';
$form = new Form($db);
$out=$form->multiselectarray($keysuffix.'options_'.$key.$keyprefix, $data, $value_arr, '', 0, '', 0, '100%');
$out=$form->multiselectarray($keyprefix.'options_'.$key.$keysuffix, $data, $value_arr, '', 0, '', 0, '100%');
} else {
print 'Error in request ' . $sql . ' ' . $this->db->lasterror() . '. Check setup of extra parameters.<br>';
@ -1305,40 +1305,41 @@ class ExtraFields
dol_include_once($InfoFieldList[1]);
if ($InfoFieldList[0] && class_exists($InfoFieldList[0]))
{
$valuetoshow=$value;
if (!empty($value))
{
$object = new $InfoFieldList[0]($this->db);
$resfetch=$object->fetch($value);
if ($resfetch > 0)
{
$valuetoshow=$object->ref;
if ($object->element == 'societe') $valuetoshow=$object->name; // Special case for thirdparty because ->ref is not name but id (because name is not unique)
}
}
$out.='<input type="text" class="flat '.$showsize.'" name="'.$keysuffix.'options_'.$key.$keyprefix.'" value="'.$valuetoshow.'" >';
$valuetoshow=$value;
if (!empty($value))
{
$object = new $InfoFieldList[0]($this->db);
$resfetch=$object->fetch($value);
if ($resfetch > 0)
{
$valuetoshow=$object->ref;
if ($object->element == 'societe') $valuetoshow=$object->name; // Special case for thirdparty because ->ref is not name but id (because name is not unique)
}
}
$out.='<input type="text" class="flat '.$showsize.'" name="'.$keyprefix.'options_'.$key.$keysuffix.'" id="'.$keyprefix.'options_'.$key.$keysuffix.'" value="'.$valuetoshow.'" >';
}
else
{
dol_syslog('Error bad setup of extrafield', LOG_WARNING);
$out.='Error bad setup of extrafield';
dol_syslog('Error bad setup of extrafield', LOG_WARNING);
$out.='Error bad setup of extrafield';
}
}
elseif ($type == 'password')
{
// If prefix is 'search_', field is used as a filter, we use a common text field.
$out='<input type="'.($keysuffix=='search_'?'text':'password').'" class="flat '.$showsize.'" name="'.$keysuffix.'options_'.$key.$keyprefix.'" value="'.$value.'" '.($moreparam?$moreparam:'').'>';
$out='<input type="'.($keyprefix=='search_'?'text':'password').'" class="flat '.$showsize.'" name="'.$keyprefix.'options_'.$key.$keysuffix.'" id="'.$keyprefix.'options_'.$key.$keysuffix.'" value="'.$value.'" '.($moreparam?$moreparam:'').'>';
}
if (!empty($hidden)) {
$out='<input type="hidden" value="'.$value.'" name="'.$keysuffix.'options_'.$key.$keyprefix.'" id="'.$keysuffix.'options_'.$key.$keyprefix.'"/>';
$out='<input type="hidden" value="'.$value.'" name="'.$keyprefix.'options_'.$key.$keysuffix.'" id="'.$keyprefix.'options_'.$key.$keysuffix.'"/>';
}
/* Add comments
if ($type == 'date') $out.=' (YYYY-MM-DD)';
elseif ($type == 'datetime') $out.=' (YYYY-MM-DD HH:MM:SS)';
*/
elseif ($type == 'datetime') $out.=' (YYYY-MM-DD HH:MM:SS)';
*/
return $out;
}
/**
* Return HTML string to put an output field into a page
*

View File

@ -4742,6 +4742,7 @@ class Form
{
$shour = dol_print_date($set_time, "%H");
$smin = dol_print_date($set_time, "%M");
$ssec = dol_print_date($set_time, "%S");
}
}
else
@ -4752,6 +4753,7 @@ class Form
$sday = '';
$shour = !isset($conf->global->MAIN_DEFAULT_DATE_HOUR) ? '' : $conf->global->MAIN_DEFAULT_DATE_HOUR;
$smin = !isset($conf->global->MAIN_DEFAULT_DATE_MIN) ? '' : $conf->global->MAIN_DEFAULT_DATE_MIN;
$ssec = !isset($conf->global->MAIN_DEFAULT_DATE_SEC) ? '' : $conf->global->MAIN_DEFAULT_DATE_SEC;
}
// You can set MAIN_POPUP_CALENDAR to 'eldy' or 'jquery'
@ -4932,6 +4934,8 @@ class Form
$retstring.='<option value="'.$min.'"'.(($min == $smin)?' selected':'').'>'.$min.(empty($conf->dol_optimize_smallscreen)?'':'').'</option>';
}
$retstring.='</select>';
$retstring.='<input type="hidden" name="'.$prefix.'sec" value="'.$ssec.'">';
}
// Add a "Now" link

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1606,7 +1606,8 @@ function getListOfModels($db,$type,$maxfilenamelength=0)
if (! $tmpdir) { unset($listofdir[$key]); continue; }
if (is_dir($tmpdir))
{
$tmpfiles=dol_dir_list($tmpdir,'files',0,'\.od(s|t)$','','name',SORT_ASC,0);
// all type of template is allowed
$tmpfiles=dol_dir_list($tmpdir, 'files', 0, '', '', 'name', SORT_ASC, 0);
if (count($tmpfiles)) $listoffiles=array_merge($listoffiles,$tmpfiles);
}
}

View File

@ -60,30 +60,30 @@ if ($conf->multicompany->enabled) {
print '<td width="80">&nbsp;</td>';
print "</tr>\n";
if (count($extrafields->attribute_type))
if (count($extrafields->attributes[$elementtype]['type']))
{
foreach($extrafields->attribute_type as $key => $value)
foreach($extrafields->attributes[$elementtype]['type'] as $key => $value)
{
// Load language if required
if (! empty($extrafields->attribute_langfile[$key])) {
$langs->load($extrafields->attribute_langfile[$key]);
if (! empty($extrafields->attributes[$elementtype]['langfile'][$key])) {
$langs->load($extrafields->attributes[$elementtype]['langfile'][$key]);
}
print '<tr class="oddeven">';
print "<td>".$extrafields->attribute_pos[$key]."</td>\n";
print "<td>".$extrafields->attribute_label[$key]."</td>\n"; // We don't translate here, we want admin to know what is the key not translated value
print "<td>".$langs->trans($extrafields->attribute_label[$key])."</td>\n";
print "<td>".$extrafields->attributes[$elementtype]['pos'][$key]."</td>\n";
print "<td>".$extrafields->attributes[$elementtype]['label'][$key]."</td>\n"; // We don't translate here, we want admin to know what is the key not translated value
print "<td>".$langs->trans($extrafields->attributes[$elementtype]['label'][$key])."</td>\n";
print "<td>".$key."</td>\n";
print "<td>".$type2label[$extrafields->attribute_type[$key]]."</td>\n";
print '<td align="right">'.$extrafields->attribute_size[$key]."</td>\n";
print '<td align="center">'.yn($extrafields->attribute_unique[$key])."</td>\n";
print '<td>'.dol_trunc($extrafields->attribute_computed[$key], 20)."</td>\n";
print '<td align="center">'.yn($extrafields->attribute_required[$key])."</td>\n";
print '<td align="center">'.yn($extrafields->attribute_alwayseditable[$key])."</td>\n";
print '<td align="center">'.$extrafields->attribute_list[$key]."</td>\n";
if (! empty($conf->global->MAIN_CAN_HIDE_EXTRAFIELDS)) print '<td align="center">'.yn($extrafields->attribute_hidden[$key])."</td>\n"; // Add hidden option on not working feature. Why hide if user can't see it.
print "<td>".$type2label[$extrafields->attributes[$elementtype]['type'][$key]]."</td>\n";
print '<td align="right">'.$extrafields->attributes[$elementtype]['size'][$key]."</td>\n";
print '<td align="center">'.yn($extrafields->attributes[$elementtype]['unique'][$key])."</td>\n";
print '<td>'.dol_trunc($extrafields->attributes[$elementtype]['computed'][$key], 20)."</td>\n";
print '<td align="center">'.yn($extrafields->attributes[$elementtype]['required'][$key])."</td>\n";
print '<td align="center">'.yn($extrafields->attributes[$elementtype]['alwayseditable'][$key])."</td>\n";
print '<td align="center">'.$extrafields->attributes[$elementtype]['list'][$key]."</td>\n";
if (! empty($conf->global->MAIN_CAN_HIDE_EXTRAFIELDS)) print '<td align="center">'.yn($extrafields->attributes[$elementtype]['ishidden'][$key])."</td>\n"; // Add hidden option on not working feature. Why hide if user can't see it.
if (! empty($conf->multicompany->enabled)) {
print '<td align="center">'.($extrafields->attribute_entityid[$key]==0?$langs->trans("All"):$extrafields->attribute_entitylabel[$key]).'</td>';
print '<td align="center">'.($extrafields->attributes[$elementtype]['entityid'][$key]==0?$langs->trans("All"):$extrafields->attributes[$elementtype]['entitylabel'][$key]).'</td>';
}
print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=edit&attrname='.$key.'">'.img_edit().'</a>';
print "&nbsp; <a href=\"".$_SERVER["PHP_SELF"]."?action=delete&attrname=$key\">".img_delete()."</a></td>\n";

View File

@ -32,7 +32,7 @@
$parameters = array();
$reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
print $hookmanager->resPrint;
if (empty($reshook) && ! empty($extrafields->attribute_label)) {
if (empty($reshook) && ! empty($extrafields->attributes[$object->table_element]['label'])) {
print $object->showOptionals($extrafields, 'edit');
}

View File

@ -32,7 +32,7 @@
$parameters = array();
$reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
print $hookmanager->resPrint;
if (empty($reshook) && ! empty($extrafields->attribute_label)) {
if (empty($reshook) && ! empty($extrafields->attributes[$object->table_element]['label'])) {
print $object->showOptionals($extrafields, 'edit');
}

View File

@ -19,8 +19,8 @@
?>
<!-- BEGIN PHP TEMPLATE originproductline.tpl.php -->
<?php
print '<tr'.$bc[$var].'>';
<?php
print '<tr class="oddeven'.(empty($this->tpl['strike'])?'':' strikefordisabled').'">';
print '<td>'.$this->tpl['label'].'</td>';
print '<td>'.$this->tpl['description'].'</td>';
print '<td align="right">'.$this->tpl['vat_rate'].'</td>';
@ -29,7 +29,7 @@ if (!empty($conf->multicurrency->enabled))
print '<td align="right">'.$this->tpl['multicurrency_price'].'</td>';
print '<td align="right">'.$this->tpl['qty'].'</td>';
if($conf->global->PRODUCT_USE_UNITS)
if($conf->global->PRODUCT_USE_UNITS)
print '<td align="left">'.$langs->trans($this->tpl['unit']).'</td>';
print '<td align="right">'.$this->tpl['remise_percent'].'</td>';

View File

@ -271,7 +271,7 @@ class ExpenseReports extends DolibarrApi
);
if ($updateRes > 0) {
return $this->get($id)->line->rowid;
return $updateRes;
}
return false;

View File

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

View File

@ -60,6 +60,7 @@ $ref = GETPOST('ref','alpha');
$socid = GETPOST('socid','int');
$contratid = GETPOST('contratid','int');
$action = GETPOST('action','alpha');
$cancel = GETPOST('cancel','alpha');
$confirm = GETPOST('confirm','alpha');
$mesg = GETPOST('msg','alpha');
$origin=GETPOST('origin','alpha');
@ -105,6 +106,16 @@ if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'e
if (empty($reshook))
{
if ($cancel)
{
if (! empty($backtopage))
{
header("Location: ".$backtopage);
exit;
}
$action='';
}
include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not include_once
include DOL_DOCUMENT_ROOT.'/core/actions_dellink.inc.php'; // Must be include, not include_once
@ -201,11 +212,11 @@ if (empty($reshook))
else if ($action == 'add' && $user->rights->ficheinter->creer)
{
$object->socid = $socid;
$object->duration = GETPOST('duration','int');
$object->duration = GETPOST('duration','int');
$object->fk_project = GETPOST('projectid','int');
$object->fk_contrat = GETPOST('contratid','int');
$object->author = $user->id;
$object->description = GETPOST('description');
$object->description = GETPOST('description','none');
$object->ref = $ref;
$object->modelpdf = GETPOST('model','alpha');
$object->note_private = GETPOST('note_private','none');
@ -276,7 +287,7 @@ if (empty($reshook))
$fk_parent_line=0;
$num=count($lines);
for ($i=0;$i<$num;$i++)
for ($i=0; $i<$num; $i++)
{
$product_type=($lines[$i]->product_type?$lines[$i]->product_type:Product::TYPE_PRODUCT);
@ -829,7 +840,7 @@ if ($action == 'create')
$soc=new Societe($db);
print load_fiche_titre($langs->trans("AddIntervention"));
print load_fiche_titre($langs->trans("AddIntervention"), '', 'title_commercial');
dol_htmloutput_mesg($mesg);
@ -1008,6 +1019,30 @@ if ($action == 'create')
$newclassname=$classname;
if ($newclassname=='Propal') $newclassname='CommercialProposal';
print '<tr><td>'.$langs->trans($newclassname).'</td><td colspan="2">'.$objectsrc->getNomUrl(1).'</td></tr>';
// Amount
/* Hide amount because we only copy services so amount may differ than source
print '<tr><td>' . $langs->trans('TotalHT') . '</td><td>' . price($objectsrc->total_ht) . '</td></tr>';
print '<tr><td>' . $langs->trans('TotalVAT') . '</td><td>' . price($objectsrc->total_tva) . "</td></tr>";
if ($mysoc->localtax1_assuj == "1" || $objectsrc->total_localtax1 != 0) // Localtax1 RE
{
print '<tr><td>' . $langs->transcountry("AmountLT1", $mysoc->country_code) . '</td><td>' . price($objectsrc->total_localtax1) . "</td></tr>";
}
if ($mysoc->localtax2_assuj == "1" || $objectsrc->total_localtax2 != 0) // Localtax2 IRPF
{
print '<tr><td>' . $langs->transcountry("AmountLT2", $mysoc->country_code) . '</td><td>' . price($objectsrc->total_localtax2) . "</td></tr>";
}
print '<tr><td>' . $langs->trans('TotalTTC') . '</td><td>' . price($objectsrc->total_ttc) . "</td></tr>";
if (!empty($conf->multicurrency->enabled))
{
print '<tr><td>' . $langs->trans('MulticurrencyTotalHT') . '</td><td>' . price($objectsrc->multicurrency_total_ht) . '</td></tr>';
print '<tr><td>' . $langs->trans('MulticurrencyTotalVAT') . '</td><td>' . price($objectsrc->multicurrency_total_tva) . "</td></tr>";
print '<tr><td>' . $langs->trans('MulticurrencyTotalTTC') . '</td><td>' . price($objectsrc->multicurrency_total_ttc) . "</td></tr>";
}
*/
}
print '</table>';
@ -1029,6 +1064,18 @@ if ($action == 'create')
print '</div>';
print '</form>';
// Show origin lines
if (! empty($origin) && ! empty($originid) && is_object($objectsrc)) {
$title = $langs->trans('Services');
print load_fiche_titre($title);
print '<table class="noborder" width="100%">';
$objectsrc->printOriginLinesList(empty($conf->global->FICHINTER_PRINT_PRODUCTS)?'services':''); // Show only service, except if option FICHINTER_PRINT_PRODUCTS is on
print '</table>';
}
}
else
{
@ -1604,22 +1651,8 @@ else if ($id > 0 || ! empty($ref))
else print '<div class="inline-block divButAction"><a class="butActionRefused" href="#">'.$langs->trans('SendByMail').'</a></div>';
}
// Event agenda
if (! empty($conf->global->FICHINTER_ADDLINK_TO_EVENT))
{
if (! empty($conf->agenda->enabled) && $object->statut > Fichinter::STATUS_DRAFT)
{
$langs->load("agenda");
if ($object->statut < Fichinter::STATUS_BILLED)
{
if ($user->rights->agenda->myactions->create) print '<div class="inline-block divButAction"><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.'&amp;backtopage='.urlencode($_SERVER["PHP_SELF"].'?id='.$object->id).'">'.$langs->trans("AddEvent").'</a></div>';
else print '<div class="inline-block divButAction"><a class="butActionRefused" href="#" title="'.$langs->trans("NotEnoughPermissions").'">'.$langs->trans("AddEvent").'</a></div>';
}
}
}
// Proposal
if (! empty($conf->propal->enabled) && $object->statut > Fichinter::STATUS_DRAFT)
if ($conf->service->enabled && ! empty($conf->propal->enabled) && $object->statut > Fichinter::STATUS_DRAFT)
{
$langs->load("propal");
if ($object->statut < Fichinter::STATUS_BILLED)

View File

@ -1449,7 +1449,7 @@ class CommandeFournisseur extends CommonOrder
$result=$prod->get_buyprice($fk_prod_fourn_price, $qty, $fk_product, 'none', $this->fk_soc); // Search on couple $fk_prod_fourn_price/$qty first, then on triplet $qty/$fk_product/$fourn_ref/$this->fk_soc
if ($result > 0)
{
$pu = $prod->fourn_pu; // Unit price supplier price set by get_buyprice
$pu = $prod->fourn_pu; // Unit price supplier price set by get_buyprice
$ref_supplier = $prod->ref_supplier; // Ref supplier price set by get_buyprice
// is remise percent not keyed but present for the product we add it
if ($remise_percent == 0 && $prod->remise_percent !=0)

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -771,6 +771,7 @@ Calendar=Calendrier
GroupBy=Grouper par...
ViewFlatList=Voir vue liste
RemoveString=Supprimer la chaine '%s'
Translation=Traduction
SomeTranslationAreUncomplete=Certains languages pourraient n'être que partiellement traduis, ou contenir des erreurs. Si vous en détectez, vous pouvez les corriger en vous enregistrant sur <a href="https://transifex.com/projects/p/dolibarr/" target="_blank">https://transifex.com/projects/p/dolibarr/</a>
DirectDownloadLink=Lien de téléchargement direct
Download=Téléchargement

View File

@ -100,7 +100,6 @@ ParentProductsNumber=Nbre de produits virtuels/packages parent
ParentProducts=Produits parents
IfZeroItIsNotAVirtualProduct=Si 0, ce produit n'est pas un produit virtuel
IfZeroItIsNotUsedByVirtualProduct=Si 0, ce produit n'est pas utilisé par un produit virtuel
Translation=Traduction
KeywordFilter=Filtre par mot-clé
CategoryFilter=Filtre par catégorie
ProductToAddSearch=Recherche des produits à ajouter

File diff suppressed because it is too large Load Diff

View File

@ -231,7 +231,7 @@ class MyObjectApi extends DolibarrApi
}
if($this->myobject->update($id, DolibarrApiAccess::$user))
return $this->get ($id);
return $this->get($id);
return false;
}

View File

@ -893,7 +893,7 @@ else
print '</td>';
if (! $i) $totalarray['nbfield']++;
}
// Stock
// Stock real
if (! empty($arrayfields['p.stock']['checked']))
{
print '<td align="right">';
@ -905,7 +905,7 @@ else
print '</td>';
if (! $i) $totalarray['nbfield']++;
}
// Stock
// Stock virtual
if (! empty($arrayfields['stock_virtual']['checked']))
{
print '<td align="right">';

View File

@ -342,7 +342,7 @@ class Projects extends DolibarrApi
);
if ($updateRes > 0) {
return $this->get($id)->line->rowid;
return $updateRes;
}
return false;

View File

@ -20,7 +20,7 @@
require_once DOL_DOCUMENT_ROOT.'/projet/class/task.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
/**
* API class for projects
*
@ -88,12 +88,12 @@ class Tasks extends DolibarrApi
// TODO
// Add class for timespent records and loop and fill $line->lines with records of timespent
}
return $this->_cleanObjectDatas($this->task);
}
/**
* List tasks
*
@ -110,7 +110,7 @@ class Tasks extends DolibarrApi
global $db, $conf;
$obj_ret = array();
// case of external user, $thirdparty_ids param is ignored and replaced by user's socid
$socids = DolibarrApiAccess::$user->societe_id ? DolibarrApiAccess::$user->societe_id : $thirdparty_ids;
@ -134,7 +134,7 @@ class Tasks extends DolibarrApi
$sql .= " AND sc.fk_user = ".$search_sale;
}
// Add sql filters
if ($sqlfilters)
if ($sqlfilters)
{
if (! DolibarrApi::_checkFilters($sqlfilters))
{
@ -143,7 +143,7 @@ class Tasks extends DolibarrApi
$regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
$sql.=" AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")";
}
$sql.= $db->order($sortfield, $sortorder);
if ($limit) {
if ($page < 0)
@ -236,7 +236,7 @@ class Tasks extends DolibarrApi
}
$this->project->getLinesArray(DolibarrApiAccess::$user);
$result = array();
foreach ($this->project->lines as $line) // $line is a task
foreach ($this->project->lines as $line) // $line is a task
{
if ($includetimespent == 1)
{
@ -252,7 +252,7 @@ class Tasks extends DolibarrApi
return $result;
}
*/
/**
* Get roles a user is assigned to a task with
*
@ -265,20 +265,20 @@ class Tasks extends DolibarrApi
*/
function getRoles($id, $userid=0) {
global $db;
if(! DolibarrApiAccess::$user->rights->projet->lire) {
throw new RestException(401);
}
$result = $this->task->fetch($id);
if( ! $result ) {
throw new RestException(404, 'Task not found');
}
if( ! DolibarrApi::_checkAccessToResource('task',$this->task->id)) {
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
}
$usert = DolibarrApiAccess::$user;
if ($userid > 0)
{
@ -292,8 +292,8 @@ class Tasks extends DolibarrApi
}
return $result;
}
/**
* Add a task to given project
*
@ -348,13 +348,13 @@ class Tasks extends DolibarrApi
);
if ($updateRes > 0) {
return $this->get($id)->line->rowid;
return $updateRes;
}
return false;
}
*/
/**
* Update a task to given project
*
@ -412,8 +412,8 @@ class Tasks extends DolibarrApi
}
return false;
}*/
/**
* Update task general fields (won't touch time spent of task)
*
@ -484,7 +484,7 @@ class Tasks extends DolibarrApi
}
/**
* Add time spent to a task of a project.
* You can test this API with the following input message
@ -495,15 +495,15 @@ class Tasks extends DolibarrApi
* @param int $duration Duration in seconds (3600 = 1h)
* @param int $user_id User (Use 0 for connected user)
* @param string $note Note
*
*
* @url POST {id}/addtimespent
*
* @return array
*/
function addTimeSpent($id, $date, $duration, $user_id=0, $note='')
{
if( ! DolibarrApiAccess::$user->rights->projet->creer) {
throw new RestException(401);
}
@ -511,22 +511,22 @@ class Tasks extends DolibarrApi
if ($result <= 0) {
throw new RestException(404, 'Task not found');
}
if( ! DolibarrApi::_checkAccessToResource('project', $this->task->fk_project)) {
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
}
$uid = $user_id;
if (empty($uid)) $uid = DolibarrApiAccess::$user->id;
$newdate = dol_stringtotime($date, 1);
$newdate = dol_stringtotime($date, 1);
$this->task->timespent_date = $newdate;
$this->task->timespent_datehour = $newdate;
$this->task->timespent_withhour = 1;
$this->task->timespent_duration = $duration;
$this->task->timespent_fk_user = $user_id;
$this->task->timespent_note = $note;
$this->task->timespent_note = $note;
$result = $this->task->addTimeSpent(DolibarrApiAccess::$user, 0);
if ($result == 0) {
throw new RestException(500, 'Error nothing done. May be object is already validated');
@ -534,7 +534,7 @@ class Tasks extends DolibarrApi
if ($result < 0) {
throw new RestException(500, 'Error when adding time: '.$this->task->error);
}
return array(
'success' => array(
'code' => 200,
@ -542,8 +542,8 @@ class Tasks extends DolibarrApi
)
);
}
/**
* Clean sensible object datas
*
@ -551,9 +551,9 @@ class Tasks extends DolibarrApi
* @return array Array of cleaned object properties
*/
function _cleanObjectDatas($object) {
$object = parent::_cleanObjectDatas($object);
unset($object->barcode_type);
unset($object->barcode_type_code);
unset($object->barcode_type_label);
@ -575,21 +575,21 @@ class Tasks extends DolibarrApi
unset($object->country);
unset($object->country_id);
unset($object->country_code);
unset($object->weekWorkLoad);
unset($object->weekWorkLoad);
//unset($object->lines); // for task we use timespent_lines, but for project we use lines
unset($object->total_ht);
unset($object->total_tva);
unset($object->total_localtax1);
unset($object->total_localtax2);
unset($object->total_ttc);
return $object;
}
/**
* Validate fields before create or update object
*
@ -608,8 +608,8 @@ class Tasks extends DolibarrApi
}
return $object;
}
// TODO
// getSummaryOfTimeSpent
}

View File

@ -738,7 +738,9 @@ class Societe extends CommonObject
$this->fax = preg_replace("/\./","",$this->fax);
$this->email = trim($this->email);
$this->skype = trim($this->skype);
$this->url = $this->url?clean_url($this->url,0):'';
$this->url = $this->url?clean_url($this->url,0):'';
$this->note_private = trim($this->note_private);
$this->note_public = trim($this->note_public);
$this->idprof1 = trim($this->idprof1);
$this->idprof2 = trim($this->idprof2);
$this->idprof3 = trim($this->idprof3);
@ -853,6 +855,9 @@ class Societe extends CommonObject
$sql .= ",skype = ".(! empty($this->skype)?"'".$this->db->escape($this->skype)."'":"null");
$sql .= ",url = ".(! empty($this->url)?"'".$this->db->escape($this->url)."'":"null");
$sql .= ",note_private = ".(! empty($this->note_private)?"'".$this->db->escape($this->note_private)."'":"null");
$sql .= ",note_public = ".(! empty($this->note_public)?"'".$this->db->escape($this->note_public)."'":"null");
$sql .= ",siren = '". $this->db->escape($this->idprof1) ."'";
$sql .= ",siret = '". $this->db->escape($this->idprof2) ."'";
$sql .= ",ape = '". $this->db->escape($this->idprof3) ."'";

View File

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

View File

@ -194,8 +194,8 @@ if (empty($reshook))
// Validation
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->validate_advance)))
((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)))
)
{
$result = $object->valid($user);
@ -258,7 +258,7 @@ if (empty($reshook))
if ($object->fetch(GETPOST('copie_supplier_proposal')) > 0) {
$object->ref = GETPOST('ref');
$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->mode_reglement_id = GETPOST('mode_reglement_id');
$object->fk_account = GETPOST('fk_account', 'int');
@ -279,7 +279,7 @@ if (empty($reshook))
$object->ref = GETPOST('ref');
$object->date_livraison = $date_delivery;
$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->mode_reglement_id = GETPOST('mode_reglement_id');
$object->fk_account = GETPOST('fk_account', 'int');
@ -381,7 +381,7 @@ if (empty($reshook))
// Hooks
$parameters = array('objFrom' => $srcobject);
$reshook = $hookmanager->executeHooks('createFrom', $parameters, $object, $action); // Note that $action and $object may have been
// modified by hook
// modified by hook
if ($reshook < 0)
$error ++;
} else {
@ -404,23 +404,23 @@ if (empty($reshook))
{
$db->commit();
// Define output language
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE))
{
$outputlangs = $langs;
$newlang = '';
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 (! empty($newlang)) {
$outputlangs = new Translate("", $conf);
$outputlangs->setDefaultLang($newlang);
}
$model=$object->modelpdf;
// Define output language
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE))
{
$outputlangs = $langs;
$newlang = '';
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 (! empty($newlang)) {
$outputlangs = new Translate("", $conf);
$outputlangs->setDefaultLang($newlang);
}
$model=$object->modelpdf;
$ret = $object->fetch($id); // Reload to get new records
$result=$object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
if ($result < 0) dol_print_error($db,$result);
}
$ret = $object->fetch($id); // Reload to get new records
$result=$object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
if ($result < 0) dol_print_error($db,$result);
}
header('Location: ' . $_SERVER["PHP_SELF"] . '?id=' . $id);
exit();
@ -451,8 +451,8 @@ if (empty($reshook))
// Close proposal
else if ($action == 'close' && $user->rights->supplier_proposal->cloturer && ! GETPOST('cancel','alpha')) {
// prevent browser refresh from reopening proposal several times
if ($object->statut == SupplierProposal::STATUS_SIGNED) {
// prevent browser refresh from reopening proposal several times
if ($object->statut == SupplierProposal::STATUS_SIGNED) {
$object->setStatut(SupplierProposal::STATUS_CLOSE);
}
}
@ -465,7 +465,7 @@ if (empty($reshook))
} else {
// prevent browser refresh from closing proposal several times
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
if ($action == 'addline' && $user->rights->supplier_proposal->creer)
{
$langs->load('errors');
$error = 0;
$langs->load('errors');
$error = 0;
// Set if we used free entry or predefined product
$predef='';
$ref_fourn = GETPOST('fourn_ref');
$predef='';
$ref_fourn = GETPOST('fourn_ref');
$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_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
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
{
$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 (preg_match('/^idprod_([0-9]+)$/',GETPOST('idprodfournprice'), $reg))
{
$idprod=$reg[1];
$res=$productsupplier->fetch($idprod);
// 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
$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)
{
//$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
$idprod=$productsupplier->get_buyprice(GETPOST('idprodfournprice'), $qtytosearch);
$res=$productsupplier->fetch($idprod);
}
if (empty($conf->global->SUPPLIER_PROPOSAL_WITH_NOPRICEDEFINED)) // TODO this test seems useless
{
$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 (preg_match('/^idprod_([0-9]+)$/',GETPOST('idprodfournprice'), $reg))
{
$idprod=$reg[1];
$res=$productsupplier->fetch($idprod);
// 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
$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)
{
//$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
$idprod=$productsupplier->get_buyprice(GETPOST('idprodfournprice'), $qtytosearch);
$res=$productsupplier->fetch($idprod);
}
if ($idprod > 0)
{
$pu_ht = $productsupplier->fourn_pu;
$price_base_type = $productsupplier->fourn_price_base_type;
$type = $productsupplier->type;
$label = $productsupplier->label;
$desc = $productsupplier->description;
if (trim($product_desc) != trim($desc)) $desc = dol_concatdesc($desc, $product_desc);
if ($idprod > 0)
{
$pu_ht = $productsupplier->fourn_pu;
$price_base_type = $productsupplier->fourn_price_base_type;
$type = $productsupplier->type;
$label = $productsupplier->label;
$desc = $productsupplier->description;
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_npr = get_default_npr($object->thirdparty, $mysoc, $productsupplier->id, GETPOST('idprodfournprice'));
if (empty($tva_tx)) $tva_npr=0;
$localtax1_tx= get_localtax($tva_tx, 1, $mysoc, $object->thirdparty, $tva_npr);
$localtax2_tx= get_localtax($tva_tx, 2, $mysoc, $object->thirdparty, $tva_npr);
$tva_tx = get_default_tva($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;
$localtax1_tx= get_localtax($tva_tx, 1, $mysoc, $object->thirdparty, $tva_npr);
$localtax2_tx= get_localtax($tva_tx, 2, $mysoc, $object->thirdparty, $tva_npr);
$result=$object->addline(
$desc,
$pu_ht,
$qty,
$tva_tx,
$localtax1_tx,
$localtax2_tx,
$productsupplier->id,
$remise_percent,
$price_base_type,
$pu_ttc,
$tva_npr,
$type,
-1,
0,
GETPOST('fk_parent_line'),
$fournprice,
$buyingprice,
$label,
$array_options,
$ref_fourn,
$fk_unit
);
//var_dump($tva_tx);var_dump($productsupplier->fourn_pu);var_dump($price_base_type);exit;
}
if ($idprod == -99 || $idprod == 0)
{
// Product not selected
$error++;
$langs->load("errors");
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("ProductOrService")).' '.$langs->trans("or").' '.$langs->trans("NoPriceDefinedForThisSupplier"), null, 'errors');
}
if ($idprod == -1)
{
// Quantity too low
$error++;
$langs->load("errors");
setEventMessages($langs->trans("ErrorQtyTooLowForThisSupplier"), null, 'errors');
}
$result=$object->addline(
$desc,
$pu_ht,
$qty,
$tva_tx,
$localtax1_tx,
$localtax2_tx,
$productsupplier->id,
$remise_percent,
$price_base_type,
$pu_ttc,
$tva_npr,
$type,
-1,
0,
GETPOST('fk_parent_line'),
$fournprice,
$buyingprice,
$label,
$array_options,
$ref_fourn,
$fk_unit
);
//var_dump($tva_tx);var_dump($productsupplier->fourn_pu);var_dump($price_base_type);exit;
}
if ($idprod == -99 || $idprod == 0)
{
// Product not selected
$error++;
$langs->load("errors");
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("ProductOrService")).' '.$langs->trans("or").' '.$langs->trans("NoPriceDefinedForThisSupplier"), null, 'errors');
}
if ($idprod == -1)
{
// Quantity too low
$error++;
$langs->load("errors");
setEventMessages($langs->trans("ErrorQtyTooLowForThisSupplier"), null, 'errors');
}
}
else if((GETPOST('price_ht')!=='' || GETPOST('price_ttc')!=='') && empty($error)) // Free product
{
$pu_ht = price2num($price_ht, 'MU');
$pu_ttc = price2num(GETPOST('price_ttc'), 'MU');
$tva_npr = (preg_match('/\*/', $tva_tx) ? 1 : 0);
$tva_tx = str_replace('*', '', $tva_tx);
$label = (GETPOST('product_label') ? GETPOST('product_label') : '');
$desc = $product_desc;
$type = GETPOST('type');
$pu_ht = price2num($price_ht, 'MU');
$pu_ttc = price2num(GETPOST('price_ttc'), 'MU');
$tva_npr = (preg_match('/\*/', $tva_tx) ? 1 : 0);
$tva_tx = str_replace('*', '', $tva_tx);
$label = (GETPOST('product_label') ? GETPOST('product_label') : '');
$desc = $product_desc;
$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
$localtax1_tx= get_localtax($tva_tx, 1, $mysoc, $object->thirdparty);
$localtax2_tx= get_localtax($tva_tx, 2, $mysoc, $object->thirdparty);
// Local Taxes
$localtax1_tx= get_localtax($tva_tx, 1, $mysoc, $object->thirdparty);
$localtax2_tx= get_localtax($tva_tx, 2, $mysoc, $object->thirdparty);
if (GETPOST('price_ht')!=='')
{
$price_base_type = 'HT';
$ht = price2num(GETPOST('price_ht'));
$ttc = 0;
}
else
{
$ttc = price2num(GETPOST('price_ttc'));
$ht = $ttc / (1 + ($tva_tx / 100));
$price_base_type = 'HT';
}
if (GETPOST('price_ht')!=='')
{
$price_base_type = 'HT';
$ht = price2num(GETPOST('price_ht'));
$ttc = 0;
}
else
{
$ttc = price2num(GETPOST('price_ttc'));
$ht = $ttc / (1 + ($tva_tx / 100));
$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, 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;
$newlang = '';
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 (! empty($newlang)) {
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 (! empty($newlang)) {
$outputlangs = new Translate("", $conf);
$outputlangs->setDefaultLang($newlang);
}
@ -716,7 +716,7 @@ if (empty($reshook))
$ret = $object->fetch($id); // Reload to get new records
$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']);
@ -729,7 +729,7 @@ if (empty($reshook))
unset($_POST['multicurrency_price_ht']);
unset($_POST['price_ttc']);
unset($_POST['tva_tx']);
unset($_POST['label']);
unset($_POST['label']);
unset($_POST['product_ref']);
unset($_POST['product_label']);
unset($_POST['product_desc']);
@ -958,9 +958,9 @@ $now = dol_now();
// Add new askprice
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);
if ($socid > 0)
@ -997,8 +997,8 @@ if ($action == 'create')
if (!empty($conf->multicurrency->enabled))
{
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($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;
}
}
else
@ -1036,7 +1036,7 @@ if ($action == 'create')
} else {
print '<td colspan="2">';
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 '</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');
print '</td></tr>';
// Bank Account
if (! empty($conf->global->BANK_ASK_PAYMENT_BANK_DURING_PROPOSAL) && ! empty($conf->banque->enabled)) {
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);
print '</td></tr>';
}
// Bank Account
if (! empty($conf->global->BANK_ASK_PAYMENT_BANK_DURING_PROPOSAL) && ! empty($conf->banque->enabled)) {
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);
print '</td></tr>';
}
// Shipping Method
if (! empty($conf->expedition->enabled)) {
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 '</td></tr>';
}
// Shipping Method
if (! empty($conf->expedition->enabled)) {
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 '</td></tr>';
}
// Delivery date (or manufacturing)
print '<tr><td>' . $langs->trans("DeliveryDate") . '</td>';
@ -1115,15 +1115,15 @@ if ($action == 'create')
{
print '<tr>';
print '<td>'.fieldLabel('Currency','multicurrency_code').'</td>';
print '<td colspan="3" class="maxwidthonsmartphone">';
print $form->selectMultiCurrency($currency_code, 'multicurrency_code');
print '<td colspan="3" class="maxwidthonsmartphone">';
print $form->selectMultiCurrency($currency_code, 'multicurrency_code');
print '</td></tr>';
}
// Other attributes
$parameters = array('colspan' => ' colspan="3"');
$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)) {
print $object->showOptionals($extrafields, 'edit');
}
@ -1181,7 +1181,7 @@ if ($action == 'create')
if (! empty($conf->global->SUPPLIER_PROPOSAL_CLONE_ON_CREATE_PAGE))
{
print '<br><table>';
print '<br><table>';
// For backward compatibility
print '<tr>';
@ -1339,34 +1339,34 @@ if ($action == 'create')
// Project
if (! empty($conf->projet->enabled))
{
$langs->load("projects");
$morehtmlref.='<br>'.$langs->trans('Project') . ' ';
if ($user->rights->supplier_proposal->creer)
{
if ($action != 'classify')
$morehtmlref.='<a href="' . $_SERVER['PHP_SELF'] . '?action=classify&amp;id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : ';
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 method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">';
$morehtmlref.='<input type="hidden" name="action" value="classin">';
$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.='<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">';
$morehtmlref.='</form>';
} else {
$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1);
}
} else {
if (! empty($object->fk_project)) {
$proj = new Project($db);
$proj->fetch($object->fk_project);
$morehtmlref.='<a href="'.DOL_URL_ROOT.'/projet/card.php?id=' . $object->fk_project . '" title="' . $langs->trans('ShowProject') . '">';
$morehtmlref.=$proj->ref;
$morehtmlref.='</a>';
} else {
$morehtmlref.='';
}
}
$langs->load("projects");
$morehtmlref.='<br>'.$langs->trans('Project') . ' ';
if ($user->rights->supplier_proposal->creer)
{
if ($action != 'classify')
$morehtmlref.='<a href="' . $_SERVER['PHP_SELF'] . '?action=classify&amp;id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : ';
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 method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">';
$morehtmlref.='<input type="hidden" name="action" value="classin">';
$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.='<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">';
$morehtmlref.='</form>';
} else {
$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1);
}
} else {
if (! empty($object->fk_project)) {
$proj = new Project($db);
$proj->fetch($object->fk_project);
$morehtmlref.='<a href="'.DOL_URL_ROOT.'/projet/card.php?id=' . $object->fk_project . '" title="' . $langs->trans('ShowProject') . '">';
$morehtmlref.=$proj->ref;
$morehtmlref.='</a>';
} else {
$morehtmlref.='';
}
}
}
$morehtmlref.='</div>';
@ -1468,17 +1468,17 @@ if ($action == 'create')
print '</tr></table>';
print '</td><td colspan="3">';
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);
}
$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 {
$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) {
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 '</div>';
}
$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) {
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 '</div>';
}
}
print '</td></tr>';
}
@ -1498,22 +1498,22 @@ if ($action == 'create')
if (! empty($conf->global->BANK_ASK_PAYMENT_BANK_DURING_PROPOSAL) && ! empty($conf->banque->enabled))
{
// Bank Account
print '<tr><td>';
print '<table width="100%" class="nobordernopadding"><tr><td>';
print $langs->trans('BankAccount');
print '</td>';
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 '</tr></table>';
print '</td><td colspan="3">';
if ($action == 'editbankaccount') {
$form->formSelectAccount($_SERVER['PHP_SELF'].'?id='.$object->id, $object->fk_account, 'fk_account', 1);
} else {
$form->formSelectAccount($_SERVER['PHP_SELF'].'?id='.$object->id, $object->fk_account, 'none');
}
print '</td>';
print '</tr>';
// Bank Account
print '<tr><td>';
print '<table width="100%" class="nobordernopadding"><tr><td>';
print $langs->trans('BankAccount');
print '</td>';
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 '</tr></table>';
print '</td><td colspan="3">';
if ($action == 'editbankaccount') {
$form->formSelectAccount($_SERVER['PHP_SELF'].'?id='.$object->id, $object->fk_account, 'fk_account', 1);
} else {
$form->formSelectAccount($_SERVER['PHP_SELF'].'?id='.$object->id, $object->fk_account, 'none');
}
print '</td>';
print '</tr>';
}
// Other attributes
@ -1619,7 +1619,7 @@ if ($action == 'create')
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%">';
// Add free products/services form
@ -1643,7 +1643,7 @@ if ($action == 'create')
}
print '</table>';
print '</div>';
print '</div>';
print "</form>\n";
dol_fiche_end();
@ -1684,15 +1684,15 @@ if ($action == 'create')
$parameters = array();
$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 ($action != 'statut' && $action != 'editline')
{
// Validate
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->validate_advance)))
((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)))
) {
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>';
@ -1733,8 +1733,8 @@ if ($action == 'create')
// Close
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 '>' . $langs->trans('Close') . '</a></div>';
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>';
}
// Clone

View File

@ -579,6 +579,9 @@ textarea.centpercent {
.right {
text-align: <?php print $right; ?>;
}
.justify {
text-align: justify;
}
.nowrap {
white-space: <?php print ($dol_optimize_smallscreen?'normal':'nowrap'); ?>;
}

View File

@ -584,6 +584,9 @@ textarea.centpercent {
.right {
text-align: <?php print $right; ?>;
}
.justify {
text-align: justify;
}
.nowrap {
white-space: <?php print ($dol_optimize_smallscreen?'normal':'nowrap'); ?>;
}

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);
}
$objectpage->htmlheader = trim($tmp);

View File

@ -32,7 +32,7 @@ $path=dirname(__FILE__).'/';
// Test if batch mode
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);
}
@ -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.= " FROM ".MAIN_DB_PREFIX."mailing_cibles as mc";
$sql2.= " WHERE mc.statut < 1 AND mc.fk_mailing = ".$id;
if ($conf->global->MAILING_LIMIT_SENDBYCLI > 0)
{
$sql2.= " LIMIT ".$conf->global->MAILING_LIMIT_SENDBYCLI;
}
if ($conf->global->MAILING_LIMIT_SENDBYCLI > 0)
{
$sql2.= " LIMIT ".$conf->global->MAILING_LIMIT_SENDBYCLI;
}
$resql2=$db->query($sql2);
if ($resql2)
@ -157,31 +157,31 @@ if ($resql)
// Make subtsitutions on topic and body
$other=explode(';',$obj2->other);
$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[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[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:'');
$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[3],2); $other4=(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:'');
$object = null; // Not defined with mass 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
$object = null; // Not defined with mass 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
// Array of possible substitutions (See also file mailing-send.php that should manage same substitutions)
$substitutionarray['__ID__'] = $obj->source_id;
$substitutionarray['__EMAIL__'] = $obj->email;
$substitutionarray['__LASTNAME__'] = $obj->lastname;
$substitutionarray['__FIRSTNAME__'] = $obj->firstname;
$substitutionarray['__MAILTOEMAIL__'] = '<a href="mailto:'.$obj->email.'">'.$obj->email.'</a>';
$substitutionarray['__OTHER1__'] = $other1;
$substitutionarray['__OTHER2__'] = $other2;
$substitutionarray['__OTHER3__'] = $other3;
$substitutionarray['__OTHER4__'] = $other4;
$substitutionarray['__OTHER5__'] = $other5;
$substitutionarray['__USER_SIGNATURE__'] = $signature; // Signature is empty when ran from command line or taken from user in parameter)
// Array of possible substitutions (See also file mailing-send.php that should manage same substitutions)
$substitutionarray['__ID__'] = $obj->source_id;
$substitutionarray['__EMAIL__'] = $obj->email;
$substitutionarray['__LASTNAME__'] = $obj->lastname;
$substitutionarray['__FIRSTNAME__'] = $obj->firstname;
$substitutionarray['__MAILTOEMAIL__'] = '<a href="mailto:'.$obj->email.'">'.$obj->email.'</a>';
$substitutionarray['__OTHER1__'] = $other1;
$substitutionarray['__OTHER2__'] = $other2;
$substitutionarray['__OTHER3__'] = $other3;
$substitutionarray['__OTHER4__'] = $other4;
$substitutionarray['__OTHER5__'] = $other5;
$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['__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['__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>';
$onlinepaymentenabled = 0;
if (! empty($conf->paypal->enabled)) $onlinepaymentenabled++;
@ -232,22 +232,22 @@ if ($resql)
// Fabrication du mail
$trackid='emailing-'.$obj2->source_type.$obj2->source_id;
$mail = new CMailFile(
$newsubject,
$sendto,
$from,
$newmessage,
array(),
array(),
array(),
'',
'',
0,
$msgishtml,
$errorsto,
'',
$trackid,
'',
'emailing'
$newsubject,
$sendto,
$from,
$newmessage,
array(),
array(),
array(),
'',
'',
0,
$msgishtml,
$errorsto,
'',
$trackid,
'',
'emailing'
);
if ($mail->error)
@ -314,7 +314,7 @@ if ($resql)
$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)";
dol_syslog("card.php: set prospect contact status", LOG_DEBUG);
@ -326,9 +326,9 @@ if ($resql)
}
}
if (!empty($conf->global->MAILING_DELAY)) {
sleep($conf->global->MAILING_DELAY);
}
if (!empty($conf->global->MAILING_DELAY)) {
sleep($conf->global->MAILING_DELAY);
}
}
}