Merge remote-tracking branch 'upstream/develop' into translateModLivraison2ModDelivery

This commit is contained in:
Aurélien 2020-10-08 16:19:10 +02:00
commit b6283c1a5d
No known key found for this signature in database
GPG Key ID: 296611B615F8FDF3
160 changed files with 15484 additions and 14939 deletions

View File

@ -12,7 +12,8 @@ NEW: Module Reception (for a more accurate management of your receptions) moved
WARNING: WARNING:
Following changes may create regressions for some external modules, but were necessary to make Dolibarr better: Following changes may create regressions for some external modules, but were necessary to make Dolibarr better:
* Properties ->contactid has been renamed into ->contact_id * Properties ->contactid have been renamed into ->contact_id
* Properties ->titre have been renamed into ->title
* Property $paiementid in API 'api_supplier_invoices.php' has been renamed into into $payment_mode_id (english) * Property $paiementid in API 'api_supplier_invoices.php' has been renamed into into $payment_mode_id (english)
* The deprecated subsitution key __SIGNATURE__ has been removed. Replace with __USER_SIGNATURE__ if you used the old syntax in * The deprecated subsitution key __SIGNATURE__ has been removed. Replace with __USER_SIGNATURE__ if you used the old syntax in
your email templates. your email templates.
@ -24,6 +25,7 @@ Following changes may create regressions for some external modules, but were nec
* The GETPOST(..., 'alpha') has now the same behaviour than GETPOST(..., 'alphanohtml') so no html will be allowed. Use GETPOST(..., 'restricthtml') to accept HTML. * The GETPOST(..., 'alpha') has now the same behaviour than GETPOST(..., 'alphanohtml') so no html will be allowed. Use GETPOST(..., 'restricthtml') to accept HTML.
* If you have links in your code with '&action=delete' as a parameter, you must also add '&token='.newToken() as another parameter to avoid CSRF protection errors. * If you have links in your code with '&action=delete' as a parameter, you must also add '&token='.newToken() as another parameter to avoid CSRF protection errors.
* The API addPayment for api_invoice has evolved to accept amount into a foreign currency. You must provide array(amount=>X,mutlicurrency_ammount=>Y) instead of amount. * The API addPayment for api_invoice has evolved to accept amount into a foreign currency. You must provide array(amount=>X,mutlicurrency_ammount=>Y) instead of amount.
* The method select_thirdparty(), deprecated since 3.8, into html.form.class.php has been removed.
***** ChangeLog for 12.0.3 compared to 12.0.2 ***** ***** ChangeLog for 12.0.3 compared to 12.0.2 *****
FIX: 10.0 - when the mime file name is different from the filesystem name, the attachment name should be the mime filename FIX: 10.0 - when the mime file name is different from the filesystem name, the attachment name should be the mime filename

View File

@ -620,6 +620,9 @@ if ($nboftargetok) {
$ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/tecnickcom/tcpdf/fonts/utils`; $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/tecnickcom/tcpdf/fonts/utils`;
$ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/tecnickcom/tcpdf/tools`; $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/tecnickcom/tcpdf/tools`;
$ret=`rm -f $BUILDROOT/$PROJECT/htdocs/includes/tecnickcom/tcpdf/LICENSE.TXT`; $ret=`rm -f $BUILDROOT/$PROJECT/htdocs/includes/tecnickcom/tcpdf/LICENSE.TXT`;
$ret=`rm -f $BUILDROOT/$PROJECT/htdocs/includes/autoload.php`;
$ret=`rm -f $BUILDROOT/$PROJECT/htdocs/theme/common/octicons/LICENSE`; $ret=`rm -f $BUILDROOT/$PROJECT/htdocs/theme/common/octicons/LICENSE`;
} }

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

@ -623,7 +623,6 @@ if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.urle
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="'.urlencode($sortfield).'">'; print '<input type="hidden" name="sortfield" value="'.urlencode($sortfield).'">';
print '<input type="hidden" name="sortorder" value="'.urlencode($sortorder).'">'; print '<input type="hidden" name="sortorder" value="'.urlencode($sortorder).'">';
print '<input type="hidden" name="page" value="'.urlencode($page).'">';
if (count($filter)) $buttonLabel = $langs->trans("ExportFilteredList"); if (count($filter)) $buttonLabel = $langs->trans("ExportFilteredList");
else $buttonLabel = $langs->trans("ExportList"); else $buttonLabel = $langs->trans("ExportList");
@ -638,14 +637,14 @@ $newcardbutton .= '<span class="valignmiddle marginrightonly">'.$langs->trans("I
$newcardbutton .= dolGetButtonTitle($buttonLabel, $langs->trans("ExportFilteredList").' ('.$listofformat[$formatexportset].')', 'fa fa-file-export paddingleft', $_SERVER["PHP_SELF"].'?action=export_file'.($param ? '&'.$param : ''), $user->rights->accounting->mouvements->export); $newcardbutton .= dolGetButtonTitle($buttonLabel, $langs->trans("ExportFilteredList").' ('.$listofformat[$formatexportset].')', 'fa fa-file-export paddingleft', $_SERVER["PHP_SELF"].'?action=export_file'.($param ? '&'.$param : ''), $user->rights->accounting->mouvements->export);
$newcardbutton .= dolGetButtonTitle($langs->trans('ViewFlatList'), '', 'fa fa-list paddingleft imgforviewmode', DOL_URL_ROOT.'/accountancy/bookkeeping/list.php?'.$param, '', 1, array('morecss'=>'btnTitleSelected')); $newcardbutton .= dolGetButtonTitle($langs->trans('ViewFlatList'), '', 'fa fa-list paddingleft imgforviewmode', DOL_URL_ROOT.'/accountancy/bookkeeping/list.php?'.$param, '', 1, array('morecss'=>'marginleftonly btnTitleSelected'));
$newcardbutton .= dolGetButtonTitle($langs->trans('GroupByAccountAccounting'), '', 'fa fa-stream paddingleft imgforviewmode', DOL_URL_ROOT.'/accountancy/bookkeeping/listbyaccount.php?'.$param, '', 1, array('morecss'=>'marginleftonly')); $newcardbutton .= dolGetButtonTitle($langs->trans('GroupByAccountAccounting'), '', 'fa fa-stream paddingleft imgforviewmode', DOL_URL_ROOT.'/accountancy/bookkeeping/listbyaccount.php?'.$param, '', 1, array('morecss'=>'marginleftonly'));
$url = './card.php?action=create'; $url = './card.php?action=create';
if (!empty($socid)) $url .= '&socid='.$socid; if (!empty($socid)) $url .= '&socid='.$socid;
$newcardbutton .= dolGetButtonTitle($langs->trans('NewAccountingMvt'), '', 'fa fa-plus-circle paddingleft', $url, '', $user->rights->accounting->mouvements->creer); $newcardbutton .= dolGetButtonTitle($langs->trans('NewAccountingMvt'), '', 'fa fa-plus-circle paddingleft', $url, '', $user->rights->accounting->mouvements->creer);
print_barre_liste($title_page, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_accountancy', 0, $newcardbutton, '', $limit); print_barre_liste($title_page, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_accountancy', 0, $newcardbutton, '', $limit, 0, 0, 1);
$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
@ -1042,10 +1041,10 @@ while ($i < min($num, $limit))
print '<td class="nowraponall center">'; print '<td class="nowraponall center">';
if (empty($line->date_export)) { if (empty($line->date_export)) {
if ($user->rights->accounting->mouvements->creer) { if ($user->rights->accounting->mouvements->creer) {
print '<a href="'.DOL_URL_ROOT.'/accountancy/bookkeeping/card.php?piece_num='.$line->piece_num.$param.'&page='.$page.($sortfield ? '&sortfield='.$sortfield : '').($sortorder ? '&sortorder='.$sortorder : '').'">'.img_edit().'</a>'; print '<a class="editfielda paddingleft marginrightonly" href="'.DOL_URL_ROOT.'/accountancy/bookkeeping/card.php?piece_num='.$line->piece_num.$param.'&page='.$page.($sortfield ? '&sortfield='.$sortfield : '').($sortorder ? '&sortorder='.$sortorder : '').'">'.img_edit().'</a>';
} }
if ($user->rights->accounting->mouvements->supprimer) { if ($user->rights->accounting->mouvements->supprimer) {
print '&nbsp;<a href="'.$_SERVER['PHP_SELF'].'?action=delmouv&mvt_num='.$line->piece_num.$param.'&page='.$page.($sortfield ? '&sortfield='.$sortfield : '').($sortorder ? '&sortorder='.$sortorder : '').'">'.img_delete().'</a>'; print '<a class="reposition paddingleft marginrightonly" href="'.$_SERVER['PHP_SELF'].'?action=delmouv&mvt_num='.$line->piece_num.$param.'&page='.$page.($sortfield ? '&sortfield='.$sortfield : '').($sortorder ? '&sortorder='.$sortorder : '').'">'.img_delete().'</a>';
} }
} }
print '</td>'; print '</td>';

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();
@ -970,8 +970,9 @@ if (empty($action) || $action == 'view') {
$obj = $db->fetch_object($resql); $obj = $db->fetch_object($resql);
if ($obj->nb > 0) if ($obj->nb > 0)
{ {
print '<br>'.img_warning().' '.$langs->trans("TheJournalCodeIsNotDefinedOnSomeBankAccount"); print '<br><div class="warning">'.img_warning().' '.$langs->trans("TheJournalCodeIsNotDefinedOnSomeBankAccount");
print ' : '.$langs->trans("AccountancyAreaDescBank", 9, '<strong>'.$langs->transnoentitiesnoconv("MenuAccountancy").'-'.$langs->transnoentitiesnoconv("Setup")."-".$langs->transnoentitiesnoconv("BankAccounts").'</strong>'); print ' : '.$langs->trans("AccountancyAreaDescBank", 9, '<strong>'.$langs->transnoentitiesnoconv("MenuAccountancy").'-'.$langs->transnoentitiesnoconv("Setup")."-".$langs->transnoentitiesnoconv("BankAccounts").'</strong>');
print '</div>';
} }
} else dol_print_error($db); } else dol_print_error($db);

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

@ -400,7 +400,7 @@ print '<tr class="liste_titre"><th class="titlefield wordbreak">'.$langs->trans(
// Name // Name
print '<tr class="oddeven"><td class="fieldrequired wordbreak"><label for="name">'.$langs->trans("CompanyName").'</label></td><td>'; print '<tr class="oddeven"><td class="fieldrequired wordbreak"><label for="name">'.$langs->trans("CompanyName").'</label></td><td>';
print '<input name="nom" id="name" class="minwidth200" value="'.dol_escape_htmltag($conf->global->MAIN_INFO_SOCIETE_NOM ? $conf->global->MAIN_INFO_SOCIETE_NOM : GETPOST("nom", 'nohtml')).'"'.(empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER) ? '' : ' autofocus="autofocus"').'></td></tr>'."\n"; print '<input name="nom" id="name" class="minwidth200" value="'.dol_escape_htmltag($conf->global->MAIN_INFO_SOCIETE_NOM ? $conf->global->MAIN_INFO_SOCIETE_NOM : GETPOST("nom", 'nohtml')).'"'.(empty($conf->global->MAIN_INFO_SOCIETE_NOM) ? ' autofocus="autofocus"' : '').'></td></tr>'."\n";
// Address // Address
print '<tr class="oddeven"><td><label for="MAIN_INFO_SOCIETE_ADDRESS">'.$langs->trans("CompanyAddress").'</label></td><td>'; print '<tr class="oddeven"><td><label for="MAIN_INFO_SOCIETE_ADDRESS">'.$langs->trans("CompanyAddress").'</label></td><td>';

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

@ -33,16 +33,16 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
$langs->load("categories"); $langs->load("categories");
$id = GETPOST('id', 'int'); $id = GETPOST('id', 'int');
$ref = GETPOST('ref'); $ref = GETPOST('ref', 'alphanohtml');
$type = GETPOST('type'); $type = GETPOST('type', 'alphanohtml');
$action = (GETPOST('action', 'aZ09') ?GETPOST('action', 'aZ09') : 'edit'); $action = (GETPOST('action', 'aZ09') ?GETPOST('action', 'aZ09') : 'edit');
$confirm = GETPOST('confirm'); $confirm = GETPOST('confirm');
$cancel = GETPOST('cancel', 'alpha'); $cancel = GETPOST('cancel', 'alpha');
$socid = GETPOST('socid', 'int'); $socid = GETPOST('socid', 'int');
$label = GETPOST('label'); $label = GETPOST('label', 'alphanohtml');
$description = GETPOST('description'); $description = GETPOST('description', 'restricthtml');
$color = GETPOST('color', 'alpha'); $color = preg_replace('/[^0-9a-f#]/i', '', GETPOST('color', 'alphanohtml'));
$visible = GETPOST('visible'); $visible = GETPOST('visible');
$parent = GETPOST('parent'); $parent = GETPOST('parent');

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

