Scrutinizer Auto-Fixes

This commit consists of patches automatically generated for this project on https://scrutinizer-ci.com
This commit is contained in:
Scrutinizer Auto-Fixer 2020-10-07 13:01:28 +00:00
parent 96ab66ea5a
commit 1512521d91
81 changed files with 14463 additions and 14463 deletions

View File

@ -47,9 +47,9 @@ $action = GETPOST('action', 'aZ09');
$list_account_main = array( $list_account_main = array(
'ACCOUNTING_ACCOUNT_CUSTOMER', 'ACCOUNTING_ACCOUNT_CUSTOMER',
'ACCOUNTING_ACCOUNT_SUPPLIER', 'ACCOUNTING_ACCOUNT_SUPPLIER',
'SALARIES_ACCOUNTING_ACCOUNT_PAYMENT', 'SALARIES_ACCOUNTING_ACCOUNT_PAYMENT',
); );
$list_account = array(); $list_account = array();
@ -120,9 +120,9 @@ if ($action == 'update') {
$constvalue = GETPOST($constname, 'alpha'); $constvalue = GETPOST($constname, 'alpha');
if (!dolibarr_set_const($db, $constname, $constvalue, 'chaine', 0, '', $conf->entity)) { if (!dolibarr_set_const($db, $constname, $constvalue, 'chaine', 0, '', $conf->entity)) {
$error++; $error++;
} }
} }
if (!$error) { if (!$error) {
@ -159,20 +159,20 @@ print '<table class="noborder centpercent">';
print '<tr class="liste_titre"><td>'.$langs->trans("ThirdParties").' | '.$langs->trans("Users").'</td><td></td></tr>'; print '<tr class="liste_titre"><td>'.$langs->trans("ThirdParties").' | '.$langs->trans("Users").'</td><td></td></tr>';
foreach ($list_account_main as $key) { foreach ($list_account_main as $key) {
print '<tr class="oddeven value">'; print '<tr class="oddeven value">';
// Param // Param
$label = $langs->trans($key); $label = $langs->trans($key);
$keydesc = $key.'_Desc'; $keydesc = $key.'_Desc';
$htmltext = $langs->trans($keydesc); $htmltext = $langs->trans($keydesc);
print '<td class="fieldrequired" width="50%">'; print '<td class="fieldrequired" width="50%">';
print $form->textwithpicto($label, $htmltext); print $form->textwithpicto($label, $htmltext);
print '</td>'; print '</td>';
// Value // Value
print '<td>'; // Do not force class=right, or it align also the content of the select box print '<td>'; // Do not force class=right, or it align also the content of the select box
print $formaccounting->select_account($conf->global->$key, $key, 1, '', 1, 1); print $formaccounting->select_account($conf->global->$key, $key, 1, '', 1, 1);
print '</td>'; print '</td>';
print '</tr>'; print '</tr>';
} }

View File

@ -300,16 +300,16 @@ if ($action == 'create')
if (!empty($user->rights->accounting->fiscalyear->write)) if (!empty($user->rights->accounting->fiscalyear->write))
{ {
/* /*
* Barre d'actions * Barre d'actions
*/ */
print '<div class="tabsAction">'; print '<div class="tabsAction">';
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=edit&token='.newToken().'&id='.$id.'">'.$langs->trans('Modify').'</a>'; print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=edit&token='.newToken().'&id='.$id.'">'.$langs->trans('Modify').'</a>';
// print '<a class="butActionDelete" href="' . $_SERVER["PHP_SELF"] . '?action=delete&token='.newToken().'&id=' . $id . '">' . $langs->trans('Delete') . '</a>'; // print '<a class="butActionDelete" href="' . $_SERVER["PHP_SELF"] . '?action=delete&token='.newToken().'&id=' . $id . '">' . $langs->trans('Delete') . '</a>';
print '</div>'; print '</div>';
} }
} }
} else { } else {

View File

@ -22,7 +22,7 @@
* \brief Setup page to configure journals * \brief Setup page to configure journals
*/ */
if (!defined('CSRFCHECK_WITH_TOKEN')) define('CSRFCHECK_WITH_TOKEN', '1'); // Force use of CSRF protection with tokens even for GET if (!defined('CSRFCHECK_WITH_TOKEN')) define('CSRFCHECK_WITH_TOKEN', '1'); // Force use of CSRF protection with tokens even for GET
require '../../main.inc.php'; require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formadmin.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formadmin.class.php';

View File

@ -59,10 +59,10 @@ if (!$sortfield) $sortfield = "label";
if (!$sortorder) $sortorder = "ASC"; if (!$sortorder) $sortorder = "ASC";
$arrayfields = array( $arrayfields = array(
'subaccount'=>array('label'=>$langs->trans("AccountNumber"), 'checked'=>1), 'subaccount'=>array('label'=>$langs->trans("AccountNumber"), 'checked'=>1),
'label'=>array('label'=>$langs->trans("Label"), 'checked'=>1), 'label'=>array('label'=>$langs->trans("Label"), 'checked'=>1),
'type'=>array('label'=>$langs->trans("Type"), 'checked'=>1), 'type'=>array('label'=>$langs->trans("Type"), 'checked'=>1),
'reconcilable'=>array('label'=>$langs->trans("Reconcilable"), 'checked'=>1) 'reconcilable'=>array('label'=>$langs->trans("Reconcilable"), 'checked'=>1)
); );
if ($conf->global->MAIN_FEATURES_LEVEL < 2) unset($arrayfields['reconcilable']); if ($conf->global->MAIN_FEATURES_LEVEL < 2) unset($arrayfields['reconcilable']);
@ -80,17 +80,17 @@ if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'e
if (empty($reshook)) if (empty($reshook))
{ {
if (!empty($cancel)) $action = ''; if (!empty($cancel)) $action = '';
include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All test are required to be compatible with all browsers if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All test are required to be compatible with all browsers
{ {
$search_subaccount = ""; $search_subaccount = "";
$search_label = ""; $search_label = "";
$search_type = ""; $search_type = "";
$search_array_options = array(); $search_array_options = array();
} }
} }
@ -273,13 +273,13 @@ if ($resql)
print '<div class="warning">'.$langs->trans("WarningCreateSubAccounts").'</div>'; print '<div class="warning">'.$langs->trans("WarningCreateSubAccounts").'</div>';
$varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
$selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
$moreforfilter = ''; $moreforfilter = '';
$massactionbutton = ''; $massactionbutton = '';
print '<div class="div-table-responsive">'; print '<div class="div-table-responsive">';
print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n"; print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
// Line for search fields // Line for search fields
print '<tr class="liste_titre_filter">'; print '<tr class="liste_titre_filter">';
@ -293,7 +293,7 @@ if ($resql)
print '</td>'; print '</td>';
print '</tr>'; print '</tr>';
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
if (!empty($arrayfields['subaccount']['checked'])) print_liste_field_titre($arrayfields['subaccount']['label'], $_SERVER["PHP_SELF"], "subaccount", "", $param, '', $sortfield, $sortorder); if (!empty($arrayfields['subaccount']['checked'])) print_liste_field_titre($arrayfields['subaccount']['label'], $_SERVER["PHP_SELF"], "subaccount", "", $param, '', $sortfield, $sortorder);
if (!empty($arrayfields['label']['checked'])) print_liste_field_titre($arrayfields['label']['label'], $_SERVER["PHP_SELF"], "label", "", $param, '', $sortfield, $sortorder); if (!empty($arrayfields['label']['checked'])) print_liste_field_titre($arrayfields['label']['label'], $_SERVER["PHP_SELF"], "label", "", $param, '', $sortfield, $sortorder);
if (!empty($arrayfields['type']['checked'])) print_liste_field_titre($arrayfields['type']['label'], $_SERVER["PHP_SELF"], "type", "", $param, '', $sortfield, $sortorder, 'center '); if (!empty($arrayfields['type']['checked'])) print_liste_field_titre($arrayfields['type']['label'], $_SERVER["PHP_SELF"], "type", "", $param, '', $sortfield, $sortorder, 'center ');

View File

@ -57,80 +57,80 @@ class BookKeeping extends CommonObject
*/ */
public $id; public $id;
/** /**
* @var string Date of source document, in db date NOT NULL * @var string Date of source document, in db date NOT NULL
*/ */
public $doc_date; public $doc_date;
/** /**
* @var int Deadline for payment * @var int Deadline for payment
*/ */
public $date_lim_reglement; public $date_lim_reglement;
/** /**
* @var string doc_type * @var string doc_type
*/ */
public $doc_type; public $doc_type;
/** /**
* @var string doc_ref * @var string doc_ref
*/ */
public $doc_ref; public $doc_ref;
/** /**
* @var int ID * @var int ID
*/ */
public $fk_doc; public $fk_doc;
/** /**
* @var int ID * @var int ID
*/ */
public $fk_docdet; public $fk_docdet;
/** /**
* @var string thirdparty code * @var string thirdparty code
*/ */
public $thirdparty_code; public $thirdparty_code;
/** /**
* @var string subledger account * @var string subledger account
*/ */
public $subledger_account; public $subledger_account;
/** /**
* @var string subledger label * @var string subledger label
*/ */
public $subledger_label; public $subledger_label;
/** /**
* @var string doc_type * @var string doc_type
*/ */
public $numero_compte; public $numero_compte;
/** /**
* @var string label compte * @var string label compte
*/ */
public $label_compte; public $label_compte;
/** /**
* @var string label operation * @var string label operation
*/ */
public $label_operation; public $label_operation;
/** /**
* @var float FEC:Debit * @var float FEC:Debit
*/ */
public $debit; public $debit;
/** /**
* @var float FEC:Credit * @var float FEC:Credit
*/ */
public $credit; public $credit;
/** /**
* @var float FEC:Amount (Not necessary) * @var float FEC:Amount (Not necessary)
* @deprecated Use $amount * @deprecated Use $amount
*/ */
public $montant; public $montant;
/** /**
@ -138,34 +138,34 @@ class BookKeeping extends CommonObject
*/ */
public $amount; public $amount;
/** /**
* @var string FEC:Sens (Not necessary) * @var string FEC:Sens (Not necessary)
*/ */
public $sens; public $sens;
/** /**
* @var int ID * @var int ID
*/ */
public $fk_user_author; public $fk_user_author;
/** /**
* @var string key for import * @var string key for import
*/ */
public $import_key; public $import_key;
/** /**
* @var string code journal * @var string code journal
*/ */
public $code_journal; public $code_journal;
/** /**
* @var string label journal * @var string label journal
*/ */
public $journal_label; public $journal_label;
/** /**
* @var int accounting transaction id * @var int accounting transaction id
*/ */
public $piece_num; public $piece_num;
/** /**
@ -179,8 +179,8 @@ class BookKeeping extends CommonObject
* *
* @param DoliDb $db Database handler * @param DoliDb $db Database handler
*/ */
public function __construct(DoliDB $db) public function __construct(DoliDB $db)
{ {
$this->db = $db; $this->db = $db;
} }
@ -191,8 +191,8 @@ class BookKeeping extends CommonObject
* @param bool $notrigger false=launch triggers after, true=disable triggers * @param bool $notrigger false=launch triggers after, true=disable triggers
* @return int <0 if KO, Id of created object if OK * @return int <0 if KO, Id of created object if OK
*/ */
public function create(User $user, $notrigger = false) public function create(User $user, $notrigger = false)
{ {
global $conf, $langs; global $conf, $langs;
dol_syslog(__METHOD__, LOG_DEBUG); dol_syslog(__METHOD__, LOG_DEBUG);
@ -504,11 +504,11 @@ class BookKeeping extends CommonObject
* @param string $mode Mode * @param string $mode Mode
* @return int <0 if KO, Id of created object if OK * @return int <0 if KO, Id of created object if OK
*/ */
public function createStd(User $user, $notrigger = false, $mode = '') public function createStd(User $user, $notrigger = false, $mode = '')
{ {
global $conf, $langs; global $conf, $langs;
$langs->loadLangs(array("accountancy", "bills", "compta")); $langs->loadLangs(array("accountancy", "bills", "compta"));
dol_syslog(__METHOD__, LOG_DEBUG); dol_syslog(__METHOD__, LOG_DEBUG);
@ -578,7 +578,7 @@ class BookKeeping extends CommonObject
$now = dol_now(); $now = dol_now();
// Check parameters // Check parameters
$this->journal_label = $langs->trans($this->journal_label); $this->journal_label = $langs->trans($this->journal_label);
// Insert request // Insert request
$sql = 'INSERT INTO '.MAIN_DB_PREFIX.$this->table_element.$mode.' ('; $sql = 'INSERT INTO '.MAIN_DB_PREFIX.$this->table_element.$mode.' (';
@ -673,8 +673,8 @@ class BookKeeping extends CommonObject
* *
* @return int <0 if KO, 0 if not found, >0 if OK * @return int <0 if KO, 0 if not found, >0 if OK
*/ */
public function fetch($id, $ref = null, $mode = '') public function fetch($id, $ref = null, $mode = '')
{ {
global $conf; global $conf;
dol_syslog(__METHOD__, LOG_DEBUG); dol_syslog(__METHOD__, LOG_DEBUG);
@ -771,8 +771,8 @@ class BookKeeping extends CommonObject
* *
* @return int <0 if KO, >=0 if OK * @return int <0 if KO, >=0 if OK
*/ */
public function fetchAllByAccount($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, array $filter = array(), $filtermode = 'AND') public function fetchAllByAccount($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, array $filter = array(), $filtermode = 'AND')
{ {
global $conf; global $conf;
dol_syslog(__METHOD__, LOG_DEBUG); dol_syslog(__METHOD__, LOG_DEBUG);
@ -904,11 +904,11 @@ class BookKeeping extends CommonObject
* @param int $offset Offset limit * @param int $offset Offset limit
* @param array $filter Filter array * @param array $filter Filter array
* @param string $filtermode Filter mode (AND or OR) * @param string $filtermode Filter mode (AND or OR)
* @param int $showAlreadyExportMovements Show movements when field 'date_export' is not empty (0:No / 1:Yes (Default)) * @param int $showAlreadyExportMovements Show movements when field 'date_export' is not empty (0:No / 1:Yes (Default))
* @return int <0 if KO, >0 if OK * @return int <0 if KO, >0 if OK
*/ */
public function fetchAll($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, array $filter = array(), $filtermode = 'AND', $showAlreadyExportMovements = 1) public function fetchAll($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, array $filter = array(), $filtermode = 'AND', $showAlreadyExportMovements = 1)
{ {
global $conf; global $conf;
dol_syslog(__METHOD__, LOG_DEBUG); dol_syslog(__METHOD__, LOG_DEBUG);
@ -940,7 +940,7 @@ class BookKeeping extends CommonObject
$sql .= " t.date_creation,"; $sql .= " t.date_creation,";
$sql .= " t.date_lim_reglement,"; $sql .= " t.date_lim_reglement,";
$sql .= " t.tms as date_modification,"; $sql .= " t.tms as date_modification,";
$sql .= " t.date_export"; $sql .= " t.date_export";
$sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t'; $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t';
// Manage filter // Manage filter
$sqlwhere = array(); $sqlwhere = array();
@ -960,8 +960,8 @@ class BookKeeping extends CommonObject
$sqlwhere[] = $key.'\''.$this->db->idate($value).'\''; $sqlwhere[] = $key.'\''.$this->db->idate($value).'\'';
} elseif ($key == 't.tms>=' || $key == 't.tms<=') { } elseif ($key == 't.tms>=' || $key == 't.tms<=') {
$sqlwhere[] = $key.'\''.$this->db->idate($value).'\''; $sqlwhere[] = $key.'\''.$this->db->idate($value).'\'';
} elseif ($key == 't.date_export>=' || $key == 't.date_export<=') { } elseif ($key == 't.date_export>=' || $key == 't.date_export<=') {
$sqlwhere[] = $key.'\''.$this->db->idate($value).'\''; $sqlwhere[] = $key.'\''.$this->db->idate($value).'\'';
} elseif ($key == 't.credit' || $key == 't.debit') { } elseif ($key == 't.credit' || $key == 't.debit') {
$sqlwhere[] = natural_search($key, $value, 1, 1); $sqlwhere[] = natural_search($key, $value, 1, 1);
} else { } else {
@ -970,9 +970,9 @@ class BookKeeping extends CommonObject
} }
} }
$sql .= ' WHERE t.entity IN ('.getEntity('accountancy').')'; $sql .= ' WHERE t.entity IN ('.getEntity('accountancy').')';
if ($showAlreadyExportMovements == 0) { if ($showAlreadyExportMovements == 0) {
$sql .= " AND t.date_export IS NULL"; $sql .= " AND t.date_export IS NULL";
} }
if (count($sqlwhere) > 0) { if (count($sqlwhere) > 0) {
$sql .= ' AND '.implode(' '.$filtermode.' ', $sqlwhere); $sql .= ' AND '.implode(' '.$filtermode.' ', $sqlwhere);
} }
@ -1020,7 +1020,7 @@ class BookKeeping extends CommonObject
$line->date_creation = $this->db->jdate($obj->date_creation); $line->date_creation = $this->db->jdate($obj->date_creation);
$line->date_lim_reglement = $this->db->jdate($obj->date_lim_reglement); $line->date_lim_reglement = $this->db->jdate($obj->date_lim_reglement);
$line->date_modification = $this->db->jdate($obj->date_modification); $line->date_modification = $this->db->jdate($obj->date_modification);
$line->date_export = $this->db->jdate($obj->date_export); $line->date_export = $this->db->jdate($obj->date_export);
$this->lines[] = $line; $this->lines[] = $line;
@ -1133,8 +1133,8 @@ class BookKeeping extends CommonObject
* @param string $mode Mode ('' or _tmp') * @param string $mode Mode ('' or _tmp')
* @return int <0 if KO, >0 if OK * @return int <0 if KO, >0 if OK
*/ */
public function update(User $user, $notrigger = false, $mode = '') public function update(User $user, $notrigger = false, $mode = '')
{ {
$error = 0; $error = 0;
dol_syslog(__METHOD__, LOG_DEBUG); dol_syslog(__METHOD__, LOG_DEBUG);
@ -1300,8 +1300,8 @@ class BookKeeping extends CommonObject
* @param string $mode Mode * @param string $mode Mode
* @return int <0 if KO, >0 if OK * @return int <0 if KO, >0 if OK
*/ */
public function delete(User $user, $notrigger = false, $mode = '') public function delete(User $user, $notrigger = false, $mode = '')
{ {
dol_syslog(__METHOD__, LOG_DEBUG); dol_syslog(__METHOD__, LOG_DEBUG);
$error = 0; $error = 0;
@ -1348,8 +1348,8 @@ class BookKeeping extends CommonObject
* @param string $importkey Import key * @param string $importkey Import key
* @return int Result * @return int Result
*/ */
public function deleteByImportkey($importkey) public function deleteByImportkey($importkey)
{ {
$this->db->begin(); $this->db->begin();
// first check if line not yet in bookkeeping // first check if line not yet in bookkeeping
@ -1379,11 +1379,11 @@ class BookKeeping extends CommonObject
* @param int $delmonth Month * @param int $delmonth Month
* @return int <0 if KO, >0 if OK * @return int <0 if KO, >0 if OK
*/ */
public function deleteByYearAndJournal($delyear = 0, $journal = '', $mode = '', $delmonth = 0) public function deleteByYearAndJournal($delyear = 0, $journal = '', $mode = '', $delmonth = 0)
{ {
global $langs; global $langs;
if (empty($delyear) && empty($journal)) if (empty($delyear) && empty($journal))
{ {
$this->error = 'ErrorOneFieldRequired'; $this->error = 'ErrorOneFieldRequired';
return -1; return -1;
@ -1428,8 +1428,8 @@ class BookKeeping extends CommonObject
* @param int $piecenum Piecenum to delete * @param int $piecenum Piecenum to delete
* @return int Result * @return int Result
*/ */
public function deleteMvtNum($piecenum) public function deleteMvtNum($piecenum)
{ {
global $conf; global $conf;
$this->db->begin(); $this->db->begin();
@ -1463,8 +1463,8 @@ class BookKeeping extends CommonObject
* @param int $fromid Id of object to clone * @param int $fromid Id of object to clone
* @return int New id of clone * @return int New id of clone
*/ */
public function createFromClone(User $user, $fromid) public function createFromClone(User $user, $fromid)
{ {
dol_syslog(__METHOD__, LOG_DEBUG); dol_syslog(__METHOD__, LOG_DEBUG);
$error = 0; $error = 0;
@ -1511,8 +1511,8 @@ class BookKeeping extends CommonObject
* *
* @return void * @return void
*/ */
public function initAsSpecimen() public function initAsSpecimen()
{ {
global $user; global $user;
$now = dol_now(); $now = dol_now();
@ -1548,8 +1548,8 @@ class BookKeeping extends CommonObject
* @param string $mode Mode * @param string $mode Mode
* @return int <0 if KO, >0 if OK * @return int <0 if KO, >0 if OK
*/ */
public function fetchPerMvt($piecenum, $mode = '') public function fetchPerMvt($piecenum, $mode = '')
{ {
global $conf; global $conf;
$sql = "SELECT piece_num,doc_date,code_journal,journal_label,doc_ref,doc_type,date_creation"; $sql = "SELECT piece_num,doc_date,code_journal,journal_label,doc_ref,doc_type,date_creation";
@ -1613,8 +1613,8 @@ class BookKeeping extends CommonObject
* @param string $mode Mode * @param string $mode Mode
* @return int <0 if KO, >0 if OK * @return int <0 if KO, >0 if OK
*/ */
public function fetchAllPerMvt($piecenum, $mode = '') public function fetchAllPerMvt($piecenum, $mode = '')
{ {
global $conf; global $conf;
$sql = "SELECT rowid, doc_date, doc_type,"; $sql = "SELECT rowid, doc_date, doc_type,";
@ -1664,16 +1664,16 @@ class BookKeeping extends CommonObject
return 1; return 1;
} }
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/** /**
* Export bookkeeping * Export bookkeeping
* *
* @param string $model Model * @param string $model Model
* @return int Result * @return int Result
*/ */
public function export_bookkeeping($model = 'ebp') public function export_bookkeeping($model = 'ebp')
{ {
// phpcs:enable // phpcs:enable
global $conf; global $conf;
$sql = "SELECT rowid, doc_date, doc_type,"; $sql = "SELECT rowid, doc_date, doc_type,";
@ -1739,10 +1739,10 @@ class BookKeeping extends CommonObject
$this->db->begin(); $this->db->begin();
if ($direction == 0) if ($direction == 0)
{ {
$next_piecenum = $this->getNextNumMvt(); $next_piecenum = $this->getNextNumMvt();
$now = dol_now(); $now = dol_now();
if ($next_piecenum < 0) { if ($next_piecenum < 0) {
$error++; $error++;
@ -1819,22 +1819,22 @@ class BookKeeping extends CommonObject
*/ */
} }
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/** /**
* Return list of accounts with label by chart of accounts * Return list of accounts with label by chart of accounts
* *
* @param string $selectid Preselected chart of accounts * @param string $selectid Preselected chart of accounts
* @param string $htmlname Name of field in html form * @param string $htmlname Name of field in html form
* @param int $showempty Add an empty field * @param int $showempty Add an empty field
* @param array $event Event options * @param array $event Event options
* @param int $select_in Value is a aa.rowid (0 default) or aa.account_number (1) * @param int $select_in Value is a aa.rowid (0 default) or aa.account_number (1)
* @param int $select_out Set value returned by select 0=rowid (default), 1=account_number * @param int $select_out Set value returned by select 0=rowid (default), 1=account_number
* @param int $aabase Set accounting_account base class to display empty=all or from 1 to 8 will display only account beginning by this number * @param int $aabase Set accounting_account base class to display empty=all or from 1 to 8 will display only account beginning by this number
* @return string String with HTML select * @return string String with HTML select
*/ */
public function select_account($selectid, $htmlname = 'account', $showempty = 0, $event = array(), $select_in = 0, $select_out = 0, $aabase = '') public function select_account($selectid, $htmlname = 'account', $showempty = 0, $event = array(), $select_in = 0, $select_out = 0, $aabase = '')
{ {
// phpcs:enable // phpcs:enable
global $conf; global $conf;
require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php';
@ -1891,7 +1891,7 @@ class BookKeeping extends CommonObject
return $out; return $out;
} }
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/** /**
* Description of a root accounting account * Description of a root accounting account
* *
@ -1900,7 +1900,7 @@ class BookKeeping extends CommonObject
*/ */
public function get_compte_racine($account = null) public function get_compte_racine($account = null)
{ {
// phpcs:enable // phpcs:enable
global $conf; global $conf;
$pcgver = $conf->global->CHARTOFACCOUNTS; $pcgver = $conf->global->CHARTOFACCOUNTS;
@ -1932,16 +1932,16 @@ class BookKeeping extends CommonObject
} }
} }
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/** /**
* Description of accounting account * Description of accounting account
* *
* @param string $account Accounting account * @param string $account Accounting account
* @return string Account desc * @return string Account desc
*/ */
public function get_compte_desc($account = null) public function get_compte_desc($account = null)
{ {
// phpcs:enable // phpcs:enable
global $conf; global $conf;
$pcgver = $conf->global->CHARTOFACCOUNTS; $pcgver = $conf->global->CHARTOFACCOUNTS;
@ -1989,13 +1989,13 @@ class BookKeepingLine
public $doc_ref; public $doc_ref;
/** /**
* @var int ID * @var int ID
*/ */
public $fk_doc; public $fk_doc;
/** /**
* @var int ID * @var int ID
*/ */
public $fk_docdet; public $fk_docdet;
public $thirdparty_code; public $thirdparty_code;
@ -2007,26 +2007,26 @@ class BookKeepingLine
public $debit; public $debit;
public $credit; public $credit;
/** /**
* @var float Amount * @var float Amount
* @deprecated see $amount * @deprecated see $amount
*/ */
public $montant; public $montant;
/** /**
* @var float Amount * @var float Amount
*/ */
public $amount; public $amount;
/** /**
* @var string Sens * @var string Sens
*/ */
public $sens; public $sens;
public $lettering_code; public $lettering_code;
/** /**
* @var int ID * @var int ID
*/ */
public $fk_user_author; public $fk_user_author;
public $import_key; public $import_key;
@ -2035,17 +2035,17 @@ class BookKeepingLine
public $piece_num; public $piece_num;
/** /**
* @var integer|string date_creation * @var integer|string date_creation
*/ */
public $date_creation; public $date_creation;
/** /**
* @var integer|string $date_modification; * @var integer|string $date_modification;
*/ */
public $date_modification; public $date_modification;
/** /**
* @var integer|string $date_export; * @var integer|string $date_export;
*/ */
public $date_export; public $date_export;
} }

View File

@ -180,10 +180,10 @@ if ($result) {
$account_supplier = (($conf->global->ACCOUNTING_ACCOUNT_SUPPLIER != "") ? $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER : 'NotDefined'); // NotDefined is a reserved word $account_supplier = (($conf->global->ACCOUNTING_ACCOUNT_SUPPLIER != "") ? $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER : 'NotDefined'); // NotDefined is a reserved word
$account_customer = (($conf->global->ACCOUNTING_ACCOUNT_CUSTOMER != "") ? $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER : 'NotDefined'); // NotDefined is a reserved word $account_customer = (($conf->global->ACCOUNTING_ACCOUNT_CUSTOMER != "") ? $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER : 'NotDefined'); // NotDefined is a reserved word
$account_employee = (!empty($conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT) ? $conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT : 'NotDefined'); // NotDefined is a reserved word $account_employee = (!empty($conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT) ? $conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT : 'NotDefined'); // NotDefined is a reserved word
$account_pay_vat = (!empty($conf->global->ACCOUNTING_VAT_PAY_ACCOUNT) ? $conf->global->ACCOUNTING_VAT_PAY_ACCOUNT : 'NotDefined'); // NotDefined is a reserved word $account_pay_vat = (!empty($conf->global->ACCOUNTING_VAT_PAY_ACCOUNT) ? $conf->global->ACCOUNTING_VAT_PAY_ACCOUNT : 'NotDefined'); // NotDefined is a reserved word
$account_pay_donation = (!empty($conf->global->DONATION_ACCOUNTINGACCOUNT) ? $conf->global->DONATION_ACCOUNTINGACCOUNT : 'NotDefined'); // NotDefined is a reserved word $account_pay_donation = (!empty($conf->global->DONATION_ACCOUNTINGACCOUNT) ? $conf->global->DONATION_ACCOUNTINGACCOUNT : 'NotDefined'); // NotDefined is a reserved word
$account_pay_subscription = (!empty($conf->global->ADHERENT_SUBSCRIPTION_ACCOUNTINGACCOUNT) ? $conf->global->ADHERENT_SUBSCRIPTION_ACCOUNTINGACCOUNT : 'NotDefined'); // NotDefined is a reserved word $account_pay_subscription = (!empty($conf->global->ADHERENT_SUBSCRIPTION_ACCOUNTINGACCOUNT) ? $conf->global->ADHERENT_SUBSCRIPTION_ACCOUNTINGACCOUNT : 'NotDefined'); // NotDefined is a reserved word
$account_transfer = (!empty($conf->global->ACCOUNTING_ACCOUNT_TRANSFER_CASH) ? $conf->global->ACCOUNTING_ACCOUNT_TRANSFER_CASH : 'NotDefined'); // NotDefined is a reserved word $account_transfer = (!empty($conf->global->ACCOUNTING_ACCOUNT_TRANSFER_CASH) ? $conf->global->ACCOUNTING_ACCOUNT_TRANSFER_CASH : 'NotDefined'); // NotDefined is a reserved word
$tabcompany = array(); $tabcompany = array();
$tabuser = array(); $tabuser = array();

View File

@ -110,7 +110,7 @@ if ($user->rights->adherent->cotisation->creer && $action == 'update' && !$cance
} else { } else {
$db->rollback(); $db->rollback();
if ($object->error) { if ($object->error) {
$errmsg = $object->error; $errmsg = $object->error;
} else { } else {
foreach ($object->errors as $error) { foreach ($object->errors as $error) {
@ -128,13 +128,13 @@ if ($user->rights->adherent->cotisation->creer && $action == 'update' && !$cance
if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->adherent->cotisation->creer) { if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->adherent->cotisation->creer) {
$result = $object->fetch($rowid); $result = $object->fetch($rowid);
$result = $object->delete($user); $result = $object->delete($user);
if ($result > 0) { if ($result > 0) {
header("Location: ".DOL_URL_ROOT."/adherents/card.php?rowid=".$object->fk_adherent); header("Location: ".DOL_URL_ROOT."/adherents/card.php?rowid=".$object->fk_adherent);
exit; exit;
} else { } else {
$mesg = $adh->error; $mesg = $adh->error;
} }
} }
@ -159,7 +159,7 @@ if ($user->rights->adherent->cotisation->creer && $action == 'edit') {
* *
********************************************/ ********************************************/
$object->fetch($rowid); $object->fetch($rowid);
$result = $adh->fetch($object->fk_adherent); $result = $adh->fetch($object->fk_adherent);
$head = subscription_prepare_head($object); $head = subscription_prepare_head($object);
@ -172,13 +172,13 @@ if ($user->rights->adherent->cotisation->creer && $action == 'edit') {
dol_fiche_head($head, 'general', $langs->trans("Subscription"), 0, 'payment'); dol_fiche_head($head, 'general', $langs->trans("Subscription"), 0, 'payment');
$linkback = '<a href="'.DOL_URL_ROOT.'/adherents/subscription/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>'; $linkback = '<a href="'.DOL_URL_ROOT.'/adherents/subscription/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
print "\n"; print "\n";
print '<table class="border centpercent">'; print '<table class="border centpercent">';
// Ref // Ref
print '<tr><td class="titlefieldcreate">'.$langs->trans("Ref").'</td>'; print '<tr><td class="titlefieldcreate">'.$langs->trans("Ref").'</td>';
print '<td class="valeur" colspan="3">'; print '<td class="valeur" colspan="3">';
print $form->showrefnav($object, 'rowid', $linkback, 1); print $form->showrefnav($object, 'rowid', $linkback, 1);
print '</td></tr>'; print '</td></tr>';
@ -195,24 +195,24 @@ if ($user->rights->adherent->cotisation->creer && $action == 'edit') {
print $form->selectarray("typeid", $adht->liste_array(), (GETPOSTISSET("typeid") ? GETPOST("typeid") : $object->fk_type)); print $form->selectarray("typeid", $adht->liste_array(), (GETPOSTISSET("typeid") ? GETPOST("typeid") : $object->fk_type));
print'</td></tr>'; print'</td></tr>';
// Date start subscription // Date start subscription
print '<tr><td>'.$langs->trans("DateSubscription").'</td><td class="valeur" colspan="2">'; print '<tr><td>'.$langs->trans("DateSubscription").'</td><td class="valeur" colspan="2">';
print $form->selectDate($object->dateh, 'datesub', 1, 1, 0, 'update', 1); print $form->selectDate($object->dateh, 'datesub', 1, 1, 0, 'update', 1);
print '</td>'; print '</td>';
print '</tr>'; print '</tr>';
// Date end subscription // Date end subscription
print '<tr><td>'.$langs->trans("DateEndSubscription").'</td><td class="valeur" colspan="2">'; print '<tr><td>'.$langs->trans("DateEndSubscription").'</td><td class="valeur" colspan="2">';
print $form->selectDate($object->datef, 'datesubend', 0, 0, 0, 'update', 1); print $form->selectDate($object->datef, 'datesubend', 0, 0, 0, 'update', 1);
print '</td>'; print '</td>';
print '</tr>'; print '</tr>';
// Amount // Amount
print '<tr><td>'.$langs->trans("Amount").'</td><td class="valeur" colspan="2">'; print '<tr><td>'.$langs->trans("Amount").'</td><td class="valeur" colspan="2">';
print '<input type="text" class="flat" size="10" name="amount" value="'.price($object->amount).'"></td></tr>'; print '<input type="text" class="flat" size="10" name="amount" value="'.price($object->amount).'"></td></tr>';
// Label // Label
print '<tr><td>'.$langs->trans("Label").'</td><td class="valeur" colspan="2">'; print '<tr><td>'.$langs->trans("Label").'</td><td class="valeur" colspan="2">';
print '<input type="text" class="flat" size="60" name="note" value="'.$object->note.'"></td></tr>'; print '<input type="text" class="flat" size="60" name="note" value="'.$object->note.'"></td></tr>';
// Bank line // Bank line
@ -234,11 +234,11 @@ if ($user->rights->adherent->cotisation->creer && $action == 'edit') {
dol_fiche_end(); dol_fiche_end();
print '<div class="center">'; print '<div class="center">';
print '<input type="submit" class="button" name="submit" value="'.$langs->trans("Save").'">'; print '<input type="submit" class="button" name="submit" value="'.$langs->trans("Save").'">';
print ' &nbsp; &nbsp; &nbsp; '; print ' &nbsp; &nbsp; &nbsp; ';
print '<input type="submit" class="button" name="cancel" value="'.$langs->trans("Cancel").'">'; print '<input type="submit" class="button" name="cancel" value="'.$langs->trans("Cancel").'">';
print '</div>'; print '</div>';
print '</form>'; print '</form>';
print "\n"; print "\n";
@ -251,69 +251,69 @@ if ($rowid && $action != 'edit') {
* *
********************************************/ ********************************************/
$result = $object->fetch($rowid); $result = $object->fetch($rowid);
$result = $adh->fetch($object->fk_adherent); $result = $adh->fetch($object->fk_adherent);
$head = subscription_prepare_head($object); $head = subscription_prepare_head($object);
dol_fiche_head($head, 'general', $langs->trans("Subscription"), -1, 'payment'); dol_fiche_head($head, 'general', $langs->trans("Subscription"), -1, 'payment');
// Confirmation to delete subscription // Confirmation to delete subscription
if ($action == 'delete') { if ($action == 'delete') {
//$formquestion=array(); //$formquestion=array();
//$formquestion['text']='<b>'.$langs->trans("ThisWillAlsoDeleteBankRecord").'</b>'; //$formquestion['text']='<b>'.$langs->trans("ThisWillAlsoDeleteBankRecord").'</b>';
$text = $langs->trans("ConfirmDeleteSubscription"); $text = $langs->trans("ConfirmDeleteSubscription");
if (!empty($conf->banque->enabled) && !empty($conf->global->ADHERENT_BANK_USE)) $text .= '<br>'.img_warning().' '.$langs->trans("ThisWillAlsoDeleteBankRecord"); if (!empty($conf->banque->enabled) && !empty($conf->global->ADHERENT_BANK_USE)) $text .= '<br>'.img_warning().' '.$langs->trans("ThisWillAlsoDeleteBankRecord");
print $form->formconfirm($_SERVER["PHP_SELF"]."?rowid=".$object->id, $langs->trans("DeleteSubscription"), $text, "confirm_delete", $formquestion, 0, 1); print $form->formconfirm($_SERVER["PHP_SELF"]."?rowid=".$object->id, $langs->trans("DeleteSubscription"), $text, "confirm_delete", $formquestion, 0, 1);
} }
print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">'; print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">';
print '<input type="hidden" name="token" value="'.newToken().'">'; print '<input type="hidden" name="token" value="'.newToken().'">';
$linkback = '<a href="'.DOL_URL_ROOT.'/adherents/subscription/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>'; $linkback = '<a href="'.DOL_URL_ROOT.'/adherents/subscription/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
dol_banner_tab($object, 'rowid', $linkback, 1); dol_banner_tab($object, 'rowid', $linkback, 1);
print '<div class="fichecenter">'; print '<div class="fichecenter">';
print '<div class="underbanner clearboth"></div>'; print '<div class="underbanner clearboth"></div>';
print '<table class="border centpercent">'; print '<table class="border centpercent">';
// Member // Member
$adh->ref = $adh->getFullName($langs); $adh->ref = $adh->getFullName($langs);
print '<tr>'; print '<tr>';
print '<td class="titlefield">'.$langs->trans("Member").'</td><td class="valeur">'.$adh->getNomUrl(1, 0, 'subscription').'</td>'; print '<td class="titlefield">'.$langs->trans("Member").'</td><td class="valeur">'.$adh->getNomUrl(1, 0, 'subscription').'</td>';
print '</tr>'; print '</tr>';
// Type // Type
print '<tr>'; print '<tr>';
print '<td class="titlefield">'.$langs->trans("Type").'</td>'; print '<td class="titlefield">'.$langs->trans("Type").'</td>';
print '<td class="valeur">'; print '<td class="valeur">';
if ($object->fk_type > 0 || $adh->typeid > 0) { if ($object->fk_type > 0 || $adh->typeid > 0) {
$typeid = ($object->fk_type > 0 ? $object->fk_type : $adh->typeid); $typeid = ($object->fk_type > 0 ? $object->fk_type : $adh->typeid);
$adht->fetch($typeid); $adht->fetch($typeid);
print $adht->getNomUrl(1); print $adht->getNomUrl(1);
} else { } else {
print $langs->trans("NoType"); print $langs->trans("NoType");
} }
print '</td></tr>'; print '</td></tr>';
// Date subscription // Date subscription
print '<tr>'; print '<tr>';
print '<td>'.$langs->trans("DateSubscription").'</td><td class="valeur">'.dol_print_date($object->dateh, 'day').'</td>'; print '<td>'.$langs->trans("DateSubscription").'</td><td class="valeur">'.dol_print_date($object->dateh, 'day').'</td>';
print '</tr>'; print '</tr>';
// Date end subscription // Date end subscription
print '<tr>'; print '<tr>';
print '<td>'.$langs->trans("DateEndSubscription").'</td><td class="valeur">'.dol_print_date($object->datef, 'day').'</td>'; print '<td>'.$langs->trans("DateEndSubscription").'</td><td class="valeur">'.dol_print_date($object->datef, 'day').'</td>';
print '</tr>'; print '</tr>';
// Amount // Amount
print '<tr><td>'.$langs->trans("Amount").'</td><td class="valeur">'.price($object->amount).'</td></tr>'; print '<tr><td>'.$langs->trans("Amount").'</td><td class="valeur">'.price($object->amount).'</td></tr>';
// Label // Label
print '<tr><td>'.$langs->trans("Label").'</td><td class="valeur">'.$object->note.'</td></tr>'; print '<tr><td>'.$langs->trans("Label").'</td><td class="valeur">'.$object->note.'</td></tr>';
// Bank line // Bank line
if (!empty($conf->banque->enabled)) { if (!empty($conf->banque->enabled)) {
@ -330,20 +330,20 @@ if ($rowid && $action != 'edit') {
} }
} }
print "</table>\n"; print "</table>\n";
print '</div>'; print '</div>';
print '</form>'; print '</form>';
dol_fiche_end(); dol_fiche_end();
/* /*
* Barre d'actions * Barre d'actions
* *
*/ */
print '<div class="tabsAction">'; print '<div class="tabsAction">';
if ($user->rights->adherent->cotisation->creer) { if ($user->rights->adherent->cotisation->creer) {
if (!$bankline->rappro) { if (!$bankline->rappro) {
print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"]."?rowid=".$object->id.'&action=edit&token='.newToken().'">'.$langs->trans("Modify")."</a></div>"; print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"]."?rowid=".$object->id.'&action=edit&token='.newToken().'">'.$langs->trans("Modify")."</a></div>";
} else { } else {
@ -351,19 +351,19 @@ if ($rowid && $action != 'edit') {
} }
} }
// Delete // Delete
if ($user->rights->adherent->cotisation->creer) { if ($user->rights->adherent->cotisation->creer) {
print '<div class="inline-block divButAction"><a class="butActionDelete" href="'.$_SERVER["PHP_SELF"]."?rowid=".$object->id.'&action=delete&token='.newToken().'">'.$langs->trans("Delete")."</a></div>\n"; print '<div class="inline-block divButAction"><a class="butActionDelete" href="'.$_SERVER["PHP_SELF"]."?rowid=".$object->id.'&action=delete&token='.newToken().'">'.$langs->trans("Delete")."</a></div>\n";
} }
print '</div>'; print '</div>';
print '<div class="fichecenter"><div class="fichehalfleft">'; print '<div class="fichecenter"><div class="fichehalfleft">';
print '<a name="builddoc"></a>'; // ancre print '<a name="builddoc"></a>'; // ancre
// Documents generes // Documents generes
/* /*
$filename = dol_sanitizeFileName($object->ref); $filename = dol_sanitizeFileName($object->ref);
$filedir = $conf->facture->dir_output . '/' . dol_sanitizeFileName($object->ref); $filedir = $conf->facture->dir_output . '/' . dol_sanitizeFileName($object->ref);
$urlsource = $_SERVER['PHP_SELF'] . '?facid=' . $object->id; $urlsource = $_SERVER['PHP_SELF'] . '?facid=' . $object->id;
@ -375,23 +375,23 @@ if ($rowid && $action != 'edit') {
*/ */
// Show links to link elements // Show links to link elements
//$linktoelem = $form->showLinkToObjectBlock($object, null, array('subscription')); //$linktoelem = $form->showLinkToObjectBlock($object, null, array('subscription'));
$somethingshown = $form->showLinkedObjectBlock($object, ''); $somethingshown = $form->showLinkedObjectBlock($object, '');
// Show links to link elements // Show links to link elements
/*$linktoelem = $form->showLinkToObjectBlock($object,array('order')); /*$linktoelem = $form->showLinkToObjectBlock($object,array('order'));
if ($linktoelem) print ($somethingshown?'':'<br>').$linktoelem; if ($linktoelem) print ($somethingshown?'':'<br>').$linktoelem;
*/ */
print '</div><div class="fichehalfright"><div class="ficheaddleft">'; print '</div><div class="fichehalfright"><div class="ficheaddleft">';
// List of actions on element // List of actions on element
/* /*
include_once DOL_DOCUMENT_ROOT . '/core/class/html.formactions.class.php'; include_once DOL_DOCUMENT_ROOT . '/core/class/html.formactions.class.php';
$formactions = new FormActions($db); $formactions = new FormActions($db);
$somethingshown = $formactions->showactions($object, 'invoice', $socid, 1); $somethingshown = $formactions->showactions($object, 'invoice', $socid, 1);
*/ */
print '</div></div></div>'; print '</div></div></div>';
} }
// End of page // End of page

View File

@ -83,17 +83,17 @@ include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
// Purge search criteria // Purge search criteria
if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All tests are required to be compatible with all browsers if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All tests are required to be compatible with all browsers
{ {
$defaulturl = ''; $defaulturl = '';
$defaultkey = ''; $defaultkey = '';
$defaultvalue = ''; $defaultvalue = '';
$toselect = ''; $toselect = '';
$search_array_options = array(); $search_array_options = array();
} }
if ($action == 'setMAIN_ENABLE_DEFAULT_VALUES') if ($action == 'setMAIN_ENABLE_DEFAULT_VALUES')
{ {
if (GETPOST('value')) dolibarr_set_const($db, 'MAIN_ENABLE_DEFAULT_VALUES', 1, 'chaine', 0, '', $conf->entity); if (GETPOST('value')) dolibarr_set_const($db, 'MAIN_ENABLE_DEFAULT_VALUES', 1, 'chaine', 0, '', $conf->entity);
else dolibarr_set_const($db, 'MAIN_ENABLE_DEFAULT_VALUES', 0, 'chaine', 0, '', $conf->entity); else dolibarr_set_const($db, 'MAIN_ENABLE_DEFAULT_VALUES', 0, 'chaine', 0, '', $conf->entity);
} }
if (($action == 'add' || (GETPOST('add') && $action != 'update')) || GETPOST('actionmodify')) if (($action == 'add' || (GETPOST('add') && $action != 'update')) || GETPOST('actionmodify'))
@ -102,57 +102,57 @@ if (($action == 'add' || (GETPOST('add') && $action != 'update')) || GETPOST('ac
if (($action == 'add' || (GETPOST('add') && $action != 'update'))) if (($action == 'add' || (GETPOST('add') && $action != 'update')))
{ {
if (empty($defaulturl)) if (empty($defaulturl))
{ {
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Url")), null, 'errors'); setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Url")), null, 'errors');
$error++; $error++;
} }
if (empty($defaultkey)) if (empty($defaultkey))
{ {
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Field")), null, 'errors'); setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Field")), null, 'errors');
$error++; $error++;
} }
} }
if (GETPOST('actionmodify')) if (GETPOST('actionmodify'))
{ {
if (empty($urlpage)) if (empty($urlpage))
{ {
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Url")), null, 'errors'); setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Url")), null, 'errors');
$error++; $error++;
} }
if (empty($key)) if (empty($key))
{ {
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Field")), null, 'errors'); setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Field")), null, 'errors');
$error++; $error++;
} }
} }
if (!$error) if (!$error)
{ {
$db->begin(); $db->begin();
if ($action == 'add' || (GETPOST('add') && $action != 'update')) if ($action == 'add' || (GETPOST('add') && $action != 'update'))
{ {
$sql = "INSERT INTO ".MAIN_DB_PREFIX."default_values(type, user_id, page, param, value, entity) VALUES ('".$db->escape($mode)."', 0, '".$db->escape($defaulturl)."','".$db->escape($defaultkey)."','".$db->escape($defaultvalue)."', ".$db->escape($conf->entity).")"; $sql = "INSERT INTO ".MAIN_DB_PREFIX."default_values(type, user_id, page, param, value, entity) VALUES ('".$db->escape($mode)."', 0, '".$db->escape($defaulturl)."','".$db->escape($defaultkey)."','".$db->escape($defaultvalue)."', ".$db->escape($conf->entity).")";
} }
if (GETPOST('actionmodify')) if (GETPOST('actionmodify'))
{ {
$sql = "UPDATE ".MAIN_DB_PREFIX."default_values SET page = '".$db->escape($urlpage)."', param = '".$db->escape($key)."', value = '".$db->escape($value)."'"; $sql = "UPDATE ".MAIN_DB_PREFIX."default_values SET page = '".$db->escape($urlpage)."', param = '".$db->escape($key)."', value = '".$db->escape($value)."'";
$sql .= " WHERE rowid = ".$id; $sql .= " WHERE rowid = ".$id;
} }
$result = $db->query($sql); $result = $db->query($sql);
if ($result > 0) if ($result > 0)
{ {
$db->commit(); $db->commit();
setEventMessages($langs->trans("RecordSaved"), null, 'mesgs'); setEventMessages($langs->trans("RecordSaved"), null, 'mesgs');
$action = ""; $action = "";
$defaulturl = ''; $defaulturl = '';
$defaultkey = ''; $defaultkey = '';
$defaultvalue = ''; $defaultvalue = '';
} else { } else {
$db->rollback(); $db->rollback();
setEventMessages($db->lasterror(), null, 'errors'); setEventMessages($db->lasterror(), null, 'errors');
$action = ''; $action = '';
} }
} }
@ -189,15 +189,15 @@ $param = '&mode='.$mode;
$enabledisablehtml .= $langs->trans("EnableDefaultValues").' '; $enabledisablehtml .= $langs->trans("EnableDefaultValues").' ';
if (empty($conf->global->MAIN_ENABLE_DEFAULT_VALUES)) if (empty($conf->global->MAIN_ENABLE_DEFAULT_VALUES))
{ {
// Button off, click to enable // Button off, click to enable
$enabledisablehtml .= '<a class="reposition valignmiddle" href="'.$_SERVER["PHP_SELF"].'?action=setMAIN_ENABLE_DEFAULT_VALUES&amp;token='.newToken().'&amp;value=1'.$param.'">'; $enabledisablehtml .= '<a class="reposition valignmiddle" href="'.$_SERVER["PHP_SELF"].'?action=setMAIN_ENABLE_DEFAULT_VALUES&amp;token='.newToken().'&amp;value=1'.$param.'">';
$enabledisablehtml .= img_picto($langs->trans("Disabled"), 'switch_off'); $enabledisablehtml .= img_picto($langs->trans("Disabled"), 'switch_off');
$enabledisablehtml .= '</a>'; $enabledisablehtml .= '</a>';
} else { } else {
// Button on, click to disable // Button on, click to disable
$enabledisablehtml .= '<a class="reposition valignmiddle" href="'.$_SERVER["PHP_SELF"].'?action=setMAIN_ENABLE_DEFAULT_VALUES&amp;token='.newToken().'&amp;value=0'.$param.'">'; $enabledisablehtml .= '<a class="reposition valignmiddle" href="'.$_SERVER["PHP_SELF"].'?action=setMAIN_ENABLE_DEFAULT_VALUES&amp;token='.newToken().'&amp;value=0'.$param.'">';
$enabledisablehtml .= img_picto($langs->trans("Activated"), 'switch_on'); $enabledisablehtml .= img_picto($langs->trans("Activated"), 'switch_on');
$enabledisablehtml .= '</a>'; $enabledisablehtml .= '</a>';
} }
print load_fiche_titre($langs->trans("DefaultValues"), $enabledisablehtml, 'title_setup'); print load_fiche_titre($langs->trans("DefaultValues"), $enabledisablehtml, 'title_setup');
@ -228,7 +228,7 @@ dol_fiche_head($head, $mode, '', -1, '');
if ($mode == 'sortorder') if ($mode == 'sortorder')
{ {
print info_admin($langs->trans("WarningSettingSortOrder")).'<br>'; print info_admin($langs->trans("WarningSettingSortOrder")).'<br>';
} }
if ($mode == 'mandatory') if ($mode == 'mandatory')
{ {
@ -253,30 +253,30 @@ print_liste_field_titre($texturl, $_SERVER["PHP_SELF"], 'page,param', '', $param
$texthelp = $langs->trans("TheKeyIsTheNameOfHtmlField"); $texthelp = $langs->trans("TheKeyIsTheNameOfHtmlField");
if ($mode != 'sortorder') if ($mode != 'sortorder')
{ {
$textkey = $form->textwithpicto($langs->trans("Field"), $texthelp); $textkey = $form->textwithpicto($langs->trans("Field"), $texthelp);
} else { } else {
$texthelp = 'field or alias.field'; $texthelp = 'field or alias.field';
$textkey = $form->textwithpicto($langs->trans("Field"), $texthelp); $textkey = $form->textwithpicto($langs->trans("Field"), $texthelp);
} }
print_liste_field_titre($textkey, $_SERVER["PHP_SELF"], 'param', '', $param, '', $sortfield, $sortorder); print_liste_field_titre($textkey, $_SERVER["PHP_SELF"], 'param', '', $param, '', $sortfield, $sortorder);
// Value // Value
if ($mode != 'focus' && $mode != 'mandatory') if ($mode != 'focus' && $mode != 'mandatory')
{ {
if ($mode != 'sortorder') if ($mode != 'sortorder')
{ {
$substitutionarray = getCommonSubstitutionArray($langs, 2, array('object', 'objectamount')); // Must match list into GETPOST $substitutionarray = getCommonSubstitutionArray($langs, 2, array('object', 'objectamount')); // Must match list into GETPOST
unset($substitutionarray['__USER_SIGNATURE__']); unset($substitutionarray['__USER_SIGNATURE__']);
$texthelp = $langs->trans("FollowingConstantsWillBeSubstituted").'<br>'; $texthelp = $langs->trans("FollowingConstantsWillBeSubstituted").'<br>';
foreach ($substitutionarray as $key => $val) foreach ($substitutionarray as $key => $val)
{ {
$texthelp .= $key.' -> '.$val.'<br>'; $texthelp .= $key.' -> '.$val.'<br>';
} }
$textvalue = $form->textwithpicto($langs->trans("Value"), $texthelp, 1, 'help', '', 0, 2, 'subsitutiontooltip'); $textvalue = $form->textwithpicto($langs->trans("Value"), $texthelp, 1, 'help', '', 0, 2, 'subsitutiontooltip');
} else { } else {
$texthelp = 'ASC or DESC'; $texthelp = 'ASC or DESC';
$textvalue = $form->textwithpicto($langs->trans("SortOrder"), $texthelp); $textvalue = $form->textwithpicto($langs->trans("SortOrder"), $texthelp);
} }
print_liste_field_titre($textvalue, $_SERVER["PHP_SELF"], 'value', '', $param, '', $sortfield, $sortorder); print_liste_field_titre($textvalue, $_SERVER["PHP_SELF"], 'value', '', $param, '', $sortfield, $sortorder);
} }
// Entity // Entity
if (!empty($conf->multicompany->enabled) && !$user->entity) print_liste_field_titre("Entity", $_SERVER["PHP_SELF"], 'entity,page', '', $param, '', $sortfield, $sortorder); if (!empty($conf->multicompany->enabled) && !$user->entity) print_liste_field_titre("Entity", $_SERVER["PHP_SELF"], 'entity,page', '', $param, '', $sortfield, $sortorder);
@ -301,9 +301,9 @@ print '</td>';
// Value // Value
if ($mode != 'focus' && $mode != 'mandatory') if ($mode != 'focus' && $mode != 'mandatory')
{ {
print '<td>'; print '<td>';
print '<input type="text" class="flat maxwidth100onsmartphone" name="defaultvalue" value="">'; print '<input type="text" class="flat maxwidth100onsmartphone" name="defaultvalue" value="">';
print '</td>'; print '</td>';
} }
// Limit to superadmin // Limit to superadmin
if (!empty($conf->multicompany->enabled) && !$user->entity) if (!empty($conf->multicompany->enabled) && !$user->entity)
@ -361,32 +361,32 @@ if ($result)
// Value // Value
if ($mode != 'focus' && $mode != 'mandatory') if ($mode != 'focus' && $mode != 'mandatory')
{ {
print '<td>'; print '<td>';
/*print '<input type="hidden" name="const['.$i.'][rowid]" value="'.$obj->rowid.'">'; /*print '<input type="hidden" name="const['.$i.'][rowid]" value="'.$obj->rowid.'">';
print '<input type="hidden" name="const['.$i.'][lang]" value="'.$obj->lang.'">'; print '<input type="hidden" name="const['.$i.'][lang]" value="'.$obj->lang.'">';
print '<input type="hidden" name="const['.$i.'][name]" value="'.$obj->transkey.'">'; print '<input type="hidden" name="const['.$i.'][name]" value="'.$obj->transkey.'">';
print '<input type="text" id="value_'.$i.'" class="flat inputforupdate" size="30" name="const['.$i.'][value]" value="'.dol_escape_htmltag($obj->transvalue).'">'; print '<input type="text" id="value_'.$i.'" class="flat inputforupdate" size="30" name="const['.$i.'][value]" value="'.dol_escape_htmltag($obj->transvalue).'">';
*/ */
if ($action != 'edit' || GETPOST('rowid') != $obj->rowid) print dol_escape_htmltag($obj->value); if ($action != 'edit' || GETPOST('rowid') != $obj->rowid) print dol_escape_htmltag($obj->value);
else print '<input type="text" name="value" value="'.dol_escape_htmltag($obj->value).'">'; else print '<input type="text" name="value" value="'.dol_escape_htmltag($obj->value).'">';
print '</td>'; print '</td>';
} }
print '<td></td>'; print '<td></td>';
// Actions // Actions
print '<td class="center">'; print '<td class="center">';
if ($action != 'edit' || GETPOST('rowid') != $obj->rowid) if ($action != 'edit' || GETPOST('rowid') != $obj->rowid)
{ {
print '<a href="'.$_SERVER['PHP_SELF'].'?rowid='.$obj->rowid.'&entity='.$obj->entity.'&mode='.$mode.'&action=edit&token='.newToken().((empty($user->entity) && $debug) ? '&debug=1' : '').'">'.img_edit().'</a>'; print '<a href="'.$_SERVER['PHP_SELF'].'?rowid='.$obj->rowid.'&entity='.$obj->entity.'&mode='.$mode.'&action=edit&token='.newToken().((empty($user->entity) && $debug) ? '&debug=1' : '').'">'.img_edit().'</a>';
print ' &nbsp; '; print ' &nbsp; ';
print '<a href="'.$_SERVER['PHP_SELF'].'?rowid='.$obj->rowid.'&entity='.$obj->entity.'&mode='.$mode.'&action=delete&token='.newToken().((empty($user->entity) && $debug) ? '&debug=1' : '').'">'.img_delete().'</a>'; print '<a href="'.$_SERVER['PHP_SELF'].'?rowid='.$obj->rowid.'&entity='.$obj->entity.'&mode='.$mode.'&action=delete&token='.newToken().((empty($user->entity) && $debug) ? '&debug=1' : '').'">'.img_delete().'</a>';
} else { } else {
print '<input type="hidden" name="page" value="'.$page.'">'; print '<input type="hidden" name="page" value="'.$page.'">';
print '<input type="hidden" name="rowid" value="'.$id.'">'; print '<input type="hidden" name="rowid" value="'.$id.'">';
print '<div name="'.(!empty($obj->rowid) ? $obj->rowid : 'none').'"></div>'; print '<div name="'.(!empty($obj->rowid) ? $obj->rowid : 'none').'"></div>';
print '<input type="submit" class="button" name="actionmodify" value="'.$langs->trans("Modify").'">'; print '<input type="submit" class="button" name="actionmodify" value="'.$langs->trans("Modify").'">';
print '<input type="submit" class="button" name="actioncancel" value="'.$langs->trans("Cancel").'">'; print '<input type="submit" class="button" name="actioncancel" value="'.$langs->trans("Cancel").'">';
} }
print '</td>'; print '</td>';
@ -395,7 +395,7 @@ if ($result)
$i++; $i++;
} }
} else { } else {
dol_print_error($db); dol_print_error($db);
} }
print '</table>'; print '</table>';

File diff suppressed because it is too large Load Diff

View File

@ -34,7 +34,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
if (!$user->admin) if (!$user->admin)
accessforbidden(); accessforbidden();
// Load translation files required by the page // Load translation files required by the page
$langs->loadLangs(array('admin', 'other', 'ecm')); $langs->loadLangs(array('admin', 'other', 'ecm'));
@ -89,9 +89,9 @@ dol_fiche_end();
// Buttons // Buttons
if ($action != 'create' && $action != 'edit') { if ($action != 'create' && $action != 'edit') {
print '<div class="tabsAction">'; print '<div class="tabsAction">';
print "<a class=\"butAction\" href=\"".$_SERVER["PHP_SELF"]."?action=create#newattrib\">".$langs->trans("NewAttribute")."</a>"; print "<a class=\"butAction\" href=\"".$_SERVER["PHP_SELF"]."?action=create#newattrib\">".$langs->trans("NewAttribute")."</a>";
print "</div>"; print "</div>";
} }
@ -102,9 +102,9 @@ if ($action != 'create' && $action != 'edit') {
/* ************************************************************************** */ /* ************************************************************************** */
if ($action == 'create') { if ($action == 'create') {
print '<br><div id="newattrib"></div>'; print '<br><div id="newattrib"></div>';
print load_fiche_titre($langs->trans('NewAttribute')); print load_fiche_titre($langs->trans('NewAttribute'));
require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php'; require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php';
} }
/* ************************************************************************** */ /* ************************************************************************** */
@ -113,9 +113,9 @@ if ($action == 'create') {
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
if ($action == 'edit' && !empty($attrname)) { if ($action == 'edit' && !empty($attrname)) {
print "<br>"; print "<br>";
print load_fiche_titre($langs->trans("FieldEdition", $attrname)); print load_fiche_titre($langs->trans("FieldEdition", $attrname));
require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php'; require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php';
} }
// End of page // End of page

View File

@ -34,7 +34,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
if (!$user->admin) if (!$user->admin)
accessforbidden(); accessforbidden();
// Load translation files required by the page // Load translation files required by the page
$langs->loadLangs(array('admin', 'other', 'ecm')); $langs->loadLangs(array('admin', 'other', 'ecm'));
@ -89,9 +89,9 @@ dol_fiche_end();
// Buttons // Buttons
if ($action != 'create' && $action != 'edit') { if ($action != 'create' && $action != 'edit') {
print '<div class="tabsAction">'; print '<div class="tabsAction">';
print "<a class=\"butAction\" href=\"".$_SERVER["PHP_SELF"]."?action=create#newattrib\">".$langs->trans("NewAttribute")."</a>"; print "<a class=\"butAction\" href=\"".$_SERVER["PHP_SELF"]."?action=create#newattrib\">".$langs->trans("NewAttribute")."</a>";
print "</div>"; print "</div>";
} }
@ -102,9 +102,9 @@ if ($action != 'create' && $action != 'edit') {
/* ************************************************************************** */ /* ************************************************************************** */
if ($action == 'create') { if ($action == 'create') {
print '<br><div id="newattrib"></div>'; print '<br><div id="newattrib"></div>';
print load_fiche_titre($langs->trans('NewAttribute')); print load_fiche_titre($langs->trans('NewAttribute'));
require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php'; require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php';
} }
/* ************************************************************************** */ /* ************************************************************************** */
@ -113,9 +113,9 @@ if ($action == 'create') {
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
if ($action == 'edit' && !empty($attrname)) { if ($action == 'edit' && !empty($attrname)) {
print "<br>"; print "<br>";
print load_fiche_titre($langs->trans("FieldEdition", $attrname)); print load_fiche_titre($langs->trans("FieldEdition", $attrname));
require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php'; require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php';
} }
// End of page // End of page

View File

@ -330,10 +330,10 @@ if ($conf->use_javascript_ajax)
$entry .= '</td></tr></table>'; $entry .= '</td></tr></table>';
$buttons = '<a class="editfielda marginleftonly marginrightonly" href="edit.php?menu_handler='.$menu_handler_to_search.'&action=edit&token='.newToken().'&menuId='.$menu['rowid'].'">'.img_edit('default', 0, 'class="menuEdit" id="edit'.$menu['rowid'].'"').'</a> '; $buttons = '<a class="editfielda marginleftonly marginrightonly" href="edit.php?menu_handler='.$menu_handler_to_search.'&action=edit&token='.newToken().'&menuId='.$menu['rowid'].'">'.img_edit('default', 0, 'class="menuEdit" id="edit'.$menu['rowid'].'"').'</a> ';
$buttons .= '<a class="marginleftonly marginrightonly" href="edit.php?menu_handler='.$menu_handler_to_search.'&action=create&token='.newToken().'&menuId='.$menu['rowid'].'">'.img_edit_add('default').'</a> '; $buttons .= '<a class="marginleftonly marginrightonly" href="edit.php?menu_handler='.$menu_handler_to_search.'&action=create&token='.newToken().'&menuId='.$menu['rowid'].'">'.img_edit_add('default').'</a> ';
$buttons .= '<a class="marginleftonly marginrightonly" href="index.php?menu_handler='.$menu_handler_to_search.'&action=delete&token='.newToken().'&menuId='.$menu['rowid'].'">'.img_delete('default').'</a> '; $buttons .= '<a class="marginleftonly marginrightonly" href="index.php?menu_handler='.$menu_handler_to_search.'&action=delete&token='.newToken().'&menuId='.$menu['rowid'].'">'.img_delete('default').'</a> ';
$buttons .= '&nbsp; &nbsp; &nbsp;'; $buttons .= '&nbsp; &nbsp; &nbsp;';
$buttons .= '<a class="marginleftonly marginrightonly" href="index.php?menu_handler='.$menu_handler_to_search.'&action=up&token='.newToken().'&menuId='.$menu['rowid'].'">'.img_picto("Up", "1uparrow").'</a><a href="index.php?menu_handler='.$menu_handler_to_search.'&action=down&menuId='.$menu['rowid'].'">'.img_picto("Down", "1downarrow").'</a>'; $buttons .= '<a class="marginleftonly marginrightonly" href="index.php?menu_handler='.$menu_handler_to_search.'&action=up&token='.newToken().'&menuId='.$menu['rowid'].'">'.img_picto("Up", "1uparrow").'</a><a href="index.php?menu_handler='.$menu_handler_to_search.'&action=down&menuId='.$menu['rowid'].'">'.img_picto("Down", "1downarrow").'</a>';
$data[] = array( $data[] = array(
'rowid'=>$menu['rowid'], 'rowid'=>$menu['rowid'],

View File

@ -58,50 +58,50 @@ if (!$mode) $mode = 'setup';
if ($action == 'setconst' && $user->admin) if ($action == 'setconst' && $user->admin)
{ {
$error = 0; $error = 0;
$db->begin(); $db->begin();
$setupconstarray = GETPOST('setupdriver', 'array'); $setupconstarray = GETPOST('setupdriver', 'array');
foreach ($setupconstarray as $setupconst) { foreach ($setupconstarray as $setupconst) {
//print '<pre>'.print_r($setupconst, true).'</pre>'; //print '<pre>'.print_r($setupconst, true).'</pre>';
$constname = dol_escape_htmltag($setupconst['varname']); $constname = dol_escape_htmltag($setupconst['varname']);
$constvalue = dol_escape_htmltag($setupconst['value']); $constvalue = dol_escape_htmltag($setupconst['value']);
$consttype = dol_escape_htmltag($setupconst['type']); $consttype = dol_escape_htmltag($setupconst['type']);
$constnote = dol_escape_htmltag($setupconst['note']); $constnote = dol_escape_htmltag($setupconst['note']);
$result = dolibarr_set_const($db, $constname, $constvalue, $consttype, 0, $constnote, $conf->entity); $result = dolibarr_set_const($db, $constname, $constvalue, $consttype, 0, $constnote, $conf->entity);
if (!$result > 0) $error++; if (!$result > 0) $error++;
} }
if (!$error) if (!$error)
{ {
$db->commit(); $db->commit();
setEventMessages($langs->trans("SetupSaved"), null); setEventMessages($langs->trans("SetupSaved"), null);
} else { } else {
$db->rollback(); $db->rollback();
dol_print_error($db); dol_print_error($db);
} }
$action = ''; $action = '';
} }
if ($action == 'setvalue' && $user->admin) if ($action == 'setvalue' && $user->admin)
{ {
$db->begin(); $db->begin();
$result = dolibarr_set_const($db, $varname, $value, 'chaine', 0, '', $conf->entity); $result = dolibarr_set_const($db, $varname, $value, 'chaine', 0, '', $conf->entity);
if (!$result > 0) $error++; if (!$result > 0) $error++;
if (!$error) if (!$error)
{ {
$db->commit(); $db->commit();
setEventMessages($langs->trans("SetupSaved"), null); setEventMessages($langs->trans("SetupSaved"), null);
} else { } else {
$db->rollback(); $db->rollback();
dol_print_error($db); dol_print_error($db);
} }
$action = ''; $action = '';
} }
@ -131,275 +131,275 @@ if (GETPOST('error')) {
if ($mode == 'setup' && $user->admin) if ($mode == 'setup' && $user->admin)
{ {
print '<span class="opacitymedium">'.$langs->trans("OAuthSetupForLogin")."</span><br><br>\n"; print '<span class="opacitymedium">'.$langs->trans("OAuthSetupForLogin")."</span><br><br>\n";
foreach ($list as $key) foreach ($list as $key)
{ {
$supported = 0; $supported = 0;
if (in_array($key[0], array_keys($supportedoauth2array))) $supported = 1; if (in_array($key[0], array_keys($supportedoauth2array))) $supported = 1;
if (!$supported) continue; // show only supported if (!$supported) continue; // show only supported
$OAUTH_SERVICENAME = 'Unknown'; $OAUTH_SERVICENAME = 'Unknown';
if ($key[0] == 'OAUTH_GITHUB_NAME') if ($key[0] == 'OAUTH_GITHUB_NAME')
{ {
$OAUTH_SERVICENAME = 'GitHub'; $OAUTH_SERVICENAME = 'GitHub';
// List of keys that will be converted into scopes (from constants 'SCOPE_state_in_uppercase' in file of service). // List of keys that will be converted into scopes (from constants 'SCOPE_state_in_uppercase' in file of service).
// We pass this param list in to 'state' because we need it before and after the redirect. // We pass this param list in to 'state' because we need it before and after the redirect.
$shortscope = 'user,public_repo'; $shortscope = 'user,public_repo';
$urltorenew = $urlwithroot.'/core/modules/oauth/github_oauthcallback.php?shortscope='.$shortscope.'&state='.$shortscope.'&backtourl='.urlencode(DOL_URL_ROOT.'/admin/oauthlogintokens.php'); $urltorenew = $urlwithroot.'/core/modules/oauth/github_oauthcallback.php?shortscope='.$shortscope.'&state='.$shortscope.'&backtourl='.urlencode(DOL_URL_ROOT.'/admin/oauthlogintokens.php');
$urltodelete = $urlwithroot.'/core/modules/oauth/github_oauthcallback.php?action=delete&token='.newToken().'&backtourl='.urlencode(DOL_URL_ROOT.'/admin/oauthlogintokens.php'); $urltodelete = $urlwithroot.'/core/modules/oauth/github_oauthcallback.php?action=delete&token='.newToken().'&backtourl='.urlencode(DOL_URL_ROOT.'/admin/oauthlogintokens.php');
$urltocheckperms = 'https://github.com/settings/applications/'; $urltocheckperms = 'https://github.com/settings/applications/';
} elseif ($key[0] == 'OAUTH_GOOGLE_NAME') } elseif ($key[0] == 'OAUTH_GOOGLE_NAME')
{ {
$OAUTH_SERVICENAME = 'Google'; $OAUTH_SERVICENAME = 'Google';
// List of keys that will be converted into scopes (from constants 'SCOPE_state_in_uppercase' in file of service). // List of keys that will be converted into scopes (from constants 'SCOPE_state_in_uppercase' in file of service).
// We pass this param list in to 'state' because we need it before and after the redirect. // We pass this param list in to 'state' because we need it before and after the redirect.
$shortscope = 'userinfo_email,userinfo_profile,cloud_print'; $shortscope = 'userinfo_email,userinfo_profile,cloud_print';
if (!empty($conf->global->OAUTH_GSUITE)){ if (!empty($conf->global->OAUTH_GSUITE)){
$shortscope .= ',admin_directory_user'; $shortscope .= ',admin_directory_user';
} }
//$scope.=',gmail_full'; //$scope.=',gmail_full';
$urltorenew = $urlwithroot.'/core/modules/oauth/google_oauthcallback.php?shortscope='.$shortscope.'&state='.$shortscope.'&backtourl='.urlencode(DOL_URL_ROOT.'/admin/oauthlogintokens.php'); $urltorenew = $urlwithroot.'/core/modules/oauth/google_oauthcallback.php?shortscope='.$shortscope.'&state='.$shortscope.'&backtourl='.urlencode(DOL_URL_ROOT.'/admin/oauthlogintokens.php');
$urltodelete = $urlwithroot.'/core/modules/oauth/google_oauthcallback.php?action=delete&token='.newToken().'&backtourl='.urlencode(DOL_URL_ROOT.'/admin/oauthlogintokens.php'); $urltodelete = $urlwithroot.'/core/modules/oauth/google_oauthcallback.php?action=delete&token='.newToken().'&backtourl='.urlencode(DOL_URL_ROOT.'/admin/oauthlogintokens.php');
$urltocheckperms = 'https://security.google.com/settings/security/permissions'; $urltocheckperms = 'https://security.google.com/settings/security/permissions';
} elseif ($key[0] == 'OAUTH_STRIPE_TEST_NAME') } elseif ($key[0] == 'OAUTH_STRIPE_TEST_NAME')
{ {
$OAUTH_SERVICENAME = 'StripeTest'; $OAUTH_SERVICENAME = 'StripeTest';
$urltorenew = $urlwithroot.'/core/modules/oauth/stripetest_oauthcallback.php?backtourl='.urlencode(DOL_URL_ROOT.'/admin/oauthlogintokens.php'); $urltorenew = $urlwithroot.'/core/modules/oauth/stripetest_oauthcallback.php?backtourl='.urlencode(DOL_URL_ROOT.'/admin/oauthlogintokens.php');
$urltodelete = ''; $urltodelete = '';
$urltocheckperms = ''; $urltocheckperms = '';
} elseif ($key[0] == 'OAUTH_STRIPE_LIVE_NAME') } elseif ($key[0] == 'OAUTH_STRIPE_LIVE_NAME')
{ {
$OAUTH_SERVICENAME = 'StripeLive'; $OAUTH_SERVICENAME = 'StripeLive';
$urltorenew = $urlwithroot.'/core/modules/oauth/stripelive_oauthcallback.php?backtourl='.urlencode(DOL_URL_ROOT.'/admin/oauthlogintokens.php'); $urltorenew = $urlwithroot.'/core/modules/oauth/stripelive_oauthcallback.php?backtourl='.urlencode(DOL_URL_ROOT.'/admin/oauthlogintokens.php');
$urltodelete = ''; $urltodelete = '';
$urltocheckperms = ''; $urltocheckperms = '';
} else { } else {
$urltorenew = ''; $urltorenew = '';
$urltodelete = ''; $urltodelete = '';
$urltocheckperms = ''; $urltocheckperms = '';
} }
// Show value of token // Show value of token
$tokenobj = null; $tokenobj = null;
// Token // Token
require_once DOL_DOCUMENT_ROOT.'/includes/OAuth/bootstrap.php'; require_once DOL_DOCUMENT_ROOT.'/includes/OAuth/bootstrap.php';
require_once DOL_DOCUMENT_ROOT.'/includes/OAuth/bootstrap.php'; require_once DOL_DOCUMENT_ROOT.'/includes/OAuth/bootstrap.php';
// Dolibarr storage // Dolibarr storage
$storage = new DoliStorage($db, $conf); $storage = new DoliStorage($db, $conf);
try { try {
$tokenobj = $storage->retrieveAccessToken($OAUTH_SERVICENAME); $tokenobj = $storage->retrieveAccessToken($OAUTH_SERVICENAME);
} catch (Exception $e) } catch (Exception $e)
{ {
// Return an error if token not found // Return an error if token not found
} }
// Set other properties // Set other properties
$refreshtoken = false; $refreshtoken = false;
$expiredat = ''; $expiredat = '';
$expire = false; $expire = false;
// Is token expired or will token expire in the next 30 seconds // Is token expired or will token expire in the next 30 seconds
if (is_object($tokenobj)) { if (is_object($tokenobj)) {
$expire = ($tokenobj->getEndOfLife() !== $tokenobj::EOL_NEVER_EXPIRES && $tokenobj->getEndOfLife() !== $tokenobj::EOL_UNKNOWN && time() > ($tokenobj->getEndOfLife() - 30)); $expire = ($tokenobj->getEndOfLife() !== $tokenobj::EOL_NEVER_EXPIRES && $tokenobj->getEndOfLife() !== $tokenobj::EOL_UNKNOWN && time() > ($tokenobj->getEndOfLife() - 30));
} }
if ($key[1] != '' && $key[2] != '') { if ($key[1] != '' && $key[2] != '') {
if (is_object($tokenobj)) { if (is_object($tokenobj)) {
$refreshtoken = $tokenobj->getRefreshToken(); $refreshtoken = $tokenobj->getRefreshToken();
$endoflife = $tokenobj->getEndOfLife(); $endoflife = $tokenobj->getEndOfLife();
if ($endoflife == $tokenobj::EOL_NEVER_EXPIRES) if ($endoflife == $tokenobj::EOL_NEVER_EXPIRES)
{ {
$expiredat = $langs->trans("Never"); $expiredat = $langs->trans("Never");
} elseif ($endoflife == $tokenobj::EOL_UNKNOWN) } elseif ($endoflife == $tokenobj::EOL_UNKNOWN)
{ {
$expiredat = $langs->trans("Unknown"); $expiredat = $langs->trans("Unknown");
} else { } else {
$expiredat = dol_print_date($endoflife, "dayhour"); $expiredat = dol_print_date($endoflife, "dayhour");
} }
} }
} }
$submit_enabled = 0; $submit_enabled = 0;
print '<form method="post" action="'.$_SERVER["PHP_SELF"].'?mode=setup&amp;driver='.$driver.'" autocomplete="off">'; print '<form method="post" action="'.$_SERVER["PHP_SELF"].'?mode=setup&amp;driver='.$driver.'" autocomplete="off">';
print '<input type="hidden" name="token" value="'.newToken().'">'; print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="action" value="setconst">'; print '<input type="hidden" name="action" value="setconst">';
print '<table class="noborder centpercent">'."\n"; print '<table class="noborder centpercent">'."\n";
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print '<th class="titlefieldcreate">'.$langs->trans($key[0]).'</th>'; print '<th class="titlefieldcreate">'.$langs->trans($key[0]).'</th>';
print '<th></th>'; print '<th></th>';
print '<th></th>'; print '<th></th>';
print "</tr>\n"; print "</tr>\n";
print '<tr class="oddeven">'; print '<tr class="oddeven">';
print '<td'.($key['required'] ? ' class="required"' : '').'>'; print '<td'.($key['required'] ? ' class="required"' : '').'>';
//var_dump($key); //var_dump($key);
print $langs->trans("OAuthIDSecret").'</td>'; print $langs->trans("OAuthIDSecret").'</td>';
print '<td>'; print '<td>';
print $langs->trans("SeePreviousTab"); print $langs->trans("SeePreviousTab");
print '</td>'; print '</td>';
print '<td>'; print '<td>';
print '</td>'; print '</td>';
print '</tr>'."\n"; print '</tr>'."\n";
print '<tr class="oddeven">'; print '<tr class="oddeven">';
print '<td'.($key['required'] ? ' class="required"' : '').'>'; print '<td'.($key['required'] ? ' class="required"' : '').'>';
//var_dump($key); //var_dump($key);
print $langs->trans("IsTokenGenerated"); print $langs->trans("IsTokenGenerated");
print '</td>'; print '</td>';
print '<td>'; print '<td>';
if (is_object($tokenobj)) print $langs->trans("HasAccessToken"); if (is_object($tokenobj)) print $langs->trans("HasAccessToken");
else print $langs->trans("NoAccessToken"); else print $langs->trans("NoAccessToken");
print '</td>'; print '</td>';
print '<td>'; print '<td>';
// Links to delete/checks token // Links to delete/checks token
if (is_object($tokenobj)) if (is_object($tokenobj))
{ {
//test on $storage->hasAccessToken($OAUTH_SERVICENAME) ? //test on $storage->hasAccessToken($OAUTH_SERVICENAME) ?
print '<a class="button" href="'.$urltodelete.'">'.$langs->trans('DeleteAccess').'</a><br>'; print '<a class="button" href="'.$urltodelete.'">'.$langs->trans('DeleteAccess').'</a><br>';
} }
// Request remote token // Request remote token
if ($urltorenew) if ($urltorenew)
{ {
print '<a class="button" href="'.$urltorenew.'">'.$langs->trans('RequestAccess').'</a><br>'; print '<a class="button" href="'.$urltorenew.'">'.$langs->trans('RequestAccess').'</a><br>';
} }
// Check remote access // Check remote access
if ($urltocheckperms) if ($urltocheckperms)
{ {
print '<br>'.$langs->trans("ToCheckDeleteTokenOnProvider", $OAUTH_SERVICENAME).': <a href="'.$urltocheckperms.'" target="_'.strtolower($OAUTH_SERVICENAME).'">'.$urltocheckperms.'</a>'; print '<br>'.$langs->trans("ToCheckDeleteTokenOnProvider", $OAUTH_SERVICENAME).': <a href="'.$urltocheckperms.'" target="_'.strtolower($OAUTH_SERVICENAME).'">'.$urltocheckperms.'</a>';
} }
print '</td>'; print '</td>';
print '</tr>'; print '</tr>';
print '<tr class="oddeven">'; print '<tr class="oddeven">';
print '<td'.($key['required'] ? ' class="required"' : '').'>'; print '<td'.($key['required'] ? ' class="required"' : '').'>';
//var_dump($key); //var_dump($key);
print $langs->trans("Token").'</td>'; print $langs->trans("Token").'</td>';
print '<td colspan="2">'; print '<td colspan="2">';
if (is_object($tokenobj)) if (is_object($tokenobj))
{ {
//var_dump($tokenobj); //var_dump($tokenobj);
print $tokenobj->getAccessToken().'<br>'; print $tokenobj->getAccessToken().'<br>';
//print 'Refresh: '.$tokenobj->getRefreshToken().'<br>'; //print 'Refresh: '.$tokenobj->getRefreshToken().'<br>';
//print 'EndOfLife: '.$tokenobj->getEndOfLife().'<br>'; //print 'EndOfLife: '.$tokenobj->getEndOfLife().'<br>';
//var_dump($tokenobj->getExtraParams()); //var_dump($tokenobj->getExtraParams());
/*print '<br>Extra: <br><textarea class="quatrevingtpercent">'; /*print '<br>Extra: <br><textarea class="quatrevingtpercent">';
print ''.join(',',$tokenobj->getExtraParams()); print ''.join(',',$tokenobj->getExtraParams());
print '</textarea>';*/ print '</textarea>';*/
} }
print '</td>'; print '</td>';
print '</tr>'."\n"; print '</tr>'."\n";
if (is_object($tokenobj)) if (is_object($tokenobj))
{ {
// Token refresh // Token refresh
print '<tr class="oddeven">'; print '<tr class="oddeven">';
print '<td'.($key['required'] ? ' class="required"' : '').'>'; print '<td'.($key['required'] ? ' class="required"' : '').'>';
//var_dump($key); //var_dump($key);
print $langs->trans("TOKEN_REFRESH").'</td>'; print $langs->trans("TOKEN_REFRESH").'</td>';
print '<td colspan="2">'; print '<td colspan="2">';
print yn($refreshtoken); print yn($refreshtoken);
print '</td>'; print '</td>';
print '</tr>'; print '</tr>';
// Token expired // Token expired
print '<tr class="oddeven">'; print '<tr class="oddeven">';
print '<td'.($key['required'] ? ' class="required"' : '').'>'; print '<td'.($key['required'] ? ' class="required"' : '').'>';
//var_dump($key); //var_dump($key);
print $langs->trans("TOKEN_EXPIRED").'</td>'; print $langs->trans("TOKEN_EXPIRED").'</td>';
print '<td colspan="2">'; print '<td colspan="2">';
print yn($expire); print yn($expire);
print '</td>'; print '</td>';
print '</tr>'; print '</tr>';
// Token expired at // Token expired at
print '<tr class="oddeven">'; print '<tr class="oddeven">';
print '<td'.($key['required'] ? ' class="required"' : '').'>'; print '<td'.($key['required'] ? ' class="required"' : '').'>';
//var_dump($key); //var_dump($key);
print $langs->trans("TOKEN_EXPIRE_AT").'</td>'; print $langs->trans("TOKEN_EXPIRE_AT").'</td>';
print '<td colspan="2">'; print '<td colspan="2">';
print $expiredat; print $expiredat;
print '</td>'; print '</td>';
print '</tr>'; print '</tr>';
} }
print '</table>'; print '</table>';
if (!empty($driver)) if (!empty($driver))
{ {
if ($submit_enabled) { if ($submit_enabled) {
print '<div class="center"><input type="submit" class="button" value="'.dol_escape_htmltag($langs->trans("Modify")).'"></div>'; print '<div class="center"><input type="submit" class="button" value="'.dol_escape_htmltag($langs->trans("Modify")).'"></div>';
} }
} }
print '</form>'; print '</form>';
} }
} }
if ($mode == 'test' && $user->admin) if ($mode == 'test' && $user->admin)
{ {
print $langs->trans('PrintTestDesc'.$driver)."<br><br>\n"; print $langs->trans('PrintTestDesc'.$driver)."<br><br>\n";
print '<table class="noborder centpercent">'; print '<table class="noborder centpercent">';
if (!empty($driver)) if (!empty($driver))
{ {
require_once DOL_DOCUMENT_ROOT.'/core/modules/printing/'.$driver.'.modules.php'; require_once DOL_DOCUMENT_ROOT.'/core/modules/printing/'.$driver.'.modules.php';
$classname = 'printing_'.$driver; $classname = 'printing_'.$driver;
$langs->load($driver); $langs->load($driver);
$printer = new $classname($db); $printer = new $classname($db);
//print '<pre>'.print_r($printer, true).'</pre>'; //print '<pre>'.print_r($printer, true).'</pre>';
if (count($printer->getlistAvailablePrinters())) { if (count($printer->getlistAvailablePrinters())) {
if ($printer->listAvailablePrinters() == 0) { if ($printer->listAvailablePrinters() == 0) {
print $printer->resprint; print $printer->resprint;
} else { } else {
setEventMessages($printer->error, $printer->errors, 'errors'); setEventMessages($printer->error, $printer->errors, 'errors');
} }
} else { } else {
print $langs->trans('PleaseConfigureDriverfromList'); print $langs->trans('PleaseConfigureDriverfromList');
} }
} }
print '</table>'; print '</table>';
} }
if ($mode == 'userconf' && $user->admin) if ($mode == 'userconf' && $user->admin)
{ {
print $langs->trans('PrintUserConfDesc'.$driver)."<br><br>\n"; print $langs->trans('PrintUserConfDesc'.$driver)."<br><br>\n";
print '<table class="noborder centpercent">'; print '<table class="noborder centpercent">';
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print '<th>'.$langs->trans("User").'</th>'; print '<th>'.$langs->trans("User").'</th>';
print '<th>'.$langs->trans("PrintModule").'</th>'; print '<th>'.$langs->trans("PrintModule").'</th>';
print '<th>'.$langs->trans("PrintDriver").'</th>'; print '<th>'.$langs->trans("PrintDriver").'</th>';
print '<th>'.$langs->trans("Printer").'</th>'; print '<th>'.$langs->trans("Printer").'</th>';
print '<th>'.$langs->trans("PrinterLocation").'</th>'; print '<th>'.$langs->trans("PrinterLocation").'</th>';
print '<th>'.$langs->trans("PrinterId").'</th>'; print '<th>'.$langs->trans("PrinterId").'</th>';
print '<th>'.$langs->trans("NumberOfCopy").'</th>'; print '<th>'.$langs->trans("NumberOfCopy").'</th>';
print '<th class="center">'.$langs->trans("Delete").'</th>'; print '<th class="center">'.$langs->trans("Delete").'</th>';
print "</tr>\n"; print "</tr>\n";
$sql = 'SELECT p.rowid, p.printer_name, p.printer_location, p.printer_id, p.copy, p.module, p.driver, p.userid, u.login FROM '.MAIN_DB_PREFIX.'printing as p, '.MAIN_DB_PREFIX.'user as u WHERE p.userid=u.rowid'; $sql = 'SELECT p.rowid, p.printer_name, p.printer_location, p.printer_id, p.copy, p.module, p.driver, p.userid, u.login FROM '.MAIN_DB_PREFIX.'printing as p, '.MAIN_DB_PREFIX.'user as u WHERE p.userid=u.rowid';
$resql = $db->query($sql); $resql = $db->query($sql);
while ($row = $db->fetch_array($resql)) { while ($row = $db->fetch_array($resql)) {
print '<tr class="oddeven">'; print '<tr class="oddeven">';
print '<td>'.$row['login'].'</td>'; print '<td>'.$row['login'].'</td>';
print '<td>'.$row['module'].'</td>'; print '<td>'.$row['module'].'</td>';
print '<td>'.$row['driver'].'</td>'; print '<td>'.$row['driver'].'</td>';
print '<td>'.$row['printer_name'].'</td>'; print '<td>'.$row['printer_name'].'</td>';
print '<td>'.$row['printer_location'].'</td>'; print '<td>'.$row['printer_location'].'</td>';
print '<td>'.$row['printer_id'].'</td>'; print '<td>'.$row['printer_id'].'</td>';
print '<td>'.$row['copy'].'</td>'; print '<td>'.$row['copy'].'</td>';
print '<td class="center">'.img_picto($langs->trans("Delete"), 'delete').'</td>'; print '<td class="center">'.img_picto($langs->trans("Delete"), 'delete').'</td>';
print "</tr>\n"; print "</tr>\n";
} }
print '</table>'; print '</table>';
} }
dol_fiche_end(); dol_fiche_end();

View File

@ -53,16 +53,16 @@ if (!$mode) $mode = 'config';
// used in library escpos maybe useful if php doesn't support gzdecode // used in library escpos maybe useful if php doesn't support gzdecode
if (!function_exists('gzdecode')) { if (!function_exists('gzdecode')) {
/** /**
* Gzdecode * Gzdecode
* *
* @param string $data data to deflate * @param string $data data to deflate
* @return string data deflated * @return string data deflated
*/ */
function gzdecode($data) function gzdecode($data)
{ {
return gzinflate(substr($data, 10, -8)); return gzinflate(substr($data, 10, -8));
} }
} }
@ -71,167 +71,167 @@ if (!function_exists('gzdecode')) {
*/ */
if ($action == 'addprinter' && $user->admin) { if ($action == 'addprinter' && $user->admin) {
$error = 0; $error = 0;
if (empty($printername)) { if (empty($printername)) {
$error++; $error++;
setEventMessages($langs->trans("PrinterNameEmpty"), null, 'errors'); setEventMessages($langs->trans("PrinterNameEmpty"), null, 'errors');
} }
if (empty($parameter)) { if (empty($parameter)) {
setEventMessages($langs->trans("PrinterParameterEmpty"), null, 'warnings'); setEventMessages($langs->trans("PrinterParameterEmpty"), null, 'warnings');
} }
if (!$error) { if (!$error) {
$db->begin(); $db->begin();
$result = $printer->addPrinter($printername, GETPOST('printertypeid', 'int'), GETPOST('printerprofileid', 'int'), $parameter); $result = $printer->addPrinter($printername, GETPOST('printertypeid', 'int'), GETPOST('printerprofileid', 'int'), $parameter);
if ($result > 0) $error++; if ($result > 0) $error++;
if (!$error) if (!$error)
{ {
$db->commit(); $db->commit();
setEventMessages($langs->trans("PrinterAdded", $printername), null); setEventMessages($langs->trans("PrinterAdded", $printername), null);
} else { } else {
$db->rollback(); $db->rollback();
dol_print_error($db); dol_print_error($db);
} }
} }
$action = ''; $action = '';
} }
if ($action == 'deleteprinter' && $user->admin) { if ($action == 'deleteprinter' && $user->admin) {
$error = 0; $error = 0;
if (empty($printerid)) { if (empty($printerid)) {
$error++; $error++;
setEventMessages($langs->trans("PrinterIdEmpty"), null, 'errors'); setEventMessages($langs->trans("PrinterIdEmpty"), null, 'errors');
} }
if (!$error) { if (!$error) {
$db->begin(); $db->begin();
$result = $printer->deletePrinter($printerid); $result = $printer->deletePrinter($printerid);
if ($result > 0) $error++; if ($result > 0) $error++;
if (!$error) if (!$error)
{ {
$db->commit(); $db->commit();
setEventMessages($langs->trans("PrinterDeleted", $printername), null); setEventMessages($langs->trans("PrinterDeleted", $printername), null);
} else { } else {
$db->rollback(); $db->rollback();
dol_print_error($db); dol_print_error($db);
} }
} }
$action = ''; $action = '';
} }
if ($action == 'updateprinter' && $user->admin) { if ($action == 'updateprinter' && $user->admin) {
$error = 0; $error = 0;
if (empty($printerid)) { if (empty($printerid)) {
$error++; $error++;
setEventMessages($langs->trans("PrinterIdEmpty"), null, 'errors'); setEventMessages($langs->trans("PrinterIdEmpty"), null, 'errors');
} }
if (!$error) { if (!$error) {
$db->begin(); $db->begin();
$result = $printer->updatePrinter($printername, GETPOST('printertypeid', 'int'), GETPOST('printerprofileid', 'int'), $parameter, $printerid); $result = $printer->updatePrinter($printername, GETPOST('printertypeid', 'int'), GETPOST('printerprofileid', 'int'), $parameter, $printerid);
if ($result > 0) $error++; if ($result > 0) $error++;
if (!$error) { if (!$error) {
$db->commit(); $db->commit();
setEventMessages($langs->trans("PrinterUpdated", $printername), null); setEventMessages($langs->trans("PrinterUpdated", $printername), null);
} else { } else {
$db->rollback(); $db->rollback();
dol_print_error($db); dol_print_error($db);
} }
} }
$action = ''; $action = '';
} }
if ($action == 'testprinter' && $user->admin) { if ($action == 'testprinter' && $user->admin) {
$error = 0; $error = 0;
if (empty($printerid)) { if (empty($printerid)) {
$error++; $error++;
setEventMessages($langs->trans("PrinterIdEmpty"), null, 'errors'); setEventMessages($langs->trans("PrinterIdEmpty"), null, 'errors');
} }
if (!$error) { if (!$error) {
// test // test
$ret = $printer->sendTestToPrinter($printerid); $ret = $printer->sendTestToPrinter($printerid);
if ($ret == 0) { if ($ret == 0) {
setEventMessages($langs->trans("TestSentToPrinter", $printername), null); setEventMessages($langs->trans("TestSentToPrinter", $printername), null);
} else { } else {
setEventMessages($printer->error, $printer->errors, 'errors'); setEventMessages($printer->error, $printer->errors, 'errors');
} }
} }
$action = ''; $action = '';
} }
if ($action == 'testtemplate' && $user->admin) { if ($action == 'testtemplate' && $user->admin) {
$error = 0; $error = 0;
// if (empty($printerid)) { // if (empty($printerid)) {
// $error++; // $error++;
// setEventMessages($langs->trans("PrinterIdEmpty"), null, 'errors'); // setEventMessages($langs->trans("PrinterIdEmpty"), null, 'errors');
// } // }
// if (! $error) { // if (! $error) {
// test // test
require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
$object = new Facture($db); $object = new Facture($db);
//$object->initAsSpecimen(); //$object->initAsSpecimen();
$object->fetch(18); $object->fetch(18);
//var_dump($object->lines); //var_dump($object->lines);
$ret = $printer->sendToPrinter($object, $templateid, 1); $ret = $printer->sendToPrinter($object, $templateid, 1);
if ($ret == 0) { if ($ret == 0) {
setEventMessages($langs->trans("TestTemplateToPrinter", $printername), null); setEventMessages($langs->trans("TestTemplateToPrinter", $printername), null);
} else { } else {
setEventMessages($printer->error, $printer->errors, 'errors'); setEventMessages($printer->error, $printer->errors, 'errors');
} }
//} //}
$action = ''; $action = '';
} }
if ($action == 'updatetemplate' && $user->admin) { if ($action == 'updatetemplate' && $user->admin) {
$error = 0; $error = 0;
if (empty($templateid)) { if (empty($templateid)) {
$error++; $error++;
setEventMessages($langs->trans("TemplateIdEmpty"), null, 'errors'); setEventMessages($langs->trans("TemplateIdEmpty"), null, 'errors');
} }
if (!$error) { if (!$error) {
$db->begin(); $db->begin();
$result = $printer->updateTemplate($templatename, $template, $templateid); $result = $printer->updateTemplate($templatename, $template, $templateid);
if ($result > 0) $error++; if ($result > 0) $error++;
if (!$error) { if (!$error) {
$db->commit(); $db->commit();
setEventMessages($langs->trans("TemplateUpdated", $templatename), null); setEventMessages($langs->trans("TemplateUpdated", $templatename), null);
} else { } else {
$db->rollback(); $db->rollback();
dol_print_error($db); dol_print_error($db);
} }
} }
$action = ''; $action = '';
} }
if ($action == 'addtemplate' && $user->admin) { if ($action == 'addtemplate' && $user->admin) {
$error = 0; $error = 0;
if (empty($templatename)) { if (empty($templatename)) {
$error++; $error++;
setEventMessages($langs->trans("TemplateNameEmpty"), null, 'errors'); setEventMessages($langs->trans("TemplateNameEmpty"), null, 'errors');
} }
if (!$error) { if (!$error) {
$db->begin(); $db->begin();
$result = $printer->addTemplate($templatename, $template); $result = $printer->addTemplate($templatename, $template);
if ($result > 0) $error++; if ($result > 0) $error++;
if (!$error) { if (!$error) {
$db->commit(); $db->commit();
setEventMessages($langs->trans("TemplateAdded", $templatename), null); setEventMessages($langs->trans("TemplateAdded", $templatename), null);
} else { } else {
$db->rollback(); $db->rollback();
dol_print_error($db); dol_print_error($db);
} }
} }
$action = ''; $action = '';
} }
if ($action == 'deletetemplate' && $user->admin) { if ($action == 'deletetemplate' && $user->admin) {
@ -273,116 +273,116 @@ $head = receiptprinteradmin_prepare_head($mode);
// mode = config // mode = config
if ($mode == 'config' && $user->admin) { if ($mode == 'config' && $user->admin) {
print '<form method="post" action="'.$_SERVER["PHP_SELF"].'?mode=config" autocomplete="off">'; print '<form method="post" action="'.$_SERVER["PHP_SELF"].'?mode=config" autocomplete="off">';
print '<input type="hidden" name="token" value="'.newToken().'">'; print '<input type="hidden" name="token" value="'.newToken().'">';
if ($action != 'editprinter') { if ($action != 'editprinter') {
print '<input type="hidden" name="action" value="addprinter">'; print '<input type="hidden" name="action" value="addprinter">';
} else { } else {
print '<input type="hidden" name="action" value="updateprinter">'; print '<input type="hidden" name="action" value="updateprinter">';
} }
dol_fiche_head($head, $mode, $langs->trans("ModuleSetup"), -1, 'technic'); dol_fiche_head($head, $mode, $langs->trans("ModuleSetup"), -1, 'technic');
print '<span class="opacitymedium">'.$langs->trans("ReceiptPrinterDesc")."</span><br><br>\n"; print '<span class="opacitymedium">'.$langs->trans("ReceiptPrinterDesc")."</span><br><br>\n";
print '<table class="noborder centpercent">'."\n"; print '<table class="noborder centpercent">'."\n";
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print '<th>'.$langs->trans("Name").'</th>'; print '<th>'.$langs->trans("Name").'</th>';
print '<th>'.$langs->trans("Type").'</th>'; print '<th>'.$langs->trans("Type").'</th>';
print '<th>'.$langs->trans("Profile").'</th>'; print '<th>'.$langs->trans("Profile").'</th>';
print '<th>'.$langs->trans("Parameters").'</th>'; print '<th>'.$langs->trans("Parameters").'</th>';
print '<th></th>'; print '<th></th>';
print "</tr>\n"; print "</tr>\n";
$ret = $printer->listprinters(); $ret = $printer->listprinters();
$nbofprinters = count($printer->listprinters); $nbofprinters = count($printer->listprinters);
if ($action != 'editprinter') { if ($action != 'editprinter') {
print '<tr>'; print '<tr>';
print '<td><input size="50" type="text" name="printername"></td>'; print '<td><input size="50" type="text" name="printername"></td>';
$ret = $printer->selectTypePrinter(); $ret = $printer->selectTypePrinter();
print '<td>'.$printer->resprint.'</td>'; print '<td>'.$printer->resprint.'</td>';
$ret = $printer->selectProfilePrinter(); $ret = $printer->selectProfilePrinter();
print '<td>'.$printer->profileresprint.'</td>'; print '<td>'.$printer->profileresprint.'</td>';
print '<td><input size="60" type="text" name="parameter"></td>'; print '<td><input size="60" type="text" name="parameter"></td>';
print '<td class="right">'; print '<td class="right">';
if ($action != 'editprinter') { if ($action != 'editprinter') {
print '<div class="center"><input type="submit" class="button" value="'.dol_escape_htmltag($langs->trans("Add")).'"></div>'; print '<div class="center"><input type="submit" class="button" value="'.dol_escape_htmltag($langs->trans("Add")).'"></div>';
} }
print '</td>'; print '</td>';
print '</tr>'; print '</tr>';
} }
if ($ret > 0) { if ($ret > 0) {
setEventMessages($printer->error, $printer->errors, 'errors'); setEventMessages($printer->error, $printer->errors, 'errors');
} else { } else {
for ($line = 0; $line < $nbofprinters; $line++) { for ($line = 0; $line < $nbofprinters; $line++) {
print '<tr class="oddeven">'; print '<tr class="oddeven">';
if ($action == 'editprinter' && $printer->listprinters[$line]['rowid'] == $printerid) { if ($action == 'editprinter' && $printer->listprinters[$line]['rowid'] == $printerid) {
print '<input type="hidden" name="printerid" value="'.$printer->listprinters[$line]['rowid'].'">'; print '<input type="hidden" name="printerid" value="'.$printer->listprinters[$line]['rowid'].'">';
print '<td><input size="50" type="text" name="printername" value="'.$printer->listprinters[$line]['name'].'"></td>'; print '<td><input size="50" type="text" name="printername" value="'.$printer->listprinters[$line]['name'].'"></td>';
$ret = $printer->selectTypePrinter($printer->listprinters[$line]['fk_type']); $ret = $printer->selectTypePrinter($printer->listprinters[$line]['fk_type']);
print '<td>'.$printer->resprint.'</td>'; print '<td>'.$printer->resprint.'</td>';
$ret = $printer->selectProfilePrinter($printer->listprinters[$line]['fk_profile']); $ret = $printer->selectProfilePrinter($printer->listprinters[$line]['fk_profile']);
print '<td>'.$printer->profileresprint.'</td>'; print '<td>'.$printer->profileresprint.'</td>';
print '<td><input size="60" type="text" name="parameter" value="'.$printer->listprinters[$line]['parameter'].'"></td>'; print '<td><input size="60" type="text" name="parameter" value="'.$printer->listprinters[$line]['parameter'].'"></td>';
print '<td>'; print '<td>';
print '<div class="center"><input type="submit" class="button" value="'.dol_escape_htmltag($langs->trans("Save")).'"></div>'; print '<div class="center"><input type="submit" class="button" value="'.dol_escape_htmltag($langs->trans("Save")).'"></div>';
print '</td>'; print '</td>';
print '</tr>'; print '</tr>';
} else { } else {
print '<td>'.$printer->listprinters[$line]['name'].'</td>'; print '<td>'.$printer->listprinters[$line]['name'].'</td>';
print '<td>'.$langs->trans($printer->listprinters[$line]['fk_type_name']).'</td>'; print '<td>'.$langs->trans($printer->listprinters[$line]['fk_type_name']).'</td>';
print '<td>'.$langs->trans($printer->listprinters[$line]['fk_profile_name']).'</td>'; print '<td>'.$langs->trans($printer->listprinters[$line]['fk_profile_name']).'</td>';
print '<td>'.$printer->listprinters[$line]['parameter'].'</td>'; print '<td>'.$printer->listprinters[$line]['parameter'].'</td>';
// edit icon // edit icon
print '<td class="right"><a class="editfielda marginrightonly" href="'.$_SERVER['PHP_SELF'].'?mode=config&amp;action=editprinter&amp;printerid='.$printer->listprinters[$line]['rowid'].'">'; print '<td class="right"><a class="editfielda marginrightonly" href="'.$_SERVER['PHP_SELF'].'?mode=config&amp;action=editprinter&amp;printerid='.$printer->listprinters[$line]['rowid'].'">';
print img_picto($langs->trans("Edit"), 'edit'); print img_picto($langs->trans("Edit"), 'edit');
print '</a>'; print '</a>';
// delete icon // delete icon
print '<a class="marginrightonly" href="'.$_SERVER['PHP_SELF'].'?mode=config&amp;action=deleteprinter&amp;token='.newToken().'&amp;printerid='.$printer->listprinters[$line]['rowid'].'&amp;printername='.$printer->listprinters[$line]['name'].'">'; print '<a class="marginrightonly" href="'.$_SERVER['PHP_SELF'].'?mode=config&amp;action=deleteprinter&amp;token='.newToken().'&amp;printerid='.$printer->listprinters[$line]['rowid'].'&amp;printername='.$printer->listprinters[$line]['name'].'">';
print img_picto($langs->trans("Delete"), 'delete'); print img_picto($langs->trans("Delete"), 'delete');
print '</a>'; print '</a>';
// test icon // test icon
print '<a class="marginrightonly" href="'.$_SERVER['PHP_SELF'].'?mode=config&amp;action=testprinter&amp;token='.newToken().'&amp;printerid='.$printer->listprinters[$line]['rowid'].'&amp;printername='.$printer->listprinters[$line]['name'].'">'; print '<a class="marginrightonly" href="'.$_SERVER['PHP_SELF'].'?mode=config&amp;action=testprinter&amp;token='.newToken().'&amp;printerid='.$printer->listprinters[$line]['rowid'].'&amp;printername='.$printer->listprinters[$line]['name'].'">';
print img_picto($langs->trans("TestPrinter"), 'printer'); print img_picto($langs->trans("TestPrinter"), 'printer');
print '</a></td>'; print '</a></td>';
print '</tr>'; print '</tr>';
} }
} }
} }
print '</table>'; print '</table>';
dol_fiche_end(); dol_fiche_end();
print '</form>'; print '</form>';
print '<br>'; print '<br>';
print load_fiche_titre($langs->trans("ReceiptPrinterTypeDesc"), '', '')."\n"; print load_fiche_titre($langs->trans("ReceiptPrinterTypeDesc"), '', '')."\n";
print '<table class="noborder centpercent">'."\n"; print '<table class="noborder centpercent">'."\n";
print '<tr class="oddeven"><td>'.$langs->trans("CONNECTOR_DUMMY").':</td><td>'.$langs->trans("CONNECTOR_DUMMY_HELP").'</td></tr>'; print '<tr class="oddeven"><td>'.$langs->trans("CONNECTOR_DUMMY").':</td><td>'.$langs->trans("CONNECTOR_DUMMY_HELP").'</td></tr>';
print '<tr class="oddeven"><td>'.$langs->trans("CONNECTOR_NETWORK_PRINT").':</td><td>'.$langs->trans("CONNECTOR_NETWORK_PRINT_HELP").'</td></tr>'; print '<tr class="oddeven"><td>'.$langs->trans("CONNECTOR_NETWORK_PRINT").':</td><td>'.$langs->trans("CONNECTOR_NETWORK_PRINT_HELP").'</td></tr>';
print '<tr class="oddeven"><td>'.$langs->trans("CONNECTOR_FILE_PRINT").':</td><td>'.$langs->trans("CONNECTOR_FILE_PRINT_HELP").'</td></tr>'; print '<tr class="oddeven"><td>'.$langs->trans("CONNECTOR_FILE_PRINT").':</td><td>'.$langs->trans("CONNECTOR_FILE_PRINT_HELP").'</td></tr>';
print '<tr class="oddeven"><td>'.$langs->trans("CONNECTOR_WINDOWS_PRINT").':</td><td>'.$langs->trans("CONNECTOR_WINDOWS_PRINT_HELP").'</td></tr>'; print '<tr class="oddeven"><td>'.$langs->trans("CONNECTOR_WINDOWS_PRINT").':</td><td>'.$langs->trans("CONNECTOR_WINDOWS_PRINT_HELP").'</td></tr>';
print '<tr class="oddeven"><td>'.$langs->trans("CONNECTOR_CUPS_PRINT").':</td><td>'.$langs->trans("CONNECTOR_CUPS_PRINT_HELP").'</td></tr>'; print '<tr class="oddeven"><td>'.$langs->trans("CONNECTOR_CUPS_PRINT").':</td><td>'.$langs->trans("CONNECTOR_CUPS_PRINT_HELP").'</td></tr>';
print '</table>'; print '</table>';
print '<br>'; print '<br>';
print load_fiche_titre($langs->trans("ReceiptPrinterProfileDesc"), '', '')."\n"; print load_fiche_titre($langs->trans("ReceiptPrinterProfileDesc"), '', '')."\n";
print '<table class="noborder centpercent">'."\n"; print '<table class="noborder centpercent">'."\n";
print '<tr class="oddeven"><td>'.$langs->trans("PROFILE_DEFAULT").':</td><td>'.$langs->trans("PROFILE_DEFAULT_HELP").'</td></tr>'; print '<tr class="oddeven"><td>'.$langs->trans("PROFILE_DEFAULT").':</td><td>'.$langs->trans("PROFILE_DEFAULT_HELP").'</td></tr>';
print '<tr class="oddeven"><td>'.$langs->trans("PROFILE_SIMPLE").':</td><td>'.$langs->trans("PROFILE_SIMPLE_HELP").'</td></tr>'; print '<tr class="oddeven"><td>'.$langs->trans("PROFILE_SIMPLE").':</td><td>'.$langs->trans("PROFILE_SIMPLE_HELP").'</td></tr>';
print '<tr class="oddeven"><td>'.$langs->trans("PROFILE_EPOSTEP").':</td><td>'.$langs->trans("PROFILE_EPOSTEP_HELP").'</td></tr>'; print '<tr class="oddeven"><td>'.$langs->trans("PROFILE_EPOSTEP").':</td><td>'.$langs->trans("PROFILE_EPOSTEP_HELP").'</td></tr>';
print '<tr class="oddeven"><td>'.$langs->trans("PROFILE_P822D").':</td><td>'.$langs->trans("PROFILE_P822D_HELP").'</td></tr>'; print '<tr class="oddeven"><td>'.$langs->trans("PROFILE_P822D").':</td><td>'.$langs->trans("PROFILE_P822D_HELP").'</td></tr>';
print '<tr class="oddeven"><td>'.$langs->trans("PROFILE_STAR").':</td><td>'.$langs->trans("PROFILE_STAR_HELP").'</td></tr>'; print '<tr class="oddeven"><td>'.$langs->trans("PROFILE_STAR").':</td><td>'.$langs->trans("PROFILE_STAR_HELP").'</td></tr>';
print '</table>'; print '</table>';
} }
// mode = template // mode = template
@ -390,56 +390,56 @@ if ($mode == 'template' && $user->admin) {
dol_fiche_head($head, $mode, $langs->trans("ModuleSetup"), -1, 'technic'); dol_fiche_head($head, $mode, $langs->trans("ModuleSetup"), -1, 'technic');
print '<form method="post" action="'.$_SERVER["PHP_SELF"].'?mode=template" autocomplete="off">'; print '<form method="post" action="'.$_SERVER["PHP_SELF"].'?mode=template" autocomplete="off">';
print '<input type="hidden" name="token" value="'.newToken().'">'; print '<input type="hidden" name="token" value="'.newToken().'">';
if ($action != 'edittemplate') { if ($action != 'edittemplate') {
print '<input type="hidden" name="action" value="addtemplate">'; print '<input type="hidden" name="action" value="addtemplate">';
} else { } else {
print '<input type="hidden" name="action" value="updatetemplate">'; print '<input type="hidden" name="action" value="updatetemplate">';
} }
print '<table class="noborder centpercent">'."\n"; print '<table class="noborder centpercent">'."\n";
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print '<th>'.$langs->trans("Name").'</th>'; print '<th>'.$langs->trans("Name").'</th>';
print '<th>'.$langs->trans("Template").'</th>'; print '<th>'.$langs->trans("Template").'</th>';
print '<th></th>'; print '<th></th>';
print "</tr>\n"; print "</tr>\n";
$ret = $printer->listPrintersTemplates(); $ret = $printer->listPrintersTemplates();
//print '<pre>'.print_r($printer->listprinterstemplates, true).'</pre>'; //print '<pre>'.print_r($printer->listprinterstemplates, true).'</pre>';
if ($ret > 0) { if ($ret > 0) {
setEventMessages($printer->error, $printer->errors, 'errors'); setEventMessages($printer->error, $printer->errors, 'errors');
} else { } else {
$max = count($printer->listprinterstemplates); $max = count($printer->listprinterstemplates);
for ($line = 0; $line < $max; $line++) { for ($line = 0; $line < $max; $line++) {
print '<tr class="oddeven">'; print '<tr class="oddeven">';
if ($action == 'edittemplate' && $printer->listprinterstemplates[$line]['rowid'] == $templateid) { if ($action == 'edittemplate' && $printer->listprinterstemplates[$line]['rowid'] == $templateid) {
print '<input type="hidden" name="templateid" value="'.$printer->listprinterstemplates[$line]['rowid'].'">'; print '<input type="hidden" name="templateid" value="'.$printer->listprinterstemplates[$line]['rowid'].'">';
print '<td><input size="50" type="text" name="templatename" value="'.$printer->listprinterstemplates[$line]['name'].'"></td>'; print '<td><input size="50" type="text" name="templatename" value="'.$printer->listprinterstemplates[$line]['name'].'"></td>';
print '<td>'; print '<td>';
print '<textarea name="template" wrap="soft" cols="120" rows="12">'.$printer->listprinterstemplates[$line]['template'].'</textarea>'; print '<textarea name="template" wrap="soft" cols="120" rows="12">'.$printer->listprinterstemplates[$line]['template'].'</textarea>';
print '</td>'; print '</td>';
print '<td></td>'; print '<td></td>';
} else { } else {
print '<td>'.$printer->listprinterstemplates[$line]['name'].'</td>'; print '<td>'.$printer->listprinterstemplates[$line]['name'].'</td>';
print '<td>'.nl2br(htmlentities($printer->listprinterstemplates[$line]['template'])).'</td>'; print '<td>'.nl2br(htmlentities($printer->listprinterstemplates[$line]['template'])).'</td>';
// edit icon // edit icon
print '<td><a class="editfielda paddingleftonly marginrightonly" href="'.$_SERVER['PHP_SELF'].'?mode=template&amp;action=edittemplate&amp;templateid='.$printer->listprinterstemplates[$line]['rowid'].'">'; print '<td><a class="editfielda paddingleftonly marginrightonly" href="'.$_SERVER['PHP_SELF'].'?mode=template&amp;action=edittemplate&amp;templateid='.$printer->listprinterstemplates[$line]['rowid'].'">';
print img_picto($langs->trans("Edit"), 'edit'); print img_picto($langs->trans("Edit"), 'edit');
print '</a>'; print '</a>';
// delete icon // delete icon
print '<a class="paddingleftonly marginrightonly" href="'.$_SERVER['PHP_SELF'].'?mode=template&amp;action=deletetemplate&amp;templateid='.$printer->listprinterstemplates[$line]['rowid'].'&amp;templatename='.$printer->listprinterstemplates[$line]['name'].'">'; print '<a class="paddingleftonly marginrightonly" href="'.$_SERVER['PHP_SELF'].'?mode=template&amp;action=deletetemplate&amp;templateid='.$printer->listprinterstemplates[$line]['rowid'].'&amp;templatename='.$printer->listprinterstemplates[$line]['name'].'">';
print img_picto($langs->trans("Delete"), 'delete'); print img_picto($langs->trans("Delete"), 'delete');
print '</a>'; print '</a>';
// test icon // test icon
print '<a class="paddingleftonly marginrightonly" href="'.$_SERVER['PHP_SELF'].'?mode=template&amp;action=testtemplate&amp;templateid='.$printer->listprinterstemplates[$line]['rowid'].'&amp;templatename='.$printer->listprinterstemplates[$line]['name'].'">'; print '<a class="paddingleftonly marginrightonly" href="'.$_SERVER['PHP_SELF'].'?mode=template&amp;action=testtemplate&amp;templateid='.$printer->listprinterstemplates[$line]['rowid'].'&amp;templatename='.$printer->listprinterstemplates[$line]['name'].'">';
print img_picto($langs->trans("TestPrinterTemplate"), 'printer'); print img_picto($langs->trans("TestPrinterTemplate"), 'printer');
print '</a></td>'; print '</a></td>';
} }
print '</tr>'; print '</tr>';
} }
} }
if ($action != 'edittemplate') { if ($action != 'edittemplate') {
print '<tr>'; print '<tr>';
print '<td><input size="50" type="text" name="templatename" value="'.$printer->listprinterstemplates[$line]['name'].'"></td>'; print '<td><input size="50" type="text" name="templatename" value="'.$printer->listprinterstemplates[$line]['name'].'"></td>';
print '<td>'; print '<td>';
print '<textarea name="template" wrap="soft" cols="120" rows="12">'; print '<textarea name="template" wrap="soft" cols="120" rows="12">';
@ -448,35 +448,35 @@ if ($mode == 'template' && $user->admin) {
print '</td>'; print '</td>';
print '<td></td>'; print '<td></td>';
print '</tr>'; print '</tr>';
} }
print '</table>'; print '</table>';
if ($action != 'edittemplate') { if ($action != 'edittemplate') {
print '<input type="hidden" name="templateid" value="'.$printer->listprinterstemplates[$line]['rowid'].'">'; print '<input type="hidden" name="templateid" value="'.$printer->listprinterstemplates[$line]['rowid'].'">';
print '<div class="center"><input type="submit" class="button" value="'.dol_escape_htmltag($langs->trans("Add")).'"></div>'; print '<div class="center"><input type="submit" class="button" value="'.dol_escape_htmltag($langs->trans("Add")).'"></div>';
} else { } else {
print '<div class="center"><input type="submit" class="button" value="'.dol_escape_htmltag($langs->trans("Save")).'"></div>'; print '<div class="center"><input type="submit" class="button" value="'.dol_escape_htmltag($langs->trans("Save")).'"></div>';
} }
print '</form>'; print '</form>';
dol_fiche_end(); dol_fiche_end();
print '<br>'; print '<br>';
print '<table class="noborder centpercent">'."\n"; print '<table class="noborder centpercent">'."\n";
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print '<th>'.$langs->trans("Tag").'</th>'; print '<th>'.$langs->trans("Tag").'</th>';
print '<th>'.$langs->trans("Description").'</th>'; print '<th>'.$langs->trans("Description").'</th>';
print "</tr>\n"; print "</tr>\n";
$langs->loadLangs(array("bills", "companies")); $langs->loadLangs(array("bills", "companies"));
foreach ($printer->tags as $key => $val) { foreach ($printer->tags as $key => $val) {
print '<tr class="oddeven">'; print '<tr class="oddeven">';
print '<td>&lt;'.$key.'&gt;</td><td>'.$langs->trans($val).'</td>'; print '<td>&lt;'.$key.'&gt;</td><td>'.$langs->trans($val).'</td>';
print '</tr>'; print '</tr>';
} }
print '</table>'; print '</table>';
} }
// End of page // End of page

View File

@ -45,9 +45,9 @@ $upload_dir = $conf->admin->dir_temp;
if (GETPOST('sendit') && !empty($conf->global->MAIN_UPLOAD_DOC)) if (GETPOST('sendit') && !empty($conf->global->MAIN_UPLOAD_DOC))
{ {
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
dol_add_file_process($upload_dir, 1, 0, 'userfile'); dol_add_file_process($upload_dir, 1, 0, 'userfile');
} }
if ($action == 'updateform') if ($action == 'updateform')
@ -144,14 +144,14 @@ print '</td>';
print '<td>'; print '<td>';
if (ini_get('safe_mode') && !empty($conf->global->MAIN_ANTIVIRUS_COMMAND)) if (ini_get('safe_mode') && !empty($conf->global->MAIN_ANTIVIRUS_COMMAND))
{ {
$langs->load("errors"); $langs->load("errors");
$basedir = preg_replace('/"/', '', dirname($conf->global->MAIN_ANTIVIRUS_COMMAND)); $basedir = preg_replace('/"/', '', dirname($conf->global->MAIN_ANTIVIRUS_COMMAND));
$listdir = explode(';', ini_get('safe_mode_exec_dir')); $listdir = explode(';', ini_get('safe_mode_exec_dir'));
if (!in_array($basedir, $listdir)) if (!in_array($basedir, $listdir))
{ {
print img_warning($langs->trans('WarningSafeModeOnCheckExecDir')); print img_warning($langs->trans('WarningSafeModeOnCheckExecDir'));
dol_syslog("safe_mode is on, basedir is ".$basedir.", safe_mode_exec_dir is ".ini_get('safe_mode_exec_dir'), LOG_WARNING); dol_syslog("safe_mode is on, basedir is ".$basedir.", safe_mode_exec_dir is ".ini_get('safe_mode_exec_dir'), LOG_WARNING);
} }
} }
print '<input type="text" name="MAIN_ANTIVIRUS_COMMAND" class="minwidth500imp" value="'.(!empty($conf->global->MAIN_ANTIVIRUS_COMMAND) ?dol_escape_htmltag($conf->global->MAIN_ANTIVIRUS_COMMAND) : '').'">'; print '<input type="text" name="MAIN_ANTIVIRUS_COMMAND" class="minwidth500imp" value="'.(!empty($conf->global->MAIN_ANTIVIRUS_COMMAND) ?dol_escape_htmltag($conf->global->MAIN_ANTIVIRUS_COMMAND) : '').'">';
if (defined('MAIN_ANTIVIRUS_COMMAND')) { if (defined('MAIN_ANTIVIRUS_COMMAND')) {

View File

@ -155,19 +155,19 @@ print '<td class="tdtop">';
print '<div id="div_container_exportoptions">'; print '<div id="div_container_exportoptions">';
print '<fieldset id="exportoptions"><legend>'.$langs->trans("ExportMethod").'</legend>'; print '<fieldset id="exportoptions"><legend>'.$langs->trans("ExportMethod").'</legend>';
if (in_array($type, array('mysql', 'mysqli'))) { if (in_array($type, array('mysql', 'mysqli'))) {
print '<div class="formelementrow"><input type="radio" name="what" value="mysql" id="radio_dump_mysql" />'; print '<div class="formelementrow"><input type="radio" name="what" value="mysql" id="radio_dump_mysql" />';
print '<label for="radio_dump_mysql">MySQL Dump (mysqldump)</label>'; print '<label for="radio_dump_mysql">MySQL Dump (mysqldump)</label>';
print '</div>'; print '</div>';
print '<br>'; print '<br>';
print '<div class="formelementrow"><input type="radio" name="what" value="mysqlnobin" id="radio_dump_mysql_nobin" />'; print '<div class="formelementrow"><input type="radio" name="what" value="mysqlnobin" id="radio_dump_mysql_nobin" />';
print '<label for="radio_dump_mysql_nobin">MySQL Dump (php) '.img_warning($langs->trans('BackupPHPWarning')).'</label>'; print '<label for="radio_dump_mysql_nobin">MySQL Dump (php) '.img_warning($langs->trans('BackupPHPWarning')).'</label>';
print '</div>'; print '</div>';
} elseif (in_array($type, array('pgsql'))) { } elseif (in_array($type, array('pgsql'))) {
print '<div class="formelementrow"><input type="radio" name="what" value="postgresql" id="radio_dump_postgresql" />'; print '<div class="formelementrow"><input type="radio" name="what" value="postgresql" id="radio_dump_postgresql" />';
print '<label for="radio_dump_postgresql">PostgreSQL Dump (pg_dump)</label>'; print '<label for="radio_dump_postgresql">PostgreSQL Dump (pg_dump)</label>';
print '</div>'; print '</div>';
} else { } else {
print 'No method available with database '.$label; print 'No method available with database '.$label;
} }
print '</fieldset>'; print '</fieldset>';
print '</div>'; print '</div>';
@ -178,200 +178,200 @@ print '<td class="tdtop">';
print '<div id="div_container_sub_exportoptions">'; print '<div id="div_container_sub_exportoptions">';
if (in_array($type, array('mysql', 'mysqli'))) { if (in_array($type, array('mysql', 'mysqli'))) {
print "<!-- Fieldset mysqldump -->\n"; print "<!-- Fieldset mysqldump -->\n";
print '<fieldset id="mysql_options"><legend>'.$langs->trans("MySqlExportParameters").'</legend>'; print '<fieldset id="mysql_options"><legend>'.$langs->trans("MySqlExportParameters").'</legend>';
print '<div class="formelementrow">'.$langs->trans("FullPathToMysqldumpCommand"); print '<div class="formelementrow">'.$langs->trans("FullPathToMysqldumpCommand");
if (empty($conf->global->SYSTEMTOOLS_MYSQLDUMP)) if (empty($conf->global->SYSTEMTOOLS_MYSQLDUMP))
{ {
$fullpathofmysqldump = $db->getPathOfDump(); $fullpathofmysqldump = $db->getPathOfDump();
} else { } else {
$fullpathofmysqldump = $conf->global->SYSTEMTOOLS_MYSQLDUMP; $fullpathofmysqldump = $conf->global->SYSTEMTOOLS_MYSQLDUMP;
} }
print '<br>'; print '<br>';
print '<input type="text" name="mysqldump" style="width: 80%" value="'.$fullpathofmysqldump.'" /></div>'; print '<input type="text" name="mysqldump" style="width: 80%" value="'.$fullpathofmysqldump.'" /></div>';
print '<br>'; print '<br>';
print '<fieldset><legend>'.$langs->trans("ExportOptions").'</legend>'; print '<fieldset><legend>'.$langs->trans("ExportOptions").'</legend>';
print '<div class="formelementrow">'; print '<div class="formelementrow">';
print '<input type="checkbox" name="use_transaction" value="yes" id="checkbox_use_transaction" />'; print '<input type="checkbox" name="use_transaction" value="yes" id="checkbox_use_transaction" />';
print '<label for="checkbox_use_transaction">'.$langs->trans("UseTransactionnalMode").'</label>'; print '<label for="checkbox_use_transaction">'.$langs->trans("UseTransactionnalMode").'</label>';
print '</div>'; print '</div>';
if (!empty($conf->global->MYSQL_OLD_OPTION_DISABLE_FK)) { if (!empty($conf->global->MYSQL_OLD_OPTION_DISABLE_FK)) {
print '<div class="formelementrow">'; print '<div class="formelementrow">';
print '<input type="checkbox" name="disable_fk" value="yes" id="checkbox_disable_fk" checked />'; print '<input type="checkbox" name="disable_fk" value="yes" id="checkbox_disable_fk" checked />';
print '<label for="checkbox_disable_fk">'.$langs->trans("CommandsToDisableForeignKeysForImport").' '.img_info($langs->trans('CommandsToDisableForeignKeysForImportWarning')).'</label>'; print '<label for="checkbox_disable_fk">'.$langs->trans("CommandsToDisableForeignKeysForImport").' '.img_info($langs->trans('CommandsToDisableForeignKeysForImportWarning')).'</label>';
print '</div>'; print '</div>';
} }
print '<label for="select_sql_compat">'.$langs->trans("ExportCompatibility").'</label>'; print '<label for="select_sql_compat">'.$langs->trans("ExportCompatibility").'</label>';
print '<select name="sql_compat" id="select_sql_compat" class="flat">'; print '<select name="sql_compat" id="select_sql_compat" class="flat">';
print '<option value="NONE" selected>NONE</option>'; print '<option value="NONE" selected>NONE</option>';
print '<option value="ANSI">ANSI</option>'; print '<option value="ANSI">ANSI</option>';
print '<option value="DB2">DB2</option>'; print '<option value="DB2">DB2</option>';
print '<option value="MAXDB">MAXDB</option>'; print '<option value="MAXDB">MAXDB</option>';
print '<option value="MYSQL323">MYSQL323</option>'; print '<option value="MYSQL323">MYSQL323</option>';
print '<option value="MYSQL40">MYSQL40</option>'; print '<option value="MYSQL40">MYSQL40</option>';
print '<option value="MSSQL">MSSQL</option>'; print '<option value="MSSQL">MSSQL</option>';
print '<option value="ORACLE">ORACLE</option>'; print '<option value="ORACLE">ORACLE</option>';
print '<option value="POSTGRESQL">POSTGRESQL</option>'; print '<option value="POSTGRESQL">POSTGRESQL</option>';
print '</select>'; print '</select>';
print '<br>'; print '<br>';
print '<input type="checkbox" name="use_mysql_quick_param" value="yes" id="checkbox_use_quick" />'; print '<input type="checkbox" name="use_mysql_quick_param" value="yes" id="checkbox_use_quick" />';
print '<label for="checkbox_use_quick">'; print '<label for="checkbox_use_quick">';
print $form->textwithpicto($langs->trans('ExportUseMySQLQuickParameter'), $langs->trans('ExportUseMySQLQuickParameterHelp')); print $form->textwithpicto($langs->trans('ExportUseMySQLQuickParameter'), $langs->trans('ExportUseMySQLQuickParameterHelp'));
print '</label>'; print '</label>';
print '<br/>'; print '<br/>';
print '<!-- <input type="checkbox" name="drop_database" value="yes" id="checkbox_drop_database" />'; print '<!-- <input type="checkbox" name="drop_database" value="yes" id="checkbox_drop_database" />';
print '<label for="checkbox_drop_database">'.$langs->trans("AddDropDatabase").'</label>'; print '<label for="checkbox_drop_database">'.$langs->trans("AddDropDatabase").'</label>';
print '-->'; print '-->';
print '</fieldset>'; print '</fieldset>';
print '<br>'; print '<br>';
print '<fieldset>'; print '<fieldset>';
print '<legend>'; print '<legend>';
print '<input type="checkbox" name="sql_structure" value="structure" id="checkbox_sql_structure" checked />'; print '<input type="checkbox" name="sql_structure" value="structure" id="checkbox_sql_structure" checked />';
print '<label for="checkbox_sql_structure">'.$langs->trans('ExportStructure').'</label>'; print '<label for="checkbox_sql_structure">'.$langs->trans('ExportStructure').'</label>';
print '</legend>'; print '</legend>';
print '<input type="checkbox" name="drop"'.((! GETPOSTISSET("drop") || GETPOST('drop')) ? ' checked' : '').' id="checkbox_dump_drop" />'; print '<input type="checkbox" name="drop"'.((! GETPOSTISSET("drop") || GETPOST('drop')) ? ' checked' : '').' id="checkbox_dump_drop" />';
print '<label for="checkbox_dump_drop">'.$langs->trans("AddDropTable").'</label>'; print '<label for="checkbox_dump_drop">'.$langs->trans("AddDropTable").'</label>';
print '<br>'; print '<br>';
print '</fieldset>'; print '</fieldset>';
print '<br>'; print '<br>';
print '<fieldset>'; print '<fieldset>';
print '<legend>'; print '<legend>';
print '<input type="checkbox" name="sql_data" value="data" id="checkbox_sql_data" checked />'; print '<input type="checkbox" name="sql_data" value="data" id="checkbox_sql_data" checked />';
print '<label for="checkbox_sql_data">'.$langs->trans("Datas").'</label>'; print '<label for="checkbox_sql_data">'.$langs->trans("Datas").'</label>';
print '</legend>'; print '</legend>';
print '<input type="checkbox" name="showcolumns" value="yes" id="checkbox_dump_showcolumns" checked />'; print '<input type="checkbox" name="showcolumns" value="yes" id="checkbox_dump_showcolumns" checked />';
print '<label for="checkbox_dump_showcolumns">'.$langs->trans("NameColumn").'</label>'; print '<label for="checkbox_dump_showcolumns">'.$langs->trans("NameColumn").'</label>';
print '<br>'; print '<br>';
print '<input type="checkbox" name="extended_ins" value="yes" id="checkbox_dump_extended_ins" checked />'; print '<input type="checkbox" name="extended_ins" value="yes" id="checkbox_dump_extended_ins" checked />';
print '<label for="checkbox_dump_extended_ins">'.$langs->trans("ExtendedInsert").'</label>'; print '<label for="checkbox_dump_extended_ins">'.$langs->trans("ExtendedInsert").'</label>';
print '<br>'; print '<br>';
print '<input type="checkbox" name="disable-add-locks" value="no" id="checkbox_dump_disable-add-locks" />'; print '<input type="checkbox" name="disable-add-locks" value="no" id="checkbox_dump_disable-add-locks" />';
print '<label for="checkbox_dump_disable-add-locks">'.$langs->trans("NoLockBeforeInsert").'</label>'; print '<label for="checkbox_dump_disable-add-locks">'.$langs->trans("NoLockBeforeInsert").'</label>';
print '<br>'; print '<br>';
print '<input type="checkbox" name="delayed" value="yes" id="checkbox_dump_delayed" />'; print '<input type="checkbox" name="delayed" value="yes" id="checkbox_dump_delayed" />';
print '<label for="checkbox_dump_delayed">'.$langs->trans("DelayedInsert").'</label>'; print '<label for="checkbox_dump_delayed">'.$langs->trans("DelayedInsert").'</label>';
print '<br>'; print '<br>';
print '<input type="checkbox" name="sql_ignore" value="yes" id="checkbox_dump_ignore" />'; print '<input type="checkbox" name="sql_ignore" value="yes" id="checkbox_dump_ignore" />';
print '<label for="checkbox_dump_ignore">'.$langs->trans("IgnoreDuplicateRecords").'</label>'; print '<label for="checkbox_dump_ignore">'.$langs->trans("IgnoreDuplicateRecords").'</label>';
print '<br>'; print '<br>';
print '<input type="checkbox" name="hexforbinary" value="yes" id="checkbox_hexforbinary" checked />'; print '<input type="checkbox" name="hexforbinary" value="yes" id="checkbox_hexforbinary" checked />';
print '<label for="checkbox_hexforbinary">'.$langs->trans("EncodeBinariesInHexa").'</label>'; print '<label for="checkbox_hexforbinary">'.$langs->trans("EncodeBinariesInHexa").'</label>';
print '<br>'; print '<br>';
print '<input type="checkbox" name="charset_utf8" value="yes" id="checkbox_charset_utf8" checked disabled />'; print '<input type="checkbox" name="charset_utf8" value="yes" id="checkbox_charset_utf8" checked disabled />';
print '<label for="checkbox_charset_utf8">'.$langs->trans("UTF8").'</label>'; print '<label for="checkbox_charset_utf8">'.$langs->trans("UTF8").'</label>';
print '<br>'; print '<br>';
print '</fieldset>'; print '</fieldset>';
print '</fieldset>'; print '</fieldset>';
print "<!-- Fieldset mysql_nobin -->\n"; print "<!-- Fieldset mysql_nobin -->\n";
print '<fieldset id="mysql_nobin_options">'; print '<fieldset id="mysql_nobin_options">';
print '<legend>'.$langs->trans("MySqlExportParameters").'</legend>'; print '<legend>'.$langs->trans("MySqlExportParameters").'</legend>';
print '<fieldset>'; print '<fieldset>';
print '<legend>'.$langs->trans("ExportOptions").'</legend>'; print '<legend>'.$langs->trans("ExportOptions").'</legend>';
print '<div class="formelementrow">'; print '<div class="formelementrow">';
print '<input type="checkbox" name="nobin_use_transaction" value="yes" id="checkbox_use_transaction" />'; print '<input type="checkbox" name="nobin_use_transaction" value="yes" id="checkbox_use_transaction" />';
print '<label for="checkbox_use_transaction">'.$langs->trans("UseTransactionnalMode").'</label>'; print '<label for="checkbox_use_transaction">'.$langs->trans("UseTransactionnalMode").'</label>';
print '</div>'; print '</div>';
if (!empty($conf->global->MYSQL_OLD_OPTION_DISABLE_FK)) { if (!empty($conf->global->MYSQL_OLD_OPTION_DISABLE_FK)) {
print '<div class="formelementrow">'; print '<div class="formelementrow">';
print '<input type="checkbox" name="nobin_disable_fk" value="yes" id="checkbox_disable_fk" checked />'; print '<input type="checkbox" name="nobin_disable_fk" value="yes" id="checkbox_disable_fk" checked />';
print '<label for="checkbox_disable_fk">'.$langs->trans("CommandsToDisableForeignKeysForImport").' '.img_info($langs->trans('CommandsToDisableForeignKeysForImportWarning')).'</label>'; print '<label for="checkbox_disable_fk">'.$langs->trans("CommandsToDisableForeignKeysForImport").' '.img_info($langs->trans('CommandsToDisableForeignKeysForImportWarning')).'</label>';
print '</div>'; print '</div>';
} }
print '</fieldset>'; print '</fieldset>';
print '<br>'; print '<br>';
print '<fieldset><legend>'.$langs->trans('ExportStructure').'</legend>'; print '<fieldset><legend>'.$langs->trans('ExportStructure').'</legend>';
print '<input type="checkbox" name="nobin_drop"'.((! GETPOSTISSET("nobin_drop") || GETPOST('nobin_drop')) ? ' checked' : '').' id="checkbox_dump_drop" />'; print '<input type="checkbox" name="nobin_drop"'.((! GETPOSTISSET("nobin_drop") || GETPOST('nobin_drop')) ? ' checked' : '').' id="checkbox_dump_drop" />';
print '<label for="checkbox_dump_drop">'.$langs->trans("AddDropTable").'</label>'; print '<label for="checkbox_dump_drop">'.$langs->trans("AddDropTable").'</label>';
print '<br>'; print '<br>';
print '</fieldset>'; print '</fieldset>';
print '<br>'; print '<br>';
print '<fieldset>'; print '<fieldset>';
print '<legend>'.$langs->trans("Datas").'</legend>'; print '<legend>'.$langs->trans("Datas").'</legend>';
print '<input type="checkbox" name="nobin_nolocks" value="no" id="checkbox_dump_disable-add-locks" />'; print '<input type="checkbox" name="nobin_nolocks" value="no" id="checkbox_dump_disable-add-locks" />';
print '<label for="checkbox_dump_disable-add-locks">'.$langs->trans("NoLockBeforeInsert").'</label>'; print '<label for="checkbox_dump_disable-add-locks">'.$langs->trans("NoLockBeforeInsert").'</label>';
print '<br>'; print '<br>';
print '<input type="checkbox" name="nobin_delayed" value="yes" id="checkbox_dump_delayed" />'; print '<input type="checkbox" name="nobin_delayed" value="yes" id="checkbox_dump_delayed" />';
print '<label for="checkbox_dump_delayed">'.$langs->trans("DelayedInsert").'</label>'; print '<label for="checkbox_dump_delayed">'.$langs->trans("DelayedInsert").'</label>';
print '<br>'; print '<br>';
print '<input type="checkbox" name="nobin_sql_ignore" value="yes" id="checkbox_dump_ignore" />'; print '<input type="checkbox" name="nobin_sql_ignore" value="yes" id="checkbox_dump_ignore" />';
print '<label for="checkbox_dump_ignore">'.$langs->trans("IgnoreDuplicateRecords").'</label>'; print '<label for="checkbox_dump_ignore">'.$langs->trans("IgnoreDuplicateRecords").'</label>';
print '<br>'; print '<br>';
print '<input type="checkbox" name="nobin_charset_utf8" value="yes" id="checkbox_charset_utf8" checked disabled />'; print '<input type="checkbox" name="nobin_charset_utf8" value="yes" id="checkbox_charset_utf8" checked disabled />';
print '<label for="checkbox_charset_utf8">'.$langs->trans("UTF8").'</label>'; print '<label for="checkbox_charset_utf8">'.$langs->trans("UTF8").'</label>';
print '<br>'; print '<br>';
print '</fieldset>'; print '</fieldset>';
print '</fieldset>'; print '</fieldset>';
} }
if (in_array($type, array('pgsql'))) { if (in_array($type, array('pgsql'))) {
print "<!-- Fieldset pg_dump -->\n"; print "<!-- Fieldset pg_dump -->\n";
print '<fieldset id="postgresql_options"><legend>'.$langs->trans("PostgreSqlExportParameters").'</legend>'; print '<fieldset id="postgresql_options"><legend>'.$langs->trans("PostgreSqlExportParameters").'</legend>';
print '<div class="formelementrow">'.$langs->trans("FullPathToPostgreSQLdumpCommand"); print '<div class="formelementrow">'.$langs->trans("FullPathToPostgreSQLdumpCommand");
if (empty($conf->global->SYSTEMTOOLS_POSTGRESQLDUMP)) { if (empty($conf->global->SYSTEMTOOLS_POSTGRESQLDUMP)) {
$fullpathofpgdump = $db->getPathOfDump(); $fullpathofpgdump = $db->getPathOfDump();
} else { } else {
$fullpathofpgdump = $conf->global->SYSTEMTOOLS_POSTGRESQLDUMP; $fullpathofpgdump = $conf->global->SYSTEMTOOLS_POSTGRESQLDUMP;
} }
print '<br>'; print '<br>';
print '<input type="text" name="postgresqldump" style="width: 80%" value="'.$fullpathofpgdump.'" /></div>'; print '<input type="text" name="postgresqldump" style="width: 80%" value="'.$fullpathofpgdump.'" /></div>';
print '<br>'; print '<br>';
print '<fieldset>'; print '<fieldset>';
print '<legend>'.$langs->trans("ExportOptions").'</legend>'; print '<legend>'.$langs->trans("ExportOptions").'</legend>';
print '<label for="select_sql_compat">'.$langs->trans("ExportCompatibility").'</label>'; print '<label for="select_sql_compat">'.$langs->trans("ExportCompatibility").'</label>';
print '<select name="sql_compat" id="select_sql_compat" class="flat">'; print '<select name="sql_compat" id="select_sql_compat" class="flat">';
print '<option value="POSTGRESQL" selected>POSTGRESQL</option>'; print '<option value="POSTGRESQL" selected>POSTGRESQL</option>';
print '<option value="ANSI">ANSI</option>'; print '<option value="ANSI">ANSI</option>';
print '</select>'; print '</select>';
print '<br>'; print '<br>';
print '<!-- <input type="checkbox" name="drop_database" value="yes" id="checkbox_drop_database" />'; print '<!-- <input type="checkbox" name="drop_database" value="yes" id="checkbox_drop_database" />';
print '<label for="checkbox_drop_database">'.$langs->trans("AddDropDatabase").'</label>'; print '<label for="checkbox_drop_database">'.$langs->trans("AddDropDatabase").'</label>';
print '-->'; print '-->';
print '</fieldset>'; print '</fieldset>';
print '<br>'; print '<br>';
print '<fieldset>'; print '<fieldset>';
print '<legend>'; print '<legend>';
print '<input type="checkbox" name="sql_structure" value="structure" id="checkbox_sql_structure" checked />'; print '<input type="checkbox" name="sql_structure" value="structure" id="checkbox_sql_structure" checked />';
print '<label for="checkbox_sql_structure">'.$langs->trans('ExportStructure').'</label>'; print '<label for="checkbox_sql_structure">'.$langs->trans('ExportStructure').'</label>';
print '</legend>'; print '</legend>';
print '</fieldset>'; print '</fieldset>';
print '<br>'; print '<br>';
print '<fieldset>'; print '<fieldset>';
print '<legend>'; print '<legend>';
print '<input type="checkbox" name="sql_data" value="data" id="checkbox_sql_data" checked />'; print '<input type="checkbox" name="sql_data" value="data" id="checkbox_sql_data" checked />';
print '<label for="checkbox_sql_data">'.$langs->trans("Datas").'</label>'; print '<label for="checkbox_sql_data">'.$langs->trans("Datas").'</label>';
print '</legend>'; print '</legend>';
print '<input type="checkbox" name="showcolumns" value="yes" id="checkbox_dump_showcolumns" checked />'; print '<input type="checkbox" name="showcolumns" value="yes" id="checkbox_dump_showcolumns" checked />';
print '<label for="checkbox_dump_showcolumns">'.$langs->trans("NameColumn").'</label>'; print '<label for="checkbox_dump_showcolumns">'.$langs->trans("NameColumn").'</label>';
print '<br>'; print '<br>';
print '</fieldset>'; print '</fieldset>';
print '</fieldset>'; print '</fieldset>';
} }
print '</div>'; print '</div>';
@ -418,16 +418,16 @@ if (in_array($type, array('mysql', 'mysqli'))) {
// 'id' => 'radio_compression_zip', // 'id' => 'radio_compression_zip',
// 'label' => $langs->trans("FormatZip") // 'label' => $langs->trans("FormatZip")
// ); // );
$compression['bz'] = array( $compression['bz'] = array(
'function' => 'bzopen', 'function' => 'bzopen',
'id' => 'radio_compression_bzip', 'id' => 'radio_compression_bzip',
'label' => $langs->trans("Bzip2") 'label' => $langs->trans("Bzip2")
); );
$compression['none'] = array( $compression['none'] = array(
'function' => '', 'function' => '',
'id' => 'radio_compression_none', 'id' => 'radio_compression_none',
'label' => $langs->trans("None") 'label' => $langs->trans("None")
); );
} else { } else {
$compression['none'] = array( $compression['none'] = array(
'function' => '', 'function' => '',
@ -480,14 +480,14 @@ print '<br>';
if (!empty($_SESSION["commandbackuplastdone"])) if (!empty($_SESSION["commandbackuplastdone"]))
{ {
print '<br><b>'.$langs->trans("RunCommandSummary").':</b><br>'."\n"; print '<br><b>'.$langs->trans("RunCommandSummary").':</b><br>'."\n";
print '<textarea rows="'.ROWS_2.'" class="centpercent">'.$_SESSION["commandbackuplastdone"].'</textarea><br>'."\n"; print '<textarea rows="'.ROWS_2.'" class="centpercent">'.$_SESSION["commandbackuplastdone"].'</textarea><br>'."\n";
print '<br>'; print '<br>';
//print $paramclear; //print $paramclear;
// Now show result // Now show result
print '<b>'.$langs->trans("BackupResult").':</b> '; print '<b>'.$langs->trans("BackupResult").':</b> ';
print $_SESSION["commandbackupresult"]; print $_SESSION["commandbackupresult"];
$_SESSION["commandbackuplastdone"] = ''; $_SESSION["commandbackuplastdone"] = '';
@ -568,20 +568,20 @@ $filecompression['zip'] = array('function' => 'dol_compress_dir', 'id' => 'radio
$i = 0; $i = 0;
foreach ($filecompression as $key => $val) foreach ($filecompression as $key => $val)
{ {
if (!$val['function'] || function_exists($val['function'])) // Enabled export format if (!$val['function'] || function_exists($val['function'])) // Enabled export format
{ {
$checked = ''; $checked = '';
if ($key == 'gz') $checked = ' checked'; if ($key == 'gz') $checked = ' checked';
print '<input type="radio" name="compression" value="'.$key.'" id="'.$val['id'].'"'.$checked.'>'; print '<input type="radio" name="compression" value="'.$key.'" id="'.$val['id'].'"'.$checked.'>';
print ' <label for="'.$val['id'].'">'.$val['label'].'</label>'; print ' <label for="'.$val['id'].'">'.$val['label'].'</label>';
} else // Disabled export format } else // Disabled export format
{ {
print '<input type="radio" name="compression" value="'.$key.'" id="'.$val['id'].'" disabled>'; print '<input type="radio" name="compression" value="'.$key.'" id="'.$val['id'].'" disabled>';
print ' <label for="'.$val['id'].'">'.$val['label'].'</label>'; print ' <label for="'.$val['id'].'">'.$val['label'].'</label>';
print ' <span class="opacitymedium">('.$langs->trans("NotAvailable").')</span>'; print ' <span class="opacitymedium">('.$langs->trans("NotAvailable").')</span>';
} }
print ' &nbsp; &nbsp; '; print ' &nbsp; &nbsp; ';
$i++; $i++;
} }
print '</div>'; print '</div>';

View File

@ -73,16 +73,16 @@ include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
// Purge search criteria // Purge search criteria
if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All tests are required to be compatible with all browsers if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All tests are required to be compatible with all browsers
{ {
$transkey = ''; $transkey = '';
$transvalue = ''; $transvalue = '';
$toselect = ''; $toselect = '';
$search_array_options = array(); $search_array_options = array();
} }
if ($action == 'setMAIN_ENABLE_OVERWRITE_TRANSLATION') if ($action == 'setMAIN_ENABLE_OVERWRITE_TRANSLATION')
{ {
if (GETPOST('value')) dolibarr_set_const($db, 'MAIN_ENABLE_OVERWRITE_TRANSLATION', 1, 'chaine', 0, '', $conf->entity); if (GETPOST('value')) dolibarr_set_const($db, 'MAIN_ENABLE_OVERWRITE_TRANSLATION', 1, 'chaine', 0, '', $conf->entity);
else dolibarr_set_const($db, 'MAIN_ENABLE_OVERWRITE_TRANSLATION', 0, 'chaine', 0, '', $conf->entity); else dolibarr_set_const($db, 'MAIN_ENABLE_OVERWRITE_TRANSLATION', 0, 'chaine', 0, '', $conf->entity);
} }
if ($action == 'update') if ($action == 'update')
@ -139,25 +139,25 @@ if ($action == 'add')
} }
if (!$error) if (!$error)
{ {
$db->begin(); $db->begin();
$sql = "INSERT INTO ".MAIN_DB_PREFIX."overwrite_trans(lang, transkey, transvalue, entity) VALUES ('".$db->escape($langcode)."','".$db->escape($transkey)."','".$db->escape($transvalue)."', ".$db->escape($conf->entity).")"; $sql = "INSERT INTO ".MAIN_DB_PREFIX."overwrite_trans(lang, transkey, transvalue, entity) VALUES ('".$db->escape($langcode)."','".$db->escape($transkey)."','".$db->escape($transvalue)."', ".$db->escape($conf->entity).")";
$result = $db->query($sql); $result = $db->query($sql);
if ($result > 0) if ($result > 0)
{ {
$db->commit(); $db->commit();
setEventMessages($langs->trans("RecordSaved"), null, 'mesgs'); setEventMessages($langs->trans("RecordSaved"), null, 'mesgs');
$action = ""; $action = "";
$transkey = ""; $transkey = "";
$transvalue = ""; $transvalue = "";
} else { } else {
$db->rollback(); $db->rollback();
if ($db->lasterrno() == 'DB_ERROR_RECORD_ALREADY_EXISTS') if ($db->lasterrno() == 'DB_ERROR_RECORD_ALREADY_EXISTS')
{ {
setEventMessages($langs->trans("WarningAnEntryAlreadyExistForTransKey"), null, 'warnings'); setEventMessages($langs->trans("WarningAnEntryAlreadyExistForTransKey"), null, 'warnings');
} else { } else {
setEventMessages($db->lasterror(), null, 'errors'); setEventMessages($db->lasterror(), null, 'errors');
} }
$action = ''; $action = '';
} }
} }
@ -196,15 +196,15 @@ $enabledisablehtml = '';
$enabledisablehtml .= $langs->trans("EnableOverwriteTranslation").' '; $enabledisablehtml .= $langs->trans("EnableOverwriteTranslation").' ';
if (empty($conf->global->MAIN_ENABLE_OVERWRITE_TRANSLATION)) if (empty($conf->global->MAIN_ENABLE_OVERWRITE_TRANSLATION))
{ {
// Button off, click to enable // Button off, click to enable
$enabledisablehtml .= '<a class="reposition valignmiddle" href="'.$_SERVER["PHP_SELF"].'?action=setMAIN_ENABLE_OVERWRITE_TRANSLATION&token='.newToken().'&value=1'.$param.'">'; $enabledisablehtml .= '<a class="reposition valignmiddle" href="'.$_SERVER["PHP_SELF"].'?action=setMAIN_ENABLE_OVERWRITE_TRANSLATION&token='.newToken().'&value=1'.$param.'">';
$enabledisablehtml .= img_picto($langs->trans("Disabled"), 'switch_off'); $enabledisablehtml .= img_picto($langs->trans("Disabled"), 'switch_off');
$enabledisablehtml .= '</a>'; $enabledisablehtml .= '</a>';
} else { } else {
// Button on, click to disable // Button on, click to disable
$enabledisablehtml .= '<a class="reposition valignmiddle" href="'.$_SERVER["PHP_SELF"].'?action=setMAIN_ENABLE_OVERWRITE_TRANSLATION&token='.newToken().'&value=0'.$param.'">'; $enabledisablehtml .= '<a class="reposition valignmiddle" href="'.$_SERVER["PHP_SELF"].'?action=setMAIN_ENABLE_OVERWRITE_TRANSLATION&token='.newToken().'&value=0'.$param.'">';
$enabledisablehtml .= img_picto($langs->trans("Activated"), 'switch_on'); $enabledisablehtml .= img_picto($langs->trans("Activated"), 'switch_on');
$enabledisablehtml .= '</a>'; $enabledisablehtml .= '</a>';
} }
print load_fiche_titre($langs->trans("Translation"), $enabledisablehtml, 'title_setup'); print load_fiche_titre($langs->trans("Translation"), $enabledisablehtml, 'title_setup');
@ -247,43 +247,43 @@ if ($mode == 'overwrite')
if ($action == 'edit' || empty($conf->global->MAIN_ENABLE_OVERWRITE_TRANSLATION)) $disablededit = ' disabled'; if ($action == 'edit' || empty($conf->global->MAIN_ENABLE_OVERWRITE_TRANSLATION)) $disablededit = ' disabled';
print '<div class="justify"><span class="opacitymedium">'; print '<div class="justify"><span class="opacitymedium">';
print img_info().' '.$langs->trans("SomeTranslationAreUncomplete"); print img_info().' '.$langs->trans("SomeTranslationAreUncomplete");
$urlwikitranslatordoc = 'https://wiki.dolibarr.org/index.php/Translator_documentation'; $urlwikitranslatordoc = 'https://wiki.dolibarr.org/index.php/Translator_documentation';
print ' ('.$langs->trans("SeeAlso", '<a href="'.$urlwikitranslatordoc.'" target="_blank">'.$langs->trans("Here").'</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("TranslationOverwriteDesc", $langs->transnoentitiesnoconv("Language"), $langs->transnoentitiesnoconv("Key"), $langs->transnoentitiesnoconv("NewTranslationStringToShow"))."\n";
print ' ('.$langs->trans("TranslationOverwriteDesc2").').'."<br>\n"; print ' ('.$langs->trans("TranslationOverwriteDesc2").').'."<br>\n";
print '</span></div>'; print '</span></div>';
print '<br>'; print '<br>';
print '<input type="hidden" name="action" value="'.($action == 'edit' ? 'update' : 'add').'">'; print '<input type="hidden" name="action" value="'.($action == 'edit' ? 'update' : 'add').'">';
print '<input type="hidden" id="mode" name="mode" value="'.$mode.'">'; print '<input type="hidden" id="mode" name="mode" value="'.$mode.'">';
print '<div class="div-table-responsive-no-min">'; print '<div class="div-table-responsive-no-min">';
print '<table class="noborder centpercent">'; print '<table class="noborder centpercent">';
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print_liste_field_titre("Language_en_US_es_MX_etc", $_SERVER["PHP_SELF"], 'lang,transkey', '', $param, '', $sortfield, $sortorder); print_liste_field_titre("Language_en_US_es_MX_etc", $_SERVER["PHP_SELF"], 'lang,transkey', '', $param, '', $sortfield, $sortorder);
print_liste_field_titre("Key", $_SERVER["PHP_SELF"], 'transkey', '', $param, '', $sortfield, $sortorder); print_liste_field_titre("Key", $_SERVER["PHP_SELF"], 'transkey', '', $param, '', $sortfield, $sortorder);
print_liste_field_titre("NewTranslationStringToShow", $_SERVER["PHP_SELF"], 'transvalue', '', $param, '', $sortfield, $sortorder); print_liste_field_titre("NewTranslationStringToShow", $_SERVER["PHP_SELF"], 'transvalue', '', $param, '', $sortfield, $sortorder);
//if (! empty($conf->multicompany->enabled) && !$user->entity) print_liste_field_titre("Entity", $_SERVER["PHP_SELF"], 'entity,transkey', '', $param, '', $sortfield, $sortorder); //if (! empty($conf->multicompany->enabled) && !$user->entity) print_liste_field_titre("Entity", $_SERVER["PHP_SELF"], 'entity,transkey', '', $param, '', $sortfield, $sortorder);
print '<td align="center"></td>'; print '<td align="center"></td>';
print "</tr>\n"; print "</tr>\n";
// Line to add new record // Line to add new record
print "\n"; print "\n";
print '<tr class="oddeven"><td>'; print '<tr class="oddeven"><td>';
print $formadmin->select_language(GETPOST('langcode'), 'langcode', 0, null, 1, 0, $disablededit ? 1 : 0, 'maxwidthonsmartphone', 1); print $formadmin->select_language(GETPOST('langcode'), 'langcode', 0, null, 1, 0, $disablededit ? 1 : 0, 'maxwidthonsmartphone', 1);
print '</td>'."\n"; print '</td>'."\n";
print '<td>'; print '<td>';
print '<input type="text" class="flat maxwidthonsmartphone"'.$disablededit.' name="transkey" id="transkey" value="'.(!empty($transkey) ? $transkey : "").'">'; print '<input type="text" class="flat maxwidthonsmartphone"'.$disablededit.' name="transkey" id="transkey" value="'.(!empty($transkey) ? $transkey : "").'">';
print '</td><td>'; print '</td><td>';
print '<input type="text" class="quatrevingtpercent"'.$disablededit.' name="transvalue" id="transvalue" value="'.(!empty($transvalue) ? $transvalue : "").'">'; print '<input type="text" class="quatrevingtpercent"'.$disablededit.' name="transvalue" id="transvalue" value="'.(!empty($transvalue) ? $transvalue : "").'">';
print '</td>'; print '</td>';
// Limit to superadmin // Limit to superadmin
/*if (! empty($conf->multicompany->enabled) && !$user->entity) /*if (! empty($conf->multicompany->enabled) && !$user->entity)
{ {
print '<td>'; print '<td>';
print '<input type="text" class="flat" size="1" name="entity" value="'.$conf->entity.'">'; print '<input type="text" class="flat" size="1" name="entity" value="'.$conf->entity.'">';
@ -292,118 +292,118 @@ if ($mode == 'overwrite')
} }
else else
{*/ {*/
print '<td class="center">'; print '<td class="center">';
print '<input type="hidden" name="entity" value="'.$conf->entity.'">'; print '<input type="hidden" name="entity" value="'.$conf->entity.'">';
//} //}
print '<input type="submit" class="button"'.$disabled.' value="'.$langs->trans("Add").'" name="add" title="'.dol_escape_htmltag($langs->trans("YouMustEnabledTranslationOverwriteBefore")).'">'; print '<input type="submit" class="button"'.$disabled.' value="'.$langs->trans("Add").'" name="add" title="'.dol_escape_htmltag($langs->trans("YouMustEnabledTranslationOverwriteBefore")).'">';
print "</td>\n"; print "</td>\n";
print '</tr>'; print '</tr>';
// Show constants // Show constants
$sql = "SELECT rowid, entity, lang, transkey, transvalue"; $sql = "SELECT rowid, entity, lang, transkey, transvalue";
$sql .= " FROM ".MAIN_DB_PREFIX."overwrite_trans"; $sql .= " FROM ".MAIN_DB_PREFIX."overwrite_trans";
$sql .= " WHERE 1 = 1"; $sql .= " WHERE 1 = 1";
$sql .= " AND entity IN (".getEntity('overwrite_trans').")"; $sql .= " AND entity IN (".getEntity('overwrite_trans').")";
$sql .= $db->order($sortfield, $sortorder); $sql .= $db->order($sortfield, $sortorder);
dol_syslog("translation::select from table", LOG_DEBUG); dol_syslog("translation::select from table", LOG_DEBUG);
$result = $db->query($sql); $result = $db->query($sql);
if ($result) if ($result)
{ {
$num = $db->num_rows($result); $num = $db->num_rows($result);
$i = 0; $i = 0;
while ($i < $num) while ($i < $num)
{ {
$obj = $db->fetch_object($result); $obj = $db->fetch_object($result);
print "\n"; print "\n";
print '<tr class="oddeven">'; print '<tr class="oddeven">';
print '<td>'.$obj->lang.'</td>'."\n"; print '<td>'.$obj->lang.'</td>'."\n";
print '<td>'.$obj->transkey.'</td>'."\n"; print '<td>'.$obj->transkey.'</td>'."\n";
// Value // Value
print '<td>'; print '<td>';
/*print '<input type="hidden" name="const['.$i.'][rowid]" value="'.$obj->rowid.'">'; /*print '<input type="hidden" name="const['.$i.'][rowid]" value="'.$obj->rowid.'">';
print '<input type="hidden" name="const['.$i.'][lang]" value="'.$obj->lang.'">'; print '<input type="hidden" name="const['.$i.'][lang]" value="'.$obj->lang.'">';
print '<input type="hidden" name="const['.$i.'][name]" value="'.$obj->transkey.'">'; print '<input type="hidden" name="const['.$i.'][name]" value="'.$obj->transkey.'">';
print '<input type="text" id="value_'.$i.'" class="flat inputforupdate" size="30" name="const['.$i.'][value]" value="'.dol_escape_htmltag($obj->transvalue).'">'; print '<input type="text" id="value_'.$i.'" class="flat inputforupdate" size="30" name="const['.$i.'][value]" value="'.dol_escape_htmltag($obj->transvalue).'">';
*/ */
if ($action == 'edit' && $obj->rowid == GETPOST('rowid', 'int')) if ($action == 'edit' && $obj->rowid == GETPOST('rowid', 'int'))
{ {
print '<input type="text" class="quatrevingtpercent" name="transvalue" value="'.dol_escape_htmltag($obj->transvalue).'">'; print '<input type="text" class="quatrevingtpercent" name="transvalue" value="'.dol_escape_htmltag($obj->transvalue).'">';
} else { } else {
print dol_escape_htmltag($obj->transvalue); print dol_escape_htmltag($obj->transvalue);
} }
print '</td>'; print '</td>';
print '<td class="center">'; print '<td class="center">';
if ($action == 'edit' && $obj->rowid == GETPOST('rowid', 'int')) if ($action == 'edit' && $obj->rowid == GETPOST('rowid', 'int'))
{ {
print '<input type="hidden" class="button" name="rowid" value="'.$obj->rowid.'">'; print '<input type="hidden" class="button" name="rowid" value="'.$obj->rowid.'">';
print '<input type="submit" class="button buttongen" name="save" value="'.dol_escape_htmltag($langs->trans("Save")).'">'; print '<input type="submit" class="button buttongen" name="save" value="'.dol_escape_htmltag($langs->trans("Save")).'">';
print ' &nbsp; ';
print '<input type="submit" class="button buttongen" name="cancel" value="'.dol_escape_htmltag($langs->trans("Cancel")).'">';
} else {
print '<a class="reposition editfielda paddingrightonly" href="'.$_SERVER['PHP_SELF'].'?rowid='.$obj->rowid.'&entity='.$obj->entity.'&action=edit'.((empty($user->entity) && $debug) ? '&debug=1' : '').'">'.img_edit().'</a>';
print ' &nbsp; '; print ' &nbsp; ';
print '<a class="reposition" href="'.$_SERVER['PHP_SELF'].'?rowid='.$obj->rowid.'&entity='.$obj->entity.'&action=delete&token='.newToken().((empty($user->entity) && $debug) ? '&debug=1' : '').'">'.img_delete().'</a>'; print '<input type="submit" class="button buttongen" name="cancel" value="'.dol_escape_htmltag($langs->trans("Cancel")).'">';
} } else {
print '</td>'; print '<a class="reposition editfielda paddingrightonly" href="'.$_SERVER['PHP_SELF'].'?rowid='.$obj->rowid.'&entity='.$obj->entity.'&action=edit'.((empty($user->entity) && $debug) ? '&debug=1' : '').'">'.img_edit().'</a>';
print ' &nbsp; ';
print '<a class="reposition" href="'.$_SERVER['PHP_SELF'].'?rowid='.$obj->rowid.'&entity='.$obj->entity.'&action=delete&token='.newToken().((empty($user->entity) && $debug) ? '&debug=1' : '').'">'.img_delete().'</a>';
}
print '</td>';
print "</tr>\n"; print "</tr>\n";
print "\n"; print "\n";
$i++; $i++;
} }
} }
print '</table>'; print '</table>';
print '</div>'; print '</div>';
} }
if ($mode == 'searchkey') if ($mode == 'searchkey')
{ {
$langcode = GETPOST('langcode') ?GETPOST('langcode') : $langs->defaultlang; $langcode = GETPOST('langcode') ?GETPOST('langcode') : $langs->defaultlang;
$newlang = new Translate('', $conf); $newlang = new Translate('', $conf);
$newlang->setDefaultLang($langcode); $newlang->setDefaultLang($langcode);
$newlangfileonly = new Translate('', $conf); $newlangfileonly = new Translate('', $conf);
$newlangfileonly->setDefaultLang($langcode); $newlangfileonly->setDefaultLang($langcode);
$recordtoshow = array(); $recordtoshow = array();
// Search modules dirs // Search modules dirs
$modulesdir = dolGetModulesDirs(); $modulesdir = dolGetModulesDirs();
$nbtotaloffiles = 0; $nbtotaloffiles = 0;
$nbempty = 0; $nbempty = 0;
/*var_dump($langcode); /*var_dump($langcode);
var_dump($transkey); var_dump($transkey);
var_dump($transvalue);*/ var_dump($transvalue);*/
if (empty($langcode) || $langcode == '-1') $nbempty++; if (empty($langcode) || $langcode == '-1') $nbempty++;
if (empty($transkey)) $nbempty++; if (empty($transkey)) $nbempty++;
if (empty($transvalue)) $nbempty++; if (empty($transvalue)) $nbempty++;
if ($action == 'search' && ($nbempty > 999)) // 999 to disable this if ($action == 'search' && ($nbempty > 999)) // 999 to disable this
{ {
setEventMessages($langs->trans("WarningAtLeastKeyOrTranslationRequired"), null, 'warnings'); setEventMessages($langs->trans("WarningAtLeastKeyOrTranslationRequired"), null, 'warnings');
} else { } else {
// Search into dir of modules (the $modulesdir is already a list that loop on $conf->file->dol_document_root) // Search into dir of modules (the $modulesdir is already a list that loop on $conf->file->dol_document_root)
$i = 0; $i = 0;
foreach ($modulesdir as $keydir => $tmpsearchdir) foreach ($modulesdir as $keydir => $tmpsearchdir)
{ {
$searchdir = $tmpsearchdir; // $searchdir can be '.../htdocs/core/modules/' or '.../htdocs/custom/mymodule/core/modules/' $searchdir = $tmpsearchdir; // $searchdir can be '.../htdocs/core/modules/' or '.../htdocs/custom/mymodule/core/modules/'
// Directory of translation files // Directory of translation files
$dir_lang = dirname(dirname($searchdir))."/langs/".$langcode; // The 2 dirname is to go up in dir for 2 levels $dir_lang = dirname(dirname($searchdir))."/langs/".$langcode; // The 2 dirname is to go up in dir for 2 levels
$dir_lang_osencoded = dol_osencode($dir_lang); $dir_lang_osencoded = dol_osencode($dir_lang);
$filearray = dol_dir_list($dir_lang_osencoded, 'files', 0, '', '', $sortfield, (strtolower($sortorder) == 'asc' ?SORT_ASC:SORT_DESC), 1); $filearray = dol_dir_list($dir_lang_osencoded, 'files', 0, '', '', $sortfield, (strtolower($sortorder) == 'asc' ?SORT_ASC:SORT_DESC), 1);
foreach ($filearray as $file) foreach ($filearray as $file)
{ {
$tmpfile = preg_replace('/.lang/i', '', basename($file['name'])); $tmpfile = preg_replace('/.lang/i', '', basename($file['name']));
$moduledirname = (basename(dirname(dirname($dir_lang)))); $moduledirname = (basename(dirname(dirname($dir_lang))));
@ -416,135 +416,135 @@ if ($mode == 'searchkey')
if ($result < 0) print 'Failed to load language file '.$tmpfile.'<br>'."\n"; if ($result < 0) print 'Failed to load language file '.$tmpfile.'<br>'."\n";
else $nbtotaloffiles++; else $nbtotaloffiles++;
//print 'After loading lang '.$langkey.', newlang has '.count($newlang->tab_translate).' records<br>'."\n"; //print 'After loading lang '.$langkey.', newlang has '.count($newlang->tab_translate).' records<br>'."\n";
} }
$i++; $i++;
} }
// Now search into translation array // Now search into translation array
foreach ($newlang->tab_translate as $key => $val) foreach ($newlang->tab_translate as $key => $val)
{ {
if ($transkey && !preg_match('/'.preg_quote($transkey, '/').'/i', $key)) continue; if ($transkey && !preg_match('/'.preg_quote($transkey, '/').'/i', $key)) continue;
if ($transvalue && !preg_match('/'.preg_quote($transvalue, '/').'/i', $val)) continue; if ($transvalue && !preg_match('/'.preg_quote($transvalue, '/').'/i', $val)) continue;
$recordtoshow[$key] = $val; $recordtoshow[$key] = $val;
} }
} }
//print '<br>'; //print '<br>';
$nbtotalofrecordswithoutfilters = count($newlang->tab_translate); $nbtotalofrecordswithoutfilters = count($newlang->tab_translate);
$nbtotalofrecords = count($recordtoshow); $nbtotalofrecords = count($recordtoshow);
$num = $limit + 1; $num = $limit + 1;
if (($offset + $num) > $nbtotalofrecords) $num = $limit; if (($offset + $num) > $nbtotalofrecords) $num = $limit;
//print 'param='.$param.' $_SERVER["PHP_SELF"]='.$_SERVER["PHP_SELF"].' num='.$num.' page='.$page.' nbtotalofrecords='.$nbtotalofrecords." sortfield=".$sortfield." sortorder=".$sortorder; //print 'param='.$param.' $_SERVER["PHP_SELF"]='.$_SERVER["PHP_SELF"].' num='.$num.' page='.$page.' nbtotalofrecords='.$nbtotalofrecords." sortfield=".$sortfield." sortorder=".$sortorder;
$title = $langs->trans("TranslationKeySearch"); $title = $langs->trans("TranslationKeySearch");
if ($nbtotalofrecords > 0) $title .= ' <span class="opacitymedium colorblack paddingleft">('.$nbtotalofrecords.' / '.$nbtotalofrecordswithoutfilters.' - '.$nbtotaloffiles.' '.$langs->trans("Files").')</span>'; if ($nbtotalofrecords > 0) $title .= ' <span class="opacitymedium colorblack paddingleft">('.$nbtotalofrecords.' / '.$nbtotalofrecordswithoutfilters.' - '.$nbtotaloffiles.' '.$langs->trans("Files").')</span>';
print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, -1 * $nbtotalofrecords, '', 0, '', '', $limit, 0, 0, 1); print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, -1 * $nbtotalofrecords, '', 0, '', '', $limit, 0, 0, 1);
print '<input type="hidden" id="action" name="action" value="search">'; print '<input type="hidden" id="action" name="action" value="search">';
print '<input type="hidden" id="mode" name="mode" value="'.$mode.'">'; print '<input type="hidden" id="mode" name="mode" value="'.$mode.'">';
print '<div class="div-table-responsive-no-min">'; print '<div class="div-table-responsive-no-min">';
print '<table class="noborder centpercent">'; print '<table class="noborder centpercent">';
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print_liste_field_titre("Language_en_US_es_MX_etc", $_SERVER["PHP_SELF"], 'lang,transkey', '', $param, '', $sortfield, $sortorder); print_liste_field_titre("Language_en_US_es_MX_etc", $_SERVER["PHP_SELF"], 'lang,transkey', '', $param, '', $sortfield, $sortorder);
print_liste_field_titre("Key", $_SERVER["PHP_SELF"], 'transkey', '', $param, '', $sortfield, $sortorder); print_liste_field_titre("Key", $_SERVER["PHP_SELF"], 'transkey', '', $param, '', $sortfield, $sortorder);
print_liste_field_titre("CurrentTranslationString", $_SERVER["PHP_SELF"], 'transvalue', '', $param, '', $sortfield, $sortorder); print_liste_field_titre("CurrentTranslationString", $_SERVER["PHP_SELF"], 'transvalue', '', $param, '', $sortfield, $sortorder);
//if (! empty($conf->multicompany->enabled) && !$user->entity) print_liste_field_titre("Entity", $_SERVER["PHP_SELF"], 'entity,transkey', '', $param, '', $sortfield, $sortorder); //if (! empty($conf->multicompany->enabled) && !$user->entity) print_liste_field_titre("Entity", $_SERVER["PHP_SELF"], 'entity,transkey', '', $param, '', $sortfield, $sortorder);
print '<td align="center"></td>'; print '<td align="center"></td>';
print "</tr>\n"; print "</tr>\n";
// Line to search new record // Line to search new record
print "\n"; print "\n";
print '<tr class="oddeven"><td>'; print '<tr class="oddeven"><td>';
//print $formadmin->select_language($langcode,'langcode',0,null,$langs->trans("All"),0,0,'',1); //print $formadmin->select_language($langcode,'langcode',0,null,$langs->trans("All"),0,0,'',1);
print $formadmin->select_language($langcode, 'langcode', 0, null, 0, 0, 0, 'maxwidthonsmartphone', 1); print $formadmin->select_language($langcode, 'langcode', 0, null, 0, 0, 0, 'maxwidthonsmartphone', 1);
print '</td>'."\n"; print '</td>'."\n";
print '<td>'; print '<td>';
print '<input type="text" class="flat maxwidthonsmartphone" name="transkey" value="'.$transkey.'">'; print '<input type="text" class="flat maxwidthonsmartphone" name="transkey" value="'.$transkey.'">';
print '</td><td>'; print '</td><td>';
print '<input type="text" class="quatrevingtpercent" name="transvalue" value="'.$transvalue.'">'; print '<input type="text" class="quatrevingtpercent" name="transvalue" value="'.$transvalue.'">';
// Limit to superadmin // Limit to superadmin
/*if (! empty($conf->multicompany->enabled) && !$user->entity) /*if (! empty($conf->multicompany->enabled) && !$user->entity)
{ {
print '</td><td>'; print '</td><td>';
print '<input type="text" class="flat" size="1" name="entitysearch" value="'.$conf->entity.'">'; print '<input type="text" class="flat" size="1" name="entitysearch" value="'.$conf->entity.'">';
} }
else else
{*/ {*/
print '<input type="hidden" name="entitysearch" value="'.$conf->entity.'">'; print '<input type="hidden" name="entitysearch" value="'.$conf->entity.'">';
//} //}
print '</td>'; print '</td>';
// Action column // Action column
print '<td class="nowrap right">'; print '<td class="nowrap right">';
$searchpicto = $form->showFilterAndCheckAddButtons($massactionbutton ? 1 : 0, 'checkforselect', 1); $searchpicto = $form->showFilterAndCheckAddButtons($massactionbutton ? 1 : 0, 'checkforselect', 1);
print $searchpicto; print $searchpicto;
print '</td>'; print '</td>';
print '</tr>'; print '</tr>';
if ($sortfield == 'transkey' && strtolower($sortorder) == 'asc') ksort($recordtoshow); if ($sortfield == 'transkey' && strtolower($sortorder) == 'asc') ksort($recordtoshow);
if ($sortfield == 'transkey' && strtolower($sortorder) == 'desc') krsort($recordtoshow); if ($sortfield == 'transkey' && strtolower($sortorder) == 'desc') krsort($recordtoshow);
if ($sortfield == 'transvalue' && strtolower($sortorder) == 'asc') asort($recordtoshow); if ($sortfield == 'transvalue' && strtolower($sortorder) == 'asc') asort($recordtoshow);
if ($sortfield == 'transvalue' && strtolower($sortorder) == 'desc') arsort($recordtoshow); if ($sortfield == 'transvalue' && strtolower($sortorder) == 'desc') arsort($recordtoshow);
// Show result // Show result
$i = 0; $i = 0;
foreach ($recordtoshow as $key => $val) foreach ($recordtoshow as $key => $val)
{ {
$i++; $i++;
if ($i <= $offset) continue; if ($i <= $offset) continue;
if ($i > ($offset + $limit)) break; if ($i > ($offset + $limit)) break;
print '<tr class="oddeven"><td>'.$langcode.'</td><td>'.$key.'</td><td>'; print '<tr class="oddeven"><td>'.$langcode.'</td><td>'.$key.'</td><td>';
print dol_escape_htmltag($val); print dol_escape_htmltag($val);
print '</td><td class="right nowraponall">'; print '</td><td class="right nowraponall">';
if (!empty($newlangfileonly->tab_translate[$key])) if (!empty($newlangfileonly->tab_translate[$key]))
{ {
if ($val != $newlangfileonly->tab_translate[$key]) if ($val != $newlangfileonly->tab_translate[$key])
{ {
// retrieve rowid // retrieve rowid
$sql = "SELECT rowid"; $sql = "SELECT rowid";
$sql .= " FROM ".MAIN_DB_PREFIX."overwrite_trans"; $sql .= " FROM ".MAIN_DB_PREFIX."overwrite_trans";
$sql .= " WHERE transkey = '".$key."'"; $sql .= " WHERE transkey = '".$key."'";
$sql .= " AND entity IN (".getEntity('overwrite_trans').")"; $sql .= " AND entity IN (".getEntity('overwrite_trans').")";
dol_syslog("translation::select from table", LOG_DEBUG); dol_syslog("translation::select from table", LOG_DEBUG);
$result = $db->query($sql); $result = $db->query($sql);
if ($result) if ($result)
{ {
$obj = $db->fetch_object($result); $obj = $db->fetch_object($result);
} }
print '<a class="editfielda reposition paddingrightonly" href="'.$_SERVER['PHP_SELF'].'?rowid='.$obj->rowid.'&entity='.$conf->entity.'&action=edit">'.img_edit().'</a>'; print '<a class="editfielda reposition paddingrightonly" href="'.$_SERVER['PHP_SELF'].'?rowid='.$obj->rowid.'&entity='.$conf->entity.'&action=edit">'.img_edit().'</a>';
print ' '; print ' ';
print '<a href="'.$_SERVER['PHP_SELF'].'?rowid='.$obj->rowid.'&entity='.$conf->entity.'&action=delete&token='.newToken().'">'.img_delete().'</a>'; print '<a href="'.$_SERVER['PHP_SELF'].'?rowid='.$obj->rowid.'&entity='.$conf->entity.'&action=delete&token='.newToken().'">'.img_delete().'</a>';
print '&nbsp;&nbsp;'; print '&nbsp;&nbsp;';
$htmltext = $langs->trans("OriginalValueWas", '<i>'.$newlangfileonly->tab_translate[$key].'</i>'); $htmltext = $langs->trans("OriginalValueWas", '<i>'.$newlangfileonly->tab_translate[$key].'</i>');
print $form->textwithpicto('', $htmltext, 1, 'info'); print $form->textwithpicto('', $htmltext, 1, 'info');
} elseif (!empty($conf->global->MAIN_ENABLE_OVERWRITE_TRANSLATION)) } elseif (!empty($conf->global->MAIN_ENABLE_OVERWRITE_TRANSLATION))
{ {
//print $key.'-'.$val; //print $key.'-'.$val;
print '<a class="reposition paddingrightonly" href="'.$_SERVER['PHP_SELF'].'?mode=overwrite&amp;langcode='.$langcode.'&amp;transkey='.$key.'">'.img_edit_add($langs->trans("Overwrite")).'</a>'; print '<a class="reposition paddingrightonly" 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)) if (!empty($conf->global->MAIN_FEATURES_LEVEL))
{ {
$transifexlangfile = '$'; // $ means 'All' $transifexlangfile = '$'; // $ means 'All'
//$transifexurl = 'https://www.transifex.com/dolibarr-association/dolibarr/translate/#'.$langcode.'/'.$transifexlangfile.'?key='.$key; //$transifexurl = 'https://www.transifex.com/dolibarr-association/dolibarr/translate/#'.$langcode.'/'.$transifexlangfile.'?key='.$key;
$transifexurl = 'https://www.transifex.com/dolibarr-association/dolibarr/translate/#'.$langcode.'/'.$transifexlangfile.'?q=key%3A'.$key; $transifexurl = 'https://www.transifex.com/dolibarr-association/dolibarr/translate/#'.$langcode.'/'.$transifexlangfile.'?q=key%3A'.$key;
print ' &nbsp; <a href="'.$transifexurl.'" target="transifex">'.img_picto($langs->trans('FixOnTransifex'), 'globe').'</a>'; print ' &nbsp; <a href="'.$transifexurl.'" target="transifex">'.img_picto($langs->trans('FixOnTransifex'), 'globe').'</a>';
} }
} else { } else {
$htmltext = $langs->trans("TransKeyWithoutOriginalValue", $key); $htmltext = $langs->trans("TransKeyWithoutOriginalValue", $key);
print $form->textwithpicto('', $htmltext, 1, 'warning'); print $form->textwithpicto('', $htmltext, 1, 'warning');
} }
/*if (! empty($conf->multicompany->enabled) && !$user->entity) /*if (! empty($conf->multicompany->enabled) && !$user->entity)
{ {
print '<td>'.$val.'</td>'; print '<td>'.$val.'</td>';
}*/ }*/
print '</td></tr>'."\n"; print '</td></tr>'."\n";
} }
print '</table>'; print '</table>';
print '</div>'; print '</div>';
} }
dol_fiche_end(); dol_fiche_end();

View File

@ -124,252 +124,252 @@ $sourceList = array();
// Actions add or modify a website // Actions add or modify a website
if (GETPOST('actionadd', 'alpha') || GETPOST('actionmodify', 'alpha')) if (GETPOST('actionadd', 'alpha') || GETPOST('actionmodify', 'alpha'))
{ {
$listfield = explode(',', $tabfield[$id]); $listfield = explode(',', $tabfield[$id]);
$listfieldinsert = explode(',', $tabfieldinsert[$id]); $listfieldinsert = explode(',', $tabfieldinsert[$id]);
$listfieldmodify = explode(',', $tabfieldinsert[$id]); $listfieldmodify = explode(',', $tabfieldinsert[$id]);
$listfieldvalue = explode(',', $tabfieldvalue[$id]); $listfieldvalue = explode(',', $tabfieldvalue[$id]);
// Check that all fields are filled // Check that all fields are filled
$ok = 1; $ok = 1;
foreach ($listfield as $f => $value) foreach ($listfield as $f => $value)
{ {
if ($value == 'ref' && (!GETPOSTISSET($value) || GETPOST($value) == '')) if ($value == 'ref' && (!GETPOSTISSET($value) || GETPOST($value) == ''))
{ {
$ok = 0;
$fieldnamekey = $listfield[$f];
setEventMessages($langs->transnoentities("ErrorFieldRequired", $langs->transnoentities($fieldnamekey)), null, 'errors');
break;
} elseif ($value == 'ref' && !preg_match('/^[a-z0-9_\-\.]+$/i', $_POST[$value]))
{
$ok = 0; $ok = 0;
$fieldnamekey = $listfield[$f]; $fieldnamekey = $listfield[$f];
setEventMessages($langs->transnoentities("ErrorFieldRequired", $langs->transnoentities($fieldnamekey)), null, 'errors');
break;
} elseif ($value == 'ref' && !preg_match('/^[a-z0-9_\-\.]+$/i', $_POST[$value]))
{
$ok = 0;
$fieldnamekey = $listfield[$f];
setEventMessages($langs->transnoentities("ErrorFieldCanNotContainSpecialCharacters", $langs->transnoentities($fieldnamekey)), null, 'errors'); setEventMessages($langs->transnoentities("ErrorFieldCanNotContainSpecialCharacters", $langs->transnoentities($fieldnamekey)), null, 'errors');
break; break;
} }
} }
// Clean parameters // Clean parameters
if (!empty($_POST['ref'])) if (!empty($_POST['ref']))
{ {
$websitekey = strtolower($_POST['ref']); $websitekey = strtolower($_POST['ref']);
} }
// Si verif ok et action add, on ajoute la ligne // Si verif ok et action add, on ajoute la ligne
if ($ok && GETPOST('actionadd', 'alpha')) if ($ok && GETPOST('actionadd', 'alpha'))
{ {
if ($tabrowid[$id]) if ($tabrowid[$id])
{ {
// Recupere id libre pour insertion // Recupere id libre pour insertion
$newid = 0; $newid = 0;
$sql = "SELECT max(".$tabrowid[$id].") newid from ".$tabname[$id]; $sql = "SELECT max(".$tabrowid[$id].") newid from ".$tabname[$id];
$result = $db->query($sql); $result = $db->query($sql);
if ($result) if ($result)
{ {
$obj = $db->fetch_object($result); $obj = $db->fetch_object($result);
$newid = ($obj->newid + 1); $newid = ($obj->newid + 1);
} else { } else {
dol_print_error($db); dol_print_error($db);
} }
} }
/* $website=new Website($db); /* $website=new Website($db);
$website->ref= $website->ref=
$website->description= $website->description=
$website->virtualhost= $website->virtualhost=
$website->create($user); */ $website->create($user); */
// Add new entry // Add new entry
$sql = "INSERT INTO ".$tabname[$id]." ("; $sql = "INSERT INTO ".$tabname[$id]." (";
// List of fields // List of fields
if ($tabrowid[$id] && !in_array($tabrowid[$id], $listfieldinsert)) if ($tabrowid[$id] && !in_array($tabrowid[$id], $listfieldinsert))
$sql .= $tabrowid[$id].","; $sql .= $tabrowid[$id].",";
$sql .= $tabfieldinsert[$id]; $sql .= $tabfieldinsert[$id];
$sql .= ",status)"; $sql .= ",status)";
$sql .= " VALUES("; $sql .= " VALUES(";
// List of values // List of values
if ($tabrowid[$id] && !in_array($tabrowid[$id], $listfieldinsert)) if ($tabrowid[$id] && !in_array($tabrowid[$id], $listfieldinsert))
$sql .= $newid.","; $sql .= $newid.",";
$i = 0; $i = 0;
foreach ($listfieldinsert as $f => $value) foreach ($listfieldinsert as $f => $value)
{ {
if ($value == 'entity') { if ($value == 'entity') {
$_POST[$listfieldvalue[$i]] = $conf->entity; $_POST[$listfieldvalue[$i]] = $conf->entity;
} }
if ($value == 'ref') { if ($value == 'ref') {
$_POST[$listfieldvalue[$i]] = strtolower($_POST[$listfieldvalue[$i]]); $_POST[$listfieldvalue[$i]] = strtolower($_POST[$listfieldvalue[$i]]);
} }
if ($i) $sql .= ","; if ($i) $sql .= ",";
if ($_POST[$listfieldvalue[$i]] == '') $sql .= "null"; if ($_POST[$listfieldvalue[$i]] == '') $sql .= "null";
else $sql .= "'".$db->escape($_POST[$listfieldvalue[$i]])."'"; else $sql .= "'".$db->escape($_POST[$listfieldvalue[$i]])."'";
$i++; $i++;
} }
$sql .= ",1)"; $sql .= ",1)";
dol_syslog("actionadd", LOG_DEBUG); dol_syslog("actionadd", LOG_DEBUG);
$result = $db->query($sql); $result = $db->query($sql);
if ($result) // Add is ok if ($result) // Add is ok
{ {
setEventMessages($langs->transnoentities("RecordSaved"), null, 'mesgs'); setEventMessages($langs->transnoentities("RecordSaved"), null, 'mesgs');
unset($_POST); // Clean $_POST array, we keep only unset($_POST); // Clean $_POST array, we keep only
} else { } else {
if ($db->errno() == 'DB_ERROR_RECORD_ALREADY_EXISTS') { if ($db->errno() == 'DB_ERROR_RECORD_ALREADY_EXISTS') {
setEventMessages($langs->transnoentities("ErrorRecordAlreadyExists"), null, 'errors'); setEventMessages($langs->transnoentities("ErrorRecordAlreadyExists"), null, 'errors');
} else { } else {
dol_print_error($db); dol_print_error($db);
} }
} }
} }
// Si verif ok et action modify, on modifie la ligne // Si verif ok et action modify, on modifie la ligne
if ($ok && GETPOST('actionmodify', 'alpha')) if ($ok && GETPOST('actionmodify', 'alpha'))
{ {
if ($tabrowid[$id]) { $rowidcol = $tabrowid[$id]; } else { $rowidcol = "rowid"; } if ($tabrowid[$id]) { $rowidcol = $tabrowid[$id]; } else { $rowidcol = "rowid"; }
$db->begin(); $db->begin();
$website = new Website($db); $website = new Website($db);
$rowid = GETPOST('rowid', 'int'); $rowid = GETPOST('rowid', 'int');
$website->fetch($rowid); $website->fetch($rowid);
// Modify entry // Modify entry
$sql = "UPDATE ".$tabname[$id]." SET "; $sql = "UPDATE ".$tabname[$id]." SET ";
// Modifie valeur des champs // Modifie valeur des champs
if ($tabrowid[$id] && !in_array($tabrowid[$id], $listfieldmodify)) if ($tabrowid[$id] && !in_array($tabrowid[$id], $listfieldmodify))
{ {
$sql .= $tabrowid[$id]."="; $sql .= $tabrowid[$id]."=";
$sql .= "'".$db->escape($rowid)."', "; $sql .= "'".$db->escape($rowid)."', ";
} }
$i = 0; $i = 0;
foreach ($listfieldmodify as $field) foreach ($listfieldmodify as $field)
{ {
if ($field == 'entity') { if ($field == 'entity') {
$_POST[$listfieldvalue[$i]] = $conf->entity; $_POST[$listfieldvalue[$i]] = $conf->entity;
} }
if ($i) $sql .= ","; if ($i) $sql .= ",";
$sql .= $field."="; $sql .= $field."=";
if ($_POST[$listfieldvalue[$i]] == '') $sql .= "null"; if ($_POST[$listfieldvalue[$i]] == '') $sql .= "null";
else $sql .= "'".$db->escape($_POST[$listfieldvalue[$i]])."'"; else $sql .= "'".$db->escape($_POST[$listfieldvalue[$i]])."'";
$i++; $i++;
} }
$sql .= " WHERE ".$rowidcol." = ".((int) $rowid); $sql .= " WHERE ".$rowidcol." = ".((int) $rowid);
dol_syslog("actionmodify", LOG_DEBUG); dol_syslog("actionmodify", LOG_DEBUG);
//print $sql; //print $sql;
$resql = $db->query($sql); $resql = $db->query($sql);
if ($resql) if ($resql)
{ {
$newname = dol_sanitizeFileName(GETPOST('ref', 'aZ09')); $newname = dol_sanitizeFileName(GETPOST('ref', 'aZ09'));
if ($newname != $website->ref) if ($newname != $website->ref)
{ {
$srcfile = DOL_DATA_ROOT.'/website/'.$website->ref; $srcfile = DOL_DATA_ROOT.'/website/'.$website->ref;
$destfile = DOL_DATA_ROOT.'/website/'.$newname; $destfile = DOL_DATA_ROOT.'/website/'.$newname;
if (dol_is_dir($destfile)) if (dol_is_dir($destfile))
{ {
$error++; $error++;
setEventMessages($langs->trans('ErrorDirAlreadyExists', $destfile), null, 'errors'); setEventMessages($langs->trans('ErrorDirAlreadyExists', $destfile), null, 'errors');
} else { } else {
@rename($srcfile, $destfile); @rename($srcfile, $destfile);
// We must now rename $website->ref into $newname inside files // We must now rename $website->ref into $newname inside files
$arrayreplacement = array($website->ref.'/htmlheader.html' => $newname.'/htmlheader.html'); $arrayreplacement = array($website->ref.'/htmlheader.html' => $newname.'/htmlheader.html');
$listofilestochange = dol_dir_list($destfile, 'files', 0, '\.php$'); $listofilestochange = dol_dir_list($destfile, 'files', 0, '\.php$');
foreach ($listofilestochange as $key => $value) foreach ($listofilestochange as $key => $value)
{ {
dolReplaceInFile($value['fullname'], $arrayreplacement); dolReplaceInFile($value['fullname'], $arrayreplacement);
} }
} }
} }
} else { } else {
$error++; $error++;
setEventMessages($db->lasterror(), null, 'errors'); setEventMessages($db->lasterror(), null, 'errors');
} }
if (!$error) if (!$error)
{ {
$db->commit(); $db->commit();
} else { } else {
$db->rollback(); $db->rollback();
} }
} }
//$_GET["id"]=GETPOST('id', 'int'); // Force affichage dictionnaire en cours d'edition //$_GET["id"]=GETPOST('id', 'int'); // Force affichage dictionnaire en cours d'edition
} }
if (GETPOST('actioncancel', 'alpha')) if (GETPOST('actioncancel', 'alpha'))
{ {
//$_GET["id"]=GETPOST('id', 'int'); // Force affichage dictionnaire en cours d'edition //$_GET["id"]=GETPOST('id', 'int'); // Force affichage dictionnaire en cours d'edition
} }
if ($action == 'confirm_delete' && $confirm == 'yes') // delete if ($action == 'confirm_delete' && $confirm == 'yes') // delete
{ {
if ($tabrowid[$id]) { $rowidcol = $tabrowid[$id]; } else { $rowidcol = "rowid"; } if ($tabrowid[$id]) { $rowidcol = $tabrowid[$id]; } else { $rowidcol = "rowid"; }
$website = new Website($db); $website = new Website($db);
$website->fetch($rowid); $website->fetch($rowid);
if ($website->id > 0) if ($website->id > 0)
{ {
$sql = "DELETE from ".MAIN_DB_PREFIX."website_account WHERE fk_website = ".((int) $rowid); $sql = "DELETE from ".MAIN_DB_PREFIX."website_account WHERE fk_website = ".((int) $rowid);
$result = $db->query($sql); $result = $db->query($sql);
$sql = "DELETE from ".MAIN_DB_PREFIX."website_page WHERE fk_website = ".((int) $rowid); $sql = "DELETE from ".MAIN_DB_PREFIX."website_page WHERE fk_website = ".((int) $rowid);
$result = $db->query($sql); $result = $db->query($sql);
$sql = "DELETE from ".MAIN_DB_PREFIX."website_extrafields WHERE fk_object = ".((int) $rowid); $sql = "DELETE from ".MAIN_DB_PREFIX."website_extrafields WHERE fk_object = ".((int) $rowid);
$result = $db->query($sql); $result = $db->query($sql);
$sql = "DELETE from ".MAIN_DB_PREFIX."website WHERE rowid = ".((int) $rowid); $sql = "DELETE from ".MAIN_DB_PREFIX."website WHERE rowid = ".((int) $rowid);
$result = $db->query($sql); $result = $db->query($sql);
if (!$result) if (!$result)
{ {
if ($db->errno() == 'DB_ERROR_CHILD_EXISTS') if ($db->errno() == 'DB_ERROR_CHILD_EXISTS')
{ {
setEventMessages($langs->transnoentities("ErrorRecordIsUsedByChild"), null, 'errors'); setEventMessages($langs->transnoentities("ErrorRecordIsUsedByChild"), null, 'errors');
} else { } else {
dol_print_error($db); dol_print_error($db);
} }
} }
if ($website->ref) if ($website->ref)
{ {
dol_delete_dir_recursive($conf->website->dir_output.'/'.$website->ref); dol_delete_dir_recursive($conf->website->dir_output.'/'.$website->ref);
} }
} else { } else {
dol_print_error($db, 'Failed to load website with id '.$rowid); dol_print_error($db, 'Failed to load website with id '.$rowid);
} }
} }
// activate // activate
if ($action == $acts[0]) if ($action == $acts[0])
{ {
if ($tabrowid[$id]) { $rowidcol = $tabrowid[$id]; } else { $rowidcol = "rowid"; } if ($tabrowid[$id]) { $rowidcol = $tabrowid[$id]; } else { $rowidcol = "rowid"; }
if ($rowid) { if ($rowid) {
$sql = "UPDATE ".$tabname[$id]." SET status = 1 WHERE rowid = ".((int) $rowid); $sql = "UPDATE ".$tabname[$id]." SET status = 1 WHERE rowid = ".((int) $rowid);
} }
$result = $db->query($sql); $result = $db->query($sql);
if (!$result) if (!$result)
{ {
dol_print_error($db); dol_print_error($db);
} }
} }
// disable // disable
if ($action == $acts[1]) if ($action == $acts[1])
{ {
if ($tabrowid[$id]) { $rowidcol = $tabrowid[$id]; } else { $rowidcol = "rowid"; } if ($tabrowid[$id]) { $rowidcol = $tabrowid[$id]; } else { $rowidcol = "rowid"; }
if ($rowid) { if ($rowid) {
$sql = "UPDATE ".$tabname[$id]." SET status = 0 WHERE rowid = ".((int) $rowid); $sql = "UPDATE ".$tabname[$id]." SET status = 0 WHERE rowid = ".((int) $rowid);
} }
$result = $db->query($sql); $result = $db->query($sql);
if (!$result) if (!$result)
{ {
dol_print_error($db); dol_print_error($db);
} }
} }
@ -411,7 +411,7 @@ print "<br>\n";
// Confirmation de la suppression de la ligne // Confirmation de la suppression de la ligne
if ($action == 'delete') if ($action == 'delete')
{ {
print $form->formconfirm($_SERVER["PHP_SELF"].'?'.($page ? 'page='.$page.'&' : '').'sortfield='.$sortfield.'&sortorder='.$sortorder.'&rowid='.$rowid, $langs->trans('DeleteWebsite'), $langs->trans('ConfirmDeleteWebsite'), 'confirm_delete', '', 0, 1, 220); print $form->formconfirm($_SERVER["PHP_SELF"].'?'.($page ? 'page='.$page.'&' : '').'sortfield='.$sortfield.'&sortorder='.$sortorder.'&rowid='.$rowid, $langs->trans('DeleteWebsite'), $langs->trans('ConfirmDeleteWebsite'), 'confirm_delete', '', 0, 1, 220);
} }
//var_dump($elementList); //var_dump($elementList);
@ -420,205 +420,205 @@ if ($action == 'delete')
*/ */
if ($id) if ($id)
{ {
// Complete requete recherche valeurs avec critere de tri // Complete requete recherche valeurs avec critere de tri
$sql = $tabsql[$id]; $sql = $tabsql[$id];
$sql .= $db->order($sortfield, $sortorder); $sql .= $db->order($sortfield, $sortorder);
$sql .= $db->plimit($limit + 1, $offset); $sql .= $db->plimit($limit + 1, $offset);
//print $sql; //print $sql;
$fieldlist = explode(',', $tabfield[$id]); $fieldlist = explode(',', $tabfield[$id]);
print '<form action="'.$_SERVER['PHP_SELF'].'" method="POST">'; print '<form action="'.$_SERVER['PHP_SELF'].'" method="POST">';
print '<input type="hidden" name="token" value="'.newToken().'">'; print '<input type="hidden" name="token" value="'.newToken().'">';
print '<table class="noborder centpercent">'; print '<table class="noborder centpercent">';
// Form to add a new line // Form to add a new line
if ($tabname[$id]) if ($tabname[$id])
{ {
$alabelisused = 0; $alabelisused = 0;
$var = false; $var = false;
$fieldlist = explode(',', $tabfield[$id]); $fieldlist = explode(',', $tabfield[$id]);
// Line for title // Line for title
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
foreach ($fieldlist as $field => $value) foreach ($fieldlist as $field => $value)
{ {
// Determine le nom du champ par rapport aux noms possibles // Determine le nom du champ par rapport aux noms possibles
// dans les dictionnaires de donnees // dans les dictionnaires de donnees
$valuetoshow = ucfirst($fieldlist[$field]); // Par defaut $valuetoshow = ucfirst($fieldlist[$field]); // Par defaut
$valuetoshow = $langs->trans($valuetoshow); // try to translate $valuetoshow = $langs->trans($valuetoshow); // try to translate
$align = ''; $align = '';
if ($fieldlist[$field] == 'lang') { $valuetoshow = $langs->trans("Language"); } if ($fieldlist[$field] == 'lang') { $valuetoshow = $langs->trans("Language"); }
if ($valuetoshow != '') if ($valuetoshow != '')
{ {
print '<td class="'.$align.'">'; print '<td class="'.$align.'">';
if (!empty($tabhelp[$id][$value]) && preg_match('/^http(s*):/i', $tabhelp[$id][$value])) print '<a href="'.$tabhelp[$id][$value].'" target="_blank">'.$valuetoshow.' '.img_help(1, $valuetoshow).'</a>'; if (!empty($tabhelp[$id][$value]) && preg_match('/^http(s*):/i', $tabhelp[$id][$value])) print '<a href="'.$tabhelp[$id][$value].'" target="_blank">'.$valuetoshow.' '.img_help(1, $valuetoshow).'</a>';
elseif (!empty($tabhelp[$id][$value])) elseif (!empty($tabhelp[$id][$value]))
{ {
if ($value == 'virtualhost') print $form->textwithpicto($valuetoshow, $tabhelp[$id][$value], 1, 'help', '', 0, 2, 'tooltipvirtual'); if ($value == 'virtualhost') print $form->textwithpicto($valuetoshow, $tabhelp[$id][$value], 1, 'help', '', 0, 2, 'tooltipvirtual');
else print $form->textwithpicto($valuetoshow, $tabhelp[$id][$value]); else print $form->textwithpicto($valuetoshow, $tabhelp[$id][$value]);
} else print $valuetoshow; } else print $valuetoshow;
print '</td>'; print '</td>';
} }
if ($fieldlist[$field] == 'libelle' || $fieldlist[$field] == 'label') $alabelisused = 1; if ($fieldlist[$field] == 'libelle' || $fieldlist[$field] == 'label') $alabelisused = 1;
} }
print '<td colspan="4">'; print '<td colspan="4">';
print '</td>'; print '</td>';
print '</tr>'; print '</tr>';
// Line to enter new values // Line to enter new values
print "<tr ".$bcnd[$var].">"; print "<tr ".$bcnd[$var].">";
$obj = new stdClass(); $obj = new stdClass();
// If data was already input, we define them in obj to populate input fields. // If data was already input, we define them in obj to populate input fields.
if (GETPOST('actionadd', 'alpha')) if (GETPOST('actionadd', 'alpha'))
{ {
foreach ($fieldlist as $key=>$val) foreach ($fieldlist as $key=>$val)
{ {
if (GETPOST($val, 'alpha')) if (GETPOST($val, 'alpha'))
$obj->$val = GETPOST($val); $obj->$val = GETPOST($val);
} }
} }
fieldListWebsites($fieldlist, $obj, $tabname[$id], 'add'); fieldListWebsites($fieldlist, $obj, $tabname[$id], 'add');
print '<td colspan="3" class="right">'; print '<td colspan="3" class="right">';
if ($action != 'edit') if ($action != 'edit')
{ {
print '<input type="submit" class="button" name="actionadd" value="'.$langs->trans("Add").'">'; print '<input type="submit" class="button" name="actionadd" value="'.$langs->trans("Add").'">';
} }
print '</td>'; print '</td>';
print "</tr>"; print "</tr>";
$colspan = count($fieldlist) + 2; $colspan = count($fieldlist) + 2;
} }
print '</table>'; print '</table>';
print '</form>'; print '</form>';
// List of websites in database // List of websites in database
$resql = $db->query($sql); $resql = $db->query($sql);
if ($resql) if ($resql)
{ {
$num = $db->num_rows($resql); $num = $db->num_rows($resql);
$i = 0; $i = 0;
if ($num) if ($num)
{ {
print '<br>'; print '<br>';
print '<form action="'.$_SERVER['PHP_SELF'].'" method="POST">'; print '<form action="'.$_SERVER['PHP_SELF'].'" method="POST">';
print '<input type="hidden" name="token" value="'.newToken().'">'; print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="page" value="'.$page.'">'; print '<input type="hidden" name="page" value="'.$page.'">';
print '<input type="hidden" name="rowid" value="'.$rowid.'">'; print '<input type="hidden" name="rowid" value="'.$rowid.'">';
print '<table class="noborder centpercent">'; print '<table class="noborder centpercent">';
// Title of lines // Title of lines
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
foreach ($fieldlist as $field => $value) foreach ($fieldlist as $field => $value)
{ {
// Determine le nom du champ par rapport aux noms possibles // Determine le nom du champ par rapport aux noms possibles
// dans les dictionnaires de donnees // dans les dictionnaires de donnees
$showfield = 1; // Par defaut $showfield = 1; // Par defaut
$align = "left"; $align = "left";
$sortable = 1; $sortable = 1;
$valuetoshow = ''; $valuetoshow = '';
/* /*
$tmparray=getLabelOfField($fieldlist[$field]); $tmparray=getLabelOfField($fieldlist[$field]);
$showfield=$tmp['showfield']; $showfield=$tmp['showfield'];
$valuetoshow=$tmp['valuetoshow']; $valuetoshow=$tmp['valuetoshow'];
$align=$tmp['align']; $align=$tmp['align'];
$sortable=$tmp['sortable']; $sortable=$tmp['sortable'];
*/ */
$valuetoshow = ucfirst($fieldlist[$field]); // Par defaut $valuetoshow = ucfirst($fieldlist[$field]); // Par defaut
$valuetoshow = $langs->trans($valuetoshow); // try to translate $valuetoshow = $langs->trans($valuetoshow); // try to translate
if ($fieldlist[$field] == 'lang') { $valuetoshow = $langs->trans("Language"); } if ($fieldlist[$field] == 'lang') { $valuetoshow = $langs->trans("Language"); }
if ($fieldlist[$field] == 'type') { $valuetoshow = $langs->trans("Type"); } if ($fieldlist[$field] == 'type') { $valuetoshow = $langs->trans("Type"); }
if ($fieldlist[$field] == 'code') { $valuetoshow = $langs->trans("Code"); } if ($fieldlist[$field] == 'code') { $valuetoshow = $langs->trans("Code"); }
// Affiche nom du champ // Affiche nom du champ
if ($showfield) if ($showfield)
{ {
print getTitleFieldOfList($valuetoshow, 0, $_SERVER["PHP_SELF"], ($sortable ? $fieldlist[$field] : ''), ($page ? 'page='.$page.'&' : ''), "", "align=".$align, $sortfield, $sortorder); print getTitleFieldOfList($valuetoshow, 0, $_SERVER["PHP_SELF"], ($sortable ? $fieldlist[$field] : ''), ($page ? 'page='.$page.'&' : ''), "", "align=".$align, $sortfield, $sortorder);
} }
} }
print getTitleFieldOfList($langs->trans("Status"), 0, $_SERVER["PHP_SELF"], "status", ($page ? 'page='.$page.'&' : ''), "", 'align="center"', $sortfield, $sortorder); print getTitleFieldOfList($langs->trans("Status"), 0, $_SERVER["PHP_SELF"], "status", ($page ? 'page='.$page.'&' : ''), "", 'align="center"', $sortfield, $sortorder);
print getTitleFieldOfList(''); print getTitleFieldOfList('');
print getTitleFieldOfList(''); print getTitleFieldOfList('');
print '</tr>'; print '</tr>';
// Lines with values // Lines with values
while ($i < $num) while ($i < $num)
{ {
$obj = $db->fetch_object($resql); $obj = $db->fetch_object($resql);
//print_r($obj); //print_r($obj);
print '<tr class="oddeven" id="rowid-'.$obj->rowid.'">'; print '<tr class="oddeven" id="rowid-'.$obj->rowid.'">';
if ($action == 'edit' && ($rowid == (!empty($obj->rowid) ? $obj->rowid : $obj->code))) if ($action == 'edit' && ($rowid == (!empty($obj->rowid) ? $obj->rowid : $obj->code)))
{ {
$tmpaction = 'edit'; $tmpaction = 'edit';
$parameters = array('fieldlist'=>$fieldlist, 'tabname'=>$tabname[$id]); $parameters = array('fieldlist'=>$fieldlist, 'tabname'=>$tabname[$id]);
$reshook = $hookmanager->executeHooks('editWebsiteFieldlist', $parameters, $obj, $tmpaction); // Note that $action and $object may have been modified by some hooks $reshook = $hookmanager->executeHooks('editWebsiteFieldlist', $parameters, $obj, $tmpaction); // Note that $action and $object may have been modified by some hooks
$error = $hookmanager->error; $errors = $hookmanager->errors; $error = $hookmanager->error; $errors = $hookmanager->errors;
if (empty($reshook)) fieldListWebsites($fieldlist, $obj, $tabname[$id], 'edit'); if (empty($reshook)) fieldListWebsites($fieldlist, $obj, $tabname[$id], 'edit');
print '<td colspan="3" class="right"><a name="'.(!empty($obj->rowid) ? $obj->rowid : $obj->code).'">&nbsp;</a><input type="submit" class="button" name="actionmodify" value="'.$langs->trans("Modify").'">'; print '<td colspan="3" class="right"><a name="'.(!empty($obj->rowid) ? $obj->rowid : $obj->code).'">&nbsp;</a><input type="submit" class="button" name="actionmodify" value="'.$langs->trans("Modify").'">';
print '&nbsp;<input type="submit" class="button" name="actioncancel" value="'.$langs->trans("Cancel").'"></td>'; print '&nbsp;<input type="submit" class="button" name="actioncancel" value="'.$langs->trans("Cancel").'"></td>';
} else { } else {
$tmpaction = 'view'; $tmpaction = 'view';
$parameters = array('var'=>$var, 'fieldlist'=>$fieldlist, 'tabname'=>$tabname[$id]); $parameters = array('var'=>$var, 'fieldlist'=>$fieldlist, 'tabname'=>$tabname[$id]);
$reshook = $hookmanager->executeHooks('viewWebsiteFieldlist', $parameters, $obj, $tmpaction); // Note that $action and $object may have been modified by some hooks $reshook = $hookmanager->executeHooks('viewWebsiteFieldlist', $parameters, $obj, $tmpaction); // Note that $action and $object may have been modified by some hooks
$error = $hookmanager->error; $errors = $hookmanager->errors; $error = $hookmanager->error; $errors = $hookmanager->errors;
if (empty($reshook)) if (empty($reshook))
{ {
foreach ($fieldlist as $field => $value) foreach ($fieldlist as $field => $value)
{ {
$showfield = 1; $showfield = 1;
$align = "left"; $align = "left";
$fieldname = $fieldlist[$field]; $fieldname = $fieldlist[$field];
$valuetoshow = $obj->$fieldname; $valuetoshow = $obj->$fieldname;
// Show value for field // Show value for field
if ($showfield) print '<td align="'.$align.'">'.$valuetoshow.'</td>'; if ($showfield) print '<td align="'.$align.'">'.$valuetoshow.'</td>';
} }
} }
// Can an entry be erased or disabled ? // Can an entry be erased or disabled ?
$iserasable = 1; $isdisable = 1; // true by default $iserasable = 1; $isdisable = 1; // true by default
if ($obj->status) $iserasable = 0; // We can't delete a website on. Disable it first. if ($obj->status) $iserasable = 0; // We can't delete a website on. Disable it first.
$url = $_SERVER["PHP_SELF"].'?'.($page ? 'page='.$page.'&' : '').'sortfield='.$sortfield.'&sortorder='.$sortorder.'&rowid='.(!empty($obj->rowid) ? $obj->rowid : (!empty($obj->code) ? $obj->code : '')).'&amp;code='.(!empty($obj->code) ?urlencode($obj->code) : '').'&amp;'; $url = $_SERVER["PHP_SELF"].'?'.($page ? 'page='.$page.'&' : '').'sortfield='.$sortfield.'&sortorder='.$sortorder.'&rowid='.(!empty($obj->rowid) ? $obj->rowid : (!empty($obj->code) ? $obj->code : '')).'&amp;code='.(!empty($obj->code) ?urlencode($obj->code) : '').'&amp;';
// Active // Active
print '<td align="center" class="nowrap">'; print '<td align="center" class="nowrap">';
print '<a class="reposition" href="'.$url.'action='.$acts[($obj->status ? 1 : 0)].'">'.$actl[($obj->status ? 1 : 0)].'</a>'; print '<a class="reposition" href="'.$url.'action='.$acts[($obj->status ? 1 : 0)].'">'.$actl[($obj->status ? 1 : 0)].'</a>';
print "</td>"; print "</td>";
// Modify link // Modify link
print '<td align="center"><a class="reposition" href="'.$url.'action=edit&token='.newToken().'">'.img_edit().'</a></td>'; print '<td align="center"><a class="reposition" href="'.$url.'action=edit&token='.newToken().'">'.img_edit().'</a></td>';
// Delete link // Delete link
if ($iserasable) print '<td align="center"><a class="reposition" href="'.$url.'action=delete&token='.newToken().'">'.img_delete().'</a></td>'; if ($iserasable) print '<td align="center"><a class="reposition" href="'.$url.'action=delete&token='.newToken().'">'.img_delete().'</a></td>';
else print '<td class="center">'.img_delete($langs->trans("DisableSiteFirst"), 'class="opacitymedium"').'</td>'; else print '<td class="center">'.img_delete($langs->trans("DisableSiteFirst"), 'class="opacitymedium"').'</td>';
print "</tr>\n"; print "</tr>\n";
} }
$i++; $i++;
} }
print '</table>'; print '</table>';
print '</form>'; print '</form>';
} }
} else { } else {
dol_print_error($db); dol_print_error($db);
} }
} }
dol_fiche_end(); dol_fiche_end();
@ -649,7 +649,7 @@ function fieldListWebsites($fieldlist, $obj = '', $tabname = '', $context = '')
foreach ($fieldlist as $field => $value) foreach ($fieldlist as $field => $value)
{ {
$fieldname = $fieldlist[$field]; $fieldname = $fieldlist[$field];
if ($fieldlist[$field] == 'lang') if ($fieldlist[$field] == 'lang')
{ {
print '<td>'; print '<td>';

File diff suppressed because it is too large Load Diff

View File

@ -111,21 +111,21 @@ print '</td>';
if ($this->status == 0 && ($object_rights->write) && $action != 'selectlines') { if ($this->status == 0 && ($object_rights->write) && $action != 'selectlines') {
print '<td class="linecoledit center">'; print '<td class="linecoledit center">';
$coldisplay++; $coldisplay++;
if (($line->info_bits & 2) == 2 || !empty($disableedit)) { if (($line->info_bits & 2) == 2 || !empty($disableedit)) {
} else { } else {
print '<a class="editfielda reposition" href="'.$_SERVER["PHP_SELF"].'?id='.$this->id.'&amp;action=editline&amp;lineid='.$line->id.'">'.img_edit().'</a>'; print '<a class="editfielda reposition" href="'.$_SERVER["PHP_SELF"].'?id='.$this->id.'&amp;action=editline&amp;lineid='.$line->id.'">'.img_edit().'</a>';
} }
print '</td>'; print '</td>';
print '<td class="linecoldelete center">'; print '<td class="linecoldelete center">';
$coldisplay++; $coldisplay++;
if (($line->fk_prev_id == null) && empty($disableremove)) { if (($line->fk_prev_id == null) && empty($disableremove)) {
//La suppression n'est autorisée que si il n'y a pas de ligne dans une précédente situation //La suppression n'est autorisée que si il n'y a pas de ligne dans une précédente situation
print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?id='.$this->id.'&amp;action=deleteline&amp;token='.newToken().'&amp;lineid='.$line->id.'">'; print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?id='.$this->id.'&amp;action=deleteline&amp;token='.newToken().'&amp;lineid='.$line->id.'">';
print img_delete(); print img_delete();
print '</a>'; print '</a>';
} }
print '</td>'; print '</td>';
if ($num > 1 && $conf->browser->layout != 'phone' && empty($disablemove)) { if ($num > 1 && $conf->browser->layout != 'phone' && empty($disablemove)) {
print '<td class="linecolmove tdlineupdown center">'; print '<td class="linecolmove tdlineupdown center">';
@ -146,14 +146,14 @@ if ($this->status == 0 && ($object_rights->write) && $action != 'selectlines') {
$coldisplay++; $coldisplay++;
} }
} else { } else {
print '<td colspan="3"></td>'; print '<td colspan="3"></td>';
$coldisplay = $coldisplay + 3; $coldisplay = $coldisplay + 3;
} }
if ($action == 'selectlines') { if ($action == 'selectlines') {
print '<td class="linecolcheck center">'; print '<td class="linecolcheck center">';
print '<input type="checkbox" class="linecheckbox" name="line_checkbox['.($i + 1).']" value="'.$line->id.'" >'; print '<input type="checkbox" class="linecheckbox" name="line_checkbox['.($i + 1).']" value="'.$line->id.'" >';
print '</td>'; print '</td>';
} }
print '</tr>'; print '</tr>';

View File

@ -44,8 +44,8 @@ $confirm = GETPOST('confirm');
if ($id == '' && $label == '') if ($id == '' && $label == '')
{ {
dol_print_error('', 'Missing parameter id'); dol_print_error('', 'Missing parameter id');
exit(); exit();
} }
// Security check // Security check
@ -70,34 +70,34 @@ if (is_numeric($type)) $type = Categorie::$MAP_ID_TO_CODE[$type]; // For backwar
if (isset($_FILES['userfile']) && $_FILES['userfile']['size'] > 0 && $_POST["sendit"] && !empty($conf->global->MAIN_UPLOAD_DOC)) if (isset($_FILES['userfile']) && $_FILES['userfile']['size'] > 0 && $_POST["sendit"] && !empty($conf->global->MAIN_UPLOAD_DOC))
{ {
if ($object->id) { if ($object->id) {
$file = $_FILES['userfile']; $file = $_FILES['userfile'];
if (is_array($file['name']) && count($file['name']) > 0) if (is_array($file['name']) && count($file['name']) > 0)
{ {
foreach ($file['name'] as $i => $name) foreach ($file['name'] as $i => $name)
{ {
if (empty($file['tmp_name'][$i]) || intval($conf->global->MAIN_UPLOAD_DOC) * 1000 <= filesize($file['tmp_name'][$i])) if (empty($file['tmp_name'][$i]) || intval($conf->global->MAIN_UPLOAD_DOC) * 1000 <= filesize($file['tmp_name'][$i]))
{ {
setEventMessage($file['name'][$i].' : '.$langs->trans(empty($file['tmp_name'][$i]) ? 'ErrorFailedToSaveFile' : 'MaxSizeForUploadedFiles')); setEventMessage($file['name'][$i].' : '.$langs->trans(empty($file['tmp_name'][$i]) ? 'ErrorFailedToSaveFile' : 'MaxSizeForUploadedFiles'));
unset($file['name'][$i], $file['type'][$i], $file['tmp_name'][$i], $file['error'][$i], $file['size'][$i]); unset($file['name'][$i], $file['type'][$i], $file['tmp_name'][$i], $file['error'][$i], $file['size'][$i]);
} }
} }
} }
if (!empty($file['tmp_name'])) { if (!empty($file['tmp_name'])) {
$object->add_photo($upload_dir, $file); $object->add_photo($upload_dir, $file);
} }
} }
} }
if ($action == 'confirm_delete' && $_GET["file"] && $confirm == 'yes' && $user->rights->categorie->creer) if ($action == 'confirm_delete' && $_GET["file"] && $confirm == 'yes' && $user->rights->categorie->creer)
{ {
$object->delete_photo($upload_dir."/".$_GET["file"]); $object->delete_photo($upload_dir."/".$_GET["file"]);
} }
if ($action == 'addthumb' && $_GET["file"]) if ($action == 'addthumb' && $_GET["file"])
{ {
$object->addThumbs($upload_dir."/".$_GET["file"]); $object->addThumbs($upload_dir."/".$_GET["file"]);
} }
@ -126,7 +126,7 @@ if ($object->id)
$ways = $object->print_all_ways(" &gt;&gt; ", '', 1); $ways = $object->print_all_ways(" &gt;&gt; ", '', 1);
foreach ($ways as $way) foreach ($ways as $way)
{ {
$morehtmlref .= $way."<br>\n"; $morehtmlref .= $way."<br>\n";
} }
$morehtmlref .= '</div>'; $morehtmlref .= '</div>';
@ -137,7 +137,7 @@ if ($object->id)
*/ */
if ($action == 'delete') if ($action == 'delete')
{ {
print $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&type='.$type.'&file='.$_GET["file"], $langs->trans('DeletePicture'), $langs->trans('ConfirmDeletePicture'), 'confirm_delete', '', 0, 1); print $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&type='.$type.'&file='.$_GET["file"], $langs->trans('DeletePicture'), $langs->trans('ConfirmDeletePicture'), 'confirm_delete', '', 0, 1);
} }
print '<br>'; print '<br>';
@ -159,7 +159,7 @@ if ($object->id)
print '</td></tr>'; print '</td></tr>';
print "</table>\n"; print "</table>\n";
print '</div>'; print '</div>';
dol_fiche_end(); dol_fiche_end();
@ -213,62 +213,62 @@ if ($object->id)
if (is_array($listofphoto) && count($listofphoto)) if (is_array($listofphoto) && count($listofphoto))
{ {
print '<br>'; print '<br>';
print '<table width="100%" valign="top" align="center">'; print '<table width="100%" valign="top" align="center">';
foreach ($listofphoto as $key => $obj) foreach ($listofphoto as $key => $obj)
{ {
$nbphoto++; $nbphoto++;
if ($nbbyrow && ($nbphoto % $nbbyrow == 1)) print '<tr align=center valign=middle border=1>'; if ($nbbyrow && ($nbphoto % $nbbyrow == 1)) print '<tr align=center valign=middle border=1>';
if ($nbbyrow) print '<td width="'.ceil(100 / $nbbyrow).'%" class="photo">'; if ($nbbyrow) print '<td width="'.ceil(100 / $nbbyrow).'%" class="photo">';
print '<a href="'.DOL_URL_ROOT.'/viewimage.php?modulepart=category&entity='.$object->entity.'&file='.urlencode($pdir.$obj['photo']).'" alt="Taille origine" target="_blank">'; print '<a href="'.DOL_URL_ROOT.'/viewimage.php?modulepart=category&entity='.$object->entity.'&file='.urlencode($pdir.$obj['photo']).'" alt="Taille origine" target="_blank">';
// Si fichier vignette disponible, on l'utilise, sinon on utilise photo origine // Si fichier vignette disponible, on l'utilise, sinon on utilise photo origine
if ($obj['photo_vignette']) if ($obj['photo_vignette'])
{ {
$filename = $obj['photo_vignette']; $filename = $obj['photo_vignette'];
} else { } else {
$filename = $obj['photo']; $filename = $obj['photo'];
} }
// Nom affiche // Nom affiche
$viewfilename = $obj['photo']; $viewfilename = $obj['photo'];
// Taille de l'image // Taille de l'image
$object->get_image_size($dir.$filename); $object->get_image_size($dir.$filename);
$imgWidth = ($object->imgWidth < $maxWidth) ? $object->imgWidth : $maxWidth; $imgWidth = ($object->imgWidth < $maxWidth) ? $object->imgWidth : $maxWidth;
$imgHeight = ($object->imgHeight < $maxHeight) ? $object->imgHeight : $maxHeight; $imgHeight = ($object->imgHeight < $maxHeight) ? $object->imgHeight : $maxHeight;
print '<img border="0" width="'.$imgWidth.'" height="'.$imgHeight.'" src="'.DOL_URL_ROOT.'/viewimage.php?modulepart=category&entity='.$object->entity.'&file='.urlencode($pdir.$filename).'">'; print '<img border="0" width="'.$imgWidth.'" height="'.$imgHeight.'" src="'.DOL_URL_ROOT.'/viewimage.php?modulepart=category&entity='.$object->entity.'&file='.urlencode($pdir.$filename).'">';
print '</a>'; print '</a>';
print '<br>'.$viewfilename; print '<br>'.$viewfilename;
print '<br>'; print '<br>';
// On propose la generation de la vignette si elle n'existe pas et si la taille est superieure aux limites // On propose la generation de la vignette si elle n'existe pas et si la taille est superieure aux limites
if (!$obj['photo_vignette'] && preg_match('/(\.bmp|\.gif|\.jpg|\.jpeg|\.png)$/i', $obj['photo']) && ($object->imgWidth > $maxWidth || $object->imgHeight > $maxHeight)) if (!$obj['photo_vignette'] && preg_match('/(\.bmp|\.gif|\.jpg|\.jpeg|\.png)$/i', $obj['photo']) && ($object->imgWidth > $maxWidth || $object->imgHeight > $maxHeight))
{ {
print '<a href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=addthumb&amp;type='.$type.'&amp;file='.urlencode($pdir.$viewfilename).'">'.img_picto($langs->trans('GenerateThumb'), 'refresh').'&nbsp;&nbsp;</a>'; print '<a href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=addthumb&amp;type='.$type.'&amp;file='.urlencode($pdir.$viewfilename).'">'.img_picto($langs->trans('GenerateThumb'), 'refresh').'&nbsp;&nbsp;</a>';
} }
if ($user->rights->categorie->creer) if ($user->rights->categorie->creer)
{ {
print '<a href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=delete&amp;token='.newToken().'&amp;type='.$type.'&amp;file='.urlencode($pdir.$viewfilename).'">'; print '<a href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=delete&amp;token='.newToken().'&amp;type='.$type.'&amp;file='.urlencode($pdir.$viewfilename).'">';
print img_delete().'</a>'; print img_delete().'</a>';
} }
if ($nbbyrow) print '</td>'; if ($nbbyrow) print '</td>';
if ($nbbyrow && ($nbphoto % $nbbyrow == 0)) print '</tr>'; if ($nbbyrow && ($nbphoto % $nbbyrow == 0)) print '</tr>';
} }
// Ferme tableau // Ferme tableau
while ($nbphoto % $nbbyrow) while ($nbphoto % $nbbyrow)
{ {
print '<td width="'.ceil(100 / $nbbyrow).'%">&nbsp;</td>'; print '<td width="'.ceil(100 / $nbbyrow).'%">&nbsp;</td>';
$nbphoto++; $nbphoto++;
} }
print '</table>'; print '</table>';
} }
if ($nbphoto < 1) if ($nbphoto < 1)
@ -277,7 +277,7 @@ if ($object->id)
} }
} }
} else { } else {
print $langs->trans("ErrorUnknown"); print $langs->trans("ErrorUnknown");
} }
// End of page // End of page

View File

@ -83,43 +83,43 @@ $cancel != $langs->trans("Cancel") &&
$current_lang = $langs->getDefaultLang(); $current_lang = $langs->getDefaultLang();
// check parameters // check parameters
$forcelangprod = GETPOST('forcelangprod', 'alpha'); $forcelangprod = GETPOST('forcelangprod', 'alpha');
$libelle = GETPOST('libelle', 'alpha'); $libelle = GETPOST('libelle', 'alpha');
$desc = GETPOST('desc', 'restricthtml'); $desc = GETPOST('desc', 'restricthtml');
if (empty($forcelangprod)) { if (empty($forcelangprod)) {
$error++; $error++;
$object->errors[] = $langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Translation')); $object->errors[] = $langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Translation'));
} }
if (!$error) { if (!$error) {
if (empty($libelle)) { if (empty($libelle)) {
$error++; $error++;
$object->errors[] = $langs->trans('Language_'.$forcelangprod).' : '.$langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Label')); $object->errors[] = $langs->trans('Language_'.$forcelangprod).' : '.$langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Label'));
} }
if (!$error) { if (!$error) {
// update de l'objet // update de l'objet
if ($forcelangprod == $current_lang) { if ($forcelangprod == $current_lang) {
$object->label = $libelle; $object->label = $libelle;
$object->description = dol_htmlcleanlastbr($desc); $object->description = dol_htmlcleanlastbr($desc);
} else { } else {
$object->multilangs[$forcelangprod]["label"] = $libelle; $object->multilangs[$forcelangprod]["label"] = $libelle;
$object->multilangs[$forcelangprod]["description"] = dol_htmlcleanlastbr($desc); $object->multilangs[$forcelangprod]["description"] = dol_htmlcleanlastbr($desc);
} }
// sauvegarde en base // sauvegarde en base
$res = $object->setMultiLangs($user); $res = $object->setMultiLangs($user);
if ($res < 0) $error++; if ($res < 0) $error++;
} }
} }
if ($error) { if ($error) {
$action = 'add'; $action = 'add';
setEventMessages($object->error, $object->errors, 'errors'); setEventMessages($object->error, $object->errors, 'errors');
} else { } else {
$action = ''; $action = '';
} }
} }
// Validation de l'edition // Validation de l'edition
@ -132,13 +132,13 @@ $cancel != $langs->trans("Cancel") &&
foreach ($object->multilangs as $key => $value) // enregistrement des nouvelles valeurs dans l'objet foreach ($object->multilangs as $key => $value) // enregistrement des nouvelles valeurs dans l'objet
{ {
$libelle = GETPOST('libelle-'.$key, 'alpha'); $libelle = GETPOST('libelle-'.$key, 'alpha');
$desc = GETPOST('desc-'.$key); $desc = GETPOST('desc-'.$key);
if (empty($libelle)) { if (empty($libelle)) {
$error++; $error++;
$object->errors[] = $langs->trans('Language_'.$key).' : '.$langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Label')); $object->errors[] = $langs->trans('Language_'.$key).' : '.$langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Label'));
} }
if ($key == $current_lang) { if ($key == $current_lang) {
$object->label = $libelle; $object->label = $libelle;
@ -149,17 +149,17 @@ $cancel != $langs->trans("Cancel") &&
} }
} }
if (!$error) { if (!$error) {
$res = $object->setMultiLangs($user); $res = $object->setMultiLangs($user);
if ($res < 0) $error++; if ($res < 0) $error++;
} }
if ($error) { if ($error) {
$action = 'edit'; $action = 'edit';
setEventMessages($object->error, $object->errors, 'errors'); setEventMessages($object->error, $object->errors, 'errors');
} else { } else {
$action = ''; $action = '';
} }
} }
@ -181,10 +181,10 @@ $head = categories_prepare_head($object, $type);
$cnt_trans = 0; $cnt_trans = 0;
if (!empty($object->multilangs)) if (!empty($object->multilangs))
{ {
foreach ($object->multilangs as $key => $value) foreach ($object->multilangs as $key => $value)
{ {
$cnt_trans++; $cnt_trans++;
} }
} }
dol_fiche_head($head, 'translation', $langs->trans($title), -1, 'category'); dol_fiche_head($head, 'translation', $langs->trans($title), -1, 'category');
@ -195,7 +195,7 @@ $object->ref = $object->label;
$morehtmlref = '<br><div class="refidno"><a href="'.DOL_URL_ROOT.'/categories/index.php?leftmenu=cat&type='.$type.'">'.$langs->trans("Root").'</a> >> '; $morehtmlref = '<br><div class="refidno"><a href="'.DOL_URL_ROOT.'/categories/index.php?leftmenu=cat&type='.$type.'">'.$langs->trans("Root").'</a> >> ';
$ways = $object->print_all_ways(" &gt;&gt; ", '', 1); $ways = $object->print_all_ways(" &gt;&gt; ", '', 1);
foreach ($ways as $way) { foreach ($ways as $way) {
$morehtmlref .= $way."<br>\n"; $morehtmlref .= $way."<br>\n";
} }
$morehtmlref .= '</div>'; $morehtmlref .= '</div>';
@ -238,11 +238,11 @@ print "\n<div class=\"tabsAction\">\n";
if ($action == '') if ($action == '')
{ {
if ($user->rights->produit->creer || $user->rights->service->creer) if ($user->rights->produit->creer || $user->rights->service->creer)
{ {
print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?action=add&id='.$object->id.'&type='.$type.'">'.$langs->trans('Add').'</a>'; print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?action=add&id='.$object->id.'&type='.$type.'">'.$langs->trans('Add').'</a>';
if ($cnt_trans > 0) print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?action=edit&id='.$object->id.'&type='.$type.'">'.$langs->trans('Update').'</a>'; if ($cnt_trans > 0) print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?action=edit&id='.$object->id.'&type='.$type.'">'.$langs->trans('Update').'</a>';
} }
} }
print "\n</div>\n"; print "\n</div>\n";
@ -258,20 +258,20 @@ if ($action == 'edit')
print '<input type="hidden" name="token" value="'.newToken().'">'; print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="action" value="vedit">'; print '<input type="hidden" name="action" value="vedit">';
print '<input type="hidden" name="id" value="'.$object->id.'">'; print '<input type="hidden" name="id" value="'.$object->id.'">';
print '<input type="hidden" name="type" value="'.$type.'">'; print '<input type="hidden" name="type" value="'.$type.'">';
if (!empty($object->multilangs)) if (!empty($object->multilangs))
{ {
foreach ($object->multilangs as $key => $value) foreach ($object->multilangs as $key => $value)
{ {
print "<br><b><u>".$langs->trans('Language_'.$key)." :</u></b><br>"; print "<br><b><u>".$langs->trans('Language_'.$key)." :</u></b><br>";
print '<table class="border centpercent">'; print '<table class="border centpercent">';
// Label // Label
$libelle = (GETPOST('libelle-'.$key, 'alpha') ? GETPOST('libelle-'.$key, 'alpha') : $object->multilangs[$key]['label']); $libelle = (GETPOST('libelle-'.$key, 'alpha') ? GETPOST('libelle-'.$key, 'alpha') : $object->multilangs[$key]['label']);
print '<tr><td class="titlefield fieldrequired">'.$langs->trans('Label').'</td><td><input name="libelle-'.$key.'" size="40" value="'.$libelle.'"></td></tr>'; print '<tr><td class="titlefield fieldrequired">'.$langs->trans('Label').'</td><td><input name="libelle-'.$key.'" size="40" value="'.$libelle.'"></td></tr>';
// Desc // Desc
$desc = (GETPOST('desc-'.$key) ? GETPOST('desc-'.$key) : $object->multilangs[$key]['description']); $desc = (GETPOST('desc-'.$key) ? GETPOST('desc-'.$key) : $object->multilangs[$key]['description']);
print '<tr><td class="tdtop">'.$langs->trans('Description').'</td><td>'; print '<tr><td class="tdtop">'.$langs->trans('Description').'</td><td>';
$doleditor = new DolEditor("desc-$key", $desc, '', 160, 'dolibarr_notes', '', false, true, $conf->global->FCKEDITOR_ENABLE_PRODUCTDESC, ROWS_3, '90%'); $doleditor = new DolEditor("desc-$key", $desc, '', 160, 'dolibarr_notes', '', false, true, $conf->global->FCKEDITOR_ENABLE_PRODUCTDESC, ROWS_3, '90%');
$doleditor->Create(); $doleditor->Create();
@ -293,20 +293,20 @@ if ($action == 'edit')
print '</form>'; print '</form>';
} elseif ($action != 'add') } elseif ($action != 'add')
{ {
if ($cnt_trans) print '<div class="underbanner clearboth"></div>'; if ($cnt_trans) print '<div class="underbanner clearboth"></div>';
if (!empty($object->multilangs)) if (!empty($object->multilangs))
{ {
foreach ($object->multilangs as $key => $value) foreach ($object->multilangs as $key => $value)
{ {
$s = picto_from_langcode($key); $s = picto_from_langcode($key);
print '<table class="border centpercent">'; print '<table class="border centpercent">';
print '<tr class="liste_titre"><td colspan="2">'.($s ? $s.' ' : '')." <b>".$langs->trans('Language_'.$key).":</b> ".'<a href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=delete&token='.newToken().'&langtodelete='.$key.'&type='.$type.'">'.img_delete('', '').'</a></td></tr>'; print '<tr class="liste_titre"><td colspan="2">'.($s ? $s.' ' : '')." <b>".$langs->trans('Language_'.$key).":</b> ".'<a href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=delete&token='.newToken().'&langtodelete='.$key.'&type='.$type.'">'.img_delete('', '').'</a></td></tr>';
print '<tr><td class="titlefield">'.$langs->trans('Label').'</td><td>'.$object->multilangs[$key]["label"].'</td></tr>'; print '<tr><td class="titlefield">'.$langs->trans('Label').'</td><td>'.$object->multilangs[$key]["label"].'</td></tr>';
print '<tr><td>'.$langs->trans('Description').'</td><td>'.$object->multilangs[$key]["description"].'</td></tr>'; print '<tr><td>'.$langs->trans('Description').'</td><td>'.$object->multilangs[$key]["description"].'</td></tr>';
if (!empty($conf->global->CATEGORY_USE_OTHER_FIELD_IN_TRANSLATION)) if (!empty($conf->global->CATEGORY_USE_OTHER_FIELD_IN_TRANSLATION))
{ {
print '<tr><td>'.$langs->trans('Other').' ('.$langs->trans("NotUsed").')</td><td>'.$object->multilangs[$key]["other"].'</td></tr>'; print '<tr><td>'.$langs->trans('Other').' ('.$langs->trans("NotUsed").')</td><td>'.$object->multilangs[$key]["other"].'</td></tr>';
} }
print '</table>'; print '</table>';
} }
@ -329,11 +329,11 @@ if ($action == 'add' && ($user->rights->produit->creer || $user->rights->service
print '<input type="hidden" name="token" value="'.newToken().'">'; print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="action" value="vadd">'; print '<input type="hidden" name="action" value="vadd">';
print '<input type="hidden" name="id" value="'.$id.'">'; print '<input type="hidden" name="id" value="'.$id.'">';
print '<input type="hidden" name="type" value="'.$type.'">'; print '<input type="hidden" name="type" value="'.$type.'">';
print '<table class="border centpercent">'; print '<table class="border centpercent">';
print '<tr><td class="titlefield fieldrequired">'.$langs->trans('Translation').'</td><td>'; print '<tr><td class="titlefield fieldrequired">'.$langs->trans('Translation').'</td><td>';
print $formadmin->select_language(GETPOST('forcelangprod', 'alpha'), 'forcelangprod', 0, $object->multilangs); print $formadmin->select_language(GETPOST('forcelangprod', 'alpha'), 'forcelangprod', 0, $object->multilangs);
print '</td></tr>'; print '</td></tr>';
print '<tr><td class="fieldrequired">'.$langs->trans('Label').'</td>'; print '<tr><td class="fieldrequired">'.$langs->trans('Label').'</td>';
print '<td><input name="libelle" class="minwidth200 maxwidth300" value="'.GETPOST('libelle', 'alpha').'"></td></tr>'; print '<td><input name="libelle" class="minwidth200 maxwidth300" value="'.GETPOST('libelle', 'alpha').'"></td></tr>';

View File

@ -138,12 +138,12 @@ if (empty($reshook))
} }
// customer preferred shipping method // customer preferred shipping method
if ($action == 'setshippingmethod' && $user->rights->societe->creer) if ($action == 'setshippingmethod' && $user->rights->societe->creer)
{ {
$object->fetch($id); $object->fetch($id);
$result = $object->setShippingMethod(GETPOST('shipping_method_id', 'int')); $result = $object->setShippingMethod(GETPOST('shipping_method_id', 'int'));
if ($result < 0) setEventMessages($object->error, $object->errors, 'errors'); if ($result < 0) setEventMessages($object->error, $object->errors, 'errors');
} }
// assujetissement a la TVA // assujetissement a la TVA
if ($action == 'setassujtva' && $user->rights->societe->creer) if ($action == 'setassujtva' && $user->rights->societe->creer)
@ -191,31 +191,31 @@ if (empty($reshook))
} }
// Set sales representatives // Set sales representatives
if ($action == 'set_salesrepresentatives' && $user->rights->societe->creer) if ($action == 'set_salesrepresentatives' && $user->rights->societe->creer)
{ {
$object->fetch($id); $object->fetch($id);
$result = $object->setSalesRep(GETPOST('commercial', 'array')); $result = $object->setSalesRep(GETPOST('commercial', 'array'));
} }
if ($action == 'update_extras') { if ($action == 'update_extras') {
$object->fetch($id); $object->fetch($id);
$object->oldcopy = dol_clone($object); $object->oldcopy = dol_clone($object);
// Fill array 'array_options' with data from update form // Fill array 'array_options' with data from update form
$ret = $extrafields->setOptionalsFromPost(null, $object, GETPOST('attribute', 'restricthtml')); $ret = $extrafields->setOptionalsFromPost(null, $object, GETPOST('attribute', 'restricthtml'));
if ($ret < 0) $error++; if ($ret < 0) $error++;
if (!$error) if (!$error)
{ {
$result = $object->insertExtraFields('COMPANY_MODIFY'); $result = $object->insertExtraFields('COMPANY_MODIFY');
if ($result < 0) if ($result < 0)
{ {
setEventMessages($object->error, $object->errors, 'errors'); setEventMessages($object->error, $object->errors, 'errors');
$error++; $error++;
} }
} }
if ($error) $action = 'edit_extras'; if ($error) $action = 'edit_extras';
} }
} }
@ -249,11 +249,11 @@ if ($object->id > 0)
$linkback = '<a href="'.DOL_URL_ROOT.'/societe/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>'; $linkback = '<a href="'.DOL_URL_ROOT.'/societe/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
dol_banner_tab($object, 'socid', $linkback, ($user->socid ? 0 : 1), 'rowid', 'nom'); dol_banner_tab($object, 'socid', $linkback, ($user->socid ? 0 : 1), 'rowid', 'nom');
print '<div class="fichecenter"><div class="fichehalfleft">'; print '<div class="fichecenter"><div class="fichehalfleft">';
print '<div class="underbanner clearboth"></div>'; print '<div class="underbanner clearboth"></div>';
print '<table class="border centpercent tableforfield">'; print '<table class="border centpercent tableforfield">';
// Prospect/Customer // Prospect/Customer
@ -262,16 +262,16 @@ if ($object->id > 0)
print '</td></tr>'; print '</td></tr>';
// Prefix // Prefix
if (!empty($conf->global->SOCIETE_USEPREFIX)) // Old not used prefix field if (!empty($conf->global->SOCIETE_USEPREFIX)) // Old not used prefix field
{ {
print '<tr><td>'.$langs->trans("Prefix").'</td><td>'; print '<tr><td>'.$langs->trans("Prefix").'</td><td>';
print ($object->prefix_comm ? $object->prefix_comm : '&nbsp;'); print ($object->prefix_comm ? $object->prefix_comm : '&nbsp;');
print '</td></tr>'; print '</td></tr>';
} }
if ($object->client) if ($object->client)
{ {
$langs->load("compta"); $langs->load("compta");
print '<tr><td>'; print '<tr><td>';
print $langs->trans('CustomerCode').'</td><td>'; print $langs->trans('CustomerCode').'</td><td>';
@ -386,64 +386,64 @@ if ($object->id > 0)
// Relative discounts (Discounts-Drawbacks-Rebates) // Relative discounts (Discounts-Drawbacks-Rebates)
if ($isCustomer) if ($isCustomer)
{ {
print '<tr><td class="nowrap">'; print '<tr><td class="nowrap">';
print '<table width="100%" class="nobordernopadding"><tr><td class="nowrap">'; print '<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
print $langs->trans("CustomerRelativeDiscountShort"); print $langs->trans("CustomerRelativeDiscountShort");
print '<td><td class="right">'; print '<td><td class="right">';
if ($user->rights->societe->creer && !$user->socid > 0) if ($user->rights->societe->creer && !$user->socid > 0)
{ {
print '<a class="editfielda" href="'.DOL_URL_ROOT.'/comm/remise.php?id='.$object->id.'">'.img_edit($langs->trans("Modify")).'</a>'; print '<a class="editfielda" href="'.DOL_URL_ROOT.'/comm/remise.php?id='.$object->id.'">'.img_edit($langs->trans("Modify")).'</a>';
} }
print '</td></tr></table>'; print '</td></tr></table>';
print '</td><td>'.($object->remise_percent ? '<a href="'.DOL_URL_ROOT.'/comm/remise.php?id='.$object->id.'">'.$object->remise_percent.'%</a>' : '').'</td>'; print '</td><td>'.($object->remise_percent ? '<a href="'.DOL_URL_ROOT.'/comm/remise.php?id='.$object->id.'">'.$object->remise_percent.'%</a>' : '').'</td>';
print '</tr>'; print '</tr>';
// Absolute discounts (Discounts-Drawbacks-Rebates) // Absolute discounts (Discounts-Drawbacks-Rebates)
print '<tr><td class="nowrap">'; print '<tr><td class="nowrap">';
print '<table width="100%" class="nobordernopadding">'; print '<table width="100%" class="nobordernopadding">';
print '<tr><td class="nowrap">'; print '<tr><td class="nowrap">';
print $langs->trans("CustomerAbsoluteDiscountShort"); print $langs->trans("CustomerAbsoluteDiscountShort");
print '<td><td class="right">'; print '<td><td class="right">';
if ($user->rights->societe->creer && !$user->socid > 0) if ($user->rights->societe->creer && !$user->socid > 0)
{ {
print '<a class="editfielda" href="'.DOL_URL_ROOT.'/comm/remx.php?id='.$object->id.'&backtopage='.urlencode($_SERVER["PHP_SELF"].'?socid='.$object->id).'">'.img_edit($langs->trans("Modify")).'</a>'; print '<a class="editfielda" href="'.DOL_URL_ROOT.'/comm/remx.php?id='.$object->id.'&backtopage='.urlencode($_SERVER["PHP_SELF"].'?socid='.$object->id).'">'.img_edit($langs->trans("Modify")).'</a>';
} }
print '</td></tr></table>'; print '</td></tr></table>';
print '</td>'; print '</td>';
print '<td>'; print '<td>';
$amount_discount = $object->getAvailableDiscounts(); $amount_discount = $object->getAvailableDiscounts();
if ($amount_discount < 0) dol_print_error($db, $object->error); if ($amount_discount < 0) dol_print_error($db, $object->error);
if ($amount_discount > 0) print '<a href="'.DOL_URL_ROOT.'/comm/remx.php?id='.$object->id.'&backtopage='.urlencode($_SERVER["PHP_SELF"].'?socid='.$object->id).'">'.price($amount_discount, 1, $langs, 1, -1, -1, $conf->currency).'</a>'; if ($amount_discount > 0) print '<a href="'.DOL_URL_ROOT.'/comm/remx.php?id='.$object->id.'&backtopage='.urlencode($_SERVER["PHP_SELF"].'?socid='.$object->id).'">'.price($amount_discount, 1, $langs, 1, -1, -1, $conf->currency).'</a>';
//else print $langs->trans("DiscountNone"); //else print $langs->trans("DiscountNone");
print '</td>'; print '</td>';
print '</tr>'; print '</tr>';
} }
// Max outstanding bill // Max outstanding bill
if ($object->client) if ($object->client)
{ {
print '<tr class="nowrap">'; print '<tr class="nowrap">';
print '<td>'; print '<td>';
print $form->editfieldkey("OutstandingBill", 'outstanding_limit', $object->outstanding_limit, $object, $user->rights->societe->creer); print $form->editfieldkey("OutstandingBill", 'outstanding_limit', $object->outstanding_limit, $object, $user->rights->societe->creer);
print '</td><td>'; print '</td><td>';
$limit_field_type = (!empty($conf->global->MAIN_USE_JQUERY_JEDITABLE)) ? 'numeric' : 'amount'; $limit_field_type = (!empty($conf->global->MAIN_USE_JQUERY_JEDITABLE)) ? 'numeric' : 'amount';
print $form->editfieldval("OutstandingBill", 'outstanding_limit', $object->outstanding_limit, $object, $user->rights->societe->creer, $limit_field_type, ($object->outstanding_limit != '' ? price($object->outstanding_limit) : '')); print $form->editfieldval("OutstandingBill", 'outstanding_limit', $object->outstanding_limit, $object, $user->rights->societe->creer, $limit_field_type, ($object->outstanding_limit != '' ? price($object->outstanding_limit) : ''));
print '</td>'; print '</td>';
print '</tr>'; print '</tr>';
} }
if ($object->client) if ($object->client)
{ {
if (!empty($conf->commande->enabled) && !empty($conf->global->ORDER_MANAGE_MIN_AMOUNT)) if (!empty($conf->commande->enabled) && !empty($conf->global->ORDER_MANAGE_MIN_AMOUNT))
{ {
print '<!-- Minimim amount for orders -->'."\n"; print '<!-- Minimim amount for orders -->'."\n";
print '<tr class="nowrap">'; print '<tr class="nowrap">';
print '<td>'; print '<td>';
print $form->editfieldkey("OrderMinAmount", 'order_min_amount', $object->order_min_amount, $object, $user->rights->societe->creer); print $form->editfieldkey("OrderMinAmount", 'order_min_amount', $object->order_min_amount, $object, $user->rights->societe->creer);
print '</td><td>'; print '</td><td>';
print $form->editfieldval("OrderMinAmount", 'order_min_amount', $object->order_min_amount, $object, $user->rights->societe->creer, $limit_field_type, ($object->order_min_amount != '' ? price($object->order_min_amount) : '')); print $form->editfieldval("OrderMinAmount", 'order_min_amount', $object->order_min_amount, $object, $user->rights->societe->creer, $limit_field_type, ($object->order_min_amount != '' ? price($object->order_min_amount) : ''));
print '</td>'; print '</td>';
print '</tr>'; print '</tr>';
} }
} }
@ -468,24 +468,24 @@ if ($object->id > 0)
print '</tr>'; print '</tr>';
} }
// Preferred shipping Method // Preferred shipping Method
if (!empty($conf->global->SOCIETE_ASK_FOR_SHIPPING_METHOD)) { if (!empty($conf->global->SOCIETE_ASK_FOR_SHIPPING_METHOD)) {
print '<tr><td class="nowrap">'; print '<tr><td class="nowrap">';
print '<table width="100%" class="nobordernopadding"><tr><td class="nowrap">'; print '<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
print $langs->trans('SendingMethod'); print $langs->trans('SendingMethod');
print '<td>'; print '<td>';
if (($action != 'editshipping') && $user->rights->societe->creer) print '<td class="right"><a class="editfielda" href="'.$_SERVER["PHP_SELF"].'?action=editshipping&amp;socid='.$object->id.'">'.img_edit($langs->trans('SetMode'), 1).'</a></td>'; if (($action != 'editshipping') && $user->rights->societe->creer) print '<td class="right"><a class="editfielda" href="'.$_SERVER["PHP_SELF"].'?action=editshipping&amp;socid='.$object->id.'">'.img_edit($langs->trans('SetMode'), 1).'</a></td>';
print '</tr></table>'; print '</tr></table>';
print '</td><td>'; print '</td><td>';
if ($action == 'editshipping') if ($action == 'editshipping')
{ {
$form->formSelectShippingMethod($_SERVER['PHP_SELF'].'?socid='.$object->id, $object->shipping_method_id, 'shipping_method_id', 1); $form->formSelectShippingMethod($_SERVER['PHP_SELF'].'?socid='.$object->id, $object->shipping_method_id, 'shipping_method_id', 1);
} else { } else {
$form->formSelectShippingMethod($_SERVER['PHP_SELF'].'?socid='.$object->id, $object->shipping_method_id, 'none'); $form->formSelectShippingMethod($_SERVER['PHP_SELF'].'?socid='.$object->id, $object->shipping_method_id, 'none');
} }
print "</td>"; print "</td>";
print '</tr>'; print '</tr>';
} }
// Categories // Categories
if (!empty($conf->categorie->enabled) && !empty($user->rights->categorie->lire)) { if (!empty($conf->categorie->enabled) && !empty($user->rights->categorie->lire)) {
@ -500,70 +500,70 @@ if ($object->id > 0)
$parameters = array('socid'=>$object->id); $parameters = array('socid'=>$object->id);
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php'; include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php';
// Sales representative // Sales representative
include DOL_DOCUMENT_ROOT.'/societe/tpl/linesalesrepresentative.tpl.php'; include DOL_DOCUMENT_ROOT.'/societe/tpl/linesalesrepresentative.tpl.php';
// Module Adherent // Module Adherent
if (!empty($conf->adherent->enabled)) if (!empty($conf->adherent->enabled))
{ {
$langs->load("members"); $langs->load("members");
$langs->load("users"); $langs->load("users");
print '<tr><td class="titlefield">'.$langs->trans("LinkedToDolibarrMember").'</td>'; print '<tr><td class="titlefield">'.$langs->trans("LinkedToDolibarrMember").'</td>';
print '<td>'; print '<td>';
$adh = new Adherent($db); $adh = new Adherent($db);
$result = $adh->fetch('', '', $object->id); $result = $adh->fetch('', '', $object->id);
if ($result > 0) if ($result > 0)
{ {
$adh->ref = $adh->getFullName($langs); $adh->ref = $adh->getFullName($langs);
print $adh->getNomUrl(1); print $adh->getNomUrl(1);
} else { } else {
print '<span class="opacitymedium">'.$langs->trans("ThirdpartyNotLinkedToMember").'</span>'; print '<span class="opacitymedium">'.$langs->trans("ThirdpartyNotLinkedToMember").'</span>';
} }
print '</td>'; print '</td>';
print "</tr>\n"; print "</tr>\n";
} }
print "</table>"; print "</table>";
// Prospection level and status // Prospection level and status
if ($object->client == 2 || $object->client == 3) if ($object->client == 2 || $object->client == 3)
{ {
print '<br>'; print '<br>';
print '<div class="underbanner clearboth"></div>'; print '<div class="underbanner clearboth"></div>';
print '<table class="border centpercent tableforfield">'; print '<table class="border centpercent tableforfield">';
// Level of prospection // Level of prospection
print '<tr><td class="titlefield nowrap">'; print '<tr><td class="titlefield nowrap">';
print '<table width="100%" class="nobordernopadding"><tr><td class="nowrap">'; print '<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
print $langs->trans('ProspectLevel'); print $langs->trans('ProspectLevel');
print '<td>'; print '<td>';
if ($action != 'editlevel' && $user->rights->societe->creer) print '<td class="right"><a class="editfielda reposition" href="'.$_SERVER["PHP_SELF"].'?action=editlevel&amp;socid='.$object->id.'">'.img_edit($langs->trans('Modify'), 1).'</a></td>'; if ($action != 'editlevel' && $user->rights->societe->creer) print '<td class="right"><a class="editfielda reposition" href="'.$_SERVER["PHP_SELF"].'?action=editlevel&amp;socid='.$object->id.'">'.img_edit($langs->trans('Modify'), 1).'</a></td>';
print '</tr></table>'; print '</tr></table>';
print '</td><td>'; print '</td><td>';
if ($action == 'editlevel') if ($action == 'editlevel')
{ {
$formcompany->form_prospect_level($_SERVER['PHP_SELF'].'?socid='.$object->id, $object->fk_prospectlevel, 'prospect_level_id', 1); $formcompany->form_prospect_level($_SERVER['PHP_SELF'].'?socid='.$object->id, $object->fk_prospectlevel, 'prospect_level_id', 1);
} else { } else {
print $object->getLibProspLevel(); print $object->getLibProspLevel();
} }
print "</td>"; print "</td>";
print '</tr>'; print '</tr>';
// Status of prospection // Status of prospection
$object->loadCacheOfProspStatus(); $object->loadCacheOfProspStatus();
print '<tr><td>'.$langs->trans("StatusProsp").'</td><td>'.$object->getLibProspCommStatut(4, $object->cacheprospectstatus[$object->stcomm_id]['label']); print '<tr><td>'.$langs->trans("StatusProsp").'</td><td>'.$object->getLibProspCommStatut(4, $object->cacheprospectstatus[$object->stcomm_id]['label']);
print ' &nbsp; &nbsp; '; print ' &nbsp; &nbsp; ';
print '<div class="floatright">'; print '<div class="floatright">';
foreach ($object->cacheprospectstatus as $key => $val) foreach ($object->cacheprospectstatus as $key => $val)
{ {
$titlealt = 'default'; $titlealt = 'default';
if (!empty($val['code']) && !in_array($val['code'], array('ST_NO', 'ST_NEVER', 'ST_TODO', 'ST_PEND', 'ST_DONE'))) $titlealt = $val['label']; if (!empty($val['code']) && !in_array($val['code'], array('ST_NO', 'ST_NEVER', 'ST_TODO', 'ST_PEND', 'ST_DONE'))) $titlealt = $val['label'];
if ($object->stcomm_id != $val['id']) print '<a class="pictosubstatus reposition" href="'.$_SERVER["PHP_SELF"].'?socid='.$object->id.'&stcomm='.$val['code'].'&action=setstcomm&token='.newToken().'">'.img_action($titlealt, $val['code'], $val['picto']).'</a>'; if ($object->stcomm_id != $val['id']) print '<a class="pictosubstatus reposition" href="'.$_SERVER["PHP_SELF"].'?socid='.$object->id.'&stcomm='.$val['code'].'&action=setstcomm&token='.newToken().'">'.img_action($titlealt, $val['code'], $val['picto']).'</a>';
} }
print '</div></td></tr>'; print '</div></td></tr>';
print "</table>"; print "</table>";
} }
print '</div><div class="fichehalfright"><div class="ficheaddleft">'; print '</div><div class="fichehalfright"><div class="ficheaddleft">';
@ -670,9 +670,9 @@ if ($object->id > 0)
$langs->load("propal"); $langs->load("propal");
$sql = "SELECT s.nom, s.rowid, p.rowid as propalid, p.fk_statut, p.total_ht"; $sql = "SELECT s.nom, s.rowid, p.rowid as propalid, p.fk_statut, p.total_ht";
$sql .= ", p.tva as total_tva"; $sql .= ", p.tva as total_tva";
$sql .= ", p.total as total_ttc"; $sql .= ", p.total as total_ttc";
$sql .= ", p.ref, p.ref_client, p.remise"; $sql .= ", p.ref, p.ref_client, p.remise";
$sql .= ", p.datep as dp, p.fin_validite as date_limit"; $sql .= ", p.datep as dp, p.fin_validite as date_limit";
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."propal as p, ".MAIN_DB_PREFIX."c_propalst as c"; $sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."propal as p, ".MAIN_DB_PREFIX."c_propalst as c";
$sql .= " WHERE p.fk_soc = s.rowid AND p.fk_statut = c.id"; $sql .= " WHERE p.fk_soc = s.rowid AND p.fk_statut = c.id";
@ -686,17 +686,17 @@ if ($object->id > 0)
$propal_static = new Propal($db); $propal_static = new Propal($db);
$num = $db->num_rows($resql); $num = $db->num_rows($resql);
if ($num > 0) if ($num > 0)
{ {
print '<div class="div-table-responsive-no-min">'; print '<div class="div-table-responsive-no-min">';
print '<table class="noborder centpercent lastrecordtable">'; print '<table class="noborder centpercent lastrecordtable">';
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print '<td colspan="4"><table width="100%" class="nobordernopadding"><tr><td>'.$langs->trans("LastPropals", ($num <= $MAXLIST ? "" : $MAXLIST)).'</td><td class="right"><a class="notasortlink" href="'.DOL_URL_ROOT.'/comm/propal/list.php?socid='.$object->id.'">'.$langs->trans("AllPropals").'<span class="badge marginleftonlyshort">'.$num.'</span></a></td>'; print '<td colspan="4"><table width="100%" class="nobordernopadding"><tr><td>'.$langs->trans("LastPropals", ($num <= $MAXLIST ? "" : $MAXLIST)).'</td><td class="right"><a class="notasortlink" href="'.DOL_URL_ROOT.'/comm/propal/list.php?socid='.$object->id.'">'.$langs->trans("AllPropals").'<span class="badge marginleftonlyshort">'.$num.'</span></a></td>';
print '<td width="20px" class="right"><a href="'.DOL_URL_ROOT.'/comm/propal/stats/index.php?socid='.$object->id.'">'.img_picto($langs->trans("Statistics"), 'stats').'</a></td>'; print '<td width="20px" class="right"><a href="'.DOL_URL_ROOT.'/comm/propal/stats/index.php?socid='.$object->id.'">'.img_picto($langs->trans("Statistics"), 'stats').'</a></td>';
print '</tr></table></td>'; print '</tr></table></td>';
print '</tr>'; print '</tr>';
} }
$i = 0; $i = 0;
while ($i < $num && $i < $MAXLIST) while ($i < $num && $i < $MAXLIST)
@ -704,17 +704,17 @@ if ($object->id > 0)
$objp = $db->fetch_object($resql); $objp = $db->fetch_object($resql);
print '<tr class="oddeven">'; print '<tr class="oddeven">';
print '<td class="nowrap">'; print '<td class="nowrap">';
$propal_static->id = $objp->propalid; $propal_static->id = $objp->propalid;
$propal_static->ref = $objp->ref; $propal_static->ref = $objp->ref;
$propal_static->ref_client = $objp->ref_client; $propal_static->ref_client = $objp->ref_client;
$propal_static->total_ht = $objp->total_ht; $propal_static->total_ht = $objp->total_ht;
$propal_static->total_tva = $objp->total_tva; $propal_static->total_tva = $objp->total_tva;
$propal_static->total_ttc = $objp->total_ttc; $propal_static->total_ttc = $objp->total_ttc;
print $propal_static->getNomUrl(1); print $propal_static->getNomUrl(1);
if (($db->jdate($objp->date_limit) < ($now - $conf->propal->cloture->warning_delay)) && $objp->fk_statut == $propal_static::STATUS_VALIDATED) { if (($db->jdate($objp->date_limit) < ($now - $conf->propal->cloture->warning_delay)) && $objp->fk_statut == $propal_static::STATUS_VALIDATED) {
print " ".img_warning(); print " ".img_warning();
} }
print '</td><td class="right" width="80px">'.dol_print_date($db->jdate($objp->dp), 'day')."</td>\n"; print '</td><td class="right" width="80px">'.dol_print_date($db->jdate($objp->dp), 'day')."</td>\n";
print '<td class="right" style="min-width: 60px">'.price($objp->total_ht).'</td>'; print '<td class="right" style="min-width: 60px">'.price($objp->total_ht).'</td>';
print '<td class="right" style="min-width: 60px" class="nowrap">'.$propal_static->LibStatut($objp->fk_statut, 5).'</td></tr>'; print '<td class="right" style="min-width: 60px" class="nowrap">'.$propal_static->LibStatut($objp->fk_statut, 5).'</td></tr>';
@ -737,12 +737,12 @@ if ($object->id > 0)
*/ */
if (!empty($conf->commande->enabled) && $user->rights->commande->lire) if (!empty($conf->commande->enabled) && $user->rights->commande->lire)
{ {
$sql = "SELECT s.nom, s.rowid"; $sql = "SELECT s.nom, s.rowid";
$sql .= ", c.rowid as cid, c.total_ht"; $sql .= ", c.rowid as cid, c.total_ht";
$sql .= ", c.tva as total_tva"; $sql .= ", c.tva as total_tva";
$sql .= ", c.total_ttc"; $sql .= ", c.total_ttc";
$sql .= ", c.ref, c.ref_client, c.fk_statut, c.facture"; $sql .= ", c.ref, c.ref_client, c.fk_statut, c.facture";
$sql .= ", c.date_commande as dc"; $sql .= ", c.date_commande as dc";
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."commande as c"; $sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."commande as c";
$sql .= " WHERE c.fk_soc = s.rowid "; $sql .= " WHERE c.fk_soc = s.rowid ";
$sql .= " AND s.rowid = ".$object->id; $sql .= " AND s.rowid = ".$object->id;
@ -795,8 +795,8 @@ if ($object->id > 0)
$commande_static->billed = $objp->billed; $commande_static->billed = $objp->billed;
print '<tr class="oddeven">'; print '<tr class="oddeven">';
print '<td class="nowrap">'; print '<td class="nowrap">';
print $commande_static->getNomUrl(1); print $commande_static->getNomUrl(1);
print '</td><td class="right" width="80px">'.dol_print_date($db->jdate($objp->dc), 'day')."</td>\n"; print '</td><td class="right" width="80px">'.dol_print_date($db->jdate($objp->dc), 'day')."</td>\n";
print '<td class="right" style="min-width: 60px">'.price($objp->total_ht).'</td>'; print '<td class="right" style="min-width: 60px">'.price($objp->total_ht).'</td>';
print '<td class="right" style="min-width: 60px" class="nowrap">'.$commande_static->LibStatut($objp->fk_statut, $objp->facture, 5).'</td></tr>'; print '<td class="right" style="min-width: 60px" class="nowrap">'.$commande_static->LibStatut($objp->fk_statut, $objp->facture, 5).'</td></tr>';
@ -814,78 +814,78 @@ if ($object->id > 0)
} }
} }
/* /*
* Latest shipments * Latest shipments
*/ */
if (!empty($conf->expedition->enabled) && $user->rights->expedition->lire) if (!empty($conf->expedition->enabled) && $user->rights->expedition->lire)
{ {
$sql = 'SELECT e.rowid as id'; $sql = 'SELECT e.rowid as id';
$sql .= ', e.ref'; $sql .= ', e.ref';
$sql .= ', e.date_creation'; $sql .= ', e.date_creation';
$sql .= ', e.fk_statut as statut'; $sql .= ', e.fk_statut as statut';
$sql .= ', s.nom'; $sql .= ', s.nom';
$sql .= ', s.rowid as socid'; $sql .= ', s.rowid as socid';
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."expedition as e"; $sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."expedition as e";
$sql .= " WHERE e.fk_soc = s.rowid AND s.rowid = ".$object->id; $sql .= " WHERE e.fk_soc = s.rowid AND s.rowid = ".$object->id;
$sql .= " AND e.entity IN (".getEntity('expedition').")"; $sql .= " AND e.entity IN (".getEntity('expedition').")";
$sql .= ' GROUP BY e.rowid'; $sql .= ' GROUP BY e.rowid';
$sql .= ', e.ref'; $sql .= ', e.ref';
$sql .= ', e.date_creation'; $sql .= ', e.date_creation';
$sql .= ', e.fk_statut'; $sql .= ', e.fk_statut';
$sql .= ', s.nom'; $sql .= ', s.nom';
$sql .= ', s.rowid'; $sql .= ', s.rowid';
$sql .= " ORDER BY e.date_creation DESC"; $sql .= " ORDER BY e.date_creation DESC";
$resql = $db->query($sql); $resql = $db->query($sql);
if ($resql) if ($resql)
{ {
$sendingstatic = new Expedition($db); $sendingstatic = new Expedition($db);
$num = $db->num_rows($resql); $num = $db->num_rows($resql);
if ($num > 0) { if ($num > 0) {
print '<div class="div-table-responsive-no-min">'; print '<div class="div-table-responsive-no-min">';
print '<table class="noborder centpercent lastrecordtable">'; print '<table class="noborder centpercent lastrecordtable">';
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print '<td colspan="4"><table width="100%" class="nobordernopadding"><tr><td>'.$langs->trans("LastSendings", ($num <= $MAXLIST ? "" : $MAXLIST)).'</td><td class="right"><a class="notasortlink" href="'.DOL_URL_ROOT.'/expedition/list.php?socid='.$object->id.'">'.$langs->trans("AllSendings").'<span class="badge marginleftonlyshort">'.$num.'</span></a></td>'; print '<td colspan="4"><table width="100%" class="nobordernopadding"><tr><td>'.$langs->trans("LastSendings", ($num <= $MAXLIST ? "" : $MAXLIST)).'</td><td class="right"><a class="notasortlink" href="'.DOL_URL_ROOT.'/expedition/list.php?socid='.$object->id.'">'.$langs->trans("AllSendings").'<span class="badge marginleftonlyshort">'.$num.'</span></a></td>';
print '<td width="20px" class="right"><a href="'.DOL_URL_ROOT.'/expedition/stats/index.php?socid='.$object->id.'">'.img_picto($langs->trans("Statistics"), 'stats').'</a></td>'; print '<td width="20px" class="right"><a href="'.DOL_URL_ROOT.'/expedition/stats/index.php?socid='.$object->id.'">'.img_picto($langs->trans("Statistics"), 'stats').'</a></td>';
print '</tr></table></td>'; print '</tr></table></td>';
print '</tr>'; print '</tr>';
} }
$i = 0; $i = 0;
while ($i < $num && $i < $MAXLIST) while ($i < $num && $i < $MAXLIST)
{ {
$objp = $db->fetch_object($resql); $objp = $db->fetch_object($resql);
$sendingstatic->id = $objp->id; $sendingstatic->id = $objp->id;
$sendingstatic->ref = $objp->ref; $sendingstatic->ref = $objp->ref;
print '<tr class="oddeven">'; print '<tr class="oddeven">';
print '<td class="nowrap">'; print '<td class="nowrap">';
print $sendingstatic->getNomUrl(1); print $sendingstatic->getNomUrl(1);
print '</td>'; print '</td>';
if ($objp->date_creation > 0) { if ($objp->date_creation > 0) {
print '<td class="right" width="80px">'.dol_print_date($db->jdate($objp->date_creation), 'day').'</td>'; print '<td class="right" width="80px">'.dol_print_date($db->jdate($objp->date_creation), 'day').'</td>';
} else { } else {
print '<td class="right"><b>!!!</b></td>'; print '<td class="right"><b>!!!</b></td>';
} }
print '<td class="nowrap right" width="100" >'.$sendingstatic->LibStatut($objp->statut, 5).'</td>'; print '<td class="nowrap right" width="100" >'.$sendingstatic->LibStatut($objp->statut, 5).'</td>';
print "</tr>\n"; print "</tr>\n";
$i++; $i++;
} }
$db->free($resql); $db->free($resql);
if ($num > 0) if ($num > 0)
{ {
print "</table>"; print "</table>";
print '</div>'; print '</div>';
} }
} else { } else {
dol_print_error($db); dol_print_error($db);
} }
} }
/* /*
* Latest contracts * Latest contracts
@ -910,7 +910,7 @@ if ($object->id > 0)
print '<div class="div-table-responsive-no-min">'; print '<div class="div-table-responsive-no-min">';
print '<table class="noborder centpercent lastrecordtable">'; print '<table class="noborder centpercent lastrecordtable">';
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print '<td colspan="5"><table width="100%" class="nobordernopadding"><tr><td>'.$langs->trans("LastContracts", ($num <= $MAXLIST ? "" : $MAXLIST)).'</td>'; print '<td colspan="5"><table width="100%" class="nobordernopadding"><tr><td>'.$langs->trans("LastContracts", ($num <= $MAXLIST ? "" : $MAXLIST)).'</td>';
print '<td class="right"><a class="notasortlink" href="'.DOL_URL_ROOT.'/contrat/list.php?socid='.$object->id.'">'.$langs->trans("AllContracts").'<span class="badge marginleftonlyshort">'.$num.'</span></a></td>'; print '<td class="right"><a class="notasortlink" href="'.DOL_URL_ROOT.'/contrat/list.php?socid='.$object->id.'">'.$langs->trans("AllContracts").'<span class="badge marginleftonlyshort">'.$num.'</span></a></td>';
//print '<td width="20px" class="right"><a href="'.DOL_URL_ROOT.'/contract/stats/index.php?socid='.$object->id.'">'.img_picto($langs->trans("Statistics"),'stats').'</a></td>'; //print '<td width="20px" class="right"><a href="'.DOL_URL_ROOT.'/contract/stats/index.php?socid='.$object->id.'">'.img_picto($langs->trans("Statistics"),'stats').'</a></td>';
@ -987,7 +987,7 @@ if ($object->id > 0)
print '<div class="div-table-responsive-no-min">'; print '<div class="div-table-responsive-no-min">';
print '<table class="noborder centpercent lastrecordtable">'; print '<table class="noborder centpercent lastrecordtable">';
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print '<td colspan="3"><table width="100%" class="nobordernopadding"><tr><td>'.$langs->trans("LastInterventions", ($num <= $MAXLIST ? "" : $MAXLIST)).'</td><td class="right"><a class="notasortlink" href="'.DOL_URL_ROOT.'/fichinter/list.php?socid='.$object->id.'">'.$langs->trans("AllInterventions").'<span class="badge marginleftonlyshort">'.$num.'</span></td>'; print '<td colspan="3"><table width="100%" class="nobordernopadding"><tr><td>'.$langs->trans("LastInterventions", ($num <= $MAXLIST ? "" : $MAXLIST)).'</td><td class="right"><a class="notasortlink" href="'.DOL_URL_ROOT.'/fichinter/list.php?socid='.$object->id.'">'.$langs->trans("AllInterventions").'<span class="badge marginleftonlyshort">'.$num.'</span></td>';
print '<td width="20px" class="right"><a href="'.DOL_URL_ROOT.'/fichinter/stats/index.php?socid='.$object->id.'">'.img_picto($langs->trans("Statistics"), 'stats').'</a></td>'; print '<td width="20px" class="right"><a href="'.DOL_URL_ROOT.'/fichinter/stats/index.php?socid='.$object->id.'">'.img_picto($langs->trans("Statistics"), 'stats').'</a></td>';
print '</tr></table></td>'; print '</tr></table></td>';
@ -1000,11 +1000,11 @@ if ($object->id > 0)
$objp = $db->fetch_object($resql); $objp = $db->fetch_object($resql);
$fichinter_static->id = $objp->id; $fichinter_static->id = $objp->id;
$fichinter_static->statut = $objp->fk_statut; $fichinter_static->statut = $objp->fk_statut;
print '<tr class="oddeven">'; print '<tr class="oddeven">';
print '<td class="nowrap"><a href="'.DOL_URL_ROOT.'/fichinter/card.php?id='.$objp->id.'">'.img_object($langs->trans("ShowPropal"), "propal").' '.$objp->ref.'</a></td>'."\n"; print '<td class="nowrap"><a href="'.DOL_URL_ROOT.'/fichinter/card.php?id='.$objp->id.'">'.img_object($langs->trans("ShowPropal"), "propal").' '.$objp->ref.'</a></td>'."\n";
//print '<td class="right" width="80px">'.dol_print_date($db->jdate($objp->startdate)).'</td>'."\n"; //print '<td class="right" width="80px">'.dol_print_date($db->jdate($objp->startdate)).'</td>'."\n";
print '<td class="right" style="min-width: 60px">'.convertSecondToTime($objp->duration).'</td>'."\n"; print '<td class="right" style="min-width: 60px">'.convertSecondToTime($objp->duration).'</td>'."\n";
print '<td class="nowrap right" style="min-width: 60px">'.$fichinter_static->getLibStatut(5).'</td>'."\n"; print '<td class="nowrap right" style="min-width: 60px">'.$fichinter_static->getLibStatut(5).'</td>'."\n";
print '</tr>'; print '</tr>';
@ -1130,10 +1130,10 @@ if ($object->id > 0)
*/ */
if (!empty($conf->facture->enabled) && $user->rights->facture->lire) if (!empty($conf->facture->enabled) && $user->rights->facture->lire)
{ {
$sql = 'SELECT f.rowid as facid, f.ref, f.type'; $sql = 'SELECT f.rowid as facid, f.ref, f.type';
$sql .= ', f.total as total_ht'; $sql .= ', f.total as total_ht';
$sql .= ', f.tva as total_tva'; $sql .= ', f.tva as total_tva';
$sql .= ', f.total_ttc'; $sql .= ', f.total_ttc';
$sql .= ', f.datef as df, f.datec as dc, f.paye as paye, f.fk_statut as statut'; $sql .= ', f.datef as df, f.datec as dc, f.paye as paye, f.fk_statut as statut';
$sql .= ', s.nom, s.rowid as socid'; $sql .= ', s.nom, s.rowid as socid';
$sql .= ', SUM(pf.amount) as am'; $sql .= ', SUM(pf.amount) as am';
@ -1159,7 +1159,7 @@ if ($object->id > 0)
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print '<td colspan="5"><table width="100%" class="nobordernopadding"><tr><td>'.$langs->trans("LastCustomersBills", ($num <= $MAXLIST ? "" : $MAXLIST)).'</td><td class="right"><a class="notasortlink" href="'.DOL_URL_ROOT.'/compta/facture/list.php?socid='.$object->id.'">'.$langs->trans("AllBills").'<span class="badge marginleftonlyshort">'.$num.'</span></a></td>'; print '<td colspan="5"><table width="100%" class="nobordernopadding"><tr><td>'.$langs->trans("LastCustomersBills", ($num <= $MAXLIST ? "" : $MAXLIST)).'</td><td class="right"><a class="notasortlink" href="'.DOL_URL_ROOT.'/compta/facture/list.php?socid='.$object->id.'">'.$langs->trans("AllBills").'<span class="badge marginleftonlyshort">'.$num.'</span></a></td>';
print '<td width="20px" class="right"><a href="'.DOL_URL_ROOT.'/compta/facture/stats/index.php?socid='.$object->id.'">'.img_picto($langs->trans("Statistics"), 'stats').'</a></td>'; print '<td width="20px" class="right"><a href="'.DOL_URL_ROOT.'/compta/facture/stats/index.php?socid='.$object->id.'">'.img_picto($langs->trans("Statistics"), 'stats').'</a></td>';
print '</tr></table></td>'; print '</tr></table></td>';
print '</tr>'; print '</tr>';
} }
@ -1192,9 +1192,9 @@ if ($object->id > 0)
if (!empty($conf->global->MAIN_SHOW_PRICE_WITH_TAX_IN_SUMMARIES)) if (!empty($conf->global->MAIN_SHOW_PRICE_WITH_TAX_IN_SUMMARIES))
{ {
print '<td class="right" style="min-width: 60px">'; print '<td class="right" style="min-width: 60px">';
print price($objp->total_ttc); print price($objp->total_ttc);
print '</td>'; print '</td>';
} }
print '<td class="nowrap right" style="min-width: 60px">'.($facturestatic->LibStatut($objp->paye, $objp->statut, 5, $objp->am)).'</td>'; print '<td class="nowrap right" style="min-width: 60px">'.($facturestatic->LibStatut($objp->paye, $objp->statut, 5, $objp->am)).'</td>';
@ -1228,79 +1228,79 @@ if ($object->id > 0)
$parameters = array(); $parameters = array();
$reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been
if (empty($reshook)) if (empty($reshook))
{ {
if ($object->status != 1) if ($object->status != 1)
{ {
print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" title="'.dol_escape_js($langs->trans("ThirdPartyIsClosed")).'" href="#">'.$langs->trans("ThirdPartyIsClosed").'</a></div>'; print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" title="'.dol_escape_js($langs->trans("ThirdPartyIsClosed")).'" href="#">'.$langs->trans("ThirdPartyIsClosed").'</a></div>';
} }
if (!empty($conf->propal->enabled) && $user->rights->propal->creer && $object->status == 1) if (!empty($conf->propal->enabled) && $user->rights->propal->creer && $object->status == 1)
{ {
$langs->load("propal"); $langs->load("propal");
print '<div class="inline-block divButAction"><a class="butAction" href="'.DOL_URL_ROOT.'/comm/propal/card.php?socid='.$object->id.'&amp;action=create">'.$langs->trans("AddProp").'</a></div>'; print '<div class="inline-block divButAction"><a class="butAction" href="'.DOL_URL_ROOT.'/comm/propal/card.php?socid='.$object->id.'&amp;action=create">'.$langs->trans("AddProp").'</a></div>';
} }
if (!empty($conf->commande->enabled) && $user->rights->commande->creer && $object->status == 1) if (!empty($conf->commande->enabled) && $user->rights->commande->creer && $object->status == 1)
{ {
$langs->load("orders"); $langs->load("orders");
print '<div class="inline-block divButAction"><a class="butAction" href="'.DOL_URL_ROOT.'/commande/card.php?socid='.$object->id.'&amp;action=create">'.$langs->trans("AddOrder").'</a></div>'; print '<div class="inline-block divButAction"><a class="butAction" href="'.DOL_URL_ROOT.'/commande/card.php?socid='.$object->id.'&amp;action=create">'.$langs->trans("AddOrder").'</a></div>';
} }
if ($user->rights->contrat->creer && $object->status == 1) if ($user->rights->contrat->creer && $object->status == 1)
{ {
$langs->load("contracts"); $langs->load("contracts");
print '<div class="inline-block divButAction"><a class="butAction" href="'.DOL_URL_ROOT.'/contrat/card.php?socid='.$object->id.'&amp;action=create">'.$langs->trans("AddContract").'</a></div>'; print '<div class="inline-block divButAction"><a class="butAction" href="'.DOL_URL_ROOT.'/contrat/card.php?socid='.$object->id.'&amp;action=create">'.$langs->trans("AddContract").'</a></div>';
} }
if (!empty($conf->ficheinter->enabled) && $user->rights->ficheinter->creer && $object->status == 1) if (!empty($conf->ficheinter->enabled) && $user->rights->ficheinter->creer && $object->status == 1)
{ {
$langs->load("fichinter"); $langs->load("fichinter");
print '<div class="inline-block divButAction"><a class="butAction" href="'.DOL_URL_ROOT.'/fichinter/card.php?socid='.$object->id.'&amp;action=create">'.$langs->trans("AddIntervention").'</a></div>'; print '<div class="inline-block divButAction"><a class="butAction" href="'.DOL_URL_ROOT.'/fichinter/card.php?socid='.$object->id.'&amp;action=create">'.$langs->trans("AddIntervention").'</a></div>';
} }
// Add invoice // Add invoice
if ($user->socid == 0) if ($user->socid == 0)
{ {
if (!empty($conf->deplacement->enabled) && $object->status == 1) if (!empty($conf->deplacement->enabled) && $object->status == 1)
{ {
$langs->load("trips"); $langs->load("trips");
print '<div class="inline-block divButAction"><a class="butAction" href="'.DOL_URL_ROOT.'/compta/deplacement/card.php?socid='.$object->id.'&amp;action=create">'.$langs->trans("AddTrip").'</a></div>'; print '<div class="inline-block divButAction"><a class="butAction" href="'.DOL_URL_ROOT.'/compta/deplacement/card.php?socid='.$object->id.'&amp;action=create">'.$langs->trans("AddTrip").'</a></div>';
} }
if (!empty($conf->facture->enabled) && $object->status == 1) if (!empty($conf->facture->enabled) && $object->status == 1)
{ {
if (empty($user->rights->facture->creer)) if (empty($user->rights->facture->creer))
{ {
print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" title="'.dol_escape_js($langs->trans("NotAllowed")).'" href="#">'.$langs->trans("AddBill").'</a></div>'; print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" title="'.dol_escape_js($langs->trans("NotAllowed")).'" href="#">'.$langs->trans("AddBill").'</a></div>';
} else { } else {
$langs->loadLangs(array("orders", "bills")); $langs->loadLangs(array("orders", "bills"));
if (!empty($conf->commande->enabled)) if (!empty($conf->commande->enabled))
{ {
if ($object->client != 0 && $object->client != 2) { if ($object->client != 0 && $object->client != 2) {
if (!empty($orders2invoice) && $orders2invoice > 0) print '<div class="inline-block divButAction"><a class="butAction" href="'.DOL_URL_ROOT.'/commande/list.php?socid='.$object->id.'&search_billed=0&autoselectall=1">'.$langs->trans("CreateInvoiceForThisCustomer").'</a></div>'; if (!empty($orders2invoice) && $orders2invoice > 0) print '<div class="inline-block divButAction"><a class="butAction" href="'.DOL_URL_ROOT.'/commande/list.php?socid='.$object->id.'&search_billed=0&autoselectall=1">'.$langs->trans("CreateInvoiceForThisCustomer").'</a></div>';
else print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" title="'.dol_escape_js($langs->trans("NoOrdersToInvoice")).'" href="#">'.$langs->trans("CreateInvoiceForThisCustomer").'</a></div>'; else print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" title="'.dol_escape_js($langs->trans("NoOrdersToInvoice")).'" href="#">'.$langs->trans("CreateInvoiceForThisCustomer").'</a></div>';
} else print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" title="'.dol_escape_js($langs->trans("ThirdPartyMustBeEditAsCustomer")).'" href="#">'.$langs->trans("AddBill").'</a></div>'; } else print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" title="'.dol_escape_js($langs->trans("ThirdPartyMustBeEditAsCustomer")).'" href="#">'.$langs->trans("AddBill").'</a></div>';
} }
if ($object->client != 0 && $object->client != 2) print '<div class="inline-block divButAction"><a class="butAction" href="'.DOL_URL_ROOT.'/compta/facture/card.php?action=create&socid='.$object->id.'">'.$langs->trans("AddBill").'</a></div>'; if ($object->client != 0 && $object->client != 2) print '<div class="inline-block divButAction"><a class="butAction" href="'.DOL_URL_ROOT.'/compta/facture/card.php?action=create&socid='.$object->id.'">'.$langs->trans("AddBill").'</a></div>';
else print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" title="'.dol_escape_js($langs->trans("ThirdPartyMustBeEditAsCustomer")).'" href="#">'.$langs->trans("AddBill").'</a></div>'; else print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" title="'.dol_escape_js($langs->trans("ThirdPartyMustBeEditAsCustomer")).'" href="#">'.$langs->trans("AddBill").'</a></div>';
} }
} }
} }
// Add action // Add action
if (!empty($conf->agenda->enabled) && !empty($conf->global->MAIN_REPEATTASKONEACHTAB) && $object->status == 1) if (!empty($conf->agenda->enabled) && !empty($conf->global->MAIN_REPEATTASKONEACHTAB) && $object->status == 1)
{ {
if ($user->rights->agenda->myactions->create) 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&socid='.$object->id.'">'.$langs->trans("AddAction").'</a></div>'; print '<div class="inline-block divButAction"><a class="butAction" href="'.DOL_URL_ROOT.'/comm/action/card.php?action=create&socid='.$object->id.'">'.$langs->trans("AddAction").'</a></div>';
} else { } else {
print '<div class="inline-block divButAction"><a class="butAction" title="'.dol_escape_js($langs->trans("NotAllowed")).'" href="#">'.$langs->trans("AddAction").'</a></div>'; print '<div class="inline-block divButAction"><a class="butAction" title="'.dol_escape_js($langs->trans("NotAllowed")).'" href="#">'.$langs->trans("AddAction").'</a></div>';
} }
} }
} }
print '</div>'; print '</div>';
@ -1310,14 +1310,14 @@ if ($object->id > 0)
show_contacts($conf, $langs, $db, $object, $_SERVER["PHP_SELF"].'?socid='.$object->id); show_contacts($conf, $langs, $db, $object, $_SERVER["PHP_SELF"].'?socid='.$object->id);
} }
if (!empty($conf->global->MAIN_REPEATTASKONEACHTAB)) if (!empty($conf->global->MAIN_REPEATTASKONEACHTAB))
{ {
print load_fiche_titre($langs->trans("ActionsOnCompany"), '', ''); print load_fiche_titre($langs->trans("ActionsOnCompany"), '', '');
// List of todo actions // List of todo actions
show_actions_todo($conf, $langs, $db, $object); show_actions_todo($conf, $langs, $db, $object);
// List of done actions // List of done actions
show_actions_done($conf, $langs, $db, $object); show_actions_done($conf, $langs, $db, $object);
} }
} else { } else {

View File

@ -30,7 +30,7 @@ require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php';
*/ */
class Proposals extends DolibarrApi class Proposals extends DolibarrApi
{ {
/** /**
* @var array $FIELDS Mandatory fields, checked when create and update object * @var array $FIELDS Mandatory fields, checked when create and update object
*/ */
static $FIELDS = array( static $FIELDS = array(
@ -65,60 +65,60 @@ class Proposals extends DolibarrApi
*/ */
public function get($id, $contact_list = 1) public function get($id, $contact_list = 1)
{ {
return $this->_fetch($id, '', '', $contact_list); return $this->_fetch($id, '', '', $contact_list);
} }
/** /**
* Get properties of an proposal object by ref * Get properties of an proposal object by ref
* *
* Return an array with proposal informations * Return an array with proposal informations
* *
* @param string $ref Ref of object * @param string $ref Ref of object
* @param int $contact_list 0: Returned array of contacts/addresses contains all properties, 1: Return array contains just id * @param int $contact_list 0: Returned array of contacts/addresses contains all properties, 1: Return array contains just id
* @return array|mixed data without useless information * @return array|mixed data without useless information
* *
* @url GET ref/{ref} * @url GET ref/{ref}
* *
* @throws RestException * @throws RestException
*/ */
public function getByRef($ref, $contact_list = 1) public function getByRef($ref, $contact_list = 1)
{ {
return $this->_fetch('', $ref, '', $contact_list); return $this->_fetch('', $ref, '', $contact_list);
} }
/** /**
* Get properties of an proposal object by ref_ext * Get properties of an proposal object by ref_ext
* *
* Return an array with proposal informations * Return an array with proposal informations
* *
* @param string $ref_ext External reference of object * @param string $ref_ext External reference of object
* @param int $contact_list 0: Returned array of contacts/addresses contains all properties, 1: Return array contains just id * @param int $contact_list 0: Returned array of contacts/addresses contains all properties, 1: Return array contains just id
* @return array|mixed data without useless information * @return array|mixed data without useless information
* *
* @url GET ref_ext/{ref_ext} * @url GET ref_ext/{ref_ext}
* *
* @throws RestException * @throws RestException
*/ */
public function getByRefExt($ref_ext, $contact_list = 1) public function getByRefExt($ref_ext, $contact_list = 1)
{ {
return $this->_fetch('', '', $ref_ext, $contact_list); return $this->_fetch('', '', $ref_ext, $contact_list);
} }
/** /**
* Get properties of an proposal object * Get properties of an proposal object
* *
* Return an array with proposal informations * Return an array with proposal informations
* *
* @param int $id ID of order * @param int $id ID of order
* @param string $ref Ref of object * @param string $ref Ref of object
* @param string $ref_ext External reference of object * @param string $ref_ext External reference of object
* @param int $contact_list 0: Returned array of contacts/addresses contains all properties, 1: Return array contains just id * @param int $contact_list 0: Returned array of contacts/addresses contains all properties, 1: Return array contains just id
* @return array|mixed data without useless information * @return array|mixed data without useless information
* *
* @throws RestException * @throws RestException
*/ */
private function _fetch($id, $ref = '', $ref_ext = '', $contact_list = 1) private function _fetch($id, $ref = '', $ref_ext = '', $contact_list = 1)
{ {
if (!DolibarrApiAccess::$user->rights->propal->lire) { if (!DolibarrApiAccess::$user->rights->propal->lire) {
throw new RestException(401); throw new RestException(401);
} }
@ -151,8 +151,8 @@ class Proposals extends DolibarrApi
* @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.ref:like:'SO-%') and (t.datec:<:'20160101')" * @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.ref:like:'SO-%') and (t.datec:<:'20160101')"
* @return array Array of order objects * @return array Array of order objects
*/ */
public function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $thirdparty_ids = '', $sqlfilters = '') public function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $thirdparty_ids = '', $sqlfilters = '')
{ {
global $db, $conf; global $db, $conf;
$obj_ret = array(); $obj_ret = array();
@ -201,8 +201,8 @@ class Proposals extends DolibarrApi
$sql .= $this->db->plimit($limit + 1, $offset); $sql .= $this->db->plimit($limit + 1, $offset);
} }
dol_syslog("API Rest request"); dol_syslog("API Rest request");
$result = $this->db->query($sql); $result = $this->db->query($sql);
if ($result) if ($result)
{ {
@ -235,13 +235,13 @@ class Proposals extends DolibarrApi
* @param array $request_data Request data * @param array $request_data Request data
* @return int ID of proposal * @return int ID of proposal
*/ */
public function post($request_data = null) public function post($request_data = null)
{ {
if (!DolibarrApiAccess::$user->rights->propal->creer) { if (!DolibarrApiAccess::$user->rights->propal->creer) {
throw new RestException(401, "Insuffisant rights"); throw new RestException(401, "Insuffisant rights");
} }
// Check mandatory fields // Check mandatory fields
$result = $this->_validate($request_data); $result = $this->_validate($request_data);
foreach ($request_data as $field => $value) { foreach ($request_data as $field => $value) {
$this->propal->$field = $value; $this->propal->$field = $value;
@ -258,7 +258,7 @@ class Proposals extends DolibarrApi
} }
return $this->propal->id; return $this->propal->id;
} }
/** /**
* Get lines of a commercial proposal * Get lines of a commercial proposal
@ -269,26 +269,26 @@ class Proposals extends DolibarrApi
* *
* @return int * @return int
*/ */
public function getLines($id) public function getLines($id)
{ {
if (!DolibarrApiAccess::$user->rights->propal->lire) { if (!DolibarrApiAccess::$user->rights->propal->lire) {
throw new RestException(401); throw new RestException(401);
} }
$result = $this->propal->fetch($id); $result = $this->propal->fetch($id);
if (!$result) { if (!$result) {
throw new RestException(404, 'Commercial Proposal not found'); throw new RestException(404, 'Commercial Proposal not found');
} }
if (!DolibarrApi::_checkAccessToResource('propal', $this->propal->id)) { if (!DolibarrApi::_checkAccessToResource('propal', $this->propal->id)) {
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
} }
$this->propal->getLinesArray(); $this->propal->getLinesArray();
$result = array(); $result = array();
foreach ($this->propal->lines as $line) { foreach ($this->propal->lines as $line) {
array_push($result, $this->_cleanObjectDatas($line)); array_push($result, $this->_cleanObjectDatas($line));
} }
return $result; return $result;
} }
/** /**
@ -309,50 +309,50 @@ class Proposals extends DolibarrApi
$result = $this->propal->fetch($id); $result = $this->propal->fetch($id);
if (!$result) { if (!$result) {
throw new RestException(404, 'Commercial Proposal not found'); throw new RestException(404, 'Commercial Proposal not found');
} }
if (!DolibarrApi::_checkAccessToResource('propal', $this->propal->id)) { if (!DolibarrApi::_checkAccessToResource('propal', $this->propal->id)) {
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
} }
$request_data = (object) $request_data; $request_data = (object) $request_data;
$updateRes = $this->propal->addline( $updateRes = $this->propal->addline(
$request_data->desc, $request_data->desc,
$request_data->subprice, $request_data->subprice,
$request_data->qty, $request_data->qty,
$request_data->tva_tx, $request_data->tva_tx,
$request_data->localtax1_tx, $request_data->localtax1_tx,
$request_data->localtax2_tx, $request_data->localtax2_tx,
$request_data->fk_product, $request_data->fk_product,
$request_data->remise_percent, $request_data->remise_percent,
'HT', 'HT',
0, 0,
$request_data->info_bits, $request_data->info_bits,
$request_data->product_type, $request_data->product_type,
$request_data->rang, $request_data->rang,
$request_data->special_code, $request_data->special_code,
$request_data->fk_parent_line, $request_data->fk_parent_line,
$request_data->fk_fournprice, $request_data->fk_fournprice,
$request_data->pa_ht, $request_data->pa_ht,
$request_data->label, $request_data->label,
$request_data->date_start, $request_data->date_start,
$request_data->date_end, $request_data->date_end,
$request_data->array_options, $request_data->array_options,
$request_data->fk_unit, $request_data->fk_unit,
$request_data->origin, $request_data->origin,
$request_data->origin_id, $request_data->origin_id,
$request_data->multicurrency_subprice, $request_data->multicurrency_subprice,
$request_data->fk_remise_except $request_data->fk_remise_except
); );
if ($updateRes > 0) { if ($updateRes > 0) {
return $updateRes; return $updateRes;
} else { } else {
throw new RestException(400, $this->propal->error); throw new RestException(400, $this->propal->error);
} }
} }
/** /**
* Update a line of given commercial proposal * Update a line of given commercial proposal
@ -388,37 +388,37 @@ class Proposals extends DolibarrApi
throw new RestException(404, 'Proposal line not found'); throw new RestException(404, 'Proposal line not found');
} }
$updateRes = $this->propal->updateline( $updateRes = $this->propal->updateline(
$lineid, $lineid,
isset($request_data->subprice) ? $request_data->subprice : $propalline->subprice, isset($request_data->subprice) ? $request_data->subprice : $propalline->subprice,
isset($request_data->qty) ? $request_data->qty : $propalline->qty, isset($request_data->qty) ? $request_data->qty : $propalline->qty,
isset($request_data->remise_percent) ? $request_data->remise_percent : $propalline->remise_percent, isset($request_data->remise_percent) ? $request_data->remise_percent : $propalline->remise_percent,
isset($request_data->tva_tx) ? $request_data->tva_tx : $propalline->tva_tx, isset($request_data->tva_tx) ? $request_data->tva_tx : $propalline->tva_tx,
isset($request_data->localtax1_tx) ? $request_data->localtax1_tx : $propalline->localtax1_tx, isset($request_data->localtax1_tx) ? $request_data->localtax1_tx : $propalline->localtax1_tx,
isset($request_data->localtax2_tx) ? $request_data->localtax2_tx : $propalline->localtax2_tx, isset($request_data->localtax2_tx) ? $request_data->localtax2_tx : $propalline->localtax2_tx,
isset($request_data->desc) ? $request_data->desc : $propalline->desc, isset($request_data->desc) ? $request_data->desc : $propalline->desc,
'HT', 'HT',
isset($request_data->info_bits) ? $request_data->info_bits : $propalline->info_bits, isset($request_data->info_bits) ? $request_data->info_bits : $propalline->info_bits,
isset($request_data->special_code) ? $request_data->special_code : $propalline->special_code, isset($request_data->special_code) ? $request_data->special_code : $propalline->special_code,
isset($request_data->fk_parent_line) ? $request_data->fk_parent_line : $propalline->fk_parent_line, isset($request_data->fk_parent_line) ? $request_data->fk_parent_line : $propalline->fk_parent_line,
0, 0,
isset($request_data->fk_fournprice) ? $request_data->fk_fournprice : $propalline->fk_fournprice, isset($request_data->fk_fournprice) ? $request_data->fk_fournprice : $propalline->fk_fournprice,
isset($request_data->pa_ht) ? $request_data->pa_ht : $propalline->pa_ht, isset($request_data->pa_ht) ? $request_data->pa_ht : $propalline->pa_ht,
isset($request_data->label) ? $request_data->label : $propalline->label, isset($request_data->label) ? $request_data->label : $propalline->label,
isset($request_data->product_type) ? $request_data->product_type : $propalline->product_type, isset($request_data->product_type) ? $request_data->product_type : $propalline->product_type,
isset($request_data->date_start) ? $request_data->date_start : $propalline->date_start, isset($request_data->date_start) ? $request_data->date_start : $propalline->date_start,
isset($request_data->date_end) ? $request_data->date_end : $propalline->date_end, isset($request_data->date_end) ? $request_data->date_end : $propalline->date_end,
isset($request_data->array_options) ? $request_data->array_options : $propalline->array_options, isset($request_data->array_options) ? $request_data->array_options : $propalline->array_options,
isset($request_data->fk_unit) ? $request_data->fk_unit : $propalline->fk_unit, isset($request_data->fk_unit) ? $request_data->fk_unit : $propalline->fk_unit,
isset($request_data->multicurrency_subprice) ? $request_data->multicurrency_subprice : $propalline->subprice isset($request_data->multicurrency_subprice) ? $request_data->multicurrency_subprice : $propalline->subprice
); );
if ($updateRes > 0) { if ($updateRes > 0) {
$result = $this->get($id); $result = $this->get($id);
unset($result->line); unset($result->line);
return $this->_cleanObjectDatas($result); return $this->_cleanObjectDatas($result);
} }
return false; return false;
} }
/** /**
@ -432,13 +432,13 @@ class Proposals extends DolibarrApi
* *
* @return int * @return int
* *
* @throws RestException 401 * @throws RestException 401
* @throws RestException 404 * @throws RestException 404
*/ */
public function deleteLine($id, $lineid) public function deleteLine($id, $lineid)
{ {
if (!DolibarrApiAccess::$user->rights->propal->creer) { if (!DolibarrApiAccess::$user->rights->propal->creer) {
throw new RestException(401); throw new RestException(401);
} }
$result = $this->propal->fetch($id); $result = $this->propal->fetch($id);
@ -460,7 +460,7 @@ class Proposals extends DolibarrApi
} }
} }
/** /**
* Add a contact type of given commercial proposal * Add a contact type of given commercial proposal
* *
* @param int $id Id of commercial proposal to update * @param int $id Id of commercial proposal to update
@ -471,66 +471,66 @@ class Proposals extends DolibarrApi
* *
* @return int * @return int
* *
* @throws RestException 401 * @throws RestException 401
* @throws RestException 404 * @throws RestException 404
*/ */
public function postContact($id, $contactid, $type) public function postContact($id, $contactid, $type)
{ {
if (!DolibarrApiAccess::$user->rights->propal->creer) { if (!DolibarrApiAccess::$user->rights->propal->creer) {
throw new RestException(401); throw new RestException(401);
} }
$result = $this->propal->fetch($id); $result = $this->propal->fetch($id);
if (!$result) { if (!$result) {
throw new RestException(404, 'Proposal not found'); throw new RestException(404, 'Proposal not found');
} }
if (!in_array($type, array('BILLING', 'SHIPPING', 'CUSTOMER'), true)) { if (!in_array($type, array('BILLING', 'SHIPPING', 'CUSTOMER'), true)) {
throw new RestException(500, 'Availables types: BILLING, SHIPPING OR CUSTOMER'); throw new RestException(500, 'Availables types: BILLING, SHIPPING OR CUSTOMER');
} }
if (!DolibarrApi::_checkAccessToResource('propal', $this->propal->id)) { if (!DolibarrApi::_checkAccessToResource('propal', $this->propal->id)) {
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
} }
$result = $this->propal->add_contact($contactid, $type, 'external'); $result = $this->propal->add_contact($contactid, $type, 'external');
if (!$result) { if (!$result) {
throw new RestException(500, 'Error when added the contact'); throw new RestException(500, 'Error when added the contact');
} }
return $this->propal; return $this->propal;
} }
/** /**
* Delete a contact type of given commercial proposal * Delete a contact type of given commercial proposal
* *
* @param int $id Id of commercial proposal to update * @param int $id Id of commercial proposal to update
* @param int $contactid Row key of the contact in the array contact_ids. * @param int $contactid Row key of the contact in the array contact_ids.
* @param string $type Type of the contact (BILLING, SHIPPING, CUSTOMER). * @param string $type Type of the contact (BILLING, SHIPPING, CUSTOMER).
* *
* @url DELETE {id}/contact/{contactid}/{type} * @url DELETE {id}/contact/{contactid}/{type}
* *
* @return int * @return int
* *
* @throws RestException 401 * @throws RestException 401
* @throws RestException 404 * @throws RestException 404
* @throws RestException 500 * @throws RestException 500
*/ */
public function deleteContact($id, $contactid, $type) public function deleteContact($id, $contactid, $type)
{ {
if (!DolibarrApiAccess::$user->rights->propal->creer) { if (!DolibarrApiAccess::$user->rights->propal->creer) {
throw new RestException(401); throw new RestException(401);
} }
$result = $this->propal->fetch($id); $result = $this->propal->fetch($id);
if (!$result) { if (!$result) {
throw new RestException(404, 'Proposal not found'); throw new RestException(404, 'Proposal not found');
} }
if (!DolibarrApi::_checkAccessToResource('propal', $this->propal->id)) { if (!DolibarrApi::_checkAccessToResource('propal', $this->propal->id)) {
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
} }
@ -547,7 +547,7 @@ class Proposals extends DolibarrApi
} }
return $this->_cleanObjectDatas($this->propal); return $this->_cleanObjectDatas($this->propal);
} }
/** /**
* Update commercial proposal general fields (won't touch lines of commercial proposal) * Update commercial proposal general fields (won't touch lines of commercial proposal)
@ -556,12 +556,12 @@ class Proposals extends DolibarrApi
* @param array $request_data Datas * @param array $request_data Datas
* *
* @return int * @return int
*/ */
public function put($id, $request_data = null) public function put($id, $request_data = null)
{ {
if (!DolibarrApiAccess::$user->rights->propal->creer) { if (!DolibarrApiAccess::$user->rights->propal->creer) {
throw new RestException(401); throw new RestException(401);
} }
$result = $this->propal->fetch($id); $result = $this->propal->fetch($id);
if (!$result) { if (!$result) {
@ -631,14 +631,14 @@ class Proposals extends DolibarrApi
} }
/** /**
* Set a proposal to draft * Set a proposal to draft
* *
* @param int $id Order ID * @param int $id Order ID
* *
* @url POST {id}/settodraft * @url POST {id}/settodraft
* *
* @return array * @return array
*/ */
public function settodraft($id) public function settodraft($id)
{ {
if (!DolibarrApiAccess::$user->rights->propal->creer) { if (!DolibarrApiAccess::$user->rights->propal->creer) {
@ -690,14 +690,14 @@ class Proposals extends DolibarrApi
* @url POST {id}/validate * @url POST {id}/validate
* *
* @throws RestException 304 * @throws RestException 304
* @throws RestException 401 * @throws RestException 401
* @throws RestException 404 * @throws RestException 404
* @throws RestException 500 * @throws RestException 500
* *
* @return array * @return array
*/ */
public function validate($id, $notrigger = 0) public function validate($id, $notrigger = 0)
{ {
if (!DolibarrApiAccess::$user->rights->propal->creer) { if (!DolibarrApiAccess::$user->rights->propal->creer) {
throw new RestException(401); throw new RestException(401);
} }
@ -718,19 +718,19 @@ class Proposals extends DolibarrApi
throw new RestException(500, 'Error when validating Commercial Proposal: '.$this->propal->error); throw new RestException(500, 'Error when validating Commercial Proposal: '.$this->propal->error);
} }
$result = $this->propal->fetch($id); $result = $this->propal->fetch($id);
if (!$result) { if (!$result) {
throw new RestException(404, 'Commercial Proposal not found'); throw new RestException(404, 'Commercial Proposal not found');
} }
if (!DolibarrApi::_checkAccessToResource('propal', $this->propal->id)) { if (!DolibarrApi::_checkAccessToResource('propal', $this->propal->id)) {
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
} }
$this->propal->fetchObjectLinked(); $this->propal->fetchObjectLinked();
return $this->_cleanObjectDatas($this->propal); return $this->_cleanObjectDatas($this->propal);
} }
/** /**
* Close (Accept or refuse) a quote / commercial proposal * Close (Accept or refuse) a quote / commercial proposal
@ -780,47 +780,47 @@ class Proposals extends DolibarrApi
return $this->_cleanObjectDatas($this->propal); return $this->_cleanObjectDatas($this->propal);
} }
/** /**
* Set a commercial proposal billed. Could be also called setbilled * Set a commercial proposal billed. Could be also called setbilled
* *
* @param int $id Commercial proposal ID * @param int $id Commercial proposal ID
* *
* @url POST {id}/setinvoiced * @url POST {id}/setinvoiced
* *
* @return array * @return array
*/ */
public function setinvoiced($id) public function setinvoiced($id)
{ {
if (!DolibarrApiAccess::$user->rights->propal->creer) { if (!DolibarrApiAccess::$user->rights->propal->creer) {
throw new RestException(401); throw new RestException(401);
} }
$result = $this->propal->fetch($id); $result = $this->propal->fetch($id);
if (!$result) { if (!$result) {
throw new RestException(404, 'Commercial Proposal not found'); throw new RestException(404, 'Commercial Proposal not found');
} }
if (!DolibarrApi::_checkAccessToResource('propal', $this->propal->id)) { if (!DolibarrApi::_checkAccessToResource('propal', $this->propal->id)) {
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
} }
$result = $this->propal->classifyBilled(DolibarrApiAccess::$user); $result = $this->propal->classifyBilled(DolibarrApiAccess::$user);
if ($result < 0) { if ($result < 0) {
throw new RestException(500, 'Error : '.$this->propal->error); throw new RestException(500, 'Error : '.$this->propal->error);
} }
$result = $this->propal->fetch($id); $result = $this->propal->fetch($id);
if (!$result) { if (!$result) {
throw new RestException(404, 'Proposal not found'); throw new RestException(404, 'Proposal not found');
} }
if (!DolibarrApi::_checkAccessToResource('propal', $this->propal->id)) { if (!DolibarrApi::_checkAccessToResource('propal', $this->propal->id)) {
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
} }
$this->propal->fetchObjectLinked(); $this->propal->fetchObjectLinked();
return $this->_cleanObjectDatas($this->propal); return $this->_cleanObjectDatas($this->propal);
} }
/** /**
@ -842,25 +842,25 @@ class Proposals extends DolibarrApi
} }
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
/** /**
* Clean sensible object datas * Clean sensible object datas
* *
* @param object $object Object to clean * @param object $object Object to clean
* @return array Array of cleaned object properties * @return array Array of cleaned object properties
*/ */
protected function _cleanObjectDatas($object) protected function _cleanObjectDatas($object)
{ {
// phpcs:enable // phpcs:enable
$object = parent::_cleanObjectDatas($object); $object = parent::_cleanObjectDatas($object);
unset($object->note); unset($object->note);
unset($object->name); unset($object->name);
unset($object->lastname); unset($object->lastname);
unset($object->firstname); unset($object->firstname);
unset($object->civility_id); unset($object->civility_id);
unset($object->address); unset($object->address);
return $object; return $object;
} }
} }

View File

@ -573,13 +573,13 @@ class Orders extends DolibarrApi
$contacts = $this->commande->liste_contact(); $contacts = $this->commande->liste_contact();
foreach ($contacts as $contact) { foreach ($contacts as $contact) {
if ($contact['id'] == $contactid && $contact['code'] == $type) { if ($contact['id'] == $contactid && $contact['code'] == $type) {
$result = $this->commande->delete_contact($contact['rowid']); $result = $this->commande->delete_contact($contact['rowid']);
if (!$result) { if (!$result) {
throw new RestException(500, 'Error when deleted the contact'); throw new RestException(500, 'Error when deleted the contact');
} }
} }
} }
return array( return array(

File diff suppressed because it is too large Load Diff

View File

@ -31,7 +31,7 @@ require_once DOL_DOCUMENT_ROOT.'/compta/deplacement/class/deplacement.class.php'
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
if (!empty($conf->projet->enabled)) if (!empty($conf->projet->enabled))
{ {
require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
} }
// Load translation files required by the page // Load translation files required by the page
@ -62,138 +62,138 @@ include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include,
if ($action == 'validate' && $user->rights->deplacement->creer) if ($action == 'validate' && $user->rights->deplacement->creer)
{ {
$object->fetch($id); $object->fetch($id);
if ($object->statut == Deplacement::STATUS_DRAFT) if ($object->statut == Deplacement::STATUS_DRAFT)
{ {
$result = $object->setStatut(1); $result = $object->setStatut(1);
if ($result > 0) if ($result > 0)
{ {
header("Location: ".$_SERVER["PHP_SELF"]."?id=".$id); header("Location: ".$_SERVER["PHP_SELF"]."?id=".$id);
exit; exit;
} else { } else {
setEventMessages($object->error, $object->errors, 'errors'); setEventMessages($object->error, $object->errors, 'errors');
} }
} }
} elseif ($action == 'classifyrefunded' && $user->rights->deplacement->creer) } elseif ($action == 'classifyrefunded' && $user->rights->deplacement->creer)
{ {
$object->fetch($id); $object->fetch($id);
if ($object->statut == Deplacement::STATUS_VALIDATED) if ($object->statut == Deplacement::STATUS_VALIDATED)
{ {
$result = $object->setStatut(Deplacement::STATUS_REFUNDED); $result = $object->setStatut(Deplacement::STATUS_REFUNDED);
if ($result > 0) if ($result > 0)
{ {
header("Location: ".$_SERVER["PHP_SELF"]."?id=".$id); header("Location: ".$_SERVER["PHP_SELF"]."?id=".$id);
exit; exit;
} else { } else {
setEventMessages($object->error, $object->errors, 'errors'); setEventMessages($object->error, $object->errors, 'errors');
} }
} }
} elseif ($action == 'confirm_delete' && $confirm == "yes" && $user->rights->deplacement->supprimer) } elseif ($action == 'confirm_delete' && $confirm == "yes" && $user->rights->deplacement->supprimer)
{ {
$result = $object->delete($id); $result = $object->delete($id);
if ($result >= 0) if ($result >= 0)
{ {
header("Location: index.php"); header("Location: index.php");
exit; exit;
} else { } else {
setEventMessages($object->error, $object->errors, 'errors'); setEventMessages($object->error, $object->errors, 'errors');
} }
} elseif ($action == 'add' && $user->rights->deplacement->creer) } elseif ($action == 'add' && $user->rights->deplacement->creer)
{ {
if (!GETPOST('cancel', 'alpha')) if (!GETPOST('cancel', 'alpha'))
{ {
$error = 0; $error = 0;
$object->date = dol_mktime(12, 0, 0, GETPOST('remonth', 'int'), GETPOST('reday', 'int'), GETPOST('reyear', 'int')); $object->date = dol_mktime(12, 0, 0, GETPOST('remonth', 'int'), GETPOST('reday', 'int'), GETPOST('reyear', 'int'));
$object->km = price2num(GETPOST('km', 'alpha'), 'MU'); // Not 'int', it may be a formated amount $object->km = price2num(GETPOST('km', 'alpha'), 'MU'); // Not 'int', it may be a formated amount
$object->type = GETPOST('type', 'alpha'); $object->type = GETPOST('type', 'alpha');
$object->socid = (int) GETPOST('socid', 'int'); $object->socid = (int) GETPOST('socid', 'int');
$object->fk_user = (int) GETPOST('fk_user', 'int'); $object->fk_user = (int) GETPOST('fk_user', 'int');
$object->note_private = GETPOST('note_private', 'alpha'); $object->note_private = GETPOST('note_private', 'alpha');
$object->note_public = GETPOST('note_public', 'alpha'); $object->note_public = GETPOST('note_public', 'alpha');
$object->statut = Deplacement::STATUS_DRAFT; $object->statut = Deplacement::STATUS_DRAFT;
if (!$object->date) if (!$object->date)
{ {
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Date")), null, 'errors'); setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Date")), null, 'errors');
$error++; $error++;
} }
if ($object->type == '-1') if ($object->type == '-1')
{ {
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Type")), null, 'errors'); setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Type")), null, 'errors');
$error++; $error++;
} }
if (!($object->fk_user > 0)) if (!($object->fk_user > 0))
{ {
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Person")), null, 'errors'); setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Person")), null, 'errors');
$error++; $error++;
} }
if (!$error) if (!$error)
{ {
$id = $object->create($user); $id = $object->create($user);
if ($id > 0) if ($id > 0)
{ {
header("Location: ".$_SERVER["PHP_SELF"]."?id=".$id); header("Location: ".$_SERVER["PHP_SELF"]."?id=".$id);
exit; exit;
} else { } else {
setEventMessages($object->error, $object->errors, 'errors'); setEventMessages($object->error, $object->errors, 'errors');
$action = 'create'; $action = 'create';
} }
} else { } else {
$action = 'create'; $action = 'create';
} }
} else { } else {
header("Location: index.php"); header("Location: index.php");
exit; exit;
} }
} // Update record } // Update record
elseif ($action == 'update' && $user->rights->deplacement->creer) elseif ($action == 'update' && $user->rights->deplacement->creer)
{ {
if (!GETPOST('cancel', 'alpha')) if (!GETPOST('cancel', 'alpha'))
{ {
$result = $object->fetch($id); $result = $object->fetch($id);
$object->date = dol_mktime(12, 0, 0, GETPOST('remonth', 'int'), GETPOST('reday', 'int'), GETPOST('reyear', 'int')); $object->date = dol_mktime(12, 0, 0, GETPOST('remonth', 'int'), GETPOST('reday', 'int'), GETPOST('reyear', 'int'));
$object->km = price2num(GETPOST('km', 'alpha'), 'MU'); // Not 'int', it may be a formated amount $object->km = price2num(GETPOST('km', 'alpha'), 'MU'); // Not 'int', it may be a formated amount
$object->type = GETPOST('type', 'alpha'); $object->type = GETPOST('type', 'alpha');
$object->socid = (int) GETPOST('socid', 'int'); $object->socid = (int) GETPOST('socid', 'int');
$object->fk_user = (int) GETPOST('fk_user', 'int'); $object->fk_user = (int) GETPOST('fk_user', 'int');
$object->note_private = GETPOST('note_private', 'alpha'); $object->note_private = GETPOST('note_private', 'alpha');
$object->note_public = GETPOST('note_public', 'alpha'); $object->note_public = GETPOST('note_public', 'alpha');
$result = $object->update($user); $result = $object->update($user);
if ($result > 0) if ($result > 0)
{ {
header("Location: ".$_SERVER["PHP_SELF"]."?id=".$id); header("Location: ".$_SERVER["PHP_SELF"]."?id=".$id);
exit; exit;
} else { } else {
setEventMessages($object->error, $object->errors, 'errors'); setEventMessages($object->error, $object->errors, 'errors');
} }
} else { } else {
header("Location: ".$_SERVER["PHP_SELF"]."?id=".$id); header("Location: ".$_SERVER["PHP_SELF"]."?id=".$id);
exit; exit;
} }
} // Set into a project } // Set into a project
elseif ($action == 'classin' && $user->rights->deplacement->creer) elseif ($action == 'classin' && $user->rights->deplacement->creer)
{ {
$object->fetch($id); $object->fetch($id);
$result = $object->setProject(GETPOST('projectid', 'int')); $result = $object->setProject(GETPOST('projectid', 'int'));
if ($result < 0) dol_print_error($db, $object->error); if ($result < 0) dol_print_error($db, $object->error);
} // Set fields } // Set fields
elseif ($action == 'setdated' && $user->rights->deplacement->creer) elseif ($action == 'setdated' && $user->rights->deplacement->creer)
{ {
$dated = dol_mktime(GETPOST('datedhour', 'int'), GETPOST('datedmin', 'int'), GETPOST('datedsec', 'int'), GETPOST('datedmonth', 'int'), GETPOST('datedday', 'int'), GETPOST('datedyear', 'int')); $dated = dol_mktime(GETPOST('datedhour', 'int'), GETPOST('datedmin', 'int'), GETPOST('datedsec', 'int'), GETPOST('datedmonth', 'int'), GETPOST('datedday', 'int'), GETPOST('datedyear', 'int'));
$object->fetch($id); $object->fetch($id);
$result = $object->setValueFrom('dated', $dated, '', '', 'date', '', $user, 'DEPLACEMENT_MODIFY'); $result = $object->setValueFrom('dated', $dated, '', '', 'date', '', $user, 'DEPLACEMENT_MODIFY');
if ($result < 0) dol_print_error($db, $object->error); if ($result < 0) dol_print_error($db, $object->error);
} elseif ($action == 'setkm' && $user->rights->deplacement->creer) } elseif ($action == 'setkm' && $user->rights->deplacement->creer)
{ {
$object->fetch($id); $object->fetch($id);
$result = $object->setValueFrom('km', GETPOST('km', 'int'), '', null, 'text', '', $user, 'DEPLACEMENT_MODIFY'); $result = $object->setValueFrom('km', GETPOST('km', 'int'), '', null, 'text', '', $user, 'DEPLACEMENT_MODIFY');
if ($result < 0) dol_print_error($db, $object->error); if ($result < 0) dol_print_error($db, $object->error);
} }
@ -210,327 +210,327 @@ $form = new Form($db);
*/ */
if ($action == 'create') if ($action == 'create')
{ {
//WYSIWYG Editor //WYSIWYG Editor
require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
print load_fiche_titre($langs->trans("NewTrip")); print load_fiche_titre($langs->trans("NewTrip"));
$datec = dol_mktime(12, 0, 0, GETPOST('remonth', 'int'), GETPOST('reday', 'int'), GETPOST('reyear', 'int')); $datec = dol_mktime(12, 0, 0, GETPOST('remonth', 'int'), GETPOST('reday', 'int'), GETPOST('reyear', 'int'));
print '<form name="add" action="'.$_SERVER["PHP_SELF"].'" method="POST">'."\n"; print '<form name="add" action="'.$_SERVER["PHP_SELF"].'" method="POST">'."\n";
print '<input type="hidden" name="token" value="'.newToken().'">'; print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="action" value="add">'; print '<input type="hidden" name="action" value="add">';
print '<table class="border centpercent">'; print '<table class="border centpercent">';
print "<tr>"; print "<tr>";
print '<td class="fieldrequired">'.$langs->trans("Type").'</td><td>'; print '<td class="fieldrequired">'.$langs->trans("Type").'</td><td>';
$form->select_type_fees(GETPOST('type', 'int'), 'type', 1); $form->select_type_fees(GETPOST('type', 'int'), 'type', 1);
print '</td></tr>'; print '</td></tr>';
print "<tr>"; print "<tr>";
print '<td class="fieldrequired">'.$langs->trans("Person").'</td><td>'; print '<td class="fieldrequired">'.$langs->trans("Person").'</td><td>';
print $form->select_dolusers(GETPOST('fk_user', 'int'), 'fk_user', 1, '', 0, '', '', 0, 0, 0, '', 0, '', 'maxwidth300'); print $form->select_dolusers(GETPOST('fk_user', 'int'), 'fk_user', 1, '', 0, '', '', 0, 0, 0, '', 0, '', 'maxwidth300');
print '</td></tr>'; print '</td></tr>';
print "<tr>"; print "<tr>";
print '<td class="fieldrequired">'.$langs->trans("Date").'</td><td>'; print '<td class="fieldrequired">'.$langs->trans("Date").'</td><td>';
print $form->selectDate($datec ? $datec : -1, '', '', '', '', 'add', 1, 1); print $form->selectDate($datec ? $datec : -1, '', '', '', '', 'add', 1, 1);
print '</td></tr>'; print '</td></tr>';
// Km // Km
print '<tr><td class="fieldrequired">'.$langs->trans("FeesKilometersOrAmout").'</td><td><input name="km" size="10" value="'.GETPOST("km").'"></td></tr>'; print '<tr><td class="fieldrequired">'.$langs->trans("FeesKilometersOrAmout").'</td><td><input name="km" size="10" value="'.GETPOST("km").'"></td></tr>';
// Company // Company
print "<tr>"; print "<tr>";
print '<td>'.$langs->trans("CompanyVisited").'</td><td>'; print '<td>'.$langs->trans("CompanyVisited").'</td><td>';
print $form->select_company(GETPOST('socid', 'int'), 'socid', '', 1); print $form->select_company(GETPOST('socid', 'int'), 'socid', '', 1);
print '</td></tr>'; print '</td></tr>';
// Public note // Public note
print '<tr>'; print '<tr>';
print '<td class="tdtop">'.$langs->trans('NotePublic').'</td>'; print '<td class="tdtop">'.$langs->trans('NotePublic').'</td>';
print '<td>'; print '<td>';
$doleditor = new DolEditor('note_public', GETPOST('note_public', 'restricthtml'), '', 200, 'dolibarr_notes', 'In', false, true, true, ROWS_8, '90%'); $doleditor = new DolEditor('note_public', GETPOST('note_public', 'restricthtml'), '', 200, 'dolibarr_notes', 'In', false, true, true, ROWS_8, '90%');
print $doleditor->Create(1); print $doleditor->Create(1);
print '</td></tr>'; print '</td></tr>';
// Private note // Private note
if (empty($user->socid)) if (empty($user->socid))
{ {
print '<tr>'; print '<tr>';
print '<td class="tdtop">'.$langs->trans('NotePrivate').'</td>'; print '<td class="tdtop">'.$langs->trans('NotePrivate').'</td>';
print '<td>'; print '<td>';
$doleditor = new DolEditor('note_private', GETPOST('note_private', 'restricthtml'), '', 200, 'dolibarr_notes', 'In', false, true, true, ROWS_8, '90%'); $doleditor = new DolEditor('note_private', GETPOST('note_private', 'restricthtml'), '', 200, 'dolibarr_notes', 'In', false, true, true, ROWS_8, '90%');
print $doleditor->Create(1); print $doleditor->Create(1);
print '</td></tr>'; print '</td></tr>';
} }
// Other attributes // Other attributes
$parameters = array(); $parameters = array();
$reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
print $hookmanager->resPrint; print $hookmanager->resPrint;
print '</table>'; print '</table>';
print '<br><div class="center">'; print '<br><div class="center">';
print '<input class="button" type="submit" value="'.$langs->trans("Save").'">'; print '<input class="button" type="submit" value="'.$langs->trans("Save").'">';
print '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'; print '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
print '<input class="button" type="submit" name="cancel" value="'.$langs->trans("Cancel").'">'; print '<input class="button" type="submit" name="cancel" value="'.$langs->trans("Cancel").'">';
print '</div>'; print '</div>';
print '</form>'; print '</form>';
} elseif ($id) } elseif ($id)
{ {
$result = $object->fetch($id); $result = $object->fetch($id);
if ($result > 0) if ($result > 0)
{ {
$head = trip_prepare_head($object); $head = trip_prepare_head($object);
dol_fiche_head($head, 'card', $langs->trans("TripCard"), 0, 'trip'); dol_fiche_head($head, 'card', $langs->trans("TripCard"), 0, 'trip');
if ($action == 'edit' && $user->rights->deplacement->creer) if ($action == 'edit' && $user->rights->deplacement->creer)
{ {
//WYSIWYG Editor //WYSIWYG Editor
require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
$soc = new Societe($db); $soc = new Societe($db);
if ($object->socid) if ($object->socid)
{ {
$soc->fetch($object->socid); $soc->fetch($object->socid);
} }
print '<form name="update" action="'.$_SERVER["PHP_SELF"].'" method="POST">'."\n"; print '<form name="update" action="'.$_SERVER["PHP_SELF"].'" method="POST">'."\n";
print '<input type="hidden" name="token" value="'.newToken().'">'; print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="action" value="update">'; print '<input type="hidden" name="action" value="update">';
print '<input type="hidden" name="id" value="'.$id.'">'; print '<input type="hidden" name="id" value="'.$id.'">';
print '<table class="border centpercent">'; print '<table class="border centpercent">';
// Ref // Ref
print "<tr>"; print "<tr>";
print '<td class="titlefield">'.$langs->trans("Ref").'</td><td>'; print '<td class="titlefield">'.$langs->trans("Ref").'</td><td>';
print $object->ref; print $object->ref;
print '</td></tr>'; print '</td></tr>';
// Type // Type
print "<tr>"; print "<tr>";
print '<td class="fieldrequired">'.$langs->trans("Type").'</td><td>'; print '<td class="fieldrequired">'.$langs->trans("Type").'</td><td>';
$form->select_type_fees(GETPOST('type', 'int') ?GETPOST('type', 'int') : $object->type, 'type', 0); $form->select_type_fees(GETPOST('type', 'int') ?GETPOST('type', 'int') : $object->type, 'type', 0);
print '</td></tr>'; print '</td></tr>';
// Who // Who
print "<tr>"; print "<tr>";
print '<td class="fieldrequired">'.$langs->trans("Person").'</td><td>'; print '<td class="fieldrequired">'.$langs->trans("Person").'</td><td>';
print $form->select_dolusers(GETPOST('fk_user', 'int') ?GETPOST('fk_user', 'int') : $object->fk_user, 'fk_user', 0, '', 0, '', '', 0, 0, 0, '', 0, '', 'maxwidth300'); print $form->select_dolusers(GETPOST('fk_user', 'int') ?GETPOST('fk_user', 'int') : $object->fk_user, 'fk_user', 0, '', 0, '', '', 0, 0, 0, '', 0, '', 'maxwidth300');
print '</td></tr>'; print '</td></tr>';
// Date // Date
print '<tr><td class="fieldrequired">'.$langs->trans("Date").'</td><td>'; print '<tr><td class="fieldrequired">'.$langs->trans("Date").'</td><td>';
print $form->selectDate($object->date, '', 0, 0, 0, 'update', 1, 0); print $form->selectDate($object->date, '', 0, 0, 0, 'update', 1, 0);
print '</td></tr>'; print '</td></tr>';
// Km // Km
print '<tr><td class="fieldrequired">'.$langs->trans("FeesKilometersOrAmout").'</td><td>'; print '<tr><td class="fieldrequired">'.$langs->trans("FeesKilometersOrAmout").'</td><td>';
print '<input name="km" class="flat" size="10" value="'.$object->km.'">'; print '<input name="km" class="flat" size="10" value="'.$object->km.'">';
print '</td></tr>'; print '</td></tr>';
// Where // Where
print "<tr>"; print "<tr>";
print '<td>'.$langs->trans("CompanyVisited").'</td><td>'; print '<td>'.$langs->trans("CompanyVisited").'</td><td>';
print $form->select_company($soc->id, 'socid', '', 1); print $form->select_company($soc->id, 'socid', '', 1);
print '</td></tr>'; print '</td></tr>';
// Public note // Public note
print '<tr><td class="tdtop">'.$langs->trans("NotePublic").'</td>'; print '<tr><td class="tdtop">'.$langs->trans("NotePublic").'</td>';
print '<td>'; print '<td>';
$doleditor = new DolEditor('note_public', $object->note_public, '', 200, 'dolibarr_notes', 'In', false, true, true, ROWS_8, '90%'); $doleditor = new DolEditor('note_public', $object->note_public, '', 200, 'dolibarr_notes', 'In', false, true, true, ROWS_8, '90%');
print $doleditor->Create(1); print $doleditor->Create(1);
print "</td></tr>"; print "</td></tr>";
// Private note // Private note
if (empty($user->socid)) if (empty($user->socid))
{ {
print '<tr><td class="tdtop">'.$langs->trans("NotePrivate").'</td>'; print '<tr><td class="tdtop">'.$langs->trans("NotePrivate").'</td>';
print '<td>'; print '<td>';
$doleditor = new DolEditor('note_private', $object->note_private, '', 200, 'dolibarr_notes', 'In', false, true, true, ROWS_8, '90%'); $doleditor = new DolEditor('note_private', $object->note_private, '', 200, 'dolibarr_notes', 'In', false, true, true, ROWS_8, '90%');
print $doleditor->Create(1); print $doleditor->Create(1);
print "</td></tr>"; print "</td></tr>";
} }
// Other attributes // Other attributes
$parameters = array(); $parameters = array();
$reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
print $hookmanager->resPrint; print $hookmanager->resPrint;
print '</table>'; print '</table>';
print '<br><div class="center">'; print '<br><div class="center">';
print '<input type="submit" class="button" value="'.$langs->trans("Save").'">'; print '<input type="submit" class="button" value="'.$langs->trans("Save").'">';
print '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'; print '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
print '<input type="submit" name="cancel" class="button" value="'.$langs->trans("Cancel").'">'; print '<input type="submit" name="cancel" class="button" value="'.$langs->trans("Cancel").'">';
print '</div>'; print '</div>';
print '</form>'; print '</form>';
print '</div>'; print '</div>';
} else { } else {
/* /*
* Confirm delete trip * Confirm delete trip
*/ */
if ($action == 'delete') if ($action == 'delete')
{ {
print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$id, $langs->trans("DeleteTrip"), $langs->trans("ConfirmDeleteTrip"), "confirm_delete"); print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$id, $langs->trans("DeleteTrip"), $langs->trans("ConfirmDeleteTrip"), "confirm_delete");
} }
$soc = new Societe($db); $soc = new Societe($db);
if ($object->socid) $soc->fetch($object->socid); if ($object->socid) $soc->fetch($object->socid);
print '<table class="border centpercent">'; print '<table class="border centpercent">';
$linkback = '<a href="'.DOL_URL_ROOT.'/compta/deplacement/list.php'.(!empty($socid) ? '?socid='.$socid : '').'">'.$langs->trans("BackToList").'</a>'; $linkback = '<a href="'.DOL_URL_ROOT.'/compta/deplacement/list.php'.(!empty($socid) ? '?socid='.$socid : '').'">'.$langs->trans("BackToList").'</a>';
// Ref // Ref
print '<tr><td width="25%">'.$langs->trans("Ref").'</td><td>'; print '<tr><td width="25%">'.$langs->trans("Ref").'</td><td>';
print $form->showrefnav($object, 'id', $linkback, 1, 'rowid', 'ref', ''); print $form->showrefnav($object, 'id', $linkback, 1, 'rowid', 'ref', '');
print '</td></tr>'; print '</td></tr>';
$form->load_cache_types_fees(); $form->load_cache_types_fees();
// Type // Type
print '<tr><td>'; print '<tr><td>';
print $form->editfieldkey("Type", 'type', $langs->trans($object->type), $object, $user->rights->deplacement->creer, 'select:types_fees'); print $form->editfieldkey("Type", 'type', $langs->trans($object->type), $object, $user->rights->deplacement->creer, 'select:types_fees');
print '</td><td>'; print '</td><td>';
print $form->editfieldval("Type", 'type', $form->cache_types_fees[$object->type], $object, $user->rights->deplacement->creer, 'select:types_fees'); print $form->editfieldval("Type", 'type', $form->cache_types_fees[$object->type], $object, $user->rights->deplacement->creer, 'select:types_fees');
print '</td></tr>'; print '</td></tr>';
// Who // Who
print '<tr><td>'.$langs->trans("Person").'</td><td>'; print '<tr><td>'.$langs->trans("Person").'</td><td>';
$userfee = new User($db); $userfee = new User($db);
$userfee->fetch($object->fk_user); $userfee->fetch($object->fk_user);
print $userfee->getNomUrl(1); print $userfee->getNomUrl(1);
print '</td></tr>'; print '</td></tr>';
// Date // Date
print '<tr><td>'; print '<tr><td>';
print $form->editfieldkey("Date", 'dated', $object->date, $object, $user->rights->deplacement->creer, 'datepicker'); print $form->editfieldkey("Date", 'dated', $object->date, $object, $user->rights->deplacement->creer, 'datepicker');
print '</td><td>'; print '</td><td>';
print $form->editfieldval("Date", 'dated', $object->date, $object, $user->rights->deplacement->creer, 'datepicker'); print $form->editfieldval("Date", 'dated', $object->date, $object, $user->rights->deplacement->creer, 'datepicker');
print '</td></tr>'; print '</td></tr>';
// Km/Price // Km/Price
print '<tr><td class="tdtop">'; print '<tr><td class="tdtop">';
print $form->editfieldkey("FeesKilometersOrAmout", 'km', $object->km, $object, $user->rights->deplacement->creer, 'numeric:6'); print $form->editfieldkey("FeesKilometersOrAmout", 'km', $object->km, $object, $user->rights->deplacement->creer, 'numeric:6');
print '</td><td>'; print '</td><td>';
print $form->editfieldval("FeesKilometersOrAmout", 'km', $object->km, $object, $user->rights->deplacement->creer, 'numeric:6'); print $form->editfieldval("FeesKilometersOrAmout", 'km', $object->km, $object, $user->rights->deplacement->creer, 'numeric:6');
print "</td></tr>"; print "</td></tr>";
// Where // Where
print '<tr><td>'.$langs->trans("CompanyVisited").'</td>'; print '<tr><td>'.$langs->trans("CompanyVisited").'</td>';
print '<td>'; print '<td>';
if ($soc->id) print $soc->getNomUrl(1); if ($soc->id) print $soc->getNomUrl(1);
print '</td></tr>'; print '</td></tr>';
// Project // Project
if (!empty($conf->projet->enabled)) if (!empty($conf->projet->enabled))
{ {
$langs->load('projects'); $langs->load('projects');
print '<tr>'; print '<tr>';
print '<td>'; print '<td>';
print '<table class="nobordernopadding" width="100%"><tr><td>'; print '<table class="nobordernopadding" width="100%"><tr><td>';
print $langs->trans('Project'); print $langs->trans('Project');
print '</td>'; print '</td>';
if ($action != 'classify' && $user->rights->deplacement->creer) if ($action != 'classify' && $user->rights->deplacement->creer)
{ {
print '<td class="right"><a href="'.$_SERVER["PHP_SELF"].'?action=classify&amp;id='.$object->id.'">'; print '<td class="right"><a href="'.$_SERVER["PHP_SELF"].'?action=classify&amp;id='.$object->id.'">';
print img_edit($langs->trans('SetProject'), 1); print img_edit($langs->trans('SetProject'), 1);
print '</a></td>'; print '</a></td>';
} }
print '</tr></table>'; print '</tr></table>';
print '</td><td colspan="3">'; print '</td><td colspan="3">';
if ($action == 'classify') if ($action == 'classify')
{ {
$form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1); $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1);
} else { } else {
$form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, 'none', 0, 0); $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, 'none', 0, 0);
} }
print '</td>'; print '</td>';
print '</tr>'; print '</tr>';
} }
// Statut // Statut
print '<tr><td>'.$langs->trans("Status").'</td><td>'.$object->getLibStatut(4).'</td></tr>'; print '<tr><td>'.$langs->trans("Status").'</td><td>'.$object->getLibStatut(4).'</td></tr>';
// Other attributes // Other attributes
$parameters = array('socid'=>$object->id); $parameters = array('socid'=>$object->id);
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php'; include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php';
print "</table><br>"; print "</table><br>";
// Notes // Notes
$blocname = 'notes'; $blocname = 'notes';
$title = $langs->trans('Notes'); $title = $langs->trans('Notes');
include DOL_DOCUMENT_ROOT.'/core/tpl/bloc_showhide.tpl.php'; include DOL_DOCUMENT_ROOT.'/core/tpl/bloc_showhide.tpl.php';
print '</div>'; print '</div>';
/* /*
* Barre d'actions * Barre d'actions
*/ */
print '<div class="tabsAction">'; print '<div class="tabsAction">';
if ($object->statut < Deplacement::STATUS_REFUNDED) // if not refunded if ($object->statut < Deplacement::STATUS_REFUNDED) // if not refunded
{ {
if ($user->rights->deplacement->creer) if ($user->rights->deplacement->creer)
{ {
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=edit&id='.$id.'">'.$langs->trans('Modify').'</a>'; print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=edit&id='.$id.'">'.$langs->trans('Modify').'</a>';
} else { } else {
print '<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans("NotAllowed")).'">'.$langs->trans('Modify').'</a>'; print '<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans("NotAllowed")).'">'.$langs->trans('Modify').'</a>';
} }
} }
if ($object->statut == Deplacement::STATUS_DRAFT) // if draft if ($object->statut == Deplacement::STATUS_DRAFT) // if draft
{ {
if ($user->rights->deplacement->creer) if ($user->rights->deplacement->creer)
{ {
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=validate&id='.$id.'">'.$langs->trans('Validate').'</a>'; print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=validate&id='.$id.'">'.$langs->trans('Validate').'</a>';
} else { } else {
print '<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans("NotAllowed")).'">'.$langs->trans('Validate').'</a>'; print '<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans("NotAllowed")).'">'.$langs->trans('Validate').'</a>';
} }
} }
if ($object->statut == Deplacement::STATUS_VALIDATED) // if validated if ($object->statut == Deplacement::STATUS_VALIDATED) // if validated
{ {
if ($user->rights->deplacement->creer) if ($user->rights->deplacement->creer)
{ {
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=classifyrefunded&id='.$id.'">'.$langs->trans('ClassifyRefunded').'</a>'; print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=classifyrefunded&id='.$id.'">'.$langs->trans('ClassifyRefunded').'</a>';
} else { } else {
print '<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans("NotAllowed")).'">'.$langs->trans('ClassifyRefunded').'</a>'; print '<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans("NotAllowed")).'">'.$langs->trans('ClassifyRefunded').'</a>';
} }
} }
if ($user->rights->deplacement->supprimer) if ($user->rights->deplacement->supprimer)
{ {
print '<a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?action=delete&token='.newToken().'&id='.$id.'">'.$langs->trans('Delete').'</a>'; print '<a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?action=delete&token='.newToken().'&id='.$id.'">'.$langs->trans('Delete').'</a>';
} else { } else {
print '<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans("NotAllowed")).'">'.$langs->trans('Delete').'</a>'; print '<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans("NotAllowed")).'">'.$langs->trans('Delete').'</a>';
} }
print '</div>'; print '</div>';
} }
} else { } else {
dol_print_error($db); dol_print_error($db);
} }
} }
// End of page // End of page

View File

@ -165,7 +165,7 @@ foreach ($object->fields as $key => $val)
} }
// Add none object fields for "search in all" // Add none object fields for "search in all"
if (empty($conf->global->SOCIETE_DISABLE_CONTACTS)) { if (empty($conf->global->SOCIETE_DISABLE_CONTACTS)) {
$fieldstosearchall['s.nom'] = "ThirdParty"; $fieldstosearchall['s.nom'] = "ThirdParty";
} }
@ -186,7 +186,7 @@ foreach ($object->fields as $key => $val) {
// Add none object fields to fields for list // Add none object fields to fields for list
$arrayfields['country.code_iso'] = array('label'=>"Country", 'position'=>22, 'checked'=>0); $arrayfields['country.code_iso'] = array('label'=>"Country", 'position'=>22, 'checked'=>0);
if (empty($conf->global->SOCIETE_DISABLE_CONTACTS)) { if (empty($conf->global->SOCIETE_DISABLE_CONTACTS)) {
$arrayfields['s.nom'] = array('label'=>"ThirdParty", 'position'=>25, 'checked'=>1); $arrayfields['s.nom'] = array('label'=>"ThirdParty", 'position'=>25, 'checked'=>1);
} }

View File

@ -30,413 +30,413 @@ include_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php';
*/ */
class box_activity extends ModeleBoxes class box_activity extends ModeleBoxes
{ {
public $boxcode = "activity"; public $boxcode = "activity";
public $boximg = "object_bill"; public $boximg = "object_bill";
public $boxlabel = 'BoxGlobalActivity'; public $boxlabel = 'BoxGlobalActivity';
public $depends = array("facture"); public $depends = array("facture");
/** /**
* @var DoliDB Database handler. * @var DoliDB Database handler.
*/ */
public $db; public $db;
public $param; public $param;
public $enabled = 1; public $enabled = 1;
public $info_box_head = array(); public $info_box_head = array();
public $info_box_contents = array(); public $info_box_contents = array();
/** /**
* Constructor * Constructor
* *
* @param DoliDB $db Database handler * @param DoliDB $db Database handler
* @param string $param More parameters * @param string $param More parameters
*/ */
public function __construct($db, $param) public function __construct($db, $param)
{ {
global $conf, $user; global $conf, $user;
$this->db = $db; $this->db = $db;
// FIXME: Pb into some status // FIXME: Pb into some status
$this->enabled = ($conf->global->MAIN_FEATURES_LEVEL); // Not enabled by default due to bugs (see previous comments) $this->enabled = ($conf->global->MAIN_FEATURES_LEVEL); // Not enabled by default due to bugs (see previous comments)
$this->hidden = !((!empty($conf->facture->enabled) && $user->rights->facture->lire) $this->hidden = !((!empty($conf->facture->enabled) && $user->rights->facture->lire)
|| (!empty($conf->commande->enabled) && $user->rights->commande->lire) || (!empty($conf->commande->enabled) && $user->rights->commande->lire)
|| (!empty($conf->propal->enabled) && $user->rights->propale->lire) || (!empty($conf->propal->enabled) && $user->rights->propale->lire)
); );
} }
/** /**
* Charge les donnees en memoire pour affichage ulterieur * Charge les donnees en memoire pour affichage ulterieur
* *
* @param int $max Maximum number of records to load * @param int $max Maximum number of records to load
* @return void * @return void
*/ */
public function loadBox($max = 5) public function loadBox($max = 5)
{ {
global $conf, $user, $langs; global $conf, $user, $langs;
include_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; include_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
$totalnb = 0; $totalnb = 0;
$line = 0; $line = 0;
$cachetime = 3600; $cachetime = 3600;
$fileid = '-e'.$conf->entity.'-u'.$user->id.'-s'.$user->socid.'-r'.($user->rights->societe->client->voir ? '1' : '0').'.cache'; $fileid = '-e'.$conf->entity.'-u'.$user->id.'-s'.$user->socid.'-r'.($user->rights->societe->client->voir ? '1' : '0').'.cache';
$now = dol_now(); $now = dol_now();
$nbofperiod = 3; $nbofperiod = 3;
if (!empty($conf->global->MAIN_BOX_ACTIVITY_DURATION)) $nbofperiod = $conf->global->MAIN_BOX_ACTIVITY_DURATION; if (!empty($conf->global->MAIN_BOX_ACTIVITY_DURATION)) $nbofperiod = $conf->global->MAIN_BOX_ACTIVITY_DURATION;
$textHead = $langs->trans("Activity").' - '.$langs->trans("LastXMonthRolling", $nbofperiod); $textHead = $langs->trans("Activity").' - '.$langs->trans("LastXMonthRolling", $nbofperiod);
$this->info_box_head = array( $this->info_box_head = array(
'text' => $textHead, 'text' => $textHead,
'limit'=> dol_strlen($textHead), 'limit'=> dol_strlen($textHead),
); );
// compute the year limit to show // compute the year limit to show
$tmpdate = dol_time_plus_duree(dol_now(), -1 * $nbofperiod, "m"); $tmpdate = dol_time_plus_duree(dol_now(), -1 * $nbofperiod, "m");
// list the summary of the propals // list the summary of the propals
if (!empty($conf->propal->enabled) && $user->rights->propale->lire) if (!empty($conf->propal->enabled) && $user->rights->propale->lire)
{ {
include_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; include_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php';
$propalstatic = new Propal($this->db); $propalstatic = new Propal($this->db);
$cachedir = DOL_DATA_ROOT.'/propale/temp'; $cachedir = DOL_DATA_ROOT.'/propale/temp';
$filename = '/boxactivity-propal'.$fileid; $filename = '/boxactivity-propal'.$fileid;
$refresh = dol_cache_refresh($cachedir, $filename, $cachetime); $refresh = dol_cache_refresh($cachedir, $filename, $cachetime);
$data = array(); $data = array();
if ($refresh) if ($refresh)
{ {
$sql = "SELECT p.fk_statut, SUM(p.total) as Mnttot, COUNT(*) as nb"; $sql = "SELECT p.fk_statut, SUM(p.total) as Mnttot, COUNT(*) as nb";
$sql .= " FROM (".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."propal as p"; $sql .= " FROM (".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."propal as p";
if (!$user->rights->societe->client->voir && !$user->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; if (!$user->rights->societe->client->voir && !$user->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql .= ")"; $sql .= ")";
$sql .= " WHERE p.entity IN (".getEntity('propal').")"; $sql .= " WHERE p.entity IN (".getEntity('propal').")";
$sql .= " AND p.fk_soc = s.rowid"; $sql .= " AND p.fk_soc = s.rowid";
if (!$user->rights->societe->client->voir && !$user->socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; if (!$user->rights->societe->client->voir && !$user->socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
if ($user->socid) $sql .= " AND s.rowid = ".$user->socid; if ($user->socid) $sql .= " AND s.rowid = ".$user->socid;
$sql .= " AND p.datep >= '".$this->db->idate($tmpdate)."'"; $sql .= " AND p.datep >= '".$this->db->idate($tmpdate)."'";
$sql .= " AND p.date_cloture IS NULL"; // just unclosed $sql .= " AND p.date_cloture IS NULL"; // just unclosed
$sql .= " GROUP BY p.fk_statut"; $sql .= " GROUP BY p.fk_statut";
$sql .= " ORDER BY p.fk_statut DESC"; $sql .= " ORDER BY p.fk_statut DESC";
$result = $this->db->query($sql); $result = $this->db->query($sql);
if ($result) if ($result)
{ {
$num = $this->db->num_rows($result); $num = $this->db->num_rows($result);
$j = 0; $j = 0;
while ($j < $num) { while ($j < $num) {
$data[$j] = $this->db->fetch_object($result); $data[$j] = $this->db->fetch_object($result);
$j++; $j++;
} }
if (!empty($conf->global->MAIN_ACTIVATE_FILECACHE)) { if (!empty($conf->global->MAIN_ACTIVATE_FILECACHE)) {
dol_filecache($cachedir, $filename, $data); dol_filecache($cachedir, $filename, $data);
} }
$this->db->free($result); $this->db->free($result);
} else { } else {
dol_print_error($this->db); dol_print_error($this->db);
} }
} else { } else {
$data = dol_readcachefile($cachedir, $filename); $data = dol_readcachefile($cachedir, $filename);
} }
if (!empty($data)) if (!empty($data))
{ {
$j = 0; $j = 0;
while ($j < count($data)) while ($j < count($data))
{ {
$this->info_box_contents[$line][0] = array( $this->info_box_contents[$line][0] = array(
'td' => 'class="left" width="16"', 'td' => 'class="left" width="16"',
'url' => DOL_URL_ROOT."/comm/propal/list.php?mainmenu=commercial&amp;leftmenu=propals&amp;search_status=".$data[$j]->fk_statut, 'url' => DOL_URL_ROOT."/comm/propal/list.php?mainmenu=commercial&amp;leftmenu=propals&amp;search_status=".$data[$j]->fk_statut,
'tooltip' => $langs->trans("Proposals")."&nbsp;".$propalstatic->LibStatut($data[$j]->fk_statut, 0), 'tooltip' => $langs->trans("Proposals")."&nbsp;".$propalstatic->LibStatut($data[$j]->fk_statut, 0),
'logo' => 'object_propal' 'logo' => 'object_propal'
); );
$this->info_box_contents[$line][1] = array( $this->info_box_contents[$line][1] = array(
'td' => '', 'td' => '',
'text' => $langs->trans("Proposals")."&nbsp;".$propalstatic->LibStatut($data[$j]->fk_statut, 0), 'text' => $langs->trans("Proposals")."&nbsp;".$propalstatic->LibStatut($data[$j]->fk_statut, 0),
); );
$this->info_box_contents[$line][2] = array( $this->info_box_contents[$line][2] = array(
'td' => 'class="right"', 'td' => 'class="right"',
'text' => $data[$j]->nb, 'text' => $data[$j]->nb,
'tooltip' => $langs->trans("Proposals")."&nbsp;".$propalstatic->LibStatut($data[$j]->fk_statut, 0), 'tooltip' => $langs->trans("Proposals")."&nbsp;".$propalstatic->LibStatut($data[$j]->fk_statut, 0),
'url' => DOL_URL_ROOT."/comm/propal/list.php?mainmenu=commercial&amp;leftmenu=propals&amp;search_status=".$data[$j]->fk_statut, 'url' => DOL_URL_ROOT."/comm/propal/list.php?mainmenu=commercial&amp;leftmenu=propals&amp;search_status=".$data[$j]->fk_statut,
); );
$totalnb += $data[$j]->nb; $totalnb += $data[$j]->nb;
$this->info_box_contents[$line][3] = array( $this->info_box_contents[$line][3] = array(
'td' => 'class="nowraponall right"', 'td' => 'class="nowraponall right"',
'text' => price($data[$j]->Mnttot, 1, $langs, 0, 0, -1, $conf->currency), 'text' => price($data[$j]->Mnttot, 1, $langs, 0, 0, -1, $conf->currency),
); );
$this->info_box_contents[$line][4] = array( $this->info_box_contents[$line][4] = array(
'td' => 'class="right" width="18"', 'td' => 'class="right" width="18"',
'text' => $propalstatic->LibStatut($data[$j]->fk_statut, 3), 'text' => $propalstatic->LibStatut($data[$j]->fk_statut, 3),
); );
$line++; $line++;
$j++; $j++;
} }
} }
} }
// list the summary of the orders // list the summary of the orders
if (!empty($conf->commande->enabled) && $user->rights->commande->lire) { if (!empty($conf->commande->enabled) && $user->rights->commande->lire) {
include_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; include_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php';
$commandestatic = new Commande($this->db); $commandestatic = new Commande($this->db);
$langs->load("orders"); $langs->load("orders");
$cachedir = DOL_DATA_ROOT.'/commande/temp'; $cachedir = DOL_DATA_ROOT.'/commande/temp';
$filename = '/boxactivity-order'.$fileid; $filename = '/boxactivity-order'.$fileid;
$refresh = dol_cache_refresh($cachedir, $filename, $cachetime); $refresh = dol_cache_refresh($cachedir, $filename, $cachetime);
$data = array(); $data = array();
if ($refresh) { if ($refresh) {
$sql = "SELECT c.fk_statut, sum(c.total_ttc) as Mnttot, count(*) as nb"; $sql = "SELECT c.fk_statut, sum(c.total_ttc) as Mnttot, count(*) as nb";
$sql .= " FROM (".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."commande as c"; $sql .= " FROM (".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."commande as c";
if (!$user->rights->societe->client->voir && !$user->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; if (!$user->rights->societe->client->voir && !$user->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql .= ")"; $sql .= ")";
$sql .= " WHERE c.entity IN (".getEntity('commande').")"; $sql .= " WHERE c.entity IN (".getEntity('commande').")";
$sql .= " AND c.fk_soc = s.rowid"; $sql .= " AND c.fk_soc = s.rowid";
if (!$user->rights->societe->client->voir && !$user->socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; if (!$user->rights->societe->client->voir && !$user->socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
if ($user->socid) $sql .= " AND s.rowid = ".$user->socid; if ($user->socid) $sql .= " AND s.rowid = ".$user->socid;
$sql .= " AND c.date_commande >= '".$this->db->idate($tmpdate)."'"; $sql .= " AND c.date_commande >= '".$this->db->idate($tmpdate)."'";
$sql .= " GROUP BY c.fk_statut"; $sql .= " GROUP BY c.fk_statut";
$sql .= " ORDER BY c.fk_statut DESC"; $sql .= " ORDER BY c.fk_statut DESC";
$result = $this->db->query($sql); $result = $this->db->query($sql);
if ($result) { if ($result) {
$num = $this->db->num_rows($result); $num = $this->db->num_rows($result);
$j = 0; $j = 0;
while ($j < $num) { while ($j < $num) {
$data[$j] = $this->db->fetch_object($result); $data[$j] = $this->db->fetch_object($result);
$j++; $j++;
} }
if (!empty($conf->global->MAIN_ACTIVATE_FILECACHE)) { if (!empty($conf->global->MAIN_ACTIVATE_FILECACHE)) {
dol_filecache($cachedir, $filename, $data); dol_filecache($cachedir, $filename, $data);
} }
$this->db->free($result); $this->db->free($result);
} else { } else {
dol_print_error($this->db); dol_print_error($this->db);
} }
} else { } else {
$data = dol_readcachefile($cachedir, $filename); $data = dol_readcachefile($cachedir, $filename);
} }
if (!empty($data)) { if (!empty($data)) {
$j = 0; $j = 0;
while ($j < count($data)) { while ($j < count($data)) {
$this->info_box_contents[$line][0] = array( $this->info_box_contents[$line][0] = array(
'td' => 'class="left" width="16"', 'td' => 'class="left" width="16"',
'url' => DOL_URL_ROOT."/commande/list.php?mainmenu=commercial&amp;leftmenu=orders&amp;search_status=".$data[$j]->fk_statut, 'url' => DOL_URL_ROOT."/commande/list.php?mainmenu=commercial&amp;leftmenu=orders&amp;search_status=".$data[$j]->fk_statut,
'tooltip' => $langs->trans("Orders")."&nbsp;".$commandestatic->LibStatut($data[$j]->fk_statut, 0, 0), 'tooltip' => $langs->trans("Orders")."&nbsp;".$commandestatic->LibStatut($data[$j]->fk_statut, 0, 0),
'logo' => 'object_order', 'logo' => 'object_order',
); );
$this->info_box_contents[$line][1] = array( $this->info_box_contents[$line][1] = array(
'td' => '', 'td' => '',
'text' =>$langs->trans("Orders")."&nbsp;".$commandestatic->LibStatut($data[$j]->fk_statut, 0, 0), 'text' =>$langs->trans("Orders")."&nbsp;".$commandestatic->LibStatut($data[$j]->fk_statut, 0, 0),
); );
$this->info_box_contents[$line][2] = array( $this->info_box_contents[$line][2] = array(
'td' => 'class="right"', 'td' => 'class="right"',
'text' => $data[$j]->nb, 'text' => $data[$j]->nb,
'tooltip' => $langs->trans("Orders")."&nbsp;".$commandestatic->LibStatut($data[$j]->fk_statut, 0, 0), 'tooltip' => $langs->trans("Orders")."&nbsp;".$commandestatic->LibStatut($data[$j]->fk_statut, 0, 0),
'url' => DOL_URL_ROOT."/commande/list.php?mainmenu=commercial&amp;leftmenu=orders&amp;search_status=".$data[$j]->fk_statut, 'url' => DOL_URL_ROOT."/commande/list.php?mainmenu=commercial&amp;leftmenu=orders&amp;search_status=".$data[$j]->fk_statut,
); );
$totalnb += $data[$j]->nb; $totalnb += $data[$j]->nb;
$this->info_box_contents[$line][3] = array( $this->info_box_contents[$line][3] = array(
'td' => 'class="nowraponall right"', 'td' => 'class="nowraponall right"',
'text' => price($data[$j]->Mnttot, 1, $langs, 0, 0, -1, $conf->currency), 'text' => price($data[$j]->Mnttot, 1, $langs, 0, 0, -1, $conf->currency),
); );
$this->info_box_contents[$line][4] = array( $this->info_box_contents[$line][4] = array(
'td' => 'class="right" width="18"', 'td' => 'class="right" width="18"',
'text' => $commandestatic->LibStatut($data[$j]->fk_statut, 0, 3), 'text' => $commandestatic->LibStatut($data[$j]->fk_statut, 0, 3),
); );
$line++; $line++;
$j++; $j++;
} }
} }
} }
// list the summary of the bills // list the summary of the bills
if (!empty($conf->facture->enabled) && $user->rights->facture->lire) if (!empty($conf->facture->enabled) && $user->rights->facture->lire)
{ {
include_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; include_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
$facturestatic = new Facture($this->db); $facturestatic = new Facture($this->db);
// part 1 // part 1
$cachedir = DOL_DATA_ROOT.'/facture/temp'; $cachedir = DOL_DATA_ROOT.'/facture/temp';
$filename = '/boxactivity-invoice'.$fileid; $filename = '/boxactivity-invoice'.$fileid;
$refresh = dol_cache_refresh($cachedir, $filename, $cachetime); $refresh = dol_cache_refresh($cachedir, $filename, $cachetime);
$data = array(); $data = array();
if ($refresh) if ($refresh)
{ {
$sql = "SELECT f.fk_statut, SUM(f.total_ttc) as Mnttot, COUNT(*) as nb"; $sql = "SELECT f.fk_statut, SUM(f.total_ttc) as Mnttot, COUNT(*) as nb";
$sql .= " FROM (".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture as f"; $sql .= " FROM (".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture as f";
if (!$user->rights->societe->client->voir && !$user->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; if (!$user->rights->societe->client->voir && !$user->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql .= ")"; $sql .= ")";
$sql .= " WHERE f.entity IN (".getEntity('invoice').')'; $sql .= " WHERE f.entity IN (".getEntity('invoice').')';
if (!$user->rights->societe->client->voir && !$user->socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; if (!$user->rights->societe->client->voir && !$user->socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
if ($user->socid) $sql .= " AND s.rowid = ".$user->socid; if ($user->socid) $sql .= " AND s.rowid = ".$user->socid;
$sql .= " AND f.fk_soc = s.rowid"; $sql .= " AND f.fk_soc = s.rowid";
$sql .= " AND f.datef >= '".$this->db->idate($tmpdate)."' AND f.paye=1"; $sql .= " AND f.datef >= '".$this->db->idate($tmpdate)."' AND f.paye=1";
$sql .= " GROUP BY f.fk_statut"; $sql .= " GROUP BY f.fk_statut";
$sql .= " ORDER BY f.fk_statut DESC"; $sql .= " ORDER BY f.fk_statut DESC";
$result = $this->db->query($sql); $result = $this->db->query($sql);
if ($result) { if ($result) {
$num = $this->db->num_rows($result); $num = $this->db->num_rows($result);
$j = 0; $j = 0;
while ($j < $num) { while ($j < $num) {
$data[$j] = $this->db->fetch_object($result); $data[$j] = $this->db->fetch_object($result);
$j++; $j++;
} }
if (!empty($conf->global->MAIN_ACTIVATE_FILECACHE)) { if (!empty($conf->global->MAIN_ACTIVATE_FILECACHE)) {
dol_filecache($cachedir, $filename, $data); dol_filecache($cachedir, $filename, $data);
} }
$this->db->free($result); $this->db->free($result);
} else { } else {
dol_print_error($this->db); dol_print_error($this->db);
} }
} else { } else {
$data = dol_readcachefile($cachedir, $filename); $data = dol_readcachefile($cachedir, $filename);
} }
if (!empty($data)) { if (!empty($data)) {
$j = 0; $j = 0;
while ($j < count($data)) { while ($j < count($data)) {
$billurl = "search_status=2&amp;paye=1&amp;year=".$data[$j]->annee; $billurl = "search_status=2&amp;paye=1&amp;year=".$data[$j]->annee;
$this->info_box_contents[$line][0] = array( $this->info_box_contents[$line][0] = array(
'td' => 'class="left" width="16"', 'td' => 'class="left" width="16"',
'tooltip' => $langs->trans('Bills').'&nbsp;'.$facturestatic->LibStatut(1, $data[$j]->fk_statut, 0), 'tooltip' => $langs->trans('Bills').'&nbsp;'.$facturestatic->LibStatut(1, $data[$j]->fk_statut, 0),
'url' => DOL_URL_ROOT."/compta/facture/list.php?".$billurl."&amp;mainmenu=accountancy&amp;leftmenu=customers_bills", 'url' => DOL_URL_ROOT."/compta/facture/list.php?".$billurl."&amp;mainmenu=accountancy&amp;leftmenu=customers_bills",
'logo' => 'bill', 'logo' => 'bill',
); );
$this->info_box_contents[$line][1] = array( $this->info_box_contents[$line][1] = array(
'td' => '', 'td' => '',
'text' => $langs->trans("Bills")."&nbsp;".$facturestatic->LibStatut(1, $data[$j]->fk_statut, 0)." ".$data[$j]->annee, 'text' => $langs->trans("Bills")."&nbsp;".$facturestatic->LibStatut(1, $data[$j]->fk_statut, 0)." ".$data[$j]->annee,
); );
$this->info_box_contents[$line][2] = array( $this->info_box_contents[$line][2] = array(
'td' => 'class="right"', 'td' => 'class="right"',
'tooltip' => $langs->trans('Bills').'&nbsp;'.$facturestatic->LibStatut(1, $data[$j]->fk_statut, 0), 'tooltip' => $langs->trans('Bills').'&nbsp;'.$facturestatic->LibStatut(1, $data[$j]->fk_statut, 0),
'text' => $data[$j]->nb, 'text' => $data[$j]->nb,
'url' => DOL_URL_ROOT."/compta/facture/list.php?".$billurl."&amp;mainmenu=accountancy&amp;leftmenu=customers_bills", 'url' => DOL_URL_ROOT."/compta/facture/list.php?".$billurl."&amp;mainmenu=accountancy&amp;leftmenu=customers_bills",
); );
$this->info_box_contents[$line][3] = array( $this->info_box_contents[$line][3] = array(
'td' => 'class="nowraponall right"', 'td' => 'class="nowraponall right"',
'text' => price($data[$j]->Mnttot, 1, $langs, 0, 0, -1, $conf->currency) 'text' => price($data[$j]->Mnttot, 1, $langs, 0, 0, -1, $conf->currency)
); );
// We add only for the current year // We add only for the current year
$totalnb += $data[$j]->nb; $totalnb += $data[$j]->nb;
$this->info_box_contents[$line][4] = array( $this->info_box_contents[$line][4] = array(
'td' => 'class="right" width="18"', 'td' => 'class="right" width="18"',
'text' => $facturestatic->LibStatut(1, $data[$j]->fk_statut, 3), 'text' => $facturestatic->LibStatut(1, $data[$j]->fk_statut, 3),
); );
$line++; $line++;
$j++; $j++;
} }
if (count($data) == 0) if (count($data) == 0)
$this->info_box_contents[$line][0] = array( $this->info_box_contents[$line][0] = array(
'td' => 'class="center"', 'td' => 'class="center"',
'text'=>$langs->trans("NoRecordedInvoices"), 'text'=>$langs->trans("NoRecordedInvoices"),
); );
} }
// part 2 // part 2
$cachedir = DOL_DATA_ROOT.'/facture/temp'; $cachedir = DOL_DATA_ROOT.'/facture/temp';
$filename = '/boxactivity-invoice2'.$fileid; $filename = '/boxactivity-invoice2'.$fileid;
$refresh = dol_cache_refresh($cachedir, $filename, $cachetime); $refresh = dol_cache_refresh($cachedir, $filename, $cachetime);
$data = array(); $data = array();
if ($refresh) { if ($refresh) {
$sql = "SELECT f.fk_statut, SUM(f.total_ttc) as Mnttot, COUNT(*) as nb"; $sql = "SELECT f.fk_statut, SUM(f.total_ttc) as Mnttot, COUNT(*) as nb";
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture as f"; $sql .= " FROM ".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture as f";
$sql .= " WHERE f.entity IN (".getEntity('invoice').')'; $sql .= " WHERE f.entity IN (".getEntity('invoice').')';
$sql .= " AND f.fk_soc = s.rowid"; $sql .= " AND f.fk_soc = s.rowid";
$sql .= " AND f.datef >= '".$this->db->idate($tmpdate)."' AND f.paye=0"; $sql .= " AND f.datef >= '".$this->db->idate($tmpdate)."' AND f.paye=0";
$sql .= " GROUP BY f.fk_statut"; $sql .= " GROUP BY f.fk_statut";
$sql .= " ORDER BY f.fk_statut DESC"; $sql .= " ORDER BY f.fk_statut DESC";
$result = $this->db->query($sql); $result = $this->db->query($sql);
if ($result) { if ($result) {
$num = $this->db->num_rows($result); $num = $this->db->num_rows($result);
$j = 0; $j = 0;
while ($j < $num) { while ($j < $num) {
$data[$j] = $this->db->fetch_object($result); $data[$j] = $this->db->fetch_object($result);
$j++; $j++;
} }
if (!empty($conf->global->MAIN_ACTIVATE_FILECACHE)) { if (!empty($conf->global->MAIN_ACTIVATE_FILECACHE)) {
dol_filecache($cachedir, $filename, $data); dol_filecache($cachedir, $filename, $data);
} }
$this->db->free($result); $this->db->free($result);
} else { } else {
dol_print_error($this->db); dol_print_error($this->db);
} }
} else { } else {
$data = dol_readcachefile($cachedir, $filename); $data = dol_readcachefile($cachedir, $filename);
} }
if (!empty($data)) { if (!empty($data)) {
$alreadypaid = -1; $alreadypaid = -1;
$j = 0; $j = 0;
while ($j < count($data)) { while ($j < count($data)) {
$billurl = "search_status=".$data[$j]->fk_statut."&amp;paye=0"; $billurl = "search_status=".$data[$j]->fk_statut."&amp;paye=0";
$this->info_box_contents[$line][0] = array( $this->info_box_contents[$line][0] = array(
'td' => 'class="left" width="16"', 'td' => 'class="left" width="16"',
'tooltip' => $langs->trans('Bills').'&nbsp;'.$facturestatic->LibStatut(0, $data[$j]->fk_statut, 0), 'tooltip' => $langs->trans('Bills').'&nbsp;'.$facturestatic->LibStatut(0, $data[$j]->fk_statut, 0),
'url' => DOL_URL_ROOT."/compta/facture/list.php?".$billurl."&amp;mainmenu=accountancy&amp;leftmenu=customers_bills", 'url' => DOL_URL_ROOT."/compta/facture/list.php?".$billurl."&amp;mainmenu=accountancy&amp;leftmenu=customers_bills",
'logo' => 'bill', 'logo' => 'bill',
); );
$this->info_box_contents[$line][1] = array( $this->info_box_contents[$line][1] = array(
'td' => '', 'td' => '',
'text' => $langs->trans("Bills")."&nbsp;".$facturestatic->LibStatut(0, $data[$j]->fk_statut, 0), 'text' => $langs->trans("Bills")."&nbsp;".$facturestatic->LibStatut(0, $data[$j]->fk_statut, 0),
); );
$this->info_box_contents[$line][2] = array( $this->info_box_contents[$line][2] = array(
'td' => 'class="right"', 'td' => 'class="right"',
'text' => $data[$j]->nb, 'text' => $data[$j]->nb,
'tooltip' => $langs->trans('Bills').'&nbsp;'.$facturestatic->LibStatut(0, $data[$j]->fk_statut, 0), 'tooltip' => $langs->trans('Bills').'&nbsp;'.$facturestatic->LibStatut(0, $data[$j]->fk_statut, 0),
'url' => DOL_URL_ROOT."/compta/facture/list.php?".$billurl."&amp;mainmenu=accountancy&amp;leftmenu=customers_bills", 'url' => DOL_URL_ROOT."/compta/facture/list.php?".$billurl."&amp;mainmenu=accountancy&amp;leftmenu=customers_bills",
); );
$totalnb += $data[$j]->nb; $totalnb += $data[$j]->nb;
$this->info_box_contents[$line][3] = array( $this->info_box_contents[$line][3] = array(
'td' => 'class="nowraponall right"', 'td' => 'class="nowraponall right"',
'text' => price($data[$j]->Mnttot, 1, $langs, 0, 0, -1, $conf->currency), 'text' => price($data[$j]->Mnttot, 1, $langs, 0, 0, -1, $conf->currency),
); );
$this->info_box_contents[$line][4] = array( $this->info_box_contents[$line][4] = array(
'td' => 'class="right" width="18"', 'td' => 'class="right" width="18"',
'text' => $facturestatic->LibStatut(0, $data[$j]->fk_statut, 3, $alreadypaid), 'text' => $facturestatic->LibStatut(0, $data[$j]->fk_statut, 3, $alreadypaid),
); );
$line++; $line++;
$j++; $j++;
} }
if (count($data) == 0) { if (count($data) == 0) {
$this->info_box_contents[$line][0] = array( $this->info_box_contents[$line][0] = array(
'td' => 'class="center"', 'td' => 'class="center"',
'text'=>$langs->trans("NoRecordedInvoices"), 'text'=>$langs->trans("NoRecordedInvoices"),
); );
} }
} }
} }
// Add the sum in the bottom of the boxes // Add the sum in the bottom of the boxes
$this->info_box_contents[$line][0] = array('tr' => 'class="liste_total_wrap"'); $this->info_box_contents[$line][0] = array('tr' => 'class="liste_total_wrap"');
@ -444,19 +444,19 @@ class box_activity extends ModeleBoxes
$this->info_box_contents[$line][2] = array('td' => 'class="liste_total right" ', 'text' => $totalnb); $this->info_box_contents[$line][2] = array('td' => 'class="liste_total right" ', 'text' => $totalnb);
$this->info_box_contents[$line][3] = array('td' => 'class="liste_total right" ', 'text' => ''); $this->info_box_contents[$line][3] = array('td' => 'class="liste_total right" ', 'text' => '');
$this->info_box_contents[$line][4] = array('td' => 'class="liste_total right" ', 'text' => ""); $this->info_box_contents[$line][4] = array('td' => 'class="liste_total right" ', 'text' => "");
} }
/** /**
* Method to show box * Method to show box
* *
* @param array $head Array with properties of box title * @param array $head Array with properties of box title
* @param array $contents Array with properties of box lines * @param array $contents Array with properties of box lines
* @param int $nooutput No print, only return string * @param int $nooutput No print, only return string
* @return string * @return string
*/ */
public function showBox($head = null, $contents = null, $nooutput = 0) public function showBox($head = null, $contents = null, $nooutput = 0)
{ {
return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput);
} }
} }

File diff suppressed because it is too large Load Diff

View File

@ -30,9 +30,9 @@
class HookManager class HookManager
{ {
/** /**
* @var DoliDB Database handler. * @var DoliDB Database handler.
*/ */
public $db; public $db;
/** /**
* @var string Error code (or message) * @var string Error code (or message)
@ -44,18 +44,18 @@ class HookManager
*/ */
public $errors = array(); public $errors = array();
// Context hookmanager was created for ('thirdpartycard', 'thirdpartydao', ...) // Context hookmanager was created for ('thirdpartycard', 'thirdpartydao', ...)
public $contextarray = array(); public $contextarray = array();
// Array with instantiated classes // Array with instantiated classes
public $hooks = array(); public $hooks = array();
// Array result // Array result
public $resArray = array(); public $resArray = array();
// Printable result // Printable result
public $resPrint = ''; public $resPrint = '';
// Nb of qualified hook ran // Nb of qualified hook ran
public $resNbOfHooks = 0; public $resNbOfHooks = 0;
/** /**
* Constructor * Constructor
@ -84,9 +84,9 @@ class HookManager
global $conf; global $conf;
// Test if there is hooks to manage // Test if there is hooks to manage
if (!is_array($conf->modules_parts['hooks']) || empty($conf->modules_parts['hooks'])) return; if (!is_array($conf->modules_parts['hooks']) || empty($conf->modules_parts['hooks'])) return;
// For backward compatibility // For backward compatibility
if (!is_array($arraycontext)) $arraycontext = array($arraycontext); if (!is_array($arraycontext)) $arraycontext = array($arraycontext);
$this->contextarray = array_unique(array_merge($arraycontext, $this->contextarray)); // All contexts are concatenated $this->contextarray = array_unique(array_merge($arraycontext, $this->contextarray)); // All contexts are concatenated
@ -130,29 +130,29 @@ class HookManager
return 1; return 1;
} }
/** /**
* Execute hooks (if they were initialized) for the given method * Execute hooks (if they were initialized) for the given method
* *
* @param string $method Name of method hooked ('doActions', 'printSearchForm', 'showInputField', ...) * @param string $method Name of method hooked ('doActions', 'printSearchForm', 'showInputField', ...)
* @param array $parameters Array of parameters * @param array $parameters Array of parameters
* @param Object $object Object to use hooks on * @param Object $object Object to use hooks on
* @param string $action Action code on calling page ('create', 'edit', 'view', 'add', 'update', 'delete'...) * @param string $action Action code on calling page ('create', 'edit', 'view', 'add', 'update', 'delete'...)
* @return mixed For 'addreplace' hooks (doActions, formConfirm, formObjectOptions, pdf_xxx,...): Return 0 if we want to keep standard actions, >0 if we want to stop/replace standard actions, <0 if KO. Things to print are returned into ->resprints and set into ->resPrint. Things to return are returned into ->results by hook and set into ->resArray for caller. * @return mixed For 'addreplace' hooks (doActions, formConfirm, formObjectOptions, pdf_xxx,...): Return 0 if we want to keep standard actions, >0 if we want to stop/replace standard actions, <0 if KO. Things to print are returned into ->resprints and set into ->resPrint. Things to return are returned into ->results by hook and set into ->resArray for caller.
* For 'output' hooks (printLeftBlock, formAddObjectLine, formBuilddocOptions, ...): Return 0, <0 if KO. Things to print are returned into ->resprints and set into ->resPrint. Things to return are returned into ->results by hook and set into ->resArray for caller. * For 'output' hooks (printLeftBlock, formAddObjectLine, formBuilddocOptions, ...): Return 0, <0 if KO. Things to print are returned into ->resprints and set into ->resPrint. Things to return are returned into ->results by hook and set into ->resArray for caller.
* All types can also return some values into an array ->results that will be finaly merged into this->resArray for caller. * All types can also return some values into an array ->results that will be finaly merged into this->resArray for caller.
* $this->error or this->errors are also defined by class called by this function if error. * $this->error or this->errors are also defined by class called by this function if error.
*/ */
public function executeHooks($method, $parameters = array(), &$object = '', &$action = '') public function executeHooks($method, $parameters = array(), &$object = '', &$action = '')
{ {
if (!is_array($this->hooks) || empty($this->hooks)) return 0; // No hook available, do nothing. if (!is_array($this->hooks) || empty($this->hooks)) return 0; // No hook available, do nothing.
$parameters['context'] = join(':', $this->contextarray); $parameters['context'] = join(':', $this->contextarray);
//dol_syslog(get_class($this).'::executeHooks method='.$method." action=".$action." context=".$parameters['context']); //dol_syslog(get_class($this).'::executeHooks method='.$method." action=".$action." context=".$parameters['context']);
// Define type of hook ('output' or 'addreplace'). // Define type of hook ('output' or 'addreplace').
// TODO Remove hooks with type 'output'. All hooks must be converted into 'addreplace' hooks. // TODO Remove hooks with type 'output'. All hooks must be converted into 'addreplace' hooks.
$hooktype = 'output'; $hooktype = 'output';
if (in_array( if (in_array(
$method, $method,
array( array(
'addCalendarChoice', 'addCalendarChoice',
@ -172,33 +172,33 @@ class HookManager
'formattachOptions', 'formattachOptions',
'formBuilddocLineOptions', 'formBuilddocLineOptions',
'formatNotificationMessage', 'formatNotificationMessage',
'formConfirm', 'formConfirm',
'getAccessForbiddenMessage', 'getAccessForbiddenMessage',
'getDirList', 'getDirList',
'getFormMail', 'getFormMail',
'getFormatedCustomerRef', 'getFormatedCustomerRef',
'getFormatedSupplierRef', 'getFormatedSupplierRef',
'getIdProfUrl', 'getIdProfUrl',
'getInputIdProf', 'getInputIdProf',
'moveUploadedFile', 'moveUploadedFile',
'moreHtmlStatus', 'moreHtmlStatus',
'pdf_build_address', 'pdf_build_address',
'pdf_writelinedesc', 'pdf_writelinedesc',
'pdf_getlinenum', 'pdf_getlinenum',
'pdf_getlineref', 'pdf_getlineref',
'pdf_getlineref_supplier', 'pdf_getlineref_supplier',
'pdf_getlinevatrate', 'pdf_getlinevatrate',
'pdf_getlineupexcltax', 'pdf_getlineupexcltax',
'pdf_getlineupwithtax', 'pdf_getlineupwithtax',
'pdf_getlineqty', 'pdf_getlineqty',
'pdf_getlineqty_asked', 'pdf_getlineqty_asked',
'pdf_getlineqty_shipped', 'pdf_getlineqty_shipped',
'pdf_getlineqty_keeptoship', 'pdf_getlineqty_keeptoship',
'pdf_getlineunit', 'pdf_getlineunit',
'pdf_getlineremisepercent', 'pdf_getlineremisepercent',
'pdf_getlineprogress', 'pdf_getlineprogress',
'pdf_getlinetotalexcltax', 'pdf_getlinetotalexcltax',
'pdf_getlinetotalwithtax', 'pdf_getlinetotalwithtax',
'paymentsupplierinvoices', 'paymentsupplierinvoices',
'printAddress', 'printAddress',
'printEmail', 'printEmail',
@ -213,88 +213,88 @@ class HookManager
'showLinkToObjectBlock', 'showLinkToObjectBlock',
'setContentSecurityPolicy', 'setContentSecurityPolicy',
'setHtmlTitle', 'setHtmlTitle',
'completeTabsHead' 'completeTabsHead'
) )
)) $hooktype = 'addreplace'; )) $hooktype = 'addreplace';
// Init return properties // Init return properties
$this->resPrint = ''; $this->resArray = array(); $this->resNbOfHooks = 0; $this->resPrint = ''; $this->resArray = array(); $this->resNbOfHooks = 0;
// Loop on each hook to qualify modules that have declared context // Loop on each hook to qualify modules that have declared context
$modulealreadyexecuted = array(); $modulealreadyexecuted = array();
$resaction = 0; $error = 0; $resaction = 0; $error = 0;
foreach ($this->hooks as $context => $modules) // $this->hooks is an array with context as key and value is an array of modules that handle this context foreach ($this->hooks as $context => $modules) // $this->hooks is an array with context as key and value is an array of modules that handle this context
{ {
if (!empty($modules)) if (!empty($modules))
{ {
foreach ($modules as $module => $actionclassinstance) foreach ($modules as $module => $actionclassinstance)
{ {
//print "Before hook ".get_class($actionclassinstance)." method=".$method." hooktype=".$hooktype." results=".count($actionclassinstance->results)." resprints=".count($actionclassinstance->resprints)." resaction=".$resaction."<br>\n"; //print "Before hook ".get_class($actionclassinstance)." method=".$method." hooktype=".$hooktype." results=".count($actionclassinstance->results)." resprints=".count($actionclassinstance->resprints)." resaction=".$resaction."<br>\n";
// test to avoid running twice a hook, when a module implements several active contexts // test to avoid running twice a hook, when a module implements several active contexts
if (in_array($module, $modulealreadyexecuted)) continue; if (in_array($module, $modulealreadyexecuted)) continue;
// jump to next module/class if method does not exist // jump to next module/class if method does not exist
if (!method_exists($actionclassinstance, $method)) continue; if (!method_exists($actionclassinstance, $method)) continue;
$this->resNbOfHooks++; $this->resNbOfHooks++;
$modulealreadyexecuted[$module] = $module; // Use the $currentcontext in method to avoid running twice $modulealreadyexecuted[$module] = $module; // Use the $currentcontext in method to avoid running twice
// Clean class (an error may have been set from a previous call of another method for same module/hook) // Clean class (an error may have been set from a previous call of another method for same module/hook)
$actionclassinstance->error = 0; $actionclassinstance->error = 0;
$actionclassinstance->errors = array(); $actionclassinstance->errors = array();
dol_syslog(get_class($this)."::executeHooks Qualified hook found (hooktype=".$hooktype."). We call method ".$method." of class ".get_class($actionclassinstance).", module=".$module.", action=".$action." context=".$context, LOG_DEBUG); dol_syslog(get_class($this)."::executeHooks Qualified hook found (hooktype=".$hooktype."). We call method ".$method." of class ".get_class($actionclassinstance).", module=".$module.", action=".$action." context=".$context, LOG_DEBUG);
// Add current context to avoid method execution in bad context, you can add this test in your method : eg if($currentcontext != 'formfile') return; // Add current context to avoid method execution in bad context, you can add this test in your method : eg if($currentcontext != 'formfile') return;
$parameters['currentcontext'] = $context; $parameters['currentcontext'] = $context;
// Hooks that must return int (hooks with type 'addreplace') // Hooks that must return int (hooks with type 'addreplace')
if ($hooktype == 'addreplace') if ($hooktype == 'addreplace')
{ {
$resaction += $actionclassinstance->$method($parameters, $object, $action, $this); // $object and $action can be changed by method ($object->id during creation for example or $action to go back to other action for example) $resaction += $actionclassinstance->$method($parameters, $object, $action, $this); // $object and $action can be changed by method ($object->id during creation for example or $action to go back to other action for example)
if ($resaction < 0 || !empty($actionclassinstance->error) || (!empty($actionclassinstance->errors) && count($actionclassinstance->errors) > 0)) if ($resaction < 0 || !empty($actionclassinstance->error) || (!empty($actionclassinstance->errors) && count($actionclassinstance->errors) > 0))
{ {
$error++; $error++;
$this->error = $actionclassinstance->error; $this->errors = array_merge($this->errors, (array) $actionclassinstance->errors); $this->error = $actionclassinstance->error; $this->errors = array_merge($this->errors, (array) $actionclassinstance->errors);
dol_syslog("Error on hook module=".$module.", method ".$method.", class ".get_class($actionclassinstance).", hooktype=".$hooktype.(empty($this->error) ? '' : " ".$this->error).(empty($this->errors) ? '' : " ".join(",", $this->errors)), LOG_ERR); dol_syslog("Error on hook module=".$module.", method ".$method.", class ".get_class($actionclassinstance).", hooktype=".$hooktype.(empty($this->error) ? '' : " ".$this->error).(empty($this->errors) ? '' : " ".join(",", $this->errors)), LOG_ERR);
} }
if (isset($actionclassinstance->results) && is_array($actionclassinstance->results)) $this->resArray = array_merge($this->resArray, $actionclassinstance->results); if (isset($actionclassinstance->results) && is_array($actionclassinstance->results)) $this->resArray = array_merge($this->resArray, $actionclassinstance->results);
if (!empty($actionclassinstance->resprints)) $this->resPrint .= $actionclassinstance->resprints; if (!empty($actionclassinstance->resprints)) $this->resPrint .= $actionclassinstance->resprints;
} }
// Generic hooks that return a string or array (printLeftBlock, formAddObjectLine, formBuilddocOptions, ...) // Generic hooks that return a string or array (printLeftBlock, formAddObjectLine, formBuilddocOptions, ...)
else { else {
// TODO. this test should be done into the method of hook by returning nothing // TODO. this test should be done into the method of hook by returning nothing
if (is_array($parameters) && !empty($parameters['special_code']) && $parameters['special_code'] > 3 && $parameters['special_code'] != $actionclassinstance->module_number) continue; if (is_array($parameters) && !empty($parameters['special_code']) && $parameters['special_code'] > 3 && $parameters['special_code'] != $actionclassinstance->module_number) continue;
//dol_syslog("Call method ".$method." of class ".get_class($actionclassinstance).", module=".$module.", hooktype=".$hooktype, LOG_DEBUG); //dol_syslog("Call method ".$method." of class ".get_class($actionclassinstance).", module=".$module.", hooktype=".$hooktype, LOG_DEBUG);
$resaction = $actionclassinstance->$method($parameters, $object, $action, $this); // $object and $action can be changed by method ($object->id during creation for example or $action to go back to other action for example) $resaction = $actionclassinstance->$method($parameters, $object, $action, $this); // $object and $action can be changed by method ($object->id during creation for example or $action to go back to other action for example)
if (!empty($actionclassinstance->results) && is_array($actionclassinstance->results)) $this->resArray = array_merge($this->resArray, $actionclassinstance->results); if (!empty($actionclassinstance->results) && is_array($actionclassinstance->results)) $this->resArray = array_merge($this->resArray, $actionclassinstance->results);
if (!empty($actionclassinstance->resprints)) $this->resPrint .= $actionclassinstance->resprints; if (!empty($actionclassinstance->resprints)) $this->resPrint .= $actionclassinstance->resprints;
if (is_numeric($resaction) && $resaction < 0) if (is_numeric($resaction) && $resaction < 0)
{ {
$error++; $error++;
$this->error = $actionclassinstance->error; $this->errors = array_merge($this->errors, (array) $actionclassinstance->errors); $this->error = $actionclassinstance->error; $this->errors = array_merge($this->errors, (array) $actionclassinstance->errors);
dol_syslog("Error on hook module=".$module.", method ".$method.", class ".get_class($actionclassinstance).", hooktype=".$hooktype.(empty($this->error) ? '' : " ".$this->error).(empty($this->errors) ? '' : " ".join(",", $this->errors)), LOG_ERR); dol_syslog("Error on hook module=".$module.", method ".$method.", class ".get_class($actionclassinstance).", hooktype=".$hooktype.(empty($this->error) ? '' : " ".$this->error).(empty($this->errors) ? '' : " ".join(",", $this->errors)), LOG_ERR);
} }
// TODO dead code to remove (do not enable this, but fix hook instead): result must not be a string but an int. you must use $actionclassinstance->resprints to return a string // TODO dead code to remove (do not enable this, but fix hook instead): result must not be a string but an int. you must use $actionclassinstance->resprints to return a string
if (!is_array($resaction) && !is_numeric($resaction)) if (!is_array($resaction) && !is_numeric($resaction))
{ {
dol_syslog('Error: Bug into hook '.$method.' of module class '.get_class($actionclassinstance).'. Method must not return a string but an int (0=OK, 1=Replace, -1=KO) and set string into ->resprints', LOG_ERR); dol_syslog('Error: Bug into hook '.$method.' of module class '.get_class($actionclassinstance).'. Method must not return a string but an int (0=OK, 1=Replace, -1=KO) and set string into ->resprints', LOG_ERR);
if (empty($actionclassinstance->resprints)) { $this->resPrint .= $resaction; $resaction = 0; } if (empty($actionclassinstance->resprints)) { $this->resPrint .= $resaction; $resaction = 0; }
} }
} }
//print "After hook ".get_class($actionclassinstance)." method=".$method." hooktype=".$hooktype." results=".count($actionclassinstance->results)." resprints=".count($actionclassinstance->resprints)." resaction=".$resaction."<br>\n"; //print "After hook ".get_class($actionclassinstance)." method=".$method." hooktype=".$hooktype." results=".count($actionclassinstance->results)." resprints=".count($actionclassinstance->resprints)." resaction=".$resaction."<br>\n";
unset($actionclassinstance->results); unset($actionclassinstance->results);
unset($actionclassinstance->resprints); unset($actionclassinstance->resprints);
} }
} }
} }
return ($error ? -1 : $resaction); return ($error ? -1 : $resaction);
} }
} }

File diff suppressed because it is too large Load Diff

View File

@ -146,30 +146,30 @@ function ecm_prepare_head_fm($object)
*/ */
function ecm_admin_prepare_head() function ecm_admin_prepare_head()
{ {
global $langs, $conf; global $langs, $conf;
$langs->load("ecm"); $langs->load("ecm");
$h = 0; $h = 0;
$head = array(); $head = array();
$head[$h][0] = DOL_URL_ROOT."/admin/ecm.php"; $head[$h][0] = DOL_URL_ROOT."/admin/ecm.php";
$head[$h][1] = $langs->trans("Setup"); $head[$h][1] = $langs->trans("Setup");
$head[$h][2] = 'ecm'; $head[$h][2] = 'ecm';
$h++; $h++;
$head[$h][0] = DOL_URL_ROOT.'/admin/ecm_files_extrafields.php'; $head[$h][0] = DOL_URL_ROOT.'/admin/ecm_files_extrafields.php';
$head[$h][1] = $langs->trans("ExtraFieldsEcmFiles"); $head[$h][1] = $langs->trans("ExtraFieldsEcmFiles");
$head[$h][2] = 'attributes_ecm_files'; $head[$h][2] = 'attributes_ecm_files';
$h++; $h++;
$head[$h][0] = DOL_URL_ROOT.'/admin/ecm_directories_extrafields.php'; $head[$h][0] = DOL_URL_ROOT.'/admin/ecm_directories_extrafields.php';
$head[$h][1] = $langs->trans("ExtraFieldsEcmDirectories"); $head[$h][1] = $langs->trans("ExtraFieldsEcmDirectories");
$head[$h][2] = 'attributes_ecm_directories'; $head[$h][2] = 'attributes_ecm_directories';
$h++; $h++;
complete_head_from_modules($conf, $langs, null, $head, $h, 'ecm_admin'); complete_head_from_modules($conf, $langs, null, $head, $h, 'ecm_admin');
complete_head_from_modules($conf, $langs, null, $head, $h, 'ecm_admin', 'remove'); complete_head_from_modules($conf, $langs, null, $head, $h, 'ecm_admin', 'remove');
return $head; return $head;
} }

View File

@ -1533,7 +1533,7 @@ function dol_add_file_process($upload_dir, $allowoverwrite = 0, $donotupdatesess
$nbok = 0; $nbok = 0;
for ($i = 0; $i < $nbfile; $i++) for ($i = 0; $i < $nbfile; $i++)
{ {
if (empty($TFile['name'][$i])) continue; // For example, when submitting a form with no file name if (empty($TFile['name'][$i])) continue; // For example, when submitting a form with no file name
// Define $destfull (path to file including filename) and $destfile (only filename) // Define $destfull (path to file including filename) and $destfile (only filename)
$destfull = $upload_dir."/".$TFile['name'][$i]; $destfull = $upload_dir."/".$TFile['name'][$i];
@ -2053,7 +2053,7 @@ function dol_uncompress($inputfile, $outputdir)
for ($i = 0; $i < $zip->numFiles; $i++) { for ($i = 0; $i < $zip->numFiles; $i++) {
if (preg_match('/\.\./', $zip->getNameIndex($i))) { if (preg_match('/\.\./', $zip->getNameIndex($i))) {
dol_syslog("Warning: Try to unzip a file with a transversal path ".$zip->getNameIndex($i), LOG_WARNING); dol_syslog("Warning: Try to unzip a file with a transversal path ".$zip->getNameIndex($i), LOG_WARNING);
continue; // Discard the file continue; // Discard the file
} }
$zip->extractTo($outputdir.'/', array($zip->getNameIndex($i))); $zip->extractTo($outputdir.'/', array($zip->getNameIndex($i)));
} }

View File

@ -84,8 +84,8 @@ function getEntity($element, $shared = 1, $currentobject = null)
// fix different element names (France to English) // fix different element names (France to English)
switch ($element) { switch ($element) {
case 'contrat': $element = 'contract'; break; // "/contrat/class/contrat.class.php" case 'contrat': $element = 'contract'; break; // "/contrat/class/contrat.class.php"
case 'order_supplier': $element = 'supplier_order'; break; // "/fourn/class/fournisseur.commande.class.php" case 'order_supplier': $element = 'supplier_order'; break; // "/fourn/class/fournisseur.commande.class.php"
} }
if (is_object($mc)) if (is_object($mc))
@ -1404,7 +1404,7 @@ function dol_get_fiche_head($links = array(), $active = '', $title = '', $notab
$tabsname = $moretabssuffix; $tabsname = $moretabssuffix;
if (empty($tabsname)) { $tabsname = str_replace("@", "", $picto); } if (empty($tabsname)) { $tabsname = str_replace("@", "", $picto); }
$out .= '<div id="moretabs'.$tabsname.'" class="inline-block tabsElem">'; $out .= '<div id="moretabs'.$tabsname.'" class="inline-block tabsElem">';
$out .= '<a href="#" class="tab moretab inline-block tabunactive">'.$langs->trans("More").'... ('.$nbintab.')</a>'; // Do not use "reposition" class in the "More". $out .= '<a href="#" class="tab moretab inline-block tabunactive">'.$langs->trans("More").'... ('.$nbintab.')</a>'; // Do not use "reposition" class in the "More".
$out .= '<div id="moretabsList'.$tabsname.'" style="width: '.$widthofpopup.'px; position: absolute; '.$left.': -999em; text-align: '.$left.'; margin:0px; padding:2px; z-index:10;">'; $out .= '<div id="moretabsList'.$tabsname.'" style="width: '.$widthofpopup.'px; position: absolute; '.$left.': -999em; text-align: '.$left.'; margin:0px; padding:2px; z-index:10;">';
$out .= $outmore; $out .= $outmore;
$out .= '</div>'; $out .= '</div>';
@ -1415,7 +1415,7 @@ function dol_get_fiche_head($links = array(), $active = '', $title = '', $notab
$out .= "$('#moretabs".$tabsname."').mouseenter( function() { $out .= "$('#moretabs".$tabsname."').mouseenter( function() {
var x = this.offsetLeft, y = this.offsetTop; var x = this.offsetLeft, y = this.offsetTop;
console.log('mouseenter ".$left." x='+x+' y='+y+' window.innerWidth='+window.innerWidth); console.log('mouseenter ".$left." x='+x+' y='+y+' window.innerWidth='+window.innerWidth);
if ((window.innerWidth - x) < ".($widthofpopup+10).") { if ((window.innerWidth - x) < ".($widthofpopup + 10).") {
$('#moretabsList".$tabsname."').css('".$right."','8px'); $('#moretabsList".$tabsname."').css('".$right."','8px');
} }
$('#moretabsList".$tabsname."').css('".$left."','auto'); $('#moretabsList".$tabsname."').css('".$left."','auto');
@ -2808,7 +2808,7 @@ function getUserRemoteIP()
$ip = $_SERVER['HTTP_CLIENT_IP']; // value is clean here $ip = $_SERVER['HTTP_CLIENT_IP']; // value is clean here
} }
} else { } else {
$ip = $_SERVER['HTTP_X_FORWARDED_FOR']; // value is clean here $ip = $_SERVER['HTTP_X_FORWARDED_FOR']; // value is clean here
} }
return $ip; return $ip;
} }
@ -4048,7 +4048,7 @@ function dol_print_error($db = '', $error = '', $errors = null)
} }
// Return a http error code if possible // Return a http error code if possible
if (! headers_sent()) { if (!headers_sent()) {
http_response_code(500); http_response_code(500);
} }
@ -7833,7 +7833,7 @@ function natural_search($fields, $value, $mode = 0, $nofirstand = 0)
$numnewcrit = price2num($newcrit); $numnewcrit = price2num($newcrit);
if (is_numeric($numnewcrit)) if (is_numeric($numnewcrit))
{ {
$newres .= ($i2 > 0 ? ' OR ' : '').$field.' '.$operator.' '.$db->sanitize($numnewcrit); // should be a numeric $newres .= ($i2 > 0 ? ' OR ' : '').$field.' '.$operator.' '.$db->sanitize($numnewcrit); // should be a numeric
} else { } else {
$newres .= ($i2 > 0 ? ' OR ' : '').'1 = 2'; // force false $newres .= ($i2 > 0 ? ' OR ' : '').'1 = 2'; // force false
} }
@ -7841,7 +7841,7 @@ function natural_search($fields, $value, $mode = 0, $nofirstand = 0)
} }
} elseif ($mode == 2 || $mode == -2) } elseif ($mode == 2 || $mode == -2)
{ {
$crit = preg_replace('/[^0-9,]/', '', $crit); // ID are always integer $crit = preg_replace('/[^0-9,]/', '', $crit); // ID are always integer
$newres .= ($i2 > 0 ? ' OR ' : '').$field." ".($mode == -2 ? 'NOT ' : ''); $newres .= ($i2 > 0 ? ' OR ' : '').$field." ".($mode == -2 ? 'NOT ' : '');
$newres .= $crit ? "IN (".$db->sanitize($db->escape($crit)).")" : "IN (0)"; $newres .= $crit ? "IN (".$db->sanitize($db->escape($crit)).")" : "IN (0)";
if ($mode == -2) $newres .= ' OR '.$field.' IS NULL'; if ($mode == -2) $newres .= ' OR '.$field.' IS NULL';
@ -8979,8 +8979,8 @@ function readfileLowMemory($fullpath_original_file_osencoded, $method = -1)
if ($method == -1) { if ($method == -1) {
$method = 0; $method = 0;
if (! empty($conf->global->MAIN_FORCE_READFILE_WITH_FREAD)) $method = 1; if (!empty($conf->global->MAIN_FORCE_READFILE_WITH_FREAD)) $method = 1;
if (! empty($conf->global->MAIN_FORCE_READFILE_WITH_STREAM_COPY)) $method = 2; if (!empty($conf->global->MAIN_FORCE_READFILE_WITH_STREAM_COPY)) $method = 2;
} }
// Be sure we don't have output buffering enabled to have readfile working correctly // Be sure we don't have output buffering enabled to have readfile working correctly

View File

@ -29,30 +29,30 @@
function payment_prepare_head(Paiement $object) function payment_prepare_head(Paiement $object)
{ {
global $langs, $conf; global $langs, $conf;
$h = 0; $h = 0;
$head = array(); $head = array();
$head[$h][0] = DOL_URL_ROOT.'/compta/paiement/card.php?id='.$object->id; $head[$h][0] = DOL_URL_ROOT.'/compta/paiement/card.php?id='.$object->id;
$head[$h][1] = $langs->trans("Payment"); $head[$h][1] = $langs->trans("Payment");
$head[$h][2] = 'payment'; $head[$h][2] = 'payment';
$h++; $h++;
// Show more tabs from modules // Show more tabs from modules
// Entries must be declared in modules descriptor with line // Entries must be declared in modules descriptor with line
// $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
// $this->tabs = array('entity:-tabname); to remove a tab // $this->tabs = array('entity:-tabname); to remove a tab
complete_head_from_modules($conf, $langs, $object, $head, $h, 'payment'); complete_head_from_modules($conf, $langs, $object, $head, $h, 'payment');
$head[$h][0] = DOL_URL_ROOT.'/compta/paiement/info.php?id='.$object->id; $head[$h][0] = DOL_URL_ROOT.'/compta/paiement/info.php?id='.$object->id;
$head[$h][1] = $langs->trans("Info"); $head[$h][1] = $langs->trans("Info");
$head[$h][2] = 'info'; $head[$h][2] = 'info';
$h++; $h++;
complete_head_from_modules($conf, $langs, $object, $head, $h, 'payment', 'remove'); complete_head_from_modules($conf, $langs, $object, $head, $h, 'payment', 'remove');
return $head; return $head;
} }
/** /**
@ -64,30 +64,30 @@ function payment_prepare_head(Paiement $object)
*/ */
function bankline_prepare_head($id) function bankline_prepare_head($id)
{ {
global $langs, $conf; global $langs, $conf;
$h = 0; $h = 0;
$head = array(); $head = array();
$head[$h][0] = DOL_URL_ROOT.'/compta/bank/line.php?rowid='.$id; $head[$h][0] = DOL_URL_ROOT.'/compta/bank/line.php?rowid='.$id;
$head[$h][1] = $langs->trans('BankTransaction'); $head[$h][1] = $langs->trans('BankTransaction');
$head[$h][2] = 'bankline'; $head[$h][2] = 'bankline';
$h++; $h++;
// Show more tabs from modules // Show more tabs from modules
// Entries must be declared in modules descriptor with line // Entries must be declared in modules descriptor with line
// $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
// $this->tabs = array('entity:-tabname); to remove a tab // $this->tabs = array('entity:-tabname); to remove a tab
complete_head_from_modules($conf, $langs, null, $head, $h, 'bankline'); complete_head_from_modules($conf, $langs, null, $head, $h, 'bankline');
$head[$h][0] = DOL_URL_ROOT.'/compta/bank/info.php?rowid='.$id; $head[$h][0] = DOL_URL_ROOT.'/compta/bank/info.php?rowid='.$id;
$head[$h][1] = $langs->trans("Info"); $head[$h][1] = $langs->trans("Info");
$head[$h][2] = 'info'; $head[$h][2] = 'info';
$h++; $h++;
complete_head_from_modules($conf, $langs, null, $head, $h, 'bankline', 'remove'); complete_head_from_modules($conf, $langs, null, $head, $h, 'bankline', 'remove');
return $head; return $head;
} }
/** /**
@ -109,11 +109,11 @@ function payment_supplier_prepare_head(Paiement $object)
$head[$h][2] = 'payment'; $head[$h][2] = 'payment';
$h++; $h++;
// Show more tabs from modules // Show more tabs from modules
// Entries must be declared in modules descriptor with line // Entries must be declared in modules descriptor with line
// $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
// $this->tabs = array('entity:-tabname); to remove a tab // $this->tabs = array('entity:-tabname); to remove a tab
complete_head_from_modules($conf, $langs, $object, $head, $h, 'payment_supplier'); complete_head_from_modules($conf, $langs, $object, $head, $h, 'payment_supplier');
$head[$h][0] = DOL_URL_ROOT.'/fourn/paiement/info.php?id='.$object->id; $head[$h][0] = DOL_URL_ROOT.'/fourn/paiement/info.php?id='.$object->id;
$head[$h][1] = $langs->trans('Info'); $head[$h][1] = $langs->trans('Info');
@ -170,7 +170,7 @@ function showOnlinePaymentUrl($type, $ref)
global $langs; global $langs;
// Load translation files required by the page // Load translation files required by the page
$langs->loadLangs(array('payment', 'stripe')); $langs->loadLangs(array('payment', 'stripe'));
$servicename = $langs->transnoentitiesnoconv('Online'); $servicename = $langs->transnoentitiesnoconv('Online');
@ -194,7 +194,7 @@ function showOnlinePaymentUrl($type, $ref)
*/ */
function getOnlinePaymentUrl($mode, $type, $ref = '', $amount = '9.99', $freetag = 'your_tag', $localorexternal = 0) function getOnlinePaymentUrl($mode, $type, $ref = '', $amount = '9.99', $freetag = 'your_tag', $localorexternal = 0)
{ {
global $conf, $dolibarr_main_url_root; global $conf, $dolibarr_main_url_root;
$ref = str_replace(' ', '', $ref); $ref = str_replace(' ', '', $ref);
$out = ''; $out = '';
@ -209,7 +209,7 @@ function getOnlinePaymentUrl($mode, $type, $ref = '', $amount = '9.99', $freetag
if ($type == 'free') if ($type == 'free')
{ {
$out = $urltouse.'/public/payment/newpayment.php?amount='.($mode ? '<font color="#666666">' : '').$amount.($mode ? '</font>' : '').'&tag='.($mode ? '<font color="#666666">' : '').$freetag.($mode ? '</font>' : ''); $out = $urltouse.'/public/payment/newpayment.php?amount='.($mode ? '<font color="#666666">' : '').$amount.($mode ? '</font>' : '').'&tag='.($mode ? '<font color="#666666">' : '').$freetag.($mode ? '</font>' : '');
if (!empty($conf->global->PAYMENT_SECURITY_TOKEN)) if (!empty($conf->global->PAYMENT_SECURITY_TOKEN))
{ {
if (empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) $out .= '&securekey='.$conf->global->PAYMENT_SECURITY_TOKEN; if (empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) $out .= '&securekey='.$conf->global->PAYMENT_SECURITY_TOKEN;
@ -218,7 +218,7 @@ function getOnlinePaymentUrl($mode, $type, $ref = '', $amount = '9.99', $freetag
//if ($mode) $out.='&noidempotency=1'; //if ($mode) $out.='&noidempotency=1';
} elseif ($type == 'order') } elseif ($type == 'order')
{ {
$out = $urltouse.'/public/payment/newpayment.php?source=order&ref='.($mode ? '<font color="#666666">' : ''); $out = $urltouse.'/public/payment/newpayment.php?source=order&ref='.($mode ? '<font color="#666666">' : '');
if ($mode == 1) $out .= 'order_ref'; if ($mode == 1) $out .= 'order_ref';
if ($mode == 0) $out .= urlencode($ref); if ($mode == 0) $out .= urlencode($ref);
$out .= ($mode ? '</font>' : ''); $out .= ($mode ? '</font>' : '');
@ -234,7 +234,7 @@ function getOnlinePaymentUrl($mode, $type, $ref = '', $amount = '9.99', $freetag
} }
} elseif ($type == 'invoice') } elseif ($type == 'invoice')
{ {
$out = $urltouse.'/public/payment/newpayment.php?source=invoice&ref='.($mode ? '<font color="#666666">' : ''); $out = $urltouse.'/public/payment/newpayment.php?source=invoice&ref='.($mode ? '<font color="#666666">' : '');
if ($mode == 1) $out .= 'invoice_ref'; if ($mode == 1) $out .= 'invoice_ref';
if ($mode == 0) $out .= urlencode($ref); if ($mode == 0) $out .= urlencode($ref);
$out .= ($mode ? '</font>' : ''); $out .= ($mode ? '</font>' : '');
@ -250,7 +250,7 @@ function getOnlinePaymentUrl($mode, $type, $ref = '', $amount = '9.99', $freetag
} }
} elseif ($type == 'contractline') } elseif ($type == 'contractline')
{ {
$out = $urltouse.'/public/payment/newpayment.php?source=contractline&ref='.($mode ? '<font color="#666666">' : ''); $out = $urltouse.'/public/payment/newpayment.php?source=contractline&ref='.($mode ? '<font color="#666666">' : '');
if ($mode == 1) $out .= 'contractline_ref'; if ($mode == 1) $out .= 'contractline_ref';
if ($mode == 0) $out .= urlencode($ref); if ($mode == 0) $out .= urlencode($ref);
$out .= ($mode ? '</font>' : ''); $out .= ($mode ? '</font>' : '');
@ -266,7 +266,7 @@ function getOnlinePaymentUrl($mode, $type, $ref = '', $amount = '9.99', $freetag
} }
} elseif ($type == 'member' || $type == 'membersubscription') } elseif ($type == 'member' || $type == 'membersubscription')
{ {
$out = $urltouse.'/public/payment/newpayment.php?source=membersubscription&ref='.($mode ? '<font color="#666666">' : ''); $out = $urltouse.'/public/payment/newpayment.php?source=membersubscription&ref='.($mode ? '<font color="#666666">' : '');
if ($mode == 1) $out .= 'member_ref'; if ($mode == 1) $out .= 'member_ref';
if ($mode == 0) $out .= urlencode($ref); if ($mode == 0) $out .= urlencode($ref);
$out .= ($mode ? '</font>' : ''); $out .= ($mode ? '</font>' : '');
@ -283,7 +283,7 @@ function getOnlinePaymentUrl($mode, $type, $ref = '', $amount = '9.99', $freetag
} }
if ($type == 'donation') if ($type == 'donation')
{ {
$out = $urltouse.'/public/payment/newpayment.php?source=donation&ref='.($mode ? '<font color="#666666">' : ''); $out = $urltouse.'/public/payment/newpayment.php?source=donation&ref='.($mode ? '<font color="#666666">' : '');
if ($mode == 1) $out .= 'donation_ref'; if ($mode == 1) $out .= 'donation_ref';
if ($mode == 0) $out .= urlencode($ref); if ($mode == 0) $out .= urlencode($ref);
$out .= ($mode ? '</font>' : ''); $out .= ($mode ? '</font>' : '');
@ -319,82 +319,82 @@ function getOnlinePaymentUrl($mode, $type, $ref = '', $amount = '9.99', $freetag
*/ */
function htmlPrintOnlinePaymentFooter($fromcompany, $langs, $addformmessage = 0, $suffix = '', $object = null) function htmlPrintOnlinePaymentFooter($fromcompany, $langs, $addformmessage = 0, $suffix = '', $object = null)
{ {
global $conf; global $conf;
// Juridical status // Juridical status
$line1 = ""; $line1 = "";
if ($fromcompany->forme_juridique_code) if ($fromcompany->forme_juridique_code)
{ {
$line1 .= ($line1 ? " - " : "").getFormeJuridiqueLabel($fromcompany->forme_juridique_code); $line1 .= ($line1 ? " - " : "").getFormeJuridiqueLabel($fromcompany->forme_juridique_code);
} }
// Capital // Capital
if ($fromcompany->capital) if ($fromcompany->capital)
{ {
$line1 .= ($line1 ? " - " : "").$langs->transnoentities("CapitalOf", $fromcompany->capital)." ".$langs->transnoentities("Currency".$conf->currency); $line1 .= ($line1 ? " - " : "").$langs->transnoentities("CapitalOf", $fromcompany->capital)." ".$langs->transnoentities("Currency".$conf->currency);
} }
// Prof Id 1 // Prof Id 1
if ($fromcompany->idprof1 && ($fromcompany->country_code != 'FR' || !$fromcompany->idprof2)) if ($fromcompany->idprof1 && ($fromcompany->country_code != 'FR' || !$fromcompany->idprof2))
{ {
$field = $langs->transcountrynoentities("ProfId1", $fromcompany->country_code); $field = $langs->transcountrynoentities("ProfId1", $fromcompany->country_code);
if (preg_match('/\((.*)\)/i', $field, $reg)) $field = $reg[1]; if (preg_match('/\((.*)\)/i', $field, $reg)) $field = $reg[1];
$line1 .= ($line1 ? " - " : "").$field.": ".$fromcompany->idprof1; $line1 .= ($line1 ? " - " : "").$field.": ".$fromcompany->idprof1;
} }
// Prof Id 2 // Prof Id 2
if ($fromcompany->idprof2) if ($fromcompany->idprof2)
{ {
$field = $langs->transcountrynoentities("ProfId2", $fromcompany->country_code); $field = $langs->transcountrynoentities("ProfId2", $fromcompany->country_code);
if (preg_match('/\((.*)\)/i', $field, $reg)) $field = $reg[1]; if (preg_match('/\((.*)\)/i', $field, $reg)) $field = $reg[1];
$line1 .= ($line1 ? " - " : "").$field.": ".$fromcompany->idprof2; $line1 .= ($line1 ? " - " : "").$field.": ".$fromcompany->idprof2;
} }
// Second line of company infos // Second line of company infos
$line2 = ""; $line2 = "";
// Prof Id 3 // Prof Id 3
if ($fromcompany->idprof3) if ($fromcompany->idprof3)
{ {
$field = $langs->transcountrynoentities("ProfId3", $fromcompany->country_code); $field = $langs->transcountrynoentities("ProfId3", $fromcompany->country_code);
if (preg_match('/\((.*)\)/i', $field, $reg)) $field = $reg[1]; if (preg_match('/\((.*)\)/i', $field, $reg)) $field = $reg[1];
$line2 .= ($line2 ? " - " : "").$field.": ".$fromcompany->idprof3; $line2 .= ($line2 ? " - " : "").$field.": ".$fromcompany->idprof3;
} }
// Prof Id 4 // Prof Id 4
if ($fromcompany->idprof4) if ($fromcompany->idprof4)
{ {
$field = $langs->transcountrynoentities("ProfId4", $fromcompany->country_code); $field = $langs->transcountrynoentities("ProfId4", $fromcompany->country_code);
if (preg_match('/\((.*)\)/i', $field, $reg)) $field = $reg[1]; if (preg_match('/\((.*)\)/i', $field, $reg)) $field = $reg[1];
$line2 .= ($line2 ? " - " : "").$field.": ".$fromcompany->idprof4; $line2 .= ($line2 ? " - " : "").$field.": ".$fromcompany->idprof4;
} }
// IntraCommunautary VAT // IntraCommunautary VAT
if ($fromcompany->tva_intra != '') if ($fromcompany->tva_intra != '')
{ {
$line2 .= ($line2 ? " - " : "").$langs->transnoentities("VATIntraShort").": ".$fromcompany->tva_intra; $line2 .= ($line2 ? " - " : "").$langs->transnoentities("VATIntraShort").": ".$fromcompany->tva_intra;
} }
print '<br>'; print '<br>';
print '<div class="center">'."\n"; print '<div class="center">'."\n";
if ($addformmessage) if ($addformmessage)
{ {
print '<!-- object = '.$object->element.' -->'; print '<!-- object = '.$object->element.' -->';
print '<br>'; print '<br>';
$parammessageform = 'ONLINE_PAYMENT_MESSAGE_FORM_'.$suffix; $parammessageform = 'ONLINE_PAYMENT_MESSAGE_FORM_'.$suffix;
if (!empty($conf->global->$parammessageform)) print $langs->transnoentities($conf->global->$parammessageform); if (!empty($conf->global->$parammessageform)) print $langs->transnoentities($conf->global->$parammessageform);
elseif (!empty($conf->global->ONLINE_PAYMENT_MESSAGE_FORM)) print $langs->transnoentities($conf->global->ONLINE_PAYMENT_MESSAGE_FORM); elseif (!empty($conf->global->ONLINE_PAYMENT_MESSAGE_FORM)) print $langs->transnoentities($conf->global->ONLINE_PAYMENT_MESSAGE_FORM);
// Add other message if VAT exists // Add other message if VAT exists
if ($object->total_vat != 0 || $object->total_tva != 0) if ($object->total_vat != 0 || $object->total_tva != 0)
{ {
$parammessageform = 'ONLINE_PAYMENT_MESSAGE_FORMIFVAT_'.$suffix; $parammessageform = 'ONLINE_PAYMENT_MESSAGE_FORMIFVAT_'.$suffix;
if (!empty($conf->global->$parammessageform)) print $langs->transnoentities($conf->global->$parammessageform); if (!empty($conf->global->$parammessageform)) print $langs->transnoentities($conf->global->$parammessageform);
elseif (!empty($conf->global->ONLINE_PAYMENT_MESSAGE_FORMIFVAT)) print $langs->transnoentities($conf->global->ONLINE_PAYMENT_MESSAGE_FORMIFVAT); elseif (!empty($conf->global->ONLINE_PAYMENT_MESSAGE_FORMIFVAT)) print $langs->transnoentities($conf->global->ONLINE_PAYMENT_MESSAGE_FORMIFVAT);
} }
} }
print '<font style="font-size: 10px;"><br><hr>'."\n"; print '<font style="font-size: 10px;"><br><hr>'."\n";
print $fromcompany->name.'<br>'; print $fromcompany->name.'<br>';
print $line1; print $line1;
if (strlen($line1.$line2) > 50) print '<br>'; if (strlen($line1.$line2) > 50) print '<br>';
else print ' - '; else print ' - ';
print $line2; print $line2;
print '</font></div>'."\n"; print '</font></div>'."\n";
} }

View File

@ -122,7 +122,7 @@ function pdf_getInstance($format = '', $metric = 'mm', $pagetype = 'P')
define('K_SMALL_RATIO', 2 / 3); define('K_SMALL_RATIO', 2 / 3);
define('K_THAI_TOPCHARS', true); define('K_THAI_TOPCHARS', true);
define('K_TCPDF_CALLS_IN_HTML', true); define('K_TCPDF_CALLS_IN_HTML', true);
if (! empty($conf->global->TCPDF_THROW_ERRORS_INSTEAD_OF_DIE)) { if (!empty($conf->global->TCPDF_THROW_ERRORS_INSTEAD_OF_DIE)) {
define('K_TCPDF_THROW_EXCEPTION_ERROR', true); define('K_TCPDF_THROW_EXCEPTION_ERROR', true);
} else { } else {
define('K_TCPDF_THROW_EXCEPTION_ERROR', false); define('K_TCPDF_THROW_EXCEPTION_ERROR', false);
@ -2140,11 +2140,11 @@ function pdf_getLinkedObjects($object, $outputlangs)
if (empty($object->linkedObjects['commande']) && $object->element != 'commande') // There is not already a link to order and object is not the order, so we show also info with order if (empty($object->linkedObjects['commande']) && $object->element != 'commande') // There is not already a link to order and object is not the order, so we show also info with order
{ {
$elementobject->fetchObjectLinked(null, '', null, '', 'OR', 1, 'sourcetype', 0); $elementobject->fetchObjectLinked(null, '', null, '', 'OR', 1, 'sourcetype', 0);
if (! empty($elementobject->linkedObjectsIds['commande'])){ if (!empty($elementobject->linkedObjectsIds['commande'])) {
include_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; include_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php';
$order = new Commande($db); $order = new Commande($db);
$ret = $order->fetch(reset($elementobject->linkedObjectsIds['commande'])); $ret = $order->fetch(reset($elementobject->linkedObjectsIds['commande']));
if ($ret < 1) { $order=null; } if ($ret < 1) { $order = null; }
} }
} }
if (!is_object($order)) if (!is_object($order))

View File

@ -265,16 +265,16 @@ class modCommande extends DolibarrModules
if (empty($user->rights->societe->client->voir)) $this->export_sql_end[$r] .= ' AND sc.fk_user = '.(empty($user) ? 0 : $user->id); if (empty($user->rights->societe->client->voir)) $this->export_sql_end[$r] .= ' AND sc.fk_user = '.(empty($user) ? 0 : $user->id);
// Imports // Imports
//-------- //--------
$r=0; $r = 0;
//Import Order Header //Import Order Header
$r++; $r++;
$this->import_code[$r] = 'commande_' . $r; $this->import_code[$r] = 'commande_'.$r;
$this->import_label[$r] = 'Sales Orders'; $this->import_label[$r] = 'Sales Orders';
$this->import_icon[$r] = $this->picto; $this->import_icon[$r] = $this->picto;
$this->import_entities_array[$r] = []; $this->import_entities_array[$r] = [];
$this->import_tables_array[$r] = ['c' => MAIN_DB_PREFIX . 'commande', 'extra' => MAIN_DB_PREFIX . 'commande_extrafields']; $this->import_tables_array[$r] = ['c' => MAIN_DB_PREFIX.'commande', 'extra' => MAIN_DB_PREFIX.'commande_extrafields'];
$this->import_tables_creator_array[$r] = ['c' => 'fk_user_author']; // Fields to store import user id $this->import_tables_creator_array[$r] = ['c' => 'fk_user_author']; // Fields to store import user id
$this->import_fields_array[$r] = [ $this->import_fields_array[$r] = [
'c.ref' => 'Document Ref*', 'c.ref' => 'Document Ref*',
'c.ref_client' => 'RefCustomer', 'c.ref_client' => 'RefCustomer',
@ -299,7 +299,7 @@ class modCommande extends DolibarrModules
'c.model_pdf' => 'Model' 'c.model_pdf' => 'Model'
]; ];
if (! empty($conf->multicurrency->enabled)) { if (!empty($conf->multicurrency->enabled)) {
$this->import_fields_array[$r]['c.multicurrency_code'] = 'Currency'; $this->import_fields_array[$r]['c.multicurrency_code'] = 'Currency';
$this->import_fields_array[$r]['c.multicurrency_tx'] = 'CurrencyRate'; $this->import_fields_array[$r]['c.multicurrency_tx'] = 'CurrencyRate';
$this->import_fields_array[$r]['c.multicurrency_total_ht'] = 'MulticurrencyAmountHT'; $this->import_fields_array[$r]['c.multicurrency_total_ht'] = 'MulticurrencyAmountHT';
@ -309,23 +309,23 @@ class modCommande extends DolibarrModules
// Add extra fields // Add extra fields
$import_extrafield_sample = []; $import_extrafield_sample = [];
$sql = "SELECT name, label, fieldrequired FROM " . MAIN_DB_PREFIX . "extrafields WHERE elementtype = 'commande' AND entity IN (0, " . $conf->entity . ")"; $sql = "SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'commande' AND entity IN (0, ".$conf->entity.")";
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
if ($resql) { if ($resql) {
while ($obj = $this->db->fetch_object($resql)) { while ($obj = $this->db->fetch_object($resql)) {
$fieldname = 'extra.' . $obj->name; $fieldname = 'extra.'.$obj->name;
$fieldlabel = ucfirst($obj->label); $fieldlabel = ucfirst($obj->label);
$this->import_fields_array[$r][$fieldname] = $fieldlabel . ($obj->fieldrequired ? '*' : ''); $this->import_fields_array[$r][$fieldname] = $fieldlabel.($obj->fieldrequired ? '*' : '');
$import_extrafield_sample[$fieldname] = $fieldlabel; $import_extrafield_sample[$fieldname] = $fieldlabel;
} }
} }
// End add extra fields // End add extra fields
$this->import_fieldshidden_array[$r] = ['extra.fk_object' => 'lastrowid-' . MAIN_DB_PREFIX . 'commande']; $this->import_fieldshidden_array[$r] = ['extra.fk_object' => 'lastrowid-'.MAIN_DB_PREFIX.'commande'];
$this->import_regex_array[$r] = [ $this->import_regex_array[$r] = [
'c.ref' => '(CPV\d{4}-\d{4}|CO\d{4}-\d{4}|PROV.{1,32}$)', 'c.ref' => '(CPV\d{4}-\d{4}|CO\d{4}-\d{4}|PROV.{1,32}$)',
'c.multicurrency_code' => 'code@' . MAIN_DB_PREFIX . 'multicurrency' 'c.multicurrency_code' => 'code@'.MAIN_DB_PREFIX.'multicurrency'
]; ];
$this->import_updatekeys_array[$r] = ['c.ref' => 'Ref']; $this->import_updatekeys_array[$r] = ['c.ref' => 'Ref'];
@ -359,7 +359,7 @@ class modCommande extends DolibarrModules
$this->import_label[$r] = 'Order Details'; $this->import_label[$r] = 'Order Details';
$this->import_icon[$r] = $this->picto; $this->import_icon[$r] = $this->picto;
$this->import_entities_array[$r] = []; $this->import_entities_array[$r] = [];
$this->import_tables_array[$r] = ['cd' => MAIN_DB_PREFIX . 'commandedet', 'extra' => MAIN_DB_PREFIX . 'commandedet_extrafields']; $this->import_tables_array[$r] = ['cd' => MAIN_DB_PREFIX.'commandedet', 'extra' => MAIN_DB_PREFIX.'commandedet_extrafields'];
$this->import_fields_array[$r] = [ $this->import_fields_array[$r] = [
'cd.fk_commande' => 'Document Ref*', 'cd.fk_commande' => 'Document Ref*',
'cd.fk_parent_line' => 'PrParentLine', 'cd.fk_parent_line' => 'PrParentLine',
@ -382,7 +382,7 @@ class modCommande extends DolibarrModules
'cd.rang' => 'LinePosition' 'cd.rang' => 'LinePosition'
]; ];
if (! empty($conf->multicurrency->enabled)) { if (!empty($conf->multicurrency->enabled)) {
$this->import_fields_array[$r]['cd.multicurrency_code'] = 'Currency'; $this->import_fields_array[$r]['cd.multicurrency_code'] = 'Currency';
$this->import_fields_array[$r]['cd.multicurrency_subprice'] = 'CurrencyRate'; $this->import_fields_array[$r]['cd.multicurrency_subprice'] = 'CurrencyRate';
$this->import_fields_array[$r]['cd.multicurrency_total_ht'] = 'MulticurrencyAmountHT'; $this->import_fields_array[$r]['cd.multicurrency_total_ht'] = 'MulticurrencyAmountHT';
@ -391,22 +391,22 @@ class modCommande extends DolibarrModules
} }
// Add extra fields // Add extra fields
$sql="SELECT name, label, fieldrequired FROM " . MAIN_DB_PREFIX . "extrafields WHERE elementtype = 'commandedet' AND entity IN (0, " . $conf->entity . ")"; $sql = "SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'commandedet' AND entity IN (0, ".$conf->entity.")";
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
if ($resql) { if ($resql) {
while ($obj = $this->db->fetch_object($resql)) { while ($obj = $this->db->fetch_object($resql)) {
$fieldname = 'extra.' . $obj->name; $fieldname = 'extra.'.$obj->name;
$fieldlabel = ucfirst($obj->label); $fieldlabel = ucfirst($obj->label);
$this->import_fields_array[$r][$fieldname] = $fieldlabel . ($obj->fieldrequired ? '*' : ''); $this->import_fields_array[$r][$fieldname] = $fieldlabel.($obj->fieldrequired ? '*' : '');
} }
} }
// End add extra fields // End add extra fields
$this->import_fieldshidden_array[$r] = ['extra.fk_object' => 'lastrowid-' . MAIN_DB_PREFIX . 'commandedet']; $this->import_fieldshidden_array[$r] = ['extra.fk_object' => 'lastrowid-'.MAIN_DB_PREFIX.'commandedet'];
$this->import_regex_array[$r] = [ $this->import_regex_array[$r] = [
'cd.product_type' => '[0|1]$', 'cd.product_type' => '[0|1]$',
'cd.fk_product' => 'rowid@' . MAIN_DB_PREFIX . 'product', 'cd.fk_product' => 'rowid@'.MAIN_DB_PREFIX.'product',
'cd.multicurrency_code' => 'code@' . MAIN_DB_PREFIX . 'multicurrency' 'cd.multicurrency_code' => 'code@'.MAIN_DB_PREFIX.'multicurrency'
]; ];
$this->import_updatekeys_array[$r] = ['cd.fk_commande' => 'Sales Order Id', 'cd.fk_product' => 'Product Id']; $this->import_updatekeys_array[$r] = ['cd.fk_commande' => 'Sales Order Id', 'cd.fk_product' => 'Product Id'];
$this->import_convertvalue_array[$r] = [ $this->import_convertvalue_array[$r] = [

View File

@ -63,12 +63,12 @@ class modFournisseur extends DolibarrModules
// Data directories to create when module is enabled // Data directories to create when module is enabled
$this->dirs = array( $this->dirs = array(
"/fournisseur/temp", "/fournisseur/temp",
"/fournisseur/commande", "/fournisseur/commande",
"/fournisseur/commande/temp", "/fournisseur/commande/temp",
"/fournisseur/facture", "/fournisseur/facture",
"/fournisseur/facture/temp" "/fournisseur/facture/temp"
); );
// Dependencies // Dependencies
$this->depends = array("modSociete"); $this->depends = array("modSociete");
@ -299,7 +299,7 @@ class modFournisseur extends DolibarrModules
'p.ref'=>'ProductRef', 'p.label'=>'ProductLabel', 'p.accountancy_code_buy'=>'ProductAccountancyBuyCode', 'project.rowid'=>'ProjectId', 'p.ref'=>'ProductRef', 'p.label'=>'ProductLabel', 'p.accountancy_code_buy'=>'ProductAccountancyBuyCode', 'project.rowid'=>'ProjectId',
'project.ref'=>'ProjectRef', 'project.title'=>'ProjectLabel' 'project.ref'=>'ProjectRef', 'project.title'=>'ProjectLabel'
); );
if (! empty($conf->multicurrency->enabled)) if (!empty($conf->multicurrency->enabled))
{ {
$this->export_fields_array[$r]['f.multicurrency_code'] = 'Currency'; $this->export_fields_array[$r]['f.multicurrency_code'] = 'Currency';
$this->export_fields_array[$r]['f.multicurrency_tx'] = 'CurrencyRate'; $this->export_fields_array[$r]['f.multicurrency_tx'] = 'CurrencyRate';
@ -434,7 +434,7 @@ class modFournisseur extends DolibarrModules
'f.fk_statut'=>'InvoiceStatus', 'f.note_public'=>"InvoiceNote", 'p.rowid'=>'PaymentId', 'pf.amount'=>'AmountPayment', 'f.fk_statut'=>'InvoiceStatus', 'f.note_public'=>"InvoiceNote", 'p.rowid'=>'PaymentId', 'pf.amount'=>'AmountPayment',
'p.datep'=>'DatePayment', 'p.num_paiement'=>'PaymentNumber', 'p.fk_bank'=>'IdTransaction', 'project.rowid'=>'ProjectId', 'project.ref'=>'ProjectRef', 'project.title'=>'ProjectLabel' 'p.datep'=>'DatePayment', 'p.num_paiement'=>'PaymentNumber', 'p.fk_bank'=>'IdTransaction', 'project.rowid'=>'ProjectId', 'project.ref'=>'ProjectRef', 'project.title'=>'ProjectLabel'
); );
if (! empty($conf->multicurrency->enabled)) if (!empty($conf->multicurrency->enabled))
{ {
$this->export_fields_array[$r]['f.multicurrency_code'] = 'Currency'; $this->export_fields_array[$r]['f.multicurrency_code'] = 'Currency';
$this->export_fields_array[$r]['f.multicurrency_tx'] = 'CurrencyRate'; $this->export_fields_array[$r]['f.multicurrency_tx'] = 'CurrencyRate';
@ -528,7 +528,7 @@ class modFournisseur extends DolibarrModules
'fd.total_tva'=>"LineTotalVAT", 'fd.product_type'=>'TypeOfLineServiceOrProduct', 'fd.ref'=>'RefSupplier', 'fd.fk_product'=>'ProductId', 'fd.total_tva'=>"LineTotalVAT", 'fd.product_type'=>'TypeOfLineServiceOrProduct', 'fd.ref'=>'RefSupplier', 'fd.fk_product'=>'ProductId',
'p.ref'=>'ProductRef', 'p.label'=>'ProductLabel', 'project.rowid'=>'ProjectId', 'project.ref'=>'ProjectRef', 'project.title'=>'ProjectLabel' 'p.ref'=>'ProductRef', 'p.label'=>'ProductLabel', 'project.rowid'=>'ProjectId', 'project.ref'=>'ProjectRef', 'project.title'=>'ProjectLabel'
); );
if (! empty($conf->multicurrency->enabled)) if (!empty($conf->multicurrency->enabled))
{ {
$this->export_fields_array[$r]['f.multicurrency_code'] = 'Currency'; $this->export_fields_array[$r]['f.multicurrency_code'] = 'Currency';
$this->export_fields_array[$r]['f.multicurrency_tx'] = 'CurrencyRate'; $this->export_fields_array[$r]['f.multicurrency_tx'] = 'CurrencyRate';
@ -654,15 +654,15 @@ class modFournisseur extends DolibarrModules
//Import Supplier Invoice //Import Supplier Invoice
//-------- //--------
$r=0; $r = 0;
$r++; $r++;
$this->import_code[$r] = $this->rights_class . '_' . $r; $this->import_code[$r] = $this->rights_class.'_'.$r;
$this->import_label[$r] = "Supplier Invoice"; // Translation key $this->import_label[$r] = "Supplier Invoice"; // Translation key
$this->import_icon[$r] = $this->picto; $this->import_icon[$r] = $this->picto;
$this->import_entities_array[$r] = []; // We define here only fields that use another icon that the one defined into import_icon $this->import_entities_array[$r] = []; // We define here only fields that use another icon that the one defined into import_icon
$this->import_tables_array[$r] = ['f' => MAIN_DB_PREFIX . 'facture_fourn', 'extra' => MAIN_DB_PREFIX . 'facture_fourn_extrafields']; $this->import_tables_array[$r] = ['f' => MAIN_DB_PREFIX.'facture_fourn', 'extra' => MAIN_DB_PREFIX.'facture_fourn_extrafields'];
$this->import_tables_creator_array[$r] = ['f' => 'fk_user_author']; // Fields to store import user id $this->import_tables_creator_array[$r] = ['f' => 'fk_user_author']; // Fields to store import user id
$this->import_fields_array[$r] = [ $this->import_fields_array[$r] = [
'f.ref' => 'InvoiceRef*', 'f.ref' => 'InvoiceRef*',
'f.ref_supplier' => 'RefSupplier', 'f.ref_supplier' => 'RefSupplier',
@ -697,19 +697,19 @@ class modFournisseur extends DolibarrModules
} }
// Add extra fields // Add extra fields
$import_extrafield_sample = []; $import_extrafield_sample = [];
$sql = "SELECT name, label, fieldrequired FROM " . MAIN_DB_PREFIX . "extrafields WHERE elementtype = 'facture_fourn' AND entity IN (0, " . $conf->entity . ")"; $sql = "SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'facture_fourn' AND entity IN (0, ".$conf->entity.")";
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
if ($resql) { if ($resql) {
while ($obj = $this->db->fetch_object($resql)) { while ($obj = $this->db->fetch_object($resql)) {
$fieldname = 'extra.' . $obj->name; $fieldname = 'extra.'.$obj->name;
$fieldlabel = ucfirst($obj->label); $fieldlabel = ucfirst($obj->label);
$this->import_fields_array[$r][$fieldname] = $fieldlabel . ($obj->fieldrequired ? '*' : ''); $this->import_fields_array[$r][$fieldname] = $fieldlabel.($obj->fieldrequired ? '*' : '');
$import_extrafield_sample[$fieldname] = $fieldlabel; $import_extrafield_sample[$fieldname] = $fieldlabel;
} }
} }
// End add extra fields // End add extra fields
$this->import_fieldshidden_array[$r] = ['extra.fk_object' => 'lastrowid-' . MAIN_DB_PREFIX . 'facture_fourn']; $this->import_fieldshidden_array[$r] = ['extra.fk_object' => 'lastrowid-'.MAIN_DB_PREFIX.'facture_fourn'];
$this->import_regex_array[$r] = ['f.ref' => '(SI\d{4}-\d{4}|PROV.{1,32}$)', 'f.multicurrency_code' => 'code@' . MAIN_DB_PREFIX . 'multicurrency']; $this->import_regex_array[$r] = ['f.ref' => '(SI\d{4}-\d{4}|PROV.{1,32}$)', 'f.multicurrency_code' => 'code@'.MAIN_DB_PREFIX.'multicurrency'];
$import_sample = [ $import_sample = [
'f.ref' => '(PROV001)', 'f.ref' => '(PROV001)',
'f.ref_supplier' => 'Supplier1', 'f.ref_supplier' => 'Supplier1',
@ -751,10 +751,10 @@ class modFournisseur extends DolibarrModules
//Import Supplier Invoice Lines //Import Supplier Invoice Lines
$r++; $r++;
$this->import_code[$r] = $this->rights_class.'_'.$r; $this->import_code[$r] = $this->rights_class.'_'.$r;
$this->import_label[$r] = "Supplier Invoice Lines"; // Translation key $this->import_label[$r] = "Supplier Invoice Lines"; // Translation key
$this->import_icon[$r] = $this->picto; $this->import_icon[$r] = $this->picto;
$this->import_entities_array[$r] = []; // We define here only fields that use another icon that the one defined into import_icon $this->import_entities_array[$r] = []; // We define here only fields that use another icon that the one defined into import_icon
$this->import_tables_array[$r] = ['fd' => MAIN_DB_PREFIX . 'facture_fourn_det', 'extra' => MAIN_DB_PREFIX . 'facture_fourn_det_extrafields']; $this->import_tables_array[$r] = ['fd' => MAIN_DB_PREFIX.'facture_fourn_det', 'extra' => MAIN_DB_PREFIX.'facture_fourn_det_extrafields'];
$this->import_fields_array[$r] = [ $this->import_fields_array[$r] = [
'fd.fk_facture_fourn' => 'InvoiceRef*', 'fd.fk_facture_fourn' => 'InvoiceRef*',
'fd.fk_parent_line' => 'FacParentLine', 'fd.fk_parent_line' => 'FacParentLine',
@ -784,19 +784,19 @@ class modFournisseur extends DolibarrModules
} }
// Add extra fields // Add extra fields
$import_extrafield_sample = []; $import_extrafield_sample = [];
$sql = "SELECT name, label, fieldrequired FROM " . MAIN_DB_PREFIX . "extrafields WHERE elementtype = 'facture_fourn_det' AND entity IN (0, " . $conf->entity . ")"; $sql = "SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'facture_fourn_det' AND entity IN (0, ".$conf->entity.")";
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
if ($resql) { if ($resql) {
while ($obj = $this->db->fetch_object($resql)) { while ($obj = $this->db->fetch_object($resql)) {
$fieldname = 'extra.' . $obj->name; $fieldname = 'extra.'.$obj->name;
$fieldlabel = ucfirst($obj->label); $fieldlabel = ucfirst($obj->label);
$this->import_fields_array[$r][$fieldname] = $fieldlabel . ($obj->fieldrequired ? '*' : ''); $this->import_fields_array[$r][$fieldname] = $fieldlabel.($obj->fieldrequired ? '*' : '');
$import_extrafield_sample[$fieldname] = $fieldlabel; $import_extrafield_sample[$fieldname] = $fieldlabel;
} }
} }
// End add extra fields // End add extra fields
$this->import_fieldshidden_array[$r] = ['extra.fk_object' => 'lastrowid-' . MAIN_DB_PREFIX . 'facture_fourn_det']; $this->import_fieldshidden_array[$r] = ['extra.fk_object' => 'lastrowid-'.MAIN_DB_PREFIX.'facture_fourn_det'];
$this->import_regex_array[$r] = ['fd.product_type' => '[0|1]$', 'fd.fk_product' => 'rowid@' . MAIN_DB_PREFIX . 'product', 'fd.multicurrency_code' => 'code@' . MAIN_DB_PREFIX . 'multicurrency']; $this->import_regex_array[$r] = ['fd.product_type' => '[0|1]$', 'fd.fk_product' => 'rowid@'.MAIN_DB_PREFIX.'product', 'fd.multicurrency_code' => 'code@'.MAIN_DB_PREFIX.'multicurrency'];
$import_sample = [ $import_sample = [
'fd.fk_facture_fourn' => '(PROV001)', 'fd.fk_facture_fourn' => '(PROV001)',
'fd.fk_parent_line' => '', 'fd.fk_parent_line' => '',
@ -835,7 +835,7 @@ class modFournisseur extends DolibarrModules
* The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database. * The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database.
* It also creates data directories * It also creates data directories
* *
* @param string $options Options when enabling module ('', 'noboxes') * @param string $options Options when enabling module ('', 'noboxes')
* @return int 1 if OK, 0 if KO * @return int 1 if OK, 0 if KO
*/ */
public function init($options = '') public function init($options = '')

View File

@ -33,155 +33,155 @@ include_once DOL_DOCUMENT_ROOT.'/core/modules/DolibarrModules.class.php';
*/ */
class modMrp extends DolibarrModules class modMrp extends DolibarrModules
{ {
/** /**
* Constructor. Define names, constants, directories, boxes, permissions * Constructor. Define names, constants, directories, boxes, permissions
* *
* @param DoliDB $db Database handler * @param DoliDB $db Database handler
*/ */
public function __construct($db) public function __construct($db)
{ {
global $langs, $conf; global $langs, $conf;
$this->db = $db; $this->db = $db;
// Id for module (must be unique). // Id for module (must be unique).
// Use here a free id (See in Home -> System information -> Dolibarr for list of used modules id). // Use here a free id (See in Home -> System information -> Dolibarr for list of used modules id).
$this->numero = 660; $this->numero = 660;
// Key text used to identify module (for permissions, menus, etc...) // Key text used to identify module (for permissions, menus, etc...)
$this->rights_class = 'mrp'; $this->rights_class = 'mrp';
// Family can be 'base' (core modules),'crm','financial','hr','projects','products','ecm','technic' (transverse modules),'interface' (link with external tools),'other','...' // Family can be 'base' (core modules),'crm','financial','hr','projects','products','ecm','technic' (transverse modules),'interface' (link with external tools),'other','...'
// It is used to group modules by family in module setup page // It is used to group modules by family in module setup page
$this->family = "products"; $this->family = "products";
// Module position in the family on 2 digits ('01', '10', '20', ...) // Module position in the family on 2 digits ('01', '10', '20', ...)
$this->module_position = '66'; $this->module_position = '66';
// Gives the possibility for the module, to provide his own family info and position of this family (Overwrite $this->family and $this->module_position. Avoid this) // Gives the possibility for the module, to provide his own family info and position of this family (Overwrite $this->family and $this->module_position. Avoid this)
//$this->familyinfo = array('myownfamily' => array('position' => '01', 'label' => $langs->trans("MyOwnFamily"))); //$this->familyinfo = array('myownfamily' => array('position' => '01', 'label' => $langs->trans("MyOwnFamily")));
// Module label (no space allowed), used if translation string 'ModuleMrpName' not found (Mrp is name of module). // Module label (no space allowed), used if translation string 'ModuleMrpName' not found (Mrp is name of module).
$this->name = preg_replace('/^mod/i', '', get_class($this)); $this->name = preg_replace('/^mod/i', '', get_class($this));
// Module description, used if translation string 'ModuleMrpDesc' not found (Mrp is name of module). // Module description, used if translation string 'ModuleMrpDesc' not found (Mrp is name of module).
$this->description = "Module to Manage Manufacturing Orders (MO)"; $this->description = "Module to Manage Manufacturing Orders (MO)";
// Used only if file README.md and README-LL.md not found. // Used only if file README.md and README-LL.md not found.
$this->descriptionlong = "Module to Manage Manufacturing Orders (MO)"; $this->descriptionlong = "Module to Manage Manufacturing Orders (MO)";
// Possible values for version are: 'development', 'experimental', 'dolibarr', 'dolibarr_deprecated' or a version string like 'x.y.z' // Possible values for version are: 'development', 'experimental', 'dolibarr', 'dolibarr_deprecated' or a version string like 'x.y.z'
$this->version = 'dolibarr'; $this->version = 'dolibarr';
// Url to the file with your last numberversion of this module // Url to the file with your last numberversion of this module
//$this->url_last_version = 'http://www.example.com/versionmodule.txt'; //$this->url_last_version = 'http://www.example.com/versionmodule.txt';
// Key used in llx_const table to save module status enabled/disabled (where MRP is value of property name of module in uppercase) // Key used in llx_const table to save module status enabled/disabled (where MRP is value of property name of module in uppercase)
$this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
// Name of image file used for this module. // Name of image file used for this module.
// If file is in theme/yourtheme/img directory under name object_pictovalue.png, use this->picto='pictovalue' // If file is in theme/yourtheme/img directory under name object_pictovalue.png, use this->picto='pictovalue'
// If file is in module/img directory under name object_pictovalue.png, use this->picto='pictovalue@module' // If file is in module/img directory under name object_pictovalue.png, use this->picto='pictovalue@module'
$this->picto = 'mrp'; $this->picto = 'mrp';
// Define some features supported by module (triggers, login, substitutions, menus, css, etc...) // Define some features supported by module (triggers, login, substitutions, menus, css, etc...)
$this->module_parts = array( $this->module_parts = array(
// Set this to 1 if module has its own trigger directory (core/triggers) // Set this to 1 if module has its own trigger directory (core/triggers)
'triggers' => 0, 'triggers' => 0,
// Set this to 1 if module has its own login method file (core/login) // Set this to 1 if module has its own login method file (core/login)
'login' => 0, 'login' => 0,
// Set this to 1 if module has its own substitution function file (core/substitutions) // Set this to 1 if module has its own substitution function file (core/substitutions)
'substitutions' => 0, 'substitutions' => 0,
// Set this to 1 if module has its own menus handler directory (core/menus) // Set this to 1 if module has its own menus handler directory (core/menus)
'menus' => 0, 'menus' => 0,
// Set this to 1 if module overwrite template dir (core/tpl) // Set this to 1 if module overwrite template dir (core/tpl)
'tpl' => 0, 'tpl' => 0,
// Set this to 1 if module has its own barcode directory (core/modules/barcode) // Set this to 1 if module has its own barcode directory (core/modules/barcode)
'barcode' => 0, 'barcode' => 0,
// Set this to 1 if module has its own models directory (core/modules/xxx) // Set this to 1 if module has its own models directory (core/modules/xxx)
'models' => 0, 'models' => 0,
// Set this to 1 if module has its own theme directory (theme) // Set this to 1 if module has its own theme directory (theme)
'theme' => 0, 'theme' => 0,
// Set this to relative path of css file if module has its own css file // Set this to relative path of css file if module has its own css file
'css' => array( 'css' => array(
// '/mrp/css/mrp.css.php', // '/mrp/css/mrp.css.php',
), ),
// Set this to relative path of js file if module must load a js on all pages // Set this to relative path of js file if module must load a js on all pages
'js' => array( 'js' => array(
// '/mrp/js/mrp.js.php', // '/mrp/js/mrp.js.php',
), ),
// Set here all hooks context managed by module. To find available hook context, make a "grep -r '>initHooks(' *" on source code. You can also set hook context to 'all' // Set here all hooks context managed by module. To find available hook context, make a "grep -r '>initHooks(' *" on source code. You can also set hook context to 'all'
'hooks' => array( 'hooks' => array(
// 'data' => array( // 'data' => array(
// 'hookcontext1', // 'hookcontext1',
// 'hookcontext2', // 'hookcontext2',
// ), // ),
// 'entity' => '0', // 'entity' => '0',
), ),
// Set this to 1 if features of module are opened to external users // Set this to 1 if features of module are opened to external users
'moduleforexternal' => 0, 'moduleforexternal' => 0,
); );
// Data directories to create when module is enabled. // Data directories to create when module is enabled.
// Example: this->dirs = array("/mrp/temp","/mrp/subdir"); // Example: this->dirs = array("/mrp/temp","/mrp/subdir");
$this->dirs = array("/mrp/temp"); $this->dirs = array("/mrp/temp");
// Config pages. Put here list of php page, stored into mrp/admin directory, to use to setup module. // Config pages. Put here list of php page, stored into mrp/admin directory, to use to setup module.
$this->config_page_url = array("mrp.php"); $this->config_page_url = array("mrp.php");
// Dependencies // Dependencies
// A condition to hide module // A condition to hide module
$this->hidden = false; $this->hidden = false;
// List of module class names as string that must be enabled if this module is enabled. Example: array('always1'=>'modModuleToEnable1','always2'=>'modModuleToEnable2', 'FR1'=>'modModuleToEnableFR'...) // List of module class names as string that must be enabled if this module is enabled. Example: array('always1'=>'modModuleToEnable1','always2'=>'modModuleToEnable2', 'FR1'=>'modModuleToEnableFR'...)
$this->depends = array('modBom'); $this->depends = array('modBom');
$this->requiredby = array(); // List of module class names as string to disable if this one is disabled. Example: array('modModuleToDisable1', ...) $this->requiredby = array(); // List of module class names as string to disable if this one is disabled. Example: array('modModuleToDisable1', ...)
$this->conflictwith = array(); // List of module class names as string this module is in conflict with. Example: array('modModuleToDisable1', ...) $this->conflictwith = array(); // List of module class names as string this module is in conflict with. Example: array('modModuleToDisable1', ...)
$this->langfiles = array("mrp"); $this->langfiles = array("mrp");
$this->phpmin = array(5, 5); // Minimum version of PHP required by module $this->phpmin = array(5, 5); // Minimum version of PHP required by module
$this->need_dolibarr_version = array(8, 0); // Minimum version of Dolibarr required by module $this->need_dolibarr_version = array(8, 0); // Minimum version of Dolibarr required by module
$this->warnings_activation = array(); // Warning to show when we activate module. array('always'='text') or array('FR'='textfr','ES'='textes'...) $this->warnings_activation = array(); // Warning to show when we activate module. array('always'='text') or array('FR'='textfr','ES'='textes'...)
$this->warnings_activation_ext = array(); // Warning to show when we activate an external module. array('always'='text') or array('FR'='textfr','ES'='textes'...) $this->warnings_activation_ext = array(); // Warning to show when we activate an external module. array('always'='text') or array('FR'='textfr','ES'='textes'...)
//$this->automatic_activation = array('FR'=>'MrpWasAutomaticallyActivatedBecauseOfYourCountryChoice'); //$this->automatic_activation = array('FR'=>'MrpWasAutomaticallyActivatedBecauseOfYourCountryChoice');
//$this->always_enabled = true; // If true, can't be disabled //$this->always_enabled = true; // If true, can't be disabled
// Constants // Constants
// List of particular constants to add when module is enabled (key, 'chaine', value, desc, visible, 'current' or 'allentities', deleteonunactive) // List of particular constants to add when module is enabled (key, 'chaine', value, desc, visible, 'current' or 'allentities', deleteonunactive)
// Example: $this->const=array(1 => array('MRP_MYNEWCONST1', 'chaine', 'myvalue', 'This is a constant to add', 1), // Example: $this->const=array(1 => array('MRP_MYNEWCONST1', 'chaine', 'myvalue', 'This is a constant to add', 1),
// 2 => array('MRP_MYNEWCONST2', 'chaine', 'myvalue', 'This is another constant to add', 0, 'current', 1) // 2 => array('MRP_MYNEWCONST2', 'chaine', 'myvalue', 'This is another constant to add', 0, 'current', 1)
// ); // );
$this->const = array( $this->const = array(
1=>array('MRP_MO_ADDON_PDF', 'chaine', 'alpha', 'Name of PDF model of MO', 0), 1=>array('MRP_MO_ADDON_PDF', 'chaine', 'alpha', 'Name of PDF model of MO', 0),
2=>array('MRP_MO_ADDON', 'chaine', 'mod_mo_standard', 'Name of numbering rules of MO', 0), 2=>array('MRP_MO_ADDON', 'chaine', 'mod_mo_standard', 'Name of numbering rules of MO', 0),
3=>array('MRP_MO_ADDON_PDF_ODT_PATH', 'chaine', 'DOL_DATA_ROOT/doctemplates/mrps', '', 0) 3=>array('MRP_MO_ADDON_PDF_ODT_PATH', 'chaine', 'DOL_DATA_ROOT/doctemplates/mrps', '', 0)
); );
// Some keys to add into the overwriting translation tables // Some keys to add into the overwriting translation tables
/*$this->overwrite_translation = array( /*$this->overwrite_translation = array(
'en_US:ParentCompany'=>'Parent company or reseller', 'en_US:ParentCompany'=>'Parent company or reseller',
'fr_FR:ParentCompany'=>'Maison mère ou revendeur' 'fr_FR:ParentCompany'=>'Maison mère ou revendeur'
)*/ )*/
if (!isset($conf->mrp) || !isset($conf->mrp->enabled)) { if (!isset($conf->mrp) || !isset($conf->mrp->enabled)) {
$conf->mrp = new stdClass(); $conf->mrp = new stdClass();
$conf->mrp->enabled = 0; $conf->mrp->enabled = 0;
} }
// Array to add new pages in new tabs // Array to add new pages in new tabs
$this->tabs = array(); $this->tabs = array();
// Example: // Example:
// $this->tabs[] = array('data'=>'objecttype:+tabname1:Title1:mylangfile@mrp:$user->rights->mrp->read:/mrp/mynewtab1.php?id=__ID__'); // To add a new tab identified by code tabname1 // $this->tabs[] = array('data'=>'objecttype:+tabname1:Title1:mylangfile@mrp:$user->rights->mrp->read:/mrp/mynewtab1.php?id=__ID__'); // To add a new tab identified by code tabname1
// $this->tabs[] = array('data'=>'objecttype:+tabname2:SUBSTITUTION_Title2:mylangfile@mrp:$user->rights->othermodule->read:/mrp/mynewtab2.php?id=__ID__', // To add another new tab identified by code tabname2. Label will be result of calling all substitution functions on 'Title2' key. // $this->tabs[] = array('data'=>'objecttype:+tabname2:SUBSTITUTION_Title2:mylangfile@mrp:$user->rights->othermodule->read:/mrp/mynewtab2.php?id=__ID__', // To add another new tab identified by code tabname2. Label will be result of calling all substitution functions on 'Title2' key.
// $this->tabs[] = array('data'=>'objecttype:-tabname:NU:conditiontoremove'); // To remove an existing tab identified by code tabname // $this->tabs[] = array('data'=>'objecttype:-tabname:NU:conditiontoremove'); // To remove an existing tab identified by code tabname
// //
// Where objecttype can be // Where objecttype can be
// 'categories_x' to add a tab in category view (replace 'x' by type of category (0=product, 1=supplier, 2=customer, 3=member) // 'categories_x' to add a tab in category view (replace 'x' by type of category (0=product, 1=supplier, 2=customer, 3=member)
// 'contact' to add a tab in contact view // 'contact' to add a tab in contact view
// 'contract' to add a tab in contract view // 'contract' to add a tab in contract view
// 'group' to add a tab in group view // 'group' to add a tab in group view
// 'intervention' to add a tab in intervention view // 'intervention' to add a tab in intervention view
// 'invoice' to add a tab in customer invoice view // 'invoice' to add a tab in customer invoice view
// 'invoice_supplier' to add a tab in supplier invoice view // 'invoice_supplier' to add a tab in supplier invoice view
// 'member' to add a tab in fundation member view // 'member' to add a tab in fundation member view
// 'opensurveypoll' to add a tab in opensurvey poll view // 'opensurveypoll' to add a tab in opensurvey poll view
// 'order' to add a tab in customer order view // 'order' to add a tab in customer order view
// 'order_supplier' to add a tab in supplier order view // 'order_supplier' to add a tab in supplier order view
// 'payment' to add a tab in payment view // 'payment' to add a tab in payment view
// 'payment_supplier' to add a tab in supplier payment view // 'payment_supplier' to add a tab in supplier payment view
// 'product' to add a tab in product view // 'product' to add a tab in product view
// 'propal' to add a tab in propal view // 'propal' to add a tab in propal view
// 'project' to add a tab in project view // 'project' to add a tab in project view
// 'stock' to add a tab in stock view // 'stock' to add a tab in stock view
// 'thirdparty' to add a tab in third party view // 'thirdparty' to add a tab in third party view
// 'user' to add a tab in user view // 'user' to add a tab in user view
// Dictionaries // Dictionaries
$this->dictionaries = array(); $this->dictionaries = array();
/* Example: /* Example:
$this->dictionaries=array( $this->dictionaries=array(
'langs'=>'mylangfile@mrp', 'langs'=>'mylangfile@mrp',
// List of tables we want to see into dictonnary editor // List of tables we want to see into dictonnary editor
@ -205,68 +205,68 @@ class modMrp extends DolibarrModules
); );
*/ */
// Boxes/Widgets // Boxes/Widgets
// Add here list of php file(s) stored in mrp/core/boxes that contains a class to show a widget. // Add here list of php file(s) stored in mrp/core/boxes that contains a class to show a widget.
$this->boxes = array( $this->boxes = array(
0 => array('file' => 'box_mos.php', 'note' => '', 'enabledbydefaulton' => 'Home') 0 => array('file' => 'box_mos.php', 'note' => '', 'enabledbydefaulton' => 'Home')
); );
// Cronjobs (List of cron jobs entries to add when module is enabled) // Cronjobs (List of cron jobs entries to add when module is enabled)
// unit_frequency must be 60 for minute, 3600 for hour, 86400 for day, 604800 for week // unit_frequency must be 60 for minute, 3600 for hour, 86400 for day, 604800 for week
$this->cronjobs = array( $this->cronjobs = array(
// 0 => array( // 0 => array(
// 'label' => 'MyJob label', // 'label' => 'MyJob label',
// 'jobtype' => 'method', // 'jobtype' => 'method',
// 'class' => '/mrp/class/mo.class.php', // 'class' => '/mrp/class/mo.class.php',
// 'objectname' => 'Mo', // 'objectname' => 'Mo',
// 'method' => 'doScheduledJob', // 'method' => 'doScheduledJob',
// 'parameters' => '', // 'parameters' => '',
// 'comment' => 'Comment', // 'comment' => 'Comment',
// 'frequency' => 2, // 'frequency' => 2,
// 'unitfrequency' => 3600, // 'unitfrequency' => 3600,
// 'status' => 0, // 'status' => 0,
// 'test' => '$conf->mrp->enabled', // 'test' => '$conf->mrp->enabled',
// 'priority' => 50, // 'priority' => 50,
// ), // ),
); );
// Example: $this->cronjobs=array( // Example: $this->cronjobs=array(
// 0=>array('label'=>'My label', 'jobtype'=>'method', 'class'=>'/dir/class/file.class.php', 'objectname'=>'MyClass', 'method'=>'myMethod', 'parameters'=>'param1, param2', 'comment'=>'Comment', 'frequency'=>2, 'unitfrequency'=>3600, 'status'=>0, 'test'=>'$conf->mrp->enabled', 'priority'=>50), // 0=>array('label'=>'My label', 'jobtype'=>'method', 'class'=>'/dir/class/file.class.php', 'objectname'=>'MyClass', 'method'=>'myMethod', 'parameters'=>'param1, param2', 'comment'=>'Comment', 'frequency'=>2, 'unitfrequency'=>3600, 'status'=>0, 'test'=>'$conf->mrp->enabled', 'priority'=>50),
// 1=>array('label'=>'My label', 'jobtype'=>'command', 'command'=>'', 'parameters'=>'param1, param2', 'comment'=>'Comment', 'frequency'=>1, 'unitfrequency'=>3600*24, 'status'=>0, 'test'=>'$conf->mrp->enabled', 'priority'=>50) // 1=>array('label'=>'My label', 'jobtype'=>'command', 'command'=>'', 'parameters'=>'param1, param2', 'comment'=>'Comment', 'frequency'=>1, 'unitfrequency'=>3600*24, 'status'=>0, 'test'=>'$conf->mrp->enabled', 'priority'=>50)
// ); // );
// Permissions provided by this module // Permissions provided by this module
$this->rights = array(); $this->rights = array();
$r = 0; $r = 0;
// Add here entries to declare new permissions // Add here entries to declare new permissions
/* BEGIN MODULEBUILDER PERMISSIONS */ /* BEGIN MODULEBUILDER PERMISSIONS */
$this->rights[$r][0] = $this->numero + $r; // Permission id (must not be already used) $this->rights[$r][0] = $this->numero + $r; // Permission id (must not be already used)
$this->rights[$r][1] = 'Read Manufacturing Order'; // Permission label $this->rights[$r][1] = 'Read Manufacturing Order'; // Permission label
$this->rights[$r][4] = 'read'; // In php code, permission will be checked by test if ($user->rights->mrp->level1->level2) $this->rights[$r][4] = 'read'; // In php code, permission will be checked by test if ($user->rights->mrp->level1->level2)
$this->rights[$r][5] = ''; // In php code, permission will be checked by test if ($user->rights->mrp->level1->level2) $this->rights[$r][5] = ''; // In php code, permission will be checked by test if ($user->rights->mrp->level1->level2)
$r++; $r++;
$this->rights[$r][0] = $this->numero + $r; // Permission id (must not be already used) $this->rights[$r][0] = $this->numero + $r; // Permission id (must not be already used)
$this->rights[$r][1] = 'Create/Update Manufacturing Order'; // Permission label $this->rights[$r][1] = 'Create/Update Manufacturing Order'; // Permission label
$this->rights[$r][4] = 'write'; // In php code, permission will be checked by test if ($user->rights->mrp->level1->level2) $this->rights[$r][4] = 'write'; // In php code, permission will be checked by test if ($user->rights->mrp->level1->level2)
$this->rights[$r][5] = ''; // In php code, permission will be checked by test if ($user->rights->mrp->level1->level2) $this->rights[$r][5] = ''; // In php code, permission will be checked by test if ($user->rights->mrp->level1->level2)
$r++; $r++;
$this->rights[$r][0] = $this->numero + $r; // Permission id (must not be already used) $this->rights[$r][0] = $this->numero + $r; // Permission id (must not be already used)
$this->rights[$r][1] = 'Delete Manufacturing Order'; // Permission label $this->rights[$r][1] = 'Delete Manufacturing Order'; // Permission label
$this->rights[$r][4] = 'delete'; // In php code, permission will be checked by test if ($user->rights->mrp->level1->level2) $this->rights[$r][4] = 'delete'; // In php code, permission will be checked by test if ($user->rights->mrp->level1->level2)
$this->rights[$r][5] = ''; // In php code, permission will be checked by test if ($user->rights->mrp->level1->level2) $this->rights[$r][5] = ''; // In php code, permission will be checked by test if ($user->rights->mrp->level1->level2)
$r++; $r++;
/* END MODULEBUILDER PERMISSIONS */ /* END MODULEBUILDER PERMISSIONS */
// Main menu entries to add // Main menu entries to add
$this->menu = array(); $this->menu = array();
$r = 0; $r = 0;
// Add here entries to declare new menus // Add here entries to declare new menus
/* BEGIN MODULEBUILDER TOPMENU */ /* BEGIN MODULEBUILDER TOPMENU */
/* END MODULEBUILDER LEFTMENU MO */ /* END MODULEBUILDER LEFTMENU MO */
// Exports profiles provided by this module // Exports profiles provided by this module
$r = 1; $r = 1;
/* BEGIN MODULEBUILDER EXPORT MO */ /* BEGIN MODULEBUILDER EXPORT MO */
/* /*
$langs->load("mrp"); $langs->load("mrp");
$this->export_code[$r]=$this->rights_class.'_'.$r; $this->export_code[$r]=$this->rights_class.'_'.$r;
$this->export_label[$r]='MoLines'; // Translation key (used only if key ExportDataset_xxx_z not found) $this->export_label[$r]='MoLines'; // Translation key (used only if key ExportDataset_xxx_z not found)
@ -281,12 +281,12 @@ class modMrp extends DolibarrModules
$this->export_sql_end[$r] .=' WHERE 1 = 1'; $this->export_sql_end[$r] .=' WHERE 1 = 1';
$this->export_sql_end[$r] .=' AND t.entity IN ('.getEntity('mo').')'; $this->export_sql_end[$r] .=' AND t.entity IN ('.getEntity('mo').')';
$r++; */ $r++; */
/* END MODULEBUILDER EXPORT MO */ /* END MODULEBUILDER EXPORT MO */
// Imports profiles provided by this module // Imports profiles provided by this module
$r = 1; $r = 1;
/* BEGIN MODULEBUILDER IMPORT MO */ /* BEGIN MODULEBUILDER IMPORT MO */
/* /*
$langs->load("mrp"); $langs->load("mrp");
$this->export_code[$r]=$this->rights_class.'_'.$r; $this->export_code[$r]=$this->rights_class.'_'.$r;
$this->export_label[$r]='MoLines'; // Translation key (used only if key ExportDataset_xxx_z not found) $this->export_label[$r]='MoLines'; // Translation key (used only if key ExportDataset_xxx_z not found)
@ -301,75 +301,75 @@ class modMrp extends DolibarrModules
$this->export_sql_end[$r] .=' WHERE 1 = 1'; $this->export_sql_end[$r] .=' WHERE 1 = 1';
$this->export_sql_end[$r] .=' AND t.entity IN ('.getEntity('mo').')'; $this->export_sql_end[$r] .=' AND t.entity IN ('.getEntity('mo').')';
$r++; */ $r++; */
/* END MODULEBUILDER IMPORT MO */ /* END MODULEBUILDER IMPORT MO */
} }
/** /**
* Function called when module is enabled. * Function called when module is enabled.
* The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database. * The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database.
* It also creates data directories * It also creates data directories
* *
* @param string $options Options when enabling module ('', 'noboxes') * @param string $options Options when enabling module ('', 'noboxes')
* @return int 1 if OK, 0 if KO * @return int 1 if OK, 0 if KO
*/ */
public function init($options = '') public function init($options = '')
{ {
global $conf, $langs; global $conf, $langs;
$result = $this->_load_tables('/mrp/sql/'); $result = $this->_load_tables('/mrp/sql/');
if ($result < 0) return -1; // Do not activate module if error 'not allowed' returned when loading module SQL queries (the _load_table run sql with run_sql with the error allowed parameter set to 'default') if ($result < 0) return -1; // Do not activate module if error 'not allowed' returned when loading module SQL queries (the _load_table run sql with run_sql with the error allowed parameter set to 'default')
// Create extrafields during init // Create extrafields during init
//include_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; //include_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
//$extrafields = new ExtraFields($this->db); //$extrafields = new ExtraFields($this->db);
//$result1=$extrafields->addExtraField('myattr1', "New Attr 1 label", 'boolean', 1, 3, 'thirdparty', 0, 0, '', '', 1, '', 0, 0, '', '', 'mrp', '$conf->mrp->enabled'); //$result1=$extrafields->addExtraField('myattr1', "New Attr 1 label", 'boolean', 1, 3, 'thirdparty', 0, 0, '', '', 1, '', 0, 0, '', '', 'mrp', '$conf->mrp->enabled');
//$result2=$extrafields->addExtraField('myattr2', "New Attr 2 label", 'varchar', 1, 10, 'project', 0, 0, '', '', 1, '', 0, 0, '', '', 'mrp', '$conf->mrp->enabled'); //$result2=$extrafields->addExtraField('myattr2', "New Attr 2 label", 'varchar', 1, 10, 'project', 0, 0, '', '', 1, '', 0, 0, '', '', 'mrp', '$conf->mrp->enabled');
//$result3=$extrafields->addExtraField('myattr3', "New Attr 3 label", 'varchar', 1, 10, 'bank_account', 0, 0, '', '', 1, '', 0, 0, '', '', 'mrp', '$conf->mrp->enabled'); //$result3=$extrafields->addExtraField('myattr3', "New Attr 3 label", 'varchar', 1, 10, 'bank_account', 0, 0, '', '', 1, '', 0, 0, '', '', 'mrp', '$conf->mrp->enabled');
//$result4=$extrafields->addExtraField('myattr4', "New Attr 4 label", 'select', 1, 3, 'thirdparty', 0, 1, '', array('options'=>array('code1'=>'Val1','code2'=>'Val2','code3'=>'Val3')), 1,'', 0, 0, '', '', 'mrp', '$conf->mrp->enabled'); //$result4=$extrafields->addExtraField('myattr4', "New Attr 4 label", 'select', 1, 3, 'thirdparty', 0, 1, '', array('options'=>array('code1'=>'Val1','code2'=>'Val2','code3'=>'Val3')), 1,'', 0, 0, '', '', 'mrp', '$conf->mrp->enabled');
//$result5=$extrafields->addExtraField('myattr5', "New Attr 5 label", 'text', 1, 10, 'user', 0, 0, '', '', 1, '', 0, 0, '', '', 'mrp', '$conf->mrp->enabled'); //$result5=$extrafields->addExtraField('myattr5', "New Attr 5 label", 'text', 1, 10, 'user', 0, 0, '', '', 1, '', 0, 0, '', '', 'mrp', '$conf->mrp->enabled');
// Permissions // Permissions
$this->remove($options); $this->remove($options);
$sql = array(); $sql = array();
// ODT template // ODT template
$src = DOL_DOCUMENT_ROOT.'/install/doctemplates/mrps/template_mo.odt'; $src = DOL_DOCUMENT_ROOT.'/install/doctemplates/mrps/template_mo.odt';
$dirodt = DOL_DATA_ROOT.'/doctemplates/mrps'; $dirodt = DOL_DATA_ROOT.'/doctemplates/mrps';
$dest = $dirodt.'/template_mo.odt'; $dest = $dirodt.'/template_mo.odt';
if (file_exists($src) && !file_exists($dest)) if (file_exists($src) && !file_exists($dest))
{ {
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
dol_mkdir($dirodt); dol_mkdir($dirodt);
$result = dol_copy($src, $dest, 0, 0); $result = dol_copy($src, $dest, 0, 0);
if ($result < 0) if ($result < 0)
{ {
$langs->load("errors"); $langs->load("errors");
$this->error = $langs->trans('ErrorFailToCopyFile', $src, $dest); $this->error = $langs->trans('ErrorFailToCopyFile', $src, $dest);
return 0; return 0;
} }
} }
$sql = array( $sql = array(
//"DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = '".$this->db->escape('standard')."' AND type = 'mo' AND entity = ".$conf->entity, //"DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = '".$this->db->escape('standard')."' AND type = 'mo' AND entity = ".$conf->entity,
//"INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('".$this->db->escape('standard')."', 'mo', ".$conf->entity.")" //"INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('".$this->db->escape('standard')."', 'mo', ".$conf->entity.")"
); );
return $this->_init($sql, $options); return $this->_init($sql, $options);
} }
/** /**
* Function called when module is disabled. * Function called when module is disabled.
* Remove from database constants, boxes and permissions from Dolibarr database. * Remove from database constants, boxes and permissions from Dolibarr database.
* Data directories are not deleted * Data directories are not deleted
* *
* @param string $options Options when enabling module ('', 'noboxes') * @param string $options Options when enabling module ('', 'noboxes')
* @return int 1 if OK, 0 if KO * @return int 1 if OK, 0 if KO
*/ */
public function remove($options = '') public function remove($options = '')
{ {
$sql = array(); $sql = array();
return $this->_remove($sql, $options); return $this->_remove($sql, $options);
} }
} }

View File

@ -262,11 +262,11 @@ class modPropale extends DolibarrModules
$r++; $r++;
$this->import_code[$r] = $this->rights_class.'_'.$r; $this->import_code[$r] = $this->rights_class.'_'.$r;
$this->import_label[$r] = 'Proposals'; // Translation key $this->import_label[$r] = 'Proposals'; // Translation key
$this->import_icon[$r] = $this->picto; $this->import_icon[$r] = $this->picto;
$this->import_entities_array[$r] = []; // We define here only fields that use another icon that the one defined into import_icon $this->import_entities_array[$r] = []; // We define here only fields that use another icon that the one defined into import_icon
$this->import_tables_array[$r] = ['c' => MAIN_DB_PREFIX . 'propal', 'extra' => MAIN_DB_PREFIX . 'propal_extrafields']; $this->import_tables_array[$r] = ['c' => MAIN_DB_PREFIX.'propal', 'extra' => MAIN_DB_PREFIX.'propal_extrafields'];
$this->import_tables_creator_array[$r] = ['c'=>'fk_user_author']; // Fields to store import user id $this->import_tables_creator_array[$r] = ['c'=>'fk_user_author']; // Fields to store import user id
$this->import_fields_array[$r] = [ $this->import_fields_array[$r] = [
'c.ref' => 'Document Ref*', 'c.ref' => 'Document Ref*',
'c.ref_client' => 'RefCustomer', 'c.ref_client' => 'RefCustomer',
@ -282,7 +282,7 @@ class modPropale extends DolibarrModules
'c.date_livraison' => 'DeliveryDate', 'c.date_livraison' => 'DeliveryDate',
'c.fk_user_valid' => 'ValidatedById' 'c.fk_user_valid' => 'ValidatedById'
]; ];
if (! empty($conf->multicurrency->enabled)) { if (!empty($conf->multicurrency->enabled)) {
$this->import_fields_array[$r]['c.multicurrency_code'] = 'Currency'; $this->import_fields_array[$r]['c.multicurrency_code'] = 'Currency';
$this->import_fields_array[$r]['c.multicurrency_tx'] = 'CurrencyRate'; $this->import_fields_array[$r]['c.multicurrency_tx'] = 'CurrencyRate';
$this->import_fields_array[$r]['c.multicurrency_total_ht'] = 'MulticurrencyAmountHT'; $this->import_fields_array[$r]['c.multicurrency_total_ht'] = 'MulticurrencyAmountHT';
@ -291,18 +291,18 @@ class modPropale extends DolibarrModules
} }
// Add extra fields // Add extra fields
$import_extrafield_sample = []; $import_extrafield_sample = [];
$sql = "SELECT name, label, fieldrequired FROM " . MAIN_DB_PREFIX . "extrafields WHERE elementtype = 'propal' AND entity IN (0, " . $conf->entity . ")"; $sql = "SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'propal' AND entity IN (0, ".$conf->entity.")";
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
if ($resql) { if ($resql) {
while ($obj = $this->db->fetch_object($resql)) { while ($obj = $this->db->fetch_object($resql)) {
$fieldname = 'extra.' . $obj->name; $fieldname = 'extra.'.$obj->name;
$fieldlabel = ucfirst($obj->label); $fieldlabel = ucfirst($obj->label);
$this->import_fields_array[$r][$fieldname] = $fieldlabel . ($obj->fieldrequired ? '*' : ''); $this->import_fields_array[$r][$fieldname] = $fieldlabel.($obj->fieldrequired ? '*' : '');
$import_extrafield_sample[$fieldname] = $fieldlabel; $import_extrafield_sample[$fieldname] = $fieldlabel;
} }
} }
// End add extra fields // End add extra fields
$this->import_fieldshidden_array[$r] = ['extra.fk_object' => 'lastrowid-' . MAIN_DB_PREFIX . 'propal']; $this->import_fieldshidden_array[$r] = ['extra.fk_object' => 'lastrowid-'.MAIN_DB_PREFIX.'propal'];
$this->import_regex_array[$r] = ['c.ref' => '[^ ]']; $this->import_regex_array[$r] = ['c.ref' => '[^ ]'];
$import_sample = [ $import_sample = [
'c.ref' => 'PROV0077', 'c.ref' => 'PROV0077',
@ -339,12 +339,12 @@ class modPropale extends DolibarrModules
//Import Proposal Lines //Import Proposal Lines
$r++; $r++;
$this->import_code[$r] = $this->rights_class.'line_'.$r; $this->import_code[$r] = $this->rights_class.'line_'.$r;
$this->import_label[$r] = "ProposalLine"; // Translation key $this->import_label[$r] = "ProposalLine"; // Translation key
$this->import_icon[$r] = $this->picto; $this->import_icon[$r] = $this->picto;
$this->import_entities_array[$r] = []; // We define here only fields that use another icon that the one defined into import_icon $this->import_entities_array[$r] = []; // We define here only fields that use another icon that the one defined into import_icon
$this->import_tables_array[$r] = [ $this->import_tables_array[$r] = [
'cd' => MAIN_DB_PREFIX . 'propaldet', 'cd' => MAIN_DB_PREFIX.'propaldet',
'extra' => MAIN_DB_PREFIX . 'propaldet_extrafields' 'extra' => MAIN_DB_PREFIX.'propaldet_extrafields'
]; ];
$this->import_fields_array[$r] = [ $this->import_fields_array[$r] = [
'cd.fk_propal' => 'Document Ref*', 'cd.fk_propal' => 'Document Ref*',
@ -366,7 +366,7 @@ class modPropale extends DolibarrModules
'cd.date_end' => 'End Date', 'cd.date_end' => 'End Date',
'cd.buy_price_ht' => 'LineBuyPriceHT' 'cd.buy_price_ht' => 'LineBuyPriceHT'
]; ];
if (! empty($conf->multicurrency->enabled)) { if (!empty($conf->multicurrency->enabled)) {
$this->import_fields_array[$r]['cd.multicurrency_code'] = 'Currency'; $this->import_fields_array[$r]['cd.multicurrency_code'] = 'Currency';
$this->import_fields_array[$r]['cd.multicurrency_subprice'] = 'CurrencyRate'; $this->import_fields_array[$r]['cd.multicurrency_subprice'] = 'CurrencyRate';
$this->import_fields_array[$r]['cd.multicurrency_total_ht'] = 'MulticurrencyAmountHT'; $this->import_fields_array[$r]['cd.multicurrency_total_ht'] = 'MulticurrencyAmountHT';
@ -379,14 +379,14 @@ class modPropale extends DolibarrModules
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
if ($resql) { if ($resql) {
while ($obj = $this->db->fetch_object($resql)) { while ($obj = $this->db->fetch_object($resql)) {
$fieldname = 'extra.' . $obj->name; $fieldname = 'extra.'.$obj->name;
$fieldlabel = ucfirst($obj->label); $fieldlabel = ucfirst($obj->label);
$this->import_fields_array[$r][$fieldname] = $fieldlabel . ($obj->fieldrequired ? '*' : ''); $this->import_fields_array[$r][$fieldname] = $fieldlabel.($obj->fieldrequired ? '*' : '');
$import_extrafield_sample[$fieldname] = $fieldlabel; $import_extrafield_sample[$fieldname] = $fieldlabel;
} }
} }
// End add extra fields // End add extra fields
$this->import_fieldshidden_array[$r] = ['extra.fk_object' => 'lastrowid-' . MAIN_DB_PREFIX . 'propaldet']; $this->import_fieldshidden_array[$r] = ['extra.fk_object' => 'lastrowid-'.MAIN_DB_PREFIX.'propaldet'];
$this->import_regex_array[$r] = ['cd.product_type' => '[0|1]$']; $this->import_regex_array[$r] = ['cd.product_type' => '[0|1]$'];
$import_sample = [ $import_sample = [
'cd.fk_propal' => 'PROV(0001)', 'cd.fk_propal' => 'PROV(0001)',

View File

@ -30,54 +30,54 @@ include_once DOL_DOCUMENT_ROOT.'/core/modules/DolibarrModules.class.php';
class modWebServicesClient extends DolibarrModules class modWebServicesClient extends DolibarrModules
{ {
/** /**
* Constructor. Define names, constants, directories, boxes, permissions * Constructor. Define names, constants, directories, boxes, permissions
* *
* @param DoliDB $db Database handler * @param DoliDB $db Database handler
*/ */
public function __construct($db) public function __construct($db)
{ {
$this->db = $db; $this->db = $db;
$this->numero = 2660; $this->numero = 2660;
$this->family = "interface"; $this->family = "interface";
$this->module_position = '25'; $this->module_position = '25';
// Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
$this->name = preg_replace('/^mod/i', '', get_class($this)); $this->name = preg_replace('/^mod/i', '', get_class($this));
$this->description = "Enable the web service client to call external supplier web services"; $this->description = "Enable the web service client to call external supplier web services";
// Possible values for version are: 'development', 'experimental', 'dolibarr' or version // Possible values for version are: 'development', 'experimental', 'dolibarr' or version
$this->version = 'experimental'; $this->version = 'experimental';
// Key used in llx_const table to save module status enabled/disabled (where MYMODULE is value of property name of module in uppercase) // Key used in llx_const table to save module status enabled/disabled (where MYMODULE is value of property name of module in uppercase)
$this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
// Name of image file used for this module. // Name of image file used for this module.
$this->picto = 'technic'; $this->picto = 'technic';
// Data directories to create when module is enabled // Data directories to create when module is enabled
$this->dirs = array(); $this->dirs = array();
// Config pages // Config pages
//$this->config_page_url = array(); //$this->config_page_url = array();
// Dependencies // Dependencies
$this->hidden = false; // A condition to hide module $this->hidden = false; // A condition to hide module
$this->depends = array(); // List of module class names as string that must be enabled if this module is enabled $this->depends = array(); // List of module class names as string that must be enabled if this module is enabled
$this->requiredby = array(); // List of module ids to disable if this one is disabled $this->requiredby = array(); // List of module ids to disable if this one is disabled
$this->conflictwith = array(); // List of module class names as string this module is in conflict with $this->conflictwith = array(); // List of module class names as string this module is in conflict with
$this->phpmin = array(5, 4); // Minimum version of PHP required by module $this->phpmin = array(5, 4); // Minimum version of PHP required by module
$this->langfiles = array("other"); $this->langfiles = array("other");
// Constants // Constants
$this->const = array(); $this->const = array();
// New pages on tabs // New pages on tabs
$this->tabs = array(); $this->tabs = array();
// Boxes // Boxes
$this->boxes = array(); $this->boxes = array();
// Permissions // Permissions
$this->rights = array(); $this->rights = array();
$this->rights_class = 'syncsupplierwebservices'; $this->rights_class = 'syncsupplierwebservices';
$r = 0; $r = 0;
} }
} }

View File

@ -35,478 +35,478 @@ use OAuth\OAuth2\Service\Google;
*/ */
class printing_printgcp extends PrintingDriver class printing_printgcp extends PrintingDriver
{ {
public $name = 'printgcp'; public $name = 'printgcp';
public $desc = 'PrintGCPDesc'; public $desc = 'PrintGCPDesc';
/** /**
* @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png * @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png
*/ */
public $picto = 'printer'; public $picto = 'printer';
public $active = 'PRINTING_PRINTGCP'; public $active = 'PRINTING_PRINTGCP';
public $conf = array(); public $conf = array();
public $google_id = ''; public $google_id = '';
public $google_secret = ''; public $google_secret = '';
/** /**
* @var string Error code (or message) * @var string Error code (or message)
*/ */
public $error = ''; public $error = '';
/** /**
* @var string[] Error codes (or messages) * @var string[] Error codes (or messages)
*/ */
public $errors = array(); public $errors = array();
/** /**
* @var DoliDB Database handler. * @var DoliDB Database handler.
*/ */
public $db; public $db;
private $OAUTH_SERVICENAME_GOOGLE = 'Google'; private $OAUTH_SERVICENAME_GOOGLE = 'Google';
const LOGIN_URL = 'https://accounts.google.com/o/oauth2/token'; const LOGIN_URL = 'https://accounts.google.com/o/oauth2/token';
const PRINTERS_SEARCH_URL = 'https://www.google.com/cloudprint/search'; const PRINTERS_SEARCH_URL = 'https://www.google.com/cloudprint/search';
const PRINTERS_GET_JOBS = 'https://www.google.com/cloudprint/jobs'; const PRINTERS_GET_JOBS = 'https://www.google.com/cloudprint/jobs';
const PRINT_URL = 'https://www.google.com/cloudprint/submit'; const PRINT_URL = 'https://www.google.com/cloudprint/submit';
/** /**
* Constructor * Constructor
* *
* @param DoliDB $db Database handler * @param DoliDB $db Database handler
*/ */
public function __construct($db) public function __construct($db)
{ {
global $conf, $langs, $dolibarr_main_url_root; global $conf, $langs, $dolibarr_main_url_root;
// Define $urlwithroot // Define $urlwithroot
$urlwithouturlroot = preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root)); $urlwithouturlroot = preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root));
$urlwithroot = $urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file
//$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current //$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current
$this->db = $db; $this->db = $db;
if (!$conf->oauth->enabled) { if (!$conf->oauth->enabled) {
$this->conf[] = array( $this->conf[] = array(
'varname'=>'PRINTGCP_INFO', 'varname'=>'PRINTGCP_INFO',
'info'=>$langs->transnoentitiesnoconv("WarningModuleNotActive", "OAuth"), 'info'=>$langs->transnoentitiesnoconv("WarningModuleNotActive", "OAuth"),
'type'=>'info', 'type'=>'info',
); );
} else { } else {
$this->google_id = $conf->global->OAUTH_GOOGLE_ID; $this->google_id = $conf->global->OAUTH_GOOGLE_ID;
$this->google_secret = $conf->global->OAUTH_GOOGLE_SECRET; $this->google_secret = $conf->global->OAUTH_GOOGLE_SECRET;
// Token storage // Token storage
$storage = new DoliStorage($this->db, $this->conf); $storage = new DoliStorage($this->db, $this->conf);
//$storage->clearToken($this->OAUTH_SERVICENAME_GOOGLE); //$storage->clearToken($this->OAUTH_SERVICENAME_GOOGLE);
// Setup the credentials for the requests // Setup the credentials for the requests
$credentials = new Credentials( $credentials = new Credentials(
$this->google_id, $this->google_id,
$this->google_secret, $this->google_secret,
$urlwithroot.'/core/modules/oauth/google_oauthcallback.php' $urlwithroot.'/core/modules/oauth/google_oauthcallback.php'
); );
$access = ($storage->hasAccessToken($this->OAUTH_SERVICENAME_GOOGLE) ? 'HasAccessToken' : 'NoAccessToken'); $access = ($storage->hasAccessToken($this->OAUTH_SERVICENAME_GOOGLE) ? 'HasAccessToken' : 'NoAccessToken');
$serviceFactory = new \OAuth\ServiceFactory(); $serviceFactory = new \OAuth\ServiceFactory();
$apiService = $serviceFactory->createService($this->OAUTH_SERVICENAME_GOOGLE, $credentials, $storage, array()); $apiService = $serviceFactory->createService($this->OAUTH_SERVICENAME_GOOGLE, $credentials, $storage, array());
$token_ok = true; $token_ok = true;
try { try {
$token = $storage->retrieveAccessToken($this->OAUTH_SERVICENAME_GOOGLE); $token = $storage->retrieveAccessToken($this->OAUTH_SERVICENAME_GOOGLE);
} catch (Exception $e) { } catch (Exception $e) {
$this->errors[] = $e->getMessage(); $this->errors[] = $e->getMessage();
$token_ok = false; $token_ok = false;
} }
//var_dump($this->errors);exit; //var_dump($this->errors);exit;
$expire = false; $expire = false;
// Is token expired or will token expire in the next 30 seconds // Is token expired or will token expire in the next 30 seconds
if ($token_ok) { if ($token_ok) {
$expire = ($token->getEndOfLife() !== -9002 && $token->getEndOfLife() !== -9001 && time() > ($token->getEndOfLife() - 30)); $expire = ($token->getEndOfLife() !== -9002 && $token->getEndOfLife() !== -9001 && time() > ($token->getEndOfLife() - 30));
} }
// Token expired so we refresh it // Token expired so we refresh it
if ($token_ok && $expire) { if ($token_ok && $expire) {
try { try {
// il faut sauvegarder le refresh token car google ne le donne qu'une seule fois // il faut sauvegarder le refresh token car google ne le donne qu'une seule fois
$refreshtoken = $token->getRefreshToken(); $refreshtoken = $token->getRefreshToken();
$token = $apiService->refreshAccessToken($token); $token = $apiService->refreshAccessToken($token);
$token->setRefreshToken($refreshtoken); $token->setRefreshToken($refreshtoken);
$storage->storeAccessToken($this->OAUTH_SERVICENAME_GOOGLE, $token); $storage->storeAccessToken($this->OAUTH_SERVICENAME_GOOGLE, $token);
} catch (Exception $e) { } catch (Exception $e) {
$this->errors[] = $e->getMessage(); $this->errors[] = $e->getMessage();
} }
} }
if ($this->google_id != '' && $this->google_secret != '') { if ($this->google_id != '' && $this->google_secret != '') {
$this->conf[] = array('varname'=>'PRINTGCP_INFO', 'info'=>'GoogleAuthConfigured', 'type'=>'info'); $this->conf[] = array('varname'=>'PRINTGCP_INFO', 'info'=>'GoogleAuthConfigured', 'type'=>'info');
$this->conf[] = array( $this->conf[] = array(
'varname'=>'PRINTGCP_TOKEN_ACCESS', 'varname'=>'PRINTGCP_TOKEN_ACCESS',
'info'=>$access, 'info'=>$access,
'type'=>'info', 'type'=>'info',
'renew'=>$urlwithroot.'/core/modules/oauth/google_oauthcallback.php?state=userinfo_email,userinfo_profile,cloud_print&backtourl='.urlencode(DOL_URL_ROOT.'/printing/admin/printing.php?mode=setup&driver=printgcp'), 'renew'=>$urlwithroot.'/core/modules/oauth/google_oauthcallback.php?state=userinfo_email,userinfo_profile,cloud_print&backtourl='.urlencode(DOL_URL_ROOT.'/printing/admin/printing.php?mode=setup&driver=printgcp'),
'delete'=>($storage->hasAccessToken($this->OAUTH_SERVICENAME_GOOGLE) ? $urlwithroot.'/core/modules/oauth/google_oauthcallback.php?action=delete&token='.newToken().'&backtourl='.urlencode(DOL_URL_ROOT.'/printing/admin/printing.php?mode=setup&driver=printgcp') : '') 'delete'=>($storage->hasAccessToken($this->OAUTH_SERVICENAME_GOOGLE) ? $urlwithroot.'/core/modules/oauth/google_oauthcallback.php?action=delete&token='.newToken().'&backtourl='.urlencode(DOL_URL_ROOT.'/printing/admin/printing.php?mode=setup&driver=printgcp') : '')
); );
if ($token_ok) { if ($token_ok) {
$expiredat = ''; $expiredat = '';
$refreshtoken = $token->getRefreshToken(); $refreshtoken = $token->getRefreshToken();
$endoflife = $token->getEndOfLife(); $endoflife = $token->getEndOfLife();
if ($endoflife == $token::EOL_NEVER_EXPIRES) if ($endoflife == $token::EOL_NEVER_EXPIRES)
{ {
$expiredat = $langs->trans("Never"); $expiredat = $langs->trans("Never");
} elseif ($endoflife == $token::EOL_UNKNOWN) } elseif ($endoflife == $token::EOL_UNKNOWN)
{ {
$expiredat = $langs->trans("Unknown"); $expiredat = $langs->trans("Unknown");
} else { } else {
$expiredat = dol_print_date($endoflife, "dayhour"); $expiredat = dol_print_date($endoflife, "dayhour");
} }
$this->conf[] = array('varname'=>'TOKEN_REFRESH', 'info'=>((!empty($refreshtoken)) ? 'Yes' : 'No'), 'type'=>'info'); $this->conf[] = array('varname'=>'TOKEN_REFRESH', 'info'=>((!empty($refreshtoken)) ? 'Yes' : 'No'), 'type'=>'info');
$this->conf[] = array('varname'=>'TOKEN_EXPIRED', 'info'=>($expire ? 'Yes' : 'No'), 'type'=>'info'); $this->conf[] = array('varname'=>'TOKEN_EXPIRED', 'info'=>($expire ? 'Yes' : 'No'), 'type'=>'info');
$this->conf[] = array('varname'=>'TOKEN_EXPIRE_AT', 'info'=>($expiredat), 'type'=>'info'); $this->conf[] = array('varname'=>'TOKEN_EXPIRE_AT', 'info'=>($expiredat), 'type'=>'info');
} }
/* /*
if ($storage->hasAccessToken($this->OAUTH_SERVICENAME_GOOGLE)) { if ($storage->hasAccessToken($this->OAUTH_SERVICENAME_GOOGLE)) {
$this->conf[] = array('varname'=>'PRINTGCP_AUTHLINK', 'link'=>$urlwithroot.'/core/modules/oauth/google_oauthcallback.php?backtourl='.urlencode(DOL_URL_ROOT.'/printing/admin/printing.php?mode=setup&driver=printgcp'), 'type'=>'authlink'); $this->conf[] = array('varname'=>'PRINTGCP_AUTHLINK', 'link'=>$urlwithroot.'/core/modules/oauth/google_oauthcallback.php?backtourl='.urlencode(DOL_URL_ROOT.'/printing/admin/printing.php?mode=setup&driver=printgcp'), 'type'=>'authlink');
$this->conf[] = array('varname'=>'DELETE_TOKEN', 'link'=>$urlwithroot.'/core/modules/oauth/google_oauthcallback.php?action=delete&token='.newToken().'&backtourl='.urlencode(DOL_URL_ROOT.'/printing/admin/printing.php?mode=setup&driver=printgcp'), 'type'=>'delete'); $this->conf[] = array('varname'=>'DELETE_TOKEN', 'link'=>$urlwithroot.'/core/modules/oauth/google_oauthcallback.php?action=delete&token='.newToken().'&backtourl='.urlencode(DOL_URL_ROOT.'/printing/admin/printing.php?mode=setup&driver=printgcp'), 'type'=>'delete');
} else { } else {
$this->conf[] = array('varname'=>'PRINTGCP_AUTHLINK', 'link'=>$urlwithroot.'/core/modules/oauth/google_oauthcallback.php?backtourl='.urlencode(DOL_URL_ROOT.'/printing/admin/printing.php?mode=setup&driver=printgcp'), 'type'=>'authlink'); $this->conf[] = array('varname'=>'PRINTGCP_AUTHLINK', 'link'=>$urlwithroot.'/core/modules/oauth/google_oauthcallback.php?backtourl='.urlencode(DOL_URL_ROOT.'/printing/admin/printing.php?mode=setup&driver=printgcp'), 'type'=>'authlink');
}*/ }*/
} else { } else {
$this->conf[] = array('varname'=>'PRINTGCP_INFO', 'info'=>'GoogleAuthNotConfigured', 'type'=>'info'); $this->conf[] = array('varname'=>'PRINTGCP_INFO', 'info'=>'GoogleAuthNotConfigured', 'type'=>'info');
} }
} }
// do not display submit button // do not display submit button
$this->conf[] = array('enabled'=>0, 'type'=>'submit'); $this->conf[] = array('enabled'=>0, 'type'=>'submit');
} }
/** /**
* Return list of available printers * Return list of available printers
* *
* @return int 0 if OK, >0 if KO * @return int 0 if OK, >0 if KO
*/ */
public function listAvailablePrinters() public function listAvailablePrinters()
{ {
global $conf, $langs; global $conf, $langs;
$error = 0; $error = 0;
$langs->load('printing'); $langs->load('printing');
$html = '<tr class="liste_titre">'; $html = '<tr class="liste_titre">';
$html .= '<td>'.$langs->trans('GCP_Name').'</td>'; $html .= '<td>'.$langs->trans('GCP_Name').'</td>';
$html .= '<td>'.$langs->trans('GCP_displayName').'</td>'; $html .= '<td>'.$langs->trans('GCP_displayName').'</td>';
$html .= '<td>'.$langs->trans('GCP_Id').'</td>'; $html .= '<td>'.$langs->trans('GCP_Id').'</td>';
$html .= '<td>'.$langs->trans('GCP_OwnerName').'</td>'; $html .= '<td>'.$langs->trans('GCP_OwnerName').'</td>';
$html .= '<td>'.$langs->trans('GCP_State').'</td>'; $html .= '<td>'.$langs->trans('GCP_State').'</td>';
$html .= '<td>'.$langs->trans('GCP_connectionStatus').'</td>'; $html .= '<td>'.$langs->trans('GCP_connectionStatus').'</td>';
$html .= '<td>'.$langs->trans('GCP_Type').'</td>'; $html .= '<td>'.$langs->trans('GCP_Type').'</td>';
$html .= '<td class="center">'.$langs->trans("Select").'</td>'; $html .= '<td class="center">'.$langs->trans("Select").'</td>';
$html .= '</tr>'."\n"; $html .= '</tr>'."\n";
$list = $this->getlistAvailablePrinters(); $list = $this->getlistAvailablePrinters();
//$html.= '<td><pre>'.print_r($list,true).'</pre></td>'; //$html.= '<td><pre>'.print_r($list,true).'</pre></td>';
foreach ($list['available'] as $printer_det) foreach ($list['available'] as $printer_det)
{ {
$html .= '<tr class="oddeven">'; $html .= '<tr class="oddeven">';
$html .= '<td>'.$printer_det['name'].'</td>'; $html .= '<td>'.$printer_det['name'].'</td>';
$html .= '<td>'.$printer_det['displayName'].'</td>'; $html .= '<td>'.$printer_det['displayName'].'</td>';
$html .= '<td>'.$printer_det['id'].'</td>'; // id to identify printer to use $html .= '<td>'.$printer_det['id'].'</td>'; // id to identify printer to use
$html .= '<td>'.$printer_det['ownerName'].'</td>'; $html .= '<td>'.$printer_det['ownerName'].'</td>';
$html .= '<td>'.$printer_det['status'].'</td>'; $html .= '<td>'.$printer_det['status'].'</td>';
$html .= '<td>'.$langs->trans('STATE_'.$printer_det['connectionStatus']).'</td>'; $html .= '<td>'.$langs->trans('STATE_'.$printer_det['connectionStatus']).'</td>';
$html .= '<td>'.$langs->trans('TYPE_'.$printer_det['type']).'</td>'; $html .= '<td>'.$langs->trans('TYPE_'.$printer_det['type']).'</td>';
// Defaut // Defaut
$html .= '<td class="center">'; $html .= '<td class="center">';
if ($conf->global->PRINTING_GCP_DEFAULT == $printer_det['id']) if ($conf->global->PRINTING_GCP_DEFAULT == $printer_det['id'])
{ {
$html .= img_picto($langs->trans("Default"), 'on'); $html .= img_picto($langs->trans("Default"), 'on');
} else $html .= '<a href="'.$_SERVER["PHP_SELF"].'?action=setvalue&amp;token='.newToken().'&amp;mode=test&amp;varname=PRINTING_GCP_DEFAULT&amp;driver=printgcp&amp;value='.urlencode($printer_det['id']).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'off').'</a>'; } else $html .= '<a href="'.$_SERVER["PHP_SELF"].'?action=setvalue&amp;token='.newToken().'&amp;mode=test&amp;varname=PRINTING_GCP_DEFAULT&amp;driver=printgcp&amp;value='.urlencode($printer_det['id']).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'off').'</a>';
$html .= '</td>'; $html .= '</td>';
$html .= '</tr>'."\n"; $html .= '</tr>'."\n";
} }
$this->resprint = $html; $this->resprint = $html;
return $error; return $error;
} }
/** /**
* Return list of available printers * Return list of available printers
* *
* @return array list of printers * @return array list of printers
*/ */
public function getlistAvailablePrinters() public function getlistAvailablePrinters()
{ {
$ret = array(); $ret = array();
// Token storage // Token storage
$storage = new DoliStorage($this->db, $this->conf); $storage = new DoliStorage($this->db, $this->conf);
// Setup the credentials for the requests // Setup the credentials for the requests
$credentials = new Credentials( $credentials = new Credentials(
$this->google_id, $this->google_id,
$this->google_secret, $this->google_secret,
DOL_MAIN_URL_ROOT.'/core/modules/oauth/google_oauthcallback.php' DOL_MAIN_URL_ROOT.'/core/modules/oauth/google_oauthcallback.php'
); );
$serviceFactory = new \OAuth\ServiceFactory(); $serviceFactory = new \OAuth\ServiceFactory();
$apiService = $serviceFactory->createService($this->OAUTH_SERVICENAME_GOOGLE, $credentials, $storage, array()); $apiService = $serviceFactory->createService($this->OAUTH_SERVICENAME_GOOGLE, $credentials, $storage, array());
// Check if we have auth token // Check if we have auth token
$token_ok = true; $token_ok = true;
try { try {
$token = $storage->retrieveAccessToken($this->OAUTH_SERVICENAME_GOOGLE); $token = $storage->retrieveAccessToken($this->OAUTH_SERVICENAME_GOOGLE);
} catch (Exception $e) { } catch (Exception $e) {
$this->errors[] = $e->getMessage(); $this->errors[] = $e->getMessage();
$token_ok = false; $token_ok = false;
} }
$expire = false; $expire = false;
// Is token expired or will token expire in the next 30 seconds // Is token expired or will token expire in the next 30 seconds
if ($token_ok) { if ($token_ok) {
$expire = ($token->getEndOfLife() !== -9002 && $token->getEndOfLife() !== -9001 && time() > ($token->getEndOfLife() - 30)); $expire = ($token->getEndOfLife() !== -9002 && $token->getEndOfLife() !== -9001 && time() > ($token->getEndOfLife() - 30));
} }
// Token expired so we refresh it // Token expired so we refresh it
if ($token_ok && $expire) { if ($token_ok && $expire) {
try { try {
// il faut sauvegarder le refresh token car google ne le donne qu'une seule fois // il faut sauvegarder le refresh token car google ne le donne qu'une seule fois
$refreshtoken = $token->getRefreshToken(); $refreshtoken = $token->getRefreshToken();
$token = $apiService->refreshAccessToken($token); $token = $apiService->refreshAccessToken($token);
$token->setRefreshToken($refreshtoken); $token->setRefreshToken($refreshtoken);
$storage->storeAccessToken($this->OAUTH_SERVICENAME_GOOGLE, $token); $storage->storeAccessToken($this->OAUTH_SERVICENAME_GOOGLE, $token);
} catch (Exception $e) { } catch (Exception $e) {
$this->errors[] = $e->getMessage(); $this->errors[] = $e->getMessage();
} }
} }
// Send a request with api // Send a request with api
try { try {
$response = $apiService->request(self::PRINTERS_SEARCH_URL); $response = $apiService->request(self::PRINTERS_SEARCH_URL);
} catch (Exception $e) { } catch (Exception $e) {
$this->errors[] = $e->getMessage(); $this->errors[] = $e->getMessage();
print '<pre>'.print_r($e->getMessage(), true).'</pre>'; print '<pre>'.print_r($e->getMessage(), true).'</pre>';
} }
//print '<tr><td><pre>'.print_r($response, true).'</pre></td></tr>'; //print '<tr><td><pre>'.print_r($response, true).'</pre></td></tr>';
$responsedata = json_decode($response, true); $responsedata = json_decode($response, true);
$printers = $responsedata['printers']; $printers = $responsedata['printers'];
// Check if we have printers? // Check if we have printers?
if (count($printers) == 0) { if (count($printers) == 0) {
// We dont have printers so return blank array // We dont have printers so return blank array
$ret['available'] = array(); $ret['available'] = array();
} else { } else {
// We have printers so returns printers as array // We have printers so returns printers as array
$ret['available'] = $printers; $ret['available'] = $printers;
} }
return $ret; return $ret;
} }
/** /**
* Print selected file * Print selected file
* *
* @param string $file file * @param string $file file
* @param string $module module * @param string $module module
* @param string $subdir subdir for file * @param string $subdir subdir for file
* @return int 0 if OK, >0 if KO * @return int 0 if OK, >0 if KO
*/ */
public function printFile($file, $module, $subdir = '') public function printFile($file, $module, $subdir = '')
{ {
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
global $conf, $user; global $conf, $user;
$error = 0; $error = 0;
$fileprint = $conf->{$module}->dir_output; $fileprint = $conf->{$module}->dir_output;
if ($subdir != '') { if ($subdir != '') {
$fileprint .= '/'.$subdir; $fileprint .= '/'.$subdir;
} }
$fileprint .= '/'.$file; $fileprint .= '/'.$file;
$mimetype = dol_mimetype($fileprint); $mimetype = dol_mimetype($fileprint);
// select printer uri for module order, propal,... // select printer uri for module order, propal,...
$sql = "SELECT rowid, printer_id, copy FROM ".MAIN_DB_PREFIX."printing WHERE module='".$this->db->escape($module)."' AND driver='printgcp' AND userid=".$user->id; $sql = "SELECT rowid, printer_id, copy FROM ".MAIN_DB_PREFIX."printing WHERE module='".$this->db->escape($module)."' AND driver='printgcp' AND userid=".$user->id;
$result = $this->db->query($sql); $result = $this->db->query($sql);
if ($result) if ($result)
{ {
$obj = $this->db->fetch_object($result); $obj = $this->db->fetch_object($result);
if ($obj) if ($obj)
{ {
$printer_id = $obj->printer_id; $printer_id = $obj->printer_id;
} else { } else {
if (!empty($conf->global->PRINTING_GCP_DEFAULT)) if (!empty($conf->global->PRINTING_GCP_DEFAULT))
{ {
$printer_id = $conf->global->PRINTING_GCP_DEFAULT; $printer_id = $conf->global->PRINTING_GCP_DEFAULT;
} else { } else {
$this->errors[] = 'NoDefaultPrinterDefined'; $this->errors[] = 'NoDefaultPrinterDefined';
$error++; $error++;
return $error; return $error;
} }
} }
} else { } else {
dol_print_error($this->db); dol_print_error($this->db);
} }
$ret = $this->sendPrintToPrinter($printer_id, $file, $fileprint, $mimetype); $ret = $this->sendPrintToPrinter($printer_id, $file, $fileprint, $mimetype);
$this->error = 'PRINTGCP: '.$ret['errormessage']; $this->error = 'PRINTGCP: '.$ret['errormessage'];
if ($ret['status'] != 1) { if ($ret['status'] != 1) {
$error++; $error++;
} }
return $error; return $error;
} }
/** /**
* Sends document to the printer * Sends document to the printer
* *
* @param string $printerid Printer id returned by Google Cloud Print * @param string $printerid Printer id returned by Google Cloud Print
* @param string $printjobtitle Job Title * @param string $printjobtitle Job Title
* @param string $filepath File Path to be send to Google Cloud Print * @param string $filepath File Path to be send to Google Cloud Print
* @param string $contenttype File content type by example application/pdf, image/png * @param string $contenttype File content type by example application/pdf, image/png
* @return array status array * @return array status array
*/ */
public function sendPrintToPrinter($printerid, $printjobtitle, $filepath, $contenttype) public function sendPrintToPrinter($printerid, $printjobtitle, $filepath, $contenttype)
{ {
// Check if printer id // Check if printer id
if (empty($printerid)) { if (empty($printerid)) {
return array('status' =>0, 'errorcode' =>'', 'errormessage'=>'No provided printer ID'); return array('status' =>0, 'errorcode' =>'', 'errormessage'=>'No provided printer ID');
} }
// Open the file which needs to be print // Open the file which needs to be print
$handle = fopen($filepath, "rb"); $handle = fopen($filepath, "rb");
if (!$handle) { if (!$handle) {
return array('status' =>0, 'errorcode' =>'', 'errormessage'=>'Could not read the file.'); return array('status' =>0, 'errorcode' =>'', 'errormessage'=>'Could not read the file.');
} }
// Read file content // Read file content
$contents = fread($handle, filesize($filepath)); $contents = fread($handle, filesize($filepath));
fclose($handle); fclose($handle);
// Prepare post fields for sending print // Prepare post fields for sending print
$post_fields = array( $post_fields = array(
'printerid' => $printerid, 'printerid' => $printerid,
'title' => $printjobtitle, 'title' => $printjobtitle,
'contentTransferEncoding' => 'base64', 'contentTransferEncoding' => 'base64',
'content' => base64_encode($contents), // encode file content as base64 'content' => base64_encode($contents), // encode file content as base64
'contentType' => $contenttype, 'contentType' => $contenttype,
); );
// Dolibarr Token storage // Dolibarr Token storage
$storage = new DoliStorage($this->db, $this->conf); $storage = new DoliStorage($this->db, $this->conf);
// Setup the credentials for the requests // Setup the credentials for the requests
$credentials = new Credentials( $credentials = new Credentials(
$this->google_id, $this->google_id,
$this->google_secret, $this->google_secret,
DOL_MAIN_URL_ROOT.'/core/modules/oauth/google_oauthcallback.php?service=google' DOL_MAIN_URL_ROOT.'/core/modules/oauth/google_oauthcallback.php?service=google'
); );
$serviceFactory = new \OAuth\ServiceFactory(); $serviceFactory = new \OAuth\ServiceFactory();
$apiService = $serviceFactory->createService($this->OAUTH_SERVICENAME_GOOGLE, $credentials, $storage, array()); $apiService = $serviceFactory->createService($this->OAUTH_SERVICENAME_GOOGLE, $credentials, $storage, array());
// Check if we have auth token and refresh it // Check if we have auth token and refresh it
$token_ok = true; $token_ok = true;
try { try {
$token = $storage->retrieveAccessToken($this->OAUTH_SERVICENAME_GOOGLE); $token = $storage->retrieveAccessToken($this->OAUTH_SERVICENAME_GOOGLE);
} catch (Exception $e) { } catch (Exception $e) {
$this->errors[] = $e->getMessage(); $this->errors[] = $e->getMessage();
$token_ok = false; $token_ok = false;
} }
if ($token_ok) { if ($token_ok) {
try { try {
// il faut sauvegarder le refresh token car google ne le donne qu'une seule fois // il faut sauvegarder le refresh token car google ne le donne qu'une seule fois
$refreshtoken = $token->getRefreshToken(); $refreshtoken = $token->getRefreshToken();
$token = $apiService->refreshAccessToken($token); $token = $apiService->refreshAccessToken($token);
$token->setRefreshToken($refreshtoken); $token->setRefreshToken($refreshtoken);
$storage->storeAccessToken($this->OAUTH_SERVICENAME_GOOGLE, $token); $storage->storeAccessToken($this->OAUTH_SERVICENAME_GOOGLE, $token);
} catch (Exception $e) { } catch (Exception $e) {
$this->errors[] = $e->getMessage(); $this->errors[] = $e->getMessage();
} }
} }
// Send a request with api // Send a request with api
$response = json_decode($apiService->request(self::PRINT_URL, 'POST', $post_fields), true); $response = json_decode($apiService->request(self::PRINT_URL, 'POST', $post_fields), true);
//print '<tr><td><pre>'.print_r($response, true).'</pre></td></tr>'; //print '<tr><td><pre>'.print_r($response, true).'</pre></td></tr>';
return array('status' => $response['success'], 'errorcode' => $response['errorCode'], 'errormessage' => $response['message']); return array('status' => $response['success'], 'errorcode' => $response['errorCode'], 'errormessage' => $response['message']);
} }
/** /**
* List jobs print * List jobs print
* *
* @return int 0 if OK, >0 if KO * @return int 0 if OK, >0 if KO
*/ */
public function listJobs() public function listJobs()
{ {
global $conf, $langs; global $conf, $langs;
$error = 0; $error = 0;
$html = ''; $html = '';
// Token storage // Token storage
$storage = new DoliStorage($this->db, $this->conf); $storage = new DoliStorage($this->db, $this->conf);
// Setup the credentials for the requests // Setup the credentials for the requests
$credentials = new Credentials( $credentials = new Credentials(
$this->google_id, $this->google_id,
$this->google_secret, $this->google_secret,
DOL_MAIN_URL_ROOT.'/core/modules/oauth/google_oauthcallback.php' DOL_MAIN_URL_ROOT.'/core/modules/oauth/google_oauthcallback.php'
); );
$serviceFactory = new \OAuth\ServiceFactory(); $serviceFactory = new \OAuth\ServiceFactory();
$apiService = $serviceFactory->createService($this->OAUTH_SERVICENAME_GOOGLE, $credentials, $storage, array()); $apiService = $serviceFactory->createService($this->OAUTH_SERVICENAME_GOOGLE, $credentials, $storage, array());
// Check if we have auth token // Check if we have auth token
$token_ok = true; $token_ok = true;
try { try {
$token = $storage->retrieveAccessToken($this->OAUTH_SERVICENAME_GOOGLE); $token = $storage->retrieveAccessToken($this->OAUTH_SERVICENAME_GOOGLE);
} catch (Exception $e) { } catch (Exception $e) {
$this->errors[] = $e->getMessage(); $this->errors[] = $e->getMessage();
$token_ok = false; $token_ok = false;
$error++; $error++;
} }
$expire = false; $expire = false;
// Is token expired or will token expire in the next 30 seconds // Is token expired or will token expire in the next 30 seconds
if ($token_ok) { if ($token_ok) {
$expire = ($token->getEndOfLife() !== -9002 && $token->getEndOfLife() !== -9001 && time() > ($token->getEndOfLife() - 30)); $expire = ($token->getEndOfLife() !== -9002 && $token->getEndOfLife() !== -9001 && time() > ($token->getEndOfLife() - 30));
} }
// Token expired so we refresh it // Token expired so we refresh it
if ($token_ok && $expire) { if ($token_ok && $expire) {
try { try {
// il faut sauvegarder le refresh token car google ne le donne qu'une seule fois // il faut sauvegarder le refresh token car google ne le donne qu'une seule fois
$refreshtoken = $token->getRefreshToken(); $refreshtoken = $token->getRefreshToken();
$token = $apiService->refreshAccessToken($token); $token = $apiService->refreshAccessToken($token);
$token->setRefreshToken($refreshtoken); $token->setRefreshToken($refreshtoken);
$storage->storeAccessToken($this->OAUTH_SERVICENAME_GOOGLE, $token); $storage->storeAccessToken($this->OAUTH_SERVICENAME_GOOGLE, $token);
} catch (Exception $e) { } catch (Exception $e) {
$this->errors[] = $e->getMessage(); $this->errors[] = $e->getMessage();
$error++; $error++;
} }
} }
// Getting Jobs // Getting Jobs
// Send a request with api // Send a request with api
try { try {
$response = $apiService->request(self::PRINTERS_GET_JOBS); $response = $apiService->request(self::PRINTERS_GET_JOBS);
} catch (Exception $e) { } catch (Exception $e) {
$this->errors[] = $e->getMessage(); $this->errors[] = $e->getMessage();
$error++; $error++;
} }
$responsedata = json_decode($response, true); $responsedata = json_decode($response, true);
//$html .= '<pre>'.print_r($responsedata,true).'</pre>'; //$html .= '<pre>'.print_r($responsedata,true).'</pre>';
$html .= '<div class="div-table-responsive">'; $html .= '<div class="div-table-responsive">';
$html .= '<table width="100%" class="noborder">'; $html .= '<table width="100%" class="noborder">';
$html .= '<tr class="liste_titre">'; $html .= '<tr class="liste_titre">';
$html .= '<td>'.$langs->trans("Id").'</td>'; $html .= '<td>'.$langs->trans("Id").'</td>';
$html .= '<td>'.$langs->trans("Date").'</td>'; $html .= '<td>'.$langs->trans("Date").'</td>';
$html .= '<td>'.$langs->trans("Owner").'</td>'; $html .= '<td>'.$langs->trans("Owner").'</td>';
$html .= '<td>'.$langs->trans("Printer").'</td>'; $html .= '<td>'.$langs->trans("Printer").'</td>';
$html .= '<td>'.$langs->trans("Filename").'</td>'; $html .= '<td>'.$langs->trans("Filename").'</td>';
$html .= '<td>'.$langs->trans("Status").'</td>'; $html .= '<td>'.$langs->trans("Status").'</td>';
$html .= '<td>'.$langs->trans("Cancel").'</td>'; $html .= '<td>'.$langs->trans("Cancel").'</td>';
$html .= '</tr>'."\n"; $html .= '</tr>'."\n";
$jobs = $responsedata['jobs']; $jobs = $responsedata['jobs'];
//$html .= '<pre>'.print_r($jobs['0'],true).'</pre>'; //$html .= '<pre>'.print_r($jobs['0'],true).'</pre>';
if (is_array($jobs)) { if (is_array($jobs)) {
foreach ($jobs as $value) { foreach ($jobs as $value) {
$html .= '<tr class="oddeven">'; $html .= '<tr class="oddeven">';
$html .= '<td>'.$value['id'].'</td>'; $html .= '<td>'.$value['id'].'</td>';
$dates = dol_print_date((int) substr($value['createTime'], 0, 10), 'dayhour'); $dates = dol_print_date((int) substr($value['createTime'], 0, 10), 'dayhour');
$html .= '<td>'.$dates.'</td>'; $html .= '<td>'.$dates.'</td>';
$html .= '<td>'.$value['ownerId'].'</td>'; $html .= '<td>'.$value['ownerId'].'</td>';
$html .= '<td>'.$value['printerName'].'</td>'; $html .= '<td>'.$value['printerName'].'</td>';
$html .= '<td>'.$value['title'].'</td>'; $html .= '<td>'.$value['title'].'</td>';
$html .= '<td>'.$value['status'].'</td>'; $html .= '<td>'.$value['status'].'</td>';
$html .= '<td>&nbsp;</td>'; $html .= '<td>&nbsp;</td>';
$html .= '</tr>'; $html .= '</tr>';
} }
} else { } else {
$html .= '<tr class="oddeven">'; $html .= '<tr class="oddeven">';
$html .= '<td colspan="7" class="opacitymedium">'.$langs->trans("None").'</td>'; $html .= '<td colspan="7" class="opacitymedium">'.$langs->trans("None").'</td>';
$html .= '</tr>'; $html .= '</tr>';
} }
$html .= '</table>'; $html .= '</table>';
$html .= '</div>'; $html .= '</div>';
$this->resprint = $html; $this->resprint = $html;
return $error; return $error;
} }
} }

View File

@ -38,21 +38,21 @@ print "</tr>\n";
if ($action !== 'editcomment') if ($action !== 'editcomment')
{ {
print '<tr class="oddeven">'; print '<tr class="oddeven">';
// Description // Description
print '<td colspan="3">'; print '<td colspan="3">';
$desc = GETPOST('comment_description'); $desc = GETPOST('comment_description');
$doleditor = new DolEditor('comment_description', $desc, '', 80, 'dolibarr_notes', 'In', 0, true, true, ROWS_3, '100%'); $doleditor = new DolEditor('comment_description', $desc, '', 80, 'dolibarr_notes', 'In', 0, true, true, ROWS_3, '100%');
print $doleditor->Create(1); print $doleditor->Create(1);
print '</td>'; print '</td>';
print '<td class="center">'; print '<td class="center">';
print '<input type="submit" class="button" value="'.$langs->trans("Add").'">'; print '<input type="submit" class="button" value="'.$langs->trans("Add").'">';
print '</td></tr>'; print '</td></tr>';
} }
print '</table></form>'; print '</table></form>';
@ -96,47 +96,47 @@ if (!empty($object->comments))
print '<div class="comment-cell comment-right">'; print '<div class="comment-cell comment-right">';
print '<div class="comment-table width100p">'; print '<div class="comment-table width100p">';
if ($action === 'editcomment' && $comment->id == $idcomment) if ($action === 'editcomment' && $comment->id == $idcomment)
{ {
print '<form method="POST" action="'.$varpage.'?id='.$object->id.'">'; print '<form method="POST" action="'.$varpage.'?id='.$object->id.'">';
print '<input type="hidden" name="token" value="'.newToken().'">'; print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="action" value="updatecomment">'; print '<input type="hidden" name="action" value="updatecomment">';
print '<input type="hidden" name="id" value="'.$object->id.'">'; print '<input type="hidden" name="id" value="'.$object->id.'">';
print '<input type="hidden" name="idcomment" value="'.$idcomment.'">'; print '<input type="hidden" name="idcomment" value="'.$idcomment.'">';
print '<input type="hidden" name="withproject" value="'.$withproject.'">'; print '<input type="hidden" name="withproject" value="'.$withproject.'">';
} }
print '<div class="comment-description comment-cell">'; print '<div class="comment-description comment-cell">';
if ($action === 'editcomment' && $comment->id == $idcomment) if ($action === 'editcomment' && $comment->id == $idcomment)
{ {
$doleditor = new DolEditor('comment_description', $comment->description, '', 80, 'dolibarr_notes', 'In', 0, true, true, ROWS_3, '100%'); $doleditor = new DolEditor('comment_description', $comment->description, '', 80, 'dolibarr_notes', 'In', 0, true, true, ROWS_3, '100%');
print $doleditor->Create(1); print $doleditor->Create(1);
} else { } else {
print $comment->description; print $comment->description;
} }
print '</div>'; // End comment-description print '</div>'; // End comment-description
if ($action === 'editcomment' && $comment->id == $idcomment) if ($action === 'editcomment' && $comment->id == $idcomment)
{ {
print '<input name="update" type="submit" class="button" value="'.$langs->trans("Update").'">'; print '<input name="update" type="submit" class="button" value="'.$langs->trans("Update").'">';
print '<input name="cancel" type="submit" class="button" value="'.$langs->trans("Cancel").'">'; print '<input name="cancel" type="submit" class="button" value="'.$langs->trans("Cancel").'">';
print '</form>'; print '</form>';
} else { } else {
if ($fk_user == $user->id || $user->admin == 1) if ($fk_user == $user->id || $user->admin == 1)
{ {
print '<a class="comment-edit comment-cell" href="'.$varpage.'?action=editcomment&token='.newToken().'&id='.$id.'&withproject=1&idcomment='.$comment->id.'#comment" title="'.$langs->trans('Edit').'">'; print '<a class="comment-edit comment-cell" href="'.$varpage.'?action=editcomment&token='.newToken().'&id='.$id.'&withproject=1&idcomment='.$comment->id.'#comment" title="'.$langs->trans('Edit').'">';
print img_picto('', 'edit.png'); print img_picto('', 'edit.png');
print '</a>'; print '</a>';
} }
if (($first && $fk_user == $user->id) || $user->admin == 1) { if (($first && $fk_user == $user->id) || $user->admin == 1) {
print '<a class="comment-delete comment-cell" href="'.$varpage.'?action=deletecomment&token='.newToken().'&id='.$id.'&withproject=1&idcomment='.$comment->id.'" title="'.$langs->trans('Delete').'">'; print '<a class="comment-delete comment-cell" href="'.$varpage.'?action=deletecomment&token='.newToken().'&id='.$id.'&withproject=1&idcomment='.$comment->id.'" title="'.$langs->trans('Delete').'">';
print img_picto('', 'delete.png'); print img_picto('', 'delete.png');
print '</a>'; print '</a>';
} }
} }
print '</div>'; // End comment-table print '</div>'; // End comment-table
print '</div>'; // End comment-right print '</div>'; // End comment-right
print '</div>'; // End comment print '</div>'; // End comment

View File

@ -35,7 +35,7 @@ class EcmDirectory extends CommonObject
/** /**
* @var string Name of table without prefix where object is stored * @var string Name of table without prefix where object is stored
*/ */
public $table_element='ecm_directories'; public $table_element = 'ecm_directories';
/** /**
* @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png * @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png

View File

@ -44,8 +44,8 @@ $socid = GETPOST("socid", "int");
// Security check // Security check
if ($user->socid > 0) if ($user->socid > 0)
{ {
$action = ''; $action = '';
$socid = $user->socid; $socid = $user->socid;
} }
$limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit;
@ -62,14 +62,14 @@ if (!$sortfield) $sortfield = "label";
$section = GETPOST("section", 'alpha'); $section = GETPOST("section", 'alpha');
if (!$section) if (!$section)
{ {
dol_print_error('', 'Error, section parameter missing'); dol_print_error('', 'Error, section parameter missing');
exit; exit;
} }
$urlfile = GETPOST("urlfile"); $urlfile = GETPOST("urlfile");
if (!$urlfile) if (!$urlfile)
{ {
dol_print_error('', "ErrorParamNotDefined"); dol_print_error('', "ErrorParamNotDefined");
exit; exit;
} }
// Load ecm object // Load ecm object
@ -77,8 +77,8 @@ $ecmdir = new EcmDirectory($db);
$result = $ecmdir->fetch(GETPOST("section", 'alpha')); $result = $ecmdir->fetch(GETPOST("section", 'alpha'));
if (!$result > 0) if (!$result > 0)
{ {
dol_print_error($db, $ecmdir->error); dol_print_error($db, $ecmdir->error);
exit; exit;
} }
$relativepath = $ecmdir->getRelativePath(); $relativepath = $ecmdir->getRelativePath();
$upload_dir = $conf->ecm->dir_output.'/'.$relativepath; $upload_dir = $conf->ecm->dir_output.'/'.$relativepath;
@ -114,67 +114,67 @@ if ($result < 0)
if ($cancel) if ($cancel)
{ {
$action = ''; $action = '';
if ($backtopage) if ($backtopage)
{ {
header("Location: ".$backtopage); header("Location: ".$backtopage);
exit; exit;
} else { } else {
header('Location: '.$_SERVER["PHP_SELF"].'?urlfile='.urlencode($urlfile).'&section='.urlencode($section).($module ? '&module='.urlencode($module) : '')); header('Location: '.$_SERVER["PHP_SELF"].'?urlfile='.urlencode($urlfile).'&section='.urlencode($section).($module ? '&module='.urlencode($module) : ''));
exit; exit;
} }
} }
// Rename file // Rename file
if ($action == 'update') if ($action == 'update')
{ {
$error = 0; $error = 0;
$oldlabel = GETPOST('urlfile', 'alpha'); $oldlabel = GETPOST('urlfile', 'alpha');
$newlabel = dol_sanitizeFileName(GETPOST('label', 'alpha')); $newlabel = dol_sanitizeFileName(GETPOST('label', 'alpha'));
$shareenabled = GETPOST('shareenabled', 'alpha'); $shareenabled = GETPOST('shareenabled', 'alpha');
//$db->begin(); //$db->begin();
$olddir = $ecmdir->getRelativePath(0); // Relative to ecm $olddir = $ecmdir->getRelativePath(0); // Relative to ecm
$olddirrelativetodocument = 'ecm/'.$olddir; // Relative to document $olddirrelativetodocument = 'ecm/'.$olddir; // Relative to document
$newdirrelativetodocument = 'ecm/'.$olddir; $newdirrelativetodocument = 'ecm/'.$olddir;
$olddir = $conf->ecm->dir_output.'/'.$olddir; $olddir = $conf->ecm->dir_output.'/'.$olddir;
$newdir = $olddir; $newdir = $olddir;
$oldfile = $olddir.$oldlabel; $oldfile = $olddir.$oldlabel;
$newfile = $newdir.$newlabel; $newfile = $newdir.$newlabel;
$newfileformove = $newfile; $newfileformove = $newfile;
// If old file end with .noexe, new file must also end with .noexe // If old file end with .noexe, new file must also end with .noexe
if (preg_match('/\.noexe$/', $oldfile) && ! preg_match('/\.noexe$/', $newfileformove)) { if (preg_match('/\.noexe$/', $oldfile) && ! preg_match('/\.noexe$/', $newfileformove)) {
$newfileformove .= '.noexe'; $newfileformove .= '.noexe';
} }
//var_dump($oldfile);var_dump($newfile);exit; //var_dump($oldfile);var_dump($newfile);exit;
// Now we update index of file // Now we update index of file
$db->begin(); $db->begin();
//print $oldfile.' - '.$newfile; //print $oldfile.' - '.$newfile;
if ($newlabel != $oldlabel) if ($newlabel != $oldlabel)
{ {
$result = dol_move($oldfile, $newfileformove); // This include update of database $result = dol_move($oldfile, $newfileformove); // This include update of database
if (!$result) if (!$result)
{ {
$langs->load('errors'); $langs->load('errors');
setEventMessages($langs->trans('ErrorFailToRenameFile', $oldfile, $newfile), null, 'errors'); setEventMessages($langs->trans('ErrorFailToRenameFile', $oldfile, $newfile), null, 'errors');
$error++; $error++;
} }
// Reload object after the move // Reload object after the move
$result = $object->fetch(0, '', $newdirrelativetodocument.$newlabel); $result = $object->fetch(0, '', $newdirrelativetodocument.$newlabel);
if ($result < 0) if ($result < 0)
{ {
dol_print_error($db, $object->error, $object->errors); dol_print_error($db, $object->error, $object->errors);
exit; exit;
} }
} }
if (!$error) if (!$error)
{ {
if ($shareenabled) if ($shareenabled)
{ {
require_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php';
@ -217,23 +217,23 @@ if ($action == 'update')
setEventMessages($object->error, $object->errors, 'warnings'); setEventMessages($object->error, $object->errors, 'warnings');
} }
} }
} }
if (!$error) if (!$error)
{ {
$db->commit(); $db->commit();
$urlfile = $newlabel; $urlfile = $newlabel;
// If old file end with .noexe, new file must also end with .noexe // If old file end with .noexe, new file must also end with .noexe
if (preg_match('/\.noexe$/', $newfileformove)) { if (preg_match('/\.noexe$/', $newfileformove)) {
$urlfile .= '.noexe'; $urlfile .= '.noexe';
} }
header('Location: '.$_SERVER["PHP_SELF"].'?urlfile='.urlencode($urlfile).'&section='.urlencode($section)); header('Location: '.$_SERVER["PHP_SELF"].'?urlfile='.urlencode($urlfile).'&section='.urlencode($section));
exit; exit;
} else { } else {
$db->rollback(); $db->rollback();
} }
} }
@ -381,7 +381,7 @@ if (!empty($object->share))
} }
print '</td>'; print '</td>';
print '</tr>'; print '</tr>';
print $object->showOptionals($extrafields, ($action == 'edit'?'edit':'view')); print $object->showOptionals($extrafields, ($action == 'edit' ? 'edit' : 'view'));
print '</table>'; print '</table>';
print '</div>'; print '</div>';
@ -392,20 +392,20 @@ dol_fiche_end();
if ($action == 'edit') if ($action == 'edit')
{ {
print '<div class="center">'; print '<div class="center">';
print '<input type="submit" class="button" name="submit" value="'.$langs->trans("Save").'">'; print '<input type="submit" class="button" name="submit" value="'.$langs->trans("Save").'">';
print ' &nbsp; &nbsp; '; print ' &nbsp; &nbsp; ';
print '<input type="submit" class="button" name="cancel" value="'.$langs->trans("Cancel").'">'; print '<input type="submit" class="button" name="cancel" value="'.$langs->trans("Cancel").'">';
print '</div>'; print '</div>';
print '</form>'; print '</form>';
} }
// Confirmation de la suppression d'une ligne categorie // Confirmation de la suppression d'une ligne categorie
if ($action == 'delete_file') if ($action == 'delete_file')
{ {
print $form->formconfirm($_SERVER["PHP_SELF"].'?section='.urlencode($section), $langs->trans('DeleteFile'), $langs->trans('ConfirmDeleteFile', $urlfile), 'confirm_deletefile', '', 1, 1); print $form->formconfirm($_SERVER["PHP_SELF"].'?section='.urlencode($section), $langs->trans('DeleteFile'), $langs->trans('ConfirmDeleteFile', $urlfile), 'confirm_deletefile', '', 1, 1);
} }
if ($action != 'edit') if ($action != 'edit')
@ -413,11 +413,11 @@ if ($action != 'edit')
// Actions buttons // Actions buttons
print '<div class="tabsAction">'; print '<div class="tabsAction">';
if ($user->rights->ecm->setup) if ($user->rights->ecm->setup)
{ {
print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?action=edit&section='.urlencode($section).'&urlfile='.urlencode($urlfile).'">'.$langs->trans('Edit').'</a>'; print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?action=edit&section='.urlencode($section).'&urlfile='.urlencode($urlfile).'">'.$langs->trans('Edit').'</a>';
} }
/* /*
if ($user->rights->ecm->setup) if ($user->rights->ecm->setup)
{ {
print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?action=delete_file&token='.newToken().'&section='.$section.'&urlfile='.urlencode($urlfile).'">'.$langs->trans('Delete').'</a>'; print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?action=delete_file&token='.newToken().'&section='.$section.'&urlfile='.urlencode($urlfile).'">'.$langs->trans('Delete').'</a>';

View File

@ -405,7 +405,7 @@ class ExpenseReport extends CommonObject
$this->id = 0; $this->id = 0;
$this->ref = ''; $this->ref = '';
$this->status = 0; $this->status = 0;
$this->fk_statut = 0; // deprecated $this->fk_statut = 0; // deprecated
// Clear fields // Clear fields
$this->fk_user_author = $fk_user_author; // Note fk_user_author is not the 'author' but the guy the expense report is for. $this->fk_user_author = $fk_user_author; // Note fk_user_author is not the 'author' but the guy the expense report is for.
@ -1353,7 +1353,7 @@ class ExpenseReport extends CommonObject
$sql .= ' WHERE rowid = '.$this->id; $sql .= ' WHERE rowid = '.$this->id;
if ($this->db->query($sql)) if ($this->db->query($sql))
{ {
$this->fk_statut = 99; // deprecated $this->fk_statut = 99; // deprecated
$this->status = 99; $this->status = 99;
$this->fk_user_refuse = $fuser->id; $this->fk_user_refuse = $fuser->id;
$this->detail_refuse = $details; $this->detail_refuse = $details;

View File

@ -202,16 +202,16 @@ if (empty($reshook))
} }
} elseif ($action == 'add' && $user->rights->ficheinter->creer) } elseif ($action == 'add' && $user->rights->ficheinter->creer)
{ {
$object->socid = $socid; $object->socid = $socid;
$object->duration = GETPOST('duration', 'int'); $object->duration = GETPOST('duration', 'int');
$object->fk_project = GETPOST('projectid', 'int'); $object->fk_project = GETPOST('projectid', 'int');
$object->fk_contrat = GETPOST('contratid', 'int'); $object->fk_contrat = GETPOST('contratid', 'int');
$object->author = $user->id; $object->author = $user->id;
$object->description = GETPOST('description', 'restricthtml'); $object->description = GETPOST('description', 'restricthtml');
$object->ref = $ref; $object->ref = $ref;
$object->model_pdf = GETPOST('model', 'alpha'); $object->model_pdf = GETPOST('model', 'alpha');
$object->note_private = GETPOST('note_private', 'restricthtml'); $object->note_private = GETPOST('note_private', 'restricthtml');
$object->note_public = GETPOST('note_public', 'restricthtml'); $object->note_public = GETPOST('note_public', 'restricthtml');
if ($object->socid > 0) if ($object->socid > 0)
{ {
@ -251,7 +251,7 @@ if (empty($reshook))
$extrafields = new ExtraFields($db); $extrafields = new ExtraFields($db);
$array_options = $extrafields->getOptionalsFromPost($object->table_element); $array_options = $extrafields->getOptionalsFromPost($object->table_element);
$object->array_options = $array_options; $object->array_options = $array_options;
$id = $object->create($user); $id = $object->create($user);
@ -356,12 +356,12 @@ if (empty($reshook))
$result = $object->addline( $result = $object->addline(
$user, $user,
$id, $id,
$desc, $desc,
$date_intervention, $date_intervention,
$duration, $duration,
$array_options $array_options
); );
if ($result < 0) if ($result < 0)
{ {
@ -371,44 +371,44 @@ if (empty($reshook))
} }
} }
} }
} else { } else {
$mesg = $srcobject->error; $mesg = $srcobject->error;
$error++; $error++;
} }
} else { } else {
$mesg = $object->error; $mesg = $object->error;
$error++; $error++;
} }
} else { } else {
// Fill array 'array_options' with data from add form // Fill array 'array_options' with data from add form
$ret = $extrafields->setOptionalsFromPost(null, $object); $ret = $extrafields->setOptionalsFromPost(null, $object);
if ($ret < 0) { if ($ret < 0) {
$error++; $error++;
$action = 'create'; $action = 'create';
} }
if (!$error) if (!$error)
{ {
// Extrafields // Extrafields
$array_options = $extrafields->getOptionalsFromPost($object->table_element); $array_options = $extrafields->getOptionalsFromPost($object->table_element);
$object->array_options = $array_options; $object->array_options = $array_options;
$result = $object->create($user); $result = $object->create($user);
if ($result > 0) if ($result > 0)
{ {
$id = $result; // Force raffraichissement sur fiche venant d'etre cree $id = $result; // Force raffraichissement sur fiche venant d'etre cree
} else { } else {
$langs->load("errors"); $langs->load("errors");
setEventMessages($object->error, $object->errors, 'errors'); setEventMessages($object->error, $object->errors, 'errors');
$action = 'create'; $action = 'create';
} }
} }
} }
} else { } else {
$mesg = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("ThirdParty")); $mesg = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("ThirdParty"));
$action = 'create'; $action = 'create';
} }
} elseif ($action == 'update' && $user->rights->ficheinter->creer) } elseif ($action == 'update' && $user->rights->ficheinter->creer)
{ {
$object->socid = $socid; $object->socid = $socid;
@ -482,14 +482,14 @@ if (empty($reshook))
$extrafields->fetch_name_optionals_label($object->table_element_line); $extrafields->fetch_name_optionals_label($object->table_element_line);
$array_options = $extrafields->getOptionalsFromPost($object->table_element_line); $array_options = $extrafields->getOptionalsFromPost($object->table_element_line);
$result = $object->addline( $result = $object->addline(
$user, $user,
$id, $id,
$desc, $desc,
$date_intervention, $date_intervention,
$duration, $duration,
$array_options $array_options
); );
// Define output language // Define output language
$outputlangs = $langs; $outputlangs = $langs;
@ -545,14 +545,14 @@ if (empty($reshook))
// Classify Done // Classify Done
elseif ($action == 'classifydone' && $user->rights->ficheinter->creer) elseif ($action == 'classifydone' && $user->rights->ficheinter->creer)
{ {
$result = $object->setStatut(3); $result = $object->setStatut(3);
if ($result > 0) if ($result > 0)
{ {
header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id); header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id);
exit; exit;
} else { } else {
setEventMessages($object->error, $object->errors, 'errors'); setEventMessages($object->error, $object->errors, 'errors');
} }
} }
// Reopen // Reopen
@ -591,9 +591,9 @@ if (empty($reshook))
$date_inter = dol_mktime(GETPOST('dihour', 'int'), GETPOST('dimin', 'int'), 0, GETPOST('dimonth', 'int'), GETPOST('diday', 'int'), GETPOST('diyear', 'int')); $date_inter = dol_mktime(GETPOST('dihour', 'int'), GETPOST('dimin', 'int'), 0, GETPOST('dimonth', 'int'), GETPOST('diday', 'int'), GETPOST('diyear', 'int'));
$duration = convertTime2Seconds(GETPOST('durationhour', 'int'), GETPOST('durationmin', 'int')); $duration = convertTime2Seconds(GETPOST('durationhour', 'int'), GETPOST('durationmin', 'int'));
$objectline->datei = $date_inter; $objectline->datei = $date_inter;
$objectline->desc = $desc; $objectline->desc = $desc;
$objectline->duration = $duration; $objectline->duration = $duration;
// Extrafields // Extrafields
$extrafields->fetch_name_optionals_label($object->table_element_line); $extrafields->fetch_name_optionals_label($object->table_element_line);
@ -601,11 +601,11 @@ if (empty($reshook))
$objectline->array_options = $array_options; $objectline->array_options = $array_options;
$result = $objectline->update($user); $result = $objectline->update($user);
if ($result < 0) if ($result < 0)
{ {
dol_print_error($db); dol_print_error($db);
exit; exit;
} }
// Define output language // Define output language
$outputlangs = $langs; $outputlangs = $langs;
@ -817,11 +817,11 @@ if ($action == 'create')
$subelement = $regs[2]; $subelement = $regs[2];
} }
if ($element == 'project') if ($element == 'project')
{ {
$projectid = GETPOST('originid', 'int'); $projectid = GETPOST('originid', 'int');
} else { } else {
// For compatibility // For compatibility
if ($element == 'order' || $element == 'commande') { if ($element == 'order' || $element == 'commande') {
$element = $subelement = 'commande'; $element = $subelement = 'commande';
} }
@ -904,20 +904,20 @@ if ($action == 'create')
$langs->load("project"); $langs->load("project");
print '<tr><td>'.$langs->trans("Project").'</td><td>'; print '<tr><td>'.$langs->trans("Project").'</td><td>';
/* Fix: If a project must be linked to any companies (suppliers or not), project must be not be set as limited to customer but must be not linked to any particular thirdparty /* Fix: If a project must be linked to any companies (suppliers or not), project must be not be set as limited to customer but must be not linked to any particular thirdparty
if ($societe->fournisseur==1) if ($societe->fournisseur==1)
$numprojet=select_projects(-1,$_POST["projectid"],'projectid'); $numprojet=select_projects(-1,$_POST["projectid"],'projectid');
else else
$numprojet=select_projects($societe->id,$_POST["projectid"],'projectid'); $numprojet=select_projects($societe->id,$_POST["projectid"],'projectid');
*/ */
$numprojet = $formproject->select_projects($soc->id, $projectid, 'projectid'); $numprojet = $formproject->select_projects($soc->id, $projectid, 'projectid');
if ($numprojet == 0) if ($numprojet == 0)
{ {
print ' &nbsp; <a href="'.DOL_URL_ROOT.'/projet/card.php?socid='.$soc->id.'&action=create"><span class="fa fa-plus-circle valignmiddle paddingleft" title="'.$langs->trans("AddProject").'"></span></a>'; print ' &nbsp; <a href="'.DOL_URL_ROOT.'/projet/card.php?socid='.$soc->id.'&action=create"><span class="fa fa-plus-circle valignmiddle paddingleft" title="'.$langs->trans("AddProject").'"></span></a>';
} }
print '</td></tr>'; print '</td></tr>';
} }
// Contract // Contract
if ($conf->contrat->enabled) if ($conf->contrat->enabled)
@ -932,53 +932,53 @@ if ($action == 'create')
print '</td></tr>'; print '</td></tr>';
} }
// Model // Model
print '<tr>'; print '<tr>';
print '<td>'.$langs->trans("DefaultModel").'</td>'; print '<td>'.$langs->trans("DefaultModel").'</td>';
print '<td>'; print '<td>';
$liste = ModelePDFFicheinter::liste_modeles($db); $liste = ModelePDFFicheinter::liste_modeles($db);
print $form->selectarray('model', $liste, $conf->global->FICHEINTER_ADDON_PDF); print $form->selectarray('model', $liste, $conf->global->FICHEINTER_ADDON_PDF);
print "</td></tr>"; print "</td></tr>";
// Public note // Public note
print '<tr>'; print '<tr>';
print '<td class="tdtop">'.$langs->trans('NotePublic').'</td>'; print '<td class="tdtop">'.$langs->trans('NotePublic').'</td>';
print '<td>'; print '<td>';
$doleditor = new DolEditor('note_public', $note_public, '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, '90%'); $doleditor = new DolEditor('note_public', $note_public, '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, '90%');
print $doleditor->Create(1); print $doleditor->Create(1);
//print '<textarea name="note_public" cols="80" rows="'.ROWS_3.'">'.$note_public.'</textarea>'; //print '<textarea name="note_public" cols="80" rows="'.ROWS_3.'">'.$note_public.'</textarea>';
print '</td></tr>'; print '</td></tr>';
// Private note // Private note
if (empty($user->socid)) if (empty($user->socid))
{ {
print '<tr>'; print '<tr>';
print '<td class="tdtop">'.$langs->trans('NotePrivate').'</td>'; print '<td class="tdtop">'.$langs->trans('NotePrivate').'</td>';
print '<td>'; print '<td>';
$doleditor = new DolEditor('note_private', $note_private, '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, '90%'); $doleditor = new DolEditor('note_private', $note_private, '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, '90%');
print $doleditor->Create(1); print $doleditor->Create(1);
//print '<textarea name="note_private" cols="80" rows="'.ROWS_3.'">'.$note_private.'</textarea>'; //print '<textarea name="note_private" cols="80" rows="'.ROWS_3.'">'.$note_private.'</textarea>';
print '</td></tr>'; print '</td></tr>';
} }
// Other attributes // Other attributes
$parameters = array(); $parameters = array();
$reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
print $hookmanager->resPrint; print $hookmanager->resPrint;
if (empty($reshook)) if (empty($reshook))
{ {
print $object->showOptionals($extrafields, 'edit'); print $object->showOptionals($extrafields, 'edit');
} }
// Show link to origin object // Show link to origin object
if (!empty($origin) && !empty($originid) && is_object($objectsrc)) if (!empty($origin) && !empty($originid) && is_object($objectsrc))
{ {
$newclassname = $classname; $newclassname = $classname;
if ($newclassname == 'Propal') $newclassname = 'CommercialProposal'; if ($newclassname == 'Propal') $newclassname = 'CommercialProposal';
print '<tr><td>'.$langs->trans($newclassname).'</td><td colspan="2">'.$objectsrc->getNomUrl(1).'</td></tr>'; print '<tr><td>'.$langs->trans($newclassname).'</td><td colspan="2">'.$objectsrc->getNomUrl(1).'</td></tr>';
// Amount // Amount
/* Hide amount because we only copy services so amount may differ than source /* Hide amount because we only copy services so amount may differ than source
print '<tr><td>' . $langs->trans('AmountHT') . '</td><td>' . price($objectsrc->total_ht) . '</td></tr>'; print '<tr><td>' . $langs->trans('AmountHT') . '</td><td>' . price($objectsrc->total_ht) . '</td></tr>';
print '<tr><td>' . $langs->trans('AmountVAT') . '</td><td>' . price($objectsrc->total_tva) . "</td></tr>"; print '<tr><td>' . $langs->trans('AmountVAT') . '</td><td>' . price($objectsrc->total_tva) . "</td></tr>";
if ($mysoc->localtax1_assuj == "1" || $objectsrc->total_localtax1 != 0) // Localtax1 RE if ($mysoc->localtax1_assuj == "1" || $objectsrc->total_localtax1 != 0) // Localtax1 RE
@ -1000,14 +1000,14 @@ if ($action == 'create')
print '<tr><td>' . $langs->trans('MulticurrencyAmountTTC') . '</td><td>' . price($objectsrc->multicurrency_total_ttc) . "</td></tr>"; print '<tr><td>' . $langs->trans('MulticurrencyAmountTTC') . '</td><td>' . price($objectsrc->multicurrency_total_ttc) . "</td></tr>";
} }
*/ */
} }
print '</table>'; print '</table>';
if (is_object($objectsrc)) if (is_object($objectsrc))
{ {
print '<input type="hidden" name="origin" value="'.$objectsrc->element.'">'; print '<input type="hidden" name="origin" value="'.$objectsrc->element.'">';
print '<input type="hidden" name="originid" value="'.$objectsrc->id.'">'; print '<input type="hidden" name="originid" value="'.$objectsrc->id.'">';
} elseif ($origin == 'project' && !empty($projectid)) { } elseif ($origin == 'project' && !empty($projectid)) {
print '<input type="hidden" name="projectid" value="'.$projectid.'">'; print '<input type="hidden" name="projectid" value="'.$projectid.'">';
} }
@ -1016,8 +1016,8 @@ if ($action == 'create')
print '<div class="center">'; print '<div class="center">';
print '<input type="submit" class="button" value="'.$langs->trans("CreateDraftIntervention").'">'; print '<input type="submit" class="button" value="'.$langs->trans("CreateDraftIntervention").'">';
print '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'; print '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
print '<input type="button" class="button" value="'.$langs->trans("Cancel").'" onClick="javascript:history.go(-1)">'; print '<input type="button" class="button" value="'.$langs->trans("Cancel").'" onClick="javascript:history.go(-1)">';
print '</div>'; print '</div>';
print '</form>'; print '</form>';
@ -1058,8 +1058,8 @@ if ($action == 'create')
print '<div class="center">'; print '<div class="center">';
print '<input type="hidden" name="action" value="create">'; print '<input type="hidden" name="action" value="create">';
print '<input type="submit" class="button" value="'.$langs->trans("CreateDraftIntervention").'">'; print '<input type="submit" class="button" value="'.$langs->trans("CreateDraftIntervention").'">';
print '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'; print '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
print '<input type="button" class="button" value="'.$langs->trans("Cancel").'" onClick="javascript:history.go(-1)">'; print '<input type="button" class="button" value="'.$langs->trans("Cancel").'" onClick="javascript:history.go(-1)">';
print '</div>'; print '</div>';
print '</form>'; print '</form>';
@ -1172,46 +1172,46 @@ if ($action == 'create')
// Project // Project
if (!empty($conf->projet->enabled)) if (!empty($conf->projet->enabled))
{ {
$langs->load("projects"); $langs->load("projects");
$morehtmlref .= '<br>'.$langs->trans('Project').' '; $morehtmlref .= '<br>'.$langs->trans('Project').' ';
if ($user->rights->ficheinter->creer) if ($user->rights->ficheinter->creer)
{ {
if ($action != 'classify') { if ($action != 'classify') {
$morehtmlref .= '<a class="editfielda" href="'.$_SERVER['PHP_SELF'].'?action=classify&amp;id='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('SetProject')).'</a> : '; $morehtmlref .= '<a class="editfielda" href="'.$_SERVER['PHP_SELF'].'?action=classify&amp;id='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('SetProject')).'</a> : ';
} }
if ($action == 'classify') { if ($action == 'classify') {
//$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1);
$morehtmlref .= '<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">'; $morehtmlref .= '<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">';
$morehtmlref .= '<input type="hidden" name="action" value="classin">'; $morehtmlref .= '<input type="hidden" name="action" value="classin">';
$morehtmlref .= '<input type="hidden" name="token" value="'.newToken().'">'; $morehtmlref .= '<input type="hidden" name="token" value="'.newToken().'">';
$morehtmlref .= $formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); $morehtmlref .= $formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1);
$morehtmlref .= '<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">'; $morehtmlref .= '<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">';
$morehtmlref .= '</form>'; $morehtmlref .= '</form>';
} else { } else {
$morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1);
} }
} else { } else {
if (!empty($object->fk_project)) { if (!empty($object->fk_project)) {
$proj = new Project($db); $proj = new Project($db);
$proj->fetch($object->fk_project); $proj->fetch($object->fk_project);
$morehtmlref .= '<a href="'.DOL_URL_ROOT.'/projet/card.php?id='.$object->fk_project.'" title="'.$langs->trans('ShowProject').'">'; $morehtmlref .= '<a href="'.DOL_URL_ROOT.'/projet/card.php?id='.$object->fk_project.'" title="'.$langs->trans('ShowProject').'">';
$morehtmlref .= $proj->ref; $morehtmlref .= $proj->ref;
$morehtmlref .= '</a>'; $morehtmlref .= '</a>';
} else { } else {
$morehtmlref .= ''; $morehtmlref .= '';
} }
} }
} }
$morehtmlref .= '</div>'; $morehtmlref .= '</div>';
dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
print '<div class="fichecenter">'; print '<div class="fichecenter">';
print '<div class="fichehalfleft">'; print '<div class="fichehalfleft">';
print '<div class="underbanner clearboth"></div>'; print '<div class="underbanner clearboth"></div>';
print '<table class="border tableforfield" width="100%">'; print '<table class="border tableforfield" width="100%">';
if (!empty($conf->global->FICHINTER_USE_PLANNED_AND_DONE_DATES)) if (!empty($conf->global->FICHINTER_USE_PLANNED_AND_DONE_DATES))
{ {
@ -1269,47 +1269,47 @@ if ($action == 'create')
$formcontract->formSelectContract($_SERVER["PHP_SELF"].'?id='.$object->id, $object->socid, $object->fk_contrat, 'contratid', 0, 1, 1); $formcontract->formSelectContract($_SERVER["PHP_SELF"].'?id='.$object->id, $object->socid, $object->fk_contrat, 'contratid', 0, 1, 1);
} else { } else {
if ($object->fk_contrat) if ($object->fk_contrat)
{ {
$contratstatic = new Contrat($db); $contratstatic = new Contrat($db);
$contratstatic->fetch($object->fk_contrat); $contratstatic->fetch($object->fk_contrat);
//print '<a href="'.DOL_URL_ROOT.'/projet/card.php?id='.$selected.'">'.$projet->title.'</a>'; //print '<a href="'.DOL_URL_ROOT.'/projet/card.php?id='.$selected.'">'.$projet->title.'</a>';
print $contratstatic->getNomUrl(0, '', 1); print $contratstatic->getNomUrl(0, '', 1);
} else { } else {
print "&nbsp;"; print "&nbsp;";
} }
} }
print '</td>'; print '</td>';
print '</tr>'; print '</tr>';
} }
// Other attributes // Other attributes
$cols = 2; $cols = 2;
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php'; include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php';
print '</table>'; print '</table>';
print '</div>'; print '</div>';
print '<div class="fichehalfright">'; print '<div class="fichehalfright">';
print '<div class="ficheaddleft">'; print '<div class="ficheaddleft">';
print '<div class="underbanner clearboth"></div>'; print '<div class="underbanner clearboth"></div>';
print '<table class="border tableforfield centpercent">'; print '<table class="border tableforfield centpercent">';
if (empty($conf->global->FICHINTER_DISABLE_DETAILS)) if (empty($conf->global->FICHINTER_DISABLE_DETAILS))
{ {
// Duration // Duration
print '<tr><td class="titlefield">'.$langs->trans("TotalDuration").'</td>'; print '<tr><td class="titlefield">'.$langs->trans("TotalDuration").'</td>';
print '<td>'.convertSecondToTime($object->duration, 'all', $conf->global->MAIN_DURATION_OF_WORKDAY).'</td>'; print '<td>'.convertSecondToTime($object->duration, 'all', $conf->global->MAIN_DURATION_OF_WORKDAY).'</td>';
print '</tr>'; print '</tr>';
} }
print "</table>"; print "</table>";
print '</div>'; print '</div>';
print '</div>'; print '</div>';
print '</div>'; print '</div>';
print '<div class="clearboth"></div><br>'; print '<div class="clearboth"></div><br>';
if (!empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) if (!empty($conf->global->MAIN_DISABLE_CONTACTS_TAB))
@ -1464,25 +1464,25 @@ if ($action == 'create')
// Date d'intervention // Date d'intervention
print '<td class="center nowrap">'; print '<td class="center nowrap">';
if (!empty($conf->global->FICHINTER_DATE_WITHOUT_HOUR)) { if (!empty($conf->global->FICHINTER_DATE_WITHOUT_HOUR)) {
print $form->selectDate($db->jdate($objp->date_intervention), 'di', 0, 0, 0, "date_intervention"); print $form->selectDate($db->jdate($objp->date_intervention), 'di', 0, 0, 0, "date_intervention");
} else { } else {
print $form->selectDate($db->jdate($objp->date_intervention), 'di', 1, 1, 0, "date_intervention"); print $form->selectDate($db->jdate($objp->date_intervention), 'di', 1, 1, 0, "date_intervention");
} }
print '</td>'; print '</td>';
// Duration // Duration
print '<td class="right">'; print '<td class="right">';
if (empty($conf->global->FICHINTER_WITHOUT_DURATION)) { if (empty($conf->global->FICHINTER_WITHOUT_DURATION)) {
$selectmode = 'select'; $selectmode = 'select';
if (!empty($conf->global->INTERVENTION_ADDLINE_FREEDUREATION)) if (!empty($conf->global->INTERVENTION_ADDLINE_FREEDUREATION))
$selectmode = 'text'; $selectmode = 'text';
$form->select_duration('duration', $objp->duree, 0, $selectmode); $form->select_duration('duration', $objp->duree, 0, $selectmode);
} }
print '</td>'; print '</td>';
print '<td class="center" colspan="5" valign="center">'; print '<td class="center" colspan="5" valign="center">';
print '<input type="submit" class="button buttongen marginbottomonly" name="save" value="'.$langs->trans("Save").'">'; print '<input type="submit" class="button buttongen marginbottomonly" name="save" value="'.$langs->trans("Save").'">';
print '<input type="submit" class="button buttongen marginbottomonly" name="cancel" value="'.$langs->trans("Cancel").'"></td>'; print '<input type="submit" class="button buttongen marginbottomonly" name="cancel" value="'.$langs->trans("Cancel").'"></td>';
print '</tr>'."\n"; print '</tr>'."\n";
@ -1514,13 +1514,13 @@ if ($action == 'create')
print '<td width="5" class="center linecolnum"></td>'; print '<td width="5" class="center linecolnum"></td>';
} }
print '<td>'; print '<td>';
print '<a name="add"></a>'; // ancre print '<a name="add"></a>'; // ancre
print $langs->trans('Description').'</td>'; print $langs->trans('Description').'</td>';
print '<td class="center">'.$langs->trans('Date').'</td>'; print '<td class="center">'.$langs->trans('Date').'</td>';
print '<td class="right">'.(empty($conf->global->FICHINTER_WITHOUT_DURATION) ? $langs->trans('Duration') : '').'</td>'; print '<td class="right">'.(empty($conf->global->FICHINTER_WITHOUT_DURATION) ? $langs->trans('Duration') : '').'</td>';
print '<td colspan="3">&nbsp;</td>'; print '<td colspan="3">&nbsp;</td>';
print "</tr>\n"; print "</tr>\n";
} }
print '<tr class="oddeven nohover">'."\n"; print '<tr class="oddeven nohover">'."\n";
@ -1530,43 +1530,43 @@ if ($action == 'create')
print '<td class="center linecolnum">'.($i + 1).'</td>'; print '<td class="center linecolnum">'.($i + 1).'</td>';
} }
print '<td>'; print '<td>';
// editeur wysiwyg // editeur wysiwyg
if (empty($conf->global->FICHINTER_EMPTY_LINE_DESC)) { if (empty($conf->global->FICHINTER_EMPTY_LINE_DESC)) {
require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
$doleditor = new DolEditor('np_desc', GETPOST('np_desc', 'restricthtml'), '', 100, 'dolibarr_details', '', false, true, $conf->global->FCKEDITOR_ENABLE_DETAILS, ROWS_2, '90%'); $doleditor = new DolEditor('np_desc', GETPOST('np_desc', 'restricthtml'), '', 100, 'dolibarr_details', '', false, true, $conf->global->FCKEDITOR_ENABLE_DETAILS, ROWS_2, '90%');
$doleditor->Create(); $doleditor->Create();
} }
print '</td>'; print '</td>';
// Date intervention // Date intervention
print '<td class="center nowrap">'; print '<td class="center nowrap">';
$now = dol_now(); $now = dol_now();
$timearray = dol_getdate($now); $timearray = dol_getdate($now);
if (!GETPOST('diday', 'int')) { if (!GETPOST('diday', 'int')) {
$timewithnohour = dol_mktime(0, 0, 0, $timearray['mon'], $timearray['mday'], $timearray['year']); $timewithnohour = dol_mktime(0, 0, 0, $timearray['mon'], $timearray['mday'], $timearray['year']);
} else { } else {
$timewithnohour = dol_mktime(GETPOST('dihour', 'int'), GETPOST('dimin', 'int'), 0, GETPOST('dimonth', 'int'), GETPOST('diday', 'int'), GETPOST('diyear', 'int')); $timewithnohour = dol_mktime(GETPOST('dihour', 'int'), GETPOST('dimin', 'int'), 0, GETPOST('dimonth', 'int'), GETPOST('diday', 'int'), GETPOST('diyear', 'int'));
} }
if (!empty($conf->global->FICHINTER_DATE_WITHOUT_HOUR)) { if (!empty($conf->global->FICHINTER_DATE_WITHOUT_HOUR)) {
print $form->selectDate($timewithnohour, 'di', 0, 0, 0, "addinter"); print $form->selectDate($timewithnohour, 'di', 0, 0, 0, "addinter");
} else { } else {
print $form->selectDate($timewithnohour, 'di', 1, 1, 0, "addinter"); print $form->selectDate($timewithnohour, 'di', 1, 1, 0, "addinter");
} }
print '</td>'; print '</td>';
// Duration // Duration
print '<td class="right">'; print '<td class="right">';
if (empty($conf->global->FICHINTER_WITHOUT_DURATION)) { if (empty($conf->global->FICHINTER_WITHOUT_DURATION)) {
$selectmode = 'select'; $selectmode = 'select';
if (!empty($conf->global->INTERVENTION_ADDLINE_FREEDUREATION)) { if (!empty($conf->global->INTERVENTION_ADDLINE_FREEDUREATION)) {
$selectmode = 'text'; $selectmode = 'text';
} }
$form->select_duration('duration', (!GETPOST('durationhour', 'int') && !GETPOST('durationmin', 'int')) ? 3600 : (60 * 60 * GETPOST('durationhour', 'int') + 60 * GETPOST('durationmin', 'int')), 0, $selectmode); $form->select_duration('duration', (!GETPOST('durationhour', 'int') && !GETPOST('durationmin', 'int')) ? 3600 : (60 * 60 * GETPOST('durationhour', 'int') + 60 * GETPOST('durationmin', 'int')), 0, $selectmode);
} }
print '</td>'; print '</td>';
print '<td class="center" valign="middle" colspan="3"><input type="submit" class="button" value="'.$langs->trans('Add').'" name="addline"></td>'; print '<td class="center" valign="middle" colspan="3"><input type="submit" class="button" value="'.$langs->trans('Add').'" name="addline"></td>';
print '</tr>'; print '</tr>';
//Line extrafield //Line extrafield
@ -1601,22 +1601,22 @@ if ($action == 'create')
$parameters = array(); $parameters = array();
$reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been
// modified by hook // modified by hook
if (empty($reshook)) if (empty($reshook))
{ {
if ($user->socid == 0) if ($user->socid == 0)
{ {
if ($action != 'editdescription' && ($action != 'presend')) { if ($action != 'editdescription' && ($action != 'presend')) {
// Validate // Validate
if ($object->statut == Fichinter::STATUS_DRAFT && (count($object->lines) > 0 || !empty($conf->global->FICHINTER_DISABLE_DETAILS))) { if ($object->statut == Fichinter::STATUS_DRAFT && (count($object->lines) > 0 || !empty($conf->global->FICHINTER_DISABLE_DETAILS))) {
if ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->rights->ficheinter->creer) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->rights->ficheinter->ficheinter_advance->validate)) { if ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->rights->ficheinter->creer) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->rights->ficheinter->ficheinter_advance->validate)) {
print '<div class="inline-block divButAction"><a class="butAction" href="card.php?id='.$object->id.'&action=validate"'; print '<div class="inline-block divButAction"><a class="butAction" href="card.php?id='.$object->id.'&action=validate"';
print '>'.$langs->trans("Validate").'</a></div>'; print '>'.$langs->trans("Validate").'</a></div>';
} }
} }
// Modify // Modify
if ($object->statut == Fichinter::STATUS_VALIDATED && ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->rights->ficheinter->creer) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->rights->ficheinter->ficheinter_advance->unvalidate))) if ($object->statut == Fichinter::STATUS_VALIDATED && ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->rights->ficheinter->creer) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->rights->ficheinter->ficheinter_advance->unvalidate)))
{ {
print '<div class="inline-block divButAction"><a class="butAction" href="card.php?id='.$object->id.'&action=modify">'; print '<div class="inline-block divButAction"><a class="butAction" href="card.php?id='.$object->id.'&action=modify">';
if (empty($conf->global->FICHINTER_DISABLE_DETAILS)) print $langs->trans("Modify"); if (empty($conf->global->FICHINTER_DISABLE_DETAILS)) print $langs->trans("Modify");
@ -1684,7 +1684,7 @@ if ($action == 'create')
} }
// Done // Done
if (empty($conf->global->FICHINTER_CLASSIFY_BILLED) && $object->statut > Fichinter::STATUS_DRAFT && $object->statut < Fichinter::STATUS_CLOSED) if (empty($conf->global->FICHINTER_CLASSIFY_BILLED) && $object->statut > Fichinter::STATUS_DRAFT && $object->statut < Fichinter::STATUS_CLOSED)
{ {
print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=classifydone">'.$langs->trans("InterventionClassifyDone").'</a></div>'; print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=classifydone">'.$langs->trans("InterventionClassifyDone").'</a></div>';
} }

View File

@ -702,7 +702,7 @@ class FactureFournisseur extends CommonInvoice
$this->note_private = $obj->note_private; $this->note_private = $obj->note_private;
$this->note_public = $obj->note_public; $this->note_public = $obj->note_public;
$this->model_pdf = $obj->model_pdf; $this->model_pdf = $obj->model_pdf;
$this->modelpdf = $obj->model_pdf; // deprecated $this->modelpdf = $obj->model_pdf; // deprecated
$this->import_key = $obj->import_key; $this->import_key = $obj->import_key;
//Incoterms //Incoterms
@ -827,7 +827,7 @@ class FactureFournisseur extends CommonInvoice
// Accountancy // Accountancy
$line->code_ventilation = $obj->fk_code_ventilation; $line->code_ventilation = $obj->fk_code_ventilation;
$line->fk_accounting_account = $obj->fk_code_ventilation; $line->fk_accounting_account = $obj->fk_code_ventilation;
// Multicurrency // Multicurrency
$line->fk_multicurrency = $obj->fk_multicurrency; $line->fk_multicurrency = $obj->fk_multicurrency;

View File

@ -364,30 +364,30 @@ if (empty($reshook))
{ {
$fk_parent_line = 0; $fk_parent_line = 0;
} }
$result = $objecttmp->addline( $result = $objecttmp->addline(
$desc, $desc,
$lines[$i]->subprice, $lines[$i]->subprice,
$lines[$i]->tva_tx, $lines[$i]->tva_tx,
$lines[$i]->localtax1_tx, $lines[$i]->localtax1_tx,
$lines[$i]->localtax2_tx, $lines[$i]->localtax2_tx,
$lines[$i]->qty, $lines[$i]->qty,
$lines[$i]->fk_product, $lines[$i]->fk_product,
$lines[$i]->remise_percent, $lines[$i]->remise_percent,
$date_start, $date_start,
$date_end, $date_end,
0, 0,
$lines[$i]->info_bits, $lines[$i]->info_bits,
'HT', 'HT',
$product_type, $product_type,
$lines[$i]->rang, $lines[$i]->rang,
false, false,
$lines[$i]->array_options, $lines[$i]->array_options,
$lines[$i]->fk_unit, $lines[$i]->fk_unit,
$objecttmp->origin_id, $objecttmp->origin_id,
$lines[$i]->pa_ht, $lines[$i]->pa_ht,
$lines[$i]->ref_supplier, $lines[$i]->ref_supplier,
$lines[$i]->special_code, $lines[$i]->special_code,
$fk_parent_line $fk_parent_line
); );
if ($result > 0) if ($result > 0)
{ {
@ -686,7 +686,7 @@ if ($resql)
$arrayofmassactions = array( $arrayofmassactions = array(
'generate_doc'=>$langs->trans("ReGeneratePDF"), 'generate_doc'=>$langs->trans("ReGeneratePDF"),
'builddoc'=>$langs->trans("PDFMerge"), 'builddoc'=>$langs->trans("PDFMerge"),
'presend'=>$langs->trans("SendByMail"), 'presend'=>$langs->trans("SendByMail"),
); );
if ($user->rights->fournisseur->facture->creer) $arrayofmassactions['createbills'] = $langs->trans("CreateInvoiceForThisSupplier"); if ($user->rights->fournisseur->facture->creer) $arrayofmassactions['createbills'] = $langs->trans("CreateInvoiceForThisSupplier");
if ($user->rights->fournisseur->commande->supprimer) $arrayofmassactions['predelete'] = '<span class="fa fa-trash paddingrightonly"></span>'.$langs->trans("Delete"); if ($user->rights->fournisseur->commande->supprimer) $arrayofmassactions['predelete'] = '<span class="fa fa-trash paddingrightonly"></span>'.$langs->trans("Delete");
@ -1293,14 +1293,14 @@ if ($resql)
$db->free($resql); $db->free($resql);
$parameters = array('arrayfields'=>$arrayfields, 'sql'=>$sql); $parameters = array('arrayfields'=>$arrayfields, 'sql'=>$sql);
$reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters); // Note that $action and $object may have been modified by hook $reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters); // Note that $action and $object may have been modified by hook
print $hookmanager->resPrint; print $hookmanager->resPrint;
print '</table>'."\n"; print '</table>'."\n";
print '</div>'; print '</div>';
print '</form>'."\n"; print '</form>'."\n";
$hidegeneratedfilelistifempty = 1; $hidegeneratedfilelistifempty = 1;
if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) $hidegeneratedfilelistifempty = 0; if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) $hidegeneratedfilelistifempty = 0;

View File

@ -153,21 +153,21 @@ if (empty($reshook))
// Action clone object // Action clone object
if ($action == 'confirm_clone' && $confirm == 'yes' && $permissiontoadd) if ($action == 'confirm_clone' && $confirm == 'yes' && $permissiontoadd)
{ {
$objectutil = dol_clone($object, 1); // To avoid to denaturate loaded object when setting some properties for clone. We use native clone to keep this->db valid. $objectutil = dol_clone($object, 1); // To avoid to denaturate loaded object when setting some properties for clone. We use native clone to keep this->db valid.
if (GETPOST('newsupplierref', 'alphanohtml')) $objectutil->ref_supplier = GETPOST('newsupplierref', 'alphanohtml'); if (GETPOST('newsupplierref', 'alphanohtml')) $objectutil->ref_supplier = GETPOST('newsupplierref', 'alphanohtml');
$objectutil->date = dol_mktime(12, 0, 0, GETPOST('newdatemonth', 'int'), GETPOST('newdateday', 'int'), GETPOST('newdateyear', 'int')); $objectutil->date = dol_mktime(12, 0, 0, GETPOST('newdatemonth', 'int'), GETPOST('newdateday', 'int'), GETPOST('newdateyear', 'int'));
$result = $objectutil->createFromClone($user, $id); $result = $objectutil->createFromClone($user, $id);
if ($result > 0) if ($result > 0)
{ {
header("Location: ".$_SERVER['PHP_SELF'].'?id='.$result); header("Location: ".$_SERVER['PHP_SELF'].'?id='.$result);
exit; exit;
} else { } else {
$langs->load("errors"); $langs->load("errors");
setEventMessages($objectutil->error, $objectutil->errors, 'errors'); setEventMessages($objectutil->error, $objectutil->errors, 'errors');
$action = ''; $action = '';
} }
} elseif ($action == 'confirm_valid' && $confirm == 'yes' && $usercanvalidate) { } elseif ($action == 'confirm_valid' && $confirm == 'yes' && $usercanvalidate) {
$idwarehouse = GETPOST('idwarehouse'); $idwarehouse = GETPOST('idwarehouse');
@ -1041,7 +1041,7 @@ if (empty($reshook))
$object->fetch($id); $object->fetch($id);
$object->fetch_thirdparty(); $object->fetch_thirdparty();
$tva_tx = (GETPOST('tva_tx') ? GETPOST('tva_tx') : 0); $tva_tx = (GETPOST('tva_tx') ? GETPOST('tva_tx') : 0);
if (GETPOST('price_ht') != '') if (GETPOST('price_ht') != '')
{ {
@ -1077,17 +1077,17 @@ if (empty($reshook))
$date_start = dol_mktime(GETPOST('date_starthour'), GETPOST('date_startmin'), GETPOST('date_startsec'), GETPOST('date_startmonth'), GETPOST('date_startday'), GETPOST('date_startyear')); $date_start = dol_mktime(GETPOST('date_starthour'), GETPOST('date_startmin'), GETPOST('date_startsec'), GETPOST('date_startmonth'), GETPOST('date_startday'), GETPOST('date_startyear'));
$date_end = dol_mktime(GETPOST('date_endhour'), GETPOST('date_endmin'), GETPOST('date_endsec'), GETPOST('date_endmonth'), GETPOST('date_endday'), GETPOST('date_endyear')); $date_end = dol_mktime(GETPOST('date_endhour'), GETPOST('date_endmin'), GETPOST('date_endsec'), GETPOST('date_endmonth'), GETPOST('date_endday'), GETPOST('date_endyear'));
// Define info_bits // Define info_bits
$info_bits = 0; $info_bits = 0;
if (preg_match('/\*/', $tva_tx)) if (preg_match('/\*/', $tva_tx))
$info_bits |= 0x01; $info_bits |= 0x01;
// Define vat_rate // Define vat_rate
$tva_tx = str_replace('*', '', $tva_tx); $tva_tx = str_replace('*', '', $tva_tx);
$localtax1_tx = get_localtax($tva_tx, 1, $mysoc, $object->thirdparty); $localtax1_tx = get_localtax($tva_tx, 1, $mysoc, $object->thirdparty);
$localtax2_tx = get_localtax($tva_tx, 2, $mysoc, $object->thirdparty); $localtax2_tx = get_localtax($tva_tx, 2, $mysoc, $object->thirdparty);
$remise_percent = GETPOST('remise_percent'); $remise_percent = GETPOST('remise_percent');
$pu_ht_devise = GETPOST('multicurrency_subprice'); $pu_ht_devise = GETPOST('multicurrency_subprice');
// Extrafields Lines // Extrafields Lines
@ -1100,12 +1100,12 @@ if (empty($reshook))
} }
} }
$result = $object->updateline(GETPOST('lineid'), $label, $up, $tva_tx, $localtax1_tx, $localtax2_tx, GETPOST('qty'), GETPOST('productid'), $price_base_type, $info_bits, $type, $remise_percent, 0, $date_start, $date_end, $array_options, $_POST['units'], $pu_ht_devise, GETPOST('fourn_ref', 'alpha')); $result = $object->updateline(GETPOST('lineid'), $label, $up, $tva_tx, $localtax1_tx, $localtax2_tx, GETPOST('qty'), GETPOST('productid'), $price_base_type, $info_bits, $type, $remise_percent, 0, $date_start, $date_end, $array_options, $_POST['units'], $pu_ht_devise, GETPOST('fourn_ref', 'alpha'));
if ($result >= 0) if ($result >= 0)
{ {
unset($_POST['label']); unset($_POST['label']);
unset($_POST['fourn_ref']); unset($_POST['fourn_ref']);
unset($_POST['date_starthour']); unset($_POST['date_starthour']);
unset($_POST['date_startmin']); unset($_POST['date_startmin']);
unset($_POST['date_startsec']); unset($_POST['date_startsec']);
unset($_POST['date_startday']); unset($_POST['date_startday']);
@ -1250,7 +1250,7 @@ if (empty($reshook))
// if we use supplier description of the products // if we use supplier description of the products
if (!empty($productsupplier->desc_supplier) && !empty($conf->global->PRODUIT_FOURN_TEXTS)) { if (!empty($productsupplier->desc_supplier) && !empty($conf->global->PRODUIT_FOURN_TEXTS)) {
$desc = $productsupplier->desc_supplier; $desc = $productsupplier->desc_supplier;
} else $desc = $productsupplier->description; } else $desc = $productsupplier->description;
if (trim($product_desc) != trim($desc)) $desc = dol_concatdesc($desc, $product_desc, '', !empty($conf->global->MAIN_CHANGE_ORDER_CONCAT_DESCRIPTION)); if (trim($product_desc) != trim($desc)) $desc = dol_concatdesc($desc, $product_desc, '', !empty($conf->global->MAIN_CHANGE_ORDER_CONCAT_DESCRIPTION));
@ -1301,8 +1301,8 @@ if (empty($reshook))
$array_options, $array_options,
$productsupplier->fk_unit, $productsupplier->fk_unit,
0, 0,
$pu_ht_devise, $pu_ht_devise,
$ref_supplier, $ref_supplier,
'' ''
); );
} }
@ -1430,34 +1430,34 @@ if (empty($reshook))
if (!$ventilExportCompta) if (!$ventilExportCompta)
{ {
// On verifie si aucun paiement n'a ete effectue // On verifie si aucun paiement n'a ete effectue
if ($resteapayer == price2num($object->total_ttc, 'MT', 1) && $object->statut == FactureFournisseur::STATUS_VALIDATED) if ($resteapayer == price2num($object->total_ttc, 'MT', 1) && $object->statut == FactureFournisseur::STATUS_VALIDATED)
{ {
$idwarehouse = GETPOST('idwarehouse'); $idwarehouse = GETPOST('idwarehouse');
$object->fetch_thirdparty(); $object->fetch_thirdparty();
$qualified_for_stock_change = 0; $qualified_for_stock_change = 0;
if (empty($conf->global->STOCK_SUPPORTS_SERVICES)) if (empty($conf->global->STOCK_SUPPORTS_SERVICES))
{ {
$qualified_for_stock_change = $object->hasProductsOrServices(2); $qualified_for_stock_change = $object->hasProductsOrServices(2);
} else { } else {
$qualified_for_stock_change = $object->hasProductsOrServices(1); $qualified_for_stock_change = $object->hasProductsOrServices(1);
} }
// Check parameters // Check parameters
if (!empty($conf->stock->enabled) && !empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_BILL) && $qualified_for_stock_change) if (!empty($conf->stock->enabled) && !empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_BILL) && $qualified_for_stock_change)
{ {
$langs->load("stocks"); $langs->load("stocks");
if (!$idwarehouse || $idwarehouse == -1) if (!$idwarehouse || $idwarehouse == -1)
{ {
$error++; $error++;
setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv("Warehouse")), null, 'errors'); setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv("Warehouse")), null, 'errors');
$action = ''; $action = '';
} }
} }
$object->setDraft($user, $idwarehouse); $object->setDraft($user, $idwarehouse);
// Define output language // Define output language
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE))
@ -1771,9 +1771,9 @@ if ($action == 'create')
print '</td></tr>'; print '</td></tr>';
// Ref supplier // Ref supplier
print '<tr><td class="fieldrequired">'.$langs->trans('RefSupplier').'</td><td><input name="ref_supplier" value="'.(isset($_POST['ref_supplier']) ? $_POST['ref_supplier'] : $objectsrc->ref_supplier).'" type="text"'; print '<tr><td class="fieldrequired">'.$langs->trans('RefSupplier').'</td><td><input name="ref_supplier" value="'.(isset($_POST['ref_supplier']) ? $_POST['ref_supplier'] : $objectsrc->ref_supplier).'" type="text"';
if ($societe->id > 0) print ' autofocus'; if ($societe->id > 0) print ' autofocus';
print '></td>'; print '></td>';
print '</tr>'; print '</tr>';
print '<tr><td class="tdtop fieldrequired">'.$langs->trans('Type').'</td><td>'; print '<tr><td class="tdtop fieldrequired">'.$langs->trans('Type').'</td><td>';
@ -2059,7 +2059,7 @@ if ($action == 'create')
$doleditor = new DolEditor('note_public', (GETPOSTISSET('note_public') ?GETPOST('note_public', 'restricthtml') : $note_public), '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, '90%'); $doleditor = new DolEditor('note_public', (GETPOSTISSET('note_public') ?GETPOST('note_public', 'restricthtml') : $note_public), '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, '90%');
print $doleditor->Create(1); print $doleditor->Create(1);
print '</td>'; print '</td>';
// print '<td><textarea name="note" wrap="soft" cols="60" rows="'.ROWS_5.'"></textarea></td>'; // print '<td><textarea name="note" wrap="soft" cols="60" rows="'.ROWS_5.'"></textarea></td>';
print '</tr>'; print '</tr>';
// Private note // Private note
@ -2241,8 +2241,8 @@ if ($action == 'create')
{ {
// Create an array for form // Create an array for form
$formquestion = array( $formquestion = array(
array('type' => 'text', 'name' => 'newsupplierref', 'label' => $langs->trans("RefSupplier"), 'value' => $langs->trans("CopyOf").' '.$object->ref_supplier), array('type' => 'text', 'name' => 'newsupplierref', 'label' => $langs->trans("RefSupplier"), 'value' => $langs->trans("CopyOf").' '.$object->ref_supplier),
array('type' => 'date', 'name' => 'newdate', 'label' => $langs->trans("Date"), 'value' => dol_now()) array('type' => 'date', 'name' => 'newdate', 'label' => $langs->trans("Date"), 'value' => dol_now())
); );
// Ask confirmation to clone // Ask confirmation to clone
$formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ToClone'), $langs->trans('ConfirmCloneInvoice', $object->ref), 'confirm_clone', $formquestion, 'yes', 1, 250); $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ToClone'), $langs->trans('ConfirmCloneInvoice', $object->ref), 'confirm_clone', $formquestion, 'yes', 1, 250);
@ -2279,59 +2279,59 @@ if ($action == 'create')
$qualified_for_stock_change = $object->hasProductsOrServices(1); $qualified_for_stock_change = $object->hasProductsOrServices(1);
} }
if (!empty($conf->stock->enabled) && !empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_BILL) && $qualified_for_stock_change) if (!empty($conf->stock->enabled) && !empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_BILL) && $qualified_for_stock_change)
{ {
$langs->load("stocks"); $langs->load("stocks");
require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php'; require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php';
$formproduct = new FormProduct($db); $formproduct = new FormProduct($db);
$warehouse = new Entrepot($db); $warehouse = new Entrepot($db);
$warehouse_array = $warehouse->list_array(); $warehouse_array = $warehouse->list_array();
if (count($warehouse_array) == 1) { if (count($warehouse_array) == 1) {
$label = $object->type == FactureFournisseur::TYPE_CREDIT_NOTE ? $langs->trans("WarehouseForStockDecrease", current($warehouse_array)) : $langs->trans("WarehouseForStockIncrease", current($warehouse_array)); $label = $object->type == FactureFournisseur::TYPE_CREDIT_NOTE ? $langs->trans("WarehouseForStockDecrease", current($warehouse_array)) : $langs->trans("WarehouseForStockIncrease", current($warehouse_array));
$value = '<input type="hidden" id="idwarehouse" name="idwarehouse" value="'.key($warehouse_array).'">'; $value = '<input type="hidden" id="idwarehouse" name="idwarehouse" value="'.key($warehouse_array).'">';
} else { } else {
$label = $object->type == FactureFournisseur::TYPE_CREDIT_NOTE ? $langs->trans("SelectWarehouseForStockDecrease") : $langs->trans("SelectWarehouseForStockIncrease"); $label = $object->type == FactureFournisseur::TYPE_CREDIT_NOTE ? $langs->trans("SelectWarehouseForStockDecrease") : $langs->trans("SelectWarehouseForStockIncrease");
$value = $formproduct->selectWarehouses(GETPOST('idwarehouse') ?GETPOST('idwarehouse') : 'ifone', 'idwarehouse', '', 1); $value = $formproduct->selectWarehouses(GETPOST('idwarehouse') ?GETPOST('idwarehouse') : 'ifone', 'idwarehouse', '', 1);
} }
$formquestion = array( $formquestion = array(
array('type' => 'other', 'name' => 'idwarehouse', 'label' => $label, 'value' => $value) array('type' => 'other', 'name' => 'idwarehouse', 'label' => $label, 'value' => $value)
); );
} }
$formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ValidateBill'), $text, 'confirm_valid', $formquestion, 1, 1); $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ValidateBill'), $text, 'confirm_valid', $formquestion, 1, 1);
} }
// Confirmation edit (back to draft) // Confirmation edit (back to draft)
if ($action == 'edit') if ($action == 'edit')
{ {
$formquestion = array(); $formquestion = array();
$qualified_for_stock_change = 0; $qualified_for_stock_change = 0;
if (empty($conf->global->STOCK_SUPPORTS_SERVICES)) if (empty($conf->global->STOCK_SUPPORTS_SERVICES))
{ {
$qualified_for_stock_change = $object->hasProductsOrServices(2); $qualified_for_stock_change = $object->hasProductsOrServices(2);
} else { } else {
$qualified_for_stock_change = $object->hasProductsOrServices(1); $qualified_for_stock_change = $object->hasProductsOrServices(1);
} }
if (!empty($conf->stock->enabled) && !empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_BILL) && $qualified_for_stock_change) if (!empty($conf->stock->enabled) && !empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_BILL) && $qualified_for_stock_change)
{ {
$langs->load("stocks"); $langs->load("stocks");
require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php'; require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php';
$formproduct = new FormProduct($db); $formproduct = new FormProduct($db);
$warehouse = new Entrepot($db); $warehouse = new Entrepot($db);
$warehouse_array = $warehouse->list_array(); $warehouse_array = $warehouse->list_array();
if (count($warehouse_array) == 1) { if (count($warehouse_array) == 1) {
$label = $object->type == FactureFournisseur::TYPE_CREDIT_NOTE ? $langs->trans("WarehouseForStockIncrease", current($warehouse_array)) : $langs->trans("WarehouseForStockDecrease", current($warehouse_array)); $label = $object->type == FactureFournisseur::TYPE_CREDIT_NOTE ? $langs->trans("WarehouseForStockIncrease", current($warehouse_array)) : $langs->trans("WarehouseForStockDecrease", current($warehouse_array));
$value = '<input type="hidden" id="idwarehouse" name="idwarehouse" value="'.key($warehouse_array).'">'; $value = '<input type="hidden" id="idwarehouse" name="idwarehouse" value="'.key($warehouse_array).'">';
} else { } else {
$label = $object->type == FactureFournisseur::TYPE_CREDIT_NOTE ? $langs->trans("SelectWarehouseForStockIncrease") : $langs->trans("SelectWarehouseForStockDecrease"); $label = $object->type == FactureFournisseur::TYPE_CREDIT_NOTE ? $langs->trans("SelectWarehouseForStockIncrease") : $langs->trans("SelectWarehouseForStockDecrease");
$value = $formproduct->selectWarehouses(GETPOST('idwarehouse') ?GETPOST('idwarehouse') : 'ifone', 'idwarehouse', '', 1); $value = $formproduct->selectWarehouses(GETPOST('idwarehouse') ?GETPOST('idwarehouse') : 'ifone', 'idwarehouse', '', 1);
} }
$formquestion = array( $formquestion = array(
array('type' => 'other', 'name' => 'idwarehouse', 'label' => $label, 'value' => $value) array('type' => 'other', 'name' => 'idwarehouse', 'label' => $label, 'value' => $value)
); );
} }
$formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('UnvalidateBill'), $langs->trans('ConfirmUnvalidateBill', $object->ref), 'confirm_edit', $formquestion, 1, 1); $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('UnvalidateBill'), $langs->trans('ConfirmUnvalidateBill', $object->ref), 'confirm_edit', $formquestion, 1, 1);
} }
// Confirmation set paid // Confirmation set paid
@ -2369,109 +2369,109 @@ if ($action == 'create')
print $formconfirm; print $formconfirm;
// Supplier invoice card // Supplier invoice card
$linkback = '<a href="'.DOL_URL_ROOT.'/fourn/facture/list.php?restore_lastsearch_values=1'.(!empty($socid) ? '&socid='.$socid : '').'">'.$langs->trans("BackToList").'</a>'; $linkback = '<a href="'.DOL_URL_ROOT.'/fourn/facture/list.php?restore_lastsearch_values=1'.(!empty($socid) ? '&socid='.$socid : '').'">'.$langs->trans("BackToList").'</a>';
$morehtmlref = '<div class="refidno">'; $morehtmlref = '<div class="refidno">';
// Ref supplier // Ref supplier
$morehtmlref .= $form->editfieldkey("RefSupplier", 'ref_supplier', $object->ref_supplier, $object, $usercancreate, 'string', '', 0, 1); $morehtmlref .= $form->editfieldkey("RefSupplier", 'ref_supplier', $object->ref_supplier, $object, $usercancreate, 'string', '', 0, 1);
$morehtmlref .= $form->editfieldval("RefSupplier", 'ref_supplier', $object->ref_supplier, $object, $usercancreate, 'string', '', null, null, '', 1); $morehtmlref .= $form->editfieldval("RefSupplier", 'ref_supplier', $object->ref_supplier, $object, $usercancreate, 'string', '', null, null, '', 1);
// Thirdparty // Thirdparty
$morehtmlref .= '<br>'.$langs->trans('ThirdParty').' : '.$object->thirdparty->getNomUrl(1); $morehtmlref .= '<br>'.$langs->trans('ThirdParty').' : '.$object->thirdparty->getNomUrl(1);
if (empty($conf->global->MAIN_DISABLE_OTHER_LINK) && $object->thirdparty->id > 0) $morehtmlref .= ' (<a href="'.DOL_URL_ROOT.'/fourn/facture/list.php?socid='.$object->thirdparty->id.'&search_company='.urlencode($object->thirdparty->name).'">'.$langs->trans("OtherBills").'</a>)'; if (empty($conf->global->MAIN_DISABLE_OTHER_LINK) && $object->thirdparty->id > 0) $morehtmlref .= ' (<a href="'.DOL_URL_ROOT.'/fourn/facture/list.php?socid='.$object->thirdparty->id.'&search_company='.urlencode($object->thirdparty->name).'">'.$langs->trans("OtherBills").'</a>)';
// Project // Project
if (!empty($conf->projet->enabled)) if (!empty($conf->projet->enabled))
{ {
$langs->load("projects"); $langs->load("projects");
$morehtmlref .= '<br>'.$langs->trans('Project').' '; $morehtmlref .= '<br>'.$langs->trans('Project').' ';
if ($usercancreate) if ($usercancreate)
{ {
if ($action != 'classify') { if ($action != 'classify') {
$morehtmlref .= '<a class="editfielda" href="'.$_SERVER['PHP_SELF'].'?action=classify&amp;id='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('SetProject')).'</a> : '; $morehtmlref .= '<a class="editfielda" href="'.$_SERVER['PHP_SELF'].'?action=classify&amp;id='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('SetProject')).'</a> : ';
} }
if ($action == 'classify') { if ($action == 'classify') {
//$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1);
$morehtmlref .= '<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">'; $morehtmlref .= '<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">';
$morehtmlref .= '<input type="hidden" name="action" value="classin">'; $morehtmlref .= '<input type="hidden" name="action" value="classin">';
$morehtmlref .= '<input type="hidden" name="token" value="'.newToken().'">'; $morehtmlref .= '<input type="hidden" name="token" value="'.newToken().'">';
$morehtmlref .= $formproject->select_projects((empty($conf->global->PROJECT_CAN_ALWAYS_LINK_TO_ALL_SUPPLIERS) ? $object->socid : -1), $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); $morehtmlref .= $formproject->select_projects((empty($conf->global->PROJECT_CAN_ALWAYS_LINK_TO_ALL_SUPPLIERS) ? $object->socid : -1), $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1);
$morehtmlref .= '<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">'; $morehtmlref .= '<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">';
$morehtmlref .= '</form>'; $morehtmlref .= '</form>';
} else { } else {
$morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1);
} }
} else { } else {
if (!empty($object->fk_project)) { if (!empty($object->fk_project)) {
$proj = new Project($db); $proj = new Project($db);
$proj->fetch($object->fk_project); $proj->fetch($object->fk_project);
$morehtmlref .= '<a href="'.DOL_URL_ROOT.'/projet/card.php?id='.$object->fk_project.'" title="'.$langs->trans('ShowProject').'">'; $morehtmlref .= '<a href="'.DOL_URL_ROOT.'/projet/card.php?id='.$object->fk_project.'" title="'.$langs->trans('ShowProject').'">';
$morehtmlref .= $proj->ref; $morehtmlref .= $proj->ref;
$morehtmlref .= '</a>'; $morehtmlref .= '</a>';
} else { } else {
$morehtmlref .= ''; $morehtmlref .= '';
} }
} }
} }
$morehtmlref .= '</div>'; $morehtmlref .= '</div>';
$object->totalpaye = $totalpaye; // To give a chance to dol_banner_tab to use already paid amount to show correct status $object->totalpaye = $totalpaye; // To give a chance to dol_banner_tab to use already paid amount to show correct status
dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
print '<div class="fichecenter">'; print '<div class="fichecenter">';
print '<div class="fichehalfleft">'; print '<div class="fichehalfleft">';
print '<div class="underbanner clearboth"></div>'; print '<div class="underbanner clearboth"></div>';
print '<table class="border tableforfield" width="100%">'; print '<table class="border tableforfield" width="100%">';
// Type // Type
print '<tr><td class="titlefield">'.$langs->trans('Type').'</td><td>'; print '<tr><td class="titlefield">'.$langs->trans('Type').'</td><td>';
print $object->getLibType(); print $object->getLibType();
if ($object->type == FactureFournisseur::TYPE_REPLACEMENT) if ($object->type == FactureFournisseur::TYPE_REPLACEMENT)
{ {
$facreplaced = new FactureFournisseur($db); $facreplaced = new FactureFournisseur($db);
$facreplaced->fetch($object->fk_facture_source); $facreplaced->fetch($object->fk_facture_source);
print ' ('.$langs->transnoentities("ReplaceInvoice", $facreplaced->getNomUrl(1)).')'; print ' ('.$langs->transnoentities("ReplaceInvoice", $facreplaced->getNomUrl(1)).')';
} }
if ($object->type == FactureFournisseur::TYPE_CREDIT_NOTE) if ($object->type == FactureFournisseur::TYPE_CREDIT_NOTE)
{ {
$facusing = new FactureFournisseur($db); $facusing = new FactureFournisseur($db);
$facusing->fetch($object->fk_facture_source); $facusing->fetch($object->fk_facture_source);
print ' ('.$langs->transnoentities("CorrectInvoice", $facusing->getNomUrl(1)).')'; print ' ('.$langs->transnoentities("CorrectInvoice", $facusing->getNomUrl(1)).')';
} }
$facidavoir = $object->getListIdAvoirFromInvoice(); $facidavoir = $object->getListIdAvoirFromInvoice();
if (count($facidavoir) > 0) if (count($facidavoir) > 0)
{ {
print ' ('.$langs->transnoentities("InvoiceHasAvoir"); print ' ('.$langs->transnoentities("InvoiceHasAvoir");
$i = 0; $i = 0;
foreach ($facidavoir as $id) foreach ($facidavoir as $id)
{ {
if ($i == 0) print ' '; if ($i == 0) print ' ';
else print ','; else print ',';
$facavoir = new FactureFournisseur($db); $facavoir = new FactureFournisseur($db);
$facavoir->fetch($id); $facavoir->fetch($id);
print $facavoir->getNomUrl(1); print $facavoir->getNomUrl(1);
} }
print ')'; print ')';
} }
if (isset($facidnext) && $facidnext > 0) if (isset($facidnext) && $facidnext > 0)
{ {
$facthatreplace = new FactureFournisseur($db); $facthatreplace = new FactureFournisseur($db);
$facthatreplace->fetch($facidnext); $facthatreplace->fetch($facidnext);
print ' ('.$langs->transnoentities("ReplacedByInvoice", $facthatreplace->getNomUrl(1)).')'; print ' ('.$langs->transnoentities("ReplacedByInvoice", $facthatreplace->getNomUrl(1)).')';
} }
if ($object->type == FactureFournisseur::TYPE_CREDIT_NOTE || $object->type == FactureFournisseur::TYPE_DEPOSIT) { if ($object->type == FactureFournisseur::TYPE_CREDIT_NOTE || $object->type == FactureFournisseur::TYPE_DEPOSIT) {
$discount = new DiscountAbsolute($db); $discount = new DiscountAbsolute($db);
$result = $discount->fetch(0, 0, $object->id); $result = $discount->fetch(0, 0, $object->id);
if ($result > 0) { if ($result > 0) {
print '. '.$langs->trans("CreditNoteConvertedIntoDiscount", $object->getLibType(1), $discount->getNomUrl(1, 'discount')).'<br>'; print '. '.$langs->trans("CreditNoteConvertedIntoDiscount", $object->getLibType(1), $discount->getNomUrl(1, 'discount')).'<br>';
} }
} }
print '</td></tr>'; print '</td></tr>';
// Relative and absolute discounts // Relative and absolute discounts
print '<!-- Discounts --><tr><td>'.$langs->trans('Discounts'); print '<!-- Discounts --><tr><td>'.$langs->trans('Discounts');
print '</td><td>'; print '</td><td>';
@ -2482,18 +2482,18 @@ if ($action == 'create')
print '</td></tr>'; print '</td></tr>';
// Label // Label
print '<tr>'; print '<tr>';
print '<td>'.$form->editfieldkey("Label", 'label', $object->label, $object, ($usercancreate)).'</td>'; print '<td>'.$form->editfieldkey("Label", 'label', $object->label, $object, ($usercancreate)).'</td>';
print '<td>'.$form->editfieldval("Label", 'label', $object->label, $object, ($usercancreate)).'</td>'; print '<td>'.$form->editfieldval("Label", 'label', $object->label, $object, ($usercancreate)).'</td>';
print '</tr>'; print '</tr>';
$form_permission = ($object->statut < FactureFournisseur::STATUS_CLOSED) && $usercancreate && ($object->getSommePaiement() <= 0); $form_permission = ($object->statut < FactureFournisseur::STATUS_CLOSED) && $usercancreate && ($object->getSommePaiement() <= 0);
// Date // Date
print '<tr><td>'.$form->editfieldkey("DateInvoice", 'datef', $object->datep, $object, $form_permission, 'datepicker').'</td><td colspan="3">'; print '<tr><td>'.$form->editfieldkey("DateInvoice", 'datef', $object->datep, $object, $form_permission, 'datepicker').'</td><td colspan="3">';
print $form->editfieldval("Date", 'datef', $object->datep, $object, $form_permission, 'datepicker'); print $form->editfieldval("Date", 'datef', $object->datep, $object, $form_permission, 'datepicker');
print '</td>'; print '</td>';
// Default terms of the settlement // Default terms of the settlement
$langs->load('bills'); $langs->load('bills');
@ -3033,7 +3033,7 @@ if ($action == 'create')
// modified by hook // modified by hook
if (empty($reshook)) if (empty($reshook))
{ {
// Modify a validated invoice with no payments // Modify a validated invoice with no payments
if ($object->statut == FactureFournisseur::STATUS_VALIDATED && $action != 'confirm_edit' && $object->getSommePaiement() == 0 && $usercancreate) if ($object->statut == FactureFournisseur::STATUS_VALIDATED && $action != 'confirm_edit' && $object->getSommePaiement() == 0 && $usercancreate)
{ {
// We check if lines of invoice are not already transfered into accountancy // We check if lines of invoice are not already transfered into accountancy
@ -3078,17 +3078,17 @@ if ($action == 'create')
} }
} }
// Make payments // Make payments
if ($object->type != FactureFournisseur::TYPE_CREDIT_NOTE && $action != 'confirm_edit' && $object->statut == FactureFournisseur::STATUS_VALIDATED && $object->paye == 0 && $user->socid == 0) if ($object->type != FactureFournisseur::TYPE_CREDIT_NOTE && $action != 'confirm_edit' && $object->statut == FactureFournisseur::STATUS_VALIDATED && $object->paye == 0 && $user->socid == 0)
{ {
print '<div class="inline-block divButAction"><a class="butAction" href="paiement.php?facid='.$object->id.'&amp;action=create'.($object->fk_account > 0 ? '&amp;accountid='.$object->fk_account : '').'">'.$langs->trans('DoPayment').'</a></div>'; // must use facid because id is for payment id not invoice print '<div class="inline-block divButAction"><a class="butAction" href="paiement.php?facid='.$object->id.'&amp;action=create'.($object->fk_account > 0 ? '&amp;accountid='.$object->fk_account : '').'">'.$langs->trans('DoPayment').'</a></div>'; // must use facid because id is for payment id not invoice
} }
// Classify paid // Classify paid
if ($action != 'confirm_edit' && $object->statut == FactureFournisseur::STATUS_VALIDATED && $object->paye == 0 && $user->socid == 0) if ($action != 'confirm_edit' && $object->statut == FactureFournisseur::STATUS_VALIDATED && $object->paye == 0 && $user->socid == 0)
{ {
print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=paid"'; print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=paid"';
print '>'.$langs->trans('ClassifyPaid').'</a></div>'; print '>'.$langs->trans('ClassifyPaid').'</a></div>';
//print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=paid">'.$langs->trans('ClassifyPaid').'</a>'; //print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=paid">'.$langs->trans('ClassifyPaid').'</a>';
} }
@ -3124,21 +3124,21 @@ if ($action == 'create')
} }
} }
// Validate // Validate
if ($action != 'confirm_edit' && $object->statut == FactureFournisseur::STATUS_DRAFT) if ($action != 'confirm_edit' && $object->statut == FactureFournisseur::STATUS_DRAFT)
{ {
if (count($object->lines)) if (count($object->lines))
{ {
if ($usercanvalidate) if ($usercanvalidate)
{ {
print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=valid"'; print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=valid"';
print '>'.$langs->trans('Validate').'</a></div>'; print '>'.$langs->trans('Validate').'</a></div>';
} else { } else {
print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans("NotAllowed")).'"'; print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans("NotAllowed")).'"';
print '>'.$langs->trans('Validate').'</a></div>'; print '>'.$langs->trans('Validate').'</a></div>';
} }
} }
} }
// Create event // Create event
/*if ($conf->agenda->enabled && ! empty($conf->global->MAIN_ADD_EVENT_ON_ELEMENT_CARD)) // Add hidden condition because this is not a "workflow" action so should appears somewhere else on page. /*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.
@ -3161,30 +3161,30 @@ if ($action == 'create')
} }
} }
// Delete // Delete
$isErasable = $object->is_erasable(); $isErasable = $object->is_erasable();
if ($action != 'confirm_edit' && ($user->rights->fournisseur->facture->supprimer || ($usercancreate && $isErasable == 1))) // isErasable = 1 means draft with temporary ref (draft can always be deleted with no need of permissions) if ($action != 'confirm_edit' && ($user->rights->fournisseur->facture->supprimer || ($usercancreate && $isErasable == 1))) // isErasable = 1 means draft with temporary ref (draft can always be deleted with no need of permissions)
{ {
//var_dump($isErasable); //var_dump($isErasable);
if ($isErasable == -4) { if ($isErasable == -4) {
print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans("DisabledBecausePayments").'">'.$langs->trans('Delete').'</a></div>'; print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans("DisabledBecausePayments").'">'.$langs->trans('Delete').'</a></div>';
} elseif ($isErasable == -3) { // Should never happen with supplier invoice } elseif ($isErasable == -3) { // Should never happen with supplier invoice
print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans("DisabledBecauseNotLastSituationInvoice").'">'.$langs->trans('Delete').'</a></div>'; print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans("DisabledBecauseNotLastSituationInvoice").'">'.$langs->trans('Delete').'</a></div>';
} elseif ($isErasable == -2) { // Should never happen with supplier invoice } elseif ($isErasable == -2) { // Should never happen with supplier invoice
print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans("DisabledBecauseNotLastInvoice").'">'.$langs->trans('Delete').'</a></div>'; print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans("DisabledBecauseNotLastInvoice").'">'.$langs->trans('Delete').'</a></div>';
} elseif ($isErasable == -1) { } elseif ($isErasable == -1) {
print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans("DisabledBecauseDispatchedInBookkeeping").'">'.$langs->trans('Delete').'</a></div>'; print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans("DisabledBecauseDispatchedInBookkeeping").'">'.$langs->trans('Delete').'</a></div>';
} elseif ($isErasable <= 0) // Any other cases } elseif ($isErasable <= 0) // Any other cases
{ {
print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans("DisabledBecauseNotErasable").'">'.$langs->trans('Delete').'</a></div>'; print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans("DisabledBecauseNotErasable").'">'.$langs->trans('Delete').'</a></div>';
} else { } else {
print '<div class="inline-block divButAction"><a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=delete&amp;token='.newToken().'">'.$langs->trans('Delete').'</a></div>'; print '<div class="inline-block divButAction"><a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=delete&amp;token='.newToken().'">'.$langs->trans('Delete').'</a></div>';
} }
} }
print '</div>'; print '</div>';
if ($action != 'confirm_edit') if ($action != 'confirm_edit')
{ {
print '<div class="fichecenter"><div class="fichehalfleft">'; print '<div class="fichecenter"><div class="fichehalfleft">';
/* /*

View File

@ -94,56 +94,56 @@ if ($object->id > 0)
$totalpaye = $object->getSommePaiement(); $totalpaye = $object->getSommePaiement();
$linkback = '<a href="'.DOL_URL_ROOT.'/fourn/facture/list.php?restore_lastsearch_values=1'.(!empty($socid) ? '&socid='.$socid : '').'">'.$langs->trans("BackToList").'</a>'; $linkback = '<a href="'.DOL_URL_ROOT.'/fourn/facture/list.php?restore_lastsearch_values=1'.(!empty($socid) ? '&socid='.$socid : '').'">'.$langs->trans("BackToList").'</a>';
$morehtmlref = '<div class="refidno">'; $morehtmlref = '<div class="refidno">';
// Ref supplier // Ref supplier
$morehtmlref .= $form->editfieldkey("RefSupplier", 'ref_supplier', $object->ref_supplier, $object, 0, 'string', '', 0, 1); $morehtmlref .= $form->editfieldkey("RefSupplier", 'ref_supplier', $object->ref_supplier, $object, 0, 'string', '', 0, 1);
$morehtmlref .= $form->editfieldval("RefSupplier", 'ref_supplier', $object->ref_supplier, $object, 0, 'string', '', null, null, '', 1); $morehtmlref .= $form->editfieldval("RefSupplier", 'ref_supplier', $object->ref_supplier, $object, 0, 'string', '', null, null, '', 1);
// Thirdparty // Thirdparty
$morehtmlref .= '<br>'.$langs->trans('ThirdParty').' : '.$object->thirdparty->getNomUrl(1); $morehtmlref .= '<br>'.$langs->trans('ThirdParty').' : '.$object->thirdparty->getNomUrl(1);
if (empty($conf->global->MAIN_DISABLE_OTHER_LINK) && $object->thirdparty->id > 0) $morehtmlref .= ' (<a href="'.DOL_URL_ROOT.'/fourn/facture/list.php?socid='.$object->thirdparty->id.'&search_company='.urlencode($object->thirdparty->name).'">'.$langs->trans("OtherBills").'</a>)'; if (empty($conf->global->MAIN_DISABLE_OTHER_LINK) && $object->thirdparty->id > 0) $morehtmlref .= ' (<a href="'.DOL_URL_ROOT.'/fourn/facture/list.php?socid='.$object->thirdparty->id.'&search_company='.urlencode($object->thirdparty->name).'">'.$langs->trans("OtherBills").'</a>)';
// Project // Project
if (!empty($conf->projet->enabled)) if (!empty($conf->projet->enabled))
{ {
$langs->load("projects"); $langs->load("projects");
$morehtmlref .= '<br>'.$langs->trans('Project').' '; $morehtmlref .= '<br>'.$langs->trans('Project').' ';
if ($user->rights->facture->creer) if ($user->rights->facture->creer)
{ {
if ($action != 'classify') if ($action != 'classify')
//$morehtmlref.='<a class="editfielda" href="' . $_SERVER['PHP_SELF'] . '?action=classify&amp;id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : '; //$morehtmlref.='<a class="editfielda" href="' . $_SERVER['PHP_SELF'] . '?action=classify&amp;id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : ';
$morehtmlref .= ' : '; $morehtmlref .= ' : ';
if ($action == 'classify') { if ($action == 'classify') {
//$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1);
$morehtmlref .= '<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">'; $morehtmlref .= '<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">';
$morehtmlref .= '<input type="hidden" name="action" value="classin">'; $morehtmlref .= '<input type="hidden" name="action" value="classin">';
$morehtmlref .= '<input type="hidden" name="token" value="'.newToken().'">'; $morehtmlref .= '<input type="hidden" name="token" value="'.newToken().'">';
$morehtmlref .= $formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); $morehtmlref .= $formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1);
$morehtmlref .= '<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">'; $morehtmlref .= '<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">';
$morehtmlref .= '</form>'; $morehtmlref .= '</form>';
} else { } else {
$morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1);
} }
} else { } else {
if (!empty($object->fk_project)) { if (!empty($object->fk_project)) {
$proj = new Project($db); $proj = new Project($db);
$proj->fetch($object->fk_project); $proj->fetch($object->fk_project);
$morehtmlref .= '<a href="'.DOL_URL_ROOT.'/projet/card.php?id='.$object->fk_project.'" title="'.$langs->trans('ShowProject').'">'; $morehtmlref .= '<a href="'.DOL_URL_ROOT.'/projet/card.php?id='.$object->fk_project.'" title="'.$langs->trans('ShowProject').'">';
$morehtmlref .= $proj->ref; $morehtmlref .= $proj->ref;
$morehtmlref .= '</a>'; $morehtmlref .= '</a>';
} else { } else {
$morehtmlref .= ''; $morehtmlref .= '';
} }
} }
} }
$morehtmlref .= '</div>'; $morehtmlref .= '</div>';
$object->totalpaye = $totalpaye; // To give a chance to dol_banner_tab to use already paid amount to show correct status $object->totalpaye = $totalpaye; // To give a chance to dol_banner_tab to use already paid amount to show correct status
dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref, '', 0); dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref, '', 0);
print '<div class="fichecenter">'; print '<div class="fichecenter">';
print '<div class="underbanner clearboth"></div>'; print '<div class="underbanner clearboth"></div>';
// Build file list // Build file list
$filearray = dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', $sortfield, (strtolower($sortorder) == 'desc' ?SORT_DESC:SORT_ASC), 1); $filearray = dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', $sortfield, (strtolower($sortorder) == 'desc' ?SORT_DESC:SORT_ASC), 1);
@ -271,7 +271,7 @@ if ($object->id > 0)
if ($res) break; if ($res) break;
} }
} else { } else {
print $langs->trans('ErrorUnknown'); print $langs->trans('ErrorUnknown');
} }
// End of page // End of page

View File

@ -96,42 +96,42 @@ print '<div class="fichecenter"><div class="fichethirdleft">';
if (!empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) // This is useless due to the global search combo if (!empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) // This is useless due to the global search combo
{ {
if (!empty($conf->holiday->enabled) && $user->rights->holiday->read) if (!empty($conf->holiday->enabled) && $user->rights->holiday->read)
{ {
$langs->load("holiday"); $langs->load("holiday");
$listofsearchfields['search_holiday'] = array('text'=>'TitreRequestCP'); $listofsearchfields['search_holiday'] = array('text'=>'TitreRequestCP');
} }
if (!empty($conf->deplacement->enabled) && $user->rights->deplacement->lire) if (!empty($conf->deplacement->enabled) && $user->rights->deplacement->lire)
{ {
$langs->load("trips"); $langs->load("trips");
$listofsearchfields['search_deplacement'] = array('text'=>'ExpenseReport'); $listofsearchfields['search_deplacement'] = array('text'=>'ExpenseReport');
} }
if (!empty($conf->expensereport->enabled) && $user->rights->expensereport->lire) if (!empty($conf->expensereport->enabled) && $user->rights->expensereport->lire)
{ {
$langs->load("trips"); $langs->load("trips");
$listofsearchfields['search_expensereport'] = array('text'=>'ExpenseReport'); $listofsearchfields['search_expensereport'] = array('text'=>'ExpenseReport');
} }
if (count($listofsearchfields)) if (count($listofsearchfields))
{ {
print '<form method="post" action="'.DOL_URL_ROOT.'/core/search.php">'; print '<form method="post" action="'.DOL_URL_ROOT.'/core/search.php">';
print '<input type="hidden" name="token" value="'.newToken().'">'; print '<input type="hidden" name="token" value="'.newToken().'">';
print '<div class="div-table-responsive-no-min">'; print '<div class="div-table-responsive-no-min">';
print '<table class="noborder nohover centpercent">'; print '<table class="noborder nohover centpercent">';
$i = 0; $i = 0;
foreach ($listofsearchfields as $key => $value) foreach ($listofsearchfields as $key => $value)
{ {
if ($i == 0) print '<tr class="liste_titre"><td colspan="3">'.$langs->trans("Search").'</td></tr>'; if ($i == 0) print '<tr class="liste_titre"><td colspan="3">'.$langs->trans("Search").'</td></tr>';
print '<tr '.$bc[false].'>'; print '<tr '.$bc[false].'>';
print '<td class="nowrap"><label for="'.$key.'">'.$langs->trans($value["text"]).'</label></td><td><input type="text" class="flat inputsearch" name="'.$key.'" id="'.$key.'" size="18"></td>'; print '<td class="nowrap"><label for="'.$key.'">'.$langs->trans($value["text"]).'</label></td><td><input type="text" class="flat inputsearch" name="'.$key.'" id="'.$key.'" size="18"></td>';
if ($i == 0) print '<td rowspan="'.count($listofsearchfields).'"><input type="submit" value="'.$langs->trans("Search").'" class="button"></td>'; if ($i == 0) print '<td rowspan="'.count($listofsearchfields).'"><input type="submit" value="'.$langs->trans("Search").'" class="button"></td>';
print '</tr>'; print '</tr>';
$i++; $i++;
} }
print '</table>'; print '</table>';
print '</div>'; print '</div>';
print '</form>'; print '</form>';
print '<br>'; print '<br>';
} }
} }
@ -141,26 +141,26 @@ if (!empty($conf->holiday->enabled))
{ {
$user_id = $user->id; $user_id = $user->id;
print '<div class="div-table-responsive-no-min">'; print '<div class="div-table-responsive-no-min">';
print '<table class="noborder nohover centpercent">'; print '<table class="noborder nohover centpercent">';
print '<tr class="liste_titre"><th colspan="3">'.$langs->trans("Holidays").'</th></tr>'; print '<tr class="liste_titre"><th colspan="3">'.$langs->trans("Holidays").'</th></tr>';
print '<tr class="oddeven">'; print '<tr class="oddeven">';
print '<td colspan="3">'; print '<td colspan="3">';
$out = ''; $out = '';
$typeleaves = $holiday->getTypes(1, 1); $typeleaves = $holiday->getTypes(1, 1);
foreach ($typeleaves as $key => $val) foreach ($typeleaves as $key => $val)
{ {
$nb_type = $holiday->getCPforUser($user->id, $val['rowid']); $nb_type = $holiday->getCPforUser($user->id, $val['rowid']);
$nb_holiday += $nb_type; $nb_holiday += $nb_type;
$out .= ' - '.$val['label'].': <strong>'.($nb_type ?price2num($nb_type) : 0).'</strong><br>'; $out .= ' - '.$val['label'].': <strong>'.($nb_type ?price2num($nb_type) : 0).'</strong><br>';
} }
print $langs->trans('SoldeCPUser', round($nb_holiday, 5)).'<br>'; print $langs->trans('SoldeCPUser', round($nb_holiday, 5)).'<br>';
print $out; print $out;
print '</td>'; print '</td>';
print '</tr>'; print '</tr>';
print '</table></div><br>'; print '</table></div><br>';
} elseif (!is_numeric($conf->global->HOLIDAY_HIDE_BALANCE)) } elseif (!is_numeric($conf->global->HOLIDAY_HIDE_BALANCE))
{ {
print $langs->trans($conf->global->HOLIDAY_HIDE_BALANCE).'<br>'; print $langs->trans($conf->global->HOLIDAY_HIDE_BALANCE).'<br>';
@ -175,80 +175,80 @@ print '</div><div class="fichetwothirdright"><div class="ficheaddleft">';
// Latest leave requests // Latest leave requests
if (!empty($conf->holiday->enabled) && $user->rights->holiday->read) if (!empty($conf->holiday->enabled) && $user->rights->holiday->read)
{ {
$sql = "SELECT u.rowid as uid, u.lastname, u.firstname, u.login, u.email, u.photo, u.statut as user_status,"; $sql = "SELECT u.rowid as uid, u.lastname, u.firstname, u.login, u.email, u.photo, u.statut as user_status,";
$sql .= " x.rowid, x.rowid as ref, x.fk_type, x.date_debut as date_start, x.date_fin as date_end, x.halfday, x.tms as dm, x.statut as status"; $sql .= " x.rowid, x.rowid as ref, x.fk_type, x.date_debut as date_start, x.date_fin as date_end, x.halfday, x.tms as dm, x.statut as status";
$sql .= " FROM ".MAIN_DB_PREFIX."holiday as x, ".MAIN_DB_PREFIX."user as u"; $sql .= " FROM ".MAIN_DB_PREFIX."holiday as x, ".MAIN_DB_PREFIX."user as u";
$sql .= " WHERE u.rowid = x.fk_user"; $sql .= " WHERE u.rowid = x.fk_user";
$sql .= " AND x.entity = ".$conf->entity; $sql .= " AND x.entity = ".$conf->entity;
if (empty($user->rights->holiday->read_all)) $sql .= ' AND x.fk_user IN ('.join(',', $childids).')'; if (empty($user->rights->holiday->read_all)) $sql .= ' AND x.fk_user IN ('.join(',', $childids).')';
//if (!$user->rights->societe->client->voir && !$user->socid) $sql.= " AND x.fk_soc = s. rowid AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; //if (!$user->rights->societe->client->voir && !$user->socid) $sql.= " AND x.fk_soc = s. rowid AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
//if (!empty($socid)) $sql.= " AND x.fk_soc = ".$socid; //if (!empty($socid)) $sql.= " AND x.fk_soc = ".$socid;
$sql .= $db->order("x.tms", "DESC"); $sql .= $db->order("x.tms", "DESC");
$sql .= $db->plimit($max, 0); $sql .= $db->plimit($max, 0);
$result = $db->query($sql); $result = $db->query($sql);
if ($result) if ($result)
{ {
$var = false; $var = false;
$num = $db->num_rows($result); $num = $db->num_rows($result);
$holidaystatic = new Holiday($db); $holidaystatic = new Holiday($db);
$userstatic = new User($db); $userstatic = new User($db);
$listhalfday = array('morning'=>$langs->trans("Morning"), "afternoon"=>$langs->trans("Afternoon")); $listhalfday = array('morning'=>$langs->trans("Morning"), "afternoon"=>$langs->trans("Afternoon"));
$typeleaves = $holidaystatic->getTypes(1, -1); $typeleaves = $holidaystatic->getTypes(1, -1);
$i = 0; $i = 0;
print '<div class="div-table-responsive-no-min">'; print '<div class="div-table-responsive-no-min">';
print '<table class="noborder centpercent">'; print '<table class="noborder centpercent">';
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print '<th colspan="3">'.$langs->trans("BoxTitleLastLeaveRequests", min($max, $num)).'</th>'; print '<th colspan="3">'.$langs->trans("BoxTitleLastLeaveRequests", min($max, $num)).'</th>';
print '<th>'.$langs->trans("from").'</th>'; print '<th>'.$langs->trans("from").'</th>';
print '<th>'.$langs->trans("to").'</th>'; print '<th>'.$langs->trans("to").'</th>';
print '<th class="right" colspan="2"><a href="'.DOL_URL_ROOT.'/holiday/list.php?sortfield=cp.tms&sortorder=DESC">'.$langs->trans("FullList").'</th>'; print '<th class="right" colspan="2"><a href="'.DOL_URL_ROOT.'/holiday/list.php?sortfield=cp.tms&sortorder=DESC">'.$langs->trans("FullList").'</th>';
print '</tr>'; print '</tr>';
if ($num) if ($num)
{ {
while ($i < $num && $i < $max) while ($i < $num && $i < $max)
{ {
$obj = $db->fetch_object($result); $obj = $db->fetch_object($result);
$holidaystatic->id = $obj->rowid; $holidaystatic->id = $obj->rowid;
$holidaystatic->ref = $obj->ref; $holidaystatic->ref = $obj->ref;
$holidaystatic->statut = $obj->status; $holidaystatic->statut = $obj->status;
$userstatic->id = $obj->uid; $userstatic->id = $obj->uid;
$userstatic->lastname = $obj->lastname; $userstatic->lastname = $obj->lastname;
$userstatic->firstname = $obj->firstname; $userstatic->firstname = $obj->firstname;
$userstatic->login = $obj->login; $userstatic->login = $obj->login;
$userstatic->photo = $obj->photo; $userstatic->photo = $obj->photo;
$userstatic->email = $obj->email; $userstatic->email = $obj->email;
$userstatic->statut = $obj->user_status; $userstatic->statut = $obj->user_status;
print '<tr class="oddeven">'; print '<tr class="oddeven">';
print '<td class="nowraponall">'.$holidaystatic->getNomUrl(1).'</td>'; print '<td class="nowraponall">'.$holidaystatic->getNomUrl(1).'</td>';
print '<td class="tdoverflowmax150">'.$userstatic->getNomUrl(-1, 'leave').'</td>'; print '<td class="tdoverflowmax150">'.$userstatic->getNomUrl(-1, 'leave').'</td>';
print '<td>'.$typeleaves[$obj->fk_type]['label'].'</td>'; print '<td>'.$typeleaves[$obj->fk_type]['label'].'</td>';
$starthalfday = ($obj->halfday == -1 || $obj->halfday == 2) ? 'afternoon' : 'morning'; $starthalfday = ($obj->halfday == -1 || $obj->halfday == 2) ? 'afternoon' : 'morning';
$endhalfday = ($obj->halfday == 1 || $obj->halfday == 2) ? 'morning' : 'afternoon'; $endhalfday = ($obj->halfday == 1 || $obj->halfday == 2) ? 'morning' : 'afternoon';
print '<td>'.dol_print_date($db->jdate($obj->date_start), 'day').' <span class="opacitymedium">'.$langs->trans($listhalfday[$starthalfday]).'</span>'; print '<td>'.dol_print_date($db->jdate($obj->date_start), 'day').' <span class="opacitymedium">'.$langs->trans($listhalfday[$starthalfday]).'</span>';
print '<td>'.dol_print_date($db->jdate($obj->date_end), 'day').' <span class="opacitymedium">'.$langs->trans($listhalfday[$endhalfday]).'</span>'; print '<td>'.dol_print_date($db->jdate($obj->date_end), 'day').' <span class="opacitymedium">'.$langs->trans($listhalfday[$endhalfday]).'</span>';
print '<td class="right">'.dol_print_date($db->jdate($obj->dm), 'day').'</td>'; print '<td class="right">'.dol_print_date($db->jdate($obj->dm), 'day').'</td>';
print '<td class="right nowrap" width="16">'.$holidaystatic->LibStatut($obj->status, 3).'</td>'; print '<td class="right nowrap" width="16">'.$holidaystatic->LibStatut($obj->status, 3).'</td>';
print '</tr>'; print '</tr>';
$i++; $i++;
} }
} else { } else {
print '<tr class="oddeven"><td colspan="7" class="opacitymedium">'.$langs->trans("None").'</td></tr>'; print '<tr class="oddeven"><td colspan="7" class="opacitymedium">'.$langs->trans("None").'</td></tr>';
} }
print '</table>'; print '</table>';
print '</div>'; print '</div>';
print '<br>'; print '<br>';
} else dol_print_error($db); } else dol_print_error($db);
} }
@ -298,7 +298,7 @@ if (!empty($conf->expensereport->enabled) && $user->rights->expensereport->lire)
$userstatic->id = $obj->uid; $userstatic->id = $obj->uid;
$userstatic->lastname = $obj->lastname; $userstatic->lastname = $obj->lastname;
$userstatic->firstname = $obj->firstname; $userstatic->firstname = $obj->firstname;
$userstatic->email = $obj->email; $userstatic->email = $obj->email;
$userstatic->login = $obj->login; $userstatic->login = $obj->login;
$userstatic->statut = $obj->user_status; $userstatic->statut = $obj->user_status;
$userstatic->photo = $obj->photo; $userstatic->photo = $obj->photo;

View File

@ -107,75 +107,75 @@ if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'e
if (empty($reshook)) if (empty($reshook))
{ {
$error = 0; $error = 0;
$backurlforlist = dol_buildpath('/mrp/mo_list.php', 1); $backurlforlist = dol_buildpath('/mrp/mo_list.php', 1);
if (empty($backtopage) || ($cancel && empty($id))) { if (empty($backtopage) || ($cancel && empty($id))) {
if (empty($backtopage) || ($cancel && strpos($backtopage, '__ID__'))) { if (empty($backtopage) || ($cancel && strpos($backtopage, '__ID__'))) {
if (empty($id) && (($action != 'add' && $action != 'create') || $cancel)) $backtopage = $backurlforlist; if (empty($id) && (($action != 'add' && $action != 'create') || $cancel)) $backtopage = $backurlforlist;
else $backtopage = DOL_URL_ROOT.'/mrp/mo_card.php?id='.($id > 0 ? $id : '__ID__'); else $backtopage = DOL_URL_ROOT.'/mrp/mo_card.php?id='.($id > 0 ? $id : '__ID__');
} }
} }
if ($cancel && !empty($backtopageforcancel)) { if ($cancel && !empty($backtopageforcancel)) {
$backtopage = $backtopageforcancel; $backtopage = $backtopageforcancel;
} }
$triggermodname = 'MRP_MO_MODIFY'; // Name of trigger action code to execute when we modify record $triggermodname = 'MRP_MO_MODIFY'; // Name of trigger action code to execute when we modify record
// Actions cancel, add, update, update_extras, confirm_validate, confirm_delete, confirm_deleteline, confirm_clone, confirm_close, confirm_setdraft, confirm_reopen // Actions cancel, add, update, update_extras, confirm_validate, confirm_delete, confirm_deleteline, confirm_clone, confirm_close, confirm_setdraft, confirm_reopen
include DOL_DOCUMENT_ROOT.'/core/actions_addupdatedelete.inc.php'; include DOL_DOCUMENT_ROOT.'/core/actions_addupdatedelete.inc.php';
// Actions when linking object each other // Actions when linking object each other
include DOL_DOCUMENT_ROOT.'/core/actions_dellink.inc.php'; include DOL_DOCUMENT_ROOT.'/core/actions_dellink.inc.php';
// Actions when printing a doc from card // Actions when printing a doc from card
include DOL_DOCUMENT_ROOT.'/core/actions_printing.inc.php'; include DOL_DOCUMENT_ROOT.'/core/actions_printing.inc.php';
// Actions to send emails // Actions to send emails
$triggersendname = 'MO_SENTBYMAIL'; $triggersendname = 'MO_SENTBYMAIL';
$autocopy = 'MAIN_MAIL_AUTOCOPY_MO_TO'; $autocopy = 'MAIN_MAIL_AUTOCOPY_MO_TO';
$trackid = 'mo'.$object->id; $trackid = 'mo'.$object->id;
include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php'; include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php';
// Action to move up and down lines of object // Action to move up and down lines of object
//include DOL_DOCUMENT_ROOT.'/core/actions_lineupdown.inc.php'; // Must be include, not include_once //include DOL_DOCUMENT_ROOT.'/core/actions_lineupdown.inc.php'; // Must be include, not include_once
if ($action == 'set_thirdparty' && $permissiontoadd) if ($action == 'set_thirdparty' && $permissiontoadd)
{ {
$object->setValueFrom('fk_soc', GETPOST('fk_soc', 'int'), '', '', 'date', '', $user, 'MO_MODIFY'); $object->setValueFrom('fk_soc', GETPOST('fk_soc', 'int'), '', '', 'date', '', $user, 'MO_MODIFY');
} }
if ($action == 'classin' && $permissiontoadd) if ($action == 'classin' && $permissiontoadd)
{ {
$object->setProject(GETPOST('projectid', 'int')); $object->setProject(GETPOST('projectid', 'int'));
} }
// Action close produced // Action close produced
if ($action == 'confirm_produced' && $confirm == 'yes' && $permissiontoadd) if ($action == 'confirm_produced' && $confirm == 'yes' && $permissiontoadd)
{ {
$result = $object->setStatut($object::STATUS_PRODUCED, 0, '', 'MRP_MO_PRODUCED'); $result = $object->setStatut($object::STATUS_PRODUCED, 0, '', 'MRP_MO_PRODUCED');
if ($result >= 0) if ($result >= 0)
{ {
// Define output language // Define output language
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE))
{ {
$outputlangs = $langs; $outputlangs = $langs;
$newlang = ''; $newlang = '';
if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09'); if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09');
if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang; if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang;
if (!empty($newlang)) { if (!empty($newlang)) {
$outputlangs = new Translate("", $conf); $outputlangs = new Translate("", $conf);
$outputlangs->setDefaultLang($newlang); $outputlangs->setDefaultLang($newlang);
} }
$model = $object->model_pdf; $model = $object->model_pdf;
$ret = $object->fetch($id); // Reload to get new records $ret = $object->fetch($id); // Reload to get new records
$object->generateDocument($model, $outputlangs, 0, 0, 0); $object->generateDocument($model, $outputlangs, 0, 0, 0);
} }
} else { } else {
setEventMessages($object->error, $object->errors, 'errors'); setEventMessages($object->error, $object->errors, 'errors');
} }
} }
} }
@ -317,7 +317,7 @@ if (($id || $ref) && $action == 'edit')
print load_fiche_titre($langs->trans("MO"), '', 'mrp'); print load_fiche_titre($langs->trans("MO"), '', 'mrp');
print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">'; print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
print '<input type="hidden" name="token" value="'.newToken().'">'; print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="action" value="update">'; print '<input type="hidden" name="action" value="update">';
print '<input type="hidden" name="id" value="'.$object->id.'">'; print '<input type="hidden" name="id" value="'.$object->id.'">';
if ($backtopage) print '<input type="hidden" name="backtopage" value="'.$backtopage.'">'; if ($backtopage) print '<input type="hidden" name="backtopage" value="'.$backtopage.'">';
@ -360,7 +360,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
// Confirmation to delete // Confirmation to delete
if ($action == 'delete') if ($action == 'delete')
{ {
$formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('DeleteMo'), $langs->trans('ConfirmDeleteMo'), 'confirm_delete', '', 0, 1); $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('DeleteMo'), $langs->trans('ConfirmDeleteMo'), 'confirm_delete', '', 0, 1);
} }
// Confirmation to delete line // Confirmation to delete line
if ($action == 'deleteline') if ($action == 'deleteline')
@ -439,32 +439,32 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
// Project // Project
if (!empty($conf->projet->enabled)) if (!empty($conf->projet->enabled))
{ {
$langs->load("projects"); $langs->load("projects");
$morehtmlref .= '<br>'.$langs->trans('Project').' '; $morehtmlref .= '<br>'.$langs->trans('Project').' ';
if ($permissiontoadd) if ($permissiontoadd)
{ {
if ($action != 'classify') if ($action != 'classify')
$morehtmlref .= '<a class="editfielda" href="'.$_SERVER['PHP_SELF'].'?action=classify&amp;id='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('SetProject')).'</a> : '; $morehtmlref .= '<a class="editfielda" href="'.$_SERVER['PHP_SELF'].'?action=classify&amp;id='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('SetProject')).'</a> : ';
if ($action == 'classify') { if ($action == 'classify') {
//$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->fk_soc, $object->fk_project, 'projectid', 0, 0, 1, 1); //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->fk_soc, $object->fk_project, 'projectid', 0, 0, 1, 1);
$morehtmlref .= '<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">'; $morehtmlref .= '<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">';
$morehtmlref .= '<input type="hidden" name="action" value="classin">'; $morehtmlref .= '<input type="hidden" name="action" value="classin">';
$morehtmlref .= '<input type="hidden" name="token" value="'.newToken().'">'; $morehtmlref .= '<input type="hidden" name="token" value="'.newToken().'">';
$morehtmlref .= $formproject->select_projects($object->fk_soc, $object->fk_project, 'projectid', 0, 0, 1, 0, 1, 0, 0, '', 1); $morehtmlref .= $formproject->select_projects($object->fk_soc, $object->fk_project, 'projectid', 0, 0, 1, 0, 1, 0, 0, '', 1);
$morehtmlref .= '<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">'; $morehtmlref .= '<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">';
$morehtmlref .= '</form>'; $morehtmlref .= '</form>';
} else { } else {
$morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->fk_soc, $object->fk_project, 'none', 0, 0, 0, 1); $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->fk_soc, $object->fk_project, 'none', 0, 0, 0, 1);
} }
} else { } else {
if (!empty($object->fk_project)) { if (!empty($object->fk_project)) {
$proj = new Project($db); $proj = new Project($db);
$proj->fetch($object->fk_project); $proj->fetch($object->fk_project);
$morehtmlref .= ' : '.$proj->getNomUrl(); $morehtmlref .= ' : '.$proj->getNomUrl();
} else { } else {
$morehtmlref .= ''; $morehtmlref .= '';
} }
} }
} }
$morehtmlref .= '</div>'; $morehtmlref .= '</div>';
@ -501,167 +501,167 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
if (!empty($object->table_element_line)) if (!empty($object->table_element_line))
{ {
// Show object lines // Show object lines
//$result = $object->getLinesArray(); //$result = $object->getLinesArray();
$object->fetchLines(); $object->fetchLines();
print ' <form name="addproduct" id="addproduct" action="'.$_SERVER["PHP_SELF"].'?id='.$object->id.(($action != 'editline') ? '#addline' : '#line_'.GETPOST('lineid', 'int')).'" method="POST"> print ' <form name="addproduct" id="addproduct" action="'.$_SERVER["PHP_SELF"].'?id='.$object->id.(($action != 'editline') ? '#addline' : '#line_'.GETPOST('lineid', 'int')).'" method="POST">
<input type="hidden" name="token" value="' . newToken().'"> <input type="hidden" name="token" value="' . newToken().'">
<input type="hidden" name="action" value="' . (($action != 'editline') ? 'addline' : 'updateline').'"> <input type="hidden" name="action" value="' . (($action != 'editline') ? 'addline' : 'updateline').'">
<input type="hidden" name="mode" value=""> <input type="hidden" name="mode" value="">
<input type="hidden" name="id" value="' . $object->id.'"> <input type="hidden" name="id" value="' . $object->id.'">
'; ';
/*if (!empty($conf->use_javascript_ajax) && $object->status == 0) { /*if (!empty($conf->use_javascript_ajax) && $object->status == 0) {
include DOL_DOCUMENT_ROOT.'/core/tpl/ajaxrow.tpl.php'; include DOL_DOCUMENT_ROOT.'/core/tpl/ajaxrow.tpl.php';
}*/ }*/
if (!empty($object->lines)) if (!empty($object->lines))
{ {
print '<div class="div-table-responsive-no-min">'; print '<div class="div-table-responsive-no-min">';
print '<table id="tablelines" class="noborder noshadow" width="100%">'; print '<table id="tablelines" class="noborder noshadow" width="100%">';
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print '<td class="liste_titre">'.$langs->trans("Summary").'</td>'; print '<td class="liste_titre">'.$langs->trans("Summary").'</td>';
print '<td></td>'; print '<td></td>';
print '</tr>'; print '</tr>';
print '<tr class="oddeven">'; print '<tr class="oddeven">';
print '<td>'.$langs->trans("ProductsToConsume").'</td>'; print '<td>'.$langs->trans("ProductsToConsume").'</td>';
print '<td>'; print '<td>';
if (!empty($object->lines)) if (!empty($object->lines))
{ {
$i = 0; $i = 0;
foreach ($object->lines as $line) { foreach ($object->lines as $line) {
if ($line->role == 'toconsume') { if ($line->role == 'toconsume') {
if ($i) print ', '; if ($i) print ', ';
$tmpproduct = new Product($db); $tmpproduct = new Product($db);
$tmpproduct->fetch($line->fk_product); $tmpproduct->fetch($line->fk_product);
print $tmpproduct->getNomUrl(1); print $tmpproduct->getNomUrl(1);
$i++; $i++;
} }
} }
} }
print '</td>'; print '</td>';
print '</tr>'; print '</tr>';
print '<tr class="oddeven">'; print '<tr class="oddeven">';
print '<td>'.$langs->trans("ProductsToProduce").'</td>'; print '<td>'.$langs->trans("ProductsToProduce").'</td>';
print '<td>'; print '<td>';
if (!empty($object->lines)) if (!empty($object->lines))
{ {
$i = 0; $i = 0;
foreach ($object->lines as $line) { foreach ($object->lines as $line) {
if ($line->role == 'toproduce') { if ($line->role == 'toproduce') {
if ($i) print ', '; if ($i) print ', ';
$tmpproduct = new Product($db); $tmpproduct = new Product($db);
$tmpproduct->fetch($line->fk_product); $tmpproduct->fetch($line->fk_product);
print $tmpproduct->getNomUrl(1); print $tmpproduct->getNomUrl(1);
$i++; $i++;
} }
} }
} }
print '</td>'; print '</td>';
print '</tr>'; print '</tr>';
print '</table>'; print '</table>';
print '</div>'; print '</div>';
} }
print "</form>\n"; print "</form>\n";
} }
// Buttons for actions // Buttons for actions
if ($action != 'presend' && $action != 'editline') { if ($action != 'presend' && $action != 'editline') {
print '<div class="tabsAction">'."\n"; print '<div class="tabsAction">'."\n";
$parameters = array(); $parameters = array();
$reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
if (empty($reshook)) if (empty($reshook))
{ {
// Send // Send
//if (empty($user->socid)) { //if (empty($user->socid)) {
// print '<a class="butAction" href="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '&action=presend&mode=init#formmailbeforetitle">' . $langs->trans('SendMail') . '</a>'."\n"; // print '<a class="butAction" href="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '&action=presend&mode=init#formmailbeforetitle">' . $langs->trans('SendMail') . '</a>'."\n";
//} //}
// Back to draft // Back to draft
if ($object->status == $object::STATUS_VALIDATED) if ($object->status == $object::STATUS_VALIDATED)
{ {
if ($permissiontoadd) if ($permissiontoadd)
{ {
// TODO Add test that production has not started // TODO Add test that production has not started
print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&action=confirm_setdraft&confirm=yes">'.$langs->trans("SetToDraft").'</a>'; print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&action=confirm_setdraft&confirm=yes">'.$langs->trans("SetToDraft").'</a>';
} }
} }
// Modify // Modify
if ($object->status == $object::STATUS_DRAFT) { if ($object->status == $object::STATUS_DRAFT) {
if ($permissiontoadd) if ($permissiontoadd)
{ {
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=edit">'.$langs->trans("Modify").'</a>'."\n"; print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=edit">'.$langs->trans("Modify").'</a>'."\n";
} else { } else {
print '<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans("NotEnoughPermissions")).'">'.$langs->trans('Modify').'</a>'."\n"; print '<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans("NotEnoughPermissions")).'">'.$langs->trans('Modify').'</a>'."\n";
} }
} }
// Validate // Validate
if ($object->status == $object::STATUS_DRAFT) if ($object->status == $object::STATUS_DRAFT)
{ {
if ($permissiontoadd) if ($permissiontoadd)
{ {
if (empty($object->table_element_line) || (is_array($object->lines) && count($object->lines) > 0)) if (empty($object->table_element_line) || (is_array($object->lines) && count($object->lines) > 0))
{ {
print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&action=validate">'.$langs->trans("Validate").'</a>'; print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&action=validate">'.$langs->trans("Validate").'</a>';
} else { } else {
$langs->load("errors"); $langs->load("errors");
print '<a class="butActionRefused" href="" title="'.$langs->trans("ErrorAddAtLeastOneLineFirst").'">'.$langs->trans("Validate").'</a>'; print '<a class="butActionRefused" href="" title="'.$langs->trans("ErrorAddAtLeastOneLineFirst").'">'.$langs->trans("Validate").'</a>';
} }
} }
} }
// Clone // Clone
if ($permissiontoadd) if ($permissiontoadd)
{ {
print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&socid='.$object->fk_soc.'&action=clone&object=mo">'.$langs->trans("ToClone").'</a>'; print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&socid='.$object->fk_soc.'&action=clone&object=mo">'.$langs->trans("ToClone").'</a>';
} }
// Cancel - Reopen // Cancel - Reopen
if ($permissiontoadd) if ($permissiontoadd)
{ {
if ($object->status == $object::STATUS_VALIDATED || $object->status == $object::STATUS_INPROGRESS) if ($object->status == $object::STATUS_VALIDATED || $object->status == $object::STATUS_INPROGRESS)
{ {
$arrayproduced = $object->fetchLinesLinked('produced', 0); $arrayproduced = $object->fetchLinesLinked('produced', 0);
$nbProduced = 0; $nbProduced = 0;
foreach ($arrayproduced as $lineproduced) { foreach ($arrayproduced as $lineproduced) {
$nbProduced += $lineproduced['qty']; $nbProduced += $lineproduced['qty'];
} }
if ($nbProduced > 0) { // If production has started, we can close it if ($nbProduced > 0) { // If production has started, we can close it
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=confirm_produced&confirm=yes">'.$langs->trans("Close").'</a>'."\n"; print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=confirm_produced&confirm=yes">'.$langs->trans("Close").'</a>'."\n";
} else { } else {
print '<a class="butActionRefused" href="#" title="'.$langs->trans("GoOnTabProductionToProduceFirst", $langs->transnoentitiesnoconv("Production")).'">'.$langs->trans("Close").'</a>'."\n"; print '<a class="butActionRefused" href="#" title="'.$langs->trans("GoOnTabProductionToProduceFirst", $langs->transnoentitiesnoconv("Production")).'">'.$langs->trans("Close").'</a>'."\n";
} }
print '<a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=confirm_close&confirm=yes">'.$langs->trans("Cancel").'</a>'."\n"; print '<a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=confirm_close&confirm=yes">'.$langs->trans("Cancel").'</a>'."\n";
} }
if ($object->status == $object::STATUS_PRODUCED || $object->status == $object::STATUS_CANCELED) if ($object->status == $object::STATUS_PRODUCED || $object->status == $object::STATUS_CANCELED)
{ {
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=confirm_reopen&confirm=yes">'.$langs->trans("ReOpen").'</a>'."\n"; print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=confirm_reopen&confirm=yes">'.$langs->trans("ReOpen").'</a>'."\n";
} }
} }
// Delete (need delete permission, or if draft, just need create/modify permission) // Delete (need delete permission, or if draft, just need create/modify permission)
if ($permissiontodelete || ($object->status == $object::STATUS_DRAFT && $permissiontoadd)) if ($permissiontodelete || ($object->status == $object::STATUS_DRAFT && $permissiontoadd))
{ {
print '<a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=delete&token='.newToken().'">'.$langs->trans('Delete').'</a>'."\n"; print '<a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=delete&token='.newToken().'">'.$langs->trans('Delete').'</a>'."\n";
} else { } else {
print '<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans("NotEnoughPermissions")).'">'.$langs->trans('Delete').'</a>'."\n"; print '<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans("NotEnoughPermissions")).'">'.$langs->trans('Delete').'</a>'."\n";
} }
} }
print '</div>'."\n"; print '</div>'."\n";
} }
@ -672,37 +672,37 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
if ($action != 'presend') if ($action != 'presend')
{ {
print '<div class="fichecenter"><div class="fichehalfleft">'; print '<div class="fichecenter"><div class="fichehalfleft">';
print '<a name="builddoc"></a>'; // ancre print '<a name="builddoc"></a>'; // ancre
// Documents // Documents
$objref = dol_sanitizeFileName($object->ref); $objref = dol_sanitizeFileName($object->ref);
$relativepath = $objref.'/'.$objref.'.pdf'; $relativepath = $objref.'/'.$objref.'.pdf';
$filedir = $conf->mrp->dir_output.'/'.$objref; $filedir = $conf->mrp->dir_output.'/'.$objref;
$urlsource = $_SERVER["PHP_SELF"]."?id=".$object->id; $urlsource = $_SERVER["PHP_SELF"]."?id=".$object->id;
$genallowed = $user->rights->mrp->read; // If you can read, you can build the PDF to read content $genallowed = $user->rights->mrp->read; // If you can read, you can build the PDF to read content
$delallowed = $user->rights->mrp->create; // If you can create/edit, you can remove a file on card $delallowed = $user->rights->mrp->create; // If you can create/edit, you can remove a file on card
print $formfile->showdocuments('mrp:mo', $objref, $filedir, $urlsource, $genallowed, $delallowed, $object->model_pdf, 1, 0, 0, 28, 0, '', '', '', $mysoc->default_lang); print $formfile->showdocuments('mrp:mo', $objref, $filedir, $urlsource, $genallowed, $delallowed, $object->model_pdf, 1, 0, 0, 28, 0, '', '', '', $mysoc->default_lang);
// Show links to link elements // Show links to link elements
$linktoelem = $form->showLinkToObjectBlock($object, null, array('mo')); $linktoelem = $form->showLinkToObjectBlock($object, null, array('mo'));
$somethingshown = $form->showLinkedObjectBlock($object, $linktoelem); $somethingshown = $form->showLinkedObjectBlock($object, $linktoelem);
print '</div><div class="fichehalfright"><div class="ficheaddleft">'; print '</div><div class="fichehalfright"><div class="ficheaddleft">';
$MAXEVENT = 10; $MAXEVENT = 10;
$morehtmlright = '<a href="'.dol_buildpath('/mrp/mo_agenda.php', 1).'?id='.$object->id.'">'; $morehtmlright = '<a href="'.dol_buildpath('/mrp/mo_agenda.php', 1).'?id='.$object->id.'">';
$morehtmlright .= $langs->trans("SeeAll"); $morehtmlright .= $langs->trans("SeeAll");
$morehtmlright .= '</a>'; $morehtmlright .= '</a>';
// List of actions on element // List of actions on element
include_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php'; include_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php';
$formactions = new FormActions($db); $formactions = new FormActions($db);
$somethingshown = $formactions->showactions($object, 'mo', $socid, 1, '', $MAXEVENT, '', $morehtmlright); $somethingshown = $formactions->showactions($object, 'mo', $socid, 1, '', $MAXEVENT, '', $morehtmlright);
print '</div></div></div>'; print '</div></div></div>';
} }
//Select mail models is same action as presend //Select mail models is same action as presend

View File

@ -42,17 +42,17 @@ if (!$user->admin) accessforbidden();
//Objects //Objects
$price_globals = new PriceGlobalVariable($db); $price_globals = new PriceGlobalVariable($db);
if ($action == 'edit_variable') { if ($action == 'edit_variable') {
$res = $price_globals->fetch($selection); $res = $price_globals->fetch($selection);
if ($res < 1) { if ($res < 1) {
setEventMessages($price_globals->error, $price_globals->errors, 'errors'); setEventMessages($price_globals->error, $price_globals->errors, 'errors');
} }
} }
$price_updaters = new PriceGlobalVariableUpdater($db); $price_updaters = new PriceGlobalVariableUpdater($db);
if ($action == 'edit_updater') { if ($action == 'edit_updater') {
$res = $price_updaters->fetch($selection); $res = $price_updaters->fetch($selection);
if ($res < 1) { if ($res < 1) {
setEventMessages($price_updaters->error, $price_updaters->errors, 'errors'); setEventMessages($price_updaters->error, $price_updaters->errors, 'errors');
} }
} }
@ -61,84 +61,84 @@ if ($action == 'edit_updater') {
*/ */
if (!empty($action) && empty($cancel)) { if (!empty($action) && empty($cancel)) {
//Global variable actions //Global variable actions
if ($action == 'create_variable' || $action == 'edit_variable') { if ($action == 'create_variable' || $action == 'edit_variable') {
$price_globals->code = GETPOSTISSET('code') ?GETPOST('code', 'alpha') : $price_globals->code; $price_globals->code = GETPOSTISSET('code') ?GETPOST('code', 'alpha') : $price_globals->code;
$price_globals->description = GETPOSTISSET('description') ?GETPOST('description', 'restricthtml') : $price_globals->description; $price_globals->description = GETPOSTISSET('description') ?GETPOST('description', 'restricthtml') : $price_globals->description;
$price_globals->value = GETPOSTISSET('value') ?GETPOST('value', 'int') : $price_globals->value; $price_globals->value = GETPOSTISSET('value') ?GETPOST('value', 'int') : $price_globals->value;
//Check if record already exists only when saving //Check if record already exists only when saving
if (!empty($save)) { if (!empty($save)) {
foreach ($price_globals->listGlobalVariables() as $entry) { foreach ($price_globals->listGlobalVariables() as $entry) {
if ($price_globals->id != $entry->id && dol_strtolower($price_globals->code) == dol_strtolower($entry->code)) { if ($price_globals->id != $entry->id && dol_strtolower($price_globals->code) == dol_strtolower($entry->code)) {
setEventMessages($langs->trans("ErrorRecordAlreadyExists"), null, 'errors'); setEventMessages($langs->trans("ErrorRecordAlreadyExists"), null, 'errors');
$save = null; $save = null;
} }
} }
} }
} }
if ($action == 'create_variable' && !empty($save)) { if ($action == 'create_variable' && !empty($save)) {
$res = $price_globals->create($user); $res = $price_globals->create($user);
if ($res > 0) { if ($res > 0) {
$action = ''; $action = '';
} else { } else {
setEventMessages($price_globals->error, $price_globals->errors, 'errors'); setEventMessages($price_globals->error, $price_globals->errors, 'errors');
} }
} elseif ($action == 'edit_variable' && !empty($save)) { } elseif ($action == 'edit_variable' && !empty($save)) {
$res = $price_globals->update($user); $res = $price_globals->update($user);
if ($res > 0) { if ($res > 0) {
$action = ''; $action = '';
} else { } else {
setEventMessages($price_globals->error, $price_globals->errors, 'errors'); setEventMessages($price_globals->error, $price_globals->errors, 'errors');
} }
} elseif ($action == 'delete_variable') { } elseif ($action == 'delete_variable') {
$res = $price_globals->delete($selection, $user); $res = $price_globals->delete($selection, $user);
if ($res > 0) { if ($res > 0) {
$action = ''; $action = '';
} else { } else {
setEventMessages($price_globals->error, $price_globals->errors, 'errors'); setEventMessages($price_globals->error, $price_globals->errors, 'errors');
} }
} }
//Updaters actions //Updaters actions
if ($action == 'create_updater' || $action == 'edit_updater') { if ($action == 'create_updater' || $action == 'edit_updater') {
$price_updaters->type = GETPOSTISSET('type') ? GETPOST('type', 'int') : $price_updaters->type; $price_updaters->type = GETPOSTISSET('type') ? GETPOST('type', 'int') : $price_updaters->type;
$price_updaters->description = GETPOSTISSET('description') ? GETPOST('description', 'restricthtml') : $price_updaters->description; $price_updaters->description = GETPOSTISSET('description') ? GETPOST('description', 'restricthtml') : $price_updaters->description;
$price_updaters->parameters = GETPOSTISSET('parameters') ? GETPOST('parameters', 'alphanohtml') : $price_updaters->parameters; $price_updaters->parameters = GETPOSTISSET('parameters') ? GETPOST('parameters', 'alphanohtml') : $price_updaters->parameters;
$price_updaters->fk_variable = GETPOSTISSET('fk_variable') ? GETPOST('fk_variable', 'int') : $price_updaters->fk_variable; $price_updaters->fk_variable = GETPOSTISSET('fk_variable') ? GETPOST('fk_variable', 'int') : $price_updaters->fk_variable;
$price_updaters->update_interval = GETPOSTISSET('update_interval') ? GETPOST('update_interval', 'int') : $price_updaters->update_interval; $price_updaters->update_interval = GETPOSTISSET('update_interval') ? GETPOST('update_interval', 'int') : $price_updaters->update_interval;
} }
if ($action == 'create_updater' && !empty($save)) { if ($action == 'create_updater' && !empty($save)) {
//Verify if process() works //Verify if process() works
$res = $price_updaters->process(); $res = $price_updaters->process();
if ($res > 0) { if ($res > 0) {
$res = $price_updaters->create($user); $res = $price_updaters->create($user);
} }
if ($res > 0) { if ($res > 0) {
$action = ''; $action = '';
} else { } else {
setEventMessages($price_updaters->error, $price_updaters->errors, 'errors'); setEventMessages($price_updaters->error, $price_updaters->errors, 'errors');
} }
} elseif ($action == 'edit_updater' && !empty($save)) { } elseif ($action == 'edit_updater' && !empty($save)) {
//Verify if process() works //Verify if process() works
$res = $price_updaters->process(); $res = $price_updaters->process();
if ($res > 0) { if ($res > 0) {
$res = $price_updaters->update($user); $res = $price_updaters->update($user);
} }
if ($res > 0) { if ($res > 0) {
$action = ''; $action = '';
} else { } else {
setEventMessages($price_updaters->error, $price_updaters->errors, 'errors'); setEventMessages($price_updaters->error, $price_updaters->errors, 'errors');
} }
} elseif ($action == 'delete_updater') { } elseif ($action == 'delete_updater') {
$res = $price_updaters->delete($selection, $user); $res = $price_updaters->delete($selection, $user);
if ($res > 0) { if ($res > 0) {
$action = ''; $action = '';
} else { } else {
setEventMessages($price_updaters->error, $price_updaters->errors, 'errors'); setEventMessages($price_updaters->error, $price_updaters->errors, 'errors');
} }
} }
} elseif (!empty($cancel)) { } elseif (!empty($cancel)) {
$action = ''; $action = '';
} }
@ -159,171 +159,171 @@ print '<br>';
//Global variables table //Global variables table
if ($action != 'create_updater' && $action != 'edit_updater') if ($action != 'create_updater' && $action != 'edit_updater')
{ {
print load_fiche_titre($langs->trans("GlobalVariables"), '', ''); print load_fiche_titre($langs->trans("GlobalVariables"), '', '');
print '<table summary="listofattributes" class="noborder centpercent">'; print '<table summary="listofattributes" class="noborder centpercent">';
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print '<td>'.$langs->trans("Variable").'</td>'; print '<td>'.$langs->trans("Variable").'</td>';
print '<td>'.$langs->trans("Description").'</td>'; print '<td>'.$langs->trans("Description").'</td>';
print '<td>'.$langs->trans("Value").'</td>'; print '<td>'.$langs->trans("Value").'</td>';
print '<td width="80">&nbsp;</td>'; //Space for buttons print '<td width="80">&nbsp;</td>'; //Space for buttons
print '</tr>'; print '</tr>';
$arrayglobalvars = $price_globals->listGlobalVariables(); $arrayglobalvars = $price_globals->listGlobalVariables();
if (!empty($arrayglobalvars)) if (!empty($arrayglobalvars))
{ {
foreach ($arrayglobalvars as $i=>$entry) { foreach ($arrayglobalvars as $i=>$entry) {
$var = !$var; $var = !$var;
print '<tr class="oddeven">'; print '<tr class="oddeven">';
print '<td>'.$entry->code.'</td>'; print '<td>'.$entry->code.'</td>';
print '<td>'.$entry->description.'</td>'; print '<td>'.$entry->description.'</td>';
print '<td>'.price($entry->value).'</td>'; print '<td>'.price($entry->value).'</td>';
print '<td class="right"><a href="'.$_SERVER["PHP_SELF"].'?action=edit_variable&token='.newToken().'&selection='.$entry->id.'">'.img_edit().'</a> &nbsp;'; print '<td class="right"><a href="'.$_SERVER["PHP_SELF"].'?action=edit_variable&token='.newToken().'&selection='.$entry->id.'">'.img_edit().'</a> &nbsp;';
print '<a href="'.$_SERVER["PHP_SELF"].'?action=delete_variable&token='.newToken().'&selection='.$entry->id.'">'.img_delete().'</a></td>'; print '<a href="'.$_SERVER["PHP_SELF"].'?action=delete_variable&token='.newToken().'&selection='.$entry->id.'">'.img_delete().'</a></td>';
print '</tr>'; print '</tr>';
} }
} else { } else {
print '<tr colspan="7"><td class="opacitymedium">'; print '<tr colspan="7"><td class="opacitymedium">';
print $langs->trans("None"); print $langs->trans("None");
print '</td></tr>'; print '</td></tr>';
} }
print '</table>'; print '</table>';
if (empty($action)) if (empty($action))
{ {
//Action Buttons //Action Buttons
print '<div class="tabsAction">'; print '<div class="tabsAction">';
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=create_variable">'.$langs->trans("AddVariable").'</a>'; print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=create_variable">'.$langs->trans("AddVariable").'</a>';
print '</div>'; print '</div>';
//Separator is only need for updaters table is showed after buttons //Separator is only need for updaters table is showed after buttons
print '<br><br>'; print '<br><br>';
} }
} }
//Global variable editor //Global variable editor
if ($action == 'create_variable' || $action == 'edit_variable') { if ($action == 'create_variable' || $action == 'edit_variable') {
//Form //Form
print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">'; print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">';
print '<input type="hidden" name="token" value="'.newToken().'">'; print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="action" value="'.$action.'">'; print '<input type="hidden" name="action" value="'.$action.'">';
print '<input type="hidden" name="selection" value="'.$selection.'">'; print '<input type="hidden" name="selection" value="'.$selection.'">';
//Table //Table
print '<br><table summary="listofattributes" class="border centpercent">'; print '<br><table summary="listofattributes" class="border centpercent">';
//Code //Code
print '<tr>'; print '<tr>';
print '<td class="fieldrequired">'.$langs->trans("Variable").'</td>'; print '<td class="fieldrequired">'.$langs->trans("Variable").'</td>';
print '<td class="valeur"><input type="text" name="code" size="20" value="'.(empty($price_globals->code) ? '' : $price_globals->code).'"></td>'; print '<td class="valeur"><input type="text" name="code" size="20" value="'.(empty($price_globals->code) ? '' : $price_globals->code).'"></td>';
print '</tr>'; print '</tr>';
//Description //Description
print '<tr>'; print '<tr>';
print '<td>'.$langs->trans("Description").'</td>'; print '<td>'.$langs->trans("Description").'</td>';
print '<td class="valeur"><input type="text" name="description" size="50" value="'.(empty($price_globals->description) ? '' : $price_globals->description).'"></td>'; print '<td class="valeur"><input type="text" name="description" size="50" value="'.(empty($price_globals->description) ? '' : $price_globals->description).'"></td>';
print '</tr>'; print '</tr>';
//Value //Value
print '<tr>'; print '<tr>';
print '<td class="fieldrequired">'.$langs->trans("Value").'</td>'; print '<td class="fieldrequired">'.$langs->trans("Value").'</td>';
print '<td class="valeur"><input type="text" name="value" size="10" value="'.(empty($price_globals->value) ? '' : $price_globals->value).'"></td>'; print '<td class="valeur"><input type="text" name="value" size="10" value="'.(empty($price_globals->value) ? '' : $price_globals->value).'"></td>';
print '</tr>'; print '</tr>';
print '</table>'; print '</table>';
//Form Buttons //Form Buttons
print '<br><div class="center">'; print '<br><div class="center">';
print '<input type="submit" class="button" name="save" value="'.$langs->trans("Save").'"> &nbsp;'; print '<input type="submit" class="button" name="save" value="'.$langs->trans("Save").'"> &nbsp;';
print '<input type="submit" class="button" name="cancel" id="cancel" value="'.$langs->trans("Cancel").'">'; print '<input type="submit" class="button" name="cancel" id="cancel" value="'.$langs->trans("Cancel").'">';
print '</div>'; print '</div>';
print '</form>'; print '</form>';
} }
// Updaters table // Updaters table
if ($action != 'create_variable' && $action != 'edit_variable') if ($action != 'create_variable' && $action != 'edit_variable')
{ {
print load_fiche_titre($langs->trans("GlobalVariableUpdaters"), '', ''); print load_fiche_titre($langs->trans("GlobalVariableUpdaters"), '', '');
print '<table summary="listofattributes" class="noborder centpercent">'; print '<table summary="listofattributes" class="noborder centpercent">';
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print '<td>'.$langs->trans("VariableToUpdate").'</td>'; print '<td>'.$langs->trans("VariableToUpdate").'</td>';
print '<td>'.$langs->trans("Description").'</td>'; print '<td>'.$langs->trans("Description").'</td>';
print '<td>'.$langs->trans("Type").'</td>'; print '<td>'.$langs->trans("Type").'</td>';
print '<td>'.$langs->trans("Parameters").'</td>'; print '<td>'.$langs->trans("Parameters").'</td>';
print '<td>'.$langs->trans("UpdateInterval").'</td>'; print '<td>'.$langs->trans("UpdateInterval").'</td>';
print '<td>'.$langs->trans("LastUpdated").'</td>'; print '<td>'.$langs->trans("LastUpdated").'</td>';
print '<td width="80">&nbsp;</td>'; //Space for buttons print '<td width="80">&nbsp;</td>'; //Space for buttons
print '</tr>'; print '</tr>';
$arraypriceupdaters = $price_updaters->listUpdaters(); $arraypriceupdaters = $price_updaters->listUpdaters();
if (!empty($arraypriceupdaters)) if (!empty($arraypriceupdaters))
{ {
foreach ($arraypriceupdaters as $i=>$entry) { foreach ($arraypriceupdaters as $i=>$entry) {
$code = ""; $code = "";
if ($entry->fk_variable > 0) { if ($entry->fk_variable > 0) {
$res = $price_globals->fetch($entry->fk_variable); $res = $price_globals->fetch($entry->fk_variable);
if ($res > 0) { if ($res > 0) {
$code = $price_globals->code; $code = $price_globals->code;
} }
} }
print '<tr>'; print '<tr>';
print '<td>'.$code.'</td>'; print '<td>'.$code.'</td>';
print '<td>'.$entry->description.'</td>'; print '<td>'.$entry->description.'</td>';
print '<td>'.$langs->trans("GlobalVariableUpdaterType".$entry->type).'</td>'; print '<td>'.$langs->trans("GlobalVariableUpdaterType".$entry->type).'</td>';
print '<td style="max-width: 250px; word-wrap: break-word; white-space: pre-wrap;">'.$entry->parameters.'</td>'; print '<td style="max-width: 250px; word-wrap: break-word; white-space: pre-wrap;">'.$entry->parameters.'</td>';
print '<td>'.$entry->update_interval.'</td>'; print '<td>'.$entry->update_interval.'</td>';
print '<td>'.$entry->getLastUpdated().'</td>'; print '<td>'.$entry->getLastUpdated().'</td>';
print '<td class="right"><a href="'.$_SERVER["PHP_SELF"].'?action=edit_updater&selection='.$entry->id.'">'.img_edit().'</a> &nbsp;'; print '<td class="right"><a href="'.$_SERVER["PHP_SELF"].'?action=edit_updater&selection='.$entry->id.'">'.img_edit().'</a> &nbsp;';
print '<a href="'.$_SERVER["PHP_SELF"].'?action=delete_updater&token='.newToken().'&selection='.$entry->id.'">'.img_delete().'</a></td>'; print '<a href="'.$_SERVER["PHP_SELF"].'?action=delete_updater&token='.newToken().'&selection='.$entry->id.'">'.img_delete().'</a></td>';
print '</tr>'; print '</tr>';
} }
} else { } else {
print '<tr><td colspan="7" class="opacitymedium">'; print '<tr><td colspan="7" class="opacitymedium">';
print $langs->trans("None"); print $langs->trans("None");
print '</td></tr>'; print '</td></tr>';
} }
print '</table>'; print '</table>';
if (empty($action)) if (empty($action))
{ {
//Action Buttons //Action Buttons
print '<div class="tabsAction">'; print '<div class="tabsAction">';
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=create_updater&token='.newToken().'">'.$langs->trans("AddUpdater").'</a>'; print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=create_updater&token='.newToken().'">'.$langs->trans("AddUpdater").'</a>';
print '</div>'; print '</div>';
} }
} }
//Updater editor //Updater editor
if ($action == 'create_updater' || $action == 'edit_updater') { if ($action == 'create_updater' || $action == 'edit_updater') {
//Form //Form
print '<form id="updaterform" action="'.$_SERVER["PHP_SELF"].'" method="post">'; print '<form id="updaterform" action="'.$_SERVER["PHP_SELF"].'" method="post">';
print '<input type="hidden" name="token" value="'.newToken().'">'; print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="action" value="'.$action.'">'; print '<input type="hidden" name="action" value="'.$action.'">';
print '<input type="hidden" name="selection" value="'.$selection.'">'; print '<input type="hidden" name="selection" value="'.$selection.'">';
//Table //Table
print '<br><table summary="listofattributes" class="border centpercent">'; print '<br><table summary="listofattributes" class="border centpercent">';
//Code //Code
print '<tr>'; print '<tr>';
print '<td class="fieldrequired">'.$langs->trans("VariableToUpdate").'</td><td>'; print '<td class="fieldrequired">'.$langs->trans("VariableToUpdate").'</td><td>';
$globals_list = array(); $globals_list = array();
foreach ($price_globals->listGlobalVariables() as $entry) { foreach ($price_globals->listGlobalVariables() as $entry) {
$globals_list[$entry->id] = $entry->code; $globals_list[$entry->id] = $entry->code;
} }
print $form->selectarray('fk_variable', $globals_list, (empty($price_updaters->fk_variable) ? 0 : $price_updaters->fk_variable)); print $form->selectarray('fk_variable', $globals_list, (empty($price_updaters->fk_variable) ? 0 : $price_updaters->fk_variable));
print '</td></tr>'; print '</td></tr>';
//Description //Description
print '<tr>'; print '<tr>';
print '<td>'.$langs->trans("Description").'</td>'; print '<td>'.$langs->trans("Description").'</td>';
print '<td class="valeur"><input type="text" name="description" size="50" value="'.(empty($price_updaters->description) ? '' : $price_updaters->description).'"></td>'; print '<td class="valeur"><input type="text" name="description" size="50" value="'.(empty($price_updaters->description) ? '' : $price_updaters->description).'"></td>';
print '</tr>'; print '</tr>';
//Type //Type
print '<tr>'; print '<tr>';
print '<td class="fieldrequired">'.$langs->trans("Type").'</td><td>'; print '<td class="fieldrequired">'.$langs->trans("Type").'</td><td>';
$type = empty($price_updaters->type) ? 0 : $price_updaters->type; $type = empty($price_updaters->type) ? 0 : $price_updaters->type;
$type_list = array(); $type_list = array();
foreach ($price_updaters->types as $val) { foreach ($price_updaters->types as $val) {
$type_list[$val] = $langs->trans("GlobalVariableUpdaterType".$val); $type_list[$val] = $langs->trans("GlobalVariableUpdaterType".$val);
} }
print $form->selectarray('type', $type_list, $type); print $form->selectarray('type', $type_list, $type);
// This code submits form when type is changed // This code submits form when type is changed
print '<script type="text/javascript"> print '<script type="text/javascript">
jQuery(document).ready(run); jQuery(document).ready(run);
function run() { function run() {
jQuery("#type").change(on_change); jQuery("#type").change(on_change);
@ -332,29 +332,29 @@ if ($action == 'create_updater' || $action == 'edit_updater') {
jQuery("#updaterform").submit(); jQuery("#updaterform").submit();
} }
</script>'; </script>';
print '</td></tr>'; print '</td></tr>';
//Parameters //Parameters
print '<tr>'; print '<tr>';
$help = $langs->trans("GlobalVariableUpdaterHelp".$type).'<br><b>'.$langs->trans("GlobalVariableUpdaterHelpFormat".$type).'</b>'; $help = $langs->trans("GlobalVariableUpdaterHelp".$type).'<br><b>'.$langs->trans("GlobalVariableUpdaterHelpFormat".$type).'</b>';
print '<td class="fieldrequired">'.$form->textwithpicto($langs->trans("Parameters"), $help, 1).'</td><td>'; print '<td class="fieldrequired">'.$form->textwithpicto($langs->trans("Parameters"), $help, 1).'</td><td>';
require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
$doleditor = new DolEditor('parameters', empty($price_updaters->parameters) ? '' : $price_updaters->parameters, '', 300, '', '', false, false, false, ROWS_8, '90%'); $doleditor = new DolEditor('parameters', empty($price_updaters->parameters) ? '' : $price_updaters->parameters, '', 300, '', '', false, false, false, ROWS_8, '90%');
$doleditor->Create(); $doleditor->Create();
print '</td></tr>'; print '</td></tr>';
print '</tr>'; print '</tr>';
//Interval //Interval
print '<tr>'; print '<tr>';
print '<td class="fieldrequired">'.$langs->trans("UpdateInterval").'</td>'; print '<td class="fieldrequired">'.$langs->trans("UpdateInterval").'</td>';
print '<td class="valeur"><input type="text" name="update_interval" size="10" value="'.(empty($price_updaters->update_interval) ? '' : $price_updaters->update_interval).'"></td>'; print '<td class="valeur"><input type="text" name="update_interval" size="10" value="'.(empty($price_updaters->update_interval) ? '' : $price_updaters->update_interval).'"></td>';
print '</tr>'; print '</tr>';
print '</table>'; print '</table>';
//Form Buttons //Form Buttons
print '<br><div class="center">'; print '<br><div class="center">';
print '<input type="submit" class="button" name="save" value="'.$langs->trans("Save").'"> &nbsp;'; print '<input type="submit" class="button" name="save" value="'.$langs->trans("Save").'"> &nbsp;';
print '<input type="submit" class="button" name="cancel" id="cancel" value="'.$langs->trans("Cancel").'">'; print '<input type="submit" class="button" name="cancel" id="cancel" value="'.$langs->trans("Cancel").'">';
print '</div>'; print '</div>';
print '</form>'; print '</form>';
} }
// End of page // End of page

View File

@ -301,8 +301,8 @@ if (empty($reshook))
$object->note_private = dol_htmlcleanlastbr(GETPOST('note_private', 'restricthtml')); $object->note_private = dol_htmlcleanlastbr(GETPOST('note_private', 'restricthtml'));
$object->note = $object->note_private; // deprecated $object->note = $object->note_private; // deprecated
$object->customcode = GETPOST('customcode', 'alphanohtml'); $object->customcode = GETPOST('customcode', 'alphanohtml');
$object->country_id = GETPOST('country_id', 'int'); $object->country_id = GETPOST('country_id', 'int');
$object->state_id = GETPOST('state_id', 'int'); $object->state_id = GETPOST('state_id', 'int');
$object->duration_value = $duration_value; $object->duration_value = $duration_value;
$object->duration_unit = $duration_unit; $object->duration_unit = $duration_unit;
$object->fk_default_warehouse = GETPOST('fk_default_warehouse'); $object->fk_default_warehouse = GETPOST('fk_default_warehouse');
@ -965,14 +965,14 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action))
$linkback = ""; $linkback = "";
print load_fiche_titre($title, $linkback, $picto); print load_fiche_titre($title, $linkback, $picto);
// We set country_id, country_code and country for the selected country // We set country_id, country_code and country for the selected country
$object->country_id = GETPOSTISSET('country_id') ? GETPOST('country_id', 'int') : null; $object->country_id = GETPOSTISSET('country_id') ? GETPOST('country_id', 'int') : null;
if ($object->country_id > 0) if ($object->country_id > 0)
{ {
$tmparray = getCountry($object->country_id, 'all'); $tmparray = getCountry($object->country_id, 'all');
$object->country_code = $tmparray['code']; $object->country_code = $tmparray['code'];
$object->country = $tmparray['label']; $object->country = $tmparray['label'];
} }
dol_fiche_head(''); dol_fiche_head('');
@ -1151,26 +1151,26 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action))
// Origin country // Origin country
print '<td>'.$langs->trans("CountryOrigin").'</td>'; print '<td>'.$langs->trans("CountryOrigin").'</td>';
print '<td>'; print '<td>';
print img_picto('', 'globe-americas', 'class="paddingrightonly"'); print img_picto('', 'globe-americas', 'class="paddingrightonly"');
print $form->select_country((GETPOSTISSET('country_id') ? GETPOST('country_id') : $object->country_id), 'country_id', '', 0, 'minwidth300 widthcentpercentminusx'); print $form->select_country((GETPOSTISSET('country_id') ? GETPOST('country_id') : $object->country_id), 'country_id', '', 0, 'minwidth300 widthcentpercentminusx');
if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1);
print '</td>'; print '</td>';
// State // State
if (empty($conf->global->PRODUCT_DISABLE_STATE)) if (empty($conf->global->PRODUCT_DISABLE_STATE))
{ {
if ($conf->browser->layout == 'phone') print '</tr><tr>'; if ($conf->browser->layout == 'phone') print '</tr><tr>';
if (!empty($conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT) && ($conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT == 1 || $conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT == 2)) if (!empty($conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT) && ($conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT == 1 || $conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT == 2))
{ {
print '<td>'.$form->editfieldkey('Region-StateOrigine', 'state_id', '', $object, 0).'</td><td colspan="3">'; print '<td>'.$form->editfieldkey('Region-StateOrigine', 'state_id', '', $object, 0).'</td><td colspan="3">';
} else { } else {
print '<td>'.$form->editfieldkey('StateOrigin', 'state_id', '', $object, 0).'</td><td colspan="3">'; print '<td>'.$form->editfieldkey('StateOrigin', 'state_id', '', $object, 0).'</td><td colspan="3">';
} }
print $formcompany->select_state($object->state_id, $object->country_code); print $formcompany->select_state($object->state_id, $object->country_code);
print '</tr>'; print '</tr>';
} }
print '</tr>'; print '</tr>';
} }
// Other attributes // Other attributes
@ -1616,7 +1616,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action))
// State // State
if (empty($conf->global->PRODUCT_DISABLE_STATE)) if (empty($conf->global->PRODUCT_DISABLE_STATE))
{ {
if ($conf->browser->layout == 'phone') print '</tr><tr>'; if ($conf->browser->layout == 'phone') print '</tr><tr>';
if (!empty($conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT) && ($conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT == 1 || $conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT == 2)) if (!empty($conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT) && ($conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT == 1 || $conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT == 2))
{ {
print '<td>'.$form->editfieldkey('Region-StateOrigine', 'state_id', '', $object, 0).'</td><td colspan="3">'; print '<td>'.$form->editfieldkey('Region-StateOrigine', 'state_id', '', $object, 0).'</td><td colspan="3">';
@ -2389,7 +2389,7 @@ if ($action != 'create' && $action != 'edit' && $action != 'delete')
$objectref = dol_sanitizeFileName($object->ref); $objectref = dol_sanitizeFileName($object->ref);
$relativepath = $comref.'/'.$objectref.'.pdf'; $relativepath = $comref.'/'.$objectref.'.pdf';
if (!empty($conf->product->multidir_output[$object->entity])) { if (!empty($conf->product->multidir_output[$object->entity])) {
$filedir = $conf->product->multidir_output[$object->entity].'/'.$objectref; //Check repertories of current entities $filedir = $conf->product->multidir_output[$object->entity].'/'.$objectref; //Check repertories of current entities
} else { } else {
$filedir = $conf->product->dir_output.'/'.$objectref; $filedir = $conf->product->dir_output.'/'.$objectref;
} }

View File

@ -368,7 +368,7 @@ class Productcustomerprice extends CommonObject
} elseif ($key == 'prod.ref' || $key == 'prod.label') { } elseif ($key == 'prod.ref' || $key == 'prod.label') {
$sql .= ' AND '.$key.' LIKE \'%'.$this->db->escape($value).'%\''; $sql .= ' AND '.$key.' LIKE \'%'.$this->db->escape($value).'%\'';
} elseif ($key == 't.price' || $key == 't.price_ttc') { } elseif ($key == 't.price' || $key == 't.price_ttc') {
$sql .= ' AND ' . $key . ' LIKE \'%' . price2num($value) . '%\''; $sql .= ' AND '.$key.' LIKE \'%'.price2num($value).'%\'';
} else { } else {
$sql .= ' AND '.$key.' = '.((int) $value); $sql .= ' AND '.$key.' = '.((int) $value);
} }

File diff suppressed because it is too large Load Diff

View File

@ -630,7 +630,7 @@ if ($search_ref || $search_label || $sall || $salert || $draftorder || GETPOST('
} }
if ($limit > 0 && $limit != $conf->liste_limit) { if ($limit > 0 && $limit != $conf->liste_limit) {
$filters .= '&limit=' . urlencode($limit); $filters .= '&limit='.urlencode($limit);
} }
$param = (isset($type) ? '&type='.$type : ''); $param = (isset($type) ? '&type='.$type : '');
@ -701,7 +701,7 @@ if (!empty($conf->global->STOCK_ALLOW_ADD_LIMIT_STOCK_BY_WAREHOUSE) && $fk_entre
print '<td class="liste_titre">&nbsp;</td>'; print '<td class="liste_titre">&nbsp;</td>';
} }
print '<td class="liste_titre right">'; print '<td class="liste_titre right">';
if (! empty($conf->global->STOCK_REPLENISH_ADD_CHECKBOX_INCLUDE_DRAFT_ORDER)) { if (!empty($conf->global->STOCK_REPLENISH_ADD_CHECKBOX_INCLUDE_DRAFT_ORDER)) {
print $langs->trans('IncludeAlsoDraftOrders').'&nbsp;<input type="checkbox" id="draftorder" name="draftorder" '.(!empty($draftchecked) ? $draftchecked : '').'>'; print $langs->trans('IncludeAlsoDraftOrders').'&nbsp;<input type="checkbox" id="draftorder" name="draftorder" '.(!empty($draftchecked) ? $draftchecked : '').'>';
} }
print '</td>'; print '</td>';
@ -768,7 +768,7 @@ while ($i < ($limit ? min($num, $limit) : $num))
} }
} }
$stockwarehouse=0; $stockwarehouse = 0;
if ($usevirtualstock) if ($usevirtualstock)
{ {
// If option to increase/decrease is not on an object validation, virtual stock may differs from physical stock. // If option to increase/decrease is not on an object validation, virtual stock may differs from physical stock.

View File

@ -178,7 +178,7 @@ class Project extends CommonObject
/** /**
* @var array Array with all fields and their property. Do not use it as a static var. It may be modified by constructor. * @var array Array with all fields and their property. Do not use it as a static var. It may be modified by constructor.
*/ */
public $fields=array( public $fields = array(
'rowid' =>array('type'=>'integer', 'label'=>'ID', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>10), 'rowid' =>array('type'=>'integer', 'label'=>'ID', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>10),
'fk_soc' =>array('type'=>'integer', 'label'=>'Fk soc', 'enabled'=>1, 'visible'=>3, 'position'=>15), 'fk_soc' =>array('type'=>'integer', 'label'=>'Fk soc', 'enabled'=>1, 'visible'=>3, 'position'=>15),
'datec' =>array('type'=>'datetime', 'label'=>'DateCreationShort', 'enabled'=>1, 'visible'=>1, 'position'=>20), 'datec' =>array('type'=>'datetime', 'label'=>'DateCreationShort', 'enabled'=>1, 'visible'=>1, 'position'=>20),
@ -577,7 +577,7 @@ class Project extends CommonObject
$this->opp_percent = $obj->opp_percent; $this->opp_percent = $obj->opp_percent;
$this->budget_amount = $obj->budget_amount; $this->budget_amount = $obj->budget_amount;
$this->model_pdf = $obj->model_pdf; $this->model_pdf = $obj->model_pdf;
$this->modelpdf = $obj->model_pdf; // deprecated $this->modelpdf = $obj->model_pdf; // deprecated
$this->usage_opportunity = (int) $obj->usage_opportunity; $this->usage_opportunity = (int) $obj->usage_opportunity;
$this->usage_task = (int) $obj->usage_task; $this->usage_task = (int) $obj->usage_task;
$this->usage_bill_time = (int) $obj->usage_bill_time; $this->usage_bill_time = (int) $obj->usage_bill_time;

View File

@ -228,47 +228,47 @@ if (empty($reshook))
$uploaddir = $conf->projet->dir_output; $uploaddir = $conf->projet->dir_output;
include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
// Close records // Close records
if (!$error && $massaction == 'close' && $user->rights->projet->creer) if (!$error && $massaction == 'close' && $user->rights->projet->creer)
{ {
$db->begin(); $db->begin();
$objecttmp = new $objectclass($db); $objecttmp = new $objectclass($db);
$nbok = 0; $nbok = 0;
foreach ($toselect as $toselectid) foreach ($toselect as $toselectid)
{ {
$result = $objecttmp->fetch($toselectid); $result = $objecttmp->fetch($toselectid);
if ($result > 0) if ($result > 0)
{ {
$userWrite = $object->restrictedProjectArea($user, 'write'); $userWrite = $object->restrictedProjectArea($user, 'write');
if ($userWrite > 0 && $objecttmp->statut == 1) { if ($userWrite > 0 && $objecttmp->statut == 1) {
$result = $objecttmp->setClose($user); $result = $objecttmp->setClose($user);
if ($result <= 0) { if ($result <= 0) {
setEventMessages($objecttmp->error, $objecttmp->errors, 'errors'); setEventMessages($objecttmp->error, $objecttmp->errors, 'errors');
$error++; $error++;
break; break;
} else $nbok++; } else $nbok++;
} elseif ($userWrite <= 0) { } elseif ($userWrite <= 0) {
setEventMessages($langs->trans("DontHavePermissionForCloseProject", $objecttmp->ref), null, 'warnings'); setEventMessages($langs->trans("DontHavePermissionForCloseProject", $objecttmp->ref), null, 'warnings');
} else { } else {
setEventMessages($langs->trans("DontHaveTheValidateStatus", $objecttmp->ref), null, 'warnings'); setEventMessages($langs->trans("DontHaveTheValidateStatus", $objecttmp->ref), null, 'warnings');
} }
} else { } else {
setEventMessages($objecttmp->error, $objecttmp->errors, 'errors'); setEventMessages($objecttmp->error, $objecttmp->errors, 'errors');
$error++; $error++;
break; break;
} }
} }
if (!$error) if (!$error)
{ {
if ($nbok > 1) setEventMessages($langs->trans("RecordsClosed", $nbok), null, 'mesgs'); if ($nbok > 1) setEventMessages($langs->trans("RecordsClosed", $nbok), null, 'mesgs');
else setEventMessages($langs->trans("RecordsClosed", $nbok), null, 'mesgs'); else setEventMessages($langs->trans("RecordsClosed", $nbok), null, 'mesgs');
$db->commit(); $db->commit();
} else { } else {
$db->rollback(); $db->rollback();
} }
} }
} }
@ -447,8 +447,8 @@ include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
// List of mass actions available // List of mass actions available
$arrayofmassactions = array( $arrayofmassactions = array(
'generate_doc'=>$langs->trans("ReGeneratePDF"), 'generate_doc'=>$langs->trans("ReGeneratePDF"),
//'builddoc'=>$langs->trans("PDFMerge"), //'builddoc'=>$langs->trans("PDFMerge"),
//'presend'=>$langs->trans("SendByMail"), //'presend'=>$langs->trans("SendByMail"),
); );
//if($user->rights->societe->creer) $arrayofmassactions['createbills']=$langs->trans("CreateInvoiceForThisCustomer"); //if($user->rights->societe->creer) $arrayofmassactions['createbills']=$langs->trans("CreateInvoiceForThisCustomer");
if ($user->rights->projet->creer) $arrayofmassactions['close'] = $langs->trans("Close"); if ($user->rights->projet->creer) $arrayofmassactions['close'] = $langs->trans("Close");
@ -474,8 +474,8 @@ print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
$texthelp = ''; $texthelp = '';
if ($search_project_user == $user->id) $texthelp .= $langs->trans("MyProjectsDesc"); if ($search_project_user == $user->id) $texthelp .= $langs->trans("MyProjectsDesc");
else { else {
if ($user->rights->projet->all->lire && !$socid) $texthelp .= $langs->trans("ProjectsDesc"); if ($user->rights->projet->all->lire && !$socid) $texthelp .= $langs->trans("ProjectsDesc");
else $texthelp .= $langs->trans("ProjectsPublicDesc"); else $texthelp .= $langs->trans("ProjectsPublicDesc");
} }
print_barre_liste($form->textwithpicto($title, $texthelp), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'project', 0, $newcardbutton, '', $limit, 0, 0, 1); print_barre_liste($form->textwithpicto($title, $texthelp), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'project', 0, $newcardbutton, '', $limit, 0, 0, 1);
@ -616,8 +616,8 @@ if (!empty($arrayfields['p.opp_percent']['checked']))
} }
if (!empty($arrayfields['opp_weighted_amount']['checked'])) if (!empty($arrayfields['opp_weighted_amount']['checked']))
{ {
print '<td class="liste_titre nowrap right">'; print '<td class="liste_titre nowrap right">';
print '</td>'; print '</td>';
} }
if (!empty($arrayfields['p.budget_amount']['checked'])) if (!empty($arrayfields['p.budget_amount']['checked']))
{ {
@ -711,8 +711,8 @@ print "</tr>\n";
$i = 0; $i = 0;
$totalarray = array( $totalarray = array(
'nbfield' => 0, 'nbfield' => 0,
'val' => array(), 'val' => array(),
); );
while ($i < min($num, $limit)) while ($i < min($num, $limit))
{ {
@ -732,9 +732,9 @@ while ($i < min($num, $limit))
$userAccess = $object->restrictedProjectArea($user); // why this ? $userAccess = $object->restrictedProjectArea($user); // why this ?
if ($userAccess >= 0) if ($userAccess >= 0)
{ {
$socstatic->id = $obj->socid; $socstatic->id = $obj->socid;
$socstatic->name = $obj->name; $socstatic->name = $obj->name;
$socstatic->email = $obj->email; $socstatic->email = $obj->email;
print '<tr class="oddeven">'; print '<tr class="oddeven">';
@ -862,19 +862,19 @@ while ($i < min($num, $limit))
print '</td>'; print '</td>';
if (!$i) $totalarray['nbfield']++; if (!$i) $totalarray['nbfield']++;
} }
// Opp weighted amount // Opp weighted amount
if (!empty($arrayfields['opp_weighted_amount']['checked'])) if (!empty($arrayfields['opp_weighted_amount']['checked']))
{ {
if (!isset($totalarray['val']['opp_weighted_amount'])) $totalarray['val']['opp_weighted_amount'] = 0; if (!isset($totalarray['val']['opp_weighted_amount'])) $totalarray['val']['opp_weighted_amount'] = 0;
print '<td align="right">'; print '<td align="right">';
if ($obj->opp_weighted_amount) { if ($obj->opp_weighted_amount) {
print price($obj->opp_weighted_amount, 1, $langs, 1, -1, -1, ''); print price($obj->opp_weighted_amount, 1, $langs, 1, -1, -1, '');
$totalarray['val']['opp_weighted_amount'] += $obj->opp_weighted_amount; $totalarray['val']['opp_weighted_amount'] += $obj->opp_weighted_amount;
} }
print '</td>'; print '</td>';
if (!$i) $totalarray['nbfield']++; if (!$i) $totalarray['nbfield']++;
if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'opp_weighted_amount'; if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'opp_weighted_amount';
} }
// Budget // Budget
if (!empty($arrayfields['p.budget_amount']['checked'])) if (!empty($arrayfields['p.budget_amount']['checked']))
{ {

View File

@ -86,7 +86,7 @@ if ($action == 'update' && !$_POST["cancel"] && $user->rights->projet->creer)
if (!$error) if (!$error)
{ {
$object->fetch($id, $ref); $object->fetch($id, $ref);
$object->oldcopy = clone $object; $object->oldcopy = clone $object;
$tmparray = explode('_', $_POST['task_parent']); $tmparray = explode('_', $_POST['task_parent']);
$task_parent = $tmparray[1]; $task_parent = $tmparray[1];
@ -110,7 +110,7 @@ if ($action == 'update' && !$_POST["cancel"] && $user->rights->projet->creer)
$result = $object->update($user); $result = $object->update($user);
if ($result < 0) if ($result < 0)
{ {
setEventMessages($object->error, $object->errors, 'errors'); setEventMessages($object->error, $object->errors, 'errors');
} }
} }
} else { } else {
@ -130,7 +130,7 @@ if ($action == 'confirm_delete' && $confirm == "yes" && $user->rights->projet->s
header('Location: '.DOL_URL_ROOT.'/projet/tasks.php?restore_lastsearch_values=1&id='.$projectstatic->id.($withproject ? '&withproject=1' : '')); header('Location: '.DOL_URL_ROOT.'/projet/tasks.php?restore_lastsearch_values=1&id='.$projectstatic->id.($withproject ? '&withproject=1' : ''));
exit; exit;
} else { } else {
setEventMessages($object->error, $object->errors, 'errors'); setEventMessages($object->error, $object->errors, 'errors');
$action = ''; $action = '';
} }
} }
@ -169,7 +169,7 @@ if ($action == 'builddoc' && $user->rights->projet->creer)
if ($result <= 0) if ($result <= 0)
{ {
setEventMessages($object->error, $object->errors, 'errors'); setEventMessages($object->error, $object->errors, 'errors');
$action = ''; $action = '';
} }
} }
@ -227,115 +227,115 @@ if ($id > 0 || !empty($ref))
// Project card // Project card
$linkback = '<a href="'.DOL_URL_ROOT.'/projet/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>'; $linkback = '<a href="'.DOL_URL_ROOT.'/projet/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
$morehtmlref = '<div class="refidno">'; $morehtmlref = '<div class="refidno">';
// Title // Title
$morehtmlref .= $projectstatic->title; $morehtmlref .= $projectstatic->title;
// Thirdparty // Thirdparty
if ($projectstatic->thirdparty->id > 0) if ($projectstatic->thirdparty->id > 0)
{ {
$morehtmlref .= '<br>'.$langs->trans('ThirdParty').' : '.$projectstatic->thirdparty->getNomUrl(1, 'project'); $morehtmlref .= '<br>'.$langs->trans('ThirdParty').' : '.$projectstatic->thirdparty->getNomUrl(1, 'project');
} }
$morehtmlref .= '</div>'; $morehtmlref .= '</div>';
// Define a complementary filter for search of next/prev ref. // Define a complementary filter for search of next/prev ref.
if (!$user->rights->projet->all->lire) if (!$user->rights->projet->all->lire)
{ {
$objectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 0); $objectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 0);
$projectstatic->next_prev_filter = " rowid in (".(count($objectsListId) ?join(',', array_keys($objectsListId)) : '0').")"; $projectstatic->next_prev_filter = " rowid in (".(count($objectsListId) ?join(',', array_keys($objectsListId)) : '0').")";
} }
dol_banner_tab($projectstatic, 'project_ref', $linkback, 1, 'ref', 'ref', $morehtmlref); dol_banner_tab($projectstatic, 'project_ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
print '<div class="fichecenter">'; print '<div class="fichecenter">';
print '<div class="fichehalfleft">'; print '<div class="fichehalfleft">';
print '<div class="underbanner clearboth"></div>'; print '<div class="underbanner clearboth"></div>';
print '<table class="border tableforfield centpercent">'; print '<table class="border tableforfield centpercent">';
// Usage // Usage
print '<tr><td class="tdtop">'; print '<tr><td class="tdtop">';
print $langs->trans("Usage"); print $langs->trans("Usage");
print '</td>'; print '</td>';
print '<td>'; print '<td>';
if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES))
{ {
print '<input type="checkbox" disabled name="usage_opportunity"'.(GETPOSTISSET('usage_opportunity') ? (GETPOST('usage_opportunity', 'alpha') != '' ? ' checked="checked"' : '') : ($projectstatic->usage_opportunity ? ' checked="checked"' : '')).'"> '; print '<input type="checkbox" disabled name="usage_opportunity"'.(GETPOSTISSET('usage_opportunity') ? (GETPOST('usage_opportunity', 'alpha') != '' ? ' checked="checked"' : '') : ($projectstatic->usage_opportunity ? ' checked="checked"' : '')).'"> ';
$htmltext = $langs->trans("ProjectFollowOpportunity"); $htmltext = $langs->trans("ProjectFollowOpportunity");
print $form->textwithpicto($langs->trans("ProjectFollowOpportunity"), $htmltext); print $form->textwithpicto($langs->trans("ProjectFollowOpportunity"), $htmltext);
print '<br>'; print '<br>';
} }
if (empty($conf->global->PROJECT_HIDE_TASKS)) if (empty($conf->global->PROJECT_HIDE_TASKS))
{ {
print '<input type="checkbox" disabled name="usage_task"'.(GETPOSTISSET('usage_task') ? (GETPOST('usage_task', 'alpha') != '' ? ' checked="checked"' : '') : ($projectstatic->usage_task ? ' checked="checked"' : '')).'"> '; print '<input type="checkbox" disabled name="usage_task"'.(GETPOSTISSET('usage_task') ? (GETPOST('usage_task', 'alpha') != '' ? ' checked="checked"' : '') : ($projectstatic->usage_task ? ' checked="checked"' : '')).'"> ';
$htmltext = $langs->trans("ProjectFollowTasks"); $htmltext = $langs->trans("ProjectFollowTasks");
print $form->textwithpicto($langs->trans("ProjectFollowTasks"), $htmltext); print $form->textwithpicto($langs->trans("ProjectFollowTasks"), $htmltext);
print '<br>'; print '<br>';
} }
if (!empty($conf->global->PROJECT_BILL_TIME_SPENT)) if (!empty($conf->global->PROJECT_BILL_TIME_SPENT))
{ {
print '<input type="checkbox" disabled name="usage_bill_time"'.(GETPOSTISSET('usage_bill_time') ? (GETPOST('usage_bill_time', 'alpha') != '' ? ' checked="checked"' : '') : ($projectstatic->usage_bill_time ? ' checked="checked"' : '')).'"> '; print '<input type="checkbox" disabled name="usage_bill_time"'.(GETPOSTISSET('usage_bill_time') ? (GETPOST('usage_bill_time', 'alpha') != '' ? ' checked="checked"' : '') : ($projectstatic->usage_bill_time ? ' checked="checked"' : '')).'"> ';
$htmltext = $langs->trans("ProjectBillTimeDescription"); $htmltext = $langs->trans("ProjectBillTimeDescription");
print $form->textwithpicto($langs->trans("BillTime"), $htmltext); print $form->textwithpicto($langs->trans("BillTime"), $htmltext);
print '<br>'; print '<br>';
} }
print '</td></tr>'; print '</td></tr>';
// Visibility // Visibility
print '<tr><td class="titlefield">'.$langs->trans("Visibility").'</td><td>'; print '<tr><td class="titlefield">'.$langs->trans("Visibility").'</td><td>';
if ($projectstatic->public) print $langs->trans('SharedProject'); if ($projectstatic->public) print $langs->trans('SharedProject');
else print $langs->trans('PrivateProject'); else print $langs->trans('PrivateProject');
print '</td></tr>'; print '</td></tr>';
// Date start - end // Date start - end
print '<tr><td>'.$langs->trans("DateStart").' - '.$langs->trans("DateEnd").'</td><td>'; print '<tr><td>'.$langs->trans("DateStart").' - '.$langs->trans("DateEnd").'</td><td>';
$start = dol_print_date($projectstatic->date_start, 'day'); $start = dol_print_date($projectstatic->date_start, 'day');
print ($start ? $start : '?'); print ($start ? $start : '?');
$end = dol_print_date($projectstatic->date_end, 'day'); $end = dol_print_date($projectstatic->date_end, 'day');
print ' - '; print ' - ';
print ($end ? $end : '?'); print ($end ? $end : '?');
if ($projectstatic->hasDelay()) print img_warning("Late"); if ($projectstatic->hasDelay()) print img_warning("Late");
print '</td></tr>'; print '</td></tr>';
// Budget // Budget
print '<tr><td>'.$langs->trans("Budget").'</td><td>'; print '<tr><td>'.$langs->trans("Budget").'</td><td>';
if (strcmp($projectstatic->budget_amount, '')) print price($projectstatic->budget_amount, '', $langs, 1, 0, 0, $conf->currency); if (strcmp($projectstatic->budget_amount, '')) print price($projectstatic->budget_amount, '', $langs, 1, 0, 0, $conf->currency);
print '</td></tr>'; print '</td></tr>';
// Other attributes // Other attributes
$cols = 2; $cols = 2;
//include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php'; //include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php';
print '</table>'; print '</table>';
print '</div>'; print '</div>';
print '<div class="fichehalfright">'; print '<div class="fichehalfright">';
print '<div class="ficheaddleft">'; print '<div class="ficheaddleft">';
print '<div class="underbanner clearboth"></div>'; print '<div class="underbanner clearboth"></div>';
print '<table class="border centpercent">'; print '<table class="border centpercent">';
// Description // Description
print '<td class="titlefield tdtop">'.$langs->trans("Description").'</td><td>'; print '<td class="titlefield tdtop">'.$langs->trans("Description").'</td><td>';
print nl2br($projectstatic->description); print nl2br($projectstatic->description);
print '</td></tr>'; print '</td></tr>';
// Categories // Categories
if ($conf->categorie->enabled) { if ($conf->categorie->enabled) {
print '<tr><td class="valignmiddle">'.$langs->trans("Categories").'</td><td>'; print '<tr><td class="valignmiddle">'.$langs->trans("Categories").'</td><td>';
print $form->showCategories($projectstatic->id, 'project', 1); print $form->showCategories($projectstatic->id, 'project', 1);
print "</td></tr>"; print "</td></tr>";
} }
print '</table>'; print '</table>';
print '</div>'; print '</div>';
print '</div>'; print '</div>';
print '</div>'; print '</div>';
print '<div class="clearboth"></div>'; print '<div class="clearboth"></div>';
dol_fiche_end(); dol_fiche_end();
@ -440,7 +440,7 @@ if ($id > 0 || !empty($ref))
// Other options // Other options
$parameters = array(); $parameters = array();
$reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
print $hookmanager->resPrint; print $hookmanager->resPrint;
if (empty($reshook)) if (empty($reshook))
{ {
print $object->showOptionals($extrafields, 'edit'); print $object->showOptionals($extrafields, 'edit');
@ -472,8 +472,8 @@ if ($id > 0 || !empty($ref))
if (!GETPOST('withproject') || empty($projectstatic->id)) if (!GETPOST('withproject') || empty($projectstatic->id))
{ {
$projectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 1); $projectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 1);
$object->next_prev_filter = " fk_projet in (".$projectsListId.")"; $object->next_prev_filter = " fk_projet in (".$projectsListId.")";
} else $object->next_prev_filter = " fk_projet = ".$projectstatic->id; } else $object->next_prev_filter = " fk_projet = ".$projectstatic->id;
$morehtmlref = ''; $morehtmlref = '';
@ -481,17 +481,17 @@ if ($id > 0 || !empty($ref))
// Project // Project
if (empty($withproject)) if (empty($withproject))
{ {
$morehtmlref .= '<div class="refidno">'; $morehtmlref .= '<div class="refidno">';
$morehtmlref .= $langs->trans("Project").': '; $morehtmlref .= $langs->trans("Project").': ';
$morehtmlref .= $projectstatic->getNomUrl(1); $morehtmlref .= $projectstatic->getNomUrl(1);
$morehtmlref .= '<br>'; $morehtmlref .= '<br>';
// Third party // Third party
$morehtmlref .= $langs->trans("ThirdParty").': '; $morehtmlref .= $langs->trans("ThirdParty").': ';
if (!empty($projectstatic->thirdparty)) { if (!empty($projectstatic->thirdparty)) {
$morehtmlref .= $projectstatic->thirdparty->getNomUrl(1); $morehtmlref .= $projectstatic->thirdparty->getNomUrl(1);
} }
$morehtmlref .= '</div>'; $morehtmlref .= '</div>';
} }
dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref, $param); dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref, $param);
@ -515,11 +515,11 @@ if ($id > 0 || !empty($ref))
// Date start - Date end // Date start - Date end
print '<tr><td class="titlefield">'.$langs->trans("DateStart").' - '.$langs->trans("DateEnd").'</td><td colspan="3">'; print '<tr><td class="titlefield">'.$langs->trans("DateStart").' - '.$langs->trans("DateEnd").'</td><td colspan="3">';
$start = dol_print_date($object->date_start, 'dayhour'); $start = dol_print_date($object->date_start, 'dayhour');
print ($start ? $start : '?'); print ($start ? $start : '?');
$end = dol_print_date($object->date_end, 'dayhour'); $end = dol_print_date($object->date_end, 'dayhour');
print ' - '; print ' - ';
print ($end ? $end : '?'); print ($end ? $end : '?');
if ($object->hasDelay()) print img_warning("Late"); if ($object->hasDelay()) print img_warning("Late");
print '</td></tr>'; print '</td></tr>';
// Planned workload // Planned workload
@ -584,13 +584,13 @@ if ($id > 0 || !empty($ref))
* Actions * Actions
*/ */
print '<div class="tabsAction">'; print '<div class="tabsAction">';
$parameters = array(); $parameters = array();
$reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been
// modified by hook // modified by hook
if (empty($reshook)) if (empty($reshook))
{ {
// Modify // Modify
if ($user->rights->projet->creer) if ($user->rights->projet->creer)
{ {
@ -602,21 +602,21 @@ if ($id > 0 || !empty($ref))
// Delete // Delete
if ($user->rights->projet->supprimer) if ($user->rights->projet->supprimer)
{ {
if (!$object->hasChildren() && !$object->hasTimeSpent()) if (!$object->hasChildren() && !$object->hasTimeSpent())
{ {
print '<a class="butActionDelete" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&amp;action=delete&amp;token='.newToken().'&amp;withproject='.$withproject.'">'.$langs->trans('Delete').'</a>'; print '<a class="butActionDelete" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&amp;action=delete&amp;token='.newToken().'&amp;withproject='.$withproject.'">'.$langs->trans('Delete').'</a>';
} else { } else {
print '<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans("TaskHasChild").'">'.$langs->trans('Delete').'</a>'; print '<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans("TaskHasChild").'">'.$langs->trans('Delete').'</a>';
} }
} else { } else {
print '<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans("NotAllowed").'">'.$langs->trans('Delete').'</a>'; print '<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans("NotAllowed").'">'.$langs->trans('Delete').'</a>';
} }
print '</div>'; print '</div>';
} }
print '<div class="fichecenter"><div class="fichehalfleft">'; print '<div class="fichecenter"><div class="fichehalfleft">';
print '<a name="builddoc"></a>'; // ancre print '<a name="builddoc"></a>'; // ancre
/* /*
* Documents generes * Documents generes

View File

@ -257,7 +257,7 @@ if ($action == 'create' || $object->fetch($id, $ref) > 0)
// Other attributes // Other attributes
$parameters = array('objectsrc' => $objectsrc); $parameters = array('objectsrc' => $objectsrc);
$reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
print $hookmanager->resPrint; print $hookmanager->resPrint;
if (empty($reshook)) if (empty($reshook))
{ {
print $object->showOptionals($extrafields, 'edit'); print $object->showOptionals($extrafields, 'edit');
@ -279,27 +279,27 @@ if ($action == 'create' || $object->fetch($id, $ref) > 0)
$formconfirm = ''; $formconfirm = '';
// Confirm deleting resource line // Confirm deleting resource line
if ($action == 'delete') if ($action == 'delete')
{ {
$formconfirm = $form->formconfirm("card.php?&id=".$object->id, $langs->trans("DeleteResource"), $langs->trans("ConfirmDeleteResource"), "confirm_delete_resource", '', '', 1); $formconfirm = $form->formconfirm("card.php?&id=".$object->id, $langs->trans("DeleteResource"), $langs->trans("ConfirmDeleteResource"), "confirm_delete_resource", '', '', 1);
} }
// Print form confirm // Print form confirm
print $formconfirm; print $formconfirm;
$linkback = '<a href="'.DOL_URL_ROOT.'/resource/list.php?restore_lastsearch_values=1'.(!empty($socid) ? '&id='.$socid : '').'">'.$langs->trans("BackToList").'</a>'; $linkback = '<a href="'.DOL_URL_ROOT.'/resource/list.php?restore_lastsearch_values=1'.(!empty($socid) ? '&id='.$socid : '').'">'.$langs->trans("BackToList").'</a>';
$morehtmlref = '<div class="refidno">'; $morehtmlref = '<div class="refidno">';
$morehtmlref .= '</div>'; $morehtmlref .= '</div>';
dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
print '<div class="fichecenter">'; print '<div class="fichecenter">';
print '<div class="underbanner clearboth"></div>'; print '<div class="underbanner clearboth"></div>';
/*--------------------------------------- /*---------------------------------------
* View object * View object
@ -365,13 +365,13 @@ if ($action == 'create' || $object->fetch($id, $ref) > 0)
} }
if ($action != "delete" && $action != "create" && $action != "edit") if ($action != "delete" && $action != "create" && $action != "edit")
{ {
// Delete resource // Delete resource
if ($user->rights->resource->delete) if ($user->rights->resource->delete)
{ {
print '<div class="inline-block divButAction">'; print '<div class="inline-block divButAction">';
print '<a href="'.$_SERVER['PHP_SELF'].'?id='.$id.'&amp;action=delete&amp;token='.newToken().'" class="butActionDelete">'.$langs->trans('Delete').'</a>'; print '<a href="'.$_SERVER['PHP_SELF'].'?id='.$id.'&amp;action=delete&amp;token='.newToken().'" class="butActionDelete">'.$langs->trans('Delete').'</a>';
print '</div>'; print '</div>';
} }
} }
} }
print '</div>'; print '</div>';

View File

@ -108,7 +108,7 @@ $pageprev = $page - 1;
$pagenext = $page + 1; $pagenext = $page + 1;
if (!$user->rights->resource->read) { if (!$user->rights->resource->read) {
accessforbidden(); accessforbidden();
} }
$arrayfields = array( $arrayfields = array(
't.ref' => array( 't.ref' => array(
@ -201,8 +201,8 @@ if ($ret == -1) {
$newcardbutton = ''; $newcardbutton = '';
if ($user->rights->resource->write) if ($user->rights->resource->write)
{ {
$newcardbutton .= dolGetButtonTitle($langs->trans('MenuResourceAdd'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/resource/card.php?action=create'); $newcardbutton .= dolGetButtonTitle($langs->trans('MenuResourceAdd'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/resource/card.php?action=create');
} }
print_barre_liste($pagetitle, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $ret + 1, $nbtotalofrecords, 'object_resource', 0, $newcardbutton, '', $limit, 0, 0, 1); print_barre_liste($pagetitle, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $ret + 1, $nbtotalofrecords, 'object_resource', 0, $newcardbutton, '', $limit, 0, 0, 1);
} }
@ -246,45 +246,45 @@ print "</tr>\n";
if ($ret) if ($ret)
{ {
foreach ($object->lines as $resource) foreach ($object->lines as $resource)
{ {
print '<tr class="oddeven">'; print '<tr class="oddeven">';
if (!empty($arrayfields['t.ref']['checked'])) if (!empty($arrayfields['t.ref']['checked']))
{ {
print '<td>'; print '<td>';
print $resource->getNomUrl(5); print $resource->getNomUrl(5);
print '</td>'; print '</td>';
if (!$i) $totalarray['nbfield']++; if (!$i) $totalarray['nbfield']++;
} }
if (!empty($arrayfields['ty.label']['checked'])) if (!empty($arrayfields['ty.label']['checked']))
{ {
print '<td>'; print '<td>';
print $resource->type_label; print $resource->type_label;
print '</td>'; print '</td>';
if (!$i) $totalarray['nbfield']++; if (!$i) $totalarray['nbfield']++;
} }
// Extra fields // Extra fields
$obj = (Object) $resource->array_options; $obj = (Object) $resource->array_options;
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
print '<td class="center">'; print '<td class="center">';
print '<a class="editfielda" href="./card.php?action=edit&token='.newToken().'&id='.$resource->id.'">'; print '<a class="editfielda" href="./card.php?action=edit&token='.newToken().'&id='.$resource->id.'">';
print img_edit(); print img_edit();
print '</a>'; print '</a>';
print '&nbsp;'; print '&nbsp;';
print '<a href="./card.php?action=delete&token='.newToken().'&id='.$resource->id.'">'; print '<a href="./card.php?action=delete&token='.newToken().'&id='.$resource->id.'">';
print img_delete('', 'class="marginleftonly"'); print img_delete('', 'class="marginleftonly"');
print '</a>'; print '</a>';
print '</td>'; print '</td>';
if (!$i) $totalarray['nbfield']++; if (!$i) $totalarray['nbfield']++;
print '</tr>'; print '</tr>';
} }
} else { } else {
$colspan = 1; $colspan = 1;
foreach ($arrayfields as $key => $val) { if (!empty($val['checked'])) $colspan++; } foreach ($arrayfields as $key => $val) { if (!empty($val['checked'])) $colspan++; }
print '<tr><td colspan="'.$colspan.'" class="opacitymedium">'.$langs->trans("NoRecordFound").'</td></tr>'; print '<tr><td colspan="'.$colspan.'" class="opacitymedium">'.$langs->trans("NoRecordFound").'</td></tr>';
} }
print '</table>'; print '</table>';

File diff suppressed because it is too large Load Diff

View File

@ -72,57 +72,57 @@ if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'e
if (empty($reshook)) if (empty($reshook))
{ {
$error = 0; $error = 0;
// Add a notification // Add a notification
if ($action == 'add') if ($action == 'add')
{ {
if (empty($contactid)) if (empty($contactid))
{ {
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Contact")), null, 'errors'); setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Contact")), null, 'errors');
$error++; $error++;
} }
if ($actionid <= 0) if ($actionid <= 0)
{ {
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Action")), null, 'errors'); setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Action")), null, 'errors');
$error++; $error++;
} }
if (!$error) if (!$error)
{ {
$db->begin(); $db->begin();
$sql = "DELETE FROM ".MAIN_DB_PREFIX."notify_def"; $sql = "DELETE FROM ".MAIN_DB_PREFIX."notify_def";
$sql .= " WHERE fk_soc=".$socid." AND fk_contact=".$contactid." AND fk_action=".$actionid; $sql .= " WHERE fk_soc=".$socid." AND fk_contact=".$contactid." AND fk_action=".$actionid;
if ($db->query($sql)) if ($db->query($sql))
{ {
$sql = "INSERT INTO ".MAIN_DB_PREFIX."notify_def (datec,fk_soc, fk_contact, fk_action)"; $sql = "INSERT INTO ".MAIN_DB_PREFIX."notify_def (datec,fk_soc, fk_contact, fk_action)";
$sql .= " VALUES ('".$db->idate($now)."',".$socid.",".$contactid.",".$actionid.")"; $sql .= " VALUES ('".$db->idate($now)."',".$socid.",".$contactid.",".$actionid.")";
if (!$db->query($sql)) if (!$db->query($sql))
{ {
$error++; $error++;
dol_print_error($db); dol_print_error($db);
} }
} else { } else {
dol_print_error($db); dol_print_error($db);
} }
if (!$error) if (!$error)
{ {
$db->commit(); $db->commit();
} else { } else {
$db->rollback(); $db->rollback();
} }
} }
} }
// Remove a notification // Remove a notification
if ($action == 'delete') if ($action == 'delete')
{ {
$sql = "DELETE FROM ".MAIN_DB_PREFIX."notify_def where rowid=".GETPOST('actid', 'int'); $sql = "DELETE FROM ".MAIN_DB_PREFIX."notify_def where rowid=".GETPOST('actid', 'int');
$db->query($sql); $db->query($sql);
} }
} }
@ -144,46 +144,46 @@ llxHeader('', $title, $help_url);
if ($result > 0) if ($result > 0)
{ {
$langs->load("other"); $langs->load("other");
$head = societe_prepare_head($object); $head = societe_prepare_head($object);
dol_fiche_head($head, 'notify', $langs->trans("ThirdParty"), -1, 'company'); dol_fiche_head($head, 'notify', $langs->trans("ThirdParty"), -1, 'company');
$linkback = '<a href="'.DOL_URL_ROOT.'/societe/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>'; $linkback = '<a href="'.DOL_URL_ROOT.'/societe/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
dol_banner_tab($object, 'socid', $linkback, ($user->socid ? 0 : 1), 'rowid', 'nom'); dol_banner_tab($object, 'socid', $linkback, ($user->socid ? 0 : 1), 'rowid', 'nom');
print '<div class="fichecenter">'; print '<div class="fichecenter">';
print '<div class="underbanner clearboth"></div>'; print '<div class="underbanner clearboth"></div>';
print '<table class="border centpercent">'; print '<table class="border centpercent">';
// Prefix // Prefix
if (!empty($conf->global->SOCIETE_USEPREFIX)) // Old not used prefix field if (!empty($conf->global->SOCIETE_USEPREFIX)) // Old not used prefix field
{ {
print '<tr><td class="titlefield">'.$langs->trans('Prefix').'</td><td colspan="3">'.$object->prefix_comm.'</td></tr>'; print '<tr><td class="titlefield">'.$langs->trans('Prefix').'</td><td colspan="3">'.$object->prefix_comm.'</td></tr>';
} }
if ($object->client) if ($object->client)
{ {
print '<tr><td class="titlefield">'; print '<tr><td class="titlefield">';
print $langs->trans('CustomerCode').'</td><td colspan="3">'; print $langs->trans('CustomerCode').'</td><td colspan="3">';
print $object->code_client; print $object->code_client;
if ($object->check_codeclient() <> 0) print ' <font class="error">('.$langs->trans("WrongCustomerCode").')</font>'; if ($object->check_codeclient() <> 0) print ' <font class="error">('.$langs->trans("WrongCustomerCode").')</font>';
print '</td></tr>'; print '</td></tr>';
} }
if (!empty($conf->fournisseur->enabled) && $object->fournisseur && !empty($user->rights->fournisseur->lire)) if (!empty($conf->fournisseur->enabled) && $object->fournisseur && !empty($user->rights->fournisseur->lire))
{ {
print '<tr><td class="titlefield">'; print '<tr><td class="titlefield">';
print $langs->trans('SupplierCode').'</td><td colspan="3">'; print $langs->trans('SupplierCode').'</td><td colspan="3">';
print $object->code_fournisseur; print $object->code_fournisseur;
if ($object->check_codefournisseur() <> 0) print ' <font class="error">('.$langs->trans("WrongSupplierCode").')</font>'; if ($object->check_codefournisseur() <> 0) print ' <font class="error">('.$langs->trans("WrongSupplierCode").')</font>';
print '</td></tr>'; print '</td></tr>';
} }
/*print '<tr><td class="titlefield">'.$langs->trans("NbOfActiveNotifications").'</td>'; // Notification for this thirdparty /*print '<tr><td class="titlefield">'.$langs->trans("NbOfActiveNotifications").'</td>'; // Notification for this thirdparty
print '<td colspan="3">'; print '<td colspan="3">';
$nbofrecipientemails=0; $nbofrecipientemails=0;
$notify=new Notify($db); $notify=new Notify($db);
@ -195,159 +195,159 @@ if ($result > 0)
print $nbofrecipientemails; print $nbofrecipientemails;
print '</td></tr>';*/ print '</td></tr>';*/
print '</table>'; print '</table>';
print '</div>';
dol_fiche_end();
print "\n";
// Help
print '<div class="opacitymedium">';
print $langs->trans("NotificationsDesc");
print '<br>'.$langs->trans("NotificationsDescUser");
print '<br>'.$langs->trans("NotificationsDescContact");
print '<br>'.$langs->trans("NotificationsDescGlobal");
print '</div>'; print '</div>';
print '<br><br>'."\n"; dol_fiche_end();
print "\n";
// Help
print '<div class="opacitymedium">';
print $langs->trans("NotificationsDesc");
print '<br>'.$langs->trans("NotificationsDescUser");
print '<br>'.$langs->trans("NotificationsDescContact");
print '<br>'.$langs->trans("NotificationsDescGlobal");
print '</div>';
print '<br><br>'."\n";
// Add notification form // Add notification form
print load_fiche_titre($langs->trans("AddNewNotification"), '', ''); print load_fiche_titre($langs->trans("AddNewNotification"), '', '');
print '<form action="'.$_SERVER["PHP_SELF"].'?socid='.$socid.'" method="post">'; print '<form action="'.$_SERVER["PHP_SELF"].'?socid='.$socid.'" method="post">';
print '<input type="hidden" name="token" value="'.newToken().'">'; print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="action" value="add">'; print '<input type="hidden" name="action" value="add">';
$param = "&socid=".$socid; $param = "&socid=".$socid;
// Line with titles // Line with titles
print '<table width="100%" class="noborder">'; print '<table width="100%" class="noborder">';
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print_liste_field_titre("Target", $_SERVER["PHP_SELF"], "c.lastname,c.firstname", '', $param, '"width="45%"', $sortfield, $sortorder); print_liste_field_titre("Target", $_SERVER["PHP_SELF"], "c.lastname,c.firstname", '', $param, '"width="45%"', $sortfield, $sortorder);
print_liste_field_titre("Action", $_SERVER["PHP_SELF"], "", '', $param, '"width="35%"', $sortfield, $sortorder); print_liste_field_titre("Action", $_SERVER["PHP_SELF"], "", '', $param, '"width="35%"', $sortfield, $sortorder);
print_liste_field_titre("Type", $_SERVER["PHP_SELF"], "n.type", '', $param, '"width="10%"', $sortfield, $sortorder); print_liste_field_titre("Type", $_SERVER["PHP_SELF"], "n.type", '', $param, '"width="10%"', $sortfield, $sortorder);
print_liste_field_titre(''); print_liste_field_titre('');
print "</tr>\n"; print "</tr>\n";
$var = false; $var = false;
$listofemails = $object->thirdparty_and_contact_email_array(); $listofemails = $object->thirdparty_and_contact_email_array();
if (count($listofemails) > 0) if (count($listofemails) > 0)
{ {
$actions = array(); $actions = array();
// Load array of available notifications // Load array of available notifications
$notificationtrigger = new InterfaceNotification($db); $notificationtrigger = new InterfaceNotification($db);
$listofmanagedeventfornotification = $notificationtrigger->getListOfManagedEvents(); $listofmanagedeventfornotification = $notificationtrigger->getListOfManagedEvents();
foreach ($listofmanagedeventfornotification as $managedeventfornotification) foreach ($listofmanagedeventfornotification as $managedeventfornotification)
{ {
$label = ($langs->trans("Notify_".$managedeventfornotification['code']) != "Notify_".$managedeventfornotification['code'] ? $langs->trans("Notify_".$managedeventfornotification['code']) : $managedeventfornotification['label']); $label = ($langs->trans("Notify_".$managedeventfornotification['code']) != "Notify_".$managedeventfornotification['code'] ? $langs->trans("Notify_".$managedeventfornotification['code']) : $managedeventfornotification['label']);
$actions[$managedeventfornotification['rowid']] = $label; $actions[$managedeventfornotification['rowid']] = $label;
} }
print '<tr class="oddeven nohover"><td class="maxwidthonsmartphone">'; print '<tr class="oddeven nohover"><td class="maxwidthonsmartphone">';
print img_picto('', 'contact', '', false, 0, 0, '', 'paddingright').$form->selectarray("contactid", $listofemails, '', 0, 0, 0, '', 0, 0, 0, '', 'maxwidthonsmartphone'); print img_picto('', 'contact', '', false, 0, 0, '', 'paddingright').$form->selectarray("contactid", $listofemails, '', 0, 0, 0, '', 0, 0, 0, '', 'maxwidthonsmartphone');
print '</td>'; print '</td>';
print '<td class="maxwidthonsmartphone">'; print '<td class="maxwidthonsmartphone">';
print img_picto('', 'object_action', '', false, 0, 0, '', 'paddingright').$form->selectarray("actionid", $actions, '', 1, 0, 0, '', 0, 0, 0, '', 'maxwidthonsmartphone'); print img_picto('', 'object_action', '', false, 0, 0, '', 'paddingright').$form->selectarray("actionid", $actions, '', 1, 0, 0, '', 0, 0, 0, '', 'maxwidthonsmartphone');
print '</td>'; print '</td>';
print '<td>'; print '<td>';
$type = array('email'=>$langs->trans("EMail")); $type = array('email'=>$langs->trans("EMail"));
print $form->selectarray("typeid", $type); print $form->selectarray("typeid", $type);
print '</td>'; print '</td>';
print '<td class="right"><input type="submit" class="button" value="'.$langs->trans("Add").'"></td>'; print '<td class="right"><input type="submit" class="button" value="'.$langs->trans("Add").'"></td>';
print '</tr>'; print '</tr>';
} else { } else {
print '<tr class="oddeven"><td colspan="4" class="opacitymedium">'; print '<tr class="oddeven"><td colspan="4" class="opacitymedium">';
print $langs->trans("YouMustCreateContactFirst"); print $langs->trans("YouMustCreateContactFirst");
print '</td></tr>'; print '</td></tr>';
} }
print '</table>'; print '</table>';
print '</form>'; print '</form>';
print '<br>'; print '<br>';
// List of notifications enabled for contacts // List of notifications enabled for contacts
$sql = "SELECT n.rowid, n.type,"; $sql = "SELECT n.rowid, n.type,";
$sql .= " a.code, a.label,"; $sql .= " a.code, a.label,";
$sql .= " c.rowid as contactid, c.lastname, c.firstname, c.email"; $sql .= " c.rowid as contactid, c.lastname, c.firstname, c.email";
$sql .= " FROM ".MAIN_DB_PREFIX."c_action_trigger as a,"; $sql .= " FROM ".MAIN_DB_PREFIX."c_action_trigger as a,";
$sql .= " ".MAIN_DB_PREFIX."notify_def as n,"; $sql .= " ".MAIN_DB_PREFIX."notify_def as n,";
$sql .= " ".MAIN_DB_PREFIX."socpeople c"; $sql .= " ".MAIN_DB_PREFIX."socpeople c";
$sql .= " WHERE a.rowid = n.fk_action"; $sql .= " WHERE a.rowid = n.fk_action";
$sql .= " AND c.rowid = n.fk_contact"; $sql .= " AND c.rowid = n.fk_contact";
$sql .= " AND c.fk_soc = ".$object->id; $sql .= " AND c.fk_soc = ".$object->id;
$resql = $db->query($sql); $resql = $db->query($sql);
if ($resql) if ($resql)
{ {
$num = $db->num_rows($resql); $num = $db->num_rows($resql);
} else { } else {
dol_print_error($db); dol_print_error($db);
} }
// List of active notifications // List of active notifications
print load_fiche_titre($langs->trans("ListOfActiveNotifications").' ('.$num.')', '', ''); print load_fiche_titre($langs->trans("ListOfActiveNotifications").' ('.$num.')', '', '');
// Line with titles // Line with titles
print '<table width="100%" class="noborder">'; print '<table width="100%" class="noborder">';
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print_liste_field_titre("Target", $_SERVER["PHP_SELF"], "c.lastname,c.firstname", '', $param, '"width="45%"', $sortfield, $sortorder); print_liste_field_titre("Target", $_SERVER["PHP_SELF"], "c.lastname,c.firstname", '', $param, '"width="45%"', $sortfield, $sortorder);
print_liste_field_titre("Action", $_SERVER["PHP_SELF"], "", '', $param, '"width="35%"', $sortfield, $sortorder); print_liste_field_titre("Action", $_SERVER["PHP_SELF"], "", '', $param, '"width="35%"', $sortfield, $sortorder);
print_liste_field_titre("Type", $_SERVER["PHP_SELF"], "n.type", '', $param, '"width="10%"', $sortfield, $sortorder); print_liste_field_titre("Type", $_SERVER["PHP_SELF"], "n.type", '', $param, '"width="10%"', $sortfield, $sortorder);
print_liste_field_titre('', '', ''); print_liste_field_titre('', '', '');
print '</tr>'; print '</tr>';
$langs->load("errors"); $langs->load("errors");
$langs->load("other"); $langs->load("other");
if ($num) if ($num)
{ {
$i = 0; $i = 0;
$contactstatic = new Contact($db); $contactstatic = new Contact($db);
while ($i < $num) while ($i < $num)
{ {
$obj = $db->fetch_object($resql); $obj = $db->fetch_object($resql);
$contactstatic->id = $obj->contact_id; $contactstatic->id = $obj->contact_id;
$contactstatic->lastname = $obj->lastname; $contactstatic->lastname = $obj->lastname;
$contactstatic->firstname = $obj->firstname; $contactstatic->firstname = $obj->firstname;
print '<tr class="oddeven"><td>'.$contactstatic->getNomUrl(1); print '<tr class="oddeven"><td>'.$contactstatic->getNomUrl(1);
if ($obj->type == 'email') if ($obj->type == 'email')
{ {
if (isValidEmail($obj->email)) if (isValidEmail($obj->email))
{ {
print ' &lt;'.$obj->email.'&gt;'; print ' &lt;'.$obj->email.'&gt;';
} else { } else {
$langs->load("errors"); $langs->load("errors");
print ' &nbsp; '.img_warning().' '.$langs->trans("ErrorBadEMail", $obj->email); print ' &nbsp; '.img_warning().' '.$langs->trans("ErrorBadEMail", $obj->email);
} }
} }
print '</td>'; print '</td>';
print '<td>'; print '<td>';
$label = ($langs->trans("Notify_".$obj->code) != "Notify_".$obj->code ? $langs->trans("Notify_".$obj->code) : $obj->label); $label = ($langs->trans("Notify_".$obj->code) != "Notify_".$obj->code ? $langs->trans("Notify_".$obj->code) : $obj->label);
print img_picto('', 'object_action', '', false, 0, 0, '', 'paddingright').$label; print img_picto('', 'object_action', '', false, 0, 0, '', 'paddingright').$label;
print '</td>'; print '</td>';
print '<td>'; print '<td>';
if ($obj->type == 'email') print $langs->trans("Email"); if ($obj->type == 'email') print $langs->trans("Email");
if ($obj->type == 'sms') print $langs->trans("SMS"); if ($obj->type == 'sms') print $langs->trans("SMS");
print '</td>'; print '</td>';
print '<td class="right"><a href="card.php?socid='.$socid.'&action=delete&token='.newToken().'&actid='.$obj->rowid.'">'.img_delete().'</a></td>'; print '<td class="right"><a href="card.php?socid='.$socid.'&action=delete&token='.newToken().'&actid='.$obj->rowid.'">'.img_delete().'</a></td>';
print '</tr>'; print '</tr>';
$i++; $i++;
} }
$db->free($resql); $db->free($resql);
} }
// List of notifications enabled for fixed email // List of notifications enabled for fixed email
/* /*
foreach($conf->global as $key => $val) foreach($conf->global as $key => $val)
{ {
if (! preg_match('/^NOTIFICATION_FIXEDEMAIL_(.*)/', $key, $reg)) continue; if (! preg_match('/^NOTIFICATION_FIXEDEMAIL_(.*)/', $key, $reg)) continue;
@ -389,7 +389,7 @@ if ($result > 0)
print '</tr>'; print '</tr>';
}*/ }*/
/*if ($user->admin) /*if ($user->admin)
{ {
$var = ! $var; $var = ! $var;
print '<tr class="oddeven"><td colspan="4">'; print '<tr class="oddeven"><td colspan="4">';
@ -397,104 +397,104 @@ if ($result > 0)
print '</td></tr>'; print '</td></tr>';
}*/ }*/
print '</table>'; print '</table>';
print '<br><br>'."\n"; print '<br><br>'."\n";
// List // List
$sql = "SELECT n.rowid, n.daten, n.email, n.objet_type as object_type, n.objet_id as object_id, n.type,"; $sql = "SELECT n.rowid, n.daten, n.email, n.objet_type as object_type, n.objet_id as object_id, n.type,";
$sql .= " c.rowid as id, c.lastname, c.firstname, c.email as contactemail,"; $sql .= " c.rowid as id, c.lastname, c.firstname, c.email as contactemail,";
$sql .= " a.code, a.label"; $sql .= " a.code, a.label";
$sql .= " FROM ".MAIN_DB_PREFIX."c_action_trigger as a,"; $sql .= " FROM ".MAIN_DB_PREFIX."c_action_trigger as a,";
$sql .= " ".MAIN_DB_PREFIX."notify as n "; $sql .= " ".MAIN_DB_PREFIX."notify as n ";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."socpeople as c ON n.fk_contact = c.rowid"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."socpeople as c ON n.fk_contact = c.rowid";
$sql .= " WHERE a.rowid = n.fk_action"; $sql .= " WHERE a.rowid = n.fk_action";
$sql .= " AND n.fk_soc = ".$object->id; $sql .= " AND n.fk_soc = ".$object->id;
$sql .= $db->order($sortfield, $sortorder); $sql .= $db->order($sortfield, $sortorder);
// Count total nb of records // Count total nb of records
$nbtotalofrecords = ''; $nbtotalofrecords = '';
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
{ {
$result = $db->query($sql); $result = $db->query($sql);
$nbtotalofrecords = $db->num_rows($result); $nbtotalofrecords = $db->num_rows($result);
if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0
{ {
$page = 0; $page = 0;
$offset = 0; $offset = 0;
} }
} }
$sql .= $db->plimit($limit + 1, $offset); $sql .= $db->plimit($limit + 1, $offset);
$resql = $db->query($sql); $resql = $db->query($sql);
if ($resql) if ($resql)
{ {
$num = $db->num_rows($resql); $num = $db->num_rows($resql);
} else { } else {
dol_print_error($db); dol_print_error($db);
} }
$param = '&socid='.$object->id; $param = '&socid='.$object->id;
if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.$contextpage; if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.$contextpage;
if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.$limit; if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.$limit;
print '<form method="post" action="'.$_SERVER["PHP_SELF"].'" name="formfilter">'; print '<form method="post" action="'.$_SERVER["PHP_SELF"].'" name="formfilter">';
if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">'; if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
print '<input type="hidden" name="token" value="'.newToken().'">'; print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">'; print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
print '<input type="hidden" name="sortfield" value="'.$sortfield.'">'; print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
print '<input type="hidden" name="sortorder" value="'.$sortorder.'">'; print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
print '<input type="hidden" name="page" value="'.$page.'">'; print '<input type="hidden" name="page" value="'.$page.'">';
print '<input type="hidden" name="socid" value="'.$object->id.'">'; print '<input type="hidden" name="socid" value="'.$object->id.'">';
// List of active notifications // List of active notifications
print_barre_liste($langs->trans("ListOfNotificationsDone"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, '', 0, '', '', $limit); print_barre_liste($langs->trans("ListOfNotificationsDone"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, '', 0, '', '', $limit);
// Line with titles // Line with titles
print '<table width="100%" class="noborder">'; print '<table width="100%" class="noborder">';
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print_liste_field_titre("Target", $_SERVER["PHP_SELF"], "c.lastname,c.firstname", '', $param, '', $sortfield, $sortorder); print_liste_field_titre("Target", $_SERVER["PHP_SELF"], "c.lastname,c.firstname", '', $param, '', $sortfield, $sortorder);
print_liste_field_titre("Action", $_SERVER["PHP_SELF"], "", '', $param, '', $sortfield, $sortorder); print_liste_field_titre("Action", $_SERVER["PHP_SELF"], "", '', $param, '', $sortfield, $sortorder);
print_liste_field_titre("Type", $_SERVER["PHP_SELF"], "n.type", '', $param, '', $sortfield, $sortorder); print_liste_field_titre("Type", $_SERVER["PHP_SELF"], "n.type", '', $param, '', $sortfield, $sortorder);
//print_liste_field_titre("Object",$_SERVER["PHP_SELF"],"",'',$param,'"',$sortfield,$sortorder); //print_liste_field_titre("Object",$_SERVER["PHP_SELF"],"",'',$param,'"',$sortfield,$sortorder);
print_liste_field_titre("Date", $_SERVER["PHP_SELF"], "n.daten", '', $param, '', $sortfield, $sortorder, 'right '); print_liste_field_titre("Date", $_SERVER["PHP_SELF"], "n.daten", '', $param, '', $sortfield, $sortorder, 'right ');
print '</tr>'; print '</tr>';
if ($num > 0) if ($num > 0)
{ {
$i = 0; $i = 0;
$contactstatic = new Contact($db); $contactstatic = new Contact($db);
while ($i < $num) while ($i < $num)
{ {
$obj = $db->fetch_object($resql); $obj = $db->fetch_object($resql);
print '<tr class="oddeven"><td>'; print '<tr class="oddeven"><td>';
if ($obj->id > 0) if ($obj->id > 0)
{ {
$contactstatic->id = $obj->id; $contactstatic->id = $obj->id;
$contactstatic->lastname = $obj->lastname; $contactstatic->lastname = $obj->lastname;
$contactstatic->firstname = $obj->firstname; $contactstatic->firstname = $obj->firstname;
print $contactstatic->getNomUrl(1); print $contactstatic->getNomUrl(1);
print $obj->email ? ' &lt;'.$obj->email.'&gt;' : $langs->trans("NoMail"); print $obj->email ? ' &lt;'.$obj->email.'&gt;' : $langs->trans("NoMail");
} else { } else {
print $obj->email; print $obj->email;
} }
print '</td>'; print '</td>';
print '<td>'; print '<td>';
$label = ($langs->trans("Notify_".$obj->code) != "Notify_".$obj->code ? $langs->trans("Notify_".$obj->code) : $obj->label); $label = ($langs->trans("Notify_".$obj->code) != "Notify_".$obj->code ? $langs->trans("Notify_".$obj->code) : $obj->label);
print $label; print $label;
print '</td>'; print '</td>';
print '<td>'; print '<td>';
if ($obj->type == 'email') print $langs->trans("Email"); if ($obj->type == 'email') print $langs->trans("Email");
if ($obj->type == 'sms') print $langs->trans("Sms"); if ($obj->type == 'sms') print $langs->trans("Sms");
print '</td>'; print '</td>';
// TODO Add link to object here for other types // TODO Add link to object here for other types
/*print '<td>'; /*print '<td>';
if ($obj->object_type == 'order') if ($obj->object_type == 'order')
{ {
$orderstatic->id=$obj->object_id; $orderstatic->id=$obj->object_id;
@ -502,19 +502,19 @@ if ($result > 0)
print $orderstatic->getNomUrl(1); print $orderstatic->getNomUrl(1);
} }
print '</td>';*/ print '</td>';*/
// print // print
print'<td class="right">'.dol_print_date($db->jdate($obj->daten), 'dayhour').'</td>'; print'<td class="right">'.dol_print_date($db->jdate($obj->daten), 'dayhour').'</td>';
print '</tr>'; print '</tr>';
$i++; $i++;
} }
$db->free($resql); $db->free($resql);
} else { } else {
print '<tr><td colspan="4"><span class="opacitymedium">'.$langs->trans("None").'</span></td></tr>'; print '<tr><td colspan="4"><span class="opacitymedium">'.$langs->trans("None").'</span></td></tr>';
} }
print '</table>'; print '</table>';
print '</form>'; print '</form>';
} else dol_print_error('', 'RecordNotFound'); } else dol_print_error('', 'RecordNotFound');
// End of page // End of page

View File

@ -550,12 +550,12 @@ if (empty($reshook))
$db->begin(); $db->begin();
if (empty($newcu)) { if (empty($newcu)) {
$sql = "DELETE FROM ".MAIN_DB_PREFIX."societe_account WHERE site = 'stripe' AND (site_account IS NULL or site_account = '' or site_account = '".$db->escape($site_account)."') AND fk_soc = ".$object->id." AND status = ".$servicestatus." AND entity = ".$conf->entity; $sql = "DELETE FROM ".MAIN_DB_PREFIX."societe_account WHERE site = 'stripe' AND (site_account IS NULL or site_account = '' or site_account = '".$db->escape($site_account)."') AND fk_soc = ".$object->id." AND status = ".$servicestatus." AND entity = ".$conf->entity;
} else { } else {
$sql = 'SELECT rowid FROM '.MAIN_DB_PREFIX."societe_account"; $sql = 'SELECT rowid FROM '.MAIN_DB_PREFIX."societe_account";
$sql .= " WHERE site = 'stripe' AND (site_account IS NULL or site_account = '' or site_account = '".$db->escape($site_account)."') AND fk_soc = ".$object->id." AND status = ".$servicestatus." AND entity = ".$conf->entity; // Keep = here for entity. Only 1 record must be modified ! $sql .= " WHERE site = 'stripe' AND (site_account IS NULL or site_account = '' or site_account = '".$db->escape($site_account)."') AND fk_soc = ".$object->id." AND status = ".$servicestatus." AND entity = ".$conf->entity; // Keep = here for entity. Only 1 record must be modified !
} }
$resql = $db->query($sql); $resql = $db->query($sql);
$num = $db->num_rows($resql); // Note: $num is always 0 on an update and delete, it is defined for select only. $num = $db->num_rows($resql); // Note: $num is always 0 on an update and delete, it is defined for select only.
@ -601,21 +601,21 @@ if (empty($reshook))
$db->begin(); $db->begin();
if (empty($newsup)) { if (empty($newsup)) {
$sql = "DELETE FROM ".MAIN_DB_PREFIX."oauth_token WHERE fk_soc = ".$object->id." AND service = '".$db->escape($service)."' AND entity = ".$conf->entity; $sql = "DELETE FROM ".MAIN_DB_PREFIX."oauth_token WHERE fk_soc = ".$object->id." AND service = '".$db->escape($service)."' AND entity = ".$conf->entity;
// TODO Add site and site_account on oauth_token table // TODO Add site and site_account on oauth_token table
//$sql = "DELETE FROM ".MAIN_DB_PREFIX."oauth_token WHERE site = 'stripe' AND (site_account IS NULL or site_account = '".$db->escape($site_account)."') AND fk_soc = ".$object->id." AND service = '".$db->escape($service)."' AND entity = ".$conf->entity; //$sql = "DELETE FROM ".MAIN_DB_PREFIX."oauth_token WHERE site = 'stripe' AND (site_account IS NULL or site_account = '".$db->escape($site_account)."') AND fk_soc = ".$object->id." AND service = '".$db->escape($service)."' AND entity = ".$conf->entity;
} else { } else {
try { try {
$stripesup = \Stripe\Account::retrieve($db->escape(GETPOST('key_account_supplier', 'alpha'))); $stripesup = \Stripe\Account::retrieve($db->escape(GETPOST('key_account_supplier', 'alpha')));
$tokenstring['stripe_user_id'] = $stripesup->id; $tokenstring['stripe_user_id'] = $stripesup->id;
$tokenstring['type'] = $stripesup->type; $tokenstring['type'] = $stripesup->type;
$sql = "UPDATE ".MAIN_DB_PREFIX."oauth_token"; $sql = "UPDATE ".MAIN_DB_PREFIX."oauth_token";
$sql .= " SET tokenstring = '".dol_json_encode($tokenstring)."'"; $sql .= " SET tokenstring = '".dol_json_encode($tokenstring)."'";
$sql .= " WHERE site = 'stripe' AND (site_account IS NULL or site_account = '".$db->escape($site_account)."') AND fk_soc = ".$object->id." AND service = '".$db->escape($service)."' AND entity = ".$conf->entity; // Keep = here for entity. Only 1 record must be modified ! $sql .= " WHERE site = 'stripe' AND (site_account IS NULL or site_account = '".$db->escape($site_account)."') AND fk_soc = ".$object->id." AND service = '".$db->escape($service)."' AND entity = ".$conf->entity; // Keep = here for entity. Only 1 record must be modified !
// TODO Add site and site_account on oauth_token table // TODO Add site and site_account on oauth_token table
$sql .= " WHERE fk_soc = ".$object->id." AND service = '".$db->escape($service)."' AND entity = ".$conf->entity; // Keep = here for entity. Only 1 record must be modified ! $sql .= " WHERE fk_soc = ".$object->id." AND service = '".$db->escape($service)."' AND entity = ".$conf->entity; // Keep = here for entity. Only 1 record must be modified !
} catch (Exception $e) { } catch (Exception $e) {
$error++; $error++;
setEventMessages($e->getMessage(), null, 'errors'); setEventMessages($e->getMessage(), null, 'errors');
} }
@ -625,14 +625,14 @@ if (empty($reshook))
$num = $db->num_rows($resql); $num = $db->num_rows($resql);
if (empty($num) && !empty($newsup)) if (empty($num) && !empty($newsup))
{ {
try { try {
$stripesup = \Stripe\Account::retrieve($db->escape(GETPOST('key_account_supplier', 'alpha'))); $stripesup = \Stripe\Account::retrieve($db->escape(GETPOST('key_account_supplier', 'alpha')));
$tokenstring['stripe_user_id'] = $stripesup->id; $tokenstring['stripe_user_id'] = $stripesup->id;
$tokenstring['type'] = $stripesup->type; $tokenstring['type'] = $stripesup->type;
$sql = "INSERT INTO ".MAIN_DB_PREFIX."oauth_token (service, fk_soc, entity, tokenstring)"; $sql = "INSERT INTO ".MAIN_DB_PREFIX."oauth_token (service, fk_soc, entity, tokenstring)";
$sql .= " VALUES ('".$db->escape($service)."', ".$object->id.", ".$conf->entity.", '".dol_json_encode($tokenstring)."')"; $sql .= " VALUES ('".$db->escape($service)."', ".$object->id.", ".$conf->entity.", '".dol_json_encode($tokenstring)."')";
// TODO Add site and site_account on oauth_token table // TODO Add site and site_account on oauth_token table
} catch (Exception $e) { } catch (Exception $e) {
$error++; $error++;
setEventMessages($e->getMessage(), null, 'errors'); setEventMessages($e->getMessage(), null, 'errors');
} }
@ -686,22 +686,22 @@ if (empty($reshook))
try { try {
if (preg_match('/pm_/', $source)) if (preg_match('/pm_/', $source))
{ {
$payment_method = \Stripe\PaymentMethod::retrieve($source, array("stripe_account" => $stripeacc)); $payment_method = \Stripe\PaymentMethod::retrieve($source, array("stripe_account" => $stripeacc));
if ($payment_method) if ($payment_method)
{ {
$payment_method->detach(); $payment_method->detach();
} }
} else { } else {
$cu = $stripe->customerStripe($object, $stripeacc, $servicestatus); $cu = $stripe->customerStripe($object, $stripeacc, $servicestatus);
$card = $cu->sources->retrieve("$source"); $card = $cu->sources->retrieve("$source");
if ($card) { if ($card) {
// $card->detach(); Does not work with card_, only with src_ // $card->detach(); Does not work with card_, only with src_
if (method_exists($card, 'detach')) { if (method_exists($card, 'detach')) {
$card->detach(); $card->detach();
} else { } else {
$card->delete(); $card->delete();
} }
} }
} }
$url = DOL_URL_ROOT.'/societe/paymentmodes.php?socid='.$object->id; $url = DOL_URL_ROOT.'/societe/paymentmodes.php?socid='.$object->id;
@ -832,7 +832,7 @@ if ($socid && $action != 'edit' && $action != 'create' && $action != 'editcard'
print $form->editfieldval("StripeCustomerId", 'key_account', $stripecu, $object, $permissiontowrite, 'string', '', null, null, '', 2, '', 'socid'); print $form->editfieldval("StripeCustomerId", 'key_account', $stripecu, $object, $permissiontowrite, 'string', '', null, null, '', 2, '', 'socid');
if (!empty($conf->stripe->enabled) && $stripecu && $action != 'editkey_account') if (!empty($conf->stripe->enabled) && $stripecu && $action != 'editkey_account')
{ {
$connect = ''; $connect = '';
if (!empty($stripeacc)) $connect = $stripeacc.'/'; if (!empty($stripeacc)) $connect = $stripeacc.'/';
$url = 'https://dashboard.stripe.com/'.$connect.'test/customers/'.$stripecu; $url = 'https://dashboard.stripe.com/'.$connect.'test/customers/'.$stripecu;
if ($servicestatus) if ($servicestatus)
@ -853,7 +853,7 @@ if ($socid && $action != 'edit' && $action != 'create' && $action != 'editcard'
} }
print '</td></tr>'; print '</td></tr>';
} }
} }
if ($object->fournisseur) if ($object->fournisseur)
{ {
@ -886,7 +886,7 @@ if ($socid && $action != 'edit' && $action != 'create' && $action != 'editcard'
print $form->editfieldval("StripeConnectAccount", 'key_account_supplier', $stripesupplieracc, $object, $permissiontowrite, 'string', '', null, null, '', 2, '', 'socid'); print $form->editfieldval("StripeConnectAccount", 'key_account_supplier', $stripesupplieracc, $object, $permissiontowrite, 'string', '', null, null, '', 2, '', 'socid');
if (!empty($conf->stripe->enabled) && $stripesupplieracc && $action != 'editkey_account_supplier') if (!empty($conf->stripe->enabled) && $stripesupplieracc && $action != 'editkey_account_supplier')
{ {
$connect = ''; $connect = '';
$url = 'https://dashboard.stripe.com/test/connect/accounts/'.$stripesupplieracc; $url = 'https://dashboard.stripe.com/test/connect/accounts/'.$stripesupplieracc;
if ($servicestatus) if ($servicestatus)
@ -922,7 +922,7 @@ if ($socid && $action != 'edit' && $action != 'create' && $action != 'editcard'
$morehtmlright = ''; $morehtmlright = '';
if (!empty($conf->global->STRIPE_ALLOW_LOCAL_CARD)) if (!empty($conf->global->STRIPE_ALLOW_LOCAL_CARD))
{ {
$morehtmlright .= dolGetButtonTitle($langs->trans('Add'), '', 'fa fa-plus-circle', $_SERVER["PHP_SELF"].'?socid='.$object->id.'&amp;action=createcard'); $morehtmlright .= dolGetButtonTitle($langs->trans('Add'), '', 'fa fa-plus-circle', $_SERVER["PHP_SELF"].'?socid='.$object->id.'&amp;action=createcard');
} }
print load_fiche_titre($langs->trans('StripePaymentModes').($stripeacc ? ' (Stripe connection with StripeConnect account '.$stripeacc.')' : ' (Stripe connection with keys from Stripe module setup)'), $morehtmlright, 'stripe-s'); print load_fiche_titre($langs->trans('StripePaymentModes').($stripeacc ? ' (Stripe connection with StripeConnect account '.$stripeacc.')' : ' (Stripe connection with keys from Stripe module setup)'), $morehtmlright, 'stripe-s');
@ -1038,9 +1038,9 @@ if ($socid && $action != 'edit' && $action != 'create' && $action != 'editcard'
print $companypaymentmodetemp->stripe_card_ref; print $companypaymentmodetemp->stripe_card_ref;
if ($companypaymentmodetemp->stripe_card_ref) if ($companypaymentmodetemp->stripe_card_ref)
{ {
$connect = ''; $connect = '';
if (!empty($stripeacc)) $connect = $stripeacc.'/'; if (!empty($stripeacc)) $connect = $stripeacc.'/';
$url = 'https://dashboard.stripe.com/'.$connect.'test/search?query='.$companypaymentmodetemp->stripe_card_ref; $url = 'https://dashboard.stripe.com/'.$connect.'test/search?query='.$companypaymentmodetemp->stripe_card_ref;
if ($servicestatus) if ($servicestatus)
{ {
$url = 'https://dashboard.stripe.com/'.$connect.'search?query='.$companypaymentmodetemp->stripe_card_ref; $url = 'https://dashboard.stripe.com/'.$connect.'search?query='.$companypaymentmodetemp->stripe_card_ref;
@ -1138,8 +1138,8 @@ if ($socid && $action != 'edit' && $action != 'create' && $action != 'editcard'
$url = 'https://dashboard.stripe.com/'.$connect.'test/search?query='.$src->id; $url = 'https://dashboard.stripe.com/'.$connect.'test/search?query='.$src->id;
if ($servicestatus) if ($servicestatus)
{ {
//$url='https://dashboard.stripe.com/'.$connect.'sources/'.$src->id; //$url='https://dashboard.stripe.com/'.$connect.'sources/'.$src->id;
$url = 'https://dashboard.stripe.com/'.$connect.'search?query='.$src->id; $url = 'https://dashboard.stripe.com/'.$connect.'search?query='.$src->id;
} }
print " <a href='".$url."' target='_stripe'>".img_picto($langs->trans('ShowInStripe'), 'globe')."</a>"; print " <a href='".$url."' target='_stripe'>".img_picto($langs->trans('ShowInStripe'), 'globe')."</a>";
print '</td>'; print '</td>';
@ -1266,30 +1266,30 @@ if ($socid && $action != 'edit' && $action != 'create' && $action != 'editcard'
} }
print "</table>"; print "</table>";
print "</div>"; print "</div>";
print '<br>'; print '<br>';
} }
// List of Stripe payment modes // List of Stripe payment modes
if (!empty($conf->stripe->enabled) && !empty($conf->stripeconnect->enabled) && !empty($stripesupplieracc)) if (!empty($conf->stripe->enabled) && !empty($conf->stripeconnect->enabled) && !empty($stripesupplieracc))
{ {
print load_fiche_titre($langs->trans('StripeBalance').($stripesupplieracc ? ' (Stripe connection with StripeConnect account '.$stripesupplieracc.')' : ' (Stripe connection with keys from Stripe module setup)'), $morehtmlright, 'stripe-s'); print load_fiche_titre($langs->trans('StripeBalance').($stripesupplieracc ? ' (Stripe connection with StripeConnect account '.$stripesupplieracc.')' : ' (Stripe connection with keys from Stripe module setup)'), $morehtmlright, 'stripe-s');
$balance = \Stripe\Balance::retrieve(array("stripe_account" => $stripesupplieracc)); $balance = \Stripe\Balance::retrieve(array("stripe_account" => $stripesupplieracc));
print '<table class="liste centpercent">'."\n"; print '<table class="liste centpercent">'."\n";
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print '<td>'.$langs->trans('Currency').'</td>'; print '<td>'.$langs->trans('Currency').'</td>';
print '<td>'.$langs->trans('Available').'</td>'; print '<td>'.$langs->trans('Available').'</td>';
print '<td>'.$langs->trans('Pending').'</td>'; print '<td>'.$langs->trans('Pending').'</td>';
print '<td>'.$langs->trans('Total').'</td>'; print '<td>'.$langs->trans('Total').'</td>';
print '</tr>'; print '</tr>';
$currencybalance = array(); $currencybalance = array();
if (is_array($balance->available) && count($balance->available)) if (is_array($balance->available) && count($balance->available))
{ {
foreach ($balance->available as $cpt) foreach ($balance->available as $cpt)
{ {
$arrayzerounitcurrency = array('BIF', 'CLP', 'DJF', 'GNF', 'JPY', 'KMF', 'KRW', 'MGA', 'PYG', 'RWF', 'VND', 'VUV', 'XAF', 'XOF', 'XPF'); $arrayzerounitcurrency = array('BIF', 'CLP', 'DJF', 'GNF', 'JPY', 'KMF', 'KRW', 'MGA', 'PYG', 'RWF', 'VND', 'VUV', 'XAF', 'XOF', 'XPF');
if (!in_array($cpt->currency, $arrayzerounitcurrency)) { if (!in_array($cpt->currency, $arrayzerounitcurrency)) {
$currencybalance[$cpt->currency]['available'] = $cpt->amount / 100; $currencybalance[$cpt->currency]['available'] = $cpt->amount / 100;
} else { } else {
$currencybalance[$cpt->currency]['available'] = $cpt->amount; $currencybalance[$cpt->currency]['available'] = $cpt->amount;
} }
@ -1297,7 +1297,7 @@ if ($socid && $action != 'edit' && $action != 'create' && $action != 'editcard'
} }
} }
if (is_array($balance->pending) && count($balance->pending)) if (is_array($balance->pending) && count($balance->pending))
{ {
foreach ($balance->pending as $cpt) foreach ($balance->pending as $cpt)
{ {
@ -1308,7 +1308,7 @@ if ($socid && $action != 'edit' && $action != 'create' && $action != 'editcard'
$currencybalance[$cpt->currency]['pending'] = $currencybalance[$cpt->currency]['available'] + $cpt->amount; $currencybalance[$cpt->currency]['pending'] = $currencybalance[$cpt->currency]['available'] + $cpt->amount;
} }
} }
} }
if (is_array($currencybalance)) if (is_array($currencybalance))
{ {
@ -1318,13 +1318,13 @@ if ($socid && $action != 'edit' && $action != 'create' && $action != 'editcard'
} }
} }
print '</table>'; print '</table>';
print '<br>'; print '<br>';
} }
// List of bank accounts // List of bank accounts
$morehtmlright = dolGetButtonTitle($langs->trans('Add'), '', 'fa fa-plus-circle', $_SERVER["PHP_SELF"].'?socid='.$object->id.'&amp;action=create'); $morehtmlright = dolGetButtonTitle($langs->trans('Add'), '', 'fa fa-plus-circle', $_SERVER["PHP_SELF"].'?socid='.$object->id.'&amp;action=create');
print load_fiche_titre($langs->trans("BankAccounts"), $morehtmlright, 'bank'); print load_fiche_titre($langs->trans("BankAccounts"), $morehtmlright, 'bank');
@ -1371,11 +1371,11 @@ if ($socid && $action != 'edit' && $action != 'create' && $action != 'editcard'
} elseif ($val == 'BankAccountNumberKey') { } elseif ($val == 'BankAccountNumberKey') {
$string .= $rib->cle_rib.' '; $string .= $rib->cle_rib.' ';
} }
// Already output after // Already output after
// } elseif ($val == 'BIC') { // } elseif ($val == 'BIC') {
// $string .= $rib->bic.' '; // $string .= $rib->bic.' ';
// } elseif ($val == 'IBAN') { // } elseif ($val == 'IBAN') {
// $string .= $rib->iban.' ';*/ // $string .= $rib->iban.' ';*/
//} //}
} }
if (!empty($rib->label) && $rib->number) { if (!empty($rib->label) && $rib->number) {

View File

@ -71,112 +71,112 @@ if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'e
if (empty($reshook)) if (empty($reshook))
{ {
if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // Both test are required to be compatible with all browsers if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // Both test are required to be compatible with all browsers
{ {
$search_prod = $search_label = $search_price = $search_price_ttc = ''; $search_prod = $search_label = $search_price = $search_price_ttc = '';
} }
if ($action == 'add_customer_price_confirm' && !$cancel && ($user->rights->produit->creer || $user->rights->service->creer)) { if ($action == 'add_customer_price_confirm' && !$cancel && ($user->rights->produit->creer || $user->rights->service->creer)) {
if (! (GETPOST('prodid', 'int') > 0)) { if (! (GETPOST('prodid', 'int') > 0)) {
$error++; $error++;
setEventMessages($langs->trans("ErrorFieldRequired", $langs->trans("Product")), null, 'errors'); setEventMessages($langs->trans("ErrorFieldRequired", $langs->trans("Product")), null, 'errors');
$action = 'add_customer_price'; $action = 'add_customer_price';
} }
if (! $error) { if (! $error) {
$update_child_soc = GETPOST('updatechildprice'); $update_child_soc = GETPOST('updatechildprice');
// add price by customer // add price by customer
$prodcustprice->fk_soc = $socid; $prodcustprice->fk_soc = $socid;
$prodcustprice->fk_product = GETPOST('prodid', 'int'); $prodcustprice->fk_product = GETPOST('prodid', 'int');
$prodcustprice->price = price2num(GETPOST("price"), 'MU'); $prodcustprice->price = price2num(GETPOST("price"), 'MU');
$prodcustprice->price_min = price2num(GETPOST("price_min"), 'MU'); $prodcustprice->price_min = price2num(GETPOST("price_min"), 'MU');
$prodcustprice->price_base_type = GETPOST("price_base_type", 'alpha'); $prodcustprice->price_base_type = GETPOST("price_base_type", 'alpha');
$tva_tx_txt = GETPOST('tva_tx', 'alpha'); // tva_tx can be '8.5' or '8.5*' or '8.5 (XXX)' or '8.5* (XXX)' $tva_tx_txt = GETPOST('tva_tx', 'alpha'); // tva_tx can be '8.5' or '8.5*' or '8.5 (XXX)' or '8.5* (XXX)'
// We must define tva_tx, npr and local taxes // We must define tva_tx, npr and local taxes
$vatratecode = ''; $vatratecode = '';
$tva_tx = preg_replace('/[^0-9\.].*$/', '', $tva_tx_txt); // keep remove all after the numbers and dot $tva_tx = preg_replace('/[^0-9\.].*$/', '', $tva_tx_txt); // keep remove all after the numbers and dot
$npr = preg_match('/\*/', $tva_tx_txt) ? 1 : 0; $npr = preg_match('/\*/', $tva_tx_txt) ? 1 : 0;
$localtax1 = 0; $localtax2 = 0; $localtax1_type = '0'; $localtax2_type = '0'; $localtax1 = 0; $localtax2 = 0; $localtax1_type = '0'; $localtax2_type = '0';
// If value contains the unique code of vat line (new recommended method), we use it to find npr and local taxes // If value contains the unique code of vat line (new recommended method), we use it to find npr and local taxes
if (preg_match('/\((.*)\)/', $tva_tx_txt, $reg)) if (preg_match('/\((.*)\)/', $tva_tx_txt, $reg))
{ {
// We look into database using code (we can't use get_localtax() because it depends on buyer that is not known). Same in update price. // We look into database using code (we can't use get_localtax() because it depends on buyer that is not known). Same in update price.
$vatratecode = $reg[1]; $vatratecode = $reg[1];
// Get record from code // Get record from code
$sql = "SELECT t.rowid, t.code, t.recuperableonly, t.localtax1, t.localtax2, t.localtax1_type, t.localtax2_type"; $sql = "SELECT t.rowid, t.code, t.recuperableonly, t.localtax1, t.localtax2, t.localtax1_type, t.localtax2_type";
$sql .= " FROM ".MAIN_DB_PREFIX."c_tva as t, ".MAIN_DB_PREFIX."c_country as c"; $sql .= " FROM ".MAIN_DB_PREFIX."c_tva as t, ".MAIN_DB_PREFIX."c_country as c";
$sql .= " WHERE t.fk_pays = c.rowid AND c.code = '".$db->escape($mysoc->country_code)."'"; $sql .= " WHERE t.fk_pays = c.rowid AND c.code = '".$db->escape($mysoc->country_code)."'";
$sql .= " AND t.taux = ".((float) $tva_tx)." AND t.active = 1"; $sql .= " AND t.taux = ".((float) $tva_tx)." AND t.active = 1";
$sql .= " AND t.code ='".$db->escape($vatratecode)."'"; $sql .= " AND t.code ='".$db->escape($vatratecode)."'";
$resql = $db->query($sql); $resql = $db->query($sql);
if ($resql) if ($resql)
{ {
$obj = $db->fetch_object($resql); $obj = $db->fetch_object($resql);
$npr = $obj->recuperableonly; $npr = $obj->recuperableonly;
$localtax1 = $obj->localtax1; $localtax1 = $obj->localtax1;
$localtax2 = $obj->localtax2; $localtax2 = $obj->localtax2;
$localtax1_type = $obj->localtax1_type; $localtax1_type = $obj->localtax1_type;
$localtax2_type = $obj->localtax2_type; $localtax2_type = $obj->localtax2_type;
} }
} }
$prodcustprice->default_vat_code = $vatratecode; $prodcustprice->default_vat_code = $vatratecode;
$prodcustprice->tva_tx = $tva_tx; $prodcustprice->tva_tx = $tva_tx;
$prodcustprice->recuperableonly = $npr; $prodcustprice->recuperableonly = $npr;
$prodcustprice->localtax1_tx = $localtax1; $prodcustprice->localtax1_tx = $localtax1;
$prodcustprice->localtax2_tx = $localtax2; $prodcustprice->localtax2_tx = $localtax2;
$prodcustprice->localtax1_type = $localtax1_type; $prodcustprice->localtax1_type = $localtax1_type;
$prodcustprice->localtax2_type = $localtax2_type; $prodcustprice->localtax2_type = $localtax2_type;
$result = $prodcustprice->create($user, 0, $update_child_soc); $result = $prodcustprice->create($user, 0, $update_child_soc);
if ($result < 0) { if ($result < 0) {
setEventMessages($prodcustprice->error, $prodcustprice->errors, 'errors'); setEventMessages($prodcustprice->error, $prodcustprice->errors, 'errors');
} else { } else {
setEventMessages($langs->trans('Save'), null, 'mesgs'); setEventMessages($langs->trans('Save'), null, 'mesgs');
} }
$action = ''; $action = '';
} }
} }
if ($action == 'delete_customer_price' && ($user->rights->produit->creer || $user->rights->service->creer)) { if ($action == 'delete_customer_price' && ($user->rights->produit->creer || $user->rights->service->creer)) {
// Delete price by customer // Delete price by customer
$prodcustprice->id = GETPOST('lineid'); $prodcustprice->id = GETPOST('lineid');
$result = $prodcustprice->delete($user); $result = $prodcustprice->delete($user);
if ($result < 0) { if ($result < 0) {
setEventMessages($prodcustprice->error, $prodcustprice->errors, 'mesgs'); setEventMessages($prodcustprice->error, $prodcustprice->errors, 'mesgs');
} else { } else {
setEventMessages($langs->trans('Delete'), null, 'errors'); setEventMessages($langs->trans('Delete'), null, 'errors');
} }
$action = ''; $action = '';
} }
if ($action == 'update_customer_price_confirm' && !$_POST ["cancel"] && ($user->rights->produit->creer || $user->rights->service->creer)) { if ($action == 'update_customer_price_confirm' && !$_POST ["cancel"] && ($user->rights->produit->creer || $user->rights->service->creer)) {
$prodcustprice->fetch(GETPOST('lineid', 'int')); $prodcustprice->fetch(GETPOST('lineid', 'int'));
$update_child_soc = GETPOST('updatechildprice'); $update_child_soc = GETPOST('updatechildprice');
// update price by customer // update price by customer
$prodcustprice->price = price2num(GETPOST("price"), 'MU'); $prodcustprice->price = price2num(GETPOST("price"), 'MU');
$prodcustprice->price_min = price2num(GETPOST("price_min"), 'MU'); $prodcustprice->price_min = price2num(GETPOST("price_min"), 'MU');
$prodcustprice->price_base_type = GETPOST("price_base_type", 'alpha'); $prodcustprice->price_base_type = GETPOST("price_base_type", 'alpha');
$prodcustprice->tva_tx = str_replace('*', '', GETPOST("tva_tx")); $prodcustprice->tva_tx = str_replace('*', '', GETPOST("tva_tx"));
$prodcustprice->recuperableonly = (preg_match('/\*/', GETPOST("tva_tx")) ? 1 : 0); $prodcustprice->recuperableonly = (preg_match('/\*/', GETPOST("tva_tx")) ? 1 : 0);
$result = $prodcustprice->update($user, 0, $update_child_soc); $result = $prodcustprice->update($user, 0, $update_child_soc);
if ($result < 0) { if ($result < 0) {
setEventMessages($prodcustprice->error, $prodcustprice->errors, 'errors'); setEventMessages($prodcustprice->error, $prodcustprice->errors, 'errors');
} else { } else {
setEventMessages($langs->trans('Save'), null, 'mesgs'); setEventMessages($langs->trans('Save'), null, 'mesgs');
} }
$action = ''; $action = '';
} }
} }
@ -242,7 +242,7 @@ if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) {
$sortfield = GETPOST("sortfield", 'alpha'); $sortfield = GETPOST("sortfield", 'alpha');
$sortorder = GETPOST("sortorder", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha');
$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
$offset = $limit * $page; $offset = $limit * $page;
@ -262,15 +262,15 @@ if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) {
$filter ['prod.ref'] = $search_prod; $filter ['prod.ref'] = $search_prod;
} }
if (! empty($search_label)) { if (!empty($search_label)) {
$filter ['prod.label'] = $search_label; $filter ['prod.label'] = $search_label;
} }
if (! empty($search_price)) { if (!empty($search_price)) {
$filter ['t.price'] = $search_price; $filter ['t.price'] = $search_price;
} }
if (! empty($search_price_ttc)) { if (!empty($search_price_ttc)) {
$filter ['t.price_ttc'] = $search_price_ttc; $filter ['t.price_ttc'] = $search_price_ttc;
} }
@ -429,7 +429,7 @@ if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) {
print '<br></form>'; print '<br></form>';
} elseif ($action == 'showlog_customer_price') { } elseif ($action == 'showlog_customer_price') {
print '<br>'; print '<br>';
print '<!-- showlog_customer_price -->'."\n"; print '<!-- showlog_customer_price -->'."\n";
$filter = array( $filter = array(
@ -503,7 +503,7 @@ if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) {
print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?socid='.$object->id.'">'.$langs->trans("Ok").'</a></div>'; print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?socid='.$object->id.'">'.$langs->trans("Ok").'</a></div>';
print "\n</div><br>\n"; print "\n</div><br>\n";
} else { } else {
// View mode // View mode
/* ************************************************************************** */ /* ************************************************************************** */
/* */ /* */
@ -519,118 +519,118 @@ if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) {
print "\n</div>\n"; print "\n</div>\n";
// Count total nb of records // Count total nb of records
$nbtotalofrecords = ''; $nbtotalofrecords = '';
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
{ {
$nbtotalofrecords = $prodcustprice->fetch_all('', '', 0, 0, $filter); $nbtotalofrecords = $prodcustprice->fetch_all('', '', 0, 0, $filter);
} }
$result = $prodcustprice->fetch_all($sortorder, $sortfield, $conf->liste_limit, $offset, $filter); $result = $prodcustprice->fetch_all($sortorder, $sortfield, $conf->liste_limit, $offset, $filter);
if ($result < 0) if ($result < 0)
{ {
setEventMessages($prodcustprice->error, $prodcustprice->errors, 'errors'); setEventMessages($prodcustprice->error, $prodcustprice->errors, 'errors');
} }
$option = '&search_prod=' . $search_prod . '&id=' . $object->id . '&label=' . $search_label .'&price=' . $search_price . '&price_ttc=' . $search_price_ttc; $option = '&search_prod=' . $search_prod . '&id=' . $object->id . '&label=' . $search_label .'&price=' . $search_price . '&price_ttc=' . $search_price_ttc;
print '<!-- view specific price for each product -->'."\n"; print '<!-- view specific price for each product -->'."\n";
print_barre_liste($langs->trans('PriceForEachProduct'), $page, $_SERVER['PHP_SELF'], $option, $sortfield, $sortorder, '', count($prodcustprice->lines), $nbtotalofrecords, ''); print_barre_liste($langs->trans('PriceForEachProduct'), $page, $_SERVER['PHP_SELF'], $option, $sortfield, $sortorder, '', count($prodcustprice->lines), $nbtotalofrecords, '');
print '<form action="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'" method="POST">'; print '<form action="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'" method="POST">';
print '<input type="hidden" name="token" value="'.newToken().'">'; print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="id" value="'.$object->id.'">'; print '<input type="hidden" name="id" value="'.$object->id.'">';
print '<table class="noborder centpercent">'; print '<table class="noborder centpercent">';
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print '<td>' . $langs->trans("Ref") . '</td>'; print '<td>' . $langs->trans("Ref") . '</td>';
print '<td>' . $langs->trans("Product") . '</td>'; print '<td>' . $langs->trans("Product") . '</td>';
print '<td>'.$langs->trans("AppliedPricesFrom").'</td>'; print '<td>'.$langs->trans("AppliedPricesFrom").'</td>';
print '<td class="center">'.$langs->trans("PriceBase").'</td>'; print '<td class="center">'.$langs->trans("PriceBase").'</td>';
print '<td class="right">'.$langs->trans("VAT").'</td>'; print '<td class="right">'.$langs->trans("VAT").'</td>';
print '<td class="right">'.$langs->trans("HT").'</td>'; print '<td class="right">'.$langs->trans("HT").'</td>';
print '<td class="right">'.$langs->trans("TTC").'</td>'; print '<td class="right">'.$langs->trans("TTC").'</td>';
print '<td class="right">'.$langs->trans("MinPrice").' '.$langs->trans("HT").'</td>'; print '<td class="right">'.$langs->trans("MinPrice").' '.$langs->trans("HT").'</td>';
print '<td class="right">'.$langs->trans("MinPrice").' '.$langs->trans("TTC").'</td>'; print '<td class="right">'.$langs->trans("MinPrice").' '.$langs->trans("TTC").'</td>';
print '<td class="right">'.$langs->trans("ChangedBy").'</td>'; print '<td class="right">'.$langs->trans("ChangedBy").'</td>';
print '<td>&nbsp;</td>'; print '<td>&nbsp;</td>';
print '</tr>'; print '</tr>';
if (count($prodcustprice->lines) > 0 || $search_prod) if (count($prodcustprice->lines) > 0 || $search_prod)
{ {
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print '<td class="liste_titre"><input type="text" class="flat" name="search_prod" value="'.$search_prod.'" size="20"></td>'; print '<td class="liste_titre"><input type="text" class="flat" name="search_prod" value="'.$search_prod.'" size="20"></td>';
print '<td class="liste_titre" ><input type="text" class="flat" name="search_label" value="' . $search_label . '" size="20"></td>'; print '<td class="liste_titre" ><input type="text" class="flat" name="search_label" value="' . $search_label . '" size="20"></td>';
print '<td class="liste_titre" colspan="3">&nbsp;</td>'; print '<td class="liste_titre" colspan="3">&nbsp;</td>';
print '<td class="liste_titre" align="right"><input type="text" class="flat" name="search_price" value="' . $search_price . '" size="10"></td>'; print '<td class="liste_titre" align="right"><input type="text" class="flat" name="search_price" value="' . $search_price . '" size="10"></td>';
print '<td class="liste_titre" align="right"><input type="text" class="flat" name="search_price_ttc" value="' . $search_price_ttc . '" size="10"></td>'; print '<td class="liste_titre" align="right"><input type="text" class="flat" name="search_price_ttc" value="' . $search_price_ttc . '" size="10"></td>';
print '<td class="liste_titre" colspan="3">&nbsp;</td>'; print '<td class="liste_titre" colspan="3">&nbsp;</td>';
// Print the search button // Print the search button
print '<td class="liste_titre maxwidthsearch">'; print '<td class="liste_titre maxwidthsearch">';
$searchpicto = $form->showFilterAndCheckAddButtons(0); $searchpicto = $form->showFilterAndCheckAddButtons(0);
print $searchpicto; print $searchpicto;
print '</td>'; print '</td>';
print '</tr>'; print '</tr>';
} }
if (count($prodcustprice->lines) > 0) if (count($prodcustprice->lines) > 0)
{ {
foreach ($prodcustprice->lines as $line) foreach ($prodcustprice->lines as $line)
{ {
print '<tr class="oddeven">'; print '<tr class="oddeven">';
$staticprod = new Product($db); $staticprod = new Product($db);
$staticprod->fetch($line->fk_product); $staticprod->fetch($line->fk_product);
print "<td>".$staticprod->getNomUrl(1)."</td>"; print "<td>".$staticprod->getNomUrl(1)."</td>";
print "<td>" . $staticprod->label ."</td>"; print "<td>" . $staticprod->label ."</td>";
print "<td>".dol_print_date($line->datec, "dayhour")."</td>"; print "<td>".dol_print_date($line->datec, "dayhour")."</td>";
print '<td class="center">'.$langs->trans($line->price_base_type)."</td>"; print '<td class="center">'.$langs->trans($line->price_base_type)."</td>";
print '<td class="right">'.vatrate($line->tva_tx.($line->default_vat_code ? ' ('.$line->default_vat_code.')' : ''), true, $line->recuperableonly)."</td>"; print '<td class="right">'.vatrate($line->tva_tx.($line->default_vat_code ? ' ('.$line->default_vat_code.')' : ''), true, $line->recuperableonly)."</td>";
print '<td class="right">'.price($line->price)."</td>"; print '<td class="right">'.price($line->price)."</td>";
print '<td class="right">'.price($line->price_ttc)."</td>"; print '<td class="right">'.price($line->price_ttc)."</td>";
print '<td class="right">'.price($line->price_min).'</td>'; print '<td class="right">'.price($line->price_min).'</td>';
print '<td class="right">'.price($line->price_min_ttc).'</td>'; print '<td class="right">'.price($line->price_min_ttc).'</td>';
// User // User
$userstatic = new User($db); $userstatic = new User($db);
$userstatic->fetch($line->fk_user); $userstatic->fetch($line->fk_user);
print '<td class="right">'; print '<td class="right">';
print $userstatic->getLoginUrl(1); print $userstatic->getLoginUrl(1);
print '</td>'; print '</td>';
// Action // Action
if ($user->rights->produit->creer || $user->rights->service->creer) if ($user->rights->produit->creer || $user->rights->service->creer)
{ {
print '<td class="right nowraponall">'; print '<td class="right nowraponall">';
print '<a class="paddingleftonly paddingrightonly" href="'.$_SERVER["PHP_SELF"].'?action=showlog_customer_price&amp;socid='.$object->id.'&amp;prodid='.$line->fk_product.'">'; print '<a class="paddingleftonly paddingrightonly" href="'.$_SERVER["PHP_SELF"].'?action=showlog_customer_price&amp;socid='.$object->id.'&amp;prodid='.$line->fk_product.'">';
print img_info(); print img_info();
print '</a>'; print '</a>';
print ' '; print ' ';
print '<a class="editfielda paddingleftonly paddingrightonly" href="'.$_SERVER["PHP_SELF"].'?action=edit_customer_price&amp;socid='.$object->id.'&amp;lineid='.$line->id.'">'; print '<a class="editfielda paddingleftonly paddingrightonly" href="'.$_SERVER["PHP_SELF"].'?action=edit_customer_price&amp;socid='.$object->id.'&amp;lineid='.$line->id.'">';
print img_edit('default', 0, 'style="vertical-align: middle;"'); print img_edit('default', 0, 'style="vertical-align: middle;"');
print '</a>'; print '</a>';
print ' '; print ' ';
print '<a class="paddingleftonly paddingrightonly" href="'.$_SERVER["PHP_SELF"].'?action=delete_customer_price&amp;token='.newToken().'&amp;socid='.$object->id.'&amp;lineid='.$line->id.'">'; print '<a class="paddingleftonly paddingrightonly" href="'.$_SERVER["PHP_SELF"].'?action=delete_customer_price&amp;token='.newToken().'&amp;socid='.$object->id.'&amp;lineid='.$line->id.'">';
print img_delete('default', 'style="vertical-align: middle;"'); print img_delete('default', 'style="vertical-align: middle;"');
print '</a>'; print '</a>';
print '</td>'; print '</td>';
} }
print "</tr>\n"; print "</tr>\n";
} }
} else { } else {
$colspan = 9; $colspan = 9;
if ($user->rights->produit->supprimer || $user->rights->service->supprimer) $colspan += 1; if ($user->rights->produit->supprimer || $user->rights->service->supprimer) $colspan += 1;
print '<tr class="oddeven"><td colspan="'.$colspan.'">'.$langs->trans('None').'</td></tr>'; print '<tr class="oddeven"><td colspan="'.$colspan.'">'.$langs->trans('None').'</td></tr>';
} }
print "</table>"; print "</table>";
print "</form>"; print "</form>";
} }
} }

View File

@ -58,7 +58,7 @@ if ($setterminal > 0)
setcookie("takeposterminal", $setterminal, (time() + (86400 * 354)), '/', null, false, true); // Permanent takeposterminal var in a cookie setcookie("takeposterminal", $setterminal, (time() + (86400 * 354)), '/', null, false, true); // Permanent takeposterminal var in a cookie
} }
if ($setcurrency!="") if ($setcurrency != "")
{ {
$_SESSION["takeposcustomercurrency"] = $setcurrency; $_SESSION["takeposcustomercurrency"] = $setcurrency;
} }
@ -812,7 +812,7 @@ if (empty($conf->global->TAKEPOS_HIDE_HEAD_BAR)) {
?> ?>
</a> </a>
<?php <?php
if (!empty($conf->multicurrency->enabled)){ if (!empty($conf->multicurrency->enabled)) {
print '<a class="valignmiddle tdoverflowmax100 minwidth75" id="multicurrency" onclick="ModalBox(\'ModalCurrency\');" title=""><span class="fas fa-coins paddingrightonly"></span>'.$langs->trans("Currency").'</a>'; print '<a class="valignmiddle tdoverflowmax100 minwidth75" id="multicurrency" onclick="ModalBox(\'ModalCurrency\');" title=""><span class="fas fa-coins paddingrightonly"></span>'.$langs->trans("Currency").'</a>';
} }
?> ?>
@ -850,10 +850,10 @@ if (empty($conf->global->TAKEPOS_HIDE_HEAD_BAR)) {
<div class="modal-content"> <div class="modal-content">
<div class="modal-header"> <div class="modal-header">
<span class="close" href="#" onclick="document.getElementById('ModalTerminal').style.display = 'none';">&times;</span> <span class="close" href="#" onclick="document.getElementById('ModalTerminal').style.display = 'none';">&times;</span>
<h3><?php print $langs->trans("TerminalSelect");?></h3> <h3><?php print $langs->trans("TerminalSelect"); ?></h3>
</div> </div>
<div class="modal-body"> <div class="modal-body">
<button type="button" class="block" onclick="location.href='index.php?setterminal=1'"><?php print $langs->trans("Terminal");?> 1</button> <button type="button" class="block" onclick="location.href='index.php?setterminal=1'"><?php print $langs->trans("Terminal"); ?> 1</button>
<?php <?php
for ($i = 2; $i <= $conf->global->TAKEPOS_NUM_TERMINALS; $i++) for ($i = 2; $i <= $conf->global->TAKEPOS_NUM_TERMINALS; $i++)
{ {

View File

@ -253,7 +253,7 @@ if ($action == 'valid' && $user->rights->facture->creer)
if ($pay != "delayed") { if ($pay != "delayed") {
$payment->create($user); $payment->create($user);
$payment->addPaymentToBank($user, 'payment', '(CustomerInvoicePayment)', $bankaccount, '', ''); $payment->addPaymentToBank($user, 'payment', '(CustomerInvoicePayment)', $bankaccount, '', '');
$remaintopay = $invoice->getRemainToPay(); // Recalculate remain to pay after the payment is recorded $remaintopay = $invoice->getRemainToPay(); // Recalculate remain to pay after the payment is recorded
} }
} }
@ -278,7 +278,7 @@ if ($action == 'history')
$invoice->fetch($placeid); $invoice->fetch($placeid);
} }
if (!empty($conf->multicurrency->enabled) && $_SESSION["takeposcustomercurrency"]!="") { if (!empty($conf->multicurrency->enabled) && $_SESSION["takeposcustomercurrency"] != "") {
$invoice->setMulticurrencyCode($_SESSION["takeposcustomercurrency"]); $invoice->setMulticurrencyCode($_SESSION["takeposcustomercurrency"]);
} }
@ -737,7 +737,7 @@ function TakeposPrinting(id){
function TakeposConnector(id){ function TakeposConnector(id){
console.log("TakeposConnector" + id); console.log("TakeposConnector" + id);
$.get("ajax/ajax.php?action=printinvoiceticket&term=<?php echo $_SESSION["takeposterminal"];?>&id="+id, function(data, status){ $.get("ajax/ajax.php?action=printinvoiceticket&term=<?php echo $_SESSION["takeposterminal"]; ?>&id="+id, function(data, status){
$.ajax({ $.ajax({
type: "POST", type: "POST",
url: '<?php print $conf->global->TAKEPOS_PRINT_SERVER; ?>/printer/index.php', url: '<?php print $conf->global->TAKEPOS_PRINT_SERVER; ?>/printer/index.php',
@ -902,12 +902,12 @@ if ($_SESSION["basiclayout"] != 1)
// In phone version only show when it is invoice page // In phone version only show when it is invoice page
if ($mobilepage == "invoice" || $mobilepage == "") { if ($mobilepage == "invoice" || $mobilepage == "") {
print '<span id="linecolht-span-total" style="font-size:1.3em; font-weight: bold;">'.price($invoice->total_ttc, 1, '', 1, -1, -1, $conf->currency).'</span>'; print '<span id="linecolht-span-total" style="font-size:1.3em; font-weight: bold;">'.price($invoice->total_ttc, 1, '', 1, -1, -1, $conf->currency).'</span>';
if (!empty($conf->multicurrency->enabled) && $_SESSION["takeposcustomercurrency"]!="" && $conf->currency!=$_SESSION["takeposcustomercurrency"]) { if (!empty($conf->multicurrency->enabled) && $_SESSION["takeposcustomercurrency"] != "" && $conf->currency != $_SESSION["takeposcustomercurrency"]) {
//Only show customer currency if multicurrency module is enabled, if currency selected and if this currency selected is not the same as main currency //Only show customer currency if multicurrency module is enabled, if currency selected and if this currency selected is not the same as main currency
include_once DOL_DOCUMENT_ROOT.'/multicurrency/class/multicurrency.class.php'; include_once DOL_DOCUMENT_ROOT.'/multicurrency/class/multicurrency.class.php';
$multicurrency = new MultiCurrency($db); $multicurrency = new MultiCurrency($db);
$multicurrency->fetch(0, $_SESSION["takeposcustomercurrency"]); $multicurrency->fetch(0, $_SESSION["takeposcustomercurrency"]);
print '<br><span id="linecolht-span-total" style="font-size:0.9em; font-style:italic;">('.price($invoice->total_ttc*$multicurrency->rate->rate).' '.$_SESSION["takeposcustomercurrency"].')</span>'; print '<br><span id="linecolht-span-total" style="font-size:0.9em; font-style:italic;">('.price($invoice->total_ttc * $multicurrency->rate->rate).' '.$_SESSION["takeposcustomercurrency"].')</span>';
} }
print '</td>'; print '</td>';
} }
@ -1108,12 +1108,12 @@ if ($placeid > 0)
$htmlforlines .= '</td>'; $htmlforlines .= '</td>';
$htmlforlines .= '<td class="right classfortooltip" title="'.$moreinfo.'">'; $htmlforlines .= '<td class="right classfortooltip" title="'.$moreinfo.'">';
$htmlforlines .= price($line->total_ttc, 1, '', 1, -1, -1, $conf->currency); $htmlforlines .= price($line->total_ttc, 1, '', 1, -1, -1, $conf->currency);
if (!empty($conf->multicurrency->enabled) && $_SESSION["takeposcustomercurrency"]!="" && $conf->currency!=$_SESSION["takeposcustomercurrency"]) { if (!empty($conf->multicurrency->enabled) && $_SESSION["takeposcustomercurrency"] != "" && $conf->currency != $_SESSION["takeposcustomercurrency"]) {
//Only show customer currency if multicurrency module is enabled, if currency selected and if this currency selected is not the same as main currency //Only show customer currency if multicurrency module is enabled, if currency selected and if this currency selected is not the same as main currency
include_once DOL_DOCUMENT_ROOT.'/multicurrency/class/multicurrency.class.php'; include_once DOL_DOCUMENT_ROOT.'/multicurrency/class/multicurrency.class.php';
$multicurrency = new MultiCurrency($db); $multicurrency = new MultiCurrency($db);
$multicurrency->fetch(0, $_SESSION["takeposcustomercurrency"]); $multicurrency->fetch(0, $_SESSION["takeposcustomercurrency"]);
$htmlforlines .= '<br><span id="linecolht-span-total" style="font-size:0.9em; font-style:italic;">('.price($line->total_ttc*$multicurrency->rate->rate).' '.$_SESSION["takeposcustomercurrency"].')</span>'; $htmlforlines .= '<br><span id="linecolht-span-total" style="font-size:0.9em; font-style:italic;">('.price($line->total_ttc * $multicurrency->rate->rate).' '.$_SESSION["takeposcustomercurrency"].')</span>';
} }
$htmlforlines .= '</td>'; $htmlforlines .= '</td>';
} }

View File

@ -231,7 +231,7 @@ else print "var received=0;";
<div style="position:relative; padding-top: 20px; left:5%; height:150px; width:90%;"> <div style="position:relative; padding-top: 20px; left:5%; height:150px; width:90%;">
<div class="paymentbordline paymentbordlinetotal"> <div class="paymentbordline paymentbordlinetotal">
<center><span class="takepospay"><font color="white"><?php echo $langs->trans('TotalTTC'); ?>: </font><span id="totaldisplay" class="colorwhite"><?php echo price($invoice->total_ttc, 1, '', 1, -1, -1, $invoice->multicurrency_code);?></span></span></center> <center><span class="takepospay"><font color="white"><?php echo $langs->trans('TotalTTC'); ?>: </font><span id="totaldisplay" class="colorwhite"><?php echo price($invoice->total_ttc, 1, '', 1, -1, -1, $invoice->multicurrency_code); ?></span></span></center>
</div> </div>
<?php if ($remaintopay != $invoice->total_ttc) { ?> <?php if ($remaintopay != $invoice->total_ttc) { ?>
<div class="paymentbordline paymentbordlineremain"> <div class="paymentbordline paymentbordlineremain">
@ -245,7 +245,7 @@ else print "var received=0;";
<center><span class="takepospay"><font color="white"><?php echo $langs->trans("Change"); ?>: </font><span class="change2 colorwhite"><?php echo price(0, 1, '', 1, -1, -1, $invoice->multicurrency_code); ?></span><input type="hidden" id="change2" class="change2" value="0"></span></center> <center><span class="takepospay"><font color="white"><?php echo $langs->trans("Change"); ?>: </font><span class="change2 colorwhite"><?php echo price(0, 1, '', 1, -1, -1, $invoice->multicurrency_code); ?></span><input type="hidden" id="change2" class="change2" value="0"></span></center>
</div> </div>
<?php <?php
if (! empty($conf->global->TAKEPOS_CAN_FORCE_BANK_ACCOUNT_DURING_PAYMENT)) { if (!empty($conf->global->TAKEPOS_CAN_FORCE_BANK_ACCOUNT_DURING_PAYMENT)) {
print '<div class="paymentbordline paddingtop paddingbottom"> print '<div class="paymentbordline paddingtop paddingbottom">
<center>'; <center>';
$filter = ''; $filter = '';

View File

@ -91,7 +91,7 @@ if (!empty($hookmanager->resPrint)) {
<br> <br>
<p class="left"> <p class="left">
<?php <?php
$constFreeText = 'TAKEPOS_HEADER' . $_SESSION['takeposterminal']; $constFreeText = 'TAKEPOS_HEADER'.$_SESSION['takeposterminal'];
if (!empty($conf->global->TAKEPOS_HEADER) || !empty($conf->global->{$constFreeText})) if (!empty($conf->global->TAKEPOS_HEADER) || !empty($conf->global->{$constFreeText}))
{ {
$newfreetext = ''; $newfreetext = '';
@ -127,8 +127,8 @@ if ($conf->global->TAKEPOS_SHOW_CUSTOMER)
<tr> <tr>
<th class="center"><?php print $langs->trans("Label"); ?></th> <th class="center"><?php print $langs->trans("Label"); ?></th>
<th class="right"><?php print $langs->trans("Qty"); ?></th> <th class="right"><?php print $langs->trans("Qty"); ?></th>
<th class="right"><?php if ($gift!=1) print $langs->trans("Price"); ?></th> <th class="right"><?php if ($gift != 1) print $langs->trans("Price"); ?></th>
<th class="right"><?php if ($gift!=1) print $langs->trans("TotalTTC"); ?></th> <th class="right"><?php if ($gift != 1) print $langs->trans("TotalTTC"); ?></th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
@ -142,8 +142,8 @@ if ($conf->global->TAKEPOS_SHOW_CUSTOMER)
else echo $line->description; ?> else echo $line->description; ?>
</td> </td>
<td class="right"><?php echo $line->qty; ?></td> <td class="right"><?php echo $line->qty; ?></td>
<td class="right"><?php if ($gift!=1) echo price(price2num($line->total_ttc / $line->qty, 'MT'), 1); ?></td> <td class="right"><?php if ($gift != 1) echo price(price2num($line->total_ttc / $line->qty, 'MT'), 1); ?></td>
<td class="right"><?php if ($gift!=1) echo price($line->total_ttc, 1); ?></td> <td class="right"><?php if ($gift != 1) echo price($line->total_ttc, 1); ?></td>
</tr> </tr>
<?php <?php
} }
@ -153,8 +153,8 @@ if ($conf->global->TAKEPOS_SHOW_CUSTOMER)
<br> <br>
<table class="right"> <table class="right">
<tr> <tr>
<th class="right"><?php if ($gift!=1) echo $langs->trans("TotalHT"); ?></th> <th class="right"><?php if ($gift != 1) echo $langs->trans("TotalHT"); ?></th>
<td class="right"><?php if ($gift!=1) echo price($object->total_ht, 1, '', 1, - 1, - 1, $conf->currency)."\n"; ?></td> <td class="right"><?php if ($gift != 1) echo price($object->total_ht, 1, '', 1, - 1, - 1, $conf->currency)."\n"; ?></td>
</tr> </tr>
<?php if ($conf->global->TAKEPOS_TICKET_VAT_GROUPPED) { <?php if ($conf->global->TAKEPOS_TICKET_VAT_GROUPPED) {
$vat_groups = array(); $vat_groups = array();
@ -168,27 +168,27 @@ if ($conf->global->TAKEPOS_SHOW_CUSTOMER)
foreach ($vat_groups as $key => $val) { foreach ($vat_groups as $key => $val) {
?> ?>
<tr> <tr>
<th align="right"><?php if ($gift!=1) echo $langs->trans("VAT").' '.vatrate($key, 1); ?></th> <th align="right"><?php if ($gift != 1) echo $langs->trans("VAT").' '.vatrate($key, 1); ?></th>
<td align="right"><?php if ($gift!=1) echo price($val, 1, '', 1, - 1, - 1, $conf->currency)."\n"; ?></td> <td align="right"><?php if ($gift != 1) echo price($val, 1, '', 1, - 1, - 1, $conf->currency)."\n"; ?></td>
</tr> </tr>
<?php <?php
} }
} else { ?> } else { ?>
<tr> <tr>
<th class="right"><?php if ($gift!=1) echo $langs->trans("TotalVAT").'</th><td class="right">'.price($object->total_tva, 1, '', 1, - 1, - 1, $conf->currency)."\n"; ?></td> <th class="right"><?php if ($gift != 1) echo $langs->trans("TotalVAT").'</th><td class="right">'.price($object->total_tva, 1, '', 1, - 1, - 1, $conf->currency)."\n"; ?></td>
</tr> </tr>
<?php } ?> <?php } ?>
<tr> <tr>
<th class="right"><?php if ($gift!=1) echo ''.$langs->trans("TotalTTC").'</th><td class="right">'.price($object->total_ttc, 1, '', 1, - 1, - 1, $conf->currency)."\n"; ?></td> <th class="right"><?php if ($gift != 1) echo ''.$langs->trans("TotalTTC").'</th><td class="right">'.price($object->total_ttc, 1, '', 1, - 1, - 1, $conf->currency)."\n"; ?></td>
</tr> </tr>
<?php <?php
if (!empty($conf->multicurrency->enabled) && $_SESSION["takeposcustomercurrency"]!="" && $conf->currency!=$_SESSION["takeposcustomercurrency"]) { if (!empty($conf->multicurrency->enabled) && $_SESSION["takeposcustomercurrency"] != "" && $conf->currency != $_SESSION["takeposcustomercurrency"]) {
//Only show customer currency if multicurrency module is enabled, if currency selected and if this currency selected is not the same as main currency //Only show customer currency if multicurrency module is enabled, if currency selected and if this currency selected is not the same as main currency
include_once DOL_DOCUMENT_ROOT.'/multicurrency/class/multicurrency.class.php'; include_once DOL_DOCUMENT_ROOT.'/multicurrency/class/multicurrency.class.php';
$multicurrency = new MultiCurrency($db); $multicurrency = new MultiCurrency($db);
$multicurrency->fetch(0, $_SESSION["takeposcustomercurrency"]); $multicurrency->fetch(0, $_SESSION["takeposcustomercurrency"]);
echo '<tr><th class="right">'; echo '<tr><th class="right">';
if ($gift!=1) echo ''.$langs->trans("TotalTTC").' '.$_SESSION["takeposcustomercurrency"].'</th><td class="right">'.price($object->total_ttc*$multicurrency->rate->rate, 1, '', 1, - 1, - 1, $_SESSION["takeposcustomercurrency"])."\n"; if ($gift != 1) echo ''.$langs->trans("TotalTTC").' '.$_SESSION["takeposcustomercurrency"].'</th><td class="right">'.price($object->total_ttc * $multicurrency->rate->rate, 1, '', 1, - 1, - 1, $_SESSION["takeposcustomercurrency"])."\n";
echo '</td></tr>'; echo '</td></tr>';
} }
@ -211,12 +211,12 @@ if ($conf->global->TAKEPOS_PRINT_PAYMENT_METHOD) {
echo $langs->transnoentitiesnoconv("PaymentTypeShort".$row->code); echo $langs->transnoentitiesnoconv("PaymentTypeShort".$row->code);
echo '</td>'; echo '</td>';
echo '<td class="right">'; echo '<td class="right">';
$amount_payment=($conf->multicurrency->enabled && $object->multicurrency_tx != 1) ? $row->multicurrency_amount : $row->amount; $amount_payment = ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) ? $row->multicurrency_amount : $row->amount;
if ($row->code == "LIQ") $amount_payment = $amount_payment + $row->pos_change; // Show amount with excess received if is cash payment if ($row->code == "LIQ") $amount_payment = $amount_payment + $row->pos_change; // Show amount with excess received if is cash payment
echo price($amount_payment, 1, '', 1, - 1, - 1, $conf->currency); echo price($amount_payment, 1, '', 1, - 1, - 1, $conf->currency);
echo '</td>'; echo '</td>';
echo '</tr>'; echo '</tr>';
if ($row->code == "LIQ" && $row->pos_change>0) // Print change only in cash payments if ($row->code == "LIQ" && $row->pos_change > 0) // Print change only in cash payments
{ {
echo '<tr>'; echo '<tr>';
echo '<td class="right">'; echo '<td class="right">';
@ -238,7 +238,7 @@ if ($conf->global->TAKEPOS_PRINT_PAYMENT_METHOD) {
<br> <br>
<br> <br>
<?php <?php
$constFreeText = 'TAKEPOS_FOOTER' . $_SESSION['takeposterminal']; $constFreeText = 'TAKEPOS_FOOTER'.$_SESSION['takeposterminal'];
if (!empty($conf->global->TAKEPOS_FOOTER) || !empty($conf->global->{$constFreeText})) if (!empty($conf->global->TAKEPOS_FOOTER) || !empty($conf->global->{$constFreeText}))
{ {
$newfreetext = ''; $newfreetext = '';

View File

@ -51,31 +51,31 @@ $invoice->fetch($facid);
$customer = new Societe($db); $customer = new Societe($db);
$customer->fetch($invoice->socid); $customer->fetch($invoice->socid);
if ($action=="send") if ($action == "send")
{ {
include_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php'; include_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php';
include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php'; include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php';
$formmail = new FormMail($db); $formmail = new FormMail($db);
$outputlangs = new Translate('', $conf); $outputlangs = new Translate('', $conf);
$model_id = $conf->global->TAKEPOS_EMAIL_TEMPLATE_INVOICE; $model_id = $conf->global->TAKEPOS_EMAIL_TEMPLATE_INVOICE;
$arraydefaultmessage = $formmail->getEMailTemplate($db, 'facture_send', $user, $outputlangs, $model_id); $arraydefaultmessage = $formmail->getEMailTemplate($db, 'facture_send', $user, $outputlangs, $model_id);
$subject = $arraydefaultmessage->topic; $subject = $arraydefaultmessage->topic;
ob_start(); // turn on output receipt ob_start(); // turn on output receipt
include 'receipt.php'; include 'receipt.php';
$receipt = ob_get_contents(); // get the contents of the output buffer $receipt = ob_get_contents(); // get the contents of the output buffer
ob_end_clean(); ob_end_clean();
$msg="<html>".$arraydefaultmessage->content."<br>".$receipt."</html>"; $msg="<html>".$arraydefaultmessage->content."<br>".$receipt."</html>";
$sendto=$email; $sendto=$email;
$from=$mysoc->email; $from=$mysoc->email;
$mail = new CMailFile($subject, $sendto, $from, $msg, array(), array(), array(), '', '', 0, 1); $mail = new CMailFile($subject, $sendto, $from, $msg, array(), array(), array(), '', '', 0, 1);
if ($mail->error || $mail->errors) { if ($mail->error || $mail->errors) {
setEventMessages($mail->error, $mail->errors, 'errors'); setEventMessages($mail->error, $mail->errors, 'errors');
} else { } else {
$result = $mail->sendfile(); $result = $mail->sendfile();
} }
exit; exit;
} }
$arrayofcss = array('/takepos/css/pos.css.php'); $arrayofcss = array('/takepos/css/pos.css.php');
$arrayofjs = array(); $arrayofjs = array();

View File

@ -170,7 +170,7 @@ class User extends CommonObject
public $users = array(); // To store all tree of users hierarchy public $users = array(); // To store all tree of users hierarchy
public $parentof; // To store an array of all parents for all ids. public $parentof; // To store an array of all parents for all ids.
private $cache_childids; // Cache array of already loaded childs private $cache_childids; // Cache array of already loaded childs
public $accountancy_code; // Accountancy code in prevision of the complete accountancy module public $accountancy_code; // Accountancy code in prevision of the complete accountancy module
@ -704,10 +704,10 @@ class User extends CommonObject
// avoid admin can remove his own important rights // avoid admin can remove his own important rights
if ($this->admin == 1) if ($this->admin == 1)
{ {
$sql .= " AND id NOT IN (251, 252, 253, 254, 255, 256)"; // other users rights $sql .= " AND id NOT IN (251, 252, 253, 254, 255, 256)"; // other users rights
$sql .= " AND id NOT IN (341, 342, 343, 344)"; // own rights $sql .= " AND id NOT IN (341, 342, 343, 344)"; // own rights
$sql .= " AND id NOT IN (351, 352, 353, 354)"; // groups rights $sql .= " AND id NOT IN (351, 352, 353, 354)"; // groups rights
$sql .= " AND id NOT IN (358)"; // user export $sql .= " AND id NOT IN (358)"; // user export
} }
$result = $this->db->query($sql); $result = $this->db->query($sql);
@ -1186,7 +1186,7 @@ class User extends CommonObject
return -5; return -5;
} }
if (! empty($conf->global->MAIN_DEFAULT_WAREHOUSE_USER) && !empty($conf->global->STOCK_USERSTOCK_AUTOCREATE)) if (!empty($conf->global->MAIN_DEFAULT_WAREHOUSE_USER) && !empty($conf->global->STOCK_USERSTOCK_AUTOCREATE))
{ {
require_once DOL_DOCUMENT_ROOT.'/product/stock/class/entrepot.class.php'; require_once DOL_DOCUMENT_ROOT.'/product/stock/class/entrepot.class.php';
$langs->load("stocks"); $langs->load("stocks");

View File

@ -220,7 +220,7 @@ if (empty($reshook))
$search_date_creation = ""; $search_date_creation = "";
$search_date_update = ""; $search_date_update = "";
$search_array_options = array(); $search_array_options = array();
$search_categ = 0; $search_categ = 0;
} }
// Mass actions // Mass actions
@ -463,11 +463,11 @@ include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php';
if (!empty($catid)) if (!empty($catid))
{ {
print "<div id='ways'>"; print "<div id='ways'>";
$c = new Categorie($db); $c = new Categorie($db);
$ways = $c->print_all_ways(' &gt; ', 'user/list.php'); $ways = $c->print_all_ways(' &gt; ', 'user/list.php');
print " &gt; ".$ways[0]."<br>\n"; print " &gt; ".$ways[0]."<br>\n";
print "</div><br>"; print "</div><br>";
} }
if ($search_all) if ($search_all)
@ -484,10 +484,10 @@ $moreforfilter = '';
// Filter on categories // Filter on categories
if (!empty($conf->categorie->enabled) && $user->rights->categorie->lire) if (!empty($conf->categorie->enabled) && $user->rights->categorie->lire)
{ {
$moreforfilter .= '<div class="divsearchfield">'; $moreforfilter .= '<div class="divsearchfield">';
$moreforfilter .= $langs->trans('Categories').': '; $moreforfilter .= $langs->trans('Categories').': ';
$moreforfilter .= $formother->select_categories(Categorie::TYPE_USER, $search_categ, 'search_categ', 1); $moreforfilter .= $formother->select_categories(Categorie::TYPE_USER, $search_categ, 'search_categ', 1);
$moreforfilter .= '</div>'; $moreforfilter .= '</div>';
} }
$parameters = array(); $parameters = array();
@ -497,9 +497,9 @@ else $moreforfilter = $hookmanager->resPrint;
if (!empty($moreforfilter)) if (!empty($moreforfilter))
{ {
print '<div class="liste_titre liste_titre_bydiv centpercent">'; print '<div class="liste_titre liste_titre_bydiv centpercent">';
print $moreforfilter; print $moreforfilter;
print '</div>'; print '</div>';
} }
$varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
@ -693,29 +693,29 @@ while ($i < ($limit ? min($num, $limit) : $num))
} }
if (!empty($arrayfields['u.firstname']['checked'])) if (!empty($arrayfields['u.firstname']['checked']))
{ {
print '<td class="tdoverflowmax150">'.$obj->firstname.'</td>'; print '<td class="tdoverflowmax150">'.$obj->firstname.'</td>';
if (!$i) $totalarray['nbfield']++; if (!$i) $totalarray['nbfield']++;
} }
if (!empty($arrayfields['u.gender']['checked'])) if (!empty($arrayfields['u.gender']['checked']))
{ {
print '<td>'; print '<td>';
if ($obj->gender) print $langs->trans("Gender".$obj->gender); if ($obj->gender) print $langs->trans("Gender".$obj->gender);
print '</td>'; print '</td>';
if (!$i) $totalarray['nbfield']++; if (!$i) $totalarray['nbfield']++;
} }
if (!empty($arrayfields['u.employee']['checked'])) if (!empty($arrayfields['u.employee']['checked']))
{ {
print '<td>'.yn($obj->employee).'</td>'; print '<td>'.yn($obj->employee).'</td>';
if (!$i) $totalarray['nbfield']++; if (!$i) $totalarray['nbfield']++;
} }
if (!empty($arrayfields['u.accountancy_code']['checked'])) if (!empty($arrayfields['u.accountancy_code']['checked']))
{ {
print '<td>'.$obj->accountancy_code.'</td>'; print '<td>'.$obj->accountancy_code.'</td>';
if (!$i) $totalarray['nbfield']++; if (!$i) $totalarray['nbfield']++;
} }
if (!empty($arrayfields['u.email']['checked'])) if (!empty($arrayfields['u.email']['checked']))
{ {
print '<td>'.$obj->email.'</td>'; print '<td>'.$obj->email.'</td>';
if (!$i) $totalarray['nbfield']++; if (!$i) $totalarray['nbfield']++;
} }
if (!empty($arrayfields['u.api_key']['checked'])) if (!empty($arrayfields['u.api_key']['checked']))
@ -774,7 +774,7 @@ while ($i < ($limit ? min($num, $limit) : $num))
$user2->admin = $obj->admin2; $user2->admin = $obj->admin2;
$user2->email = $obj->email2; $user2->email = $obj->email2;
$user2->socid = $obj->fk_soc2; $user2->socid = $obj->fk_soc2;
$user2->statut = $obj->statut2; $user2->statut = $obj->statut2;
print $user2->getNomUrl(-1, '', 0, 0, 24, 0, '', '', 1); print $user2->getNomUrl(-1, '', 0, 0, 24, 0, '', '', 1);
if (!empty($conf->multicompany->enabled) && $obj->admin2 && !$obj->entity2) if (!empty($conf->multicompany->enabled) && $obj->admin2 && !$obj->entity2)
{ {
@ -826,9 +826,9 @@ while ($i < ($limit ? min($num, $limit) : $num))
// Status // Status
if (!empty($arrayfields['u.statut']['checked'])) if (!empty($arrayfields['u.statut']['checked']))
{ {
$userstatic->statut = $obj->statut; $userstatic->statut = $obj->statut;
print '<td class="center">'.$userstatic->getLibStatut(5).'</td>'; print '<td class="center">'.$userstatic->getLibStatut(5).'</td>';
if (!$i) $totalarray['nbfield']++; if (!$i) $totalarray['nbfield']++;
} }
// Action column // Action column
print '<td class="nowrap center">'; print '<td class="nowrap center">';

View File

@ -63,48 +63,48 @@ $now = dol_now();
// Add a notification // Add a notification
if ($action == 'add') if ($action == 'add')
{ {
$error = 0; $error = 0;
if ($actionid <= 0) if ($actionid <= 0)
{ {
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Action")), null, 'errors'); setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Action")), null, 'errors');
$error++; $error++;
} }
if (!$error) if (!$error)
{ {
$db->begin(); $db->begin();
$sql = "DELETE FROM ".MAIN_DB_PREFIX."notify_def"; $sql = "DELETE FROM ".MAIN_DB_PREFIX."notify_def";
$sql .= " WHERE fk_user=".$id." AND fk_action=".$actionid; $sql .= " WHERE fk_user=".$id." AND fk_action=".$actionid;
if ($db->query($sql)) if ($db->query($sql))
{ {
$sql = "INSERT INTO ".MAIN_DB_PREFIX."notify_def (datec,fk_user, fk_action)"; $sql = "INSERT INTO ".MAIN_DB_PREFIX."notify_def (datec,fk_user, fk_action)";
$sql .= " VALUES ('".$db->idate($now)."',".$id.",".$actionid.")"; $sql .= " VALUES ('".$db->idate($now)."',".$id.",".$actionid.")";
if (!$db->query($sql)) if (!$db->query($sql))
{ {
$error++; $error++;
dol_print_error($db); dol_print_error($db);
} }
} else { } else {
dol_print_error($db); dol_print_error($db);
} }
if (!$error) if (!$error)
{ {
$db->commit(); $db->commit();
} else { } else {
$db->rollback(); $db->rollback();
} }
} }
} }
// Remove a notification // Remove a notification
if ($action == 'delete') if ($action == 'delete')
{ {
$sql = "DELETE FROM ".MAIN_DB_PREFIX."notify_def where rowid=".GETPOST("actid", "int"); $sql = "DELETE FROM ".MAIN_DB_PREFIX."notify_def where rowid=".GETPOST("actid", "int");
$db->query($sql); $db->query($sql);
} }
@ -127,32 +127,32 @@ llxHeader('', $title, $help_url);
if ($result > 0) if ($result > 0)
{ {
$langs->load("other"); $langs->load("other");
$head = user_prepare_head($object); $head = user_prepare_head($object);
dol_fiche_head($head, 'notify', $langs->trans("User"), -1, 'user'); dol_fiche_head($head, 'notify', $langs->trans("User"), -1, 'user');
$linkback = '<a href="'.DOL_URL_ROOT.'/user/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>'; $linkback = '<a href="'.DOL_URL_ROOT.'/user/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
dol_banner_tab($object, 'id', $linkback, $user->rights->user->user->lire || $user->admin, 'rowid', 'ref', '', '', 0, '', '', 0, ''); dol_banner_tab($object, 'id', $linkback, $user->rights->user->user->lire || $user->admin, 'rowid', 'ref', '', '', 0, '', '', 0, '');
print '<div class="fichecenter">'; print '<div class="fichecenter">';
print '<div class="underbanner clearboth"></div>'; print '<div class="underbanner clearboth"></div>';
print '<table class="border centpercent tableforfield">'; print '<table class="border centpercent tableforfield">';
// Login // Login
print '<tr><td class="titlefield">'.$langs->trans("Login").'</td>'; print '<tr><td class="titlefield">'.$langs->trans("Login").'</td>';
if (!empty($object->ldap_sid) && $object->statut == 0) if (!empty($object->ldap_sid) && $object->statut == 0)
{ {
print '<td class="error">'.$langs->trans("LoginAccountDisableInDolibarr").'</td>'; print '<td class="error">'.$langs->trans("LoginAccountDisableInDolibarr").'</td>';
} else { } else {
print '<td>'.$object->login.'</td>'; print '<td>'.$object->login.'</td>';
} }
print '</tr>'."\n"; print '</tr>'."\n";
/*print '<tr><td class="titlefield">'.$langs->trans("NbOfActiveNotifications").'</td>'; // Notification for this thirdparty /*print '<tr><td class="titlefield">'.$langs->trans("NbOfActiveNotifications").'</td>'; // Notification for this thirdparty
print '<td colspan="3">'; print '<td colspan="3">';
$nbofrecipientemails=0; $nbofrecipientemails=0;
$notify=new Notify($db); $notify=new Notify($db);
@ -164,164 +164,164 @@ if ($result > 0)
print $nbofrecipientemails; print $nbofrecipientemails;
print '</td></tr>';*/ print '</td></tr>';*/
print '</table>'; print '</table>';
print '</div>'; print '</div>';
dol_fiche_end(); dol_fiche_end();
print "\n"; print "\n";
// Help // Help
print '<span class="opacitymedium">'; print '<span class="opacitymedium">';
print '<br>'.$langs->trans("NotificationsDesc"); print '<br>'.$langs->trans("NotificationsDesc");
print '<br>'.$langs->trans("NotificationsDescUser"); print '<br>'.$langs->trans("NotificationsDescUser");
print '<br>'.$langs->trans("NotificationsDescContact"); print '<br>'.$langs->trans("NotificationsDescContact");
print '<br>'.$langs->trans("NotificationsDescGlobal"); print '<br>'.$langs->trans("NotificationsDescGlobal");
print '</span>'; print '</span>';
print '<br><br><br>'."\n"; print '<br><br><br>'."\n";
// Add notification form // Add notification form
print load_fiche_titre($langs->trans("AddNewNotification"), '', ''); print load_fiche_titre($langs->trans("AddNewNotification"), '', '');
print '<form action="'.$_SERVER["PHP_SELF"].'?id='.$id.'" method="post">'; print '<form action="'.$_SERVER["PHP_SELF"].'?id='.$id.'" method="post">';
print '<input type="hidden" name="token" value="'.newToken().'">'; print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="action" value="add">'; print '<input type="hidden" name="action" value="add">';
$param = "&id=".$id; $param = "&id=".$id;
// Line with titles // Line with titles
print '<table width="100%" class="noborder">'; print '<table width="100%" class="noborder">';
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print_liste_field_titre("Target", $_SERVER["PHP_SELF"], "c.lastname,c.firstname", '', $param, '"width="45%"', $sortfield, $sortorder); print_liste_field_titre("Target", $_SERVER["PHP_SELF"], "c.lastname,c.firstname", '', $param, '"width="45%"', $sortfield, $sortorder);
print_liste_field_titre("Action", $_SERVER["PHP_SELF"], "", '', $param, '"width="35%"', $sortfield, $sortorder); print_liste_field_titre("Action", $_SERVER["PHP_SELF"], "", '', $param, '"width="35%"', $sortfield, $sortorder);
print_liste_field_titre("Type", $_SERVER["PHP_SELF"], "n.type", '', $param, '"width="10%"', $sortfield, $sortorder); print_liste_field_titre("Type", $_SERVER["PHP_SELF"], "n.type", '', $param, '"width="10%"', $sortfield, $sortorder);
print_liste_field_titre(''); print_liste_field_titre('');
print "</tr>\n"; print "</tr>\n";
// $listofemails=$object->thirdparty_and_contact_email_array(); // $listofemails=$object->thirdparty_and_contact_email_array();
if ($object->email) if ($object->email)
{ {
$actions = array(); $actions = array();
// Load array of available notifications // Load array of available notifications
$notificationtrigger = new InterfaceNotification($db); $notificationtrigger = new InterfaceNotification($db);
$listofnotifiedevents = $notificationtrigger->getListOfManagedEvents(); $listofnotifiedevents = $notificationtrigger->getListOfManagedEvents();
foreach ($listofnotifiedevents as $notifiedevent) foreach ($listofnotifiedevents as $notifiedevent)
{ {
$label = ($langs->trans("Notify_".$notifiedevent['code']) != "Notify_".$notifiedevent['code'] ? $langs->trans("Notify_".$notifiedevent['code']) : $notifiedevent['label']); $label = ($langs->trans("Notify_".$notifiedevent['code']) != "Notify_".$notifiedevent['code'] ? $langs->trans("Notify_".$notifiedevent['code']) : $notifiedevent['label']);
$actions[$notifiedevent['rowid']] = $label; $actions[$notifiedevent['rowid']] = $label;
} }
print '<tr class="oddeven nohover"><td>'; print '<tr class="oddeven nohover"><td>';
print $object->getNomUrl(1); print $object->getNomUrl(1);
if (isValidEmail($object->email)) if (isValidEmail($object->email))
{ {
print ' &lt;'.$object->email.'&gt;'; print ' &lt;'.$object->email.'&gt;';
} else { } else {
$langs->load("errors"); $langs->load("errors");
print ' &nbsp; '.img_warning().' '.$langs->trans("ErrorBadEMail", $object->email); print ' &nbsp; '.img_warning().' '.$langs->trans("ErrorBadEMail", $object->email);
} }
print '</td>'; print '</td>';
print '<td>'; print '<td>';
print img_picto('', 'object_action', '', false, 0, 0, '', 'paddingright').$form->selectarray("actionid", $actions, '', 1); print img_picto('', 'object_action', '', false, 0, 0, '', 'paddingright').$form->selectarray("actionid", $actions, '', 1);
print '</td>'; print '</td>';
print '<td>'; print '<td>';
$type = array('email'=>$langs->trans("EMail")); $type = array('email'=>$langs->trans("EMail"));
print $form->selectarray("typeid", $type); print $form->selectarray("typeid", $type);
print '</td>'; print '</td>';
print '<td class="right"><input type="submit" class="button" value="'.$langs->trans("Add").'"></td>'; print '<td class="right"><input type="submit" class="button" value="'.$langs->trans("Add").'"></td>';
print '</tr>'; print '</tr>';
} else { } else {
print '<tr class="oddeven"><td colspan="4">'; print '<tr class="oddeven"><td colspan="4">';
print $langs->trans("YouMustAssignUserMailFirst"); print $langs->trans("YouMustAssignUserMailFirst");
print '</td></tr>'; print '</td></tr>';
} }
print '</table>'; print '</table>';
print '</form>'; print '</form>';
print '<br>'; print '<br>';
// List of notifications enabled for contacts // List of notifications enabled for contacts
$sql = "SELECT n.rowid, n.type,"; $sql = "SELECT n.rowid, n.type,";
$sql .= " a.code, a.label,"; $sql .= " a.code, a.label,";
$sql .= " c.rowid as userid, c.lastname, c.firstname, c.email"; $sql .= " c.rowid as userid, c.lastname, c.firstname, c.email";
$sql .= " FROM ".MAIN_DB_PREFIX."c_action_trigger as a,"; $sql .= " FROM ".MAIN_DB_PREFIX."c_action_trigger as a,";
$sql .= " ".MAIN_DB_PREFIX."notify_def as n,"; $sql .= " ".MAIN_DB_PREFIX."notify_def as n,";
$sql .= " ".MAIN_DB_PREFIX."user c"; $sql .= " ".MAIN_DB_PREFIX."user c";
$sql .= " WHERE a.rowid = n.fk_action"; $sql .= " WHERE a.rowid = n.fk_action";
$sql .= " AND c.rowid = n.fk_user"; $sql .= " AND c.rowid = n.fk_user";
$sql .= " AND c.rowid = ".$object->id; $sql .= " AND c.rowid = ".$object->id;
$resql = $db->query($sql); $resql = $db->query($sql);
if ($resql) if ($resql)
{ {
$num = $db->num_rows($resql); $num = $db->num_rows($resql);
} else { } else {
dol_print_error($db); dol_print_error($db);
} }
// List of active notifications // List of active notifications
print load_fiche_titre($langs->trans("ListOfActiveNotifications").' ('.$num.')', '', ''); print load_fiche_titre($langs->trans("ListOfActiveNotifications").' ('.$num.')', '', '');
// Line with titles // Line with titles
print '<table width="100%" class="noborder">'; print '<table width="100%" class="noborder">';
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print_liste_field_titre("Target", $_SERVER["PHP_SELF"], "c.lastname,c.firstname", '', $param, '"width="45%"', $sortfield, $sortorder); print_liste_field_titre("Target", $_SERVER["PHP_SELF"], "c.lastname,c.firstname", '', $param, '"width="45%"', $sortfield, $sortorder);
print_liste_field_titre("Action", $_SERVER["PHP_SELF"], "", '', $param, '"width="35%"', $sortfield, $sortorder); print_liste_field_titre("Action", $_SERVER["PHP_SELF"], "", '', $param, '"width="35%"', $sortfield, $sortorder);
print_liste_field_titre("Type", $_SERVER["PHP_SELF"], "n.type", '', $param, '"width="10%"', $sortfield, $sortorder); print_liste_field_titre("Type", $_SERVER["PHP_SELF"], "n.type", '', $param, '"width="10%"', $sortfield, $sortorder);
print_liste_field_titre('', '', ''); print_liste_field_titre('', '', '');
print '</tr>'; print '</tr>';
$langs->load("errors"); $langs->load("errors");
$langs->load("other"); $langs->load("other");
if ($num) if ($num)
{ {
$i = 0; $i = 0;
$userstatic = new user($db); $userstatic = new user($db);
while ($i < $num) while ($i < $num)
{ {
$obj = $db->fetch_object($resql); $obj = $db->fetch_object($resql);
$userstatic->id = $obj->userid; $userstatic->id = $obj->userid;
$userstatic->lastname = $obj->lastname; $userstatic->lastname = $obj->lastname;
$userstatic->firstname = $obj->firstname; $userstatic->firstname = $obj->firstname;
print '<tr class="oddeven"><td>'.$userstatic->getNomUrl(1); print '<tr class="oddeven"><td>'.$userstatic->getNomUrl(1);
if ($obj->type == 'email') if ($obj->type == 'email')
{ {
if (isValidEmail($obj->email)) if (isValidEmail($obj->email))
{ {
print ' &lt;'.$obj->email.'&gt;'; print ' &lt;'.$obj->email.'&gt;';
} else { } else {
$langs->load("errors"); $langs->load("errors");
print ' &nbsp; '.img_warning().' '.$langs->trans("ErrorBadEMail", $obj->email); print ' &nbsp; '.img_warning().' '.$langs->trans("ErrorBadEMail", $obj->email);
} }
} }
print '</td>'; print '</td>';
print '<td>'; print '<td>';
$label = ($langs->trans("Notify_".$obj->code) != "Notify_".$obj->code ? $langs->trans("Notify_".$obj->code) : $obj->label); $label = ($langs->trans("Notify_".$obj->code) != "Notify_".$obj->code ? $langs->trans("Notify_".$obj->code) : $obj->label);
print img_picto('', 'object_action', '', false, 0, 0, '', 'paddingright').$label; print img_picto('', 'object_action', '', false, 0, 0, '', 'paddingright').$label;
print '</td>'; print '</td>';
print '<td>'; print '<td>';
if ($obj->type == 'email') print $langs->trans("Email"); if ($obj->type == 'email') print $langs->trans("Email");
if ($obj->type == 'sms') print $langs->trans("SMS"); if ($obj->type == 'sms') print $langs->trans("SMS");
print '</td>'; print '</td>';
print '<td class="right"><a href="card.php?id='.$id.'&amp;action=delete&amp;token='.newToken().'&amp;actid='.$obj->rowid.'">'.img_delete().'</a></td>'; print '<td class="right"><a href="card.php?id='.$id.'&amp;action=delete&amp;token='.newToken().'&amp;actid='.$obj->rowid.'">'.img_delete().'</a></td>';
print '</tr>'; print '</tr>';
$i++; $i++;
} }
$db->free($resql); $db->free($resql);
} }
// List of notifications enabled for fixed email // List of notifications enabled for fixed email
/* /*
foreach($conf->global as $key => $val) foreach($conf->global as $key => $val)
{ {
if (! preg_match('/^NOTIFICATION_FIXEDEMAIL_(.*)/', $key, $reg)) continue; if (! preg_match('/^NOTIFICATION_FIXEDEMAIL_(.*)/', $key, $reg)) continue;
@ -362,7 +362,7 @@ if ($result > 0)
print '<td class="right">'.$langs->trans("SeeModuleSetup", $langs->transnoentitiesnoconv("Module600Name")).'</td>'; print '<td class="right">'.$langs->trans("SeeModuleSetup", $langs->transnoentitiesnoconv("Module600Name")).'</td>';
print '</tr>'; print '</tr>';
}*/ }*/
/*if ($user->admin) /*if ($user->admin)
{ {
$var = ! $var; $var = ! $var;
print '<tr class="oddeven"><td colspan="4">'; print '<tr class="oddeven"><td colspan="4">';
@ -370,104 +370,104 @@ if ($result > 0)
print '</td></tr>'; print '</td></tr>';
}*/ }*/
print '</table>'; print '</table>';
print '<br><br>'."\n"; print '<br><br>'."\n";
// List // List
$sql = "SELECT n.rowid, n.daten, n.email, n.objet_type as object_type, n.objet_id as object_id, n.type,"; $sql = "SELECT n.rowid, n.daten, n.email, n.objet_type as object_type, n.objet_id as object_id, n.type,";
$sql .= " c.rowid as id, c.lastname, c.firstname, c.email as contactemail,"; $sql .= " c.rowid as id, c.lastname, c.firstname, c.email as contactemail,";
$sql .= " a.code, a.label"; $sql .= " a.code, a.label";
$sql .= " FROM ".MAIN_DB_PREFIX."c_action_trigger as a,"; $sql .= " FROM ".MAIN_DB_PREFIX."c_action_trigger as a,";
$sql .= " ".MAIN_DB_PREFIX."notify as n"; $sql .= " ".MAIN_DB_PREFIX."notify as n";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."user as c ON n.fk_user = c.rowid"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."user as c ON n.fk_user = c.rowid";
$sql .= " WHERE a.rowid = n.fk_action"; $sql .= " WHERE a.rowid = n.fk_action";
$sql .= " AND n.fk_user = ".$object->id; $sql .= " AND n.fk_user = ".$object->id;
$sql .= $db->order($sortfield, $sortorder); $sql .= $db->order($sortfield, $sortorder);
// Count total nb of records // Count total nb of records
$nbtotalofrecords = ''; $nbtotalofrecords = '';
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
{ {
$result = $db->query($sql); $result = $db->query($sql);
$nbtotalofrecords = $db->num_rows($result); $nbtotalofrecords = $db->num_rows($result);
if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0
{ {
$page = 0; $page = 0;
$offset = 0; $offset = 0;
} }
} }
$sql .= $db->plimit($limit + 1, $offset); $sql .= $db->plimit($limit + 1, $offset);
$resql = $db->query($sql); $resql = $db->query($sql);
if ($resql) if ($resql)
{ {
$num = $db->num_rows($resql); $num = $db->num_rows($resql);
} else { } else {
dol_print_error($db); dol_print_error($db);
} }
$param = '&id='.$object->id; $param = '&id='.$object->id;
if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.$contextpage; if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.$contextpage;
if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.$limit; if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.$limit;
print '<form method="post" action="'.$_SERVER["PHP_SELF"].'" name="formfilter">'; print '<form method="post" action="'.$_SERVER["PHP_SELF"].'" name="formfilter">';
if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">'; if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
print '<input type="hidden" name="token" value="'.newToken().'">'; print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">'; print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
print '<input type="hidden" name="sortfield" value="'.$sortfield.'">'; print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
print '<input type="hidden" name="sortorder" value="'.$sortorder.'">'; print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
print '<input type="hidden" name="page" value="'.$page.'">'; print '<input type="hidden" name="page" value="'.$page.'">';
print '<input type="hidden" name="id" value="'.$object->id.'">'; print '<input type="hidden" name="id" value="'.$object->id.'">';
// List of notifications done // List of notifications done
print_barre_liste($langs->trans("ListOfNotificationsDone"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, '', 0, '', '', $limit); print_barre_liste($langs->trans("ListOfNotificationsDone"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, '', 0, '', '', $limit);
// Line with titles // Line with titles
print '<table width="100%" class="noborder">'; print '<table width="100%" class="noborder">';
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print_liste_field_titre("Target", $_SERVER["PHP_SELF"], "c.lastname,c.firstname", '', $param, '', $sortfield, $sortorder); print_liste_field_titre("Target", $_SERVER["PHP_SELF"], "c.lastname,c.firstname", '', $param, '', $sortfield, $sortorder);
print_liste_field_titre("Action", $_SERVER["PHP_SELF"], "", '', $param, '', $sortfield, $sortorder); print_liste_field_titre("Action", $_SERVER["PHP_SELF"], "", '', $param, '', $sortfield, $sortorder);
print_liste_field_titre("Type", $_SERVER["PHP_SELF"], "n.type", '', $param, '', $sortfield, $sortorder); print_liste_field_titre("Type", $_SERVER["PHP_SELF"], "n.type", '', $param, '', $sortfield, $sortorder);
//print_liste_field_titre("Object",$_SERVER["PHP_SELF"],"",'',$param,'"',$sortfield,$sortorder); //print_liste_field_titre("Object",$_SERVER["PHP_SELF"],"",'',$param,'"',$sortfield,$sortorder);
print_liste_field_titre("Date", $_SERVER["PHP_SELF"], "n.daten", '', $param, '', $sortfield, $sortorder, 'right '); print_liste_field_titre("Date", $_SERVER["PHP_SELF"], "n.daten", '', $param, '', $sortfield, $sortorder, 'right ');
print '</tr>'; print '</tr>';
if ($num) if ($num)
{ {
$i = 0; $i = 0;
$userstatic = new User($db); $userstatic = new User($db);
while ($i < $num) while ($i < $num)
{ {
$obj = $db->fetch_object($resql); $obj = $db->fetch_object($resql);
print '<tr class="oddeven"><td>'; print '<tr class="oddeven"><td>';
if ($obj->id > 0) if ($obj->id > 0)
{ {
$userstatic->id = $obj->id; $userstatic->id = $obj->id;
$userstatic->lastname = $obj->lastname; $userstatic->lastname = $obj->lastname;
$userstatic->firstname = $obj->firstname; $userstatic->firstname = $obj->firstname;
print $userstatic->getNomUrl(1); print $userstatic->getNomUrl(1);
print $obj->email ? ' &lt;'.$obj->email.'&gt;' : $langs->trans("NoMail"); print $obj->email ? ' &lt;'.$obj->email.'&gt;' : $langs->trans("NoMail");
} else { } else {
print $obj->email; print $obj->email;
} }
print '</td>'; print '</td>';
print '<td>'; print '<td>';
$label = ($langs->trans("Notify_".$obj->code) != "Notify_".$obj->code ? $langs->trans("Notify_".$obj->code) : $obj->label); $label = ($langs->trans("Notify_".$obj->code) != "Notify_".$obj->code ? $langs->trans("Notify_".$obj->code) : $obj->label);
print $label; print $label;
print '</td>'; print '</td>';
print '<td>'; print '<td>';
if ($obj->type == 'email') print $langs->trans("Email"); if ($obj->type == 'email') print $langs->trans("Email");
if ($obj->type == 'sms') print $langs->trans("Sms"); if ($obj->type == 'sms') print $langs->trans("Sms");
print '</td>'; print '</td>';
// TODO Add link to object here for other types // TODO Add link to object here for other types
/*print '<td>'; /*print '<td>';
if ($obj->object_type == 'order') if ($obj->object_type == 'order')
{ {
$orderstatic->id=$obj->object_id; $orderstatic->id=$obj->object_id;
@ -475,19 +475,19 @@ if ($result > 0)
print $orderstatic->getNomUrl(1); print $orderstatic->getNomUrl(1);
} }
print '</td>';*/ print '</td>';*/
// print // print
print'<td class="right">'.dol_print_date($db->jdate($obj->daten), 'dayhour').'</td>'; print'<td class="right">'.dol_print_date($db->jdate($obj->daten), 'dayhour').'</td>';
print '</tr>'; print '</tr>';
$i++; $i++;
} }
$db->free($resql); $db->free($resql);
} else { } else {
print '<tr><td colspan="4"><span class="opacitymedium">'.$langs->trans("None").'</span></td></tr>'; print '<tr><td colspan="4"><span class="opacitymedium">'.$langs->trans("None").'</span></td></tr>';
} }
print '</table>'; print '</table>';
print '</form>'; print '</form>';
} else dol_print_error('', 'RecordNotFound'); } else dol_print_error('', 'RecordNotFound');
// End of page // End of page

View File

@ -52,8 +52,8 @@ class WebsitePage extends CommonObject
/** /**
* @var int ID * @var int ID
*/ */
public $fk_website; public $fk_website;
public $pageurl; public $pageurl;
@ -106,14 +106,14 @@ class WebsitePage extends CommonObject
public $author_alias; public $author_alias;
/** /**
* @var string path of external object * @var string path of external object
*/ */
public $object_type; public $object_type;
/** /**
* @var string id of external object * @var string id of external object
*/ */
public $fk_object; public $fk_object;
const STATUS_DRAFT = 0; const STATUS_DRAFT = 0;
const STATUS_VALIDATED = 1; const STATUS_VALIDATED = 1;
@ -145,25 +145,25 @@ class WebsitePage extends CommonObject
// BEGIN MODULEBUILDER PROPERTIES // BEGIN MODULEBUILDER PROPERTIES
/** /**
* @var array Array with all fields and their property. Do not use it as a static var. It may be modified by constructor. * @var array Array with all fields and their property. Do not use it as a static var. It may be modified by constructor.
*/ */
public $fields = array( public $fields = array(
'rowid' =>array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'index'=>1, 'position'=>1, 'comment'=>'Id'), 'rowid' =>array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'index'=>1, 'position'=>1, 'comment'=>'Id'),
'pageurl' =>array('type'=>'varchar(16)', 'label'=>'WEBSITE_PAGENAME', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'index'=>1, 'position'=>10, 'searchall'=>1, 'comment'=>'Ref/alias of page'), 'pageurl' =>array('type'=>'varchar(16)', 'label'=>'WEBSITE_PAGENAME', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'index'=>1, 'position'=>10, 'searchall'=>1, 'comment'=>'Ref/alias of page'),
'aliasalt' =>array('type'=>'varchar(255)', 'label'=>'AliasAlt', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'index'=>0, 'position'=>11, 'searchall'=>0, 'comment'=>'Alias alternative of page'), 'aliasalt' =>array('type'=>'varchar(255)', 'label'=>'AliasAlt', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'index'=>0, 'position'=>11, 'searchall'=>0, 'comment'=>'Alias alternative of page'),
'type_container' =>array('type'=>'varchar(16)', 'label'=>'Type', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'index'=>0, 'position'=>12, 'comment'=>'Type of container'), 'type_container' =>array('type'=>'varchar(16)', 'label'=>'Type', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'index'=>0, 'position'=>12, 'comment'=>'Type of container'),
'title' =>array('type'=>'varchar(255)', 'label'=>'Label', 'enabled'=>1, 'visible'=>1, 'position'=>30, 'searchall'=>1, 'help'=>'UseTextBetween5And70Chars'), 'title' =>array('type'=>'varchar(255)', 'label'=>'Label', 'enabled'=>1, 'visible'=>1, 'position'=>30, 'searchall'=>1, 'help'=>'UseTextBetween5And70Chars'),
'description' =>array('type'=>'varchar(255)', 'label'=>'Description', 'enabled'=>1, 'visible'=>1, 'position'=>30, 'searchall'=>1), 'description' =>array('type'=>'varchar(255)', 'label'=>'Description', 'enabled'=>1, 'visible'=>1, 'position'=>30, 'searchall'=>1),
'image' =>array('type'=>'varchar(255)', 'label'=>'Image', 'enabled'=>1, 'visible'=>1, 'position'=>32, 'searchall'=>0, 'help'=>'Relative path of media. Used if Type is "blogpost"'), 'image' =>array('type'=>'varchar(255)', 'label'=>'Image', 'enabled'=>1, 'visible'=>1, 'position'=>32, 'searchall'=>0, 'help'=>'Relative path of media. Used if Type is "blogpost"'),
'keywords' =>array('type'=>'varchar(255)', 'label'=>'Keywords', 'enabled'=>1, 'visible'=>1, 'position'=>45, 'searchall'=>0), 'keywords' =>array('type'=>'varchar(255)', 'label'=>'Keywords', 'enabled'=>1, 'visible'=>1, 'position'=>45, 'searchall'=>0),
'lang' =>array('type'=>'varchar(6)', 'label'=>'Lang', 'enabled'=>1, 'notnull'=>-1, 'visible'=>1, 'position'=>45, 'searchall'=>0), 'lang' =>array('type'=>'varchar(6)', 'label'=>'Lang', 'enabled'=>1, 'notnull'=>-1, 'visible'=>1, 'position'=>45, 'searchall'=>0),
//'status' =>array('type'=>'integer', 'label'=>'Status', 'enabled'=>1, 'visible'=>1, 'index'=>true, 'position'=>1000), //'status' =>array('type'=>'integer', 'label'=>'Status', 'enabled'=>1, 'visible'=>1, 'index'=>true, 'position'=>1000),
'fk_website' =>array('type'=>'integer', 'label'=>'WebsiteId', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'position'=>40, 'searchall'=>0, 'foreignkey'=>'websitepage.rowid'), 'fk_website' =>array('type'=>'integer', 'label'=>'WebsiteId', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'position'=>40, 'searchall'=>0, 'foreignkey'=>'websitepage.rowid'),
'fk_page' =>array('type'=>'integer', 'label'=>'ParentPageId', 'enabled'=>1, 'visible'=>1, 'notnull'=>-1, 'position'=>45, 'searchall'=>0, 'foreignkey'=>'website.rowid'), 'fk_page' =>array('type'=>'integer', 'label'=>'ParentPageId', 'enabled'=>1, 'visible'=>1, 'notnull'=>-1, 'position'=>45, 'searchall'=>0, 'foreignkey'=>'website.rowid'),
'htmlheader' =>array('type'=>'text', 'label'=>'HtmlHeader', 'enabled'=>1, 'visible'=>0, 'position'=>50, 'searchall'=>0), 'htmlheader' =>array('type'=>'text', 'label'=>'HtmlHeader', 'enabled'=>1, 'visible'=>0, 'position'=>50, 'searchall'=>0),
'content' =>array('type'=>'mediumtext', 'label'=>'Content', 'enabled'=>1, 'visible'=>0, 'position'=>51, 'searchall'=>0), 'content' =>array('type'=>'mediumtext', 'label'=>'Content', 'enabled'=>1, 'visible'=>0, 'position'=>51, 'searchall'=>0),
'grabbed_from' =>array('type'=>'varchar(255)', 'label'=>'GrabbedFrom', 'enabled'=>1, 'visible'=>1, 'index'=>1, 'position'=>400, 'comment'=>'URL page content was grabbed from'), 'grabbed_from' =>array('type'=>'varchar(255)', 'label'=>'GrabbedFrom', 'enabled'=>1, 'visible'=>1, 'index'=>1, 'position'=>400, 'comment'=>'URL page content was grabbed from'),
'date_creation' =>array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>500), 'date_creation' =>array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>500),
'tms' =>array('type'=>'timestamp', 'label'=>'DateModification', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>501), 'tms' =>array('type'=>'timestamp', 'label'=>'DateModification', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>501),
//'date_valid' =>array('type'=>'datetime', 'label'=>'DateValidation', 'enabled'=>1, 'visible'=>-1, 'position'=>502), //'date_valid' =>array('type'=>'datetime', 'label'=>'DateValidation', 'enabled'=>1, 'visible'=>-1, 'position'=>502),
'fk_user_creat' =>array('type'=>'integer', 'label'=>'UserAuthor', 'enabled'=>1, 'visible'=>-1, 'notnull'=>true, 'position'=>510), 'fk_user_creat' =>array('type'=>'integer', 'label'=>'UserAuthor', 'enabled'=>1, 'visible'=>-1, 'notnull'=>true, 'position'=>510),
@ -172,7 +172,7 @@ class WebsitePage extends CommonObject
//'fk_user_valid' =>array('type'=>'integer', 'label'=>'UserValidation', 'enabled'=>1, 'visible'=>-1, 'position'=>512), //'fk_user_valid' =>array('type'=>'integer', 'label'=>'UserValidation', 'enabled'=>1, 'visible'=>-1, 'position'=>512),
'import_key' =>array('type'=>'varchar(14)', 'label'=>'ImportId', 'enabled'=>1, 'visible'=>-1, 'index'=>1, 'position'=>1000, 'notnull'=>-1), 'import_key' =>array('type'=>'varchar(14)', 'label'=>'ImportId', 'enabled'=>1, 'visible'=>-1, 'index'=>1, 'position'=>1000, 'notnull'=>-1),
'object_type' => array('type' => 'varchar(255)','label' => 'ObjectType', 'enabled'=>1, 'visible'=>1, 'position'=>46, 'searchall'=>0, 'help'=>''), 'object_type' => array('type' => 'varchar(255)','label' => 'ObjectType', 'enabled'=>1, 'visible'=>1, 'position'=>46, 'searchall'=>0, 'help'=>''),
'fk_object' => array('type' => 'varchar(255)','label' => 'ObjectId', 'enabled'=>1, 'visible'=>1, 'position'=>47, 'searchall'=>0, 'help'=>'') 'fk_object' => array('type' => 'varchar(255)','label' => 'ObjectId', 'enabled'=>1, 'visible'=>1, 'position'=>47, 'searchall'=>0, 'help'=>'')
); );
// END MODULEBUILDER PROPERTIES // END MODULEBUILDER PROPERTIES
@ -274,7 +274,7 @@ class WebsitePage extends CommonObject
$sql .= " t.fk_user_modif,"; $sql .= " t.fk_user_modif,";
$sql .= " t.import_key,"; $sql .= " t.import_key,";
$sql .= " t.object_type,"; $sql .= " t.object_type,";
$sql .= " t.fk_object"; $sql .= " t.fk_object";
$sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t'; $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t';
//$sql .= ' WHERE entity IN ('.getEntity('website').')'; // entity is on website level //$sql .= ' WHERE entity IN ('.getEntity('website').')'; // entity is on website level
$sql .= ' WHERE 1 = 1'; $sql .= ' WHERE 1 = 1';
@ -285,22 +285,22 @@ class WebsitePage extends CommonObject
else { else {
if ($id < 0) $sql .= ' AND t.rowid <> '.abs($id); if ($id < 0) $sql .= ' AND t.rowid <> '.abs($id);
if (null !== $website_id) { if (null !== $website_id) {
$sql .= " AND t.fk_website = '".$this->db->escape($website_id)."'"; $sql .= " AND t.fk_website = '".$this->db->escape($website_id)."'";
if ($page) { if ($page) {
$pagetouse = $page; $pagetouse = $page;
$langtouse = ''; $langtouse = '';
$tmppage = explode('/', $page); $tmppage = explode('/', $page);
if (!empty($tmppage[1])) { if (!empty($tmppage[1])) {
$pagetouse = $tmppage[1]; $pagetouse = $tmppage[1];
if (strlen($tmppage[0])) $langtouse = $tmppage[0]; if (strlen($tmppage[0])) $langtouse = $tmppage[0];
} }
$sql .= " AND t.pageurl = '".$this->db->escape($pagetouse)."'"; $sql .= " AND t.pageurl = '".$this->db->escape($pagetouse)."'";
if ($langtouse) $sql .= " AND t.lang = '".$this->db->escape($langtouse)."'"; if ($langtouse) $sql .= " AND t.lang = '".$this->db->escape($langtouse)."'";
} }
if ($aliasalt) $sql .= " AND (t.aliasalt LIKE '%,".$this->db->escape($aliasalt).",%' OR t.aliasalt LIKE '%, ".$this->db->escape($aliasalt).",%')"; if ($aliasalt) $sql .= " AND (t.aliasalt LIKE '%,".$this->db->escape($aliasalt).",%' OR t.aliasalt LIKE '%, ".$this->db->escape($aliasalt).",%')";
} }
} }
$sql .= $this->db->plimit(1); $sql .= $this->db->plimit(1);
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
if ($resql) { if ($resql) {
@ -334,7 +334,7 @@ class WebsitePage extends CommonObject
$this->fk_user_modif = $obj->fk_user_modif; $this->fk_user_modif = $obj->fk_user_modif;
$this->import_key = $obj->import_key; $this->import_key = $obj->import_key;
$this->object_type = $obj->object_type; $this->object_type = $obj->object_type;
$this->fk_object = $obj->fk_object; $this->fk_object = $obj->fk_object;
} }
$this->db->free($resql); $this->db->free($resql);
@ -392,7 +392,7 @@ class WebsitePage extends CommonObject
$sql .= " t.fk_user_modif,"; $sql .= " t.fk_user_modif,";
$sql .= " t.import_key,"; $sql .= " t.import_key,";
$sql .= " t.object_type,"; $sql .= " t.object_type,";
$sql .= " t.fk_object"; $sql .= " t.fk_object";
$sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t'; $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t';
$sql .= ' WHERE t.fk_website = '.$websiteid; $sql .= ' WHERE t.fk_website = '.$websiteid;
// Manage filter // Manage filter
@ -619,7 +619,7 @@ class WebsitePage extends CommonObject
} }
} }
if (! $error) { if (!$error) {
return 1; return 1;
} else { } else {
return -1; return -1;
@ -712,43 +712,43 @@ class WebsitePage extends CommonObject
* *
* @param int $withpicto Include picto in link (0=No picto, 1=Include picto into link, 2=Only picto) * @param int $withpicto Include picto in link (0=No picto, 1=Include picto into link, 2=Only picto)
* @param string $option On what the link point to * @param string $option On what the link point to
* @param integer $notooltip 1=Disable tooltip * @param integer $notooltip 1=Disable tooltip
* @param int $maxlen Max length of visible user name * @param int $maxlen Max length of visible user name
* @param string $morecss Add more css on link * @param string $morecss Add more css on link
* @return string String with URL * @return string String with URL
*/ */
public function getNomUrl($withpicto = 0, $option = '', $notooltip = 0, $maxlen = 24, $morecss = '') public function getNomUrl($withpicto = 0, $option = '', $notooltip = 0, $maxlen = 24, $morecss = '')
{ {
global $langs, $conf, $db; global $langs, $conf, $db;
global $dolibarr_main_authentication, $dolibarr_main_demo; global $dolibarr_main_authentication, $dolibarr_main_demo;
global $menumanager; global $menumanager;
$result = ''; $result = '';
$label = '<u>'.$langs->trans("Page").'</u>'; $label = '<u>'.$langs->trans("Page").'</u>';
$label .= '<br>'; $label .= '<br>';
$label .= '<b>'.$langs->trans('Ref').':</b> '.$this->ref.'<br>'; $label .= '<b>'.$langs->trans('Ref').':</b> '.$this->ref.'<br>';
$label .= '<b>'.$langs->trans('ID').':</b> '.$this->id.'<br>'; $label .= '<b>'.$langs->trans('ID').':</b> '.$this->id.'<br>';
$label .= '<b>'.$langs->trans('Title').':</b> '.$this->title.'<br>'; $label .= '<b>'.$langs->trans('Title').':</b> '.$this->title.'<br>';
$label .= '<b>'.$langs->trans('Language').':</b> '.$this->lang; $label .= '<b>'.$langs->trans('Language').':</b> '.$this->lang;
$url = DOL_URL_ROOT.'/website/index.php?websiteid='.$this->fk_website.'&pageid='.$this->id; $url = DOL_URL_ROOT.'/website/index.php?websiteid='.$this->fk_website.'&pageid='.$this->id;
$linkclose = ''; $linkclose = '';
if (empty($notooltip)) if (empty($notooltip))
{ {
if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER))
{ {
$label = $langs->trans("ShowMyObject"); $label = $langs->trans("ShowMyObject");
$linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"'; $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"';
} }
$linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"'; $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"';
$linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"'; $linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"';
} }
else $linkclose = ($morecss ? ' class="'.$morecss.'"' : ''); else $linkclose = ($morecss ? ' class="'.$morecss.'"' : '');
$linkstart = '<a href="'.$url.'"'; $linkstart = '<a href="'.$url.'"';
$linkstart .= $linkclose.'>'; $linkstart .= $linkclose.'>';
$linkend = '</a>'; $linkend = '</a>';
//$linkstart = $linkend = ''; //$linkstart = $linkend = '';
@ -772,7 +772,7 @@ class WebsitePage extends CommonObject
return $this->LibStatut($this->status, $mode); return $this->LibStatut($this->status, $mode);
} }
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/** /**
* Renvoi le libelle d'un status donne * Renvoi le libelle d'un status donne
* *
@ -782,7 +782,7 @@ class WebsitePage extends CommonObject
*/ */
public function LibStatut($status, $mode = 0) public function LibStatut($status, $mode = 0)
{ {
// phpcs:enable // phpcs:enable
global $langs; global $langs;
if (empty($this->labelStatus) || empty($this->labelStatusShort)) if (empty($this->labelStatus) || empty($this->labelStatusShort))

View File

@ -130,10 +130,10 @@ if ($pageid < 0) $pageid = 0;
if (($pageid > 0 || $pageref) && $action != 'addcontainer') if (($pageid > 0 || $pageref) && $action != 'addcontainer')
{ {
$res = $objectpage->fetch($pageid, ($object->id > 0 ? $object->id : null), $pageref); $res = $objectpage->fetch($pageid, ($object->id > 0 ? $object->id : null), $pageref);
if ($res == 0) if ($res == 0)
{ {
$res = $objectpage->fetch($pageid, ($object->id > 0 ? $object->id : null), null, $pageref); $res = $objectpage->fetch($pageid, ($object->id > 0 ? $object->id : null), null, $pageref);
} }
// Check if pageid is inside the new website, if not we reset param pageid // Check if pageid is inside the new website, if not we reset param pageid
if ($res >= 0 && $object->id > 0) if ($res >= 0 && $object->id > 0)
@ -303,28 +303,28 @@ $permissiontodelete = $user->rights->website->delete;
// Protections // Protections
if (GETPOST('refreshsite') || GETPOST('refreshsite_x') || GETPOST('refreshsite.x') || GETPOST('refreshpage') || GETPOST('refreshpage_x') || GETPOST('refreshpage.x')) if (GETPOST('refreshsite') || GETPOST('refreshsite_x') || GETPOST('refreshsite.x') || GETPOST('refreshpage') || GETPOST('refreshpage_x') || GETPOST('refreshpage.x'))
{ {
$action = 'preview'; // To avoid to make an action on another page or another site when we click on button to select another site or page. $action = 'preview'; // To avoid to make an action on another page or another site when we click on button to select another site or page.
} }
if (GETPOST('refreshsite', 'alpha') || GETPOST('refreshsite.x', 'alpha') || GETPOST('refreshsite_x', 'alpha')) // If we change the site, we reset the pageid and cancel addsite action. if (GETPOST('refreshsite', 'alpha') || GETPOST('refreshsite.x', 'alpha') || GETPOST('refreshsite_x', 'alpha')) // If we change the site, we reset the pageid and cancel addsite action.
{ {
if ($action == 'addsite') $action = 'preview'; if ($action == 'addsite') $action = 'preview';
if ($action == 'updatesource') $action = 'preview'; if ($action == 'updatesource') $action = 'preview';
$pageid = $object->fk_default_home; $pageid = $object->fk_default_home;
if (empty($pageid)) if (empty($pageid))
{ {
$array = $objectpage->fetchAll($object->id, 'ASC,ASC', 'type_container,pageurl'); $array = $objectpage->fetchAll($object->id, 'ASC,ASC', 'type_container,pageurl');
if (!is_array($array) && $array < 0) dol_print_error('', $objectpage->error, $objectpage->errors); if (!is_array($array) && $array < 0) dol_print_error('', $objectpage->error, $objectpage->errors);
$atleastonepage = (is_array($array) && count($array) > 0); $atleastonepage = (is_array($array) && count($array) > 0);
$firstpageid = 0; $homepageid = 0; $firstpageid = 0; $homepageid = 0;
foreach ($array as $key => $valpage) foreach ($array as $key => $valpage)
{ {
if (empty($firstpageid)) $firstpageid = $valpage->id; if (empty($firstpageid)) $firstpageid = $valpage->id;
if ($object->fk_default_home && $key == $object->fk_default_home) $homepageid = $valpage->id; if ($object->fk_default_home && $key == $object->fk_default_home) $homepageid = $valpage->id;
} }
$pageid = ($homepageid ? $homepageid : $firstpageid); // We choose home page and if not defined yet, we take first page $pageid = ($homepageid ? $homepageid : $firstpageid); // We choose home page and if not defined yet, we take first page
} }
} }
if (GETPOST('refreshpage', 'alpha') && !in_array($action, array('updatecss'))) $action = 'preview'; if (GETPOST('refreshpage', 'alpha') && !in_array($action, array('updatecss'))) $action = 'preview';
@ -529,9 +529,9 @@ if ($action == 'addsite')
$db->begin(); $db->begin();
if (GETPOST('virtualhost', 'alpha') && !preg_match('/^http/', GETPOST('virtualhost', 'alpha'))) if (GETPOST('virtualhost', 'alpha') && !preg_match('/^http/', GETPOST('virtualhost', 'alpha')))
{ {
$error++; $error++;
setEventMessages($langs->trans('ErrorURLMustStartWithHttp', $langs->transnoentitiesnoconv("VirtualHost")), null, 'errors'); setEventMessages($langs->trans('ErrorURLMustStartWithHttp', $langs->transnoentitiesnoconv("VirtualHost")), null, 'errors');
} }
if (!$error && !GETPOST('WEBSITE_REF', 'alpha')) if (!$error && !GETPOST('WEBSITE_REF', 'alpha'))
@ -1278,54 +1278,54 @@ if ($action == 'updatecss')
{ {
$tmpvirtualhost = preg_replace('/\/$/', '', GETPOST('virtualhost', 'alpha')); $tmpvirtualhost = preg_replace('/\/$/', '', GETPOST('virtualhost', 'alpha'));
if ($tmpvirtualhost && !preg_match('/^http/', $tmpvirtualhost)) if ($tmpvirtualhost && !preg_match('/^http/', $tmpvirtualhost))
{ {
$error++; $error++;
setEventMessages($langs->trans('ErrorURLMustStartWithHttp', $langs->transnoentitiesnoconv("VirtualHost")), null, 'errors'); setEventMessages($langs->trans('ErrorURLMustStartWithHttp', $langs->transnoentitiesnoconv("VirtualHost")), null, 'errors');
$action = 'editcss'; $action = 'editcss';
} }
if (!$error) if (!$error)
{ {
$arrayotherlang = explode(',', GETPOST('WEBSITE_OTHERLANG', 'alphanohtml')); $arrayotherlang = explode(',', GETPOST('WEBSITE_OTHERLANG', 'alphanohtml'));
foreach ($arrayotherlang as $key => $val) { foreach ($arrayotherlang as $key => $val) {
$arrayotherlang[$key] = substr(trim($val), 0, 2); // Kept short language code only $arrayotherlang[$key] = substr(trim($val), 0, 2); // Kept short language code only
} }
$object->virtualhost = $tmpvirtualhost; $object->virtualhost = $tmpvirtualhost;
$object->lang = GETPOST('WEBSITE_LANG', 'aZ09'); $object->lang = GETPOST('WEBSITE_LANG', 'aZ09');
$object->otherlang = join(',', $arrayotherlang); $object->otherlang = join(',', $arrayotherlang);
$object->use_manifest = GETPOST('use_manifest', 'alpha'); $object->use_manifest = GETPOST('use_manifest', 'alpha');
$result = $object->update($user); $result = $object->update($user);
if ($result < 0) if ($result < 0)
{ {
$error++; $error++;
setEventMessages($object->error, $object->errors, 'errors'); setEventMessages($object->error, $object->errors, 'errors');
$action = 'editcss'; $action = 'editcss';
} }
} }
} }
if (!$error) if (!$error)
{ {
// Save master.inc.php file // Save master.inc.php file
dol_syslog("Save master file ".$filemaster); dol_syslog("Save master file ".$filemaster);
dol_mkdir($pathofwebsite); dol_mkdir($pathofwebsite);
// Now generate the master.inc.php page // Now generate the master.inc.php page
$result = dolSaveMasterFile($filemaster); $result = dolSaveMasterFile($filemaster);
if (!$result) if (!$result)
{ {
$error++; $error++;
setEventMessages('Failed to write file '.$filemaster, null, 'errors'); setEventMessages('Failed to write file '.$filemaster, null, 'errors');
} }
// Html header file // Html header file
$htmlheadercontent = ''; $htmlheadercontent = '';
/* We disable php code since htmlheader is never executed as an include but only read by fgets_content. /* We disable php code since htmlheader is never executed as an include but only read by fgets_content.
$htmlheadercontent.= "<?php // BEGIN PHP\n"; $htmlheadercontent.= "<?php // BEGIN PHP\n";
$htmlheadercontent.= '$websitekey=basename(__DIR__);'."\n"; $htmlheadercontent.= '$websitekey=basename(__DIR__);'."\n";
$htmlheadercontent.= "if (! defined('USEDOLIBARRSERVER') && ! defined('USEDOLIBARREDITOR')) { require_once './master.inc.php'; } // Load env if not already loaded"."\n"; $htmlheadercontent.= "if (! defined('USEDOLIBARRSERVER') && ! defined('USEDOLIBARREDITOR')) { require_once './master.inc.php'; } // Load env if not already loaded"."\n";
@ -1335,84 +1335,84 @@ if ($action == 'updatecss')
// $htmlheadercontent.= "header('Content-type: text/html');\n"; // Not required. htmlheader.html is never call as a standalone page // $htmlheadercontent.= "header('Content-type: text/html');\n"; // Not required. htmlheader.html is never call as a standalone page
$htmlheadercontent.= "// END PHP ?>\n";*/ $htmlheadercontent.= "// END PHP ?>\n";*/
$htmlheadercontent .= preg_replace(array('/<html>\n*/ims', '/<\/html>\n*/ims'), array('', ''), GETPOST('WEBSITE_HTML_HEADER', 'none')); $htmlheadercontent .= preg_replace(array('/<html>\n*/ims', '/<\/html>\n*/ims'), array('', ''), GETPOST('WEBSITE_HTML_HEADER', 'none'));
/*$htmlheadercontent.= "\n".'<?php // BEGIN PHP'."\n"; /*$htmlheadercontent.= "\n".'<?php // BEGIN PHP'."\n";
$htmlheadercontent.= '$tmp = ob_get_contents(); ob_end_clean(); dolWebsiteOutput($tmp);'."\n"; $htmlheadercontent.= '$tmp = ob_get_contents(); ob_end_clean(); dolWebsiteOutput($tmp);'."\n";
$htmlheadercontent.= "// END PHP ?>"."\n";*/ $htmlheadercontent.= "// END PHP ?>"."\n";*/
$htmlheadercontent = trim($htmlheadercontent)."\n"; $htmlheadercontent = trim($htmlheadercontent)."\n";
$result = dolSaveHtmlHeader($filehtmlheader, $htmlheadercontent); $result = dolSaveHtmlHeader($filehtmlheader, $htmlheadercontent);
if (!$result) if (!$result)
{ {
$error++; $error++;
setEventMessages('Failed to write file '.$filehtmlheader, null, 'errors'); setEventMessages('Failed to write file '.$filehtmlheader, null, 'errors');
} }
// Css file // Css file
$csscontent = ''; $csscontent = '';
$csscontent .= "<?php // BEGIN PHP\n"; $csscontent .= "<?php // BEGIN PHP\n";
$csscontent .= '$websitekey=basename(__DIR__);'."\n"; $csscontent .= '$websitekey=basename(__DIR__);'."\n";
$csscontent .= "if (! defined('USEDOLIBARRSERVER') && ! defined('USEDOLIBARREDITOR')) { require_once __DIR__.'/master.inc.php'; } // Load env if not already loaded\n"; // For the css, we need to set path of master using the dirname of css file. $csscontent .= "if (! defined('USEDOLIBARRSERVER') && ! defined('USEDOLIBARREDITOR')) { require_once __DIR__.'/master.inc.php'; } // Load env if not already loaded\n"; // For the css, we need to set path of master using the dirname of css file.
$csscontent .= "require_once DOL_DOCUMENT_ROOT.'/core/lib/website.lib.php';\n"; $csscontent .= "require_once DOL_DOCUMENT_ROOT.'/core/lib/website.lib.php';\n";
$csscontent .= "require_once DOL_DOCUMENT_ROOT.'/core/website.inc.php';\n"; $csscontent .= "require_once DOL_DOCUMENT_ROOT.'/core/website.inc.php';\n";
$csscontent .= "ob_start();\n"; $csscontent .= "ob_start();\n";
$csscontent .= "if (! headers_sent()) { /* because file is included inline when in edit mode and we don't want warning */ \n"; $csscontent .= "if (! headers_sent()) { /* because file is included inline when in edit mode and we don't want warning */ \n";
$csscontent .= "header('Cache-Control: max-age=3600, public, must-revalidate');\n"; $csscontent .= "header('Cache-Control: max-age=3600, public, must-revalidate');\n";
$csscontent .= "header('Content-type: text/css');\n"; $csscontent .= "header('Content-type: text/css');\n";
$csscontent .= "}\n"; $csscontent .= "}\n";
$csscontent .= "// END PHP ?>\n"; $csscontent .= "// END PHP ?>\n";
$csscontent .= trim(GETPOST('WEBSITE_CSS_INLINE', 'none'))."\n"; $csscontent .= trim(GETPOST('WEBSITE_CSS_INLINE', 'none'))."\n";
$csscontent .= '<?php // BEGIN PHP'."\n"; $csscontent .= '<?php // BEGIN PHP'."\n";
$csscontent .= '$tmp = ob_get_contents(); ob_end_clean(); dolWebsiteOutput($tmp, "css");'."\n"; $csscontent .= '$tmp = ob_get_contents(); ob_end_clean(); dolWebsiteOutput($tmp, "css");'."\n";
$csscontent .= "// END PHP ?>\n"; $csscontent .= "// END PHP ?>\n";
dol_syslog("Save css content into ".$filecss); dol_syslog("Save css content into ".$filecss);
$result = dolSaveCssFile($filecss, $csscontent); $result = dolSaveCssFile($filecss, $csscontent);
if (!$result) if (!$result)
{ {
$error++; $error++;
setEventMessages('Failed to write file '.$filecss, null, 'errors'); setEventMessages('Failed to write file '.$filecss, null, 'errors');
} }
// Js file // Js file
$jscontent = ''; $jscontent = '';
$jscontent .= "<?php // BEGIN PHP\n"; $jscontent .= "<?php // BEGIN PHP\n";
$jscontent .= '$websitekey=basename(__DIR__);'."\n"; $jscontent .= '$websitekey=basename(__DIR__);'."\n";
$jscontent .= "if (! defined('USEDOLIBARRSERVER') && ! defined('USEDOLIBARREDITOR')) { require_once __DIR__.'/master.inc.php'; } // Load env if not already loaded\n"; // For the css, we need to set path of master using the dirname of css file. $jscontent .= "if (! defined('USEDOLIBARRSERVER') && ! defined('USEDOLIBARREDITOR')) { require_once __DIR__.'/master.inc.php'; } // Load env if not already loaded\n"; // For the css, we need to set path of master using the dirname of css file.
$jscontent .= "require_once DOL_DOCUMENT_ROOT.'/core/lib/website.lib.php';\n"; $jscontent .= "require_once DOL_DOCUMENT_ROOT.'/core/lib/website.lib.php';\n";
$jscontent .= "require_once DOL_DOCUMENT_ROOT.'/core/website.inc.php';\n"; $jscontent .= "require_once DOL_DOCUMENT_ROOT.'/core/website.inc.php';\n";
$jscontent .= "ob_start();\n"; $jscontent .= "ob_start();\n";
$jscontent .= "header('Cache-Control: max-age=3600, public, must-revalidate');\n"; $jscontent .= "header('Cache-Control: max-age=3600, public, must-revalidate');\n";
$jscontent .= "header('Content-type: application/javascript');\n"; $jscontent .= "header('Content-type: application/javascript');\n";
$jscontent .= "// END PHP ?>\n"; $jscontent .= "// END PHP ?>\n";
$jscontent .= trim(GETPOST('WEBSITE_JS_INLINE', 'none'))."\n"; $jscontent .= trim(GETPOST('WEBSITE_JS_INLINE', 'none'))."\n";
$jscontent .= '<?php // BEGIN PHP'."\n"; $jscontent .= '<?php // BEGIN PHP'."\n";
$jscontent .= '$tmp = ob_get_contents(); ob_end_clean(); dolWebsiteOutput($tmp, "js");'."\n"; $jscontent .= '$tmp = ob_get_contents(); ob_end_clean(); dolWebsiteOutput($tmp, "js");'."\n";
$jscontent .= "// END PHP ?>\n"; $jscontent .= "// END PHP ?>\n";
$result = dolSaveJsFile($filejs, $jscontent); $result = dolSaveJsFile($filejs, $jscontent);
if (!$result) if (!$result)
{ {
$error++; $error++;
setEventMessages('Failed to write file '.$filejs, null, 'errors'); setEventMessages('Failed to write file '.$filejs, null, 'errors');
} }
// Robot file // Robot file
$robotcontent = ''; $robotcontent = '';
/*$robotcontent.= "<?php // BEGIN PHP\n"; /*$robotcontent.= "<?php // BEGIN PHP\n";
$robotcontent.= '$websitekey=basename(__DIR__);'."\n"; $robotcontent.= '$websitekey=basename(__DIR__);'."\n";
$robotcontent.= "if (! defined('USEDOLIBARRSERVER') && ! defined('USEDOLIBARREDITOR')) { require_once './master.inc.php'; } // Load env if not already loaded"."\n"; $robotcontent.= "if (! defined('USEDOLIBARRSERVER') && ! defined('USEDOLIBARREDITOR')) { require_once './master.inc.php'; } // Load env if not already loaded"."\n";
$robotcontent.= "require_once DOL_DOCUMENT_ROOT.'/core/lib/website.lib.php';\n"; $robotcontent.= "require_once DOL_DOCUMENT_ROOT.'/core/lib/website.lib.php';\n";
@ -1422,63 +1422,63 @@ if ($action == 'updatecss')
$robotcontent.= "header('Content-type: text/css');\n"; $robotcontent.= "header('Content-type: text/css');\n";
$robotcontent.= "// END PHP ?>\n";*/ $robotcontent.= "// END PHP ?>\n";*/
$robotcontent .= trim(GETPOST('WEBSITE_ROBOT', 'restricthtml'))."\n"; $robotcontent .= trim(GETPOST('WEBSITE_ROBOT', 'restricthtml'))."\n";
/*$robotcontent.= "\n".'<?php // BEGIN PHP'."\n"; /*$robotcontent.= "\n".'<?php // BEGIN PHP'."\n";
$robotcontent.= '$tmp = ob_get_contents(); ob_end_clean(); dolWebsiteOutput($tmp, "robot");'."\n"; $robotcontent.= '$tmp = ob_get_contents(); ob_end_clean(); dolWebsiteOutput($tmp, "robot");'."\n";
$robotcontent.= "// END PHP ?>"."\n";*/ $robotcontent.= "// END PHP ?>"."\n";*/
$result = dolSaveRobotFile($filerobot, $robotcontent); $result = dolSaveRobotFile($filerobot, $robotcontent);
if (!$result) if (!$result)
{ {
$error++; $error++;
setEventMessages('Failed to write file '.$filerobot, null, 'errors'); setEventMessages('Failed to write file '.$filerobot, null, 'errors');
} }
// Htaccess file // Htaccess file
$htaccesscontent = ''; $htaccesscontent = '';
$htaccesscontent .= trim(GETPOST('WEBSITE_HTACCESS', 'restricthtml'))."\n"; $htaccesscontent .= trim(GETPOST('WEBSITE_HTACCESS', 'restricthtml'))."\n";
$result = dolSaveHtaccessFile($filehtaccess, $htaccesscontent); $result = dolSaveHtaccessFile($filehtaccess, $htaccesscontent);
if (!$result) if (!$result)
{ {
$error++; $error++;
setEventMessages('Failed to write file '.$filehtaccess, null, 'errors'); setEventMessages('Failed to write file '.$filehtaccess, null, 'errors');
} }
// manifest.json file // manifest.json file
$manifestjsoncontent = ''; $manifestjsoncontent = '';
$manifestjsoncontent .= "<?php // BEGIN PHP\n"; $manifestjsoncontent .= "<?php // BEGIN PHP\n";
$manifestjsoncontent .= '$websitekey=basename(__DIR__);'."\n"; $manifestjsoncontent .= '$websitekey=basename(__DIR__);'."\n";
$manifestjsoncontent .= "if (! defined('USEDOLIBARRSERVER') && ! defined('USEDOLIBARREDITOR')) { require_once __DIR__.'/master.inc.php'; } // Load env if not already loaded\n"; // For the css, we need to set path of master using the dirname of css file. $manifestjsoncontent .= "if (! defined('USEDOLIBARRSERVER') && ! defined('USEDOLIBARREDITOR')) { require_once __DIR__.'/master.inc.php'; } // Load env if not already loaded\n"; // For the css, we need to set path of master using the dirname of css file.
$manifestjsoncontent .= "require_once DOL_DOCUMENT_ROOT.'/core/lib/website.lib.php';\n"; $manifestjsoncontent .= "require_once DOL_DOCUMENT_ROOT.'/core/lib/website.lib.php';\n";
$manifestjsoncontent .= "require_once DOL_DOCUMENT_ROOT.'/core/website.inc.php';\n"; $manifestjsoncontent .= "require_once DOL_DOCUMENT_ROOT.'/core/website.inc.php';\n";
$manifestjsoncontent .= "ob_start();\n"; $manifestjsoncontent .= "ob_start();\n";
$manifestjsoncontent .= "header('Cache-Control: max-age=3600, public, must-revalidate');\n"; $manifestjsoncontent .= "header('Cache-Control: max-age=3600, public, must-revalidate');\n";
$manifestjsoncontent .= "header('Content-type: application/manifest+json');\n"; $manifestjsoncontent .= "header('Content-type: application/manifest+json');\n";
$manifestjsoncontent .= "// END PHP ?>\n"; $manifestjsoncontent .= "// END PHP ?>\n";
$manifestjsoncontent .= trim(GETPOST('WEBSITE_MANIFEST_JSON', 'none'))."\n"; $manifestjsoncontent .= trim(GETPOST('WEBSITE_MANIFEST_JSON', 'none'))."\n";
$manifestjsoncontent .= '<?php // BEGIN PHP'."\n"; $manifestjsoncontent .= '<?php // BEGIN PHP'."\n";
$manifestjsoncontent .= '$tmp = ob_get_contents(); ob_end_clean(); dolWebsiteOutput($tmp, "manifest");'."\n"; $manifestjsoncontent .= '$tmp = ob_get_contents(); ob_end_clean(); dolWebsiteOutput($tmp, "manifest");'."\n";
$manifestjsoncontent .= "// END PHP ?>\n"; $manifestjsoncontent .= "// END PHP ?>\n";
$result = dolSaveManifestJson($filemanifestjson, $manifestjsoncontent); $result = dolSaveManifestJson($filemanifestjson, $manifestjsoncontent);
if (!$result) if (!$result)
{ {
$error++; $error++;
setEventMessages('Failed to write file '.$filemanifestjson, null, 'errors'); setEventMessages('Failed to write file '.$filemanifestjson, null, 'errors');
} }
// README.md file // README.md file
$readmecontent = ''; $readmecontent = '';
/*$readmecontent.= "<?php // BEGIN PHP\n"; /*$readmecontent.= "<?php // BEGIN PHP\n";
$readmecontent.= '$websitekey=basename(__DIR__);'."\n"; $readmecontent.= '$websitekey=basename(__DIR__);'."\n";
$readmecontent.= "if (! defined('USEDOLIBARRSERVER') && ! defined('USEDOLIBARREDITOR')) { require_once __DIR__.'/master.inc.php'; } // Load env if not already loaded"."\n"; // For the css, we need to set path of master using the dirname of css file. $readmecontent.= "if (! defined('USEDOLIBARRSERVER') && ! defined('USEDOLIBARREDITOR')) { require_once __DIR__.'/master.inc.php'; } // Load env if not already loaded"."\n"; // For the css, we need to set path of master using the dirname of css file.
$readmecontent.= "require_once DOL_DOCUMENT_ROOT.'/core/lib/website.lib.php';\n"; $readmecontent.= "require_once DOL_DOCUMENT_ROOT.'/core/lib/website.lib.php';\n";
@ -1488,42 +1488,42 @@ if ($action == 'updatecss')
$readmecontent.= "header('Content-type: application/manifest+json');\n"; $readmecontent.= "header('Content-type: application/manifest+json');\n";
$readmecontent.= "// END PHP ?>\n";*/ $readmecontent.= "// END PHP ?>\n";*/
$readmecontent .= trim(GETPOST('WEBSITE_README', 'restricthtml'))."\n"; $readmecontent .= trim(GETPOST('WEBSITE_README', 'restricthtml'))."\n";
/*$readmecontent.= '<?php // BEGIN PHP'."\n"; /*$readmecontent.= '<?php // BEGIN PHP'."\n";
$readmecontent.= '$tmp = ob_get_contents(); ob_end_clean(); dolWebsiteOutput($tmp, "manifest");'."\n"; $readmecontent.= '$tmp = ob_get_contents(); ob_end_clean(); dolWebsiteOutput($tmp, "manifest");'."\n";
$readmecontent.= "// END PHP ?>"."\n";*/ $readmecontent.= "// END PHP ?>"."\n";*/
$result = dolSaveReadme($filereadme, $readmecontent); $result = dolSaveReadme($filereadme, $readmecontent);
if (!$result) if (!$result)
{ {
$error++; $error++;
setEventMessages('Failed to write file '.$filereadme, null, 'errors'); setEventMessages('Failed to write file '.$filereadme, null, 'errors');
} }
// Save wrapper.php // Save wrapper.php
$result = dolSaveIndexPage($pathofwebsite, '', '', $filewrapper); $result = dolSaveIndexPage($pathofwebsite, '', '', $filewrapper);
// Message if no error // Message if no error
if (!$error) if (!$error)
{ {
setEventMessages($langs->trans("Saved"), null, 'mesgs'); setEventMessages($langs->trans("Saved"), null, 'mesgs');
} }
if (!GETPOSTISSET('updateandstay')) // If we click on "Save And Stay", we don not make the redirect if (!GETPOSTISSET('updateandstay')) // If we click on "Save And Stay", we don not make the redirect
{ {
$action = 'preview'; $action = 'preview';
if ($backtopage) if ($backtopage)
{ {
header("Location: ".$backtopage); header("Location: ".$backtopage);
exit; exit;
} }
} }
else { else {
$action = 'editcss'; $action = 'editcss';
} }
} }
} }
} }
@ -1660,7 +1660,7 @@ if ($action == 'updatemeta')
$objectpage->fk_page = (GETPOST('pageidfortranslation', 'int') > 0 ? GETPOST('pageidfortranslation', 'int') : 0); $objectpage->fk_page = (GETPOST('pageidfortranslation', 'int') > 0 ? GETPOST('pageidfortranslation', 'int') : 0);
$objectpage->author_alias = trim(GETPOST('WEBSITE_AUTHORALIAS', 'alphanohtml')); $objectpage->author_alias = trim(GETPOST('WEBSITE_AUTHORALIAS', 'alphanohtml'));
$objectpage->object_type = GETPOST('WEBSITE_OBJECTCLASS', 'alpha'); $objectpage->object_type = GETPOST('WEBSITE_OBJECTCLASS', 'alpha');
$objectpage->fk_object = GETPOST('WEBSITE_OBJECTID', 'aZ09'); $objectpage->fk_object = GETPOST('WEBSITE_OBJECTID', 'aZ09');
$newdatecreation = dol_mktime(GETPOST('datecreationhour', 'int'), GETPOST('datecreationmin', 'int'), GETPOST('datecreationsec', 'int'), GETPOST('datecreationmonth', 'int'), GETPOST('datecreationday', 'int'), GETPOST('datecreationyear', 'int')); $newdatecreation = dol_mktime(GETPOST('datecreationhour', 'int'), GETPOST('datecreationmin', 'int'), GETPOST('datecreationsec', 'int'), GETPOST('datecreationmonth', 'int'), GETPOST('datecreationday', 'int'), GETPOST('datecreationyear', 'int'));
if ($newdatecreation) $objectpage->date_creation = $newdatecreation; if ($newdatecreation) $objectpage->date_creation = $newdatecreation;
@ -1932,35 +1932,35 @@ if (($action == 'updatesource' || $action == 'updatecontent' || $action == 'conf
$objectpage->content = GETPOST('PAGE_CONTENT', 'none'); $objectpage->content = GETPOST('PAGE_CONTENT', 'none');
// Security analysis // Security analysis
$phpfullcodestring = dolKeepOnlyPhpCode($objectpage->content); $phpfullcodestring = dolKeepOnlyPhpCode($objectpage->content);
//print dol_escape_htmltag($phpfullcodestring);exit; //print dol_escape_htmltag($phpfullcodestring);exit;
$forbiddenphpcommands = array("exec", "passthru", "system", "shell_exec", "proc_open"); $forbiddenphpcommands = array("exec", "passthru", "system", "shell_exec", "proc_open");
if (empty($conf->global->WEBSITE_PHP_ALLOW_WRITE)) // If option is not on, we disallow functions to write files if (empty($conf->global->WEBSITE_PHP_ALLOW_WRITE)) // If option is not on, we disallow functions to write files
{ {
$forbiddenphpcommands = array_merge($forbiddenphpcommands, array("fopen", "file_put_contents", "fputs", "fputscsv", "fwrite", "fpassthru", "unlink", "mkdir", "rmdir", "symlink", "touch", "umask")); $forbiddenphpcommands = array_merge($forbiddenphpcommands, array("fopen", "file_put_contents", "fputs", "fputscsv", "fwrite", "fpassthru", "unlink", "mkdir", "rmdir", "symlink", "touch", "umask"));
} }
foreach ($forbiddenphpcommands as $forbiddenphpcommand) foreach ($forbiddenphpcommands as $forbiddenphpcommand)
{ {
if (preg_match('/'.$forbiddenphpcommand.'\s*\(/ms', $phpfullcodestring)) if (preg_match('/'.$forbiddenphpcommand.'\s*\(/ms', $phpfullcodestring))
{ {
$error++; $error++;
setEventMessages($langs->trans("DynamicPHPCodeContainsAForbiddenInstruction", $forbiddenphpcommand), null, 'errors'); setEventMessages($langs->trans("DynamicPHPCodeContainsAForbiddenInstruction", $forbiddenphpcommand), null, 'errors');
if ($action == 'updatesource') $action = 'editsource'; if ($action == 'updatesource') $action = 'editsource';
if ($action == 'updatecontent') $action = 'editcontent'; if ($action == 'updatecontent') $action = 'editcontent';
} }
} }
if (empty($user->rights->website->writephp)) if (empty($user->rights->website->writephp))
{ {
if ($phpfullcodestringold != $phpfullcodestring) if ($phpfullcodestringold != $phpfullcodestring)
{ {
$error++; $error++;
setEventMessages($langs->trans("NotAllowedToAddDynamicContent"), null, 'errors'); setEventMessages($langs->trans("NotAllowedToAddDynamicContent"), null, 'errors');
if ($action == 'updatesource') $action = 'editsource'; if ($action == 'updatesource') $action = 'editsource';
if ($action == 'updatecontent') $action = 'editcontent'; if ($action == 'updatecontent') $action = 'editcontent';
} }
} }
// Clean data. We remove all the head section. // Clean data. We remove all the head section.
$objectpage->content = preg_replace('/<head>.*<\/head>/ims', '', $objectpage->content); $objectpage->content = preg_replace('/<head>.*<\/head>/ims', '', $objectpage->content);
@ -2434,28 +2434,28 @@ if (!GETPOST('hide_websitemenu'))
$htmltext = ''; $htmltext = '';
if (empty($object->fk_default_home)) if (empty($object->fk_default_home))
{ {
$htmltext .= '<br><span class="error">'.$langs->trans("YouMustDefineTheHomePage").'</span><br><br>'; $htmltext .= '<br><span class="error">'.$langs->trans("YouMustDefineTheHomePage").'</span><br><br>';
} }
elseif (empty($virtualurl)) elseif (empty($virtualurl))
{ {
//$htmltext .= '<br><span class="error">'.$langs->trans("VirtualHostUrlNotDefined").'</span><br><br>'; //$htmltext .= '<br><span class="error">'.$langs->trans("VirtualHostUrlNotDefined").'</span><br><br>';
} }
else { else {
$htmltext .= '<br><center>'.$langs->trans("GoTo").' <a href="'.$virtualurl.'" target="_website">'.$virtualurl.'</a></center><br>'; $htmltext .= '<br><center>'.$langs->trans("GoTo").' <a href="'.$virtualurl.'" target="_website">'.$virtualurl.'</a></center><br>';
} }
if (!empty($conf->global->WEBSITE_REPLACE_INFO_ABOUT_USAGE_WITH_WEBSERVER)) if (!empty($conf->global->WEBSITE_REPLACE_INFO_ABOUT_USAGE_WITH_WEBSERVER))
{ {
$htmltext .= '<br>'.$langs->trans($conf->global->WEBSITE_REPLACE_INFO_ABOUT_USAGE_WITH_WEBSERVER); $htmltext .= '<br>'.$langs->trans($conf->global->WEBSITE_REPLACE_INFO_ABOUT_USAGE_WITH_WEBSERVER);
} }
else { else {
$htmltext .= $langs->trans("SetHereVirtualHost", $dataroot); $htmltext .= $langs->trans("SetHereVirtualHost", $dataroot);
$htmltext .= '<br>'; $htmltext .= '<br>';
$htmltext .= '<br>'.$langs->trans("CheckVirtualHostPerms", $langs->transnoentitiesnoconv("ReadPerm"), DOL_DOCUMENT_ROOT); $htmltext .= '<br>'.$langs->trans("CheckVirtualHostPerms", $langs->transnoentitiesnoconv("ReadPerm"), DOL_DOCUMENT_ROOT);
$htmltext .= '<br>'.$langs->trans("CheckVirtualHostPerms", $langs->transnoentitiesnoconv("WritePerm"), DOL_DATA_ROOT.'/website<br>'.DOL_DATA_ROOT.'/medias'); $htmltext .= '<br>'.$langs->trans("CheckVirtualHostPerms", $langs->transnoentitiesnoconv("WritePerm"), DOL_DATA_ROOT.'/website<br>'.DOL_DATA_ROOT.'/medias');
$examplewithapache = '#php_admin_value open_basedir /tmp/:'.DOL_DOCUMENT_ROOT.':'.DOL_DATA_ROOT.':/dev/urandom'."\n"; $examplewithapache = '#php_admin_value open_basedir /tmp/:'.DOL_DOCUMENT_ROOT.':'.DOL_DATA_ROOT.':/dev/urandom'."\n";
$examplewithapache .= '<Directory "'.DOL_DOCUMENT_ROOT.'">'."\n"; $examplewithapache .= '<Directory "'.DOL_DOCUMENT_ROOT.'">'."\n";
$examplewithapache .= 'AllowOverride FileInfo Options $examplewithapache .= 'AllowOverride FileInfo Options
Options -Indexes -MultiViews -FollowSymLinks -ExecCGI Options -Indexes -MultiViews -FollowSymLinks -ExecCGI
Require all granted Require all granted
</Directory> </Directory>
@ -2470,14 +2470,14 @@ if (!GETPOST('hide_websitemenu'))
Require all granted Require all granted
</Directory>'; </Directory>';
$htmltext .= '<br>'.$langs->trans("ExampleToUseInApacheVirtualHostConfig").':<br>'; $htmltext .= '<br>'.$langs->trans("ExampleToUseInApacheVirtualHostConfig").':<br>';
$htmltext .= '<div class="centpercent exampleapachesetup">'.dol_nl2br(dol_escape_htmltag($examplewithapache, 1, 1)).'</div>'; $htmltext .= '<div class="centpercent exampleapachesetup">'.dol_nl2br(dol_escape_htmltag($examplewithapache, 1, 1)).'</div>';
$htmltext .= '<br>'; $htmltext .= '<br>';
$htmltext .= $langs->trans("YouCanAlsoTestWithPHPS", $dataroot); $htmltext .= $langs->trans("YouCanAlsoTestWithPHPS", $dataroot);
$htmltext .= '<br>'; $htmltext .= '<br>';
$htmltext .= '<br>'; $htmltext .= '<br>';
$htmltext .= $langs->trans("YouCanAlsoDeployToAnotherWHP"); $htmltext .= $langs->trans("YouCanAlsoDeployToAnotherWHP");
} }
print $form->textwithpicto($linktotestonwebserver, $htmltext, 1, 'none', 'valignmiddle', 0, 3, 'helpvirtualhost'); print $form->textwithpicto($linktotestonwebserver, $htmltext, 1, 'none', 'valignmiddle', 0, 3, 'helpvirtualhost');
print '</span>'; print '</span>';
@ -2818,14 +2818,14 @@ if (!GETPOST('hide_websitemenu'))
$htmltext .= $langs->transnoentitiesnoconv("YouCanEditHtmlSource2", $url); $htmltext .= $langs->transnoentitiesnoconv("YouCanEditHtmlSource2", $url);
$htmltext .= $langs->transnoentitiesnoconv("YouCanEditHtmlSourceMore", $url); $htmltext .= $langs->transnoentitiesnoconv("YouCanEditHtmlSourceMore", $url);
$htmltext .= '<br>'; $htmltext .= '<br>';
if ($conf->browser->layout == 'phone') if ($conf->browser->layout == 'phone')
{ {
print $form->textwithpicto('', $htmltext, 1, 'help', 'inline-block', 1, 2, 'tooltipsubstitution'); print $form->textwithpicto('', $htmltext, 1, 'help', 'inline-block', 1, 2, 'tooltipsubstitution');
} }
else { else {
//img_help(($tooltiptrigger != '' ? 2 : 1), $alt) //img_help(($tooltiptrigger != '' ? 2 : 1), $alt)
print $form->textwithpicto($langs->trans("SyntaxHelp").' '.img_help(2, $langs->trans("SyntaxHelp")), $htmltext, 1, 'none', 'inline-block', 1, 2, 'tooltipsubstitution'); print $form->textwithpicto($langs->trans("SyntaxHelp").' '.img_help(2, $langs->trans("SyntaxHelp")), $htmltext, 1, 'none', 'inline-block', 1, 2, 'tooltipsubstitution');
} }
} }
print '</span>'; // end websitehelp print '</span>'; // end websitehelp
@ -3566,16 +3566,16 @@ if ($action == 'editmeta' || $action == 'createcontainer')
} }
print '<tr><td class="titlefieldcreate">'; print '<tr><td class="titlefieldcreate">';
print 'ObjectClass'; print 'ObjectClass';
print '</td><td>'; print '</td><td>';
print '<input type="text" class="flat minwidth300" name="WEBSITE_OBJECTCLASS" placeholder="ClassName::/path/class/ObjectClass.class.php" >'; print '<input type="text" class="flat minwidth300" name="WEBSITE_OBJECTCLASS" placeholder="ClassName::/path/class/ObjectClass.class.php" >';
print '</td></tr>'; print '</td></tr>';
print '<tr><td class="titlefieldcreate">'; print '<tr><td class="titlefieldcreate">';
print 'ObjectID'; print 'ObjectID';
print '</td><td>'; print '</td><td>';
print '<input type="text" class="flat minwidth300" name="WEBSITE_OBJECTID" >'; print '<input type="text" class="flat minwidth300" name="WEBSITE_OBJECTID" >';
print '</td></tr>'; print '</td></tr>';
$fuser = new User($db); $fuser = new User($db);
@ -3585,8 +3585,8 @@ if ($action == 'editmeta' || $action == 'createcontainer')
print '</td><td>'; print '</td><td>';
if ($pageauthorid > 0) if ($pageauthorid > 0)
{ {
$fuser->fetch($pageauthorid); $fuser->fetch($pageauthorid);
print $fuser->getNomUrl(1); print $fuser->getNomUrl(1);
} else { } else {
print '<span class="opacitymedium">'.$langs->trans("Unknown").'</span>'; print '<span class="opacitymedium">'.$langs->trans("Unknown").'</span>';
} }
@ -3607,17 +3607,17 @@ if ($action == 'editmeta' || $action == 'createcontainer')
if ($action != 'createcontainer') if ($action != 'createcontainer')
{ {
print '<tr><td>'; print '<tr><td>';
print $langs->trans('UserModif'); print $langs->trans('UserModif');
print '</td><td>'; print '</td><td>';
if ($pageusermodifid > 0) if ($pageusermodifid > 0)
{ {
$fuser->fetch($pageusermodifid); $fuser->fetch($pageusermodifid);
print $fuser->getNomUrl(1); print $fuser->getNomUrl(1);
} }
print '</td></tr>'; print '</td></tr>';
print '<tr><td>'; print '<tr><td>';
print $langs->trans('DateModification'); print $langs->trans('DateModification');
print '</td><td>'; print '</td><td>';
print dol_print_date($pagedatemodification, 'dayhour', 'tzuser'); print dol_print_date($pagedatemodification, 'dayhour', 'tzuser');
@ -4232,7 +4232,7 @@ if ($action == 'preview' || $action == 'createfromclone' || $action == 'createpa
// Change the contenteditable to "true" or "false" when mode Edit Inline is on or off // Change the contenteditable to "true" or "false" when mode Edit Inline is on or off
if (empty($conf->global->WEBSITE_EDITINLINE)) if (empty($conf->global->WEBSITE_EDITINLINE))
{ {
// Remove the contenteditable="true" // Remove the contenteditable="true"
$newcontent = preg_replace('/(div|section)(\s[^\>]*)contenteditable="true"/', '\1\2', $newcontent); $newcontent = preg_replace('/(div|section)(\s[^\>]*)contenteditable="true"/', '\1\2', $newcontent);
} }
else { else {

View File

@ -55,7 +55,7 @@ $search_all = GETPOST("search_all", 'alpha');
$search = array(); $search = array();
foreach ($object->fields as $key => $val) foreach ($object->fields as $key => $val)
{ {
if (GETPOST('search_'.$key, 'alpha')) $search[$key] = GETPOST('search_'.$key, 'alpha'); if (GETPOST('search_'.$key, 'alpha')) $search[$key] = GETPOST('search_'.$key, 'alpha');
} }
if (empty($action) && empty($id) && empty($ref)) $action = 'view'; if (empty($action) && empty($id) && empty($ref)) $action = 'view';
@ -198,7 +198,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
{ {
if ($object->fk_soc > 0 && empty($socid)) $socid = $object->fk_soc; if ($object->fk_soc > 0 && empty($socid)) $socid = $object->fk_soc;
$res = $object->fetch_optionals(); $res = $object->fetch_optionals();
$head = websiteaccountPrepareHead($object); $head = websiteaccountPrepareHead($object);
dol_fiche_head($head, 'card', $langs->trans("WebsiteAccount"), -1, 'websiteaccount@website'); dol_fiche_head($head, 'card', $langs->trans("WebsiteAccount"), -1, 'websiteaccount@website');
@ -207,7 +207,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
// Confirmation to delete // Confirmation to delete
if ($action == 'delete') { if ($action == 'delete') {
$formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('DeleteWebsiteAccount'), $langs->trans('ConfirmDeleteWebsiteAccount'), 'confirm_delete', '', 0, 1); $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('DeleteWebsiteAccount'), $langs->trans('ConfirmDeleteWebsiteAccount'), 'confirm_delete', '', 0, 1);
} }
// Call Hook formConfirm // Call Hook formConfirm
@ -298,24 +298,24 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
// Buttons for actions // Buttons for actions
if ($action != 'presend' && $action != 'editline') { if ($action != 'presend' && $action != 'editline') {
print '<div class="tabsAction">'."\n"; print '<div class="tabsAction">'."\n";
$parameters = array(); $parameters = array();
$reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
if (empty($reshook)) if (empty($reshook))
{ {
// Send // Send
if (empty($user->socid)) { if (empty($user->socid)) {
print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=presend&mode=init#formmailbeforetitle">'.$langs->trans('SendMail').'</a></div>'."\n"; print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=presend&mode=init#formmailbeforetitle">'.$langs->trans('SendMail').'</a></div>'."\n";
} }
if ($user->rights->website->write) if ($user->rights->website->write)
{ {
print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=edit">'.$langs->trans("Modify").'</a></div>'."\n"; print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=edit">'.$langs->trans("Modify").'</a></div>'."\n";
} }
/* /*
if ($user->rights->sellyoursaas->create) if ($user->rights->sellyoursaas->create)
{ {
if ($object->status == 1) if ($object->status == 1)
@ -329,28 +329,28 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
} }
*/ */
if ($user->rights->website->delete) if ($user->rights->website->delete)
{ {
print '<div class="inline-block divButAction"><a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=delete&amp;token='.newToken().'">'.$langs->trans('Delete').'</a></div>'."\n"; print '<div class="inline-block divButAction"><a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=delete&amp;token='.newToken().'">'.$langs->trans('Delete').'</a></div>'."\n";
} }
} }
print '</div>'."\n"; print '</div>'."\n";
} }
// Select mail models is same action as presend // Select mail models is same action as presend
if (GETPOST('modelselected')) { if (GETPOST('modelselected')) {
$action = 'presend'; $action = 'presend';
} }
if ($action != 'presend') if ($action != 'presend')
{ {
print '<div class="fichecenter"><div class="fichehalfleft">'; print '<div class="fichecenter"><div class="fichehalfleft">';
print '<a name="builddoc"></a>'; // ancre print '<a name="builddoc"></a>'; // ancre
print '</div><div class="fichehalfright"><div class="ficheaddleft">'; print '</div><div class="fichehalfright"><div class="ficheaddleft">';
/* /*
$MAXEVENT = 10; $MAXEVENT = 10;
// List of actions on element // List of actions on element
@ -359,7 +359,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
$somethingshown = $formactions->showactions($object, 'websiteaccount', $socid, 1, '', $MAXEVENT); $somethingshown = $formactions->showactions($object, 'websiteaccount', $socid, 1, '', $MAXEVENT);
*/ */
print '</div></div></div>'; print '</div></div></div>';
} }
// Presend form // Presend form

View File

@ -82,31 +82,31 @@ $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
if (empty($reshook)) { if (empty($reshook)) {
$error = 0; $error = 0;
$permissiontoadd = $user->rights->mymodule->write; $permissiontoadd = $user->rights->mymodule->write;
$permissiontodelete = $user->rights->mymodule->delete || ($permissiontoadd && $object->status == 0); $permissiontodelete = $user->rights->mymodule->delete || ($permissiontoadd && $object->status == 0);
$backurlforlist = dol_buildpath('/mymodule/myobject_list.php', 1); $backurlforlist = dol_buildpath('/mymodule/myobject_list.php', 1);
if (empty($backtopage)) { if (empty($backtopage)) {
if (empty($id)) $backtopage = $backurlforlist; if (empty($id)) $backtopage = $backurlforlist;
else $backtopage = dol_buildpath('/mymodule/myobject_card.php', 1).($id > 0 ? $id : '__ID__'); else $backtopage = dol_buildpath('/mymodule/myobject_card.php', 1).($id > 0 ? $id : '__ID__');
} }
$triggermodname = 'MYMODULE_MYOBJECT_MODIFY'; // Name of trigger action code to execute when we modify record $triggermodname = 'MYMODULE_MYOBJECT_MODIFY'; // Name of trigger action code to execute when we modify record
// Actions cancel, add, update, delete or clone // Actions cancel, add, update, delete or clone
include DOL_DOCUMENT_ROOT.'/core/actions_addupdatedelete.inc.php'; include DOL_DOCUMENT_ROOT.'/core/actions_addupdatedelete.inc.php';
// Actions when linking object each other // Actions when linking object each other
include DOL_DOCUMENT_ROOT.'/core/actions_dellink.inc.php'; include DOL_DOCUMENT_ROOT.'/core/actions_dellink.inc.php';
// Actions when printing a doc from card // Actions when printing a doc from card
include DOL_DOCUMENT_ROOT.'/core/actions_printing.inc.php'; include DOL_DOCUMENT_ROOT.'/core/actions_printing.inc.php';
// Actions to send emails // Actions to send emails
$triggersendname = 'MYOBJECT_SENTBYMAIL'; $triggersendname = 'MYOBJECT_SENTBYMAIL';
$autocopy = 'MAIN_MAIL_AUTOCOPY_MYOBJECT_TO'; $autocopy = 'MAIN_MAIL_AUTOCOPY_MYOBJECT_TO';
$trackid = 'myobject'.$object->id; $trackid = 'myobject'.$object->id;
include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php'; include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php';
} }
@ -176,7 +176,7 @@ if (($id || $ref) && $action == 'edit') {
print load_fiche_titre($langs->trans("MyObject")); print load_fiche_titre($langs->trans("MyObject"));
print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">'; print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
print '<input type="hidden" name="token" value="'.newToken().'">'; print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="action" value="update">'; print '<input type="hidden" name="action" value="update">';
print '<input type="hidden" name="backtopage" value="'.$backtopage.'">'; print '<input type="hidden" name="backtopage" value="'.$backtopage.'">';
print '<input type="hidden" name="id" value="'.$object->id.'">'; print '<input type="hidden" name="id" value="'.$object->id.'">';
@ -204,7 +204,7 @@ if (($id || $ref) && $action == 'edit') {
// Part to show record // Part to show record
if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'create'))) { if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'create'))) {
$res = $object->fetch_optionals(); $res = $object->fetch_optionals();
$head = myobjectPrepareHead($object); $head = myobjectPrepareHead($object);
dol_fiche_head($head, 'card', $langs->trans("MyObject"), -1, 'myobject@mymodule'); dol_fiche_head($head, 'card', $langs->trans("MyObject"), -1, 'myobject@mymodule');
@ -213,7 +213,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
// Confirmation to delete // Confirmation to delete
if ($action == 'delete') { if ($action == 'delete') {
$formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('DeleteMyObject'), $langs->trans('ConfirmDeleteMyObject'), 'confirm_delete', '', 0, 1); $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('DeleteMyObject'), $langs->trans('ConfirmDeleteMyObject'), 'confirm_delete', '', 0, 1);
} }
// Clone confirmation // Clone confirmation
@ -226,7 +226,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
// Confirmation of action xxxx // Confirmation of action xxxx
if ($action == 'xxx') { if ($action == 'xxx') {
$formquestion = array(); $formquestion = array();
/* /*
$forcecombo=0; $forcecombo=0;
if ($conf->browser->name == 'ie') $forcecombo = 1; // There is a bug in IE10 that make combo inside popup crazy if ($conf->browser->name == 'ie') $forcecombo = 1; // There is a bug in IE10 that make combo inside popup crazy
$formquestion = array( $formquestion = array(
@ -236,7 +236,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
// array('type' => 'other', 'name' => 'idwarehouse', 'label' => $langs->trans("SelectWarehouseForStockDecrease"), 'value' => $formproduct->selectWarehouses(GETPOST('idwarehouse')?GETPOST('idwarehouse'):'ifone', 'idwarehouse', '', 1, 0, 0, '', 0, $forcecombo)) // array('type' => 'other', 'name' => 'idwarehouse', 'label' => $langs->trans("SelectWarehouseForStockDecrease"), 'value' => $formproduct->selectWarehouses(GETPOST('idwarehouse')?GETPOST('idwarehouse'):'ifone', 'idwarehouse', '', 1, 0, 0, '', 0, $forcecombo))
); );
*/ */
$formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('XXX'), $text, 'confirm_xxx', $formquestion, 0, 1, 220); $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('XXX'), $text, 'confirm_xxx', $formquestion, 0, 1, 220);
} }
// Call Hook formConfirm // Call Hook formConfirm
@ -320,25 +320,25 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
// Buttons for actions // Buttons for actions
if ($action != 'presend' && $action != 'editline') { if ($action != 'presend' && $action != 'editline') {
print '<div class="tabsAction">'."\n"; print '<div class="tabsAction">'."\n";
$parameters = array(); $parameters = array();
$reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
if (empty($reshook)) { if (empty($reshook)) {
// Modify // Modify
if ($user->rights->mymodule->write) { if ($user->rights->mymodule->write) {
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=edit">'.$langs->trans("Modify").'</a>'."\n"; print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=edit">'.$langs->trans("Modify").'</a>'."\n";
} else { } else {
print '<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans("NotEnoughPermissions")).'">'.$langs->trans('Modify').'</a>'."\n"; print '<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans("NotEnoughPermissions")).'">'.$langs->trans('Modify').'</a>'."\n";
} }
// Clone // Clone
if ($user->rights->mymodule->write) { if ($user->rights->mymodule->write) {
print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&amp;socid='.$object->socid.'&amp;action=clone&amp;object=order">'.$langs->trans("ToClone").'</a></div>'; print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&amp;socid='.$object->socid.'&amp;action=clone&amp;object=order">'.$langs->trans("ToClone").'</a></div>';
} }
/* /*
if ($user->rights->mymodule->write) if ($user->rights->mymodule->write)
{ {
if ($object->status == 1) if ($object->status == 1)
@ -352,13 +352,13 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
} }
*/ */
if ($user->rights->mymodule->delete) { if ($user->rights->mymodule->delete) {
print '<a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=delete&amp;token='.newToken().'">'.$langs->trans('Delete').'</a>'."\n"; print '<a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=delete&amp;token='.newToken().'">'.$langs->trans('Delete').'</a>'."\n";
} else { } else {
print '<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans("NotEnoughPermissions")).'">'.$langs->trans('Delete').'</a>'."\n"; print '<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans("NotEnoughPermissions")).'">'.$langs->trans('Delete').'</a>'."\n";
} }
} }
print '</div>'."\n"; print '</div>'."\n";
} }
@ -368,28 +368,28 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
} }
if ($action != 'presend') { if ($action != 'presend') {
print '<div class="fichecenter"><div class="fichehalfleft">'; print '<div class="fichecenter"><div class="fichehalfleft">';
print '<a name="builddoc"></a>'; // ancre print '<a name="builddoc"></a>'; // ancre
// Show links to link elements // Show links to link elements
$linktoelem = $form->showLinkToObjectBlock($object, null, array('myobject')); $linktoelem = $form->showLinkToObjectBlock($object, null, array('myobject'));
$somethingshown = $form->showLinkedObjectBlock($object, $linktoelem); $somethingshown = $form->showLinkedObjectBlock($object, $linktoelem);
print '</div><div class="fichehalfright"><div class="ficheaddleft">'; print '</div><div class="fichehalfright"><div class="ficheaddleft">';
$MAXEVENT = 10; $MAXEVENT = 10;
$morehtmlright = '<a href="'.dol_buildpath('/mymodule/myobject_info.php', 1).'?id='.$object->id.'">'; $morehtmlright = '<a href="'.dol_buildpath('/mymodule/myobject_info.php', 1).'?id='.$object->id.'">';
$morehtmlright .= $langs->trans("SeeAll"); $morehtmlright .= $langs->trans("SeeAll");
$morehtmlright .= '</a>'; $morehtmlright .= '</a>';
// List of actions on element // List of actions on element
include_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php'; include_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php';
$formactions = new FormActions($db); $formactions = new FormActions($db);
$somethingshown = $formactions->showactions($object, 'myobject', $socid, 1, '', $MAXEVENT, '', $morehtmlright); $somethingshown = $formactions->showactions($object, 'myobject', $socid, 1, '', $MAXEVENT, '', $morehtmlright);
print '</div></div></div>'; print '</div></div></div>';
} }
//Select mail models is same action as presend //Select mail models is same action as presend