@ -426,7 +426,7 @@ if ($object->fetch($id) >= 0) {
print $form->showrefnav($object, 'id', $linkback); print $form->showrefnav($object, 'id', $linkback);
print '</td></tr>'; print '</td></tr>';
print '<tr><td>'.$langs->trans("MailTitle").'</td><td colspan="3">'.$object->titre.'</td></tr>'; print '<tr><td>'.$langs->trans("MailTitle").'</td><td colspan="3">'.$object->title.'</td></tr>';
print '<tr><td>'.$langs->trans("MailFrom").'</td><td colspan="3">'.dol_print_email($object->email_from, 0, 0, 0, 0, 1).'</td></tr>'; print '<tr><td>'.$langs->trans("MailFrom").'</td><td colspan="3">'.dol_print_email($object->email_from, 0, 0, 0, 0, 1).'</td></tr>';

View File

@ -465,13 +465,13 @@ if (empty($reshook))
$object->email_from = GETPOST("from"); $object->email_from = GETPOST("from");
$object->email_replyto = GETPOST("replyto"); $object->email_replyto = GETPOST("replyto");
$object->email_errorsto = GETPOST("errorsto"); $object->email_errorsto = GETPOST("errorsto");
$object->titre = GETPOST("titre"); $object->title = GETPOST("title");
$object->sujet = GETPOST("sujet"); $object->sujet = GETPOST("sujet");
$object->body = GETPOST("bodyemail", 'restricthtml'); $object->body = GETPOST("bodyemail", 'restricthtml');
$object->bgcolor = GETPOST("bgcolor"); $object->bgcolor = GETPOST("bgcolor");
$object->bgimage = GETPOST("bgimage"); $object->bgimage = GETPOST("bgimage");
if (!$object->titre) { if (!$object->title) {
$mesgs[] = $langs->trans("ErrorFieldRequired", $langs->transnoentities("MailTitle")); $mesgs[] = $langs->trans("ErrorFieldRequired", $langs->transnoentities("MailTitle"));
} }
if (!$object->sujet) { if (!$object->sujet) {
@ -496,16 +496,16 @@ if (empty($reshook))
} }
// Action update description of emailing // Action update description of emailing
if ($action == 'settitre' || $action == 'setemail_from' || $action == 'setreplyto' || $action == 'setemail_errorsto') if ($action == 'settitle' || $action == 'setemail_from' || $action == 'setreplyto' || $action == 'setemail_errorsto')
{ {
$upload_dir = $conf->mailing->dir_output."/".get_exdir($object->id, 2, 0, 1, $object, 'mailing'); $upload_dir = $conf->mailing->dir_output."/".get_exdir($object->id, 2, 0, 1, $object, 'mailing');
if ($action == 'settitre') $object->titre = trim(GETPOST('titre', 'alpha')); if ($action == 'settitle') $object->title = trim(GETPOST('title', 'alpha'));
elseif ($action == 'setemail_from') $object->email_from = trim(GETPOST('email_from', 'alpha')); elseif ($action == 'setemail_from') $object->email_from = trim(GETPOST('email_from', 'alpha'));
elseif ($action == 'setemail_replyto') $object->email_replyto = trim(GETPOST('email_replyto', 'alpha')); elseif ($action == 'setemail_replyto') $object->email_replyto = trim(GETPOST('email_replyto', 'alpha'));
elseif ($action == 'setemail_errorsto') { elseif ($action == 'setemail_errorsto') {
$object->email_errorsto = trim(GETPOST('email_errorsto', 'alpha')); $object->email_errorsto = trim(GETPOST('email_errorsto', 'alpha'));
} elseif ($action == 'settitre' && empty($object->titre)) { } elseif ($action == 'settitle' && empty($object->title)) {
$mesg = $langs->trans("ErrorFieldRequired", $langs->transnoentities("MailTitle")); $mesg = $langs->trans("ErrorFieldRequired", $langs->transnoentities("MailTitle"));
} elseif ($action == 'setfrom' && empty($object->email_from)) { } elseif ($action == 'setfrom' && empty($object->email_from)) {
$mesg = $langs->trans("ErrorFieldRequired", $langs->transnoentities("MailFrom")); $mesg = $langs->trans("ErrorFieldRequired", $langs->transnoentities("MailFrom"));
@ -854,9 +854,9 @@ if ($action == 'create')
// Description // Description
print '<tr><td class="titlefield">'; print '<tr><td class="titlefield">';
print $form->editfieldkey("MailTitle", 'titre', $object->titre, $object, $user->rights->mailing->creer && $object->statut < 3, 'string'); print $form->editfieldkey("MailTitle", 'title', $object->title, $object, $user->rights->mailing->creer && $object->statut < 3, 'string');
print '</td><td>'; print '</td><td>';
print $form->editfieldval("MailTitle", 'titre', $object->titre, $object, $user->rights->mailing->creer && $object->statut < 3, 'string'); print $form->editfieldval("MailTitle", 'title', $object->title, $object, $user->rights->mailing->creer && $object->statut < 3, 'string');
print '</td></tr>'; print '</td></tr>';
// From // From
@ -1144,7 +1144,7 @@ if ($action == 'create')
*/ */
// Topic // Topic
print '<tr><td class="titlefield">'.$langs->trans("MailTitle").'</td><td colspan="3">'.$object->titre.'</td></tr>'; print '<tr><td class="titlefield">'.$langs->trans("MailTitle").'</td><td colspan="3">'.$object->title.'</td></tr>';
// From // From
print '<tr><td class="titlefield">'.$langs->trans("MailFrom").'</td><td colspan="3">'.dol_print_email($object->email_from, 0, 0, 0, 0, 1).'</td></tr>'; print '<tr><td class="titlefield">'.$langs->trans("MailFrom").'</td><td colspan="3">'.dol_print_email($object->email_from, 0, 0, 0, 0, 1).'</td></tr>';
// To // To

View File

@ -237,7 +237,7 @@ if ($object->fetch($id) >= 0)
print '<table class="border centpercent tableforfield">'; print '<table class="border centpercent tableforfield">';
print '<tr><td class="titlefield">'.$langs->trans("MailTitle").'</td><td colspan="3">'.$object->titre.'</td></tr>'; print '<tr><td class="titlefield">'.$langs->trans("MailTitle").'</td><td colspan="3">'.$object->title.'</td></tr>';
print '<tr><td>'.$langs->trans("MailFrom").'</td><td colspan="3">'; print '<tr><td>'.$langs->trans("MailFrom").'</td><td colspan="3">';
$emailarray = CMailFile::getArrayAddress($object->email_from); $emailarray = CMailFile::getArrayAddress($object->email_from);

View File

@ -46,7 +46,7 @@ class Mailing extends CommonObject
*/ */
public $picto = 'email'; public $picto = 'email';
public $titre; public $title;
public $sujet; public $sujet;
public $body; public $body;
public $nbemail; public $nbemail;
@ -115,7 +115,7 @@ class Mailing extends CommonObject
$this->db->begin(); $this->db->begin();
$this->titre = trim($this->titre); $this->title = trim($this->title);
$this->email_from = trim($this->email_from); $this->email_from = trim($this->email_from);
if (!$this->email_from) if (!$this->email_from)
@ -130,9 +130,9 @@ class Mailing extends CommonObject
$sql .= " (date_creat, fk_user_creat, entity)"; $sql .= " (date_creat, fk_user_creat, entity)";
$sql .= " VALUES ('".$this->db->idate($now)."', ".$user->id.", ".$conf->entity.")"; $sql .= " VALUES ('".$this->db->idate($now)."', ".$user->id.", ".$conf->entity.")";
if (!$this->titre) if (!$this->title)
{ {
$this->titre = $langs->trans("NoTitle"); $this->title = $langs->trans("NoTitle");
} }
dol_syslog("Mailing::Create", LOG_DEBUG); dol_syslog("Mailing::Create", LOG_DEBUG);
@ -167,7 +167,7 @@ class Mailing extends CommonObject
public function update($user) public function update($user)
{ {
$sql = "UPDATE ".MAIN_DB_PREFIX."mailing "; $sql = "UPDATE ".MAIN_DB_PREFIX."mailing ";
$sql .= " SET titre = '".$this->db->escape($this->titre)."'"; $sql .= " SET titre = '".$this->db->escape($this->title)."'";
$sql .= ", sujet = '".$this->db->escape($this->sujet)."'"; $sql .= ", sujet = '".$this->db->escape($this->sujet)."'";
$sql .= ", body = '".$this->db->escape($this->body)."'"; $sql .= ", body = '".$this->db->escape($this->body)."'";
$sql .= ", email_from = '".$this->db->escape($this->email_from)."'"; $sql .= ", email_from = '".$this->db->escape($this->email_from)."'";
@ -198,7 +198,7 @@ class Mailing extends CommonObject
{ {
global $conf; global $conf;
$sql = "SELECT m.rowid, m.titre, m.sujet, m.body, m.bgcolor, m.bgimage"; $sql = "SELECT m.rowid, m.titre as title, m.sujet, m.body, m.bgcolor, m.bgimage";
$sql .= ", m.email_from, m.email_replyto, m.email_errorsto"; $sql .= ", m.email_from, m.email_replyto, m.email_errorsto";
$sql .= ", m.statut, m.nbemail"; $sql .= ", m.statut, m.nbemail";
$sql .= ", m.fk_user_creat, m.fk_user_valid"; $sql .= ", m.fk_user_creat, m.fk_user_valid";
@ -221,7 +221,7 @@ class Mailing extends CommonObject
$this->ref = $obj->rowid; $this->ref = $obj->rowid;
$this->statut = $obj->statut; $this->statut = $obj->statut;
$this->nbemail = $obj->nbemail; $this->nbemail = $obj->nbemail;
$this->titre = $obj->titre; $this->title = $obj->title;
$this->sujet = $obj->sujet; $this->sujet = $obj->sujet;
if (!empty($conf->global->FCKEDITOR_ENABLE_MAILING) && dol_textishtml(dol_html_entity_decode($obj->body, ENT_COMPAT | ENT_HTML401))) { if (!empty($conf->global->FCKEDITOR_ENABLE_MAILING) && dol_textishtml(dol_html_entity_decode($obj->body, ENT_COMPAT | ENT_HTML401))) {
@ -283,7 +283,7 @@ class Mailing extends CommonObject
$object->statut = 0; $object->statut = 0;
// Clear fields // Clear fields
$object->titre = $langs->trans("CopyOf").' '.$object->titre.' '.dol_print_date(dol_now()); $object->title = $langs->trans("CopyOf").' '.$object->title.' '.dol_print_date(dol_now());
// If no option copy content // If no option copy content
if (empty($option1)) if (empty($option1))

View File

@ -182,7 +182,7 @@ if ($result) {
print '<tr class="oddeven">'; print '<tr class="oddeven">';
print '<td class="nowrap">'.$mailstatic->getNomUrl(1).'</td>'; print '<td class="nowrap">'.$mailstatic->getNomUrl(1).'</td>';
print '<td>'.dol_trunc($obj->titre, 38).'</td>'; print '<td>'.dol_trunc($obj->title, 38).'</td>';
print '<td class="center">'.dol_print_date($db->jdate($obj->date_creat), 'day').'</td>'; print '<td class="center">'.dol_print_date($db->jdate($obj->date_creat), 'day').'</td>';
print '<td class="center">'.($obj->nbemail ? $obj->nbemail : "0").'</td>'; print '<td class="center">'.($obj->nbemail ? $obj->nbemail : "0").'</td>';
print '<td class="right">'.$mailstatic->LibStatut($obj->statut, 5).'</td>'; print '<td class="right">'.$mailstatic->LibStatut($obj->statut, 5).'</td>';

View File

@ -238,7 +238,7 @@ if ($resql)
print $email->getNomUrl(1); print $email->getNomUrl(1);
print '</td>'; print '</td>';
print '<td>'.$obj->titre.'</td>'; print '<td>'.$obj->title.'</td>';
// Date creation // Date creation
print '<td class="center">'; print '<td class="center">';

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(

View File

@ -3531,6 +3531,8 @@ class Commande extends CommonOrder
$billedtext = ''; $billedtext = '';
if (empty($donotshowbilled)) $billedtext .= ($billed ? ' - '.$langs->trans("Billed") : ''); if (empty($donotshowbilled)) $billedtext .= ($billed ? ' - '.$langs->trans("Billed") : '');
$labelTooltip = '';
if ($status == self::STATUS_CANCELED) { if ($status == self::STATUS_CANCELED) {
$labelStatus = $langs->trans('StatusOrderCanceled'); $labelStatus = $langs->trans('StatusOrderCanceled');
$labelStatusShort = $langs->trans('StatusOrderCanceledShort'); $labelStatusShort = $langs->trans('StatusOrderCanceledShort');
@ -3544,8 +3546,9 @@ class Commande extends CommonOrder
$labelStatusShort = $langs->trans('StatusOrderValidatedShort').$billedtext; $labelStatusShort = $langs->trans('StatusOrderValidatedShort').$billedtext;
$statusType = 'status1'; $statusType = 'status1';
} elseif ($status == self::STATUS_SHIPMENTONPROCESS) { } elseif ($status == self::STATUS_SHIPMENTONPROCESS) {
$labelStatus = $langs->trans('StatusOrderSentShort').$billedtext; $labelStatus = $langs->trans('StatusOrderSent').$billedtext;
$labelStatusShort = $langs->trans('StatusOrderSentShort').$billedtext; $labelStatusShort = $langs->trans('StatusOrderSentShort').$billedtext;
$labelTooltip = $langs->trans("StatusOrderSent").' - '.$langs->trans("DateDeliveryPlanned").dol_print_date($this->date_livraison).$billedtext;
$statusType = 'status4'; $statusType = 'status4';
} elseif ($status == self::STATUS_CLOSED && (!$billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) { } elseif ($status == self::STATUS_CLOSED && (!$billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) {
$labelStatus = $langs->trans('StatusOrderToBill'); $labelStatus = $langs->trans('StatusOrderToBill');
@ -3553,11 +3556,11 @@ class Commande extends CommonOrder
$statusType = 'status4'; $statusType = 'status4';
} elseif ($status == self::STATUS_CLOSED && ($billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) { } elseif ($status == self::STATUS_CLOSED && ($billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) {
$labelStatus = $langs->trans('StatusOrderProcessed').$billedtext; $labelStatus = $langs->trans('StatusOrderProcessed').$billedtext;
$labelStatusShort = $langs->trans('StatusOrderProcessed').$billedtext; $labelStatusShort = $langs->trans('StatusOrderProcessedShort').$billedtext;
$statusType = 'status6'; $statusType = 'status6';
} elseif ($status == self::STATUS_CLOSED && (!empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) { } elseif ($status == self::STATUS_CLOSED && (!empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) {
$labelStatus = $langs->trans('StatusOrderDelivered'); $labelStatus = $langs->trans('StatusOrderDelivered');
$labelStatusShort = $langs->trans('StatusOrderDelivered'); $labelStatusShort = $langs->trans('StatusOrderDeliveredShort');
$statusType = 'status6'; $statusType = 'status6';
} else { } else {
$labelStatus = $langs->trans('Unknown'); $labelStatus = $langs->trans('Unknown');
@ -3566,7 +3569,7 @@ class Commande extends CommonOrder
$mode = 0; $mode = 0;
} }
return dolGetStatus($labelStatus, $labelStatusShort, '', $statusType, $mode); return dolGetStatus($labelStatus, $labelStatusShort, '', $statusType, $mode, '', array('tooltip' => $labelTooltip));
} }

View File

@ -46,7 +46,7 @@ require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
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
$langs->loadLangs(array("orders", 'sendings', 'deliveries', 'companies', 'compta', 'bills')); $langs->loadLangs(array("orders", 'sendings', 'deliveries', 'companies', 'compta', 'bills', 'stocks'));
$action = GETPOST('action', 'aZ09'); $action = GETPOST('action', 'aZ09');
$massaction = GETPOST('massaction', 'alpha'); $massaction = GETPOST('massaction', 'alpha');
@ -680,9 +680,9 @@ if ($resql)
print '</td>'; print '</td>';
} }
// Town // Town
if (!empty($arrayfields['s.town']['checked'])) print '<td class="liste_titre"><input class="flat" type="text" size="4" name="search_town" value="'.$search_town.'"></td>'; if (!empty($arrayfields['s.town']['checked'])) print '<td class="liste_titre"><input class="flat" type="text" size="4" name="search_town" value="'.dol_escape_htmltag($search_town).'"></td>';
// Zip // Zip
if (!empty($arrayfields['s.zip']['checked'])) print '<td class="liste_titre"><input class="flat" type="text" size="4" name="search_zip" value="'.$search_zip.'"></td>'; if (!empty($arrayfields['s.zip']['checked'])) print '<td class="liste_titre"><input class="flat" type="text" size="4" name="search_zip" value="'.dol_escape_htmltag($search_zip).'"></td>';
// State // State
if (!empty($arrayfields['state.nom']['checked'])) if (!empty($arrayfields['state.nom']['checked']))
{ {
@ -905,6 +905,7 @@ if ($resql)
$total = 0; $total = 0;
$subtotal = 0; $subtotal = 0;
$productstat_cache = array(); $productstat_cache = array();
$productstat_cachevirtual = array();
$getNomUrl_cache = array(); $getNomUrl_cache = array();
$generic_commande = new Commande($db); $generic_commande = new Commande($db);
@ -962,7 +963,6 @@ if ($resql)
// Show shippable Icon (create subloop, so may be slow) // Show shippable Icon (create subloop, so may be slow)
if ($conf->stock->enabled) if ($conf->stock->enabled)
{ {
$langs->load("stocks");
if (($obj->fk_statut > 0) && ($obj->fk_statut < 3)) if (($obj->fk_statut > 0) && ($obj->fk_statut < 3))
{ {
$numlines = count($generic_commande->lines); // Loop on each line of order $numlines = count($generic_commande->lines); // Loop on each line of order
@ -986,16 +986,16 @@ if ($resql)
if (empty($conf->global->SHIPPABLE_ORDER_ICON_IN_LIST)) // Default code. Default is when this option is not set, setting it create strange result if (empty($conf->global->SHIPPABLE_ORDER_ICON_IN_LIST)) // Default code. Default is when this option is not set, setting it create strange result
{ {
$text_info .= $generic_commande->lines[$lig]->qty.' X '.$generic_commande->lines[$lig]->ref.'&nbsp;'.dol_trunc($generic_commande->lines[$lig]->product_label, 25); $text_info .= $generic_commande->lines[$lig]->qty.' X '.$generic_commande->lines[$lig]->product_ref.'&nbsp;'.dol_trunc($generic_commande->lines[$lig]->product_label, 25);
$text_info .= ' - '.$langs->trans("Stock").': '.$generic_product->stock_reel; $text_info .= ' - '.$langs->trans("Stock").': <span class="'.($generic_product->stock_reel > 0 ? 'ok' : 'error').'">'.$generic_product->stock_reel.'</span>';
$text_info .= ' - '.$langs->trans("VirtualStock").': '.$generic_product->stock_theorique; $text_info .= ' - '.$langs->trans("VirtualStock").': <span class="'.($generic_product->stock_theorique > 0 ? 'ok' : 'error').'">'.$generic_product->stock_theorique.'</span>';
$text_info .= '<br>'; $text_info .= '<br>';
if ($generic_commande->lines[$lig]->qty > $generic_product->stock_reel) if ($generic_commande->lines[$lig]->qty > $generic_product->stock_reel)
{ {
$notshippable++; $notshippable++;
} }
} else { // Detailed code, looks bugged } else { // Detailed virtual stock, looks bugged, uncomplete and need heavy load.
// stock order and stock order_supplier // stock order and stock order_supplier
$stock_order = 0; $stock_order = 0;
$stock_order_supplier = 0; $stock_order_supplier = 0;

View File

@ -182,7 +182,7 @@ if (($action == 'searchfiles' || $action == 'dl')) {
$sql .= " AND t.entity IN (".($entity == 1 ? '0,1' : $entity).')'; $sql .= " AND t.entity IN (".($entity == 1 ? '0,1' : $entity).')';
$sql .= " AND t.fk_statut <> ".Don::STATUS_DRAFT; $sql .= " AND t.fk_statut <> ".Don::STATUS_DRAFT;
} }
// Paiements of salaries // Payments of salaries
if (GETPOST('selectpaymentsofsalaries')) { if (GETPOST('selectpaymentsofsalaries')) {
if (!empty($sql)) $sql .= " UNION ALL"; if (!empty($sql)) $sql .= " UNION ALL";
$sql .= " SELECT t.rowid as id, t.entity, t.label as ref, 1 as paid, amount as total_ht, amount as total_ttc, 0 as total_vat, '".$db->escape($conf->currency)."' as currency, t.fk_user as fk_soc, t.datep as date, t.dateep as date_due, 'SalaryPayment' as item, CONCAT(CONCAT(u.lastname, ' '), u.firstname) as thirdparty_name, '' as thirdparty_code, c.code as country_code, '' as vatnum, ".PAY_DEBIT." as sens"; $sql .= " SELECT t.rowid as id, t.entity, t.label as ref, 1 as paid, amount as total_ht, amount as total_ttc, 0 as total_vat, '".$db->escape($conf->currency)."' as currency, t.fk_user as fk_soc, t.datep as date, t.dateep as date_due, 'SalaryPayment' as item, CONCAT(CONCAT(u.lastname, ' '), u.firstname) as thirdparty_name, '' as thirdparty_code, c.code as country_code, '' as vatnum, ".PAY_DEBIT." as sens";
@ -203,7 +203,7 @@ if (($action == 'searchfiles' || $action == 'dl')) {
// Various payments // Various payments
if (GETPOST('selectvariouspayment')) { if (GETPOST('selectvariouspayment')) {
if (!empty($sql)) $sql .= " UNION ALL"; if (!empty($sql)) $sql .= " UNION ALL";
$sql .= " SELECT t.rowid as id, t.entity, t.label as ref, 1 as paid, t.amount as total_ht, t.amount as total_ttc, 0 as total_vat, '".$db->escape($conf->currency)."' as currency, 0 as fk_soc, t.datep as date, t.datep as date_due, 'VariousPayment' as item, '' as thirdparty_name, '' as thirdparty_code, '' as country_code, '' as vatnum, sens"; $sql .= " SELECT t.rowid as id, t.entity, t.ref, 1 as paid, t.amount as total_ht, t.amount as total_ttc, 0 as total_vat, '".$db->escape($conf->currency)."' as currency, 0 as fk_soc, t.datep as date, t.datep as date_due, 'VariousPayment' as item, '' as thirdparty_name, '' as thirdparty_code, '' as country_code, '' as vatnum, sens";
$sql .= " FROM ".MAIN_DB_PREFIX."payment_various as t"; $sql .= " FROM ".MAIN_DB_PREFIX."payment_various as t";
$sql .= " WHERE datep between ".$wheretail; $sql .= " WHERE datep between ".$wheretail;
$sql .= " AND t.entity IN (".($entity == 1 ? '0,1' : $entity).')'; $sql .= " AND t.entity IN (".($entity == 1 ? '0,1' : $entity).')';
@ -581,7 +581,7 @@ if (!empty($date_start) && !empty($date_stop))
foreach ($listofchoices as $choice => $val) { foreach ($listofchoices as $choice => $val) {
$param .= '&'.$choice.'='.(GETPOST($choice, 'int') ? 1 : 0); $param .= '&'.$choice.'='.(GETPOST($choice, 'int') ? 1 : 0);
} }
print '<form name="dl" action="?action=dl" method="POST" >'."\n"; print '<form name="dl" action="'.$_SERVER["PHP_SELF"].'?action=dl" method="POST">'."\n";
print '<input type="hidden" name="token" value="'.currentToken().'">'; print '<input type="hidden" name="token" value="'.currentToken().'">';
echo dol_print_date($date_start, 'day')." - ".dol_print_date($date_stop, 'day'); echo dol_print_date($date_start, 'day')." - ".dol_print_date($date_stop, 'day');
@ -592,7 +592,7 @@ if (!empty($date_start) && !empty($date_stop))
print '<input type="hidden" name="'.$choice.'" value="'.GETPOST($choice).'">'; print '<input type="hidden" name="'.$choice.'" value="'.GETPOST($choice).'">';
} }
print '<input class="butAction" type="submit" value="'.$langs->trans("Download").'" />'; print '<input class="butAction butDownload" type="submit" value="'.$langs->trans("Download").'" />';
print '</form>'."\n"; print '</form>'."\n";
print '<br>'; print '<br>';
@ -606,13 +606,14 @@ if (!empty($date_start) && !empty($date_stop))
print_liste_field_titre($arrayfields['ref']['label'], $_SERVER["PHP_SELF"], "", "", $param, '', $sortfield, $sortorder, 'nowraponall '); print_liste_field_titre($arrayfields['ref']['label'], $_SERVER["PHP_SELF"], "", "", $param, '', $sortfield, $sortorder, 'nowraponall ');
print '<td>'.$langs->trans("Document").'</td>'; print '<td>'.$langs->trans("Document").'</td>';
print '<td>'.$langs->trans("Paid").'</td>'; print '<td>'.$langs->trans("Paid").'</td>';
print '<td align="right">'.$langs->trans("TotalHT").'</td>'; print '<td align="right">'.$langs->trans("TotalHT").($conf->multicurrency->enabled ? ' ('.$conf->currency.')' : '').'</td>';
print '<td align="right">'.$langs->trans("TotalTTC").'</td>'; print '<td align="right">'.$langs->trans("TotalTTC").($conf->multicurrency->enabled ? ' ('.$conf->currency.')' : '').'</td>';
print '<td align="right">'.$langs->trans("TotalVAT").'</td>'; print '<td align="right">'.$langs->trans("TotalVAT").($conf->multicurrency->enabled ? ' ('.$conf->currency.')' : '').'</td>';
print '<td>'.$langs->trans("ThirdParty").'</td>'; print '<td>'.$langs->trans("ThirdParty").'</td>';
print '<td class="center">'.$langs->trans("Code").'</td>'; print '<td class="center">'.$langs->trans("Code").'</td>';
print '<td class="center">'.$langs->trans("Country").'</td>'; print '<td class="center">'.$langs->trans("Country").'</td>';
print '<td class="center">'.$langs->trans("VATIntra").'</td>'; print '<td class="center">'.$langs->trans("VATIntra").'</td>';
if ($conf->multicurrency->enabled) print '<td class="center">'.$langs->trans("Currency").'</td>';
print '</tr>'; print '</tr>';
if ($result) if ($result)
{ {
@ -620,7 +621,11 @@ if (!empty($date_start) && !empty($date_stop))
if (empty($TData)) if (empty($TData))
{ {
print '<tr class="oddeven"><td colspan="7">'.$langs->trans("NoItem").'</td></tr>'; print '<tr class="oddeven"><td colspan="7">'.$langs->trans("NoItem").'</td>';
if (! empty($conf->multicurrency->enabled)) {
print '<td></td>';
}
print '</tr>';
} else { } else {
// Sort array by date ASC to calculate balance // Sort array by date ASC to calculate balance
@ -647,7 +652,7 @@ if (!empty($date_start) && !empty($date_stop))
print dol_print_date($data['date'], 'day'); print dol_print_date($data['date'], 'day');
print "</td>\n"; print "</td>\n";
// Date // Date due
print '<td class="center">'; print '<td class="center">';
print dol_print_date($data['date_due'], 'day'); print dol_print_date($data['date_due'], 'day');
print "</td>\n"; print "</td>\n";
@ -658,10 +663,18 @@ if (!empty($date_start) && !empty($date_stop))
if ($data['item'] == 'Invoice') { if ($data['item'] == 'Invoice') {
$invoice->id = $data['id']; $invoice->id = $data['id'];
$invoice->ref = $data['ref']; $invoice->ref = $data['ref'];
$invoice->total_ht = $data['amount_ht'];
$invoice->total_ttc = $data['amount_ttc'];
$invoice->total_tva = $data['amount_vat'];
$invoice->multicurrency_code = $data['currency'];
print $invoice->getNomUrl(1, '', 0, 0, '', 0, 0, 0); print $invoice->getNomUrl(1, '', 0, 0, '', 0, 0, 0);
} elseif ($data['item'] == 'SupplierInvoice') { } elseif ($data['item'] == 'SupplierInvoice') {
$supplier_invoice->id = $data['id']; $supplier_invoice->id = $data['id'];
$supplier_invoice->ref = $data['ref']; $supplier_invoice->ref = $data['ref'];
$supplier_invoice->total_ht = $data['amount_ht'];
$supplier_invoice->total_ttc = $data['amount_ttc'];
$supplier_invoice->total_tva = $data['amount_vat'];
$supplier_invoice->multicurrency_code = $data['currency'];
print $supplier_invoice->getNomUrl(1, '', 0, 0, '', 0, 0, 0); print $supplier_invoice->getNomUrl(1, '', 0, 0, '', 0, 0, 0);
} elseif ($data['item'] == 'ExpenseReport') { } elseif ($data['item'] == 'ExpenseReport') {
$expensereport->id = $data['id']; $expensereport->id = $data['id'];
@ -712,7 +725,7 @@ if (!empty($date_start) && !empty($date_stop))
// Total VAT // Total VAT
print '<td align="right">'.price($data['sens'] ? $data['amount_vat'] : -$data['amount_vat'])."</td>\n"; print '<td align="right">'.price($data['sens'] ? $data['amount_vat'] : -$data['amount_vat'])."</td>\n";
print '<td>'.$data['thirdparty_name']."</td>\n"; print '<td class="tdoverflowmax150" title="'.$data['thirdparty_name'].'">'.$data['thirdparty_name']."</td>\n";
print '<td class="center">'.$data['thirdparty_code']."</td>\n"; print '<td class="center">'.$data['thirdparty_code']."</td>\n";
@ -730,6 +743,10 @@ if (!empty($date_start) && !empty($date_stop))
$totalVAT_debit -= $data['amount_vat']; $totalVAT_debit -= $data['amount_vat'];
} }
if (! empty($conf->multicurrency->enabled)) {
print '<td class="center">'.$data['currency']."</td>\n";
}
print "</tr>\n"; print "</tr>\n";
} }
@ -740,6 +757,9 @@ if (!empty($date_start) && !empty($date_stop))
print '<td align="right">'.price(price2num($totalIT_credit, 'MT')).'</td>'; print '<td align="right">'.price(price2num($totalIT_credit, 'MT')).'</td>';
print '<td align="right">'.price(price2num($totalVAT_credit, 'MT')).'</td>'; print '<td align="right">'.price(price2num($totalVAT_credit, 'MT')).'</td>';
print '<td colspan="4"></td>'; print '<td colspan="4"></td>';
if (! empty($conf->multicurrency->enabled)) {
print '<td></td>';
}
print "</tr>\n"; print "</tr>\n";
// Total debits // Total debits
print '<tr class="liste_total">'; print '<tr class="liste_total">';
@ -748,6 +768,9 @@ if (!empty($date_start) && !empty($date_stop))
print '<td align="right">'.price(price2num($totalIT_debit, 'MT')).'</td>'; print '<td align="right">'.price(price2num($totalIT_debit, 'MT')).'</td>';
print '<td align="right">'.price(price2num($totalVAT_debit, 'MT')).'</td>'; print '<td align="right">'.price(price2num($totalVAT_debit, 'MT')).'</td>';
print '<td colspan="4"></td>'; print '<td colspan="4"></td>';
if (! empty($conf->multicurrency->enabled)) {
print '<td></td>';
}
print "</tr>\n"; print "</tr>\n";
// Balance // Balance
print '<tr class="liste_total">'; print '<tr class="liste_total">';
@ -756,6 +779,9 @@ if (!empty($date_start) && !empty($date_stop))
print '<td align="right">'.price(price2num($totalIT_credit + $totalIT_debit, 'MT')).'</td>'; print '<td align="right">'.price(price2num($totalIT_credit + $totalIT_debit, 'MT')).'</td>';
print '<td align="right">'.price(price2num($totalVAT_credit + $totalVAT_debit, 'MT')).'</td>'; print '<td align="right">'.price(price2num($totalVAT_credit + $totalVAT_debit, 'MT')).'</td>';
print '<td colspan="4"></td>'; print '<td colspan="4"></td>';
if (! empty($conf->multicurrency->enabled)) {
print '<td></td>';
}
print "</tr>\n"; print "</tr>\n";
} }
} }

File diff suppressed because it is too large Load Diff

View File

@ -338,6 +338,24 @@ class PaymentVarious extends CommonObject
$this->fk_user_modif = ''; $this->fk_user_modif = '';
} }
/**
* Check if a miscellaneous payment can be created into database
*
* @return boolean True or false
*/
public function check()
{
$newamount = price2num($this->amount, 'MT');
// Validation of parameters
if (!($newamount) > 0 || empty($this->datep))
{
return false;
}
return true;
}
/** /**
* Create in database * Create in database
* *

View File

@ -41,8 +41,9 @@ $langs->loadLangs(array("compta", "banks", "bills", "users", "accountancy", "cat
// Get parameters // Get parameters
$id = GETPOST('id', 'int'); $id = GETPOST('id', 'int');
$action = GETPOST('action', 'alpha'); $action = GETPOST('action', 'alpha');
$cancel = GETPOST('cancel', 'aZ09'); $confirm = GETPOST('confirm');
$cancel = GETPOST('cancel', 'aZ09');
$backtopage = GETPOST('backtopage', 'alpha'); $backtopage = GETPOST('backtopage', 'alpha');
$accountid = GETPOST("accountid") > 0 ? GETPOST("accountid", "int") : 0; $accountid = GETPOST("accountid") > 0 ? GETPOST("accountid", "int") : 0;
@ -225,6 +226,64 @@ if (empty($reshook))
} }
} }
// Action clone object
if ($action == 'confirm_clone' && $confirm != 'yes') { $action = ''; }
if ($action == 'confirm_clone' && $confirm == 'yes' && ($user->rights->banque->modifier))
{
$db->begin();
$originalId = $id;
$object->fetch($id);
if ($object->id > 0)
{
$object->id = $object->ref = null;
if (GETPOST('clone_label', 'alphanohtml')) {
$object->label = GETPOST('clone_label', 'alphanohtml');
} else {
$object->label = $langs->trans("CopyOf").' '.$object->label;
}
$newdatepayment = dol_mktime(0, 0, 0, GETPOST('clone_date_paymentmonth', 'int'), GETPOST('clone_date_paymentday', 'int'), GETPOST('clone_date_paymentyear', 'int'));
$newdatevalue = dol_mktime(0, 0, 0, GETPOST('clone_date_valuemonth', 'int'), GETPOST('clone_date_valueday', 'int'), GETPOST('clone_date_valueyear', 'int'));
if ($newdatepayment) $object->datep = $newdatepayment;
if (!empty($newdatevalue)) {
$object->datev = $newdatevalue;
} else {
$object->datev = $newdatepayment;
}
if ($object->check())
{
$id = $object->create($user);
if ($id > 0)
{
$db->commit();
$db->close();
header("Location: ".$_SERVER["PHP_SELF"]."?id=".$id);
exit;
} else {
$id = $originalId;
$db->rollback();
setEventMessages($object->error, $object->errors, 'errors');
}
} else {
$id = $originalId;
$db->rollback();
setEventMessages($object->error, $object->errors, 'errors');
}
} else {
$db->rollback();
dol_print_error($db, $object->error);
}
}
/* /*
* View * View
@ -419,6 +478,19 @@ if ($id)
$head = various_payment_prepare_head($object); $head = various_payment_prepare_head($object);
// Clone confirmation
if ($action === 'clone')
{
$formquestion = array(
array('type' => 'text', 'name' => 'clone_label', 'label' => $langs->trans("Label"), 'value' => $langs->trans("CopyOf").' '.$object->label),
);
$formquestion[] = array('type' => 'date', 'tdclass'=>'fieldrequired', 'name' => 'clone_date_payment', 'label' => $langs->trans("DatePayment"), 'value' => -1);
$formquestion[] = array('type' => 'date', 'name' => 'clone_date_value', 'label' => $langs->trans("DateValue"), 'value' => -1);
$formquestion[] = array('type' => 'other', 'tdclass'=>'fieldrequired', 'name' => 'accountid', 'label' => $langs->trans("BankAccount"), 'value' => $form->select_comptes($accountid, "accountid", 0, '', 1));
print $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ToClone'), $langs->trans('ConfirmCloneVariousPayment', $object->ref), 'confirm_clone', $formquestion, 'yes', 1, 300);
}
dol_fiche_head($head, 'card', $langs->trans("VariousPayment"), -1, $object->picto); dol_fiche_head($head, 'card', $langs->trans("VariousPayment"), -1, $object->picto);
$morehtmlref = '<div class="refidno">'; $morehtmlref = '<div class="refidno">';
@ -542,6 +614,12 @@ if ($id)
// TODO // TODO
// Add button modify // Add button modify
// Clone
if ($user->rights->banque->modifier)
{
print '<div class="inline-block divButAction"><a class="butAction" href="'.dol_buildpath("/compta/bank/various_payment/card.php", 1).'?id='.$object->id.'&amp;action=clone">'.$langs->trans("ToClone")."</a></div>";
}
// Delete // Delete
if (empty($object->rappro)) if (empty($object->rappro))
{ {

View File

@ -490,9 +490,9 @@ if ($result)
print $accountstatic->getNomUrl(1); print $accountstatic->getNomUrl(1);
} else { } else {
print '&nbsp;'; print '&nbsp;';
print '</td>';
if (!$i) $totalarray['nbfield']++;
} }
print '</td>';
if (!$i) $totalarray['nbfield']++;
} }
// Bank entry // Bank entry

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

@ -188,8 +188,8 @@ if (empty($reshook))
if (!$error) if (!$error)
{ {
$object->titre = GETPOST('titre', 'nohtml'); // deprecated $object->titre = GETPOST('title', 'nohtml'); // deprecated
$object->title = GETPOST('titre', 'nohtml'); $object->title = GETPOST('title', 'nohtml');
$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');
$object->model_pdf = GETPOST('modelpdf', 'alpha'); $object->model_pdf = GETPOST('modelpdf', 'alpha');

View File

@ -1499,7 +1499,7 @@ class Invoices extends DolibarrApi
$amount = price2num($amountarray["multicurrency_amount"], 'MT'); $amount = price2num($amountarray["multicurrency_amount"], 'MT');
} }
if ($amount > $remainstopay && $accepthigherpayment == false) { if ($amount > $remainstopay && !$accepthigherpayment) {
$this->db->rollback(); $this->db->rollback();
throw new RestException(400, 'Payment amount on invoice ID '.$id.' ('.$amount.') is higher than remain to pay ('.$remainstopay.')'); throw new RestException(400, 'Payment amount on invoice ID '.$id.' ('.$amount.') is higher than remain to pay ('.$remainstopay.')');
} }

View File

@ -74,6 +74,11 @@ class FactureRec extends CommonInvoice
*/ */
protected $table_ref_field = 'titre'; protected $table_ref_field = 'titre';
/**
* @var string The label of recurring invoice
*/
public $title;
public $number; public $number;
public $date; public $date;
public $remise; public $remise;

View File

@ -51,7 +51,7 @@ $maxOpenCount = empty($conf->global->MAIN_MAXLIST_OVERLOAD) ? 500 : $conf->glob
llxHeader("", $langs->trans("CustomersInvoicesArea"), "EN:Customers_Invoices|FR:Factures_Clients|ES:Facturas_a_clientes"); llxHeader("", $langs->trans("CustomersInvoicesArea"), "EN:Customers_Invoices|FR:Factures_Clients|ES:Facturas_a_clientes");
print load_fiche_titre($langs->trans("CustomersInvoicesArea"), '', 'invoicing'); print load_fiche_titre($langs->trans("CustomersInvoicesArea"), '', 'bill');
print '<div class="fichecenter">'; print '<div class="fichecenter">';

View File

@ -478,7 +478,7 @@ if ($resql)
} }
// Action column // Action column
print '<td class="liste_titre" align="middle">'; print '<td class="liste_titre" align="middle">';
$searchpicto = $form->showFilterAndCheckAddButtons(0, 'checkforselect', 1); $searchpicto = $form->showFilterButtons();
print $searchpicto; print $searchpicto;
print '</td>'; print '</td>';
print "</tr>\n"; print "</tr>\n";
@ -502,7 +502,7 @@ if ($resql)
// Extra fields // Extra fields
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
if (!empty($arrayfields['status']['checked'])) print_liste_field_titre($arrayfields['status']['label'], $_SERVER['PHP_SELF'], "f.suspended,f.frequency", "", $param, 'align="center"', $sortfield, $sortorder); if (!empty($arrayfields['status']['checked'])) print_liste_field_titre($arrayfields['status']['label'], $_SERVER['PHP_SELF'], "f.suspended,f.frequency", "", $param, 'align="center"', $sortfield, $sortorder);
print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', 'align="center"', $sortfield, $sortorder, 'nomaxwidthsearch '); print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', 'align="center"', $sortfield, $sortorder, 'center maxwidthsearch ');
print "</tr>\n"; print "</tr>\n";
if ($num > 0) if ($num > 0)

View File

@ -1040,8 +1040,10 @@ if (!empty($conf->facture->enabled) && $user->rights->facture->lire)
} }
if ($othernb) { if ($othernb) {
$colspan = 6;
if (!empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) $colspan++;
print '<tr class="oddeven">'; print '<tr class="oddeven">';
print '<td class="nowrap" colspan="5">'; print '<td class="nowrap" colspan="'.$colspan.'">';
print '<span class="opacitymedium">'.$langs->trans("More").'... ('.$othernb.')</span>'; print '<span class="opacitymedium">'.$langs->trans("More").'... ('.$othernb.')</span>';
print '</td>'; print '</td>';
print "</tr>\n"; print "</tr>\n";
@ -1174,8 +1176,10 @@ if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SU
} }
if ($othernb) { if ($othernb) {
$colspan = 6;
if (!empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) $colspan++;
print '<tr class="oddeven">'; print '<tr class="oddeven">';
print '<td class="nowrap" colspan="5">'; print '<td class="nowrap" colspan="'.$colspan.'">';
print '<span class="opacitymedium">'.$langs->trans("More").'... ('.$othernb.')</span>'; print '<span class="opacitymedium">'.$langs->trans("More").'... ('.$othernb.')</span>';
print '</td>'; print '</td>';
print "</tr>\n"; print "</tr>\n";

View File

@ -220,7 +220,7 @@ if ($resql)
print '<td class="liste_titre"><input type="text" class="flat maxwidth100" name="search_label" value="'.dol_escape_htmltag($search_label).'"></td>'; print '<td class="liste_titre"><input type="text" class="flat maxwidth100" name="search_label" value="'.dol_escape_htmltag($search_label).'"></td>';
// Type // Type
print '<td class="liste_titre" align="left">'; print '<td class="liste_titre" align="left">';
$formsocialcontrib->select_type_socialcontrib($search_typeid, 'search_typeid', 1, 0, 0, 'maxwidth100onsmartphone'); $formsocialcontrib->select_type_socialcontrib($search_typeid, 'search_typeid', 1, 0, 0, 'maxwidth100onsmartphone', 1);
print '</td>'; print '</td>';
// Ref Project // Ref Project
if (!empty($conf->projet->enabled)) print '<td class="liste_titre"><input type="text" class="flat" size="6" name="search_project_ref" value="'.$search_project_ref.'"></td>'; if (!empty($conf->projet->enabled)) print '<td class="liste_titre"><input type="text" class="flat" size="6" name="search_project_ref" value="'.$search_project_ref.'"></td>';

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);
} }
} }

View File

@ -1083,25 +1083,6 @@ class Form
} }
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Return HTML code to select a company.
*
* @param int $selected Preselected products
* @param string $htmlname Name of HTML select field (must be unique in page)
* @param int $filter Filter on thirdparty
* @param int $limit Limit on number of returned lines
* @param array $ajaxoptions Options for ajax_autocompleter
* @param int $forcecombo Force to load all values and output a standard combobox (with no beautification)
* @return string Return select box for thirdparty.
* @deprecated 3.8 Use select_company instead. For exemple $form->select_thirdparty(GETPOST('socid'),'socid','',0) => $form->select_company(GETPOST('socid'),'socid','',1,0,0,array(),0)
*/
public function select_thirdparty($selected = '', $htmlname = 'socid', $filter = '', $limit = 20, $ajaxoptions = array(), $forcecombo = 0)
{
// phpcs:enable
return $this->select_thirdparty_list($selected, $htmlname, $filter, 1, 0, $forcecombo, array(), '', 0, $limit);
}
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/** /**
* Output html form to select a third party * Output html form to select a third party
@ -5315,6 +5296,7 @@ class Form
} }
// Analysis of the pre-selection date // Analysis of the pre-selection date
$reg = array();
if (preg_match('/^([0-9]+)\-([0-9]+)\-([0-9]+)\s?([0-9]+)?:?([0-9]+)?/', $set_time, $reg)) // deprecated usage if (preg_match('/^([0-9]+)\-([0-9]+)\-([0-9]+)\s?([0-9]+)?:?([0-9]+)?/', $set_time, $reg)) // deprecated usage
{ {
// Date format 'YYYY-MM-DD' or 'YYYY-MM-DD HH:MM:SS' // Date format 'YYYY-MM-DD' or 'YYYY-MM-DD HH:MM:SS'
@ -5807,7 +5789,7 @@ class Form
* @param int $disabled 1=Html component is disabled * @param int $disabled 1=Html component is disabled
* @param string $selected_input_value Value of preselected input text (for use with ajax) * @param string $selected_input_value Value of preselected input text (for use with ajax)
* @return string Return HTML string * @return string Return HTML string
* @see selectForFormsList() select_thirdparty() * @see selectForFormsList() select_thirdparty_list()
*/ */
public function selectForForms($objectdesc, $htmlname, $preselectedvalue, $showempty = '', $searchkey = '', $placeholder = '', $morecss = '', $moreparams = '', $forcecombo = 0, $disabled = 0, $selected_input_value = '') public function selectForForms($objectdesc, $htmlname, $preselectedvalue, $showempty = '', $searchkey = '', $placeholder = '', $morecss = '', $moreparams = '', $forcecombo = 0, $disabled = 0, $selected_input_value = '')
{ {

View File

@ -115,7 +115,7 @@ class FormFile
if (empty($usewithoutform)) // Try to avoid this and set instead the form by the caller. if (empty($usewithoutform)) // Try to avoid this and set instead the form by the caller.
{ {
// Add a param as GET parameter to detect when POST were cleaned by PHP because a file larger than post_max_size // Add a param as GET parameter to detect when POST were cleaned by PHP because a file larger than post_max_size
$url .= (strpos('?', $url) === false ? '?' : '&').'uploadform=1'; $url .= (strpos($url, '?') === false ? '?' : '&').'uploadform=1';
$out .= '<form name="'.$htmlname.'" id="'.$htmlname.'" action="'.$url.'" enctype="multipart/form-data" method="POST">'; $out .= '<form name="'.$htmlname.'" id="'.$htmlname.'" action="'.$url.'" enctype="multipart/form-data" method="POST">';
$out .= '<input type="hidden" name="token" value="'.newToken().'">'; $out .= '<input type="hidden" name="token" value="'.newToken().'">';

File diff suppressed because it is too large Load Diff

View File

@ -170,7 +170,7 @@ class FormProjets
if (empty($conf->global->PROJECT_ALLOW_TO_LINK_FROM_OTHER_COMPANY)) $sql .= " AND (p.fk_soc=".$socid." OR p.fk_soc IS NULL)"; if (empty($conf->global->PROJECT_ALLOW_TO_LINK_FROM_OTHER_COMPANY)) $sql .= " AND (p.fk_soc=".$socid." OR p.fk_soc IS NULL)";
elseif ($conf->global->PROJECT_ALLOW_TO_LINK_FROM_OTHER_COMPANY != 'all') // PROJECT_ALLOW_TO_LINK_FROM_OTHER_COMPANY is 'all' or a list of ids separated by coma. elseif ($conf->global->PROJECT_ALLOW_TO_LINK_FROM_OTHER_COMPANY != 'all') // PROJECT_ALLOW_TO_LINK_FROM_OTHER_COMPANY is 'all' or a list of ids separated by coma.
{ {
$sql .= " AND (p.fk_soc IN (".$socid.", ".$conf->global->PROJECT_ALLOW_TO_LINK_FROM_OTHER_COMPANY.") OR p.fk_soc IS NULL)"; $sql .= " AND (p.fk_soc IN (".$socid.", ".((int) $conf->global->PROJECT_ALLOW_TO_LINK_FROM_OTHER_COMPANY).") OR p.fk_soc IS NULL)";
} }
} }
if (!empty($filterkey)) $sql .= natural_search(array('p.title', 'p.ref'), $filterkey); if (!empty($filterkey)) $sql .= natural_search(array('p.title', 'p.ref'), $filterkey);

View File

@ -59,17 +59,18 @@ class FormSocialContrib
* @param int $maxlen Max length of text in combo box * @param int $maxlen Max length of text in combo box
* @param int $help Add or not the admin help picto * @param int $help Add or not the admin help picto
* @param string $morecss Add more CSS on select * @param string $morecss Add more CSS on select
* @param int $noerrorifempty No print error if list is empty for the country
* @return void * @return void
*/ */
public function select_type_socialcontrib($selected = '', $htmlname = 'actioncode', $useempty = 0, $maxlen = 40, $help = 1, $morecss = 'minwidth300') public function select_type_socialcontrib($selected = '', $htmlname = 'actioncode', $useempty = 0, $maxlen = 40, $help = 1, $morecss = 'minwidth300', $noerrorifempty = 0)
{ {
// phpcs:enable // phpcs:enable
global $conf, $db, $langs, $user, $mysoc; global $conf, $db, $langs, $user, $mysoc;
if (empty($mysoc->country_id) && empty($mysoc->country_code)) if (empty($mysoc->country_id) && empty($mysoc->country_code))
{ {
dol_print_error('', 'Call to select_type_socialcontrib with mysoc country not yet defined'); print $langs->trans("ErrorSetupOfCountryMustBeDone");
exit; return;
} }
if (!empty($mysoc->country_id)) if (!empty($mysoc->country_id))
@ -110,7 +111,7 @@ class FormSocialContrib
if ($user->admin && $help) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); if ($user->admin && $help) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1);
if (!empty($conf->use_javascript_ajax)) print ajax_combobox($htmlname); if (!empty($conf->use_javascript_ajax)) print ajax_combobox($htmlname);
} else { } else {
print $langs->trans("ErrorNoSocialContributionForSellerCountry", $mysoc->country_code); if (empty($noerrorifempty)) print $langs->trans("ErrorNoSocialContributionForSellerCountry", $mysoc->country_code);
} }
} else { } else {
dol_print_error($this->db); dol_print_error($this->db);

View File

@ -173,6 +173,7 @@ class Menubase
global $conf, $langs; global $conf, $langs;
// Clean parameters // Clean parameters
if (!isset($this->enabled)) $this->enabled = '1';
$this->menu_handler = trim($this->menu_handler); $this->menu_handler = trim($this->menu_handler);
$this->module = trim($this->module); $this->module = trim($this->module);
$this->type = trim($this->type); $this->type = trim($this->type);

View File

@ -90,7 +90,7 @@ abstract class DoliDB implements Database
public function idate($param) public function idate($param)
{ {
// TODO GMT $param should be gmt, so we should add tzouptut to 'gmt' // TODO GMT $param should be gmt, so we should add tzouptut to 'gmt'
return dol_print_date($param, "%Y-%m-%d %H:%M:%S"); return dol_print_date($param, "%Y-%m-%d %H:%M:%S", 'tzserver');
} }
/** /**

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))
@ -1209,6 +1209,38 @@ function dol_syslog($message, $level = LOG_INFO, $ident = 0, $suffixinfilename =
} }
} }
/**
* Return HTML code to output a button to open a dialog popup box.
* Such buttons must be included inside a HTML form.
*
* @param string $name A name for the html component
* @param string $label Label of button
* @param string $buttonstring button string
* @param string $url Url to open
* @param string $disabled Disabled text
* @return string HTML component with button
*/
function dolButtonToOpenUrlInDialogPopup($name, $label, $buttonstring, $url, $disabled = '')
{
//print '<input type="submit" class="button bordertransp"'.$disabled.' value="'.dol_escape_htmltag($langs->trans("MediaFiles")).'" name="file_manager">';
$out = '<a class="button bordertransp button_'.$name.'"'.$disabled.' title="'.dol_escape_htmltag($label).'">'.$buttonstring.'</a>';
$out .= '<script language="javascript">
jQuery(document).ready(function () {
jQuery(".button_'.$name.'").click(function () {
var $dialog = $(\'<div></div>\').html(\'<iframe class="iframedialog" style="border: 0px;" src="'.DOL_URL_ROOT.$url.'" width="100%" height="98%"></iframe>\')
.dialog({
autoOpen: false,
modal: true,
height: (window.innerHeight - 150),
width: \'80%\',
title: "'.dol_escape_js($label).'"
});
$dialog.dialog(\'open\');
});
});
</script>';
return $out;
}
/** /**
* Show tab header of a card * Show tab header of a card
@ -1224,6 +1256,7 @@ function dol_syslog($message, $level = LOG_INFO, $ident = 0, $suffixinfilename =
* @param int $limittoshow Limit number of tabs to show. Use 0 to use automatic default value. * @param int $limittoshow Limit number of tabs to show. Use 0 to use automatic default value.
* @param string $moretabssuffix A suffix to use when you have several dol_get_fiche_head() in same page * @param string $moretabssuffix A suffix to use when you have several dol_get_fiche_head() in same page
* @return void * @return void
* @deprecated Use print dol_get_fiche_head() instead
*/ */
function dol_fiche_head($links = array(), $active = '0', $title = '', $notab = 0, $picto = '', $pictoisfullpath = 0, $morehtmlright = '', $morecss = '', $limittoshow = 0, $moretabssuffix = '') function dol_fiche_head($links = array(), $active = '0', $title = '', $notab = 0, $picto = '', $pictoisfullpath = 0, $morehtmlright = '', $morecss = '', $limittoshow = 0, $moretabssuffix = '')
{ {
@ -1371,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>';
@ -1382,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');
@ -2775,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;
} }
@ -3100,7 +3133,7 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $
'filter', 'file-code', 'file-export', 'file-import', 'file-upload', 'folder', 'folder-open', 'globe', 'globe-americas', 'grip', 'grip_title', 'filter', 'file-code', 'file-export', 'file-import', 'file-upload', 'folder', 'folder-open', 'globe', 'globe-americas', 'grip', 'grip_title',
'help', 'holiday', 'help', 'holiday',
'intervention', 'label', 'language', 'list', 'listlight', 'lot', 'intervention', 'label', 'language', 'list', 'listlight', 'lot',
'map-marker-alt', 'money-bill-alt', 'mrp', 'note', 'map-marker-alt', 'money-bill-alt', 'mrp', 'note', 'next',
'object_accounting', 'object_account', 'object_accountline', 'object_action', 'object_barcode', 'object_bill', 'object_billa', 'object_billd', 'object_bom', 'object_accounting', 'object_account', 'object_accountline', 'object_action', 'object_barcode', 'object_bill', 'object_billa', 'object_billd', 'object_bom',
'object_category', 'object_conversation', 'object_bookmark', 'object_bug', 'object_dolly', 'object_dollyrevert', 'object_generic', 'object_folder', 'object_category', 'object_conversation', 'object_bookmark', 'object_bug', 'object_dolly', 'object_dollyrevert', 'object_generic', 'object_folder',
'object_list-alt', 'object_calendar', 'object_calendarweek', 'object_calendarmonth', 'object_calendarday', 'object_calendarperuser', 'object_list-alt', 'object_calendar', 'object_calendarweek', 'object_calendarmonth', 'object_calendarday', 'object_calendarperuser',
@ -3114,7 +3147,7 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $
'object_technic', 'object_ticket', 'object_trip', 'object_user', 'object_group', 'object_member', 'object_technic', 'object_ticket', 'object_trip', 'object_user', 'object_group', 'object_member',
'object_phoning', 'object_phoning_mobile', 'object_phoning_fax', 'object_email', 'object_website', 'object_phoning', 'object_phoning_mobile', 'object_phoning_fax', 'object_email', 'object_website',
'off', 'on', 'order', 'off', 'on', 'order',
'paiment', 'play', 'playdisabled', 'poll', 'printer', 'product', 'propal', 'projecttask', 'stock', 'resize', 'service', 'stats', 'trip', 'paiment', 'play', 'playdisabled', 'previous', 'poll', 'printer', 'product', 'propal', 'projecttask', 'stock', 'resize', 'service', 'stats', 'trip',
'setup', 'share-alt', 'sign-out', 'split', 'stripe-s', 'switch_off', 'switch_on', 'tools', 'unlink', 'uparrow', 'user', 'vcard', 'wrench', 'setup', 'share-alt', 'sign-out', 'split', 'stripe-s', 'switch_off', 'switch_on', 'tools', 'unlink', 'uparrow', 'user', 'vcard', 'wrench',
'jabber', 'skype', 'twitter', 'facebook', 'linkedin', 'instagram', 'snapchat', 'youtube', 'google-plus-g', 'whatsapp', 'jabber', 'skype', 'twitter', 'facebook', 'linkedin', 'instagram', 'snapchat', 'youtube', 'google-plus-g', 'whatsapp',
'chevron-left', 'chevron-right', 'chevron-down', 'chevron-top', 'commercial', 'companies', 'chevron-left', 'chevron-right', 'chevron-down', 'chevron-top', 'commercial', 'companies',
@ -3148,7 +3181,8 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $
'email'=>'at', 'email'=>'at',
'edit'=>'pencil-alt', 'grip_title'=>'arrows-alt', 'grip'=>'arrows-alt', 'help'=>'question-circle', 'edit'=>'pencil-alt', 'grip_title'=>'arrows-alt', 'grip'=>'arrows-alt', 'help'=>'question-circle',
'generic'=>'file', 'holiday'=>'umbrella-beach', 'label'=>'layer-group', 'generic'=>'file', 'holiday'=>'umbrella-beach', 'label'=>'layer-group',
'member'=>'users', 'mrp'=>'cubes', 'trip'=>'wallet', 'group'=>'users', 'member'=>'users', 'mrp'=>'cubes', 'next'=>'arrow-alt-circle-right',
'trip'=>'wallet', 'group'=>'users',
'sign-out'=>'sign-out-alt', 'sign-out'=>'sign-out-alt',
'switch_off'=>'toggle-off', 'switch_on'=>'toggle-on', 'check'=>'check', 'bookmark'=>'star', 'bookmark'=>'star', 'switch_off'=>'toggle-off', 'switch_on'=>'toggle-on', 'check'=>'check', 'bookmark'=>'star', 'bookmark'=>'star',
'bank'=>'university', 'close_title'=>'window-close', 'delete'=>'trash', 'edit'=>'pencil-alt', 'filter'=>'filter', 'bank'=>'university', 'close_title'=>'window-close', 'delete'=>'trash', 'edit'=>'pencil-alt', 'filter'=>'filter',
@ -3159,7 +3193,7 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $
'playdisabled'=>'play', 'poll'=>'check-double', 'preview'=>'binoculars', 'project'=>'sitemap', 'projectpub'=>'sitemap', 'projecttask'=>'tasks', 'propal'=>'file-signature', 'playdisabled'=>'play', 'poll'=>'check-double', 'preview'=>'binoculars', 'project'=>'sitemap', 'projectpub'=>'sitemap', 'projecttask'=>'tasks', 'propal'=>'file-signature',
'recruitmentjobposition'=>'id-card-alt', 'recruitmentcandidature'=>'id-badge', 'recruitmentjobposition'=>'id-card-alt', 'recruitmentcandidature'=>'id-badge',
'resize'=>'crop', 'supplier_order'=>'dol-order_supplier', 'supplier_proposal'=>'file-signature', 'resize'=>'crop', 'supplier_order'=>'dol-order_supplier', 'supplier_proposal'=>'file-signature',
'payment'=>'money-check-alt', 'phoning'=>'phone', 'phoning_mobile'=>'mobile-alt', 'phoning_fax'=>'fax', 'printer'=>'print', 'product'=>'cube', 'service'=>'concierge-bell', 'payment'=>'money-check-alt', 'phoning'=>'phone', 'phoning_mobile'=>'mobile-alt', 'phoning_fax'=>'fax', 'previous'=>'arrow-alt-circle-left', 'printer'=>'print', 'product'=>'cube', 'service'=>'concierge-bell',
'refresh'=>'redo', 'resource'=>'laptop-house', 'refresh'=>'redo', 'resource'=>'laptop-house',
'shipment'=>'dolly', 'stock'=>'box-open', 'stats' => 'chart-bar', 'split'=>'code-branch', 'supplier_invoice'=>'file-invoice-dollar', 'technic'=>'cogs', 'ticket'=>'ticket-alt', 'shipment'=>'dolly', 'stock'=>'box-open', 'stats' => 'chart-bar', 'split'=>'code-branch', 'supplier_invoice'=>'file-invoice-dollar', 'technic'=>'cogs', 'ticket'=>'ticket-alt',
'title_setup'=>'tools', 'title_accountancy'=>'money-check-alt', 'title_bank'=>'university', 'title_hrm'=>'umbrella-beach', 'title_setup'=>'tools', 'title_accountancy'=>'money-check-alt', 'title_bank'=>'university', 'title_hrm'=>'umbrella-beach',
@ -4015,7 +4049,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);
} }
@ -7800,7 +7834,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
} }
@ -7808,7 +7842,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';
@ -8336,7 +8370,7 @@ function dolGetBadge($label, $html = '', $type = 'primary', $mode = '', $url = '
/** /**
* Function dolGetStatus * Output the badge of a status.
* *
* @param string $statusLabel Label of badge no html : use in alt attribute for accessibility * @param string $statusLabel Label of badge no html : use in alt attribute for accessibility
* @param string $statusLabelShort Short label of badge no html * @param string $statusLabelShort Short label of badge no html
@ -8344,7 +8378,7 @@ function dolGetBadge($label, $html = '', $type = 'primary', $mode = '', $url = '
* @param string $statusType status0 status1 status2 status3 status4 status5 status6 status7 status8 status9 : image name or badge name * @param string $statusType status0 status1 status2 status3 status4 status5 status6 status7 status8 status9 : image name or badge name
* @param int $displayMode 0=Long label, 1=Short label, 2=Picto + Short label, 3=Picto, 4=Picto + Long label, 5=Short label + Picto, 6=Long label + Picto * @param int $displayMode 0=Long label, 1=Short label, 2=Picto + Short label, 3=Picto, 4=Picto + Long label, 5=Short label + Picto, 6=Long label + Picto
* @param string $url The url for link * @param string $url The url for link
* @param array $params Various params for future : recommended rather than adding more function arguments * @param array $params Various params. Example: array('tooltip'=>'...', 'badgeParams'=>...)
* @return string Html status string * @return string Html status string
*/ */
function dolGetStatus($statusLabel = '', $statusLabelShort = '', $html = '', $statusType = 'status0', $displayMode = 0, $url = '', $params = array()) function dolGetStatus($statusLabel = '', $statusLabelShort = '', $html = '', $statusType = 'status0', $displayMode = 0, $url = '', $params = array())
@ -8413,7 +8447,7 @@ function dolGetStatus($statusLabel = '', $statusLabelShort = '', $html = '', $st
$statusLabelShort = (empty($statusLabelShort) ? $statusLabel : $statusLabelShort); $statusLabelShort = (empty($statusLabelShort) ? $statusLabel : $statusLabelShort);
$dolGetBadgeParams['attr']['class'] = 'badge-status'; $dolGetBadgeParams['attr']['class'] = 'badge-status';
$dolGetBadgeParams['attr']['title'] = $statusLabel; $dolGetBadgeParams['attr']['title'] = empty($params['tooltip']) ? $statusLabel : $params['tooltip'];
if ($displayMode == 3) { if ($displayMode == 3) {
$return = dolGetBadge((empty($conf->dol_optimize_smallscreen) ? $statusLabel : (empty($statusLabelShort) ? $statusLabel : $statusLabelShort)), '', $statusType, 'dot', $url, $dolGetBadgeParams); $return = dolGetBadge((empty($conf->dol_optimize_smallscreen) ? $statusLabel : (empty($statusLabelShort) ? $statusLabel : $statusLabelShort)), '', $statusType, 'dot', $url, $dolGetBadgeParams);
@ -8946,8 +8980,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

@ -2384,3 +2384,77 @@ function price2fec($amount)
return $output; return $output;
} }
/**
* Check the syntax of some PHP code.
*
* @param string $code PHP code to check.
* @return boolean|array If false, then check was successful, otherwise an array(message,line) of errors is returned.
*/
function phpSyntaxError($code)
{
if (!defined("CR")) define("CR", "\r");
if (!defined("LF")) define("LF", "\n");
if (!defined("CRLF")) define("CRLF", "\r\n");
$braces=0;
$inString=0;
foreach (token_get_all('<?php ' . $code) as $token) {
if (is_array($token)) {
switch ($token[0]) {
case T_CURLY_OPEN:
case T_DOLLAR_OPEN_CURLY_BRACES:
case T_START_HEREDOC: ++$inString; break;
case T_END_HEREDOC: --$inString; break;
}
} elseif ($inString & 1) {
switch ($token) {
case '`':
case '\'':
case '"': --$inString; break;
}
} else {
switch ($token) {
case '`':
case '\'':
case '"': ++$inString; break;
case '{': ++$braces; break;
case '}':
if ($inString) {
--$inString;
} else {
--$braces;
if ($braces < 0) break 2;
}
break;
}
}
}
$inString = @ini_set('log_errors', false);
$token = @ini_set('display_errors', true);
ob_start();
$code = substr($code, strlen('<?php '));
$braces || $code = "if(0){{$code}\n}";
if (eval($code) === false) {
if ($braces) {
$braces = PHP_INT_MAX;
} else {
false !== strpos($code, CR) && $code = strtr(str_replace(CRLF, LF, $code), CR, LF);
$braces = substr_count($code, LF);
}
$code = ob_get_clean();
$code = strip_tags($code);
if (preg_match("'syntax error, (.+) in .+ on line (\d+)$'s", $code, $code)) {
$code[2] = (int) $code[2];
$code = $code[2] <= $braces
? array($code[1], $code[2])
: array('unexpected $end' . substr($code[1], 14), $braces);
} else $code = array('syntax error', 0);
} else {
ob_end_clean();
$code = false;
}
@ini_set('display_errors', $token);
@ini_set('log_errors', $inString);
return $code;
}

View File

@ -23,7 +23,7 @@
*/ */
// Define size of logo small and mini // Define size of logo small and mini
$maxwidthsmall = 350; $maxheightsmall = 200; // Near 16/9eme $maxwidthsmall = 480; $maxheightsmall = 270; // Near 16/9eme
$maxwidthmini = 128; $maxheightmini = 72; // 16/9eme $maxwidthmini = 128; $maxheightmini = 72; // 16/9eme
$quality = 80; $quality = 80;

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

@ -30,23 +30,23 @@ require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
/** /**
* Prepare array with list of tabs * Prepare array with list of tabs
* *
* @param Object $object Object related to tabs * @param Project $project Object related to tabs
* @return array Array of tabs to show * @return array Array of tabs to show
*/ */
function project_prepare_head($object) function project_prepare_head(Project $project)
{ {
global $db, $langs, $conf, $user; global $db, $langs, $conf, $user;
$h = 0; $h = 0;
$head = array(); $head = array();
$head[$h][0] = DOL_URL_ROOT.'/projet/card.php?id='.$object->id; $head[$h][0] = DOL_URL_ROOT.'/projet/card.php?id='.$project->id;
$head[$h][1] = $langs->trans("Project"); $head[$h][1] = $langs->trans("Project");
$head[$h][2] = 'project'; $head[$h][2] = 'project';
$h++; $h++;
$nbContact = count($object->liste_contact(-1, 'internal')) + count($object->liste_contact(-1, 'external')); $nbContact = count($project->liste_contact(-1, 'internal')) + count($project->liste_contact(-1, 'external'));
$head[$h][0] = DOL_URL_ROOT.'/projet/contact.php?id='.$object->id; $head[$h][0] = DOL_URL_ROOT.'/projet/contact.php?id='.$project->id;
$head[$h][1] = $langs->trans("ProjectContact"); $head[$h][1] = $langs->trans("ProjectContact");
if ($nbContact > 0) $head[$h][1] .= '<span class="badge marginleftonlyshort">'.$nbContact.'</span>'; if ($nbContact > 0) $head[$h][1] .= '<span class="badge marginleftonlyshort">'.$nbContact.'</span>';
$head[$h][2] = 'contact'; $head[$h][2] = 'contact';
@ -55,12 +55,12 @@ function project_prepare_head($object)
if (empty($conf->global->PROJECT_HIDE_TASKS)) if (empty($conf->global->PROJECT_HIDE_TASKS))
{ {
// Then tab for sub level of projet, i mean tasks // Then tab for sub level of projet, i mean tasks
$head[$h][0] = DOL_URL_ROOT.'/projet/tasks.php?id='.$object->id; $head[$h][0] = DOL_URL_ROOT.'/projet/tasks.php?id='.$project->id;
$head[$h][1] = $langs->trans("Tasks"); $head[$h][1] = $langs->trans("Tasks");
require_once DOL_DOCUMENT_ROOT.'/projet/class/task.class.php'; require_once DOL_DOCUMENT_ROOT.'/projet/class/task.class.php';
$taskstatic = new Task($db); $taskstatic = new Task($db);
$nbTasks = count($taskstatic->getTasksArray(0, 0, $object->id, 0, 0)); $nbTasks = count($taskstatic->getTasksArray(0, 0, $project->id, 0, 0));
if ($nbTasks > 0) $head[$h][1] .= '<span class="badge marginleftonlyshort">'.($nbTasks).'</span>'; if ($nbTasks > 0) $head[$h][1] .= '<span class="badge marginleftonlyshort">'.($nbTasks).'</span>';
$head[$h][2] = 'tasks'; $head[$h][2] = 'tasks';
$h++; $h++;
@ -71,7 +71,7 @@ function project_prepare_head($object)
//$sql .= " WHERE t.fk_user = u.rowid AND t.fk_task = pt.rowid"; //$sql .= " WHERE t.fk_user = u.rowid AND t.fk_task = pt.rowid";
$sql .= " FROM ".MAIN_DB_PREFIX."projet_task_time as t, ".MAIN_DB_PREFIX."projet_task as pt"; $sql .= " FROM ".MAIN_DB_PREFIX."projet_task_time as t, ".MAIN_DB_PREFIX."projet_task as pt";
$sql .= " WHERE t.fk_task = pt.rowid"; $sql .= " WHERE t.fk_task = pt.rowid";
$sql .= " AND pt.fk_projet =".$object->id; $sql .= " AND pt.fk_projet =".$project->id;
$resql = $db->query($sql); $resql = $db->query($sql);
if ($resql) if ($resql)
{ {
@ -79,7 +79,7 @@ function project_prepare_head($object)
if ($obj) $nbTimeSpent = 1; if ($obj) $nbTimeSpent = 1;
} else dol_print_error($db); } else dol_print_error($db);
$head[$h][0] = DOL_URL_ROOT.'/projet/tasks/time.php?withproject=1&projectid='.$object->id; $head[$h][0] = DOL_URL_ROOT.'/projet/tasks/time.php?withproject=1&projectid='.$project->id;
$head[$h][1] = $langs->trans("TimeSpent"); $head[$h][1] = $langs->trans("TimeSpent");
if ($nbTimeSpent > 0) $head[$h][1] .= '<span class="badge marginleftonlyshort">...</span>'; if ($nbTimeSpent > 0) $head[$h][1] .= '<span class="badge marginleftonlyshort">...</span>';
$head[$h][2] = 'timespent'; $head[$h][2] = 'timespent';
@ -91,8 +91,32 @@ function project_prepare_head($object)
|| !empty($conf->facture->enabled) || !empty($conf->contrat->enabled) || !empty($conf->facture->enabled) || !empty($conf->contrat->enabled)
|| !empty($conf->ficheinter->enabled) || !empty($conf->agenda->enabled) || !empty($conf->deplacement->enabled)) || !empty($conf->ficheinter->enabled) || !empty($conf->agenda->enabled) || !empty($conf->deplacement->enabled))
{ {
$head[$h][0] = DOL_URL_ROOT.'/projet/element.php?id='.$object->id; $count = 0;
if (!empty($conf->propal->enabled)) $count += $project->getElementCount('propal', 'propal');
if (!empty($conf->commande->enabled)) $count += $project->getElementCount('order', 'commande');
if (!empty($conf->facture->enabled)) $count += $project->getElementCount('invoice', 'facture');
if (!empty($conf->facture->enabled)) $count += $project->getElementCount('invoice_predefined', 'facture_rec');
if (!empty($conf->supplier_proposal->enabled)) $count += $project->getElementCount('proposal_supplier', 'supplier_proposal');
if (!empty($conf->supplier_order->enabled)) $count += $project->getElementCount('order_supplier', 'commande_fournisseur');
if (!empty($conf->supplier_invoice->enabled)) $count += $project->getElementCount('invoice_supplier', 'facture_fourn');
if (!empty($conf->contrat->enabled)) $count += $project->getElementCount('contract', 'contrat');
if (!empty($conf->ficheinter->enabled)) $count += $project->getElementCount('intervention', 'fichinter');
if (!empty($conf->expedition->enabled)) $count += $project->getElementCount('shipping', 'expedition');
if (!empty($conf->mrp->enabled)) $count += $project->getElementCount('mrp', 'mrp_mo', 'fk_project');
if (!empty($conf->deplacement->enabled)) $count += $project->getElementCount('trip', 'deplacement');
if (!empty($conf->expensereport->enabled)) $count += $project->getElementCount('expensereport', 'expensereport');
if (!empty($conf->don->enabled)) $count += $project->getElementCount('donation', 'don');
if (!empty($conf->loan->enabled)) $count += $project->getElementCount('loan', 'loan');
if (!empty($conf->tax->enabled)) $count += $project->getElementCount('chargesociales', 'chargesociales');
if (!empty($conf->projet->enabled)) $count += $project->getElementCount('project_task', 'projet_task');
if (!empty($conf->stock->enabled)) $count += $project->getElementCount('stock_mouvement', 'stock');
if (!empty($conf->salaries->enabled)) $count += $project->getElementCount('salaries', 'payment_salary');
if (!empty($conf->banque->enabled)) $count += $project->getElementCount('variouspayment', 'payment_various');
$head[$h][0] = DOL_URL_ROOT.'/projet/element.php?id='.$project->id;
$head[$h][1] = $langs->trans("ProjectOverview"); $head[$h][1] = $langs->trans("ProjectOverview");
if ($count > 0) $head[$h][1] .= '<span class="badge marginleftonlyshort">'.$count.'</span>';
$head[$h][2] = 'element'; $head[$h][2] = 'element';
$h++; $h++;
} }
@ -101,15 +125,15 @@ function project_prepare_head($object)
// 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, 'project'); complete_head_from_modules($conf, $langs, $project, $head, $h, 'project');
if (empty($conf->global->MAIN_DISABLE_NOTES_TAB)) if (empty($conf->global->MAIN_DISABLE_NOTES_TAB))
{ {
$nbNote = 0; $nbNote = 0;
if (!empty($object->note_private)) $nbNote++; if (!empty($project->note_private)) $nbNote++;
if (!empty($object->note_public)) $nbNote++; if (!empty($project->note_public)) $nbNote++;
$head[$h][0] = DOL_URL_ROOT.'/projet/note.php?id='.$object->id; $head[$h][0] = DOL_URL_ROOT.'/projet/note.php?id='.$project->id;
$head[$h][1] = $langs->trans('Notes'); $head[$h][1] = $langs->trans('Notes');
if ($nbNote > 0) $head[$h][1] .= '<span class="badge marginleftonlyshort">'.$nbNote.'</span>'; if ($nbNote > 0) $head[$h][1] .= '<span class="badge marginleftonlyshort">'.$nbNote.'</span>';
$head[$h][2] = 'notes'; $head[$h][2] = 'notes';
@ -118,10 +142,10 @@ function project_prepare_head($object)
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php';
$upload_dir = $conf->projet->dir_output."/".dol_sanitizeFileName($object->ref); $upload_dir = $conf->projet->dir_output."/".dol_sanitizeFileName($project->ref);
$nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$')); $nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$'));
$nbLinks = Link::count($db, $object->element, $object->id); $nbLinks = Link::count($db, $project->element, $project->id);
$head[$h][0] = DOL_URL_ROOT.'/projet/document.php?id='.$object->id; $head[$h][0] = DOL_URL_ROOT.'/projet/document.php?id='.$project->id;
$head[$h][1] = $langs->trans('Documents'); $head[$h][1] = $langs->trans('Documents');
if (($nbFiles + $nbLinks) > 0) $head[$h][1] .= '<span class="badge marginleftonlyshort">'.($nbFiles + $nbLinks).'</span>'; if (($nbFiles + $nbLinks) > 0) $head[$h][1] .= '<span class="badge marginleftonlyshort">'.($nbFiles + $nbLinks).'</span>';
$head[$h][2] = 'document'; $head[$h][2] = 'document';
@ -130,15 +154,15 @@ function project_prepare_head($object)
// Manage discussion // Manage discussion
if (!empty($conf->global->PROJECT_ALLOW_COMMENT_ON_PROJECT)) if (!empty($conf->global->PROJECT_ALLOW_COMMENT_ON_PROJECT))
{ {
$nbComments = $object->getNbComments(); $nbComments = $project->getNbComments();
$head[$h][0] = DOL_URL_ROOT.'/projet/comment.php?id='.$object->id; $head[$h][0] = DOL_URL_ROOT.'/projet/comment.php?id='.$project->id;
$head[$h][1] = $langs->trans("CommentLink"); $head[$h][1] = $langs->trans("CommentLink");
if ($nbComments > 0) $head[$h][1] .= '<span class="badge marginleftonlyshort">'.$nbComments.'</span>'; if ($nbComments > 0) $head[$h][1] .= '<span class="badge marginleftonlyshort">'.$nbComments.'</span>';
$head[$h][2] = 'project_comment'; $head[$h][2] = 'project_comment';
$h++; $h++;
} }
$head[$h][0] = DOL_URL_ROOT.'/projet/info.php?id='.$object->id; $head[$h][0] = DOL_URL_ROOT.'/projet/info.php?id='.$project->id;
$head[$h][1] .= $langs->trans("Events"); $head[$h][1] .= $langs->trans("Events");
if (!empty($conf->agenda->enabled) && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read))) if (!empty($conf->agenda->enabled) && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read)))
{ {
@ -148,7 +172,7 @@ function project_prepare_head($object)
$head[$h][2] = 'agenda'; $head[$h][2] = 'agenda';
$h++; $h++;
complete_head_from_modules($conf, $langs, $object, $head, $h, 'project', 'remove'); complete_head_from_modules($conf, $langs, $project, $head, $h, 'project', 'remove');
return $head; return $head;
} }

View File

@ -1048,7 +1048,7 @@ function print_left_eldy_menu($db, $menu_array_before, $menu_array_after, &$tabM
$newmenu->add("/fourn/facture/list.php?leftmenu=suppliers_bills_paid&amp;search_status=2", $langs->trans("BillShortStatusPaid"), 2, $user->rights->fournisseur->facture->lire, '', $mainmenu, 'suppliers_bills_paid'); $newmenu->add("/fourn/facture/list.php?leftmenu=suppliers_bills_paid&amp;search_status=2", $langs->trans("BillShortStatusPaid"), 2, $user->rights->fournisseur->facture->lire, '', $mainmenu, 'suppliers_bills_paid');
} }
$newmenu->add("/fourn/facture/paiement.php?leftmenu=suppliers_bills_payment", $langs->trans("Payments"), 1, $user->rights->fournisseur->facture->lire, '', $mainmenu, 'suppliers_bills_payment'); $newmenu->add("/fourn/paiement/list.php?leftmenu=suppliers_bills_payment", $langs->trans("Payments"), 1, $user->rights->fournisseur->facture->lire, '', $mainmenu, 'suppliers_bills_payment');
$newmenu->add("/fourn/facture/rapport.php?leftmenu=suppliers_bills_report", $langs->trans("Reportings"), 2, $user->rights->fournisseur->facture->lire, '', $mainmenu, 'suppliers_bills_report'); $newmenu->add("/fourn/facture/rapport.php?leftmenu=suppliers_bills_report", $langs->trans("Reportings"), 2, $user->rights->fournisseur->facture->lire, '', $mainmenu, 'suppliers_bills_report');

View File

@ -238,37 +238,35 @@ class mailing_fraise extends MailingTargets
$cibles = array(); $cibles = array();
$now = dol_now(); $now = dol_now();
$dateendsubscriptionafter = dol_mktime($_POST['subscriptionafterhour'], $_POST['subscriptionaftermin'], $_POST['subscriptionaftersec'], $_POST['subscriptionaftermonth'], $_POST['subscriptionafterday'], $_POST['subscriptionafteryear']); $dateendsubscriptionafter = dol_mktime(GETPOST('subscriptionafterhour', 'int'), GETPOST('subscriptionaftermin', 'int'), GETPOST('subscriptionaftersec', 'int'), GETPOST('subscriptionaftermonth', 'int'), GETPOST('subscriptionafterday', 'int'), GETPOST('subscriptionafteryear', 'int'));
$dateendsubscriptionbefore = dol_mktime($_POST['subscriptionbeforehour'], $_POST['subscriptionbeforemin'], $_POST['subscriptionbeforesec'], $_POST['subscriptionbeforemonth'], $_POST['subscriptionbeforeday'], $_POST['subscriptionbeforeyear']); $dateendsubscriptionbefore = dol_mktime(GETPOST('subscriptionbeforehour', 'int'), GETPOST('subscriptionbeforemin', 'int'), GETPOST('subscriptionbeforesec', 'int'), GETPOST('subscriptionbeforemonth', 'int'), GETPOST('subscriptionbeforeday', 'int'), GETPOST('subscriptionbeforeyear', 'int'));
// La requete doit retourner: id, email, fk_contact, name, firstname // La requete doit retourner: id, email, fk_contact, name, firstname
$sql = "SELECT a.rowid as id, a.email as email, null as fk_contact, "; $sql = "SELECT a.rowid as id, a.email as email, null as fk_contact, ";
$sql .= " a.lastname, a.firstname,"; $sql .= " a.lastname, a.firstname,";
$sql .= " a.datefin, a.civility as civility_id, a.login, a.societe"; // Other fields $sql .= " a.datefin, a.civility as civility_id, a.login, a.societe"; // Other fields
$sql .= " FROM ".MAIN_DB_PREFIX."adherent as a"; $sql .= " FROM ".MAIN_DB_PREFIX."adherent as a";
if ($_POST['filter_category']) if (GETPOST('filter_category'))
{ {
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."categorie_member as cm ON cm.fk_member = a.rowid"; $sql .= " INNER JOIN ".MAIN_DB_PREFIX."categorie_member as cm ON cm.fk_member = a.rowid";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."categorie as c ON c.rowid = cm.fk_categorie"; $sql .= " INNER JOIN ".MAIN_DB_PREFIX."categorie as c ON c.rowid = cm.fk_categorie AND c.rowid = ".((int) GETPOST('filter_category', 'int'));
} }
$sql .= " , ".MAIN_DB_PREFIX."adherent_type as ta"; $sql .= " , ".MAIN_DB_PREFIX."adherent_type as ta";
$sql .= " WHERE a.entity IN (".getEntity('member').") AND a.email <> ''"; // Note that null != '' is false $sql .= " WHERE a.entity IN (".getEntity('member').") AND a.email <> ''"; // Note that null != '' is false
$sql .= " AND a.email NOT IN (SELECT email FROM ".MAIN_DB_PREFIX."mailing_cibles WHERE fk_mailing=".$this->db->escape($mailing_id).")"; $sql .= " AND a.email NOT IN (SELECT email FROM ".MAIN_DB_PREFIX."mailing_cibles WHERE fk_mailing=".$this->db->escape($mailing_id).")";
// Filter on status // Filter on status
if (isset($_POST["filter"]) && $_POST["filter"] == '-1') { if (GETPOST("filter") == '-1') {
$sql .= " AND a.statut=-1"; $sql .= " AND a.statut=-1";
} }
if (isset($_POST["filter"]) && $_POST["filter"] == '1a') $sql .= " AND a.statut=1 AND (a.datefin >= '".$this->db->idate($now)."' OR ta.subscription = 0)"; if (GETPOST("filter", 'aZ09') == '1a') $sql .= " AND a.statut=1 AND (a.datefin >= '".$this->db->idate($now)."' OR ta.subscription = 0)";
if (isset($_POST["filter"]) && $_POST["filter"] == '1b') $sql .= " AND a.statut=1 AND ((a.datefin IS NULL or a.datefin < '".$this->db->idate($now)."') AND ta.subscription = 1)"; if (GETPOST("filter", 'aZ09') == '1b') $sql .= " AND a.statut=1 AND ((a.datefin IS NULL or a.datefin < '".$this->db->idate($now)."') AND ta.subscription = 1)";
if (isset($_POST["filter"]) && $_POST["filter"] == '0') $sql .= " AND a.statut=0"; if (GETPOST("filter", 'aZ09') === '0') $sql .= " AND a.statut=0";
// Filter on date // Filter on date
if ($dateendsubscriptionafter > 0) $sql .= " AND datefin > '".$this->db->idate($dateendsubscriptionafter)."'"; if ($dateendsubscriptionafter > 0) $sql .= " AND datefin > '".$this->db->idate($dateendsubscriptionafter)."'";
if ($dateendsubscriptionbefore > 0) $sql .= " AND datefin < '".$this->db->idate($dateendsubscriptionbefore)."'"; if ($dateendsubscriptionbefore > 0) $sql .= " AND datefin < '".$this->db->idate($dateendsubscriptionbefore)."'";
$sql .= " AND a.fk_adherent_type = ta.rowid"; $sql .= " AND a.fk_adherent_type = ta.rowid";
// Filter on type // Filter on type
if (GETPOSTISSET('filter_type')) $sql .= " AND ta.rowid='".$this->db->escape(GETPOST('filter_type'))."'"; if (GETPOST('filter_type', 'int') > 0) $sql .= " AND ta.rowid='".$this->db->escape(GETPOST('filter_type', 'int'))."'";
// Filter on category
if (GETPOSTISSET('filter_category')) $sql .= " AND c.rowid='".$this->db->escape(GETPOST('filter_category'))."'";
$sql .= " ORDER BY a.email"; $sql .= " ORDER BY a.email";
//print $sql; //print $sql;

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

@ -66,7 +66,7 @@ class modSocialNetworks extends DolibarrModules
// Dependencies // Dependencies
$this->hidden = !empty($conf->global->MODULE_SOCIALNETWORKS_DISABLED); // A condition to hide module $this->hidden = !empty($conf->global->MODULE_SOCIALNETWORKS_DISABLED); // A condition to hide module
$this->depends = array('modSociete'); // 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

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

@ -74,18 +74,18 @@ print '<div class="inline-block toolbarbutton centpercent">';
// Toolbar // Toolbar
if ($permtoadd) if ($permtoadd)
{ {
print '<a href="'.DOL_URL_ROOT.'/ecm/dir_add_card.php?action=create&module='.urlencode($module).($websitekey ? '&website='.$websitekey : '').($pageid ? '&pageid='.$pageid : '').'&backtopage='.urlencode($_SERVER["PHP_SELF"].'?file_manager=1&website='.$websitekey.'&pageid='.$pageid).'" class="inline-block valignmiddle toolbarbutton" title="'.dol_escape_htmltag($langs->trans('ECMAddSection')).'">'; print '<a href="'.DOL_URL_ROOT.'/ecm/dir_add_card.php?action=create&module='.urlencode($module).($websitekey ? '&website='.$websitekey : '').($pageid ? '&pageid='.$pageid : '').'&backtopage='.urlencode($_SERVER["PHP_SELF"].'?file_manager=1&website='.$websitekey.'&pageid='.$pageid).'" class="inline-block valignmiddle toolbarbutton paddingtop" title="'.dol_escape_htmltag($langs->trans('ECMAddSection')).'">';
print '<img class="toolbarbutton" border="0" src="'.DOL_URL_ROOT.'/theme/common/folder-new.png">'; print '<img class="toolbarbutton" border="0" src="'.DOL_URL_ROOT.'/theme/common/folder-new.png">';
print '</a>'; print '</a>';
} else { } else {
print '<a href="#" class="inline-block valignmiddle toolbarbutton" title="'.$langs->trans("NotAllowed").'">'; print '<a href="#" class="inline-block valignmiddle toolbarbutton paddingtop" title="'.$langs->trans("NotAllowed").'">';
print '<img class="toolbarbutton disabled" border="0" src="'.DOL_URL_ROOT.'/theme/common/folder-new.png">'; print '<img class="toolbarbutton disabled" border="0" src="'.DOL_URL_ROOT.'/theme/common/folder-new.png">';
print '</a>'; print '</a>';
} }
if ($module == 'ecm') if ($module == 'ecm')
{ {
$tmpurl = ((!empty($conf->use_javascript_ajax) && empty($conf->global->MAIN_ECM_DISABLE_JS)) ? '#' : ($_SERVER["PHP_SELF"].'?action=refreshmanual'.($module ? '&amp;module='.$module : '').($section ? '&amp;section='.$section : ''))); $tmpurl = ((!empty($conf->use_javascript_ajax) && empty($conf->global->MAIN_ECM_DISABLE_JS)) ? '#' : ($_SERVER["PHP_SELF"].'?action=refreshmanual'.($module ? '&amp;module='.$module : '').($section ? '&amp;section='.$section : '')));
print '<a href="'.$tmpurl.'" class="inline-block valignmiddle toolbarbutton" title="'.dol_escape_htmltag($langs->trans('ReSyncListOfDir')).'">'; print '<a href="'.$tmpurl.'" class="inline-block valignmiddle toolbarbutton paddingtop" title="'.dol_escape_htmltag($langs->trans('ReSyncListOfDir')).'">';
print '<img id="refreshbutton" class="toolbarbutton" border="0" src="'.DOL_URL_ROOT.'/theme/common/view-refresh.png">'; print '<img id="refreshbutton" class="toolbarbutton" border="0" src="'.DOL_URL_ROOT.'/theme/common/view-refresh.png">';
print '</a>'; print '</a>';
} }

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

@ -352,7 +352,7 @@ print '<div class="inline-block toolbarbutton centpercent">';
// Toolbar // Toolbar
$url = ((!empty($conf->use_javascript_ajax) && empty($conf->global->MAIN_ECM_DISABLE_JS)) ? '#' : ($_SERVER["PHP_SELF"].'?action=refreshmanual'.($module ? '&amp;module='.$module : '').($section ? '&amp;section='.$section : ''))); $url = ((!empty($conf->use_javascript_ajax) && empty($conf->global->MAIN_ECM_DISABLE_JS)) ? '#' : ($_SERVER["PHP_SELF"].'?action=refreshmanual'.($module ? '&amp;module='.$module : '').($section ? '&amp;section='.$section : '')));
print '<a href="'.$url.'" class="inline-block valignmiddle toolbarbutton" title="'.dol_escape_htmltag($langs->trans('Refresh')).'">'; print '<a href="'.$url.'" class="inline-block valignmiddle toolbarbutton paddingtop" title="'.dol_escape_htmltag($langs->trans('Refresh')).'">';
print '<img id="refreshbutton" class="toolbarbutton" border="0" src="'.DOL_URL_ROOT.'/theme/common/view-refresh.png">'; print '<img id="refreshbutton" class="toolbarbutton" border="0" src="'.DOL_URL_ROOT.'/theme/common/view-refresh.png">';
print '</a>'; print '</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

@ -459,7 +459,7 @@ if ($step == 1 || !$datatoexport)
print '</td><td class="right">'; print '</td><td class="right">';
if ($objexport->array_export_perms[$key]) if ($objexport->array_export_perms[$key])
{ {
print '<a href="'.DOL_URL_ROOT.'/exports/export.php?step=2&module_position='.$objexport->array_export_module[$key]->module_position.'&datatoexport='.$objexport->array_export_code[$key].'">'.img_picto($langs->trans("NewExport"), 'filenew').'</a>'; print '<a href="'.DOL_URL_ROOT.'/exports/export.php?step=2&module_position='.$objexport->array_export_module[$key]->module_position.'&datatoexport='.$objexport->array_export_code[$key].'">'.img_picto($langs->trans("NewExport"), 'next', 'class="fa-15x"').'</a>';
} else { } else {
print $langs->trans("NotEnoughPermissions"); print $langs->trans("NotEnoughPermissions");
} }

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

@ -250,12 +250,11 @@ class FichinterRec extends Fichinter
*/ */
public function fetch($rowid = 0, $ref = '', $ref_ext = '') public function fetch($rowid = 0, $ref = '', $ref_ext = '')
{ {
$sql = 'SELECT f.titre, f.fk_soc'; $sql = 'SELECT f.titre as title, f.fk_soc';
$sql .= ', f.datec, f.duree, f.fk_projet, f.fk_contrat, f.description'; $sql .= ', f.datec, f.duree, f.fk_projet, f.fk_contrat, f.description';
$sql .= ', f.note_private, f.note_public, f.fk_user_author'; $sql .= ', f.note_private, f.note_public, f.fk_user_author';
$sql .= ', f.frequency, f.unit_frequency, f.date_when, f.date_last_gen, f.nb_gen_done, f.nb_gen_max, f.auto_validate'; $sql .= ', f.frequency, f.unit_frequency, f.date_when, f.date_last_gen, f.nb_gen_done, f.nb_gen_max, f.auto_validate';
$sql .= ', f.note_private, f.note_public, f.fk_user_author'; $sql .= ', f.note_private, f.note_public, f.fk_user_author';
$sql .= ' FROM '.MAIN_DB_PREFIX.'fichinter_rec as f'; $sql .= ' FROM '.MAIN_DB_PREFIX.'fichinter_rec as f';
if ($rowid > 0) $sql .= ' WHERE f.rowid='.$rowid; if ($rowid > 0) $sql .= ' WHERE f.rowid='.$rowid;
elseif ($ref) $sql .= " WHERE f.titre='".$this->db->escape($ref)."'"; elseif ($ref) $sql .= " WHERE f.titre='".$this->db->escape($ref)."'";
@ -268,8 +267,9 @@ class FichinterRec extends Fichinter
$obj = $this->db->fetch_object($result); $obj = $this->db->fetch_object($result);
$this->id = $rowid; $this->id = $rowid;
$this->titre = $obj->titre; $this->titre = $obj->title;
$this->ref = $obj->titre; $this->title = $obj->title;
$this->ref = $obj->title;
$this->description = $obj->description; $this->description = $obj->description;
$this->datec = $obj->datec; $this->datec = $obj->datec;
$this->duration = $obj->duree; $this->duration = $obj->duree;

View File

@ -1554,7 +1554,7 @@ class CommandeFournisseur extends CommonOrder
include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php'; include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php';
// Clean parameters // Clean parameters
if (!$qty) $qty = 1; if (empty($qty)) $qty = 0;
if (!$info_bits) $info_bits = 0; if (!$info_bits) $info_bits = 0;
if (empty($txtva)) $txtva = 0; if (empty($txtva)) $txtva = 0;
if (empty($txlocaltax1)) $txlocaltax1 = 0; if (empty($txlocaltax1)) $txlocaltax1 = 0;
@ -2526,7 +2526,6 @@ class CommandeFournisseur extends CommonOrder
$remise_percent = price2num($remise_percent); $remise_percent = price2num($remise_percent);
$qty = price2num($qty); $qty = price2num($qty);
if (!$qty) $qty = 1;
$pu = price2num($pu); $pu = price2num($pu);
$pu_ht_devise = price2num($pu_ht_devise); $pu_ht_devise = price2num($pu_ht_devise);
$txtva = price2num($txtva); $txtva = price2num($txtva);

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;
@ -2286,7 +2286,7 @@ class FactureFournisseur extends CommonInvoice
if ($this->type == self::TYPE_CREDIT_NOTE) $picto .= 'a'; // Credit note if ($this->type == self::TYPE_CREDIT_NOTE) $picto .= 'a'; // Credit note
if ($this->type == self::TYPE_DEPOSIT) $picto .= 'd'; // Deposit invoice if ($this->type == self::TYPE_DEPOSIT) $picto .= 'd'; // Deposit invoice
$label = '<u>'.$langs->trans("SupplierInvoice").'</u>'; $label = img_picto('', $this->picto).' <u>'.$langs->trans("SupplierInvoice").'</u>';
if ($this->type == self::TYPE_REPLACEMENT) $label = '<u>'.$langs->transnoentitiesnoconv("InvoiceReplace").'</u>'; if ($this->type == self::TYPE_REPLACEMENT) $label = '<u>'.$langs->transnoentitiesnoconv("InvoiceReplace").'</u>';
elseif ($this->type == self::TYPE_CREDIT_NOTE) $label = '<u>'.$langs->transnoentitiesnoconv("CreditNote").'</u>'; elseif ($this->type == self::TYPE_CREDIT_NOTE) $label = '<u>'.$langs->transnoentitiesnoconv("CreditNote").'</u>';
elseif ($this->type == self::TYPE_DEPOSIT) $label = '<u>'.$langs->transnoentitiesnoconv("Deposit").'</u>'; elseif ($this->type == self::TYPE_DEPOSIT) $label = '<u>'.$langs->transnoentitiesnoconv("Deposit").'</u>';
@ -2301,7 +2301,7 @@ class FactureFournisseur extends CommonInvoice
if (!empty($this->total_ht)) if (!empty($this->total_ht))
$label .= '<br><b>'.$langs->trans('AmountHT').':</b> '.price($this->total_ht, 0, $langs, 0, -1, -1, $conf->currency); $label .= '<br><b>'.$langs->trans('AmountHT').':</b> '.price($this->total_ht, 0, $langs, 0, -1, -1, $conf->currency);
if (!empty($this->total_tva)) if (!empty($this->total_tva))
$label .= '<br><b>'.$langs->trans('VAT').':</b> '.price($this->total_tva, 0, $langs, 0, -1, -1, $conf->currency); $label .= '<br><b>'.$langs->trans('AmountVAT').':</b> '.price($this->total_tva, 0, $langs, 0, -1, -1, $conf->currency);
if (!empty($this->total_ttc)) if (!empty($this->total_ttc))
$label .= '<br><b>'.$langs->trans('AmountTTC').':</b> '.price($this->total_ttc, 0, $langs, 0, -1, -1, $conf->currency); $label .= '<br><b>'.$langs->trans('AmountTTC').':</b> '.price($this->total_ttc, 0, $langs, 0, -1, -1, $conf->currency);
if ($moretitle) $label .= ' - '.$moretitle; if ($moretitle) $label .= ' - '.$moretitle;

View File

@ -406,7 +406,7 @@ if (empty($reshook))
setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Description')), null, 'errors'); setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Description')), null, 'errors');
$error++; $error++;
} }
if (!GETPOST('qty')) if (GETPOST('qty', 'int') == '')
{ {
setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Qty')), null, 'errors'); setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Qty')), null, 'errors');
$error++; $error++;
@ -666,7 +666,7 @@ if (empty($reshook))
$productsupplier = new ProductFournisseur($db); $productsupplier = new ProductFournisseur($db);
if (!empty($conf->global->SUPPLIER_ORDER_WITH_PREDEFINED_PRICES_ONLY)) if (!empty($conf->global->SUPPLIER_ORDER_WITH_PREDEFINED_PRICES_ONLY))
{ {
if ($line->fk_product > 0 && $productsupplier->get_buyprice(0, price2num($_POST['qty']), $line->fk_product, 'none', GETPOST('socid', 'int')) < 0) if ($line->fk_product > 0 && $productsupplier->get_buyprice(0, price2num(GETPOST('qty', 'int')), $line->fk_product, 'none', GETPOST('socid', 'int')) < 0)
{ {
setEventMessages($langs->trans("ErrorQtyTooLowForThisSupplier"), null, 'warnings'); setEventMessages($langs->trans("ErrorQtyTooLowForThisSupplier"), null, 'warnings');
} }
@ -719,7 +719,7 @@ if (empty($reshook))
$lineid, $lineid,
$_POST['product_desc'], $_POST['product_desc'],
$ht, $ht,
$_POST['qty'], GETPOST('qty', 'int'),
$_POST['remise_percent'], $_POST['remise_percent'],
$vat_rate, $vat_rate,
$localtax1_rate, $localtax1_rate,

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

@ -51,7 +51,7 @@ $maxOpenCount = empty($conf->global->MAIN_MAXLIST_OVERLOAD) ? 500 : $conf->glob
llxHeader("", $langs->trans("SupplierInvoicesArea"), 'EN:Suppliers_Invoices|FR:FactureFournisseur|ES:Facturas_de_proveedores'); llxHeader("", $langs->trans("SupplierInvoicesArea"), 'EN:Suppliers_Invoices|FR:FactureFournisseur|ES:Facturas_de_proveedores');
print load_fiche_titre($langs->trans("SupplierInvoicesArea"), '', 'invoicing'); print load_fiche_titre($langs->trans("SupplierInvoicesArea"), '', 'bill');
print '<div class="fichecenter">'; print '<div class="fichecenter">';

View File

@ -787,255 +787,6 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie
} else dol_print_error($db); } else dol_print_error($db);
} }
/*
* Show list
*/
if (empty($action) || $action == 'list')
{
$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
$sortfield = GETPOST("sortfield", 'alpha');
$sortorder = GETPOST("sortorder", 'alpha');
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
if (empty($page) || $page == -1) { $page = 0; }
$offset = $limit * $page;
$pageprev = $page - 1;
$pagenext = $page + 1;
if (!$sortorder) $sortorder = 'DESC';
if (!$sortfield) $sortfield = 'p.datep';
$sql = 'SELECT p.rowid as pid, p.ref, p.datep as dp, p.amount as pamount, p.num_paiement,';
$sql .= ' s.rowid as socid, s.nom as name,';
$sql .= ' c.code as paiement_type, c.libelle as paiement_libelle,';
$sql .= ' ba.rowid as bid, ba.label,';
if (!$user->rights->societe->client->voir) $sql .= ' sc.fk_soc, sc.fk_user,';
$sql .= ' SUM(pf.amount)';
$sql .= ' FROM '.MAIN_DB_PREFIX.'paiementfourn AS p';
$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'paiementfourn_facturefourn AS pf ON p.rowid=pf.fk_paiementfourn';
$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'facture_fourn AS f ON f.rowid=pf.fk_facturefourn';
$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement AS c ON p.fk_paiement = c.id';
$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe AS s ON s.rowid = f.fk_soc';
$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'bank as b ON p.fk_bank = b.rowid';
$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'bank_account as ba ON b.fk_account = ba.rowid';
if (!$user->rights->societe->client->voir) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql .= " WHERE f.entity = ".$conf->entity;
if (!$user->rights->societe->client->voir) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
if ($socid > 0) $sql .= ' AND f.fk_soc = '.$socid;
$sql .= dolSqlDateFilter('p.datep', $day, $month, $year);
if ($search_ref) $sql .= natural_search('p.rowid', $search_ref);
if ($search_account > 0) $sql .= " AND b.fk_account=".$search_account;
if ($search_paymenttype != "") $sql .= " AND c.code='".$db->escape($search_paymenttype)."'";
if ($search_payment_num != '') $sql .= natural_search('p.num_paiement', $search_payment_num);
if ($search_amount) $sql .= natural_search('p.amount', $search_amount, 1);
if ($search_company) $sql .= natural_search('s.nom', $search_company);
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
$sql .= " GROUP BY p.rowid, p.datep, p.amount, p.num_paiement, s.rowid, s.nom, c.code, c.libelle, ba.rowid, ba.label";
if (!$user->rights->societe->client->voir) $sql .= ", sc.fk_soc, sc.fk_user";
// Add where from extra fields
$sql .= $db->order($sortfield, $sortorder);
$nbtotalofrecords = '';
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
{
$result = $db->query($sql);
$nbtotalofrecords = $db->num_rows($result);
if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0
{
$page = 0;
$offset = 0;
}
}
$sql .= $db->plimit($limit + 1, $offset);
$resql = $db->query($sql);
if ($resql)
{
$num = $db->num_rows($resql);
$i = 0;
$param = '';
if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage);
if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit);
if ($day) $param .= ($day ? "&day=".urlencode($day) : "");
if ($month) $param .= ($month ? "&month=".urlencode($month) : "");
if ($year) $param .= ($year ? "&year=".urlencode($year) : "");
if ($search_ref) $param .= ($search_ref ? "&search_ref=".urlencode($search_ref) : "");
if ($search_company) $param .= ($search_company ? "&search_company=".urlencode($search_company) : "");
if ($search_amount != '') $param .= ($search_amount ? "&search_amount=".urlencode($search_amount) : "");
if ($search_payment_num) $param .= ($search_payment_num ? "&search_payment_num=".urlencode($search_payment_num) : "");
if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss);
// Add $param from extra fields
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
$massactionbutton = $form->selectMassAction('', $massaction == 'presend' ? array() : array('presend'=>$langs->trans("SendByMail"), 'builddoc'=>$langs->trans("PDFMerge")));
print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="action" 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="sortorder" value="'.$sortorder.'">';
print_barre_liste($langs->trans('SupplierPayments'), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'supplier_invoice', 0, '', '', $limit, 0, 0, 1);
$moreforfilter = '';
$parameters = array();
$reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook
if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint;
else $moreforfilter = $hookmanager->resPrint;
if ($moreforfilter)
{
print '<div class="liste_titre liste_titre_bydiv centpercent">';
print $moreforfilter;
print '</div>';
}
$varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
$selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
print '<div class="div-table-responsive">';
print '<table class="tagtable nobottomiftotal liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
// Lines for filters fields
print '<tr class="liste_titre_filter">';
print '<td class="liste_titre left">';
print '<input class="flat" type="text" size="4" name="search_ref" value="'.dol_escape_htmltag($search_ref).'">';
print '</td>';
print '<td class="liste_titre center">';
if (!empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print '<input class="flat width25 valignmiddle" type="text" maxlength="2" name="day" value="'.dol_escape_htmltag($day).'">';
print '<input class="flat width25 valignmiddle" type="text" maxlength="2" name="month" value="'.dol_escape_htmltag($month).'">';
$formother->select_year($year ? $year : -1, 'year', 1, 20, 5);
print '</td>';
print '<td class="liste_titre">';
print '<input class="flat" type="text" size="6" name="search_company" value="'.dol_escape_htmltag($search_company).'">';
print '</td>';
print '<td class="liste_titre">';
$form->select_types_paiements($search_paymenttype, 'search_paymenttype', '', 2, 1, 1);
print '</td>';
print '<td class="liste_titre">';
print '<input class="flat" type="text" size="4" name="search_payment_num" value="'.dol_escape_htmltag($search_payment_num).'">';
print '</td>';
if (!empty($conf->banque->enabled))
{
print '<td class="liste_titre">';
$form->select_comptes($search_account, 'search_account', 0, '', 1);
print '</td>';
}
print '<td class="liste_titre right">';
print '<input class="flat" type="text" size="4" name="search_amount" value="'.dol_escape_htmltag($search_amount).'">';
print '</td>';
print '<td class="liste_titre maxwidthsearch">';
$searchpicto = $form->showFilterAndCheckAddButtons(0);
print $searchpicto;
print '</td>';
print "</tr>\n";
print '<tr class="liste_titre">';
print_liste_field_titre("RefPayment", $_SERVER["PHP_SELF"], 'p.rowid', '', $param, '', $sortfield, $sortorder);
print_liste_field_titre("Date", $_SERVER["PHP_SELF"], 'dp', '', $param, '', $sortfield, $sortorder, 'center ');
print_liste_field_titre("ThirdParty", $_SERVER["PHP_SELF"], 's.nom', '', $param, '', $sortfield, $sortorder);
print_liste_field_titre("Type", $_SERVER["PHP_SELF"], 'c.libelle', '', $param, '', $sortfield, $sortorder);
print_liste_field_titre("Numero", $_SERVER["PHP_SELF"], "p.num_paiement", "", $param, "", $sortfield, $sortorder);
if (!empty($conf->banque->enabled))
{
print_liste_field_titre("Account", $_SERVER["PHP_SELF"], 'ba.label', '', $param, '', $sortfield, $sortorder);
}
print_liste_field_titre("Amount", $_SERVER["PHP_SELF"], 'p.amount', '', $param, '', $sortfield, $sortorder, 'right ');
$parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder);
$reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook
print $hookmanager->resPrint;
print_liste_field_titre('', $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'maxwidthsearch ');
print "</tr>\n";
$paymentfournstatic = new PaiementFourn($db);
$i = 0;
$totalarray = array();
while ($i < min($num, $limit))
{
$objp = $db->fetch_object($resql);
$paymentfournstatic->id = $objp->pid;
$paymentfournstatic->ref = $objp->ref;
$paymentfournstatic->datepaye = $objp->dp;
print '<tr class="oddeven">';
// Ref payment
print '<td class="nowrap">';
print $paymentfournstatic->getNomUrl(1);
print '</td>';
if (!$i) $totalarray['nbfield']++;
// Date
$dateformatforpayment = 'day';
if (!empty($conf->global->INVOICE_USE_HOURS_FOR_PAYMENT)) $dateformatforpayment = 'dayhour';
print '<td class="nowrap center">'.dol_print_date($db->jdate($objp->dp), $dateformatforpayment)."</td>\n";
if (!$i) $totalarray['nbfield']++;
// Thirdparty
print '<td>';
if ($objp->socid) print '<a href="'.DOL_URL_ROOT.'/societe/card.php?socid='.$objp->socid.'">'.img_object($langs->trans('ShowCompany'), 'company').' '.dol_trunc($objp->name, 32).'</a>';
else print '&nbsp;';
print '</td>';
if (!$i) $totalarray['nbfield']++;
// Type
$payment_type = $langs->trans("PaymentType".$objp->paiement_type) != ("PaymentType".$objp->paiement_type) ? $langs->trans("PaymentType".$objp->paiement_type) : $objp->paiement_libelle;
print '<td>'.$payment_type.' '.dol_trunc($objp->num_paiement, 32)."</td>\n";
if (!$i) $totalarray['nbfield']++;
// Payment number
print '<td>'.$objp->num_paiement.'</td>';
if (!$i) $totalarray['nbfield']++;
// Account
if (!empty($conf->banque->enabled))
{
print '<td>';
if ($objp->bid) print '<a href="'.DOL_URL_ROOT.'/compta/bank/bankentries_list.php?account='.$objp->bid.'">'.img_object($langs->trans("ShowAccount"), 'account').' '.dol_trunc($objp->label, 24).'</a>';
else print '&nbsp;';
print '</td>';
if (!$i) $totalarray['nbfield']++;
}
// Amount
print '<td class="right">'.price($objp->pamount).'</td>';
if (!$i) $totalarray['nbfield']++;
if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'amount';
$totalarray['val']['amount'] += $objp->pamount;
// Ref invoice
/*$invoicesupplierstatic->ref=$objp->ref_supplier;
$invoicesupplierstatic->id=$objp->facid;
print '<td class="nowrap">';
print $invoicesupplierstatic->getNomUrl(1);
print '</td>';*/
print '<td></td>';
if (!$i) $totalarray['nbfield']++;
print '</tr>';
$i++;
}
// Show total line
include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
print "</table>";
print "</div>";
print "</form>\n";
} else {
dol_print_error($db);
}
}
// End of page // End of page
llxFooter(); llxFooter();
$db->close(); $db->close();

View File

@ -74,7 +74,7 @@ if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->fournisse
if ($result > 0) if ($result > 0)
{ {
$db->commit(); $db->commit();
header('Location: '.DOL_URL_ROOT.'/fourn/facture/paiement.php'); header('Location: '.DOL_URL_ROOT.'/fourn/paiement/list.php');
exit; exit;
} else { } else {
setEventMessages($object->error, $object->errors, 'errors'); setEventMessages($object->error, $object->errors, 'errors');
@ -166,7 +166,7 @@ if ($result > 0)
print $form->formconfirm($_SERVER['PHP_SELF'].'?id='.$object->id, $langs->trans("ValidatePayment"), $langs->trans("ConfirmValidatePayment"), 'confirm_valide'); print $form->formconfirm($_SERVER['PHP_SELF'].'?id='.$object->id, $langs->trans("ValidatePayment"), $langs->trans("ConfirmValidatePayment"), 'confirm_valide');
} }
$linkback = '<a href="'.DOL_URL_ROOT.'/fourn/facture/paiement.php'.(!empty($socid) ? '?socid='.$socid : '').'">'.$langs->trans("BackToList").'</a>'; $linkback = '<a href="'.DOL_URL_ROOT.'/fourn/paiement/list.php'.(!empty($socid) ? '?socid='.$socid : '').'">'.$langs->trans("BackToList").'</a>';
dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref'); dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref');

View File

@ -0,0 +1,429 @@
<?php
/* Copyright (C) 2003-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004 Eric Seigne <eric.seigne@ryxeo.com>
* Copyright (C) 2004-2020 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2004 Christophe Combelles <ccomb@free.fr>
* Copyright (C) 2005 Marc Barilley / Ocebo <marc@ocebo.com>
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@inodbox.com>
* Copyright (C) 2014 Teddy Andreotti <125155@supinfo.com>
* Copyright (C) 2015 Marcos García <marcosgdf@gmail.com>
* Copyright (C) 2015 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2017 Alexandre Spangaro <aspangaro@open-dsi.fr>
* Copyright (C) 2018 Frédéric France <frederic.france@netlogic.fr>
* Copyright (C) 2020 Tobias Sekan <tobias.sekan@startmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
/**
* \file htdocs/fourn/paiment/list.php
* \ingroup fournisseur,facture
* \brief Payment list for supplier invoices
*/
require '../../main.inc.php';
// Security check
if ($user->socid) $socid = $user->socid;
// doesn't work :-(
// restrictedArea($user, 'fournisseur');
// doesn't work :-(
// require_once DOL_DOCUMENT_ROOT.'/fourn/class/paiementfourn.class.php';
// $object = new PaiementFourn($db);
// restrictedArea($user, $object->element);
if (!$user->rights->fournisseur->facture->lire) {
accessforbidden();
}
require_once DOL_DOCUMENT_ROOT.'/fourn/class/paiementfourn.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
// Load translation files required by the page
$langs->loadLangs(array('companies', 'bills', 'banks', 'compta'));
$action = GETPOST('action', 'alpha');
$massaction = GETPOST('massaction', 'alpha');
$optioncss = GETPOST('optioncss', 'alpha');
$contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'vendorpaymentlist';
$socid = GETPOST('socid', 'int');
$search_ref = GETPOST('search_ref', 'alpha');
$search_day = GETPOST('search_day', 'int');
$search_month = GETPOST('search_month', 'int');
$search_year = GETPOST('search_year', 'int');
$search_company = GETPOST('search_company', 'alpha');
$search_payment_type = GETPOST('search_payment_type');
$search_cheque_num = GETPOST('search_cheque_num', 'alpha');
$search_bank_account = GETPOST('search_bank_account', 'int');
$search_amount = GETPOST('search_amount', 'alpha'); // alpha because we must be able to search on '< x'
$limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit;
$sortfield = GETPOST('sortfield', 'alpha');
$sortorder = GETPOST('sortorder', 'alpha');
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST('page', 'int');
if (empty($page) || $page == -1) $page = 0; // If $page is not defined, or '' or -1
$offset = $limit * $page;
$pageprev = $page - 1;
$pagenext = $page + 1;
if (!$sortorder) $sortorder = "DESC";
if (!$sortfield) $sortfield = "p.datep";
// TODO: add global search for this list
$arrayfields = array(
'p.ref' =>array('label'=>"RefPayment", 'checked'=>1, 'position'=>10),
'p.datep' =>array('label'=>"Date", 'checked'=>1, 'position'=>20),
's.nom' =>array('label'=>"ThirdParty", 'checked'=>1, 'position'=>30),
'c.libelle' =>array('label'=>"Type", 'checked'=>1, 'position'=>40),
'p.num_paiement' =>array('label'=>"Numero", 'checked'=>1, 'position'=>50, 'tooltip'=>"ChequeOrTransferNumber"),
'ba.label' =>array('label'=>"Account", 'checked'=>1, 'position'=>60, 'enable'=>(!empty($conf->banque->enabled))),
'p.amount' =>array('label'=>"Amount", 'checked'=>1, 'position'=>70),
);
$arrayfields = dol_sort_array($arrayfields, 'position');
$hookmanager->initHooks(array('paymentsupplierlist'));
$object = new PaiementFourn($db);
/*
* Actions
*/
$parameters = array('socid'=>$socid);
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
if (empty($reshook)) {
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 tests are required to be compatible with all browsers
$search_ref = '';
$search_day = '';
$search_month = '';
$search_year = '';
$search_company = '';
$search_payment_type = '';
$search_cheque_num = '';
$search_bank_account = '';
$search_amount = '';
}
}
/*
* View
*/
llxHeader('', $langs->trans('ListPayment'));
$form = new Form($db);
$formother = new FormOther($db);
$companystatic = new Societe($db);
$paymentfournstatic = new PaiementFourn($db);
$sql = 'SELECT p.rowid, p.ref, p.datep, p.amount as pamount, p.num_paiement';
$sql .= ', s.rowid as socid, s.nom as name, s.email';
$sql .= ', c.code as paiement_type, c.libelle as paiement_libelle';
$sql .= ', ba.rowid as bid, ba.label';
if (!$user->rights->societe->client->voir) $sql .= ', sc.fk_soc, sc.fk_user';
$sql .= ', SUM(pf.amount)';
$sql .= ' FROM '.MAIN_DB_PREFIX.'paiementfourn AS p';
$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'paiementfourn_facturefourn AS pf ON p.rowid=pf.fk_paiementfourn';
$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'facture_fourn AS f ON f.rowid=pf.fk_facturefourn';
$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement AS c ON p.fk_paiement = c.id';
$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe AS s ON s.rowid = f.fk_soc';
$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'bank as b ON p.fk_bank = b.rowid';
$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'bank_account as ba ON b.fk_account = ba.rowid';
if (!$user->rights->societe->client->voir) $sql .= ', '.MAIN_DB_PREFIX.'societe_commerciaux as sc';
$sql .= ' WHERE f.entity = '.$conf->entity;
if (!$user->rights->societe->client->voir) $sql .= ' AND s.rowid = sc.fk_soc AND sc.fk_user = '.$user->id;
if ($socid > 0) $sql .= ' AND f.fk_soc = '.$socid;
if ($search_ref) $sql .= natural_search('p.ref', $search_ref);
$sql .= dolSqlDateFilter('p.datep', $search_day, $search_month, $search_year);
if ($search_company) $sql .= natural_search('s.nom', $search_company);
if ($search_payment_type != '') $sql .= " AND c.code='".$db->escape($search_payment_type)."'";
if ($search_cheque_num != '') $sql .= natural_search('p.num_paiement', $search_cheque_num);
if ($search_amount) $sql .= natural_search('p.amount', $search_amount, 1);
if ($search_bank_account > 0) $sql .= ' AND b.fk_account='.$search_bank_account."'";
// Add where from extra fields
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
$sql .= ' GROUP BY p.rowid, p.datep, p.amount, p.num_paiement, s.rowid, s.nom, c.code, c.libelle, ba.rowid, ba.label';
if (!$user->rights->societe->client->voir) $sql .= ', sc.fk_soc, sc.fk_user';
$sql .= $db->order($sortfield, $sortorder);
$nbtotalofrecords = '';
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
$result = $db->query($sql);
$nbtotalofrecords = $db->num_rows($result);
if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0
$page = 0;
$offset = 0;
}
}
$sql .= $db->plimit($limit + 1, $offset);
$resql = $db->query($sql);
if (!$resql) {
dol_print_error($db);
llxFooter();
$db->close();
exit;
}
$num = $db->num_rows($resql);
$i = 0;
$param = '';
if (!empty($contextpage) && $contextpage != $_SERVER['PHP_SELF']) $param .= '&contextpage='.urlencode($contextpage);
if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit);
if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss);
if ($search_ref) $param .= '&search_ref='.urlencode($search_ref);
if ($saerch_day) $param .= '&search_day='.urlencode($search_day);
if ($saerch_month) $param .= '&search_month='.urlencode($search_month);
if ($search_year) $param .= '&search_year='.urlencode($search_year);
if ($search_company) $param .= '&search_company='.urlencode($search_company);
if ($search_payment_type) $param .= '&search_company='.urlencode($search_payment_type);
if ($search_cheque_num) $param .= '&search_cheque_num='.urlencode($search_cheque_num);
if ($search_amount) $param .= '&search_amount='.urlencode($search_amount);
// Add $param from extra fields
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="action" 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="sortorder" value="'.$sortorder.'">';
print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
print_barre_liste($langs->trans('SupplierPayments'), $page, $_SERVER['PHP_SELF'], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'supplier_invoice', 0, '', '', $limit, 0, 0, 1);
$moreforfilter = '';
$parameters = array();
$reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook
if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint;
else $moreforfilter = $hookmanager->resPrint;
if ($moreforfilter) {
print '<div class="liste_titre liste_titre_bydiv centpercent">';
print $moreforfilter;
print '</div>';
}
$varpage = empty($contextpage) ? $_SERVER['PHP_SELF'] : $contextpage;
$selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
if ($massactionbutton) $selectedfields .= $form->showCheckAddButtons('checkforselect', 1);
print '<div class="div-table-responsive">';
print '<table class="tagtable nobottomiftotal liste'.($moreforfilter ? " listwithfilterbefore" : '').'">';
print '<tr class="liste_titre_filter">';
// Filter: Ref
if (!empty($arrayfields['p.ref']['checked'])) {
print '<td class="liste_titre left">';
print '<input class="flat" type="text" size="4" name="search_ref" value="'.dol_escape_htmltag($search_ref).'">';
print '</td>';
}
// Filter: Date
if (!empty($arrayfields['p.datep']['checked'])) {
print '<td class="liste_titre center">';
if (!empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print '<input class="flat width25 valignmiddle" type="text" maxlength="2" name="search_day" value="'.dol_escape_htmltag($search_day).'">';
print '<input class="flat width25 valignmiddle" type="text" maxlength="2" name="search_month" value="'.dol_escape_htmltag($search_month).'">';
$formother->select_year($search_year ? $search_year : -1, 'search_year', 1, 20, 5);
print '</td>';
}
// Filter: Thirdparty
if (!empty($arrayfields['s.nom']['checked'])) {
print '<td class="liste_titre">';
print '<input class="flat" type="text" size="6" name="search_company" value="'.dol_escape_htmltag($search_company).'">';
print '</td>';
}
// Filter: Payment type
if (!empty($arrayfields['c.libelle']['checked'])) {
print '<td class="liste_titre">';
$form->select_types_paiements($search_payment_type, 'search_payment_type', '', 2, 1, 1);
print '</td>';
}
// Filter: Cheque number (fund transfer)
if (!empty($arrayfields['p.num_paiement']['checked'])) {
print '<td class="liste_titre">';
print '<input class="flat" type="text" size="4" name="search_cheque_num" value="'.dol_escape_htmltag($search_cheque_num).'">';
print '</td>';
}
// Filter: Bank account
if (!empty($arrayfields['ba.label']['checked'])) {
print '<td class="liste_titre">';
$form->select_comptes($search_bank_account, 'search_bank_account', 0, '', 1);
print '</td>';
}
// Filter: Amount
if (!empty($arrayfields['p.amount']['checked'])) {
print '<td class="liste_titre right">';
print '<input class="flat" type="text" size="4" name="search_amount" value="'.dol_escape_htmltag($search_amount).'">';
print '</td>';
}
// Fields from hook
$parameters = array('arrayfields'=>$arrayfields);
$reshook = $hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook
print $hookmanager->resPrint;
// Buttons
print '<td class="liste_titre maxwidthsearch">';
print $form->showFilterAndCheckAddButtons(0);
print '</td>';
print '</tr>';
print '<tr class="liste_titre">';
if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER_IN_LIST)) print_liste_field_titre('#', $_SERVER['PHP_SELF'], '', '', $param, '', $sortfield, $sortorder);
if (!empty($arrayfields['p.ref']['checked'])) print_liste_field_titre($arrayfields['p.ref']['label'], $_SERVER["PHP_SELF"], 'p.rowid', '', $param, '', $sortfield, $sortorder);
if (!empty($arrayfields['p.datep']['checked'])) print_liste_field_titre($arrayfields['p.datep']['label'], $_SERVER["PHP_SELF"], 'p.datep', '', $param, '', $sortfield, $sortorder, 'center ');
if (!empty($arrayfields['s.nom']['checked'])) print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER["PHP_SELF"], 's.nom', '', $param, '', $sortfield, $sortorder);
if (!empty($arrayfields['c.libelle']['checked'])) print_liste_field_titre($arrayfields['c.libelle']['label'], $_SERVER["PHP_SELF"], 'c.libelle', '', $param, '', $sortfield, $sortorder);
if (!empty($arrayfields['p.num_paiement']['checked'])) print_liste_field_titre($arrayfields['p.num_paiement']['label'], $_SERVER["PHP_SELF"], "p.num_paiement", '', $param, '', $sortfield, $sortorder, '', $arrayfields['p.num_paiement']['tooltip']);
if (!empty($arrayfields['ba.label']['checked'])) print_liste_field_titre($arrayfields['ba.label']['label'], $_SERVER["PHP_SELF"], 'ba.label', '', $param, '', $sortfield, $sortorder);
if (!empty($arrayfields['p.amount']['checked'])) print_liste_field_titre($arrayfields['p.amount']['label'], $_SERVER["PHP_SELF"], 'p.amount', '', $param, '', $sortfield, $sortorder, 'right ');
// Hook fields
$parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder);
$reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook
print $hookmanager->resPrint;
print_liste_field_titre($selectedfields, $_SERVER['PHP_SELF'], '', '', '', 'align="center"', $sortfield, $sortorder, 'maxwidthsearch ');
print '</tr>';
$checkedCount = 0;
foreach ($arrayfields as $column) {
if ($column['checked']) {
$checkedCount++;
}
}
$i = 0;
$totalarray = array();
while ($i < min($num, $limit)) {
$objp = $db->fetch_object($resql);
$paymentfournstatic->id = $objp->rowid;
$paymentfournstatic->ref = $objp->ref;
$paymentfournstatic->datepaye = $objp->datep;
$companystatic->id = $objp->socid;
$companystatic->name = $objp->name;
$companystatic->email = $objp->email;
print '<tr class="oddeven">';
// No
if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER_IN_LIST)) {
print '<td>'.(($offset * $limit) + $i).'</td>';
if (!$i) $totalarray['nbfield']++;
}
// Ref
if (!empty($arrayfields['p.ref']['checked'])) {
print '<td class="nowrap">'.$paymentfournstatic->getNomUrl(1).'</td>';
if (!$i) $totalarray['nbfield']++;
}
// Date
if (!empty($arrayfields['p.datep']['checked'])) {
$dateformatforpayment = 'day';
if (!empty($conf->global->INVOICE_USE_HOURS_FOR_PAYMENT)) $dateformatforpayment = 'dayhour';
print '<td class="nowrap center">'.dol_print_date($db->jdate($objp->datep), $dateformatforpayment).'</td>';
if (!$i) $totalarray['nbfield']++;
}
// Thirdparty
if (!empty($arrayfields['s.nom']['checked'])) {
print '<td>';
if ($objp->socid > 0) {
print $companystatic->getNomUrl(1, '', 24);
}
print '</td>';
if (!$i) $totalarray['nbfield']++;
}
// Pyament type
if (!empty($arrayfields['c.libelle']['checked'])) {
$payment_type = $langs->trans("PaymentType".$objp->paiement_type) != ("PaymentType".$objp->paiement_type) ? $langs->trans("PaymentType".$objp->paiement_type) : $objp->paiement_libelle;
print '<td>'.$payment_type.' '.dol_trunc($objp->num_paiement, 32).'</td>';
if (!$i) $totalarray['nbfield']++;
}
// Cheque number (fund transfer)
if (!empty($arrayfields['p.num_paiement']['checked'])) {
print '<td>'.$objp->num_paiement.'</td>';
if (!$i) $totalarray['nbfield']++;
}
// Account
if (!empty($arrayfields['ba.label']['checked']))
{
print '<td>';
if ($objp->bid) print '<a href="'.DOL_URL_ROOT.'/compta/bank/bankentries_list.php?account='.$objp->bid.'">'.img_object($langs->trans("ShowAccount"), 'account').' '.dol_trunc($objp->label, 24).'</a>';
else print '&nbsp;';
print '</td>';
if (!$i) $totalarray['nbfield']++;
}
// Amount
if (!empty($arrayfields['p.amount']['checked'])) {
print '<td class="right">'.price($objp->pamount).'</td>';
if (!$i) $totalarray['nbfield']++;
$totalarray['pos'][$checkedCount] = 'amount';
$totalarray['val']['amount'] += $objp->pamount;
}
// Buttons
print '<td></td>';
if (!$i) $totalarray['nbfield']++;
print '</tr>';
$i++;
}
// Show total line
include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
print '</table>';
print '</div>';
print '</form>';
// End of page
llxFooter();
$db->close();

View File

@ -48,7 +48,10 @@ $massaction = GETPOST('massaction', 'alpha');
$contextpage = GETPOST('contextpage', 'aZ'); $contextpage = GETPOST('contextpage', 'aZ');
$optioncss = GETPOST('optioncss', 'aZ'); $optioncss = GETPOST('optioncss', 'aZ');
$search_ref = GETPOST('search_ref', 'alpha'); $search_ref = GETPOST('search_ref', 'alphanohtml');
$search_employee = GETPOST('search_employee', 'int');
$search_type = GETPOST('search_type', 'int');
$search_description = GETPOST('search_description', 'alphanohtml');
$limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit;
$sortfield = GETPOST('sortfield', 'aZ09comma'); $sortfield = GETPOST('sortfield', 'aZ09comma');
@ -82,6 +85,9 @@ if (empty($reshook))
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
{ {
$search_ref = ''; $search_ref = '';
$search_employee = '';
$search_type = '';
$search_description = '';
$toselect = ''; $toselect = '';
$search_array_options = array(); $search_array_options = array();
} }
@ -135,7 +141,10 @@ $sql.= " WHERE cp.rowid > 0";
$sql.= " AND cp.statut = 3"; // 3 = Approved $sql.= " AND cp.statut = 3"; // 3 = Approved
$sql.= " AND (date_format(cp.date_debut, '%Y-%m') = '".$db->escape($year_month)."' OR date_format(cp.date_fin, '%Y-%m') = '".$db->escape($year_month)."')"; $sql.= " AND (date_format(cp.date_debut, '%Y-%m') = '".$db->escape($year_month)."' OR date_format(cp.date_fin, '%Y-%m') = '".$db->escape($year_month)."')";
if ($search_ref != '') $sql.= natural_search('cp.ref', $search_ref, 0); if (!empty($search_ref)) $sql .= natural_search('cp.ref', $search_ref);
if (!empty($search_employee)) $sql .= " AND cp.fk_user = '".$db->escape($search_employee)."'";
if (!empty($search_type)) $sql .= ' AND cp.fk_type IN ('.$db->escape($search_type).')';
if (!empty($search_description)) $sql.= natural_search('cp.description', $search_description);
$sql.= $db->order($sortfield, $sortorder); $sql.= $db->order($sortfield, $sortorder);
@ -149,9 +158,12 @@ if (empty($resql))
$num = $db->num_rows($resql); $num = $db->num_rows($resql);
$param = ''; $param = '';
if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.= '&contextpage='.urlencode($contextpage); if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.= '&contextpage='.urlencode($contextpage);
if ($limit > 0 && $limit != $conf->liste_limit) $param.= '&limit='.urlencode($limit); if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit);
if ($search_ref) $param = '&search_ref='.urlencode($search_ref); if (!empty($search_ref)) $param .= '&search_ref='.urlencode($search_ref);
if (!empty($search_employee)) $param .= '&search_employee='.urlencode($search_employee);
if (!empty($search_type)) $param .= '&search_type='.urlencode($search_type);
if (!empty($search_description)) $param .= '&search_description='.urlencode($search_description);
print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">'; print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">';
if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">'; if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
@ -184,16 +196,50 @@ print '<div class="div-table-responsive">';
print '<table class="noborder centpercent">'; print '<table class="noborder centpercent">';
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
if (!empty($arrayfields['cp.ref']['checked'])) print '<td class="liste_titre"><input type="text" class="maxwidth100" name="search_ref" value="'.$search_ref.'"></td>';
if (!empty($arrayfields['cp.fk_user']['checked'])) print '<td class="liste_titre"></td>'; // Filter: Ref
if (!empty($arrayfields['ct.label']['checked'])) print '<td class="liste_titre"></td>'; if (!empty($arrayfields['cp.ref']['checked'])) {
print '<td class="liste_titre">';
print '<input class="flat maxwidth100" type="text" name="search_ref" value="'.dol_escape_htmltag($search_ref).'">';
print '</td>';
}
// Filter: Employee
if (!empty($arrayfields['cp.fk_user']['checked'])) {
print '<td class="liste_titre">';
print $form->select_dolusers($search_employee, "search_employee", 1, null, 0, '', '', 0, 0, 0, '', 0, '', 'maxwidth200');
print '</td>';
}
// Filter: Type
if (!empty($arrayfields['ct.label']['checked'])) {
$typeleaves = $holidaystatic->getTypes(1, -1);
$arraytypeleaves = array();
foreach ($typeleaves as $key => $val)
{
$labeltoshow = ($langs->trans($val['code']) != $val['code'] ? $langs->trans($val['code']) : $val['label']);
$arraytypeleaves[$val['rowid']] = $labeltoshow;
}
print '<td class="liste_titre">';
print $form->selectarray('search_type', $arraytypeleaves, $search_type, 1, 0, 0, '', 0, 0, 0, '', '', 1);
print '</td>';
}
if (!empty($arrayfields['cp.date_debut']['checked'])) print '<td class="liste_titre"></td>'; if (!empty($arrayfields['cp.date_debut']['checked'])) print '<td class="liste_titre"></td>';
if (!empty($arrayfields['cp.date_fin']['checked'])) print '<td class="liste_titre"></td>'; if (!empty($arrayfields['cp.date_fin']['checked'])) print '<td class="liste_titre"></td>';
if (!empty($arrayfields['used_days']['checked'])) print '<td class="liste_titre"></td>'; if (!empty($arrayfields['used_days']['checked'])) print '<td class="liste_titre"></td>';
if (!empty($arrayfields['date_start_month']['checked'])) print '<td class="liste_titre"></td>'; if (!empty($arrayfields['date_start_month']['checked'])) print '<td class="liste_titre"></td>';
if (!empty($arrayfields['date_end_month']['checked'])) print '<td class="liste_titre"></td>'; if (!empty($arrayfields['date_end_month']['checked'])) print '<td class="liste_titre"></td>';
if (!empty($arrayfields['used_days_month']['checked'])) print '<td class="liste_titre"></td>'; if (!empty($arrayfields['used_days_month']['checked'])) print '<td class="liste_titre"></td>';
if (!empty($arrayfields['cp.description']['checked'])) print '<td class="liste_titre"></td>';
// Filter: Description
if (!empty($arrayfields['cp.description']['checked'])) {
print '<td class="liste_titre">';
print '<input type="text" class="maxwidth100" name="search_description" value="'.$search_description.'">';
print '</td>';
}
// Action column // Action column
print '<td class="liste_titre maxwidthsearch">'; print '<td class="liste_titre maxwidthsearch">';
$searchpicto = $form->showFilterButtons(); $searchpicto = $form->showFilterButtons();

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;

Some files were not shown because too many files have changed in this diff Show More