Merge branch 'develop' of https://github.com/Dolibarr/dolibarr into develop-api

This commit is contained in:
Neil Orley 2017-10-25 14:46:44 +02:00
commit ff760eb8d5
82 changed files with 1570 additions and 539 deletions

View File

@ -37,7 +37,7 @@ $form = new Form($db);
// List of supported format // List of supported format
$tmptype2label=ExtraFields::$type2label; $tmptype2label=ExtraFields::$type2label;
$type2label=array(''); $type2label=array('');
foreach ($tmptype2label as $key => $val) $type2label[$key]=$langs->trans($val); foreach ($tmptype2label as $key => $val) $type2label[$key]=$langs->transnoentitiesnoconv($val);
$action=GETPOST('action', 'alpha'); $action=GETPOST('action', 'alpha');
$attrname=GETPOST('attrname', 'alpha'); $attrname=GETPOST('attrname', 'alpha');

View File

@ -40,7 +40,7 @@ $form = new Form($db);
// List of supported format // List of supported format
$tmptype2label=ExtraFields::$type2label; $tmptype2label=ExtraFields::$type2label;
$type2label=array(''); $type2label=array('');
foreach ($tmptype2label as $key => $val) $type2label[$key]=$langs->trans($val); foreach ($tmptype2label as $key => $val) $type2label[$key]=$langs->transnoentitiesnoconv($val);
$action=GETPOST('action', 'alpha'); $action=GETPOST('action', 'alpha');
$attrname=GETPOST('attrname', 'alpha'); $attrname=GETPOST('attrname', 'alpha');

View File

@ -44,7 +44,7 @@ $form = new Form($db);
// List of supported format // List of supported format
$tmptype2label=ExtraFields::$type2label; $tmptype2label=ExtraFields::$type2label;
$type2label=array(''); $type2label=array('');
foreach ($tmptype2label as $key => $val) $type2label[$key]=$langs->trans($val); foreach ($tmptype2label as $key => $val) $type2label[$key]=$langs->transnoentitiesnoconv($val);
$action=GETPOST('action', 'alpha'); $action=GETPOST('action', 'alpha');
$attrname=GETPOST('attrname', 'alpha'); $attrname=GETPOST('attrname', 'alpha');

View File

@ -39,7 +39,7 @@ $form = new Form($db);
// List of supported format // List of supported format
$tmptype2label=ExtraFields::$type2label; $tmptype2label=ExtraFields::$type2label;
$type2label=array(''); $type2label=array('');
foreach ($tmptype2label as $key => $val) $type2label[$key]=$langs->trans($val); foreach ($tmptype2label as $key => $val) $type2label[$key]=$langs->transnoentitiesnoconv($val);
$action=GETPOST('action', 'alpha'); $action=GETPOST('action', 'alpha');
$attrname=GETPOST('attrname', 'alpha'); $attrname=GETPOST('attrname', 'alpha');

View File

@ -47,7 +47,7 @@ $form = new Form($db);
// List of supported format // List of supported format
$tmptype2label=ExtraFields::$type2label; $tmptype2label=ExtraFields::$type2label;
$type2label=array(''); $type2label=array('');
foreach ($tmptype2label as $key => $val) $type2label[$key]=$langs->trans($val); foreach ($tmptype2label as $key => $val) $type2label[$key]=$langs->transnoentitiesnoconv($val);
$action=GETPOST('action', 'alpha'); $action=GETPOST('action', 'alpha');
$attrname=GETPOST('attrname', 'alpha'); $attrname=GETPOST('attrname', 'alpha');

View File

@ -47,7 +47,7 @@ $form = new Form($db);
// List of supported format // List of supported format
$tmptype2label=ExtraFields::$type2label; $tmptype2label=ExtraFields::$type2label;
$type2label=array(''); $type2label=array('');
foreach ($tmptype2label as $key => $val) $type2label[$key]=$langs->trans($val); foreach ($tmptype2label as $key => $val) $type2label[$key]=$langs->transnoentitiesnoconv($val);
$action=GETPOST('action', 'alpha'); $action=GETPOST('action', 'alpha');
$attrname=GETPOST('attrname', 'alpha'); $attrname=GETPOST('attrname', 'alpha');

View File

@ -44,7 +44,7 @@ $form = new Form($db);
// List of supported format // List of supported format
$tmptype2label=ExtraFields::$type2label; $tmptype2label=ExtraFields::$type2label;
$type2label=array(''); $type2label=array('');
foreach ($tmptype2label as $key => $val) $type2label[$key]=$langs->trans($val); foreach ($tmptype2label as $key => $val) $type2label[$key]=$langs->transnoentitiesnoconv($val);
$action=GETPOST('action', 'alpha'); $action=GETPOST('action', 'alpha');
$attrname=GETPOST('attrname', 'alpha'); $attrname=GETPOST('attrname', 'alpha');

View File

@ -47,7 +47,7 @@ $form = new Form($db);
// List of supported format // List of supported format
$tmptype2label=ExtraFields::$type2label; $tmptype2label=ExtraFields::$type2label;
$type2label=array(''); $type2label=array('');
foreach ($tmptype2label as $key => $val) $type2label[$key]=$langs->trans($val); foreach ($tmptype2label as $key => $val) $type2label[$key]=$langs->transnoentitiesnoconv($val);
$action=GETPOST('action', 'alpha'); $action=GETPOST('action', 'alpha');
$attrname=GETPOST('attrname', 'alpha'); $attrname=GETPOST('attrname', 'alpha');

View File

@ -47,7 +47,7 @@ $form = new Form($db);
// List of supported format // List of supported format
$tmptype2label=ExtraFields::$type2label; $tmptype2label=ExtraFields::$type2label;
$type2label=array(''); $type2label=array('');
foreach ($tmptype2label as $key => $val) $type2label[$key]=$langs->trans($val); foreach ($tmptype2label as $key => $val) $type2label[$key]=$langs->transnoentitiesnoconv($val);
$action=GETPOST('action', 'alpha'); $action=GETPOST('action', 'alpha');
$attrname=GETPOST('attrname', 'alpha'); $attrname=GETPOST('attrname', 'alpha');

View File

@ -44,7 +44,7 @@ $form = new Form($db);
// List of supported format // List of supported format
$tmptype2label=ExtraFields::$type2label; $tmptype2label=ExtraFields::$type2label;
$type2label=array(''); $type2label=array('');
foreach ($tmptype2label as $key => $val) $type2label[$key]=$langs->trans($val); foreach ($tmptype2label as $key => $val) $type2label[$key]=$langs->transnoentitiesnoconv($val);
$action=GETPOST('action', 'alpha'); $action=GETPOST('action', 'alpha');
$attrname=GETPOST('attrname', 'alpha'); $attrname=GETPOST('attrname', 'alpha');

View File

@ -45,7 +45,7 @@ $form = new Form($db);
// List of supported format // List of supported format
$tmptype2label=ExtraFields::$type2label; $tmptype2label=ExtraFields::$type2label;
$type2label=array(''); $type2label=array('');
foreach ($tmptype2label as $key => $val) $type2label[$key]=$langs->trans($val); foreach ($tmptype2label as $key => $val) $type2label[$key]=$langs->transnoentitiesnoconv($val);
$action=GETPOST('action', 'alpha'); $action=GETPOST('action', 'alpha');
$attrname=GETPOST('attrname', 'alpha'); $attrname=GETPOST('attrname', 'alpha');

View File

@ -43,7 +43,7 @@ $form = new Form($db);
// List of supported format // List of supported format
$tmptype2label=ExtraFields::$type2label; $tmptype2label=ExtraFields::$type2label;
$type2label=array(''); $type2label=array('');
foreach ($tmptype2label as $key => $val) $type2label[$key]=$langs->trans($val); foreach ($tmptype2label as $key => $val) $type2label[$key]=$langs->transnoentitiesnoconv($val);
$action=GETPOST('action', 'alpha'); $action=GETPOST('action', 'alpha');
$attrname=GETPOST('attrname', 'alpha'); $attrname=GETPOST('attrname', 'alpha');

View File

@ -48,7 +48,7 @@ $form = new Form($db);
// List of supported format // List of supported format
$tmptype2label=ExtraFields::$type2label; $tmptype2label=ExtraFields::$type2label;
$type2label=array(''); $type2label=array('');
foreach ($tmptype2label as $key => $val) $type2label[$key]=$langs->trans($val); foreach ($tmptype2label as $key => $val) $type2label[$key]=$langs->transnoentitiesnoconv($val);
$action=GETPOST('action', 'alpha'); $action=GETPOST('action', 'alpha');
$attrname=GETPOST('attrname', 'alpha'); $attrname=GETPOST('attrname', 'alpha');

View File

@ -48,7 +48,7 @@ $form = new Form($db);
// List of supported format // List of supported format
$tmptype2label=ExtraFields::$type2label; $tmptype2label=ExtraFields::$type2label;
$type2label=array(''); $type2label=array('');
foreach ($tmptype2label as $key => $val) $type2label[$key]=$langs->trans($val); foreach ($tmptype2label as $key => $val) $type2label[$key]=$langs->transnoentitiesnoconv($val);
$action=GETPOST('action', 'alpha'); $action=GETPOST('action', 'alpha');
$attrname=GETPOST('attrname', 'alpha'); $attrname=GETPOST('attrname', 'alpha');

View File

@ -44,7 +44,7 @@ $form = new Form($db);
// List of supported format // List of supported format
$tmptype2label=ExtraFields::$type2label; $tmptype2label=ExtraFields::$type2label;
$type2label=array(''); $type2label=array('');
foreach ($tmptype2label as $key => $val) $type2label[$key]=$langs->trans($val); foreach ($tmptype2label as $key => $val) $type2label[$key]=$langs->transnoentitiesnoconv($val);
$action=GETPOST('action', 'alpha'); $action=GETPOST('action', 'alpha');
$attrname=GETPOST('attrname', 'alpha'); $attrname=GETPOST('attrname', 'alpha');

View File

@ -45,7 +45,7 @@ $form = new Form($db);
// List of supported format // List of supported format
$tmptype2label=ExtraFields::$type2label; $tmptype2label=ExtraFields::$type2label;
$type2label=array(''); $type2label=array('');
foreach ($tmptype2label as $key => $val) $type2label[$key]=$langs->trans($val); foreach ($tmptype2label as $key => $val) $type2label[$key]=$langs->transnoentitiesnoconv($val);
$action=GETPOST('action', 'alpha'); $action=GETPOST('action', 'alpha');
$attrname=GETPOST('attrname', 'alpha'); $attrname=GETPOST('attrname', 'alpha');

View File

@ -335,7 +335,7 @@ class Dictionary extends DolibarrApi
if ($type == 'thirdparty') $type='societe'; if ($type == 'thirdparty') $type='societe';
if ($type == 'contact') $type='socpeople'; if ($type == 'contact') $type='socpeople';
$sql = "SELECT t.rowid, t.name, t.label, t.type, t.size, t.elementtype, t.fieldunique, t.fieldrequired, t.param, t.pos, t.alwayseditable, t.perms, t.list, t.ishidden, t.fielddefault, t.fieldcomputed"; $sql = "SELECT t.rowid, t.name, t.label, t.type, t.size, t.elementtype, t.fieldunique, t.fieldrequired, t.param, t.pos, t.alwayseditable, t.perms, t.list, t.fielddefault, t.fieldcomputed";
$sql.= " FROM ".MAIN_DB_PREFIX."extrafields as t"; $sql.= " FROM ".MAIN_DB_PREFIX."extrafields as t";
$sql.= " WHERE t.entity IN (".getEntity('extrafields').")"; $sql.= " WHERE t.entity IN (".getEntity('extrafields').")";
if (! empty($type)) $sql.= " AND t.elementtype = '".$this->db->escape($type)."'"; if (! empty($type)) $sql.= " AND t.elementtype = '".$this->db->escape($type)."'";
@ -373,7 +373,6 @@ class Dictionary extends DolibarrApi
$list[$tab->elementtype][$tab->name]['alwayseditable']=$tab->alwayseditable; $list[$tab->elementtype][$tab->name]['alwayseditable']=$tab->alwayseditable;
$list[$tab->elementtype][$tab->name]['perms']=$tab->perms; $list[$tab->elementtype][$tab->name]['perms']=$tab->perms;
$list[$tab->elementtype][$tab->name]['list']=$tab->list; $list[$tab->elementtype][$tab->name]['list']=$tab->list;
$list[$tab->elementtype][$tab->name]['ishidden']=$tab->ishidden;
} }
} }
} }

View File

@ -155,10 +155,16 @@ class BlockedLog
*/ */
public function setObjectData(&$object) { public function setObjectData(&$object) {
if($object->element=='payment') { // Set date
if ($object->element=='payment')
{
$this->date_object = $object->datepaye; $this->date_object = $object->datepaye;
} }
else{ if ($object->element=='payment_salary')
{
$this->date_object = $object->datev;
}
else {
$this->date_object = $object->date; $this->date_object = $object->date;
} }
@ -168,7 +174,8 @@ class BlockedLog
$this->object_data=new stdClass(); $this->object_data=new stdClass();
if($this->element === 'facture') { if ($this->element === 'facture')
{
if(empty($object->thirdparty))$object->fetch_thirdparty(); if(empty($object->thirdparty))$object->fetch_thirdparty();
$this->object_data->thirdparty = new stdClass(); $this->object_data->thirdparty = new stdClass();
@ -182,14 +189,16 @@ class BlockedLog
$this->object_data->total_localtax1= (double) $object->total_localtax1; $this->object_data->total_localtax1= (double) $object->total_localtax1;
$this->object_data->total_localtax2= (double) $object->total_localtax2; $this->object_data->total_localtax2= (double) $object->total_localtax2;
$this->object_data->note_public = (double) $object->note_public; $this->object_data->note_public = (double) $object->note_public;
$this->object_data->note_private= (double) $object->note_private;
} }
elseif($this->element==='payment'){ elseif($this->element === 'payment')
{
$this->object_data->amounts = $object->amounts; $this->object_data->amounts = $object->amounts;
} }
elseif($this->element === 'payment_salary')
{
$this->object_data->amounts = array($object->amount);
}
} }
/** /**

View File

@ -37,7 +37,7 @@ $form = new Form($db);
// List of supported format // List of supported format
$tmptype2label=ExtraFields::$type2label; $tmptype2label=ExtraFields::$type2label;
$type2label=array(''); $type2label=array('');
foreach ($tmptype2label as $key => $val) $type2label[$key]=$langs->trans($val); foreach ($tmptype2label as $key => $val) $type2label[$key]=$langs->transnoentitiesnoconv($val);
$action=GETPOST('action', 'alpha'); $action=GETPOST('action', 'alpha');
$attrname=GETPOST('attrname', 'alpha'); $attrname=GETPOST('attrname', 'alpha');

View File

@ -38,7 +38,7 @@ $form = new Form($db);
// List of supported format // List of supported format
$tmptype2label=ExtraFields::$type2label; $tmptype2label=ExtraFields::$type2label;
$type2label=array(''); $type2label=array('');
foreach ($tmptype2label as $key => $val) $type2label[$key]=$langs->trans($val); foreach ($tmptype2label as $key => $val) $type2label[$key]=$langs->transnoentitiesnoconv($val);
$action=GETPOST('action', 'alpha'); $action=GETPOST('action', 'alpha');
$attrname=GETPOST('attrname', 'alpha'); $attrname=GETPOST('attrname', 'alpha');

View File

@ -45,7 +45,7 @@ $form = new Form($db);
// List of supported format // List of supported format
$tmptype2label=ExtraFields::$type2label; $tmptype2label=ExtraFields::$type2label;
$type2label=array(''); $type2label=array('');
foreach ($tmptype2label as $key => $val) $type2label[$key]=$langs->trans($val); foreach ($tmptype2label as $key => $val) $type2label[$key]=$langs->transnoentitiesnoconv($val);
$action=GETPOST('action', 'alpha'); $action=GETPOST('action', 'alpha');
$attrname=GETPOST('attrname', 'alpha'); $attrname=GETPOST('attrname', 'alpha');

View File

@ -186,8 +186,12 @@ if (empty($reshook))
if ($ret < 0) $error++; if ($ret < 0) $error++;
if (! $error) if (! $error)
{ {
$result = $object->insertExtraFields(); $result = $object->insertExtraFields();
if ($result < 0) $error++; if ($result < 0)
{
setEventMessages($object->error, $object->errors, 'errors');
$error++;
}
} }
if ($error) $action = 'edit_extras'; if ($error) $action = 'edit_extras';
} }

View File

@ -1176,7 +1176,11 @@ if (empty($reshook))
if (! $error) if (! $error)
{ {
$result = $object->insertExtraFields(); $result = $object->insertExtraFields();
if ($result < 0) $error++; if ($result < 0)
{
setEventMessages($object->error, $object->errors, 'errors');
$error++;
}
} }
if ($error) $action = 'edit_extras'; if ($error) $action = 'edit_extras';
} }

View File

@ -1226,7 +1226,9 @@ if (empty($reshook))
// some hooks // some hooks
if (empty($reshook)) { if (empty($reshook)) {
$result = $object->insertExtraFields(); $result = $object->insertExtraFields();
if ($result < 0) { if ($result < 0)
{
setEventMessages($object->error, $object->errors, 'errors');
$error++; $error++;
} }
} else if ($reshook < 0) } else if ($reshook < 0)

View File

@ -386,7 +386,7 @@ class Account extends CommonObject
* Add an entry into table ".MAIN_DB_PREFIX."bank * Add an entry into table ".MAIN_DB_PREFIX."bank
* *
* @param int $date Date operation * @param int $date Date operation
* @param string $oper 1,2,3,4... (deprecated) or TYP,VIR,PRE,LIQ,VAD,CB,CHQ... * @param string $oper 1,2,3,4... (deprecated) or 'TYP','VIR','PRE','LIQ','VAD','CB','CHQ'...
* @param string $label Descripton * @param string $label Descripton
* @param float $amount Amount * @param float $amount Amount
* @param string $num_chq Numero cheque ou virement * @param string $num_chq Numero cheque ou virement

View File

@ -39,7 +39,7 @@ $form = new Form($db);
// List of supported format // List of supported format
$tmptype2label=ExtraFields::$type2label; $tmptype2label=ExtraFields::$type2label;
$type2label=array(''); $type2label=array('');
foreach ($tmptype2label as $key => $val) $type2label[$key]=$langs->trans($val); foreach ($tmptype2label as $key => $val) $type2label[$key]=$langs->transnoentitiesnoconv($val);
$action=GETPOST('action', 'alpha'); $action=GETPOST('action', 'alpha');
$attrname=GETPOST('attrname', 'alpha'); $attrname=GETPOST('attrname', 'alpha');

View File

@ -40,7 +40,7 @@ $form = new Form($db);
// List of supported format // List of supported format
$tmptype2label=ExtraFields::$type2label; $tmptype2label=ExtraFields::$type2label;
$type2label=array(''); $type2label=array('');
foreach ($tmptype2label as $key => $val) $type2label[$key]=$langs->trans($val); foreach ($tmptype2label as $key => $val) $type2label[$key]=$langs->transnoentitiesnoconv($val);
$action=GETPOST('action', 'alpha'); $action=GETPOST('action', 'alpha');
$attrname=GETPOST('attrname', 'alpha'); $attrname=GETPOST('attrname', 'alpha');

View File

@ -40,7 +40,7 @@ $form = new Form($db);
// List of supported format // List of supported format
$tmptype2label=ExtraFields::$type2label; $tmptype2label=ExtraFields::$type2label;
$type2label=array(''); $type2label=array('');
foreach ($tmptype2label as $key => $val) $type2label[$key]=$langs->trans($val); foreach ($tmptype2label as $key => $val) $type2label[$key]=$langs->transnoentitiesnoconv($val);
$action=GETPOST('action', 'alpha'); $action=GETPOST('action', 'alpha');
$attrname=GETPOST('attrname', 'alpha'); $attrname=GETPOST('attrname', 'alpha');

View File

@ -40,7 +40,7 @@ $form = new Form($db);
// List of supported format // List of supported format
$tmptype2label=ExtraFields::$type2label; $tmptype2label=ExtraFields::$type2label;
$type2label=array(''); $type2label=array('');
foreach ($tmptype2label as $key => $val) $type2label[$key]=$langs->trans($val); foreach ($tmptype2label as $key => $val) $type2label[$key]=$langs->transnoentitiesnoconv($val);
$action=GETPOST('action', 'alpha'); $action=GETPOST('action', 'alpha');
$attrname=GETPOST('attrname', 'alpha'); $attrname=GETPOST('attrname', 'alpha');

View File

@ -2041,8 +2041,10 @@ if (empty($reshook))
// some hooks // some hooks
if (empty($reshook)) { if (empty($reshook)) {
$result = $object->insertExtraFields(); $result = $object->insertExtraFields();
if ($result < 0) { if ($result < 0)
$error ++; {
setEventMessages($object->error, $object->errors, 'errors');
$error++;
} }
} else if ($reshook < 0) } else if ($reshook < 0)
$error ++; $error ++;

View File

@ -386,22 +386,16 @@ if (empty($reshook))
// Fill array 'array_options' with data from update form // Fill array 'array_options' with data from update form
$extralabels = $extrafields->fetch_name_optionals_label($object->table_element); $extralabels = $extrafields->fetch_name_optionals_label($object->table_element);
$ret = $extrafields->setOptionalsFromPost($extralabels, $object, GETPOST('attribute')); $ret = $extrafields->setOptionalsFromPost($extralabels, $object, GETPOST('attribute'));
if ($ret < 0) if ($ret < 0) $error++;
$error ++;
if (! $error) { if (! $error) {
$result = $object->insertExtraFields();
$result = $object->insertExtraFields(); if ($result < 0)
if ($result < 0) { {
$error ++; setEventMessages($object->error, $object->errors, 'errors');
} $error++;
} else if ($reshook < 0) }
$error ++; }
if ($error) {
$action = 'edit_extras';
setEventMessages($object->error, $object->errors, 'errors');
}
} }
// Add a new line // Add a new line

View File

@ -73,6 +73,8 @@ if ($action == 'add' && $_POST["cancel"] <> $langs->trans("Cancel"))
$dateep=dol_mktime(12,0,0, $_POST["dateepmonth"], $_POST["dateepday"], $_POST["dateepyear"]); $dateep=dol_mktime(12,0,0, $_POST["dateepmonth"], $_POST["dateepday"], $_POST["dateepyear"]);
if (empty($datev)) $datev=$datep; if (empty($datev)) $datev=$datep;
$type_payment = dol_getIdFromCode($db, GETPOST("paymenttype", 'alpha'), 'c_paiement');
$object->accountid=GETPOST("accountid") > 0 ? GETPOST("accountid","int") : 0; $object->accountid=GETPOST("accountid") > 0 ? GETPOST("accountid","int") : 0;
$object->fk_user=GETPOST("fk_user") > 0 ? GETPOST("fk_user","int") : 0; $object->fk_user=GETPOST("fk_user") > 0 ? GETPOST("fk_user","int") : 0;
$object->datev=$datev; $object->datev=$datev;
@ -82,7 +84,7 @@ if ($action == 'add' && $_POST["cancel"] <> $langs->trans("Cancel"))
$object->datesp=$datesp; $object->datesp=$datesp;
$object->dateep=$dateep; $object->dateep=$dateep;
$object->note=GETPOST("note"); $object->note=GETPOST("note");
$object->type_payment=GETPOST("paymenttype") > 0 ? GETPOST("paymenttype", "int") : 0; $object->type_payment=($type_payment > 0 ? $type_payment : 0);
$object->num_payment=GETPOST("num_payment"); $object->num_payment=GETPOST("num_payment");
$object->fk_user_author=$user->id; $object->fk_user_author=$user->id;
@ -101,7 +103,7 @@ if ($action == 'add' && $_POST["cancel"] <> $langs->trans("Cancel"))
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Employee")), null, 'errors'); setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Employee")), null, 'errors');
$error++; $error++;
} }
if (empty($object->type_payment) || $object->type_payment < 0) if (empty($type_payment) || $type_payment < 0)
{ {
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("PaymentMode")), null, 'errors'); setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("PaymentMode")), null, 'errors');
$error++; $error++;
@ -292,7 +294,7 @@ if ($action == 'create')
// Type payment // Type payment
print '<tr><td>'; print '<tr><td>';
print fieldLabel('PaymentMode','selectpaymenttype',1).'</td><td>'; print fieldLabel('PaymentMode','selectpaymenttype',1).'</td><td>';
$form->select_types_paiements(GETPOST("paymenttype"), "paymenttype"); $form->select_types_paiements(GETPOST("paymenttype"), "paymenttype", '', 2);
print '</td></tr>'; print '</td></tr>';
// Number // Number

View File

@ -349,7 +349,7 @@ class PaymentSalary extends CommonObject
$sql.= ", '".$this->db->idate($this->datev)."'"; $sql.= ", '".$this->db->idate($this->datev)."'";
$sql.= ", ".$this->amount; $sql.= ", ".$this->amount;
$sql.= ", ".($this->salary > 0 ? $this->salary : "null"); $sql.= ", ".($this->salary > 0 ? $this->salary : "null");
$sql.= ", '".$this->db->escape($this->type_payment)."'"; $sql.= ", ".$this->db->escape($this->type_payment);
$sql.= ", '".$this->db->escape($this->num_payment)."'"; $sql.= ", '".$this->db->escape($this->num_payment)."'";
if ($this->note) $sql.= ", '".$this->db->escape($this->note)."'"; if ($this->note) $sql.= ", '".$this->db->escape($this->note)."'";
$sql.= ", '".$this->db->escape($this->label)."'"; $sql.= ", '".$this->db->escape($this->label)."'";

View File

@ -114,7 +114,7 @@ $sql.= " AND s.entity = ".$conf->entity;
// Search criteria // Search criteria
if ($search_ref) $sql.=" AND s.rowid=".$search_ref; if ($search_ref) $sql.=" AND s.rowid=".$search_ref;
if ($search_user) $sql.=natural_search(array('u.login', 'u.lastname', 'u.firstname', 'u.email', 'u.note'), $search_user); if ($search_user) $sql.=natural_search(array('u.login', 'u.lastname', 'u.firstname', 'u.email'), $search_user);
if ($search_label) $sql.=natural_search(array('s.label'), $search_label); if ($search_label) $sql.=natural_search(array('s.label'), $search_label);
if ($search_amount) $sql.=natural_search("s.amount", $search_amount, 1); if ($search_amount) $sql.=natural_search("s.amount", $search_amount, 1);
if ($search_account > 0) $sql .=" AND b.fk_account=".$search_account; if ($search_account > 0) $sql .=" AND b.fk_account=".$search_account;

View File

@ -41,7 +41,7 @@ $form = new Form($db);
// List of supported format // List of supported format
$tmptype2label=ExtraFields::$type2label; $tmptype2label=ExtraFields::$type2label;
$type2label=array(''); $type2label=array('');
foreach ($tmptype2label as $key => $val) $type2label[$key]=$langs->trans($val); foreach ($tmptype2label as $key => $val) $type2label[$key]=$langs->transnoentitiesnoconv($val);
$action=GETPOST('action', 'alpha'); $action=GETPOST('action', 'alpha');
$attrname=GETPOST('attrname', 'alpha'); $attrname=GETPOST('attrname', 'alpha');

View File

@ -41,7 +41,7 @@ $form = new Form($db);
// List of supported format // List of supported format
$tmptype2label=ExtraFields::$type2label; $tmptype2label=ExtraFields::$type2label;
$type2label=array(''); $type2label=array('');
foreach ($tmptype2label as $key => $val) $type2label[$key]=$langs->trans($val); foreach ($tmptype2label as $key => $val) $type2label[$key]=$langs->transnoentitiesnoconv($val);
$action=GETPOST('action', 'alpha'); $action=GETPOST('action', 'alpha');
$attrname=GETPOST('attrname', 'alpha'); $attrname=GETPOST('attrname', 'alpha');

View File

@ -821,21 +821,19 @@ if (empty($reshook))
// Fill array 'array_options' with data from update form // Fill array 'array_options' with data from update form
$extralabels = $extrafields->fetch_name_optionals_label($object->table_element); $extralabels = $extrafields->fetch_name_optionals_label($object->table_element);
$ret = $extrafields->setOptionalsFromPost($extralabels, $object, GETPOST('attribute')); $ret = $extrafields->setOptionalsFromPost($extralabels, $object, GETPOST('attribute'));
if ($ret < 0) if ($ret < 0) $error++;
$error ++;
if (! $error) { if (! $error) {
$result = $object->insertExtraFields();
$result = $object->insertExtraFields(); if ($result < 0)
if ($result < 0) { {
$error ++; setEventMessages($object->error, $object->errors, 'errors');
} $error++;
} else if ($reshook < 0) }
$error ++; }
if ($error) { if ($error) {
$action = 'edit_extras'; $action = 'edit_extras';
setEventMessages($object->error, $object->errors, 'errors');
} }
} }
elseif ($action=='setref_supplier') elseif ($action=='setref_supplier')

View File

@ -0,0 +1,133 @@
<?php
/* Copyright (C) 2017 Laurent Destailleur <eldy@users.sourceforge.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* or see http://www.gnu.org/
*/
/**
* \file htdocs/core/actions_addupdatedelete.inc.php
* \brief Code for common actions cancel / add / update / delete
*/
// $action or $cancel must be defined
// $object must be defined
// $permissiontoadd must be defined
// $permissiontodelete must be defined
// $backurlforlist must be defined
// $backtopage may be defined
if ($cancel)
{
if (! empty($backtopage))
{
header("Location: ".$backtopage);
exit;
}
$action='';
}
// Action to add record
if ($action == 'add' && ! empty($permissiontoadd))
{
foreach ($object->fields as $key => $val)
{
if (in_array($key, array('rowid', 'entity', 'date_creation', 'tms', 'fk_user_creat', 'fk_user_modif', 'import_key'))) continue; // Ignore special fields
$object->$key=GETPOST($key,'alpha');
if ($val['notnull'] > 0 && $object->$key == '')
{
$error++;
setEventMessages($langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv($val['label'])), null, 'errors');
}
}
if (! $error)
{
$result=$object->createCommon($user);
if ($result > 0)
{
// Creation OK
$urltogo=$backtopage?$backtopage:$backurlforlist;
header("Location: ".$urltogo);
exit;
}
else
{
// Creation KO
if (! empty($object->errors)) setEventMessages(null, $object->errors, 'errors');
else setEventMessages($object->error, null, 'errors');
$action='create';
}
}
else
{
$action='create';
}
}
// Action to update record
if ($action == 'update' && ! empty($permissiontoadd))
{
foreach ($object->fields as $key => $val)
{
if (in_array($key, array('rowid', 'entity', 'date_creation', 'tms', 'fk_user_creat', 'fk_user_modif', 'import_key'))) continue; // Ignore special fields
$object->$key=GETPOST($key,'alpha');
if ($val['notnull'] > 0 && $object->$key == '')
{
$error++;
setEventMessages($langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv($val['label'])), null, 'errors');
}
}
if (! $error)
{
$result=$object->updateCommon($user);
if ($result > 0)
{
$action='view';
}
else
{
// Creation KO
if (! empty($object->errors)) setEventMessages(null, $object->errors, 'errors');
else setEventMessages($object->error, null, 'errors');
$action='edit';
}
}
else
{
$action='edit';
}
}
// Action to delete
if ($action == 'confirm_delete' && ! empty($permissiontodelete))
{
$result=$object->deleteCommon($user);
if ($result > 0)
{
// Delete OK
setEventMessages("RecordDeleted", null, 'mesgs');
header("Location: ".$backurlforlist);
exit;
}
else
{
if (! empty($object->errors)) setEventMessages(null, $object->errors, 'errors');
else setEventMessages($object->error, null, 'errors');
}
}

View File

@ -174,7 +174,7 @@ if ($action == 'add')
(GETPOST('alwayseditable', 'alpha')?1:0), (GETPOST('alwayseditable', 'alpha')?1:0),
(GETPOST('perms', 'alpha')?GETPOST('perms', 'alpha'):''), (GETPOST('perms', 'alpha')?GETPOST('perms', 'alpha'):''),
GETPOST('list', 'alpha'), // Same as visible -1=not visible by default in list, 1=visible, 0=not visible in list GETPOST('list', 'alpha'), // Same as visible -1=not visible by default in list, 1=visible, 0=not visible in list
(GETPOST('ishidden', 'alpha')?1:0), 0,
GETPOST('computed_value','alpha'), GETPOST('computed_value','alpha'),
(GETPOST('entitycurrentorall', 'alpha')?0:''), (GETPOST('entitycurrentorall', 'alpha')?0:''),
GETPOST('langfile', 'alpha') GETPOST('langfile', 'alpha')
@ -336,7 +336,7 @@ if ($action == 'update')
(GETPOST('alwayseditable', 'alpha')?1:0), (GETPOST('alwayseditable', 'alpha')?1:0),
(GETPOST('perms', 'alpha')?GETPOST('perms', 'alpha'):''), (GETPOST('perms', 'alpha')?GETPOST('perms', 'alpha'):''),
GETPOST('list', 'alpha'), // Same as visible -1=not visible by default in list, 1=visible, 0=not visible in list GETPOST('list', 'alpha'), // Same as visible -1=not visible by default in list, 1=visible, 0=not visible in list
(GETPOST('ishidden', 'alpha')?1:0), 0,
GETPOST('default_value','alpha'), GETPOST('default_value','alpha'),
GETPOST('computed_value','alpha'), GETPOST('computed_value','alpha'),
(GETPOST('entitycurrentorall', 'alpha')?0:''), (GETPOST('entitycurrentorall', 'alpha')?0:''),

View File

@ -4246,7 +4246,7 @@ abstract class CommonObject
/** /**
* Call trigger based on this instance. * Call trigger based on this instance.
* Some context information may also be provided into array property this->context. * Some context information may also be provided into array property this->context.
* NB: Error from trigger are stacked in interface->errors * NB: Error from trigger are stacked in interface->errors
* NB2: If return code of triggers are < 0, action calling trigger should cancel all transaction. * NB2: If return code of triggers are < 0, action calling trigger should cancel all transaction.
* *
* @param string $trigger_name trigger's name to execute * @param string $trigger_name trigger's name to execute
@ -4399,11 +4399,15 @@ abstract class CommonObject
* Data to describe values to insert/update are stored into $this->array_options=array('options_codeforfield1'=>'valueforfield1', 'options_codeforfield2'=>'valueforfield2', ...) * Data to describe values to insert/update are stored into $this->array_options=array('options_codeforfield1'=>'valueforfield1', 'options_codeforfield2'=>'valueforfield2', ...)
* This function delete record with all extrafields and insert them again from the array $this->array_options. * This function delete record with all extrafields and insert them again from the array $this->array_options.
* *
* @return int -1=error, O=did nothing, 1=OK * @param string $trigger If defined, call also the trigger (for example COMPANY_MODIFY)
* @param User $userused Object user
* @return int -1=error, O=did nothing, 1=OK
*/ */
function insertExtraFields() function insertExtraFields($trigger='',$userused=null)
{ {
global $conf,$langs; global $conf,$langs,$user;
if (empty($userused)) $userused=$user;
$error=0; $error=0;
@ -4529,6 +4533,22 @@ abstract class CommonObject
if (! $resql) if (! $resql)
{ {
$this->error=$this->db->lasterror(); $this->error=$this->db->lasterror();
$error++;
}
else
{
if ($trigger)
{
// Call trigger
$this->context=array('extrafieldaddupdate'=>1);
$result=$this->call_trigger($trigger, $userused);
if ($result < 0) $error++;
// End call trigger
}
}
if ($error)
{
$this->db->rollback(); $this->db->rollback();
return -1; return -1;
} }
@ -4631,14 +4651,572 @@ abstract class CommonObject
else return 0; else return 0;
} }
/**
* Return HTML string to put an input field into a page
* Code very similar with showInputField of extra fields
*
* @param array $val Array of properties for field to show
* @param string $key Key of attribute
* @param string $value Preselected value to show (for date type it must be in timestamp format, for amount or price it must be a php numeric value)
* @param string $moreparam To add more parametes on html input tag
* @param string $keysuffix Prefix string to add into name and id of field (can be used to avoid duplicate names)
* @param string $keyprefix Suffix string to add into name and id of field (can be used to avoid duplicate names)
* @param mixed $showsize Value for css to define size. May also be a numeric.
* @param int $objectid Current object id
* @return string
*/
function showInputField($val, $key, $value, $moreparam='', $keysuffix='', $keyprefix='', $showsize=0, $objectid=0)
{
global $conf,$langs;
$label=$val['label'];
$type =$val['type'];
$size =$val['css'];
// Convert var to be able to share same code than showInputField of extrafields
if (preg_match('/varchar/', $type)) $type = 'varchar'; // convert varchar(xx) int varchar
if (is_array($val['arrayofkeyval'])) $type='select';
if (preg_match('/^integer:(.*):(.*)/i', $val['type'], $reg)) $type='link';
//$elementtype=$this->attribute_elementtype[$key]; // seems to not be used
$default=$val['default'];
$computed=$val['computed'];
$unique=$val['unique'];
$required=$val['required'];
$param=$val['param'];
if (is_array($val['arrayofkeyval'])) $param['options'] = $val['arrayofkeyval'];
if (preg_match('/^integer:(.*):(.*)/i', $val['type'], $reg))
{
$type='link';
$param['options']=array($reg[1].':'.$reg[2]=>$reg[1].':'.$reg[2]);
}
$langfile=$val['langfile'];
$list=$val['list'];
$hidden=(abs($val['visible'])!=1 ? 1 : 0);
$help=$val['help'];
if ($computed)
{
if (! preg_match('/^search_/', $keyprefix)) return '<span class="opacitymedium">'.$langs->trans("AutomaticallyCalculated").'</span>';
else return '';
}
if (empty($showsize))
{
if ($type == 'date')
{
//$showsize=10;
$showsize = 'minwidth100imp';
}
elseif ($type == 'datetime')
{
//$showsize=19;
$showsize = 'minwidth200imp';
}
elseif (in_array($type,array('int','double','price')))
{
//$showsize=10;
$showsize = 'maxwidth75';
}
elseif ($type == 'url')
{
$showsize='minwidth400';
}
elseif ($type == 'boolean')
{
$showsize='';
}
else
{
if (round($size) < 12)
{
$showsize = 'minwidth100';
}
else if (round($size) <= 48)
{
$showsize = 'minwidth200';
}
else
{
//$showsize=48;
$showsize = 'minwidth400';
}
}
}
if (in_array($type,array('date','datetime')))
{
$tmp=explode(',',$size);
$newsize=$tmp[0];
$showtime = in_array($type,array('datetime')) ? 1 : 0;
// Do not show current date when field not required (see select_date() method)
if (!$required && $value == '') $value = '-1';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php';
global $form;
if (! is_object($form)) $form=new Form($this->db);
// TODO Must also support $moreparam
$out = $form->select_date($value, $keyprefix.$key.$keysuffix, $showtime, $showtime, $required, '', 1, ($keyprefix != 'search_' ? 1 : 0), 1, 0, 1);
}
elseif (in_array($type,array('int','integer')))
{
$tmp=explode(',',$size);
$newsize=$tmp[0];
$out='<input type="text" class="flat '.$showsize.' maxwidthonsmartphone" name="'.$keyprefix.$key.$keysuffix.'" id="'.$keyprefix.$key.$keysuffix.'" maxlength="'.$newsize.'" value="'.$value.'"'.($moreparam?$moreparam:'').'>';
}
elseif (preg_match('/varchar/', $type))
{
$out='<input type="text" class="flat '.$showsize.' maxwidthonsmartphone" name="'.$keyprefix.$key.$keysuffix.'" id="'.$keyprefix.$key.$keysuffix.'" maxlength="'.$size.'" value="'.dol_escape_htmltag($value).'"'.($moreparam?$moreparam:'').'>';
}
elseif (in_array($type, array('mail', 'phone', 'url')))
{
$out='<input type="text" class="flat '.$showsize.' maxwidthonsmartphone" name="'.$keyprefix.$key.$keysuffix.'" id="'.$keyprefix.$key.$keysuffix.'" value="'.$value.'" '.($moreparam?$moreparam:'').'>';
}
elseif ($type == 'text')
{
require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
$doleditor=new DolEditor($keyprefix.$key.$keysuffix,$value,'',200,'dolibarr_notes','In',false,false,! empty($conf->fckeditor->enabled) && $conf->global->FCKEDITOR_ENABLE_SOCIETE,ROWS_5,'90%');
$out=$doleditor->Create(1);
}
elseif ($type == 'boolean')
{
$checked='';
if (!empty($value)) {
$checked=' checked value="1" ';
} else {
$checked=' value="1" ';
}
$out='<input type="checkbox" class="flat '.$showsize.' maxwidthonsmartphone" name="'.$keyprefix.$key.$keysuffix.'" id="'.$keyprefix.$key.$keysuffix.'" '.$checked.' '.($moreparam?$moreparam:'').'>';
}
elseif ($type == 'price')
{
if (!empty($value)) { // $value in memory is a php numeric, we format it into user number format.
$value=price($value);
}
$out='<input type="text" class="flat '.$showsize.' maxwidthonsmartphone" name="'.$keyprefix.$key.$keysuffix.'" id="'.$keyprefix.$key.$keysuffix.'" value="'.$value.'" '.($moreparam?$moreparam:'').'> '.$langs->getCurrencySymbol($conf->currency);
}
elseif ($type == 'double')
{
if (!empty($value)) { // $value in memory is a php numeric, we format it into user number format.
$value=price($value);
}
$out='<input type="text" class="flat '.$showsize.' maxwidthonsmartphone" name="'.$keyprefix.$key.$keysuffix.'" id="'.$keyprefix.$key.$keysuffix.'" value="'.$value.'" '.($moreparam?$moreparam:'').'> ';
}
elseif ($type == 'select')
{
$out = '';
if (! empty($conf->use_javascript_ajax) && ! empty($conf->global->MAIN_EXTRAFIELDS_USE_SELECT2))
{
include_once DOL_DOCUMENT_ROOT . '/core/lib/ajax.lib.php';
$out.= ajax_combobox($keyprefix.$key.$keysuffix, array(), 0);
}
$out.='<select class="flat '.$showsize.' maxwidthonsmartphone" name="'.$keyprefix.$key.$keysuffix.'" id="'.$keyprefix.$key.$keysuffix.'" '.($moreparam?$moreparam:'').'>';
$out.='<option value="0">&nbsp;</option>';
foreach ($param['options'] as $key => $val)
{
if ((string) $key == '') continue;
list($val, $parent) = explode('|', $val);
$out.='<option value="'.$key.'"';
$out.= (((string) $value == (string) $key)?' selected':'');
$out.= (!empty($parent)?' parent="'.$parent.'"':'');
$out.='>'.$val.'</option>';
}
$out.='</select>';
}
elseif ($type == 'sellist')
{
$out = '';
if (! empty($conf->use_javascript_ajax) && ! empty($conf->global->MAIN_EXTRAFIELDS_USE_SELECT2))
{
include_once DOL_DOCUMENT_ROOT . '/core/lib/ajax.lib.php';
$out.= ajax_combobox($keyprefix.$key.$keysuffix, array(), 0);
}
$out.='<select class="flat '.$showsize.' maxwidthonsmartphone" name="'.$keyprefix.$key.$keysuffix.'" id="'.$keyprefix.$key.$keysuffix.'" '.($moreparam?$moreparam:'').'>';
if (is_array($param['options']))
{
$param_list=array_keys($param['options']);
$InfoFieldList = explode(":", $param_list[0]);
// 0 : tableName
// 1 : label field name
// 2 : key fields name (if differ of rowid)
// 3 : key field parent (for dependent lists)
// 4 : where clause filter on column or table extrafield, syntax field='value' or extra.field=value
$keyList=(empty($InfoFieldList[2])?'rowid':$InfoFieldList[2].' as rowid');
if (count($InfoFieldList) > 4 && ! empty($InfoFieldList[4]))
{
if (strpos($InfoFieldList[4], 'extra.') !== false)
{
$keyList='main.'.$InfoFieldList[2].' as rowid';
} else {
$keyList=$InfoFieldList[2].' as rowid';
}
}
if (count($InfoFieldList) > 3 && ! empty($InfoFieldList[3]))
{
list($parentName, $parentField) = explode('|', $InfoFieldList[3]);
$keyList.= ', '.$parentField;
}
$fields_label = explode('|',$InfoFieldList[1]);
if (is_array($fields_label))
{
$keyList .=', ';
$keyList .= implode(', ', $fields_label);
}
$sqlwhere='';
$sql = 'SELECT '.$keyList;
$sql.= ' FROM '.MAIN_DB_PREFIX .$InfoFieldList[0];
if (!empty($InfoFieldList[4]))
{
// can use SELECT request
if (strpos($InfoFieldList[4], '$SEL$')!==false) {
$InfoFieldList[4]=str_replace('$SEL$','SELECT',$InfoFieldList[4]);
}
// current object id can be use into filter
if (strpos($InfoFieldList[4], '$ID$')!==false && !empty($objectid)) {
$InfoFieldList[4]=str_replace('$ID$',$objectid,$InfoFieldList[4]);
} else {
$InfoFieldList[4]=str_replace('$ID$','0',$InfoFieldList[4]);
}
//We have to join on extrafield table
if (strpos($InfoFieldList[4], 'extra')!==false)
{
$sql.= ' as main, '.MAIN_DB_PREFIX .$InfoFieldList[0].'_extrafields as extra';
$sqlwhere.= ' WHERE extra.fk_object=main.'.$InfoFieldList[2]. ' AND '.$InfoFieldList[4];
}
else
{
$sqlwhere.= ' WHERE '.$InfoFieldList[4];
}
}
else
{
$sqlwhere.= ' WHERE 1=1';
}
// Some tables may have field, some other not. For the moment we disable it.
if (in_array($InfoFieldList[0],array('tablewithentity')))
{
$sqlwhere.= ' AND entity = '.$conf->entity;
}
$sql.=$sqlwhere;
//print $sql;
$sql .= ' ORDER BY ' . implode(', ', $fields_label);
dol_syslog(get_class($this).'::showInputField type=sellist', LOG_DEBUG);
$resql = $this->db->query($sql);
if ($resql)
{
$out.='<option value="0">&nbsp;</option>';
$num = $this->db->num_rows($resql);
$i = 0;
while ($i < $num)
{
$labeltoshow='';
$obj = $this->db->fetch_object($resql);
// Several field into label (eq table:code|libelle:rowid)
$fields_label = explode('|',$InfoFieldList[1]);
if(is_array($fields_label))
{
$notrans = true;
foreach ($fields_label as $field_toshow)
{
$labeltoshow.= $obj->$field_toshow.' ';
}
}
else
{
$labeltoshow=$obj->{$InfoFieldList[1]};
}
$labeltoshow=dol_trunc($labeltoshow,45);
if ($value==$obj->rowid)
{
foreach ($fields_label as $field_toshow)
{
$translabel=$langs->trans($obj->$field_toshow);
if ($translabel!=$obj->$field_toshow) {
$labeltoshow=dol_trunc($translabel,18).' ';
}else {
$labeltoshow=dol_trunc($obj->$field_toshow,18).' ';
}
}
$out.='<option value="'.$obj->rowid.'" selected>'.$labeltoshow.'</option>';
}
else
{
if(!$notrans)
{
$translabel=$langs->trans($obj->{$InfoFieldList[1]});
if ($translabel!=$obj->{$InfoFieldList[1]}) {
$labeltoshow=dol_trunc($translabel,18);
}
else {
$labeltoshow=dol_trunc($obj->{$InfoFieldList[1]},18);
}
}
if (empty($labeltoshow)) $labeltoshow='(not defined)';
if ($value==$obj->rowid)
{
$out.='<option value="'.$obj->rowid.'" selected>'.$labeltoshow.'</option>';
}
if (!empty($InfoFieldList[3]))
{
$parent = $parentName.':'.$obj->{$parentField};
}
$out.='<option value="'.$obj->rowid.'"';
$out.= ($value==$obj->rowid?' selected':'');
$out.= (!empty($parent)?' parent="'.$parent.'"':'');
$out.='>'.$labeltoshow.'</option>';
}
$i++;
}
$this->db->free($resql);
}
else {
print 'Error in request '.$sql.' '.$this->db->lasterror().'. Check setup of extra parameters.<br>';
}
}
$out.='</select>';
}
elseif ($type == 'checkbox')
{
require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php';
$form = new Form($db);
$value_arr=explode(',',$value);
$out=$form->multiselectarray($keyprefix.$key.$keysuffix, (empty($param['options'])?null:$param['options']), $value_arr, '', 0, '', 0, '100%');
}
elseif ($type == 'radio')
{
$out='';
foreach ($param['options'] as $keyopt => $val)
{
$out.='<input class="flat '.$showsize.'" type="radio" name="'.$keyprefix.$key.$keysuffix.'" id="'.$keyprefix.$key.$keysuffix.'" '.($moreparam?$moreparam:'');
$out.=' value="'.$keyopt.'"';
$out.=' id="'.$keyprefix.$key.$keysuffix.'_'.$keyopt.'"';
$out.= ($value==$keyopt?'checked':'');
$out.='/><label for="'.$keyprefix.$key.$keysuffix.'_'.$keyopt.'">'.$val.'</label><br>';
}
}
elseif ($type == 'chkbxlst')
{
if (is_array($value)) {
$value_arr = $value;
}
else {
$value_arr = explode(',', $value);
}
if (is_array($param['options'])) {
$param_list = array_keys($param['options']);
$InfoFieldList = explode(":", $param_list[0]);
// 0 : tableName
// 1 : label field name
// 2 : key fields name (if differ of rowid)
// 3 : key field parent (for dependent lists)
// 4 : where clause filter on column or table extrafield, syntax field='value' or extra.field=value
$keyList = (empty($InfoFieldList[2]) ? 'rowid' : $InfoFieldList[2] . ' as rowid');
if (count($InfoFieldList) > 3 && ! empty($InfoFieldList[3])) {
list ( $parentName, $parentField ) = explode('|', $InfoFieldList[3]);
$keyList .= ', ' . $parentField;
}
if (count($InfoFieldList) > 4 && ! empty($InfoFieldList[4])) {
if (strpos($InfoFieldList[4], 'extra.') !== false) {
$keyList = 'main.' . $InfoFieldList[2] . ' as rowid';
} else {
$keyList = $InfoFieldList[2] . ' as rowid';
}
}
$fields_label = explode('|', $InfoFieldList[1]);
if (is_array($fields_label)) {
$keyList .= ', ';
$keyList .= implode(', ', $fields_label);
}
$sqlwhere = '';
$sql = 'SELECT ' . $keyList;
$sql .= ' FROM ' . MAIN_DB_PREFIX . $InfoFieldList[0];
if (! empty($InfoFieldList[4])) {
// can use SELECT request
if (strpos($InfoFieldList[4], '$SEL$')!==false) {
$InfoFieldList[4]=str_replace('$SEL$','SELECT',$InfoFieldList[4]);
}
// current object id can be use into filter
if (strpos($InfoFieldList[4], '$ID$')!==false && !empty($objectid)) {
$InfoFieldList[4]=str_replace('$ID$',$objectid,$InfoFieldList[4]);
} else {
$InfoFieldList[4]=str_replace('$ID$','0',$InfoFieldList[4]);
}
// We have to join on extrafield table
if (strpos($InfoFieldList[4], 'extra') !== false) {
$sql .= ' as main, ' . MAIN_DB_PREFIX . $InfoFieldList[0] . '_extrafields as extra';
$sqlwhere .= ' WHERE extra.fk_object=main.' . $InfoFieldList[2] . ' AND ' . $InfoFieldList[4];
} else {
$sqlwhere .= ' WHERE ' . $InfoFieldList[4];
}
} else {
$sqlwhere .= ' WHERE 1=1';
}
// Some tables may have field, some other not. For the moment we disable it.
if (in_array($InfoFieldList[0], array ('tablewithentity')))
{
$sqlwhere .= ' AND entity = ' . $conf->entity;
}
// $sql.=preg_replace('/^ AND /','',$sqlwhere);
// print $sql;
$sql .= $sqlwhere;
dol_syslog(get_class($this) . '::showInputField type=chkbxlst',LOG_DEBUG);
$resql = $this->db->query($sql);
if ($resql) {
$num = $this->db->num_rows($resql);
$i = 0;
$data=array();
while ( $i < $num ) {
$labeltoshow = '';
$obj = $this->db->fetch_object($resql);
// Several field into label (eq table:code|libelle:rowid)
$fields_label = explode('|', $InfoFieldList[1]);
if (is_array($fields_label)) {
$notrans = true;
foreach ( $fields_label as $field_toshow ) {
$labeltoshow .= $obj->$field_toshow . ' ';
}
} else {
$labeltoshow = $obj->{$InfoFieldList[1]};
}
$labeltoshow = dol_trunc($labeltoshow, 45);
if (is_array($value_arr) && in_array($obj->rowid, $value_arr)) {
foreach ( $fields_label as $field_toshow ) {
$translabel = $langs->trans($obj->$field_toshow);
if ($translabel != $obj->$field_toshow) {
$labeltoshow = dol_trunc($translabel, 18) . ' ';
} else {
$labeltoshow = dol_trunc($obj->$field_toshow, 18) . ' ';
}
}
$data[$obj->rowid]=$labeltoshow;
} else {
if (! $notrans) {
$translabel = $langs->trans($obj->{$InfoFieldList[1]});
if ($translabel != $obj->{$InfoFieldList[1]}) {
$labeltoshow = dol_trunc($translabel, 18);
} else {
$labeltoshow = dol_trunc($obj->{$InfoFieldList[1]}, 18);
}
}
if (empty($labeltoshow))
$labeltoshow = '(not defined)';
if (is_array($value_arr) && in_array($obj->rowid, $value_arr)) {
$data[$obj->rowid]=$labeltoshow;
}
if (! empty($InfoFieldList[3])) {
$parent = $parentName . ':' . $obj->{$parentField};
}
$data[$obj->rowid]=$labeltoshow;
}
$i ++;
}
$this->db->free($resql);
require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php';
$form = new Form($db);
$out=$form->multiselectarray($keyprefix.$key.$keysuffix, $data, $value_arr, '', 0, '', 0, '100%');
} else {
print 'Error in request ' . $sql . ' ' . $this->db->lasterror() . '. Check setup of extra parameters.<br>';
}
}
$out .= '</select>';
}
elseif ($type == 'link')
{
$out='';
$param_list=array_keys($param['options']);
// 0 : ObjectName
// 1 : classPath
$InfoFieldList = explode(":", $param_list[0]);
dol_include_once($InfoFieldList[1]);
if ($InfoFieldList[0] && class_exists($InfoFieldList[0]))
{
$valuetoshow=$value;
if (!empty($value))
{
$object = new $InfoFieldList[0]($this->db);
$resfetch=$object->fetch($value);
if ($resfetch > 0)
{
$valuetoshow=$object->ref;
if ($object->element == 'societe') $valuetoshow=$object->name; // Special case for thirdparty because ->ref is not name but id (because name is not unique)
}
}
$out.='<input type="text" class="flat '.$showsize.'" name="'.$keyprefix.$key.$keysuffix.'" id="'.$keyprefix.$key.$keysuffix.'" value="'.$valuetoshow.'" >';
}
else
{
dol_syslog('Error bad setup of type for field '.$InfoFieldList, LOG_WARNING);
$out.='Error bad setup of type for field '.join(',', $InfoFieldList);
}
}
elseif ($type == 'password')
{
// If prefix is 'search_', field is used as a filter, we use a common text field.
$out='<input type="'.($keyprefix=='search_'?'text':'password').'" class="flat '.$showsize.'" name="'.$keyprefix.$key.$keysuffix.'" id="'.$keyprefix.$key.$keysuffix.'" value="'.$value.'" '.($moreparam?$moreparam:'').'>';
}
if (!empty($hidden)) {
$out='<input type="hidden" value="'.$value.'" name="'.$keyprefix.$key.$keysuffix.'" id="'.$keyprefix.$key.$keysuffix.'"/>';
}
/* Add comments
if ($type == 'date') $out.=' (YYYY-MM-DD)';
elseif ($type == 'datetime') $out.=' (YYYY-MM-DD HH:MM:SS)';
*/
return $out;
}
/** /**
* Function to show lines of extrafields with output datas * Function to show lines of extrafields with output datas
* *
* @param Extrafields $extrafields Extrafield Object * @param Extrafields $extrafields Extrafield Object
* @param string $mode Show output (view) or input (edit) for extrafield * @param string $mode Show output (view) or input (edit) for extrafield
* @param array $params Optional parameters * @param array $params Optional parameters
* @param string $keysuffix Suffix string to add into name and id of field (can be used to avoid duplicate names) * @param string $keysuffix Suffix string to add after name and id of field (can be used to avoid duplicate names)
* @param string $keyprefix Prefix string to add into name and id of field (can be used to avoid duplicate names) * @param string $keyprefix Prefix string to add before name and id of field (can be used to avoid duplicate names)
* *
* @return string * @return string
*/ */
@ -4657,6 +5235,9 @@ abstract class CommonObject
$e = 0; $e = 0;
foreach($extrafields->attribute_label as $key=>$label) foreach($extrafields->attribute_label as $key=>$label)
{ {
if (empty($extrafields->attribute_list[$key])) continue; // 0 = Never visible field
if (($mode == 'create' || $mode == 'edit') && abs($extrafields->attribute_list[$key]) != 1) continue; // <> -1 and <> 1 = not visible on forms, only on list
// Load language if required // Load language if required
if (! empty($extrafields->attributes[$this->table_element]['langfile'][$key])) $langs->load($extrafields->attributes[$this->table_element]['langfile'][$key]); if (! empty($extrafields->attributes[$this->table_element]['langfile'][$key])) $langs->load($extrafields->attributes[$this->table_element]['langfile'][$key]);

View File

@ -140,8 +140,8 @@ class ExtraFields
* @param array|string $param Params for field (ex for select list : array('options' => array(value'=>'label of option')) ) * @param array|string $param Params for field (ex for select list : array('options' => array(value'=>'label of option')) )
* @param int $alwayseditable Is attribute always editable regardless of the document status * @param int $alwayseditable Is attribute always editable regardless of the document status
* @param string $perms Permission to check * @param string $perms Permission to check
* @param int $list Into list view by default (-1, 0 or 1) * @param int $list Visibilty
* @param int $ishidden Is hidden extrafield (warning, do not rely on this. If your module need a hidden data, it must use its own table) * @param int $ishidden Deprecated. Us visibility instead.
* @param string $computed Computed value * @param string $computed Computed value
* @param string $entity Entity of extrafields * @param string $entity Entity of extrafields
* @param string $langfile Language file * @param string $langfile Language file
@ -279,8 +279,8 @@ class ExtraFields
* @param array|string $param Params for field (ex for select list : array('options' => array(value'=>'label of option')) ) * @param array|string $param Params for field (ex for select list : array('options' => array(value'=>'label of option')) )
* @param int $alwayseditable Is attribute always editable regardless of the document status * @param int $alwayseditable Is attribute always editable regardless of the document status
* @param string $perms Permission to check * @param string $perms Permission to check
* @param int $list Into list view by default (-1, 0 or 1) * @param int $list Visibily
* @param int $ishidden Is hidden extrafield (warning, do not rely on this. If your module need a hidden data, it must use its own table) * @param int $ishidden Deprecated. Use visibility instead.
* @param string $default Default value (in database. use the default_value feature for default value on screen). * @param string $default Default value (in database. use the default_value feature for default value on screen).
* @param string $computed Computed value * @param string $computed Computed value
* @param string $entity Entity of extrafields * @param string $entity Entity of extrafields
@ -328,7 +328,6 @@ class ExtraFields
$sql.= " perms,"; $sql.= " perms,";
$sql.= " langs,"; $sql.= " langs,";
$sql.= " list,"; $sql.= " list,";
$sql.= " ishidden,";
$sql.= " fielddefault,"; $sql.= " fielddefault,";
$sql.= " fieldcomputed,"; $sql.= " fieldcomputed,";
$sql.= " fk_user_author,"; $sql.= " fk_user_author,";
@ -349,7 +348,6 @@ class ExtraFields
$sql.= " ".($perms?"'".$this->db->escape($perms)."'":"null").","; $sql.= " ".($perms?"'".$this->db->escape($perms)."'":"null").",";
$sql.= " ".($langfile?"'".$this->db->escape($langfile)."'":"null").","; $sql.= " ".($langfile?"'".$this->db->escape($langfile)."'":"null").",";
$sql.= " ".$list.","; $sql.= " ".$list.",";
$sql.= " ".$ishidden.",";
$sql.= " ".($default?"'".$this->db->escape($default)."'":"null").","; $sql.= " ".($default?"'".$this->db->escape($default)."'":"null").",";
$sql.= " ".($computed?"'".$this->db->escape($computed)."'":"null").","; $sql.= " ".($computed?"'".$this->db->escape($computed)."'":"null").",";
$sql .= " " . $user->id . ","; $sql .= " " . $user->id . ",";
@ -483,8 +481,8 @@ class ExtraFields
* @param array $param Params for field (ex for select list : array('options' => array(value'=>'label of option')) ) * @param array $param Params for field (ex for select list : array('options' => array(value'=>'label of option')) )
* @param int $alwayseditable Is attribute always editable regardless of the document status * @param int $alwayseditable Is attribute always editable regardless of the document status
* @param string $perms Permission to check * @param string $perms Permission to check
* @param int $list Into list view by default * @param int $list Visibility
* @param int $ishidden Is hidden extrafield (warning, do not rely on this. If your module need a hidden data, it must use its own table) * @param int $ishidden Deprecated. Use visiblity instead.
* @param string $default Default value (in database. use the default_value feature for default value on screen). * @param string $default Default value (in database. use the default_value feature for default value on screen).
* @param string $computed Computed value * @param string $computed Computed value
* @param string $entity Entity of extrafields * @param string $entity Entity of extrafields
@ -589,8 +587,8 @@ class ExtraFields
* @param array $param Params for field (ex for select list : array('options' => array(value'=>'label of option')) ) * @param array $param Params for field (ex for select list : array('options' => array(value'=>'label of option')) )
* @param int $alwayseditable Is attribute always editable regardless of the document status * @param int $alwayseditable Is attribute always editable regardless of the document status
* @param string $perms Permission to check * @param string $perms Permission to check
* @param int $list Into list view by default * @param int $list Visiblity
* @param int $ishidden Is hidden extrafield (warning, do not rely on this. If your module need a hidden data, it must use its own table) * @param int $ishidden Deprecated. Use visility instead.
* @param string $default Default value (in database. use the default_value feature for default value on screen). * @param string $default Default value (in database. use the default_value feature for default value on screen).
* @param string $computed Computed value * @param string $computed Computed value
* @param string $entity Entity of extrafields * @param string $entity Entity of extrafields
@ -639,7 +637,6 @@ class ExtraFields
$sql.= " alwayseditable,"; $sql.= " alwayseditable,";
$sql.= " param,"; $sql.= " param,";
$sql.= " list,"; $sql.= " list,";
$sql.= " ishidden,";
$sql.= " fielddefault,"; $sql.= " fielddefault,";
$sql.= " fieldcomputed,"; $sql.= " fieldcomputed,";
$sql.= " fk_user_author,"; $sql.= " fk_user_author,";
@ -660,7 +657,6 @@ class ExtraFields
$sql.= " '".$alwayseditable."',"; $sql.= " '".$alwayseditable."',";
$sql.= " '".$param."',"; $sql.= " '".$param."',";
$sql.= " ".$list.", "; $sql.= " ".$list.", ";
$sql.= " ".$ishidden.", ";
$sql.= " ".(($default!='')?"'".$this->db->escape($default)."'":"null").","; $sql.= " ".(($default!='')?"'".$this->db->escape($default)."'":"null").",";
$sql.= " ".($computed?"'".$this->db->escape($computed)."'":"null").","; $sql.= " ".($computed?"'".$this->db->escape($computed)."'":"null").",";
$sql .= " " . $user->id . ","; $sql .= " " . $user->id . ",";
@ -714,7 +710,7 @@ class ExtraFields
// We should not have several time this log. If we have, there is some optimization to do by calling a simple $object->fetch_optionals() that include cache management. // We should not have several time this log. If we have, there is some optimization to do by calling a simple $object->fetch_optionals() that include cache management.
dol_syslog("fetch_name_optionals_label elementtype=".$elementtype); dol_syslog("fetch_name_optionals_label elementtype=".$elementtype);
$sql = "SELECT rowid,name,label,type,size,elementtype,fieldunique,fieldrequired,param,pos,alwayseditable,perms,langs,list,ishidden,fielddefault,fieldcomputed"; $sql = "SELECT rowid,name,label,type,size,elementtype,fieldunique,fieldrequired,param,pos,alwayseditable,perms,langs,list,fielddefault,fieldcomputed";
$sql .= ",entity"; $sql .= ",entity";
$sql.= " FROM ".MAIN_DB_PREFIX."extrafields"; $sql.= " FROM ".MAIN_DB_PREFIX."extrafields";
$sql.= " WHERE entity IN (0,".$conf->entity.")"; $sql.= " WHERE entity IN (0,".$conf->entity.")";
@ -749,7 +745,6 @@ class ExtraFields
$this->attribute_perms[$tab->name]=$tab->perms; $this->attribute_perms[$tab->name]=$tab->perms;
$this->attribute_langfile[$tab->name]=$tab->langs; $this->attribute_langfile[$tab->name]=$tab->langs;
$this->attribute_list[$tab->name]=$tab->list; $this->attribute_list[$tab->name]=$tab->list;
$this->attribute_hidden[$tab->name]=$tab->ishidden;
$this->attribute_entityid[$tab->name]=$tab->entity; $this->attribute_entityid[$tab->name]=$tab->entity;
// New usage // New usage
@ -767,7 +762,6 @@ class ExtraFields
$this->attributes[$tab->elementtype]['perms'][$tab->name]=$tab->perms; $this->attributes[$tab->elementtype]['perms'][$tab->name]=$tab->perms;
$this->attributes[$tab->elementtype]['langfile'][$tab->name]=$tab->langs; $this->attributes[$tab->elementtype]['langfile'][$tab->name]=$tab->langs;
$this->attributes[$tab->elementtype]['list'][$tab->name]=$tab->list; $this->attributes[$tab->elementtype]['list'][$tab->name]=$tab->list;
$this->attributes[$tab->elementtype]['ishidden'][$tab->name]=$tab->ishidden;
$this->attributes[$tab->elementtype]['entityid'][$tab->name]=$tab->entity; $this->attributes[$tab->elementtype]['entityid'][$tab->name]=$tab->entity;
if (!empty($conf->multicompany->enabled)) if (!empty($conf->multicompany->enabled))
@ -802,12 +796,13 @@ class ExtraFields
/** /**
* Return HTML string to put an input field into a page * Return HTML string to put an input field into a page
* Code very similar with showInputField of common object
* *
* @param string $key Key of attribute * @param string $key Key of attribute
* @param string $value Preselected value to show (for date type it must be in timestamp format, for amount or price it must be a php numeric value) * @param string $value Preselected value to show (for date type it must be in timestamp format, for amount or price it must be a php numeric value)
* @param string $moreparam To add more parametes on html input tag * @param string $moreparam To add more parametes on html input tag
* @param string $keysuffix Prefix string to add into name and id of field (can be used to avoid duplicate names) * @param string $keysuffix Prefix string to add after name and id of field (can be used to avoid duplicate names)
* @param string $keyprefix Suffix string to add into name and id of field (can be used to avoid duplicate names) * @param string $keyprefix Suffix string to add before name and id of field (can be used to avoid duplicate names)
* @param mixed $showsize Value for css to define size. May also be a numeric. * @param mixed $showsize Value for css to define size. May also be a numeric.
* @param int $objectid Current object id * @param int $objectid Current object id
* @return string * @return string
@ -816,10 +811,12 @@ class ExtraFields
{ {
global $conf,$langs; global $conf,$langs;
$keyprefix = $keyprefix.'options_'; // Because we work on extrafields
$label=$this->attribute_label[$key]; $label=$this->attribute_label[$key];
$type =$this->attribute_type[$key]; $type =$this->attribute_type[$key];
$size =$this->attribute_size[$key]; $size =$this->attribute_size[$key];
$elementtype=$this->attribute_elementtype[$key]; $elementtype=$this->attribute_elementtype[$key]; // Seems not used
$default=$this->attribute_default[$key]; $default=$this->attribute_default[$key];
$computed=$this->attribute_computed[$key]; $computed=$this->attribute_computed[$key];
$unique=$this->attribute_unique[$key]; $unique=$this->attribute_unique[$key];
@ -831,7 +828,7 @@ class ExtraFields
if ($computed) if ($computed)
{ {
if ($keyprefix != 'search_') return '<span class="opacitymedium">'.$langs->trans("AutomaticallyCalculated").'</span>'; if (! preg_match('/^search_/', $keyprefix)) return '<span class="opacitymedium">'.$langs->trans("AutomaticallyCalculated").'</span>';
else return ''; else return '';
} }
@ -847,7 +844,7 @@ class ExtraFields
//$showsize=19; //$showsize=19;
$showsize = 'minwidth200imp'; $showsize = 'minwidth200imp';
} }
elseif (in_array($type,array('int','double','price'))) elseif (in_array($type,array('int','integer','double','price')))
{ {
//$showsize=10; //$showsize=10;
$showsize = 'maxwidth75'; $showsize = 'maxwidth75';
@ -893,26 +890,26 @@ class ExtraFields
if (! is_object($form)) $form=new Form($this->db); if (! is_object($form)) $form=new Form($this->db);
// TODO Must also support $moreparam // TODO Must also support $moreparam
$out = $form->select_date($value, $keyprefix.'options_'.$key.$keysuffix, $showtime, $showtime, $required, '', 1, ($keyprefix != 'search_' ? 1 : 0), 1, 0, 1); $out = $form->select_date($value, $keyprefix.$key.$keysuffix, $showtime, $showtime, $required, '', 1, ($keyprefix != 'search_' ? 1 : 0), 1, 0, 1);
} }
elseif (in_array($type,array('int'))) elseif (in_array($type,array('int','integer')))
{ {
$tmp=explode(',',$size); $tmp=explode(',',$size);
$newsize=$tmp[0]; $newsize=$tmp[0];
$out='<input type="text" class="flat '.$showsize.' maxwidthonsmartphone" name="'.$keyprefix.'options_'.$key.$keysuffix.'" id="'.$keyprefix.'options_'.$key.$keysuffix.'" maxlength="'.$newsize.'" value="'.$value.'"'.($moreparam?$moreparam:'').'>'; $out='<input type="text" class="flat '.$showsize.' maxwidthonsmartphone" name="'.$keyprefix.$key.$keysuffix.'" id="'.$keyprefix.$key.$keysuffix.'" maxlength="'.$newsize.'" value="'.$value.'"'.($moreparam?$moreparam:'').'>';
} }
elseif ($type == 'varchar') elseif (preg_match('/varchar/', $type))
{ {
$out='<input type="text" class="flat '.$showsize.' maxwidthonsmartphone" name="'.$keyprefix.'options_'.$key.$keysuffix.'" id="'.$keyprefix.'options_'.$key.$keysuffix.'" maxlength="'.$size.'" value="'.dol_escape_htmltag($value).'"'.($moreparam?$moreparam:'').'>'; $out='<input type="text" class="flat '.$showsize.' maxwidthonsmartphone" name="'.$keyprefix.$key.$keysuffix.'" id="'.$keyprefix.$key.$keysuffix.'" maxlength="'.$size.'" value="'.dol_escape_htmltag($value).'"'.($moreparam?$moreparam:'').'>';
} }
elseif (in_array($type, array('mail', 'phone', 'url'))) elseif (in_array($type, array('mail', 'phone', 'url')))
{ {
$out='<input type="text" class="flat '.$showsize.' maxwidthonsmartphone" name="'.$keyprefix.'options_'.$key.$keysuffix.'" id="'.$keyprefix.'options_'.$key.$keysuffix.'" value="'.$value.'" '.($moreparam?$moreparam:'').'>'; $out='<input type="text" class="flat '.$showsize.' maxwidthonsmartphone" name="'.$keyprefix.$key.$keysuffix.'" id="'.$keyprefix.$key.$keysuffix.'" value="'.$value.'" '.($moreparam?$moreparam:'').'>';
} }
elseif ($type == 'text') elseif ($type == 'text')
{ {
require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
$doleditor=new DolEditor($keyprefix.'options_'.$key.$keysuffix,$value,'',200,'dolibarr_notes','In',false,false,! empty($conf->fckeditor->enabled) && $conf->global->FCKEDITOR_ENABLE_SOCIETE,ROWS_5,'90%'); $doleditor=new DolEditor($keyprefix.$key.$keysuffix,$value,'',200,'dolibarr_notes','In',false,false,! empty($conf->fckeditor->enabled) && $conf->global->FCKEDITOR_ENABLE_SOCIETE,ROWS_5,'90%');
$out=$doleditor->Create(1); $out=$doleditor->Create(1);
} }
elseif ($type == 'boolean') elseif ($type == 'boolean')
@ -923,21 +920,21 @@ class ExtraFields
} else { } else {
$checked=' value="1" '; $checked=' value="1" ';
} }
$out='<input type="checkbox" class="flat '.$showsize.' maxwidthonsmartphone" name="'.$keyprefix.'options_'.$key.$keysuffix.'" id="'.$keyprefix.'options_'.$key.$keysuffix.'" '.$checked.' '.($moreparam?$moreparam:'').'>'; $out='<input type="checkbox" class="flat '.$showsize.' maxwidthonsmartphone" name="'.$keyprefix.$key.$keysuffix.'" id="'.$keyprefix.$key.$keysuffix.'" '.$checked.' '.($moreparam?$moreparam:'').'>';
} }
elseif ($type == 'price') elseif ($type == 'price')
{ {
if (!empty($value)) { // $value in memory is a php numeric, we format it into user number format. if (!empty($value)) { // $value in memory is a php numeric, we format it into user number format.
$value=price($value); $value=price($value);
} }
$out='<input type="text" class="flat '.$showsize.' maxwidthonsmartphone" name="'.$keyprefix.'options_'.$key.$keysuffix.'" id="'.$keyprefix.'options_'.$key.$keysuffix.'" value="'.$value.'" '.($moreparam?$moreparam:'').'> '.$langs->getCurrencySymbol($conf->currency); $out='<input type="text" class="flat '.$showsize.' maxwidthonsmartphone" name="'.$keyprefix.$key.$keysuffix.'" id="'.$keyprefix.$key.$keysuffix.'" value="'.$value.'" '.($moreparam?$moreparam:'').'> '.$langs->getCurrencySymbol($conf->currency);
} }
elseif ($type == 'double') elseif ($type == 'double')
{ {
if (!empty($value)) { // $value in memory is a php numeric, we format it into user number format. if (!empty($value)) { // $value in memory is a php numeric, we format it into user number format.
$value=price($value); $value=price($value);
} }
$out='<input type="text" class="flat '.$showsize.' maxwidthonsmartphone" name="'.$keyprefix.'options_'.$key.$keysuffix.'" id="'.$keyprefix.'options_'.$key.$keysuffix.'" value="'.$value.'" '.($moreparam?$moreparam:'').'> '; $out='<input type="text" class="flat '.$showsize.' maxwidthonsmartphone" name="'.$keyprefix.$key.$keysuffix.'" id="'.$keyprefix.$key.$keysuffix.'" value="'.$value.'" '.($moreparam?$moreparam:'').'> ';
} }
elseif ($type == 'select') elseif ($type == 'select')
{ {
@ -945,10 +942,10 @@ class ExtraFields
if (! empty($conf->use_javascript_ajax) && ! empty($conf->global->MAIN_EXTRAFIELDS_USE_SELECT2)) if (! empty($conf->use_javascript_ajax) && ! empty($conf->global->MAIN_EXTRAFIELDS_USE_SELECT2))
{ {
include_once DOL_DOCUMENT_ROOT . '/core/lib/ajax.lib.php'; include_once DOL_DOCUMENT_ROOT . '/core/lib/ajax.lib.php';
$out.= ajax_combobox($keyprefix.'options_'.$key.$keysuffix, array(), 0); $out.= ajax_combobox($keyprefix.$key.$keysuffix, array(), 0);
} }
$out.='<select class="flat '.$showsize.' maxwidthonsmartphone" name="'.$keyprefix.'options_'.$key.$keysuffix.'" id="'.$keyprefix.'options_'.$key.$keysuffix.'" '.($moreparam?$moreparam:'').'>'; $out.='<select class="flat '.$showsize.' maxwidthonsmartphone" name="'.$keyprefix.$key.$keysuffix.'" id="'.$keyprefix.$key.$keysuffix.'" '.($moreparam?$moreparam:'').'>';
$out.='<option value="0">&nbsp;</option>'; $out.='<option value="0">&nbsp;</option>';
foreach ($param['options'] as $key => $val) foreach ($param['options'] as $key => $val)
{ {
@ -967,10 +964,10 @@ class ExtraFields
if (! empty($conf->use_javascript_ajax) && ! empty($conf->global->MAIN_EXTRAFIELDS_USE_SELECT2)) if (! empty($conf->use_javascript_ajax) && ! empty($conf->global->MAIN_EXTRAFIELDS_USE_SELECT2))
{ {
include_once DOL_DOCUMENT_ROOT . '/core/lib/ajax.lib.php'; include_once DOL_DOCUMENT_ROOT . '/core/lib/ajax.lib.php';
$out.= ajax_combobox($keyprefix.'options_'.$key.$keysuffix, array(), 0); $out.= ajax_combobox($keyprefix.$key.$keysuffix, array(), 0);
} }
$out.='<select class="flat '.$showsize.' maxwidthonsmartphone" name="'.$keyprefix.'options_'.$key.$keysuffix.'" id="'.$keyprefix.'options_'.$key.$keysuffix.'" '.($moreparam?$moreparam:'').'>'; $out.='<select class="flat '.$showsize.' maxwidthonsmartphone" name="'.$keyprefix.$key.$keysuffix.'" id="'.$keyprefix.$key.$keysuffix.'" '.($moreparam?$moreparam:'').'>';
if (is_array($param['options'])) if (is_array($param['options']))
{ {
$param_list=array_keys($param['options']); $param_list=array_keys($param['options']);
@ -1132,7 +1129,7 @@ class ExtraFields
$form = new Form($db); $form = new Form($db);
$value_arr=explode(',',$value); $value_arr=explode(',',$value);
$out=$form->multiselectarray($keyprefix.'options_'.$key.$keysuffix, (empty($param['options'])?null:$param['options']), $value_arr, '', 0, '', 0, '100%'); $out=$form->multiselectarray($keyprefix.$key.$keysuffix, (empty($param['options'])?null:$param['options']), $value_arr, '', 0, '', 0, '100%');
} }
elseif ($type == 'radio') elseif ($type == 'radio')
@ -1140,11 +1137,11 @@ class ExtraFields
$out=''; $out='';
foreach ($param['options'] as $keyopt => $val) foreach ($param['options'] as $keyopt => $val)
{ {
$out.='<input class="flat '.$showsize.'" type="radio" name="'.$keyprefix.'options_'.$key.$keysuffix.'" id="'.$keyprefix.'options_'.$key.$keysuffix.'" '.($moreparam?$moreparam:''); $out.='<input class="flat '.$showsize.'" type="radio" name="'.$keyprefix.$key.$keysuffix.'" id="'.$keyprefix.$key.$keysuffix.'" '.($moreparam?$moreparam:'');
$out.=' value="'.$keyopt.'"'; $out.=' value="'.$keyopt.'"';
$out.=' id="'.$keyprefix.'options_'.$key.$keysuffix.'_'.$keyopt.'"'; $out.=' id="'.$keyprefix.$key.$keysuffix.'_'.$keyopt.'"';
$out.= ($value==$keyopt?'checked':''); $out.= ($value==$keyopt?'checked':'');
$out.='/><label for="'.$keyprefix.'options_'.$key.$keysuffix.'_'.$keyopt.'">'.$val.'</label><br>'; $out.='/><label for="'.$keyprefix.$key.$keysuffix.'_'.$keyopt.'">'.$val.'</label><br>';
} }
} }
elseif ($type == 'chkbxlst') elseif ($type == 'chkbxlst')
@ -1286,7 +1283,7 @@ class ExtraFields
require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php';
$form = new Form($db); $form = new Form($db);
$out=$form->multiselectarray($keyprefix.'options_'.$key.$keysuffix, $data, $value_arr, '', 0, '', 0, '100%'); $out=$form->multiselectarray($keyprefix.$key.$keysuffix, $data, $value_arr, '', 0, '', 0, '100%');
} else { } else {
print 'Error in request ' . $sql . ' ' . $this->db->lasterror() . '. Check setup of extra parameters.<br>'; print 'Error in request ' . $sql . ' ' . $this->db->lasterror() . '. Check setup of extra parameters.<br>';
@ -1316,7 +1313,7 @@ class ExtraFields
if ($object->element == 'societe') $valuetoshow=$object->name; // Special case for thirdparty because ->ref is not name but id (because name is not unique) if ($object->element == 'societe') $valuetoshow=$object->name; // Special case for thirdparty because ->ref is not name but id (because name is not unique)
} }
} }
$out.='<input type="text" class="flat '.$showsize.'" name="'.$keyprefix.'options_'.$key.$keysuffix.'" id="'.$keyprefix.'options_'.$key.$keysuffix.'" value="'.$valuetoshow.'" >'; $out.='<input type="text" class="flat '.$showsize.'" name="'.$keyprefix.$key.$keysuffix.'" id="'.$keyprefix.$key.$keysuffix.'" value="'.$valuetoshow.'" >';
} }
else else
{ {
@ -1327,10 +1324,10 @@ class ExtraFields
elseif ($type == 'password') elseif ($type == 'password')
{ {
// If prefix is 'search_', field is used as a filter, we use a common text field. // If prefix is 'search_', field is used as a filter, we use a common text field.
$out='<input type="'.($keyprefix=='search_'?'text':'password').'" class="flat '.$showsize.'" name="'.$keyprefix.'options_'.$key.$keysuffix.'" id="'.$keyprefix.'options_'.$key.$keysuffix.'" value="'.$value.'" '.($moreparam?$moreparam:'').'>'; $out='<input type="'.($keyprefix=='search_'?'text':'password').'" class="flat '.$showsize.'" name="'.$keyprefix.$key.$keysuffix.'" id="'.$keyprefix.$key.$keysuffix.'" value="'.$value.'" '.($moreparam?$moreparam:'').'>';
} }
if (!empty($hidden)) { if (!empty($hidden)) {
$out='<input type="hidden" value="'.$value.'" name="'.$keyprefix.'options_'.$key.$keysuffix.'" id="'.$keyprefix.'options_'.$key.$keysuffix.'"/>'; $out='<input type="hidden" value="'.$value.'" name="'.$keyprefix.$key.$keysuffix.'" id="'.$keyprefix.$key.$keysuffix.'"/>';
} }
/* Add comments /* Add comments
if ($type == 'date') $out.=' (YYYY-MM-DD)'; if ($type == 'date') $out.=' (YYYY-MM-DD)';
@ -1352,7 +1349,7 @@ class ExtraFields
{ {
global $conf,$langs; global $conf,$langs;
$elementtype=$this->attribute_elementtype[$key]; $elementtype=$this->attribute_elementtype[$key]; // seems not used
$label=$this->attribute_label[$key]; $label=$this->attribute_label[$key];
$type=$this->attribute_type[$key]; $type=$this->attribute_type[$key];
$size=$this->attribute_size[$key]; $size=$this->attribute_size[$key];

View File

@ -504,7 +504,7 @@ class Form
global $conf, $langs; global $conf, $langs;
$alt = ''; $alt = '';
if ($tooltiptrigger) $alt=$langs->trans("ClickToShowHelp"); if ($tooltiptrigger) $alt=$langs->transnoentitiesnoconv("ClickToShowHelp");
//For backwards compatibility //For backwards compatibility
if ($type == '0') $type = 'info'; if ($type == '0') $type = 'info';

View File

@ -251,7 +251,11 @@ function rebuildObjectSql($destdir, $module, $objectname, $newmask, $readdir='',
foreach($object->fields as $key => $val) foreach($object->fields as $key => $val)
{ {
$i++; $i++;
$texttoinsert.= "\t".$key." ".$val['type'];
$type = $val['type'];
$type = preg_replace('/:.*$/', '', $type); // For case type = 'integer:Societe:societe/class/societe.class.php'
$texttoinsert.= "\t".$key." ".$type;
if ($key == 'rowid') $texttoinsert.= ' AUTO_INCREMENT PRIMARY KEY'; if ($key == 'rowid') $texttoinsert.= ' AUTO_INCREMENT PRIMARY KEY';
if ($key == 'entity') $texttoinsert.= ' DEFAULT 1'; if ($key == 'entity') $texttoinsert.= ' DEFAULT 1';
else else

View File

@ -209,9 +209,9 @@ insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, left
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->tax->enabled && empty($conf->global->TAX_DISABLE_VAT_MENUS) && $leftmenu=="tax_vat"', __HANDLER__, 'left', 2302__+MAX_llx_menu__, 'billing', '', 2300__+MAX_llx_menu__, '/compta/tva/reglement.php?leftmenu=tax_vat', 'List', 2, 'companies', '$user->rights->tax->charges->lire', '', 0, 1, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->tax->enabled && empty($conf->global->TAX_DISABLE_VAT_MENUS) && $leftmenu=="tax_vat"', __HANDLER__, 'left', 2302__+MAX_llx_menu__, 'billing', '', 2300__+MAX_llx_menu__, '/compta/tva/reglement.php?leftmenu=tax_vat', 'List', 2, 'companies', '$user->rights->tax->charges->lire', '', 0, 1, __ENTITY__);
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->tax->enabled && empty($conf->global->TAX_DISABLE_VAT_MENUS) && $leftmenu=="tax_vat"', __HANDLER__, 'left', 2303__+MAX_llx_menu__, 'billing', '', 2300__+MAX_llx_menu__, '/compta/tva/clients.php?leftmenu=tax_vat', 'ReportByCustomers', 2, 'companies', '$user->rights->tax->charges->lire', '', 0, 2, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->tax->enabled && empty($conf->global->TAX_DISABLE_VAT_MENUS) && $leftmenu=="tax_vat"', __HANDLER__, 'left', 2303__+MAX_llx_menu__, 'billing', '', 2300__+MAX_llx_menu__, '/compta/tva/clients.php?leftmenu=tax_vat', 'ReportByCustomers', 2, 'companies', '$user->rights->tax->charges->lire', '', 0, 2, __ENTITY__);
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->tax->enabled && empty($conf->global->TAX_DISABLE_VAT_MENUS) && $leftmenu=="tax_vat"', __HANDLER__, 'left', 2304__+MAX_llx_menu__, 'billing', '', 2300__+MAX_llx_menu__, '/compta/tva/quadri_detail.php?leftmenu=tax_vat', 'ReportByQuarter', 2, 'companies', '$user->rights->tax->charges->lire', '', 0, 3, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->tax->enabled && empty($conf->global->TAX_DISABLE_VAT_MENUS) && $leftmenu=="tax_vat"', __HANDLER__, 'left', 2304__+MAX_llx_menu__, 'billing', '', 2300__+MAX_llx_menu__, '/compta/tva/quadri_detail.php?leftmenu=tax_vat', 'ReportByQuarter', 2, 'companies', '$user->rights->tax->charges->lire', '', 0, 3, __ENTITY__);
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->banque->enabled', __HANDLER__, 'left', 2350__+MAX_llx_menu__, 'billing', 'tax_various', 2200__+MAX_llx_menu__, '/bank/various_payment/index.php?leftmenu=tax_various&amp;mainmenu=billing', 'MenuVariousPayment', 1, 'banks', '$user->rights->banque->lire', '', 0, 1, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->banque->enabled', __HANDLER__, 'left', 2350__+MAX_llx_menu__, 'billing', 'tax_various', 2200__+MAX_llx_menu__, '/compta/bank/various_payment/index.php?leftmenu=tax_various&amp;mainmenu=billing', 'MenuVariousPayment', 1, 'banks', '$user->rights->banque->lire', '', 0, 1, __ENTITY__);
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->banque->enabled && $leftmenu=="tax_various"', __HANDLER__, 'left', 2351__+MAX_llx_menu__, 'billing', '', 2350__+MAX_llx_menu__, '/bank/various_payment/card.php?leftmenu=tax_various&amp;action=create', 'MenuNewVariousPayment', 2, 'various_payment', '$user->rights->banque->modifier', '', 0, 2, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->banque->enabled && $leftmenu=="tax_various"', __HANDLER__, 'left', 2351__+MAX_llx_menu__, 'billing', '', 2350__+MAX_llx_menu__, '/compta/bank/various_payment/card.php?leftmenu=tax_various&amp;action=create', 'MenuNewVariousPayment', 2, 'various_payment', '$user->rights->banque->modifier', '', 0, 2, __ENTITY__);
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->banque->enabled && $leftmenu=="tax_various"', __HANDLER__, 'left', 2352__+MAX_llx_menu__, 'billing', '', 2350__+MAX_llx_menu__, '/bank/various_payment/index.php?leftmenu=tax_various', 'List', 2, 'various_payment', '$user->rights->banque->lire', '', 0, 3, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->banque->enabled && $leftmenu=="tax_various"', __HANDLER__, 'left', 2352__+MAX_llx_menu__, 'billing', '', 2350__+MAX_llx_menu__, '/compta/bank/various_payment/index.php?leftmenu=tax_various', 'List', 2, 'various_payment', '$user->rights->banque->lire', '', 0, 3, __ENTITY__);
-- Accounting Expert -- Accounting Expert
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled', __HANDLER__, 'left', 2400__+MAX_llx_menu__, 'accountancy', 'accountancy', 9__+MAX_llx_menu__, '/accountancy/index.php?leftmenu=accountancy', 'MenuAccountancy', 0, 'accountancy', '! empty($conf->accounting->enabled) || $user->rights->accounting->bind->write || $user->rights->accounting->bind->write || $user->rights->compta->resultat->lire', '', 0, 7, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled', __HANDLER__, 'left', 2400__+MAX_llx_menu__, 'accountancy', 'accountancy', 9__+MAX_llx_menu__, '/accountancy/index.php?leftmenu=accountancy', 'MenuAccountancy', 0, 'accountancy', '! empty($conf->accounting->enabled) || $user->rights->accounting->bind->write || $user->rights->accounting->bind->write || $user->rights->compta->resultat->lire', '', 0, 7, __ENTITY__);
-- Setup -- Setup

View File

@ -67,15 +67,15 @@ $langs->load("modulebuilder");
{ {
console.log("We enter a computed formula"); console.log("We enter a computed formula");
jQuery("#default_value").val(''); jQuery("#default_value").val('');
/* jQuery("#unique, #required, #alwayseditable, #ishidden, #list").removeAttr('checked'); */ /* jQuery("#unique, #required, #alwayseditable, #list").removeAttr('checked'); */
jQuery("#default_value, #unique, #required, #alwayseditable, #ishidden, #list").attr('disabled', true); jQuery("#default_value, #unique, #required, #alwayseditable, #list").attr('disabled', true);
jQuery("tr.extra_default_value, tr.extra_unique, tr.extra_required, tr.extra_alwayseditable, tr.extra_ishidden, tr.extra_list").hide(); jQuery("tr.extra_default_value, tr.extra_unique, tr.extra_required, tr.extra_alwayseditable, tr.extra_list").hide();
} }
else else
{ {
console.log("No computed formula"); console.log("No computed formula");
jQuery("#default_value, #unique, #required, #alwayseditable, #ishidden, #list").attr('disabled', false); jQuery("#default_value, #unique, #required, #alwayseditable, #list").attr('disabled', false);
jQuery("tr.extra_default_value, tr.extra_unique, tr.extra_required, tr.extra_alwayseditable, tr.extra_ishidden, tr.extra_list").show(); jQuery("tr.extra_default_value, tr.extra_unique, tr.extra_required, tr.extra_alwayseditable, tr.extra_list").show();
} }
if (type == 'date') { size.val('').prop('disabled', true); unique.removeAttr('disabled'); jQuery("#value_choice").hide();jQuery("#helpchkbxlst").hide(); } if (type == 'date') { size.val('').prop('disabled', true); unique.removeAttr('disabled'); jQuery("#value_choice").hide();jQuery("#helpchkbxlst").hide(); }
@ -151,10 +151,10 @@ $langs->load("modulebuilder");
<tr><td> <tr><td>
<textarea name="param" id="param" cols="80" rows="<?php echo ROWS_4 ?>"><?php echo GETPOST('param','alpha'); ?></textarea> <textarea name="param" id="param" cols="80" rows="<?php echo ROWS_4 ?>"><?php echo GETPOST('param','alpha'); ?></textarea>
</td><td> </td><td>
<span id="helpselect"><?php print $form->textwithpicto('', $langs->trans("ExtrafieldParamHelpselect"),1,0)?></span> <span id="helpselect"><?php print $form->textwithpicto('', $langs->trans("ExtrafieldParamHelpselect"),1,0,'', 0, 2, 'helpvalue1')?></span>
<span id="helpsellist"><?php print $form->textwithpicto('', $langs->trans("ExtrafieldParamHelpsellist"),1,0)?></span> <span id="helpsellist"><?php print $form->textwithpicto('', $langs->trans("ExtrafieldParamHelpsellist"),1,0,'', 0, 2, 'helpvalue2')?></span>
<span id="helpchkbxlst"><?php print $form->textwithpicto('', $langs->trans("ExtrafieldParamHelpchkbxlst"),1,0)?></span> <span id="helpchkbxlst"><?php print $form->textwithpicto('', $langs->trans("ExtrafieldParamHelpchkbxlst"),1,0,'', 0, 2, 'helpvalue3')?></span>
<span id="helplink"><?php print $form->textwithpicto('', $langs->trans("ExtrafieldParamHelplink"),1,0)?></span> <span id="helplink"><?php print $form->textwithpicto('', $langs->trans("ExtrafieldParamHelplink"),1,0,'', 0, 2, 'helpvalue4')?></span>
</td></tr> </td></tr>
</table> </table>
</td> </td>
@ -173,15 +173,11 @@ $langs->load("modulebuilder");
<tr class="extra_required"><td><?php echo $langs->trans("Required"); ?></td><td class="valeur"><input id="required" type="checkbox" name="required"<?php echo (GETPOST('required','alpha')?' checked':''); ?>></td></tr> <tr class="extra_required"><td><?php echo $langs->trans("Required"); ?></td><td class="valeur"><input id="required" type="checkbox" name="required"<?php echo (GETPOST('required','alpha')?' checked':''); ?>></td></tr>
<!-- Always editable --> <!-- Always editable -->
<tr class="extra_alwayseditable"><td><?php echo $langs->trans("AlwaysEditable"); ?></td><td class="valeur"><input id="alwayseditable" type="checkbox" name="alwayseditable"<?php echo ((GETPOST('alwayseditable','alpha') || ! GETPOST('button','alpha'))?' checked':''); ?>></td></tr> <tr class="extra_alwayseditable"><td><?php echo $langs->trans("AlwaysEditable"); ?></td><td class="valeur"><input id="alwayseditable" type="checkbox" name="alwayseditable"<?php echo ((GETPOST('alwayseditable','alpha') || ! GETPOST('button','alpha'))?' checked':''); ?>></td></tr>
<!-- Is visible or not -->
<?php if (! empty($conf->global->MAIN_CAN_HIDE_EXTRAFIELDS)) { ?>
<tr class="extra_ishidden"><td><?php echo $langs->trans("Hidden"); ?></td><td class="valeur"><input id="ishidden" type="checkbox" name="ishidden"<?php echo (GETPOST('ishidden','alpha') ?' checked' : ''); ?>></td></tr>
<?php } ?>
<?php if ($conf->multicompany->enabled) { ?> <?php if ($conf->multicompany->enabled) { ?>
<tr><td><?php echo $langs->trans("AllEntities"); ?></td><td class="valeur"><input id="entitycurrentorall" type="checkbox" name="entitycurrentorall"<?php echo (GETPOST('entitycurrentorall','alpha') ? '':' checked'); ?>></td></tr> <tr><td><?php echo $langs->trans("AllEntities"); ?></td><td class="valeur"><input id="entitycurrentorall" type="checkbox" name="entitycurrentorall"<?php echo (GETPOST('entitycurrentorall','alpha') ? '':' checked'); ?>></td></tr>
<?php } ?> <?php } ?>
<!-- By default visible into list --> <!-- Visibility -->
<tr><td class="extra_list"><?php echo $form->textwithpicto($langs->trans("ByDefaultInList"), $langs->trans("VisibleDesc")); ?> <tr><td class="extra_list"><?php echo $form->textwithpicto($langs->trans("Visibility"), $langs->trans("VisibleDesc")); ?>
</td><td class="valeur"><input id="list" size="1" type="text" name="list" value="<?php echo GETPOST('list','int')!='' ? GETPOST('list','int') : '1'; ?>"></td></tr> </td><td class="valeur"><input id="list" size="1" type="text" name="list" value="<?php echo GETPOST('list','int')!='' ? GETPOST('list','int') : '1'; ?>"></td></tr>
</table> </table>

View File

@ -65,15 +65,15 @@ $langs->load("modulebuilder");
{ {
console.log("We enter a computed formula"); console.log("We enter a computed formula");
jQuery("#default_value").val(''); jQuery("#default_value").val('');
/* jQuery("#unique, #required, #alwayseditable, #ishidden, #list").removeAttr('checked'); */ /* jQuery("#unique, #required, #alwayseditable, #list").removeAttr('checked'); */
jQuery("#default_value, #unique, #required, #alwayseditable, #ishidden, #list").attr('disabled', true); jQuery("#default_value, #unique, #required, #alwayseditable, #list").attr('disabled', true);
jQuery("tr.extra_default_value, tr.extra_unique, tr.extra_required, tr.extra_alwayseditable, tr.extra_ishidden, tr.extra_list").hide(); jQuery("tr.extra_default_value, tr.extra_unique, tr.extra_required, tr.extra_alwayseditable, tr.extra_list").hide();
} }
else else
{ {
console.log("No computed formula"); console.log("No computed formula");
jQuery("#default_value, #unique, #required, #alwayseditable, #ishidden, #list").attr('disabled', false); jQuery("#default_value, #unique, #required, #alwayseditable, #list").attr('disabled', false);
jQuery("tr.extra_default_value, tr.extra_unique, tr.extra_required, tr.extra_alwayseditable, tr.extra_ishidden, tr.extra_list").show(); jQuery("tr.extra_default_value, tr.extra_unique, tr.extra_required, tr.extra_alwayseditable, tr.extra_list").show();
} }
if (type == 'date') { size.val('').prop('disabled', true); unique.removeAttr('disabled'); jQuery("#value_choice").hide();jQuery("#helpchkbxlst").hide(); } if (type == 'date') { size.val('').prop('disabled', true); unique.removeAttr('disabled'); jQuery("#value_choice").hide();jQuery("#helpchkbxlst").hide(); }
@ -143,7 +143,6 @@ $param=$extrafields->attributes[$elementtype]['param'][$attrname];
$perms=$extrafields->attributes[$elementtype]['perms'][$attrname]; $perms=$extrafields->attributes[$elementtype]['perms'][$attrname];
$langfile=$extrafields->attributes[$elementtype]['langfile'][$attrname]; $langfile=$extrafields->attributes[$elementtype]['langfile'][$attrname];
$list=$extrafields->attributes[$elementtype]['list'][$attrname]; $list=$extrafields->attributes[$elementtype]['list'][$attrname];
$ishidden=$extrafields->attributes[$elementtype]['hidden'][$attrname];
$entitycurrentorall=$extrafields->attributes[$elementtype]['entityid'][$attrname]; $entitycurrentorall=$extrafields->attributes[$elementtype]['entityid'][$attrname];
if((($type == 'select') || ($type == 'checkbox') || ($type == 'radio')) && is_array($param)) if((($type == 'select') || ($type == 'checkbox') || ($type == 'radio')) && is_array($param))
@ -210,10 +209,10 @@ else
<tr><td> <tr><td>
<textarea name="param" id="param" cols="80" rows="<?php echo ROWS_4 ?>"><?php echo dol_htmlcleanlastbr($param_chain); ?></textarea> <textarea name="param" id="param" cols="80" rows="<?php echo ROWS_4 ?>"><?php echo dol_htmlcleanlastbr($param_chain); ?></textarea>
</td><td> </td><td>
<span id="helpselect"><?php print $form->textwithpicto('', $langs->trans("ExtrafieldParamHelpselect"),1,0)?></span> <span id="helpselect"><?php print $form->textwithpicto('', $langs->trans("ExtrafieldParamHelpselect"),1,0,'', 0, 2, 'helpvalue1')?></span>
<span id="helpsellist"><?php print $form->textwithpicto('', $langs->trans("ExtrafieldParamHelpsellist"),1,0)?></span> <span id="helpsellist"><?php print $form->textwithpicto('', $langs->trans("ExtrafieldParamHelpsellist"),1,0,'', 0, 2, 'helpvalue2')?></span>
<span id="helpchkbxlst"><?php print $form->textwithpicto('', $langs->trans("ExtrafieldParamHelpchkbxlst"),1,0)?></span> <span id="helpchkbxlst"><?php print $form->textwithpicto('', $langs->trans("ExtrafieldParamHelpchkbxlst"),1,0,'', 0, 2, 'helpvalue3')?></span>
<span id="helplink"><?php print $form->textwithpicto('', $langs->trans("ExtrafieldParamHelplink"),1,0)?></span> <span id="helplink"><?php print $form->textwithpicto('', $langs->trans("ExtrafieldParamHelplink"),1,0,'', 0, 2, 'helpvalue4')?></span>
</td></tr> </td></tr>
</table> </table>
</td> </td>
@ -232,15 +231,11 @@ else
<tr class="extra_required"><td><?php echo $langs->trans("Required"); ?></td><td class="valeur"><input id="required" type="checkbox" name="required"<?php echo ($required?' checked':''); ?>></td></tr> <tr class="extra_required"><td><?php echo $langs->trans("Required"); ?></td><td class="valeur"><input id="required" type="checkbox" name="required"<?php echo ($required?' checked':''); ?>></td></tr>
<!-- Always editable --> <!-- Always editable -->
<tr class="extra_alwayseditable"><td><?php echo $langs->trans("AlwaysEditable"); ?></td><td class="valeur"><input id="alwayseditable" type="checkbox" name="alwayseditable"<?php echo ($alwayseditable?' checked':''); ?>></td></tr> <tr class="extra_alwayseditable"><td><?php echo $langs->trans("AlwaysEditable"); ?></td><td class="valeur"><input id="alwayseditable" type="checkbox" name="alwayseditable"<?php echo ($alwayseditable?' checked':''); ?>></td></tr>
<!-- Is visible or not -->
<?php if (! empty($conf->global->MAIN_CAN_HIDE_EXTRAFIELDS)) { ?>
<tr><td><?php echo $langs->trans("Hidden"); ?></td><td class="valeur"><input id="ishidden" type="checkbox" name="ishidden"<?php echo ($ishidden ?' checked':''); ?>></td></tr>
<?php } ?>
<?php if ($conf->multicompany->enabled) { ?> <?php if ($conf->multicompany->enabled) { ?>
<tr><td><?php echo $langs->trans("AllEntities"); ?></td><td class="valeur"><input id="entitycurrentorall" type="checkbox" name="entitycurrentorall"<?php echo (empty($entitycurrentorall) ?' checked':''); ?>></td></tr> <tr><td><?php echo $langs->trans("AllEntities"); ?></td><td class="valeur"><input id="entitycurrentorall" type="checkbox" name="entitycurrentorall"<?php echo (empty($entitycurrentorall) ?' checked':''); ?>></td></tr>
<?php } ?> <?php } ?>
<!-- By default visible into list --> <!-- Visibility -->
<tr><td class="extra_list"><?php echo $form->textwithpicto($langs->trans("ByDefaultInList"), $langs->trans("VisibleDesc")); ?> <tr><td class="extra_list"><?php echo $form->textwithpicto($langs->trans("Visibility"), $langs->trans("VisibleDesc")); ?>
</td><td class="valeur"><input id="list" size="1" type="text" name="list" value="<?php echo ($list!=''?$list:'1'); ?>"></td></tr> </td><td class="valeur"><input id="list" size="1" type="text" name="list" value="<?php echo ($list!=''?$list:'1'); ?>"></td></tr>
</table> </table>

View File

@ -81,7 +81,6 @@ if (count($extrafields->attributes[$elementtype]['type']))
print '<td align="center">'.yn($extrafields->attributes[$elementtype]['required'][$key])."</td>\n"; print '<td align="center">'.yn($extrafields->attributes[$elementtype]['required'][$key])."</td>\n";
print '<td align="center">'.yn($extrafields->attributes[$elementtype]['alwayseditable'][$key])."</td>\n"; print '<td align="center">'.yn($extrafields->attributes[$elementtype]['alwayseditable'][$key])."</td>\n";
print '<td align="center">'.$extrafields->attributes[$elementtype]['list'][$key]."</td>\n"; print '<td align="center">'.$extrafields->attributes[$elementtype]['list'][$key]."</td>\n";
if (! empty($conf->global->MAIN_CAN_HIDE_EXTRAFIELDS)) print '<td align="center">'.yn($extrafields->attributes[$elementtype]['ishidden'][$key])."</td>\n"; // Add hidden option on not working feature. Why hide if user can't see it.
if (! empty($conf->multicompany->enabled)) { if (! empty($conf->multicompany->enabled)) {
print '<td align="center">'.($extrafields->attributes[$elementtype]['entityid'][$key]==0?$langs->trans("All"):$extrafields->attributes[$elementtype]['entitylabel'][$key]).'</td>'; print '<td align="center">'.($extrafields->attributes[$elementtype]['entityid'][$key]==0?$langs->trans("All"):$extrafields->attributes[$elementtype]['entitylabel'][$key]).'</td>';
} }

View File

@ -59,8 +59,7 @@ if (empty($reshook) && ! empty($extrafields->attributes[$object->table_element][
} }
else else
{ {
if (! empty($extrafields->attributes[$object->table_element]['ishidden'][$key])) print '<tr class="hideobject"><td>'; print '<tr><td>';
else print '<tr><td>';
print '<table width="100%" class="nobordernopadding">'; print '<table width="100%" class="nobordernopadding">';
print '<tr>'; print '<tr>';
print '<td'; print '<td';

View File

@ -48,6 +48,8 @@ class InterfaceActionsBlockedLog extends DolibarrTriggers
{ {
if (empty($conf->blockedlog->enabled)) return 0; // Module not active, we do nothing if (empty($conf->blockedlog->enabled)) return 0; // Module not active, we do nothing
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
if($action==='BILL_VALIDATE' || $action === 'BILL_PAYED' || $action==='BILL_UNPAYED' if($action==='BILL_VALIDATE' || $action === 'BILL_PAYED' || $action==='BILL_UNPAYED'
|| $action === 'BILL_SENTBYMAIL' || $action === 'DOC_DOWNLOAD' || $action === 'DOC_PREVIEW') { || $action === 'BILL_SENTBYMAIL' || $action === 'DOC_DOWNLOAD' || $action === 'DOC_PREVIEW') {
$amounts= (double) $object->total_ttc; $amounts= (double) $object->total_ttc;
@ -72,7 +74,7 @@ class InterfaceActionsBlockedLog extends DolibarrTriggers
$b=new BlockedLog($this->db); $b=new BlockedLog($this->db);
$b->action = $action; $b->action = $action;
$b->amounts= $amounts; $b->amounts= $amounts;
$b->setObjectData($object); $b->setObjectData($object); // Set field ref_object, fk_object, element, object_data
$res = $b->create($user); $res = $b->create($user);

View File

@ -36,7 +36,7 @@ $form = new Form($db);
// List of supported format // List of supported format
$tmptype2label=ExtraFields::$type2label; $tmptype2label=ExtraFields::$type2label;
$type2label=array(''); $type2label=array('');
foreach ($tmptype2label as $key => $val) $type2label[$key]=$langs->trans($val); foreach ($tmptype2label as $key => $val) $type2label[$key]=$langs->transnoentitiesnoconv($val);
$action=GETPOST('action', 'alpha'); $action=GETPOST('action', 'alpha');
$attrname=GETPOST('attrname', 'alpha'); $attrname=GETPOST('attrname', 'alpha');

View File

@ -173,9 +173,11 @@ if (empty($reshook))
$reshook = $hookmanager->executeHooks('insertExtraFields', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks $reshook = $hookmanager->executeHooks('insertExtraFields', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
if (empty($reshook)) { if (empty($reshook)) {
$result = $object->insertExtraFields(); $result = $object->insertExtraFields();
if ($result < 0) { if ($result < 0)
$error++; {
} setEventMessages($object->error, $object->errors, 'errors');
$error++;
}
} else if ($reshook < 0) } else if ($reshook < 0)
$error++; $error++;
} }

View File

@ -191,9 +191,11 @@ if (empty($reshook))
// some hooks // some hooks
if (empty($reshook)) { if (empty($reshook)) {
$result = $object->insertExtraFields(); $result = $object->insertExtraFields();
if ($result < 0) { if ($result < 0)
$error++; {
} setEventMessages($object->error, $object->errors, 'errors');
$error++;
}
} else if ($reshook < 0) } else if ($reshook < 0)
$error++; $error++;
} }

View File

@ -296,9 +296,11 @@ if (empty($reshook))
// some hooks // some hooks
if (empty($reshook)) { if (empty($reshook)) {
$result = $object->insertExtraFields(); $result = $object->insertExtraFields();
if ($result < 0) { if ($result < 0)
$error++; {
} setEventMessages($object->error, $object->errors, 'errors');
$error++;
}
} else if ($reshook < 0) } else if ($reshook < 0)
$error++; $error++;
} }

View File

@ -41,7 +41,7 @@ $form = new Form($db);
// List of supported format // List of supported format
$tmptype2label=ExtraFields::$type2label; $tmptype2label=ExtraFields::$type2label;
$type2label=array(''); $type2label=array('');
foreach ($tmptype2label as $key => $val) $type2label[$key]=$langs->trans($val); foreach ($tmptype2label as $key => $val) $type2label[$key]=$langs->transnoentitiesnoconv($val);
$action=GETPOST('action', 'alpha'); $action=GETPOST('action', 'alpha');
$attrname=GETPOST('attrname', 'alpha'); $attrname=GETPOST('attrname', 'alpha');

View File

@ -41,7 +41,7 @@ $form = new Form($db);
// List of supported format // List of supported format
$tmptype2label=ExtraFields::$type2label; $tmptype2label=ExtraFields::$type2label;
$type2label=array(''); $type2label=array('');
foreach ($tmptype2label as $key => $val) $type2label[$key]=$langs->trans($val); foreach ($tmptype2label as $key => $val) $type2label[$key]=$langs->transnoentitiesnoconv($val);
$action=GETPOST('action', 'alpha'); $action=GETPOST('action', 'alpha');
$attrname=GETPOST('attrname', 'alpha'); $attrname=GETPOST('attrname', 'alpha');

View File

@ -169,12 +169,17 @@ ALTER TABLE llx_accounting_bookkeeping ADD COLUMN date_lim_reglement datetime DE
ALTER TABLE llx_accounting_bookkeeping ADD COLUMN fk_user integer NULL; ALTER TABLE llx_accounting_bookkeeping ADD COLUMN fk_user integer NULL;
ALTER TABLE llx_menu MODIFY fk_mainmenu varchar(100);
ALTER TABLE llx_menu MODIFY fk_leftmenu varchar(100);
CREATE TABLE llx_websiteaccount( CREATE TABLE llx_websiteaccount(
rowid integer AUTO_INCREMENT PRIMARY KEY NOT NULL, rowid integer AUTO_INCREMENT PRIMARY KEY NOT NULL,
login varchar(64) NOT NULL, login varchar(64) NOT NULL,
label varchar(255), pass_crypted varchar(128),
note_public text, pass_temp varchar(128), -- temporary password when asked for forget password
note_private text, date_last_login datetime,
date_previous_login datetime,
date_creation datetime NOT NULL, date_creation datetime NOT NULL,
tms timestamp NOT NULL, tms timestamp NOT NULL,
fk_user_creat integer NOT NULL, fk_user_creat integer NOT NULL,
@ -184,6 +189,7 @@ CREATE TABLE llx_websiteaccount(
fk_soc integer fk_soc integer
) ENGINE=innodb; ) ENGINE=innodb;
ALTER TABLE llx_websiteaccount ADD INDEX idx_websiteaccount_rowid (rowid); ALTER TABLE llx_websiteaccount ADD INDEX idx_websiteaccount_rowid (rowid);
ALTER TABLE llx_websiteaccount ADD INDEX idx_websiteaccount_login (login); ALTER TABLE llx_websiteaccount ADD INDEX idx_websiteaccount_login (login);
ALTER TABLE llx_websiteaccount ADD INDEX idx_websiteaccount_import_key (import_key); ALTER TABLE llx_websiteaccount ADD INDEX idx_websiteaccount_import_key (import_key);
@ -343,7 +349,7 @@ ALTER TABLE llx_extrafields ADD COLUMN fk_user_modif integer;
ALTER TABLE llx_extrafields ADD COLUMN datec datetime; ALTER TABLE llx_extrafields ADD COLUMN datec datetime;
ALTER TABLE llx_extrafields ADD COLUMN tms timestamp; ALTER TABLE llx_extrafields ADD COLUMN tms timestamp;
-- We fix value of 'list' fro m0 to 1 for all extrafields created before this migration -- We fix value of 'list' from 0 to 1 for all extrafields created before this migration
UPDATE llx_extrafields SET list = 1 WHERE list = 0 AND fk_user_author IS NULL and fk_user_modif IS NULL and datec IS NULL; UPDATE llx_extrafields SET list = 1 WHERE list = 0 AND fk_user_author IS NULL and fk_user_modif IS NULL and datec IS NULL;
ALTER TABLE llx_extrafields MODIFY COLUMN list integer DEFAULT 1; ALTER TABLE llx_extrafields MODIFY COLUMN list integer DEFAULT 1;

View File

@ -34,9 +34,8 @@ create table llx_extrafields
pos integer DEFAULT 0, pos integer DEFAULT 0,
alwayseditable integer DEFAULT 0, -- 1 if field can be edited whatever is element status alwayseditable integer DEFAULT 0, -- 1 if field can be edited whatever is element status
param text, -- extra parameters to define possible values of field param text, -- extra parameters to define possible values of field
list integer DEFAULT 1, -- list of values for field that are combo lists list integer DEFAULT 1, -- visibility of field. 0=Never visible, 1=Visible on list and forms, 2=Visible on list only. Using a negative value means field is not shown by default on list but can be selected for viewing
langs varchar(64), -- example: fileofmymodule@mymodule langs varchar(64), -- example: fileofmymodule@mymodule
ishidden integer DEFAULT 0, -- Can be foreign key of external system
fk_user_author integer, -- user making creation fk_user_author integer, -- user making creation
fk_user_modif integer, -- user making last change fk_user_modif integer, -- user making last change
datec datetime, -- date de creation datec datetime, -- date de creation

View File

@ -30,8 +30,8 @@ CREATE TABLE llx_menu
mainmenu varchar(100) NOT NULL, -- Name family/module for top menu (home, companies, ...) mainmenu varchar(100) NOT NULL, -- Name family/module for top menu (home, companies, ...)
leftmenu varchar(100) NULL, -- Name family/module for left menu (setup, info, ...) leftmenu varchar(100) NULL, -- Name family/module for left menu (setup, info, ...)
fk_menu integer NOT NULL, -- 0 or Id of mother menu line, or -1 if we use fk_mainmenu and fk_leftmenu fk_menu integer NOT NULL, -- 0 or Id of mother menu line, or -1 if we use fk_mainmenu and fk_leftmenu
fk_mainmenu varchar(24), -- fk_mainmenu varchar(100), --
fk_leftmenu varchar(24), -- fk_leftmenu varchar(100), --
position integer NOT NULL, -- Sort order of entry position integer NOT NULL, -- Sort order of entry
url varchar(255) NOT NULL, -- Relative (or absolute) url to go url varchar(255) NOT NULL, -- Relative (or absolute) url to go
target varchar(100) NULL, -- Target of Url link target varchar(100) NULL, -- Target of Url link

View File

@ -17,10 +17,11 @@
CREATE TABLE llx_websiteaccount( CREATE TABLE llx_websiteaccount(
-- BEGIN MODULEBUILDER FIELDS -- BEGIN MODULEBUILDER FIELDS
rowid integer AUTO_INCREMENT PRIMARY KEY NOT NULL, rowid integer AUTO_INCREMENT PRIMARY KEY NOT NULL,
login varchar(64) NOT NULL, login varchar(64) NOT NULL,
label varchar(255), pass_crypted varchar(128),
note_public text, pass_temp varchar(128), -- temporary password when asked for forget password
note_private text, date_last_login datetime,
date_previous_login datetime,
date_creation datetime NOT NULL, date_creation datetime NOT NULL,
tms timestamp NOT NULL, tms timestamp NOT NULL,
fk_user_creat integer NOT NULL, fk_user_creat integer NOT NULL,

View File

@ -71,7 +71,7 @@ NoWidget=No widget
GoToApiExplorer=Go to API explorer GoToApiExplorer=Go to API explorer
ListOfPermissionsDefined=List of defined permissions ListOfPermissionsDefined=List of defined permissions
EnabledDesc=Condition to have this field active (Examples: 1 or $conf->global->MYMODULE_MYOPTION) EnabledDesc=Condition to have this field active (Examples: 1 or $conf->global->MYMODULE_MYOPTION)
VisibleDesc=Is the field visible into list ? (Examples: 0=not visible, 1=visible by default on list, -1=not shown by default on list but can be added into list to be viewed) VisibleDesc=Is the field visible ? (Examples: 0=Never visible, 1=Visible on list and forms, 2=Visible on list only. Using a negative value means field is not shown by default on list but can be selected for viewing)
IsAMeasureDesc=Can the value of field be cumulated to get a total into list ? (Examples: 1 or 0) IsAMeasureDesc=Can the value of field be cumulated to get a total into list ? (Examples: 1 or 0)
SearchAllDesc=Is the field used to make a search from the quick search tool ? (Examples: 1 or 0) SearchAllDesc=Is the field used to make a search from the quick search tool ? (Examples: 1 or 0)
SpecDefDesc=Enter here all documentation you want to provide with your module that is not already defined by other tabs. You can use .md or better, the rich .asciidoc syntax. SpecDefDesc=Enter here all documentation you want to provide with your module that is not already defined by other tabs. You can use .md or better, the rich .asciidoc syntax.

View File

@ -207,7 +207,9 @@ if ($action == 'update_extras')
$reshook = $hookmanager->executeHooks('insertExtraFields', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks $reshook = $hookmanager->executeHooks('insertExtraFields', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
if (empty($reshook)) { if (empty($reshook)) {
$result = $object->insertExtraFields(); $result = $object->insertExtraFields();
if ($result < 0) { if ($result < 0)
{
setEventMessages($object->error, $object->errors, 'errors');
$error++; $error++;
} }
} else if ($reshook < 0) } else if ($reshook < 0)

View File

@ -421,7 +421,7 @@ class Loan extends CommonObject
if ($withpicto) $result.=($link.$linkclose.img_object($langs->trans("ShowLoan").': '.$this->label,'bill', 'class="classfortooltip"').$linkend.' '); if ($withpicto) $result.=($link.$linkclose.img_object($langs->trans("ShowLoan").': '.$this->label,'bill', 'class="classfortooltip"').$linkend.' ');
if ($withpicto && $withpicto != 2) $result.=' '; if ($withpicto && $withpicto != 2) $result.=' ';
if ($withpicto != 2) $result.=$link.$linkclose.($maxlen?dol_trunc($this->label,$maxlen):$this->label).$linkend; if ($withpicto != 2) $result.=$link.$linkclose.($maxlen?dol_trunc($this->ref,$maxlen):$this->ref).$linkend;
return $result; return $result;
} }

View File

@ -76,9 +76,9 @@ $sql.= " SUM(pl.amount_capital) as alreadypayed";
$sql.= " FROM ".MAIN_DB_PREFIX."loan as l LEFT JOIN ".MAIN_DB_PREFIX."payment_loan AS pl"; $sql.= " FROM ".MAIN_DB_PREFIX."loan as l LEFT JOIN ".MAIN_DB_PREFIX."payment_loan AS pl";
$sql.= " ON l.rowid = pl.fk_loan"; $sql.= " ON l.rowid = pl.fk_loan";
$sql.= " WHERE l.entity = ".$conf->entity; $sql.= " WHERE l.entity = ".$conf->entity;
if ($search_amount) $sql.=" AND l.capital='".$db->escape(price2num(trim($search_amount)))."'"; if ($search_amount) $sql.= natural_search("l.capital", $search_amount, 1);
if ($search_ref) $sql.=" AND l.rowid = ".$db->escape($search_ref); if ($search_ref) $sql.= " AND l.rowid = ".$db->escape($search_ref);
if ($search_label) $sql.=" AND l.label LIKE '%".$db->escape($search_label)."%'"; if ($search_label) $sql.= natural_search("l.label", $search_label);
if ($filtre) { if ($filtre) {
$filtre=str_replace(":","=",$filtre); $filtre=str_replace(":","=",$filtre);
$sql .= " AND ".$filtre; $sql .= " AND ".$filtre;
@ -104,12 +104,12 @@ if ($resql)
$var=true; $var=true;
$param=''; $param='';
if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage; if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.urlencode($contextpage);
if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit; if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.urlencode($limit);
if ($search_ref) $param.="&amp;search_ref=".$search_ref; if ($search_ref) $param.="&amp;search_ref=".urlencode($search_ref);
if ($search_label) $param.="&amp;search_label=".$search_user; if ($search_label) $param.="&amp;search_label=".urlencode($search_user);
if ($search_amount) $param.="&amp;search_amount=".$search_amount_ht; if ($search_amount) $param.="&amp;search_amount=".urlencode($search_amount_ht);
if ($optioncss != '') $param.='&amp;optioncss='.$optioncss; if ($optioncss != '') $param.='&amp;optioncss='.urlencode($optioncss);
print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">'."\n"; print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">'."\n";
if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">'; if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';

View File

@ -57,8 +57,8 @@ class MyObject extends CommonObject
/** /**
* 'type' if the field format. * 'type' if the field format.
* 'label' the translation key. * 'label' the translation key.
* 'enabled' is a condition when the filed must be managed. * 'enabled' is a condition when the field must be managed.
* 'visible' says if field is visible in list (-1 means not shown by default but can be added into list to be viewed). * 'visible' says if field is visible in list (Examples: 0=Not visible, 1=Visible on list and forms, 2=Visible on list only. Using a negative value means field is not shown by default on list but can be selected for viewing)
* 'notnull' is set to 1 if not null in database. Set to -1 if we must set data to null if empty ('' or 0). * 'notnull' is set to 1 if not null in database. Set to -1 if we must set data to null if empty ('' or 0).
* 'index' if we want an index in database. * 'index' if we want an index in database.
* 'foreignkey'=>'tablename.field' if the field is a foreign key (it is recommanded to name the field fk_...). * 'foreignkey'=>'tablename.field' if the field is a foreign key (it is recommanded to name the field fk_...).
@ -74,20 +74,21 @@ class MyObject extends CommonObject
* @var array Array with all fields and their property. Do not use it as a static var. It may be modified by constructor. * @var array Array with all fields and their property. Do not use it as a static var. It may be modified by constructor.
*/ */
public $fields=array( public $fields=array(
'rowid' =>array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'index'=>1, 'position'=>1, 'comment'=>'Id'), 'rowid' =>array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'index'=>1, 'position'=>1, 'comment'=>'Id'),
'ref' =>array('type'=>'varchar(64)', 'label'=>'Ref', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'index'=>1, 'position'=>10, 'searchall'=>1, 'comment'=>'Reference of object'), 'ref' =>array('type'=>'varchar(64)', 'label'=>'Ref', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'index'=>1, 'position'=>10, 'searchall'=>1, 'comment'=>'Reference of object'),
'entity' =>array('type'=>'integer', 'label'=>'Entity', 'enabled'=>1, 'visible'=>0, 'default'=>1, 'notnull'=>1, 'index'=>1, 'position'=>20), 'entity' =>array('type'=>'integer', 'label'=>'Entity', 'enabled'=>1, 'visible'=>0, 'default'=>1, 'notnull'=>1, 'index'=>1, 'position'=>20),
'label' =>array('type'=>'varchar(255)', 'label'=>'Label', 'enabled'=>1, 'visible'=>1, 'position'=>30, 'searchall'=>1, 'css'=>'minwidth200'), 'label' =>array('type'=>'varchar(255)', 'label'=>'Label', 'enabled'=>1, 'visible'=>1, 'position'=>30, 'searchall'=>1, 'css'=>'minwidth200', 'help'=>'Help text'),
'amount' =>array('type'=>'double(24,8)', 'label'=>'Amount', 'enabled'=>1, 'visible'=>1, 'default'=>'null', 'position'=>40, 'searchall'=>0, 'isameasure'=>1, 'help'=>'Amount'), 'amount' =>array('type'=>'double(24,8)', 'label'=>'Amount', 'enabled'=>1, 'visible'=>1, 'default'=>'null', 'position'=>40, 'searchall'=>0, 'isameasure'=>1, 'help'=>'Help text'),
'note_public' =>array('type'=>'text', 'label'=>'NotePublic', 'enabled'=>1, 'visible'=>0, 'position'=>45), 'fk_soc' =>array('type'=>'integer:Societe:societe/class/societe.class.php', 'label'=>'ThirdParty', 'visible'=>1, 'enabled'=>1, 'position'=>50, 'notnull'=>-1, 'index'=>1, 'searchall'=>1, 'help'=>'LinkToThirparty'),
'note_private' =>array('type'=>'text', 'label'=>'NotePrivate', 'enabled'=>1, 'visible'=>0, 'position'=>46), 'note_public' =>array('type'=>'text', 'label'=>'NotePublic', 'enabled'=>1, 'visible'=>0, 'position'=>60),
'date_creation' =>array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>500), 'note_private' =>array('type'=>'text', 'label'=>'NotePrivate', 'enabled'=>1, 'visible'=>0, 'position'=>61),
'tms' =>array('type'=>'timestamp', 'label'=>'DateModification', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>501), 'date_creation' =>array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>500),
//'date_valid' =>array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>-1, 'position'=>502), 'tms' =>array('type'=>'timestamp', 'label'=>'DateModification', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>501),
'fk_user_creat' =>array('type'=>'integer', 'label'=>'UserAuthor', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>510), //'date_valid' =>array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>-2, 'position'=>502),
'fk_user_modif' =>array('type'=>'integer', 'label'=>'UserModif', 'enabled'=>1, 'visible'=>-1, 'notnull'=>-1, 'position'=>511), 'fk_user_creat' =>array('type'=>'integer', 'label'=>'UserAuthor', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>510),
'fk_user_modif' =>array('type'=>'integer', 'label'=>'UserModif', 'enabled'=>1, 'visible'=>-2, 'notnull'=>-1, 'position'=>511),
//'fk_user_valid' =>array('type'=>'integer', 'label'=>'UserValidation', 'enabled'=>1, 'visible'=>-1, 'position'=>512), //'fk_user_valid' =>array('type'=>'integer', 'label'=>'UserValidation', 'enabled'=>1, 'visible'=>-1, 'position'=>512),
'import_key' =>array('type'=>'varchar(14)', 'label'=>'ImportId', 'enabled'=>1, 'visible'=>-1, 'notnull'=>-1, 'index'=>1, 'position'=>1000), 'import_key' =>array('type'=>'varchar(14)', 'label'=>'ImportId', 'enabled'=>1, 'visible'=>-2, 'notnull'=>-1, 'index'=>1, 'position'=>1000),
'status' =>array('type'=>'integer', 'label'=>'Status', 'enabled'=>1, 'visible'=>1, 'index'=>1, 'position'=>1000, 'arrayofkeyval'=>array(0=>'Draft', 1=>'Active', -1=>'Cancel')), 'status' =>array('type'=>'integer', 'label'=>'Status', 'enabled'=>1, 'visible'=>1, 'index'=>1, 'position'=>1000, 'arrayofkeyval'=>array(0=>'Draft', 1=>'Active', -1=>'Cancel')),
); );

View File

@ -99,7 +99,7 @@ include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be inclu
/* /*
* ACTIONS * Actions
* *
* Put here all code to do according to value of "action" parameter * Put here all code to do according to value of "action" parameter
*/ */
@ -112,108 +112,12 @@ if (empty($reshook))
{ {
$error=0; $error=0;
if ($cancel) $permissiontoadd = $user->rights->mymodule->create;
{ $permissiontodelete = $user->rights->mymodule->delete;
if (! empty($backtopage)) $backurlforlist = dol_buildpath('/mymodule/myobject_list.php',1);
{
header("Location: ".$backtopage);
exit;
}
$action='';
}
// Action to add record // Actions cancel, add, update or delete
if ($action == 'add' && ! empty($user->rights->mymodule->create)) include DOL_DOCUMENT_ROOT.'/core/actions_addupdatedelete.inc.php';
{
foreach ($object->fields as $key => $val)
{
if (in_array($key, array('rowid', 'entity', 'date_creation', 'tms', 'fk_user_creat', 'fk_user_modif', 'import_key'))) continue; // Ignore special fields
$object->$key=GETPOST($key,'alpha');
if ($val['notnull'] > 0 && $object->$key == '')
{
$error++;
setEventMessages($langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv($val['label'])), null, 'errors');
}
}
if (! $error)
{
$result=$object->createCommon($user);
if ($result > 0)
{
// Creation OK
$urltogo=$backtopage?$backtopage:dol_buildpath('/mymodule/myobject_list.php',1);
header("Location: ".$urltogo);
exit;
}
else
{
// Creation KO
if (! empty($object->errors)) setEventMessages(null, $object->errors, 'errors');
else setEventMessages($object->error, null, 'errors');
$action='create';
}
}
else
{
$action='create';
}
}
// Action to update record
if ($action == 'update' && ! empty($user->rights->mymodule->create))
{
foreach ($object->fields as $key => $val)
{
if (in_array($key, array('rowid', 'entity', 'date_creation', 'tms', 'fk_user_creat', 'fk_user_modif', 'import_key'))) continue; // Ignore special fields
$object->$key=GETPOST($key,'alpha');
if ($val['notnull'] > 0 && $object->$key == '')
{
$error++;
setEventMessages($langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv($val['label'])), null, 'errors');
}
}
if (! $error)
{
$result=$object->updateCommon($user);
if ($result > 0)
{
$action='view';
}
else
{
// Creation KO
if (! empty($object->errors)) setEventMessages(null, $object->errors, 'errors');
else setEventMessages($object->error, null, 'errors');
$action='edit';
}
}
else
{
$action='edit';
}
}
// Action to delete
if ($action == 'confirm_delete' && ! empty($user->rights->mymodule->delete))
{
$result=$object->deleteCommon($user);
if ($result > 0)
{
// Delete OK
setEventMessages("RecordDeleted", null, 'mesgs');
header("Location: ".dol_buildpath('/mymodule/myobject_list.php',1));
exit;
}
else
{
if (! empty($object->errors)) setEventMessages(null, $object->errors, 'errors');
else setEventMessages($object->error, null, 'errors');
}
}
// Actions when printing a doc from card // Actions when printing a doc from card
include DOL_DOCUMENT_ROOT.'/core/actions_printing.inc.php'; include DOL_DOCUMENT_ROOT.'/core/actions_printing.inc.php';
@ -229,7 +133,7 @@ if (empty($reshook))
/* /*
* VIEW * View
* *
* Put here all code to build page * Put here all code to build page
*/ */
@ -270,7 +174,9 @@ if ($action == 'create')
print '<table class="border centpercent">'."\n"; print '<table class="border centpercent">'."\n";
foreach($object->fields as $key => $val) foreach($object->fields as $key => $val)
{ {
if (in_array($key, array('rowid', 'entity', 'date_creation', 'date_validation', 'tms', 'fk_user_creat', 'fk_user_modif', 'fk_user_valid', 'import_key'))) continue; if (abs($val['visible']) != 1) continue; // Discard such field from form
if (array_key_exists('enabled', $val) && isset($val['enabled']) && ! $val['enabled']) continue; // We don't want this field
print '<tr id="field_'.$key.'">'; print '<tr id="field_'.$key.'">';
print '<td'; print '<td';
print ' class="titlefieldcreate'; print ' class="titlefieldcreate';
@ -332,7 +238,8 @@ if (($id || $ref) && $action == 'edit')
print '<table class="border centpercent">'."\n"; print '<table class="border centpercent">'."\n";
foreach($object->fields as $key => $val) foreach($object->fields as $key => $val)
{ {
if (in_array($key, array('rowid', 'entity', 'date_creation', 'tms', 'fk_user_creat', 'fk_user_modif', 'import_key'))) continue; if (abs($val['visible']) != 1) continue; // Discard such field from form
if (array_key_exists('enabled', $val) && isset($val['enabled']) && ! $val['enabled']) continue; // We don't want this field
print '<tr><td'; print '<tr><td';
print ' class="titlefieldcreate'; print ' class="titlefieldcreate';
@ -474,7 +381,8 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
foreach($object->fields as $key => $val) foreach($object->fields as $key => $val)
{ {
if (in_array($key, array('rowid', 'ref', 'entity', 'note_public', 'note_private', 'date_creation', 'tms', 'fk_user_creat', 'fk_user_modif', 'import_key', 'status'))) continue; if (abs($val['visible']) != 1) continue; // Discard such field from form
if (array_key_exists('enabled', $val) && isset($val['enabled']) && ! $val['enabled']) continue; // We don't want this field
print '<tr><td'; print '<tr><td';
print ' class="titlefield'; print ' class="titlefield';

View File

@ -39,7 +39,7 @@ $form = new Form($db);
// List of supported format // List of supported format
$tmptype2label=ExtraFields::$type2label; $tmptype2label=ExtraFields::$type2label;
$type2label=array(''); $type2label=array('');
foreach ($tmptype2label as $key => $val) $type2label[$key]=$langs->trans($val); foreach ($tmptype2label as $key => $val) $type2label[$key]=$langs->transnoentitiesnoconv($val);
$action=GETPOST('action', 'alpha'); $action=GETPOST('action', 'alpha');
$attrname=GETPOST('attrname', 'alpha'); $attrname=GETPOST('attrname', 'alpha');

View File

@ -40,7 +40,7 @@ $form = new Form($db);
// List of supported format // List of supported format
$tmptype2label=ExtraFields::$type2label; $tmptype2label=ExtraFields::$type2label;
$type2label=array(''); $type2label=array('');
foreach ($tmptype2label as $key => $val) $type2label[$key]=$langs->trans($val); foreach ($tmptype2label as $key => $val) $type2label[$key]=$langs->transnoentitiesnoconv($val);
$action=GETPOST('action', 'alpha'); $action=GETPOST('action', 'alpha');
$attrname=GETPOST('attrname', 'alpha'); $attrname=GETPOST('attrname', 'alpha');

View File

@ -80,109 +80,12 @@ if (empty($reshook))
{ {
$error=0; $error=0;
if ($cancel) $permissiontoadd = $user->rights->inventory->create;
{ $permissiontodelete = $user->rights->inventory->delete;
if ($action != 'addlink') $backurlforlist = dol_buildpath('/inventory/inventory_list.php',1);
{
$urltogo=$backtopage?$backtopage:(DOL_URL_ROOT.'/product/inventory/list.php');
header("Location: ".$urltogo);
exit;
}
if ($id > 0 || ! empty($ref)) $ret = $object->fetch($id,$ref);
$action='';
}
// Action to add record // Actions cancel, add, update or delete
if ($action == 'add' && ! empty($user->rights->inventory->create)) include DOL_DOCUMENT_ROOT.'/core/actions_addupdatedelete.inc.php';
{
foreach ($object->fields as $key => $val)
{
if (in_array($key, array('rowid', 'entity', 'date_creation', 'date_validation', 'tms', 'fk_user_creat', 'fk_user_modif', 'fk_user_validation', 'import_key'))) continue; // Ignore special fields
$object->$key=GETPOST($key,'alpha');
if ($val['notnull'] && $object->$key == '')
{
$error++;
setEventMessages($langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv($val['label'])), null, 'errors');
}
}
if (! $error)
{
$result=$object->createCommon($user);
if ($result > 0)
{
// Creation OK
$urltogo=$backtopage?$backtopage:dol_buildpath('/inventory/inventory_list.php',1);
header("Location: ".$urltogo);
exit;
}
else
{
// Creation KO
if (! empty($object->errors)) setEventMessages(null, $object->errors, 'errors');
else setEventMessages($object->error, null, 'errors');
$action='create';
}
}
else
{
$action='create';
}
}
// Action to update record
if ($action == 'update' && ! empty($user->rights->inventory->create))
{
foreach ($object->fields as $key => $val)
{
$object->$key=GETPOST($key,'alpha');
if (in_array($key, array('rowid', 'entity', 'date_creation', 'tms', 'import_key'))) continue;
if ($val['notnull'] && $object->$key == '')
{
$error++;
setEventMessages($langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv($val['label'])), null, 'errors');
}
}
if (! $error)
{
$result=$object->updateCommon($user);
if ($result > 0)
{
$action='view';
}
else
{
// Creation KO
if (! empty($object->errors)) setEventMessages(null, $object->errors, 'errors');
else setEventMessages($object->error, null, 'errors');
$action='edit';
}
}
else
{
$action='edit';
}
}
// Action to delete
if ($action == 'confirm_delete' && ! empty($user->rights->inventory->delete))
{
$result=$object->deleteCommon($user);
if ($result > 0)
{
// Delete OK
setEventMessages("RecordDeleted", null, 'mesgs');
header("Location: ".dol_buildpath('/inventory/inventory_list.php',1));
exit;
}
else
{
if (! empty($object->errors)) setEventMessages(null, $object->errors, 'errors');
else setEventMessages($object->error, null, 'errors');
}
}
} }

View File

@ -136,9 +136,11 @@ if (empty($reshook))
// some hooks // some hooks
if (empty($reshook)) { if (empty($reshook)) {
$result = $object->insertExtraFields(); $result = $object->insertExtraFields();
if ($result < 0) { if ($result < 0)
$error++; {
} setEventMessages($object->error, $object->errors, 'errors');
$error++;
}
} else if ($reshook < 0) } else if ($reshook < 0)
$error++; $error++;
} }

View File

@ -39,7 +39,7 @@ $form = new Form($db);
// List of supported format // List of supported format
$tmptype2label=ExtraFields::$type2label; $tmptype2label=ExtraFields::$type2label;
$type2label=array(''); $type2label=array('');
foreach ($tmptype2label as $key => $val) $type2label[$key]=$langs->trans($val); foreach ($tmptype2label as $key => $val) $type2label[$key]=$langs->transnoentitiesnoconv($val);
$action=GETPOST('action', 'alpha'); $action=GETPOST('action', 'alpha');
$attrname=GETPOST('attrname', 'alpha'); $attrname=GETPOST('attrname', 'alpha');

View File

@ -39,7 +39,7 @@ $form = new Form($db);
// List of supported format // List of supported format
$tmptype2label=ExtraFields::$type2label; $tmptype2label=ExtraFields::$type2label;
$type2label=array(''); $type2label=array('');
foreach ($tmptype2label as $key => $val) $type2label[$key]=$langs->trans($val); foreach ($tmptype2label as $key => $val) $type2label[$key]=$langs->transnoentitiesnoconv($val);
$action=GETPOST('action', 'alpha'); $action=GETPOST('action', 'alpha');
$attrname=GETPOST('attrname', 'alpha'); $attrname=GETPOST('attrname', 'alpha');

View File

@ -37,7 +37,7 @@ $form = new Form($db);
// List of supported format // List of supported format
$tmptype2label=ExtraFields::$type2label; $tmptype2label=ExtraFields::$type2label;
$type2label=array(''); $type2label=array('');
foreach ($tmptype2label as $key => $val) $type2label[$key]=$langs->trans($val); foreach ($tmptype2label as $key => $val) $type2label[$key]=$langs->transnoentitiesnoconv($val);
$action=GETPOST('action', 'alpha'); $action=GETPOST('action', 'alpha');
$attrname=GETPOST('attrname', 'alpha'); $attrname=GETPOST('attrname', 'alpha');

View File

@ -38,7 +38,7 @@ $form = new Form($db);
// List of supported format // List of supported format
$tmptype2label=ExtraFields::$type2label; $tmptype2label=ExtraFields::$type2label;
$type2label=array(''); $type2label=array('');
foreach ($tmptype2label as $key => $val) $type2label[$key]=$langs->trans($val); foreach ($tmptype2label as $key => $val) $type2label[$key]=$langs->transnoentitiesnoconv($val);
$action=GETPOST('action', 'alpha'); $action=GETPOST('action', 'alpha');
$attrname=GETPOST('attrname', 'alpha'); $attrname=GETPOST('attrname', 'alpha');

View File

@ -290,11 +290,17 @@ if (empty($reshook))
$extralabels = $extrafields->fetch_name_optionals_label($object->table_element); $extralabels = $extrafields->fetch_name_optionals_label($object->table_element);
$ret = $extrafields->setOptionalsFromPost($extralabels, $object, GETPOST('attribute')); $ret = $extrafields->setOptionalsFromPost($extralabels, $object, GETPOST('attribute'));
if ($ret < 0) $error++; if ($ret < 0) $error++;
if (! $error) if (! $error)
{ {
$result = $object->insertExtraFields(); $result = $object->insertExtraFields();
if ($result < 0) $error++; if ($result < 0)
{
setEventMessages($object->error, $object->errors, 'errors');
$error++;
}
} }
if ($error) $action = 'edit_extras'; if ($error) $action = 'edit_extras';
} }

View File

@ -230,7 +230,7 @@ dol_fiche_end();
$morehtmlcenter = ''; $morehtmlcenter = '';
if (! empty($conf->website->enabled)) { if (! empty($conf->website->enabled)) {
if (! empty($user->rights->societe->lire)) { if (! empty($user->rights->societe->lire)) {
$morehtmlcenter .= '<a class="butAction" href="' . DOL_URL_ROOT.'/website/websiteaccount_card.php?action=create' . $param . '">' . $langs->trans("AddWebsiteAccount") . '</a>'; $morehtmlcenter .= '<a class="butAction" href="' . DOL_URL_ROOT.'/website/websiteaccount_card.php?action=create&thirdpartyid='.$object->id.'&backtopage='.urlencode($_SERVER["PHP_SELF"].'id='.$object->id).'">' . $langs->trans("AddWebsiteAccount") . '</a>';
} else { } else {
$morehtmlcenter .= '<a class="butActionRefused" href="#">' . $langs->trans("AddAction") . '</a>'; $morehtmlcenter .= '<a class="butActionRefused" href="#">' . $langs->trans("AddAction") . '</a>';
} }
@ -378,7 +378,6 @@ print '<table class="tagtable liste'.($moreforfilter?" listwithfilterbefore":"")
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
foreach($objectwebsiteaccount->fields as $key => $val) foreach($objectwebsiteaccount->fields as $key => $val)
{ {
if (in_array($key, array('date_creation', 'tms', 'import_key', 'status'))) continue;
$align=''; $align='';
if (in_array($val['type'], array('date','datetime','timestamp'))) $align='center'; if (in_array($val['type'], array('date','datetime','timestamp'))) $align='center';
if (in_array($val['type'], array('timestamp'))) $align.=' nowrap'; if (in_array($val['type'], array('timestamp'))) $align.=' nowrap';
@ -412,16 +411,6 @@ if (is_array($extrafields->attribute_label) && count($extrafields->attribute_lab
$parameters=array('arrayfields'=>$arrayfields); $parameters=array('arrayfields'=>$arrayfields);
$reshook=$hookmanager->executeHooks('printFieldListOption', $parameters, $objectwebsiteaccount); // Note that $action and $object may have been modified by hook $reshook=$hookmanager->executeHooks('printFieldListOption', $parameters, $objectwebsiteaccount); // Note that $action and $object may have been modified by hook
print $hookmanager->resPrint; print $hookmanager->resPrint;
// Rest of fields search
foreach($objectwebsiteaccount->fields as $key => $val)
{
if (! in_array($key, array('date_creation', 'tms', 'import_key', 'status'))) continue;
$align='';
if (in_array($val['type'], array('date','datetime','timestamp'))) $align='center';
if (in_array($val['type'], array('timestamp'))) $align.=' nowrap';
if ($key == 'status') $align.=($align?' ':'').'center';
if (! empty($arrayfields['t.'.$key]['checked'])) print '<td class="liste_titre'.($align?' '.$align:'').'"><input type="text" class="flat maxwidth75" name="search_'.$key.'" value="'.dol_escape_htmltag($search[$key]).'"></td>';
}
// Action column // Action column
print '<td class="liste_titre" align="right">'; print '<td class="liste_titre" align="right">';
$searchpicto=$form->showFilterButtons(); $searchpicto=$form->showFilterButtons();
@ -435,7 +424,6 @@ print '</tr>'."\n";
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
foreach($objectwebsiteaccount->fields as $key => $val) foreach($objectwebsiteaccount->fields as $key => $val)
{ {
if (in_array($key, array('date_creation', 'tms', 'import_key', 'status'))) continue;
$align=''; $align='';
if (in_array($val['type'], array('date','datetime','timestamp'))) $align='center'; if (in_array($val['type'], array('date','datetime','timestamp'))) $align='center';
if (in_array($val['type'], array('timestamp'))) $align.='nowrap'; if (in_array($val['type'], array('timestamp'))) $align.='nowrap';
@ -460,16 +448,6 @@ if (is_array($extrafields->attribute_label) && count($extrafields->attribute_lab
$parameters=array('arrayfields'=>$arrayfields); $parameters=array('arrayfields'=>$arrayfields);
$reshook=$hookmanager->executeHooks('printFieldListTitle', $parameters, $objectwebsiteaccount); // Note that $action and $object may have been modified by hook $reshook=$hookmanager->executeHooks('printFieldListTitle', $parameters, $objectwebsiteaccount); // Note that $action and $object may have been modified by hook
print $hookmanager->resPrint; print $hookmanager->resPrint;
// Rest of fields title
foreach($objectwebsiteaccount->fields as $key => $val)
{
if (! in_array($key, array('date_creation', 'tms', 'import_key', 'status'))) continue;
$align='';
if (in_array($val['type'], array('date','datetime','timestamp'))) $align='center';
if (in_array($val['type'], array('timestamp'))) $align.=' nowrap';
if ($key == 'status') $align.=($align?' ':'').'center';
if (! empty($arrayfields['t.'.$key]['checked'])) print getTitleFieldOfList($arrayfields['t.'.$key]['label'], 0, $_SERVER['PHP_SELF'], 't.'.$key, '', $param, ($align?'class="'.$align.'"':''), $sortfield, $sortorder, $align.' ')."\n";
}
print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"],"",'','','align="center"',$sortfield,$sortorder,'maxwidthsearch ')."\n"; print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"],"",'','','align="center"',$sortfield,$sortorder,'maxwidthsearch ')."\n";
print '</tr>'."\n"; print '</tr>'."\n";
@ -502,7 +480,6 @@ while ($i < min($num, $limit))
print '<tr class="oddeven">'; print '<tr class="oddeven">';
foreach($objectwebsiteaccount->fields as $key => $val) foreach($objectwebsiteaccount->fields as $key => $val)
{ {
if (in_array($key, array('date_creation', 'tms', 'import_key', 'status'))) continue; // Discard some field output at end
$align=''; $align='';
if (in_array($val['type'], array('date','datetime','timestamp'))) $align='center'; if (in_array($val['type'], array('date','datetime','timestamp'))) $align='center';
if (in_array($val['type'], array('timestamp'))) $align.='nowrap'; if (in_array($val['type'], array('timestamp'))) $align.='nowrap';
@ -551,30 +528,6 @@ while ($i < min($num, $limit))
$parameters=array('arrayfields'=>$arrayfields, 'obj'=>$obj); $parameters=array('arrayfields'=>$arrayfields, 'obj'=>$obj);
$reshook=$hookmanager->executeHooks('printFieldListValue', $parameters, $objectwebsiteaccount); // Note that $action and $object may have been modified by hook $reshook=$hookmanager->executeHooks('printFieldListValue', $parameters, $objectwebsiteaccount); // Note that $action and $object may have been modified by hook
print $hookmanager->resPrint; print $hookmanager->resPrint;
// Rest of fields
foreach($objectwebsiteaccount->fields as $key => $val)
{
if (! in_array($key, array('date_creation', 'tms', 'import_key', 'status'))) continue; // Keep only field not yet already output
$align='';
if (in_array($val['type'], array('date','datetime','timestamp'))) $align.=($align?' ':'').'center';
if (in_array($val['type'], array('timestamp'))) $align.=($align?' ':'').'nowrap';
if ($key == 'status') $align.=($align?' ':'').'center';
if (! empty($arrayfields['t.'.$key]['checked']))
{
print '<td'.($align?' class="'.$align.'"':'').'>';
if (in_array($val['type'], array('date'))) print dol_print_date($db->jdate($obj->$key), 'day', 'tzuser');
elseif (in_array($val['type'], array('datetime','timestamp'))) print dol_print_date($db->jdate($obj->$key), 'dayhour', 'tzuser');
elseif ($key == 'status') print $objectwebsiteaccount->getLibStatut(3);
else print $obj->$key;
print '</td>';
if (! $i) $totalarray['nbfield']++;
if (! empty($val['isameasure']))
{
if (! $i) $totalarray['pos'][$totalarray['nbfield']]='t.'.$key;
$totalarray['val']['t.'.$key] += $obj->$key;
}
}
}
// Action column // Action column
print '<td class="nowrap" align="center">'; print '<td class="nowrap" align="center">';
if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined

View File

@ -32,7 +32,7 @@ $form = new Form($db);
// List of supported format // List of supported format
$tmptype2label=ExtraFields::$type2label; $tmptype2label=ExtraFields::$type2label;
$type2label=array(''); $type2label=array('');
foreach ($tmptype2label as $key => $val) $type2label[$key]=$langs->trans($val); foreach ($tmptype2label as $key => $val) $type2label[$key]=$langs->transnoentitiesnoconv($val);
$action=GETPOST('action', 'alpha'); $action=GETPOST('action', 'alpha');
$attrname=GETPOST('attrname', 'alpha'); $attrname=GETPOST('attrname', 'alpha');

View File

@ -39,7 +39,7 @@ $form = new Form($db);
// List of supported format // List of supported format
$tmptype2label=ExtraFields::$type2label; $tmptype2label=ExtraFields::$type2label;
$type2label=array(''); $type2label=array('');
foreach ($tmptype2label as $key => $val) $type2label[$key]=$langs->trans($val); foreach ($tmptype2label as $key => $val) $type2label[$key]=$langs->transnoentitiesnoconv($val);
$action=GETPOST('action', 'alpha'); $action=GETPOST('action', 'alpha');
$attrname=GETPOST('attrname', 'alpha'); $attrname=GETPOST('attrname', 'alpha');

View File

@ -930,11 +930,17 @@ if (empty($reshook))
$extralabels = $extrafields->fetch_name_optionals_label($object->table_element); $extralabels = $extrafields->fetch_name_optionals_label($object->table_element);
$ret = $extrafields->setOptionalsFromPost($extralabels, $object, GETPOST('attribute')); $ret = $extrafields->setOptionalsFromPost($extralabels, $object, GETPOST('attribute'));
if ($ret < 0) $error++; if ($ret < 0) $error++;
if (! $error) if (! $error)
{ {
$result = $object->insertExtraFields(); $result = $object->insertExtraFields();
if ($result < 0) $error++; if ($result < 0)
{
setEventMessages($object->error, $object->errors, 'errors');
$error++;
}
} }
if ($error) $action = 'edit_extras'; if ($error) $action = 'edit_extras';
} }
} }

View File

@ -38,7 +38,7 @@ $form = new Form($db);
// List of supported format // List of supported format
$tmptype2label=ExtraFields::$type2label; $tmptype2label=ExtraFields::$type2label;
$type2label=array(''); $type2label=array('');
foreach ($tmptype2label as $key => $val) $type2label[$key]=$langs->trans($val); foreach ($tmptype2label as $key => $val) $type2label[$key]=$langs->transnoentitiesnoconv($val);
$action=GETPOST('action', 'alpha'); $action=GETPOST('action', 'alpha');
$attrname=GETPOST('attrname', 'alpha'); $attrname=GETPOST('attrname', 'alpha');

View File

@ -37,7 +37,7 @@ $form = new Form($db);
// List of supported format // List of supported format
$tmptype2label=ExtraFields::$type2label; $tmptype2label=ExtraFields::$type2label;
$type2label=array(''); $type2label=array('');
foreach ($tmptype2label as $key => $val) $type2label[$key]=$langs->trans($val); foreach ($tmptype2label as $key => $val) $type2label[$key]=$langs->transnoentitiesnoconv($val);
$action=GETPOST('action', 'alpha'); $action=GETPOST('action', 'alpha');
$attrname=GETPOST('attrname', 'alpha'); $attrname=GETPOST('attrname', 'alpha');

View File

@ -58,8 +58,8 @@ class WebsiteAccount extends CommonObject
/** /**
* 'type' if the field format. * 'type' if the field format.
* 'label' the translation key. * 'label' the translation key.
* 'enabled' is a condition when the filed must be managed. * 'enabled' is a condition when the field must be managed.
* 'visible' says if field is visible in list (-1 means not shown by default but can be added into list to be viewed). * 'visible' says if field is visible in list (Examples: 0=Not visible, 1=Visible on list and forms, 2=Visible on list only. Using a negative value means field is not shown by default on list but can be selected for viewing)
* 'notnull' is set to 1 if not null in database. Set to -1 if we must set data to null if empty ('' or 0). * 'notnull' is set to 1 if not null in database. Set to -1 if we must set data to null if empty ('' or 0).
* 'index' if we want an index in database. * 'index' if we want an index in database.
* 'foreignkey'=>'tablename.field' if the field is a foreign key (it is recommanded to name the field fk_...). * 'foreignkey'=>'tablename.field' if the field is a foreign key (it is recommanded to name the field fk_...).
@ -75,24 +75,27 @@ class WebsiteAccount extends CommonObject
* @var array Array with all fields and their property. Do not use it as a static var. It may be modified by constructor. * @var array Array with all fields and their property. Do not use it as a static var. It may be modified by constructor.
*/ */
public $fields=array( public $fields=array(
'rowid' => array('type'=>'integer', 'label'=>'TechnicalID', 'visible'=>-1, 'enabled'=>1, 'position'=>1, 'notnull'=>1, 'index'=>1, 'comment'=>'Id',), 'rowid' => array('type'=>'integer', 'label'=>'TechnicalID', 'visible'=>-2, 'enabled'=>1, 'position'=>1, 'notnull'=>1, 'index'=>1, 'comment'=>'Id',),
'login' => array('type'=>'varchar(64)', 'label'=>'Ref', 'visible'=>1, 'enabled'=>1, 'position'=>10, 'notnull'=>1, 'index'=>1, 'searchall'=>1, 'comment'=>'Login',), 'login' => array('type'=>'varchar(64)', 'label'=>'Login', 'visible'=>1, 'enabled'=>1, 'position'=>10, 'notnull'=>1, 'index'=>1, 'searchall'=>1, 'comment'=>'Login',),
'label' => array('type'=>'varchar(255)', 'label'=>'Label', 'visible'=>1, 'enabled'=>1, 'position'=>30, 'notnull'=>-1, 'searchall'=>1,), 'pass_crypted' => array('type'=>'varchar(128)', 'label'=>'Password', 'visible'=>1, 'enabled'=>1, 'position'=>30, 'notnull'=>-1, 'searchall'=>1,),
'note_public' => array('type'=>'text', 'label'=>'NotePublic', 'visible'=>-1, 'enabled'=>1, 'position'=>45, 'notnull'=>-1,), 'pass_temp' => array('type'=>'varchar(128)', 'label'=>'Temp', 'visible'=>0, 'enabled'=>0, 'position'=>30, 'notnull'=>-1,),
'note_private' => array('type'=>'text', 'label'=>'NotePrivate', 'visible'=>-1, 'enabled'=>1, 'position'=>46, 'notnull'=>-1,), 'date_last_login' => array('type'=>'datetime', 'label'=>'LastConnexion', 'visible'=>2, 'enabled'=>1, 'position'=>50, 'notnull'=>0,),
'date_creation' => array('type'=>'datetime', 'label'=>'DateCreation', 'visible'=>-1, 'enabled'=>1, 'position'=>500, 'notnull'=>1,), 'date_previous_login' => array('type'=>'datetime', 'label'=>'PreviousConnexion', 'visible'=>2, 'enabled'=>1, 'position'=>51, 'notnull'=>0,),
'tms' => array('type'=>'timestamp', 'label'=>'DateModification', 'visible'=>-1, 'enabled'=>1, 'position'=>500, 'notnull'=>1,), //'note_public' => array('type'=>'text', 'label'=>'NotePublic', 'visible'=>-1, 'enabled'=>1, 'position'=>45, 'notnull'=>-1,),
'fk_user_creat' => array('type'=>'integer', 'label'=>'UserAuthor', 'visible'=>-1, 'enabled'=>1, 'position'=>500, 'notnull'=>1,), //'note_private' => array('type'=>'text', 'label'=>'NotePrivate', 'visible'=>-1, 'enabled'=>1, 'position'=>46, 'notnull'=>-1,),
'fk_user_modif' => array('type'=>'integer', 'label'=>'UserModif', 'visible'=>-1, 'enabled'=>1, 'position'=>500, 'notnull'=>-1,), 'date_creation' => array('type'=>'datetime', 'label'=>'DateCreation', 'visible'=>-2, 'enabled'=>1, 'position'=>500, 'notnull'=>1,),
'import_key' => array('type'=>'varchar(14)', 'label'=>'ImportId', 'visible'=>-1, 'enabled'=>1, 'position'=>1000, 'notnull'=>-1, 'index'=>1,), 'tms' => array('type'=>'timestamp', 'label'=>'DateModification', 'visible'=>-2, 'enabled'=>1, 'position'=>500, 'notnull'=>1,),
'status' => array('type'=>'integer', 'label'=>'Status', 'visible'=>1, 'enabled'=>1, 'position'=>1000, 'notnull'=>-1, 'index'=>1, 'arrayofkeyval'=>array('0'=>'Disabled', '1'=>'Active')), 'fk_user_creat' => array('type'=>'integer', 'label'=>'UserAuthor', 'visible'=>-2, 'enabled'=>1, 'position'=>500, 'notnull'=>1,),
'fk_soc' => array('type'=>'integer', 'label'=>'ThirdParty', 'visible'=>1, 'enabled'=>1, 'position'=>50, 'notnull'=>-1, 'index'=>1, 'searchall'=>1,), 'fk_user_modif' => array('type'=>'integer', 'label'=>'UserModif', 'visible'=>-2, 'enabled'=>1, 'position'=>500, 'notnull'=>-1,),
'import_key' => array('type'=>'varchar(14)', 'label'=>'ImportId', 'visible'=>-2, 'enabled'=>1, 'position'=>1000, 'notnull'=>-1, 'index'=>1,),
'status' => array('type'=>'integer', 'label'=>'Status', 'visible'=>1, 'enabled'=>1, 'position'=>1000, 'notnull'=>-1, 'index'=>1, 'default'=>1, 'arrayofkeyval'=>array('1'=>'Active','0'=>'Disabled')),
'fk_soc' => array('type'=>'integer:Societe:societe/class/societe.class.php', 'label'=>'ThirdParty', 'visible'=>1, 'enabled'=>1, 'position'=>50, 'notnull'=>-1, 'index'=>1, 'searchall'=>1,),
); );
public $rowid; public $rowid;
public $login; public $login;
public $label; public $pass_crypted;
public $note_public; public $date_last_login;
public $note_private; public $date_previous_login;
public $date_creation; public $date_creation;
public $tms; public $tms;
public $fk_user_creat; public $fk_user_creat;

View File

@ -0,0 +1,515 @@
<?php
/* Copyright (C) 2017 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) ---Put here your own copyright and developer email---
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* \file htdocs/Website/websiteaccount_card.php
* \ingroup website
* \brief Page to create/edit/view websiteaccount
*/
//if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER','1');
//if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1');
//if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1');
//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1');
//if (! defined('NOSCANGETFORINJECTION')) define('NOSCANGETFORINJECTION','1'); // Do not check anti CSRF attack test
//if (! defined('NOSCANPOSTFORINJECTION')) define('NOSCANPOSTFORINJECTION','1'); // Do not check anti CSRF attack test
//if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK','1'); // Do not check anti CSRF attack test done when option MAIN_SECURITY_CSRF_WITH_TOKEN is on.
//if (! defined('NOSTYLECHECK')) define('NOSTYLECHECK','1'); // Do not check style html tag into posted data
//if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); // Do not check anti POST attack test
//if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); // If there is no need to load and show top and left menu
//if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); // If we don't need to load the html.form.class.php
//if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); // Do not load ajax.lib.php library
//if (! defined("NOLOGIN")) define("NOLOGIN",'1'); // If this page is public (can be called outside logged session)
// Load Dolibarr environment
$res=0;
// Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined)
if (! $res && ! empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) $res=@include($_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php");
// Try main.inc.php into web root detected using web root caluclated from SCRIPT_FILENAME
$tmp=empty($_SERVER['SCRIPT_FILENAME'])?'':$_SERVER['SCRIPT_FILENAME'];$tmp2=realpath(__FILE__); $i=strlen($tmp)-1; $j=strlen($tmp2)-1;
while($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i]==$tmp2[$j]) { $i--; $j--; }
if (! $res && $i > 0 && file_exists(substr($tmp, 0, ($i+1))."/main.inc.php")) $res=@include(substr($tmp, 0, ($i+1))."/main.inc.php");
if (! $res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i+1)))."/main.inc.php")) $res=@include(dirname(substr($tmp, 0, ($i+1)))."/main.inc.php");
// Try main.inc.php using relative path
if (! $res && file_exists("../main.inc.php")) $res=@include("../main.inc.php");
if (! $res && file_exists("../../main.inc.php")) $res=@include("../../main.inc.php");
if (! $res && file_exists("../../../main.inc.php")) $res=@include("../../../main.inc.php");
if (! $res) die("Include of main fails");
include_once(DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php');
include_once(DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php');
dol_include_once('/website/class/websiteaccount.class.php');
//dol_include_once('/website/lib/websiteaccount.lib.php');
// Load traductions files requiredby by page
$langs->loadLangs(array("website","other"));
// Get parameters
$id = GETPOST('id', 'int');
$ref = GETPOST('ref', 'alpha');
$action = GETPOST('action', 'alpha');
$cancel = GETPOST('cancel', 'aZ09');
$backtopage = GETPOST('backtopage', 'alpha');
$thirdpartyid = GETPOST('thirdpartyid', 'int');
// Initialize technical objects
$object=new WebsiteAccount($db);
$extrafields = new ExtraFields($db);
$diroutputmassaction=$conf->website->dir_output . '/temp/massgeneration/'.$user->id;
$hookmanager->initHooks(array('websiteaccountcard')); // Note that conf->hooks_modules contains array
// Fetch optionals attributes and labels
$extralabels = $extrafields->fetch_name_optionals_label('websiteaccount');
$search_array_options=$extrafields->getOptionalsFromPost($extralabels,'','search_');
// Initialize array of search criterias
$search_all=trim(GETPOST("search_all",'alpha'));
$search=array();
foreach($object->fields as $key => $val)
{
if (GETPOST('search_'.$key,'alpha')) $search[$key]=GETPOST('search_'.$key,'alpha');
}
if (empty($action) && empty($id) && empty($ref)) $action='view';
// Security check - Protection if external user
//if ($user->societe_id > 0) access_forbidden();
//if ($user->societe_id > 0) $socid = $user->societe_id;
//$result = restrictedArea($user, 'website', $id);
// fetch optionals attributes and labels
$extralabels = $extrafields->fetch_name_optionals_label($object->table_element);
// Load object
include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once // Must be include, not include_once. Include fetch and fetch_thirdparty but not fetch_optionals
/*
* Actions
*/
$parameters=array();
$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))
{
$error=0;
$permissiontoadd = $user->rights->website->write;
$permissiontodelete = $user->rights->website->delete;
$backurlforlist = dol_buildpath('/website/websiteaccount_list.php',1);
// Actions cancel, add, update or delete
include DOL_DOCUMENT_ROOT.'/core/actions_addupdatedelete.inc.php';
// Actions when printing a doc from card
include DOL_DOCUMENT_ROOT.'/core/actions_printing.inc.php';
// Actions to send emails
$trigger_name='MYOBJECT_SENTBYMAIL';
$autocopy='MAIN_MAIL_AUTOCOPY_MYOBJECT_TO';
$trackid='websiteaccount'.$object->id;
include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php';
}
/*
* View
*/
$form=new Form($db);
$formfile=new FormFile($db);
llxHeader('','WebsiteAccount','');
// Example : Adding jquery code
print '<script type="text/javascript" language="javascript">
jQuery(document).ready(function() {
function init_myfunc()
{
jQuery("#myid").removeAttr(\'disabled\');
jQuery("#myid").attr(\'disabled\',\'disabled\');
}
init_myfunc();
jQuery("#mybutton").click(function() {
init_myfunc();
});
});
</script>';
// Part to create
if ($action == 'create')
{
print load_fiche_titre($langs->trans("NewObject", $langs->transnoentitiesnoconv("WebsiteAccount")));
print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="add">';
print '<input type="hidden" name="backtopage" value="'.$backtopage.'">';
print '<input type="hidden" name="thirdpartyid" value="'.$thirdpartyid.'">';
dol_fiche_head(array(), '');
print '<table class="border centpercent">'."\n";
foreach($object->fields as $key => $val)
{
if (abs($val['visible']) != 1) continue; // Discard such field from form
if (array_key_exists('enabled', $val) && isset($val['enabled']) && ! $val['enabled']) continue; // We don't want this field
print '<tr id="field_'.$key.'">';
print '<td';
print ' class="titlefieldcreate';
if ($val['notnull'] > 0) print ' fieldrequired';
if ($val['type'] == 'text') print ' tdtop';
print '"';
print '>';
print $langs->trans($val['label']);
print '</td>';
print '<td>';
if (in_array($val['type'], array('int', 'integer'))) $value = GETPOST($key, 'int');
elseif ($val['type'] == 'text') $value = GETPOST($key, 'none');
else $value = GETPOST($key, 'alpha');
print $object->showInputField($val, $key, $value, '', '', '', 0, 0);
print '</td>';
print '</tr>';
}
// Other attributes
include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_add.tpl.php';
print '</table>'."\n";
dol_fiche_end();
print '<div class="center">';
print '<input type="submit" class="button" name="add" value="'.dol_escape_htmltag($langs->trans("Create")).'">';
print '&nbsp; ';
print '<input type="button" class="button" name="cancel" value="'.dol_escape_htmltag($langs->trans("Cancel")).'" onclick="javascript:history.go(-1)">'; // Cancel for create doe not post form
print '</div>';
print '</form>';
}
// Part to edit record
if (($id || $ref) && $action == 'edit')
{
print load_fiche_titre($langs->trans("WebsiteAccount"));
print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
print '<input type="hidden" name="action" value="update">';
print '<input type="hidden" name="backtopage" value="'.$backtopage.'">';
print '<input type="hidden" name="id" value="'.$object->id.'">';
dol_fiche_head();
print '<table class="border centpercent">'."\n";
foreach($object->fields as $key => $val)
{
if (abs($val['visible']) != 1) continue; // Discard such field from form
if (array_key_exists('enabled', $val) && isset($val['enabled']) && ! $val['enabled']) continue; // We don't want this field
print '<tr><td';
print ' class="titlefieldcreate';
if ($val['notnull'] > 0) print ' fieldrequired';
if ($val['type'] == 'text') print ' tdtop';
print '"';
print '>'.$langs->trans($val['label']).'</td>';
print '<td>';
$defaultcss='minwidth100';
if ($val['type'] == 'text')
{
print '<textarea class="flat quatrevingtpercent" rows="'.ROWS_4.'" name="'.$key.'">';
print GETPOST($key,'none')?GETPOST($key,'none'):$object->$key;
print '</textarea>';
}
elseif (is_array($val['arrayofkeyval']))
{
print $form->selectarray($key, $val['arrayofkeyval'], GETPOST($key, 'int')!=''?GETPOST($key, 'int'):$object->$key);
}
else
{
$cssforinput = empty($val['css'])?$defaultcss:$val['css'];
print '<input class="flat'.($cssforinput?' '.$cssforinput:'').'" type="text" name="'.$key.'" value="'.(GETPOST($key,'alpha')?GETPOST($key,'alpha'):$object->$key).'">';
}
print '</td>';
print '</tr>';
}
// Other attributes
include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_edit.tpl.php';
print '</table>';
dol_fiche_end();
print '<div class="center"><input type="submit" class="button" name="save" value="'.$langs->trans("Save").'">';
print ' &nbsp; <input type="submit" class="button" name="cancel" value="'.$langs->trans("Cancel").'">';
print '</div>';
print '</form>';
}
// Part to show record
if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'create')))
{
$res = $object->fetch_optionals($object->id, $extralabels);
$head = websiteaccountPrepareHead($object);
dol_fiche_head($head, 'card', $langs->trans("WebsiteAccount"), -1, 'websiteaccount@website');
$formconfirm = '';
// Confirmation to delete
if ($action == 'delete') {
$formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('DeleteWebsiteAccount'), $langs->trans('ConfirmDeleteWebsiteAccount'), 'confirm_delete', '', 0, 1);
}
// Confirmation of action xxxx
if ($action == 'xxx')
{
$formquestion=array();
/*
$formquestion = array(
// 'text' => $langs->trans("ConfirmClone"),
// array('type' => 'checkbox', 'name' => 'clone_content', 'label' => $langs->trans("CloneMainAttributes"), 'value' => 1),
// array('type' => 'checkbox', 'name' => 'update_prices', 'label' => $langs->trans("PuttingPricesUpToDate"), 'value' => 1),
// array('type' => 'other', 'name' => 'idwarehouse', 'label' => $langs->trans("SelectWarehouseForStockDecrease"), 'value' => $formproduct->selectWarehouses(GETPOST('idwarehouse')?GETPOST('idwarehouse'):'ifone', 'idwarehouse', '', 1)));
}*/
$formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('XXX'), $text, 'confirm_xxx', $formquestion, 0, 1, 220);
}
if (! $formconfirm) {
$parameters = array('lineid' => $lineid);
$reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
if (empty($reshook)) $formconfirm.=$hookmanager->resPrint;
elseif ($reshook > 0) $formconfirm=$hookmanager->resPrint;
}
// Print form confirm
print $formconfirm;
// Object card
// ------------------------------------------------------------
$linkback = '<a href="' .dol_buildpath('/website/websiteaccount_list.php',1) . '?restore_lastsearch_values=1' . (! empty($socid) ? '&socid=' . $socid : '') . '">' . $langs->trans("BackToList") . '</a>';
$morehtmlref='<div class="refidno">';
/*
// Ref bis
$morehtmlref.=$form->editfieldkey("RefBis", 'ref_client', $object->ref_client, $object, $user->rights->website->creer, 'string', '', 0, 1);
$morehtmlref.=$form->editfieldval("RefBis", 'ref_client', $object->ref_client, $object, $user->rights->website->creer, 'string', '', null, null, '', 1);
// Thirdparty
$morehtmlref.='<br>'.$langs->trans('ThirdParty') . ' : ' . $soc->getNomUrl(1);
// Project
if (! empty($conf->projet->enabled))
{
$langs->load("projects");
$morehtmlref.='<br>'.$langs->trans('Project') . ' ';
if ($user->rights->website->creer)
{
if ($action != 'classify')
{
$morehtmlref.='<a href="' . $_SERVER['PHP_SELF'] . '?action=classify&amp;id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : ';
if ($action == 'classify') {
//$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1);
$morehtmlref.='<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">';
$morehtmlref.='<input type="hidden" name="action" value="classin">';
$morehtmlref.='<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
$morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1);
$morehtmlref.='<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">';
$morehtmlref.='</form>';
} else {
$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1);
}
}
} else {
if (! empty($object->fk_project)) {
$proj = new Project($db);
$proj->fetch($object->fk_project);
$morehtmlref.='<a href="'.DOL_URL_ROOT.'/projet/card.php?id=' . $object->fk_project . '" title="' . $langs->trans('ShowProject') . '">';
$morehtmlref.=$proj->ref;
$morehtmlref.='</a>';
} else {
$morehtmlref.='';
}
}
}
*/
$morehtmlref.='</div>';
dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
print '<div class="fichecenter">';
print '<div class="fichehalfleft">';
print '<div class="underbanner clearboth"></div>';
print '<table class="border centpercent">'."\n";
foreach($object->fields as $key => $val)
{
if (abs($val['visible']) != 1) continue; // Discard such field from form
if (array_key_exists('enabled', $val) && isset($val['enabled']) && ! $val['enabled']) continue; // We don't want this field
print '<tr><td';
print ' class="titlefield';
if ($val['notnull'] > 0) print ' fieldrequired';
print '"';
print '>'.$langs->trans($val['label']).'</td>';
print '<td>';
print dol_escape_htmltag($object->$key, 1, 1);
print '</td>';
print '</tr>';
//if ($key == 'targetsrcfile3') break; // key used for break on second column
}
print '</table>';
print '</div>';
print '<div class="fichehalfright">';
print '<div class="ficheaddleft">';
print '<div class="underbanner clearboth"></div>';
print '<table class="border centpercent">';
$alreadyoutput = 1;
foreach($object->fields as $key => $val)
{
if ($alreadyoutput)
{
//if ($key == 'targetsrcfile3') $alreadyoutput = 0; // key used for break on second column
continue;
}
if (in_array($key, array('rowid', 'ref', 'entity', 'note_public', 'note_private', 'date_creation', 'tms', 'fk_user_creat', 'fk_user_modif', 'import_key', 'status'))) continue;
print '<tr><td';
print ' class="titlefield';
if ($val['notnull'] > 0) print ' fieldrequired';
print '"';
print '>'.$langs->trans($val['label']).'</td>';
print '<td>';
print dol_escape_htmltag($object->$key, 1, 1);
print '</td>';
print '</tr>';
}
// Other attributes
include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php';
print '</table>';
print '</div>';
print '</div>';
print '</div>';
print '<div class="clearboth"></div><br>';
dol_fiche_end();
// Buttons for actions
if ($action != 'presend' && $action != 'editline') {
print '<div class="tabsAction">'."\n";
$parameters=array();
$reshook=$hookmanager->executeHooks('addMoreActionsButtons',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
if (empty($reshook))
{
// Send
print '<div class="inline-block divButAction"><a class="butAction" href="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '&action=presend&mode=init#formmailbeforetitle">' . $langs->trans('SendByMail') . '</a></div>'."\n";
if ($user->rights->website->write)
{
print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=edit">'.$langs->trans("Modify").'</a></div>'."\n";
}
/*
if ($user->rights->sellyoursaas->create)
{
if ($object->status == 1)
{
print '<div class="inline-block divButAction"><a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=disable">'.$langs->trans("Disable").'</a></div>'."\n";
}
else
{
print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=enable">'.$langs->trans("Enable").'</a></div>'."\n";
}
}
*/
if ($user->rights->website->delete)
{
print '<div class="inline-block divButAction"><a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=delete">'.$langs->trans('Delete').'</a></div>'."\n";
}
}
print '</div>'."\n";
}
// Select mail models is same action as presend
if (GETPOST('modelselected')) {
$action = 'presend';
}
if ($action != 'presend')
{
print '<div class="fichecenter"><div class="fichehalfleft">';
print '<a name="builddoc"></a>'; // ancre
// Documents
$comref = dol_sanitizeFileName($object->ref);
$relativepath = $comref . '/' . $comref . '.pdf';
$filedir = $conf->website->dir_output . '/' . $comref;
$urlsource = $_SERVER["PHP_SELF"] . "?id=" . $object->id;
$genallowed = $user->rights->website->read; // If you can read, you can build the PDF to read content
$delallowed = $user->rights->website->create; // If you can create/edit, you can remove a file on card
print $formfile->showdocuments('website', $comref, $filedir, $urlsource, $genallowed, $delallowed, $object->modelpdf, 1, 0, 0, 28, 0, '', '', '', $soc->default_lang);
// Show links to link elements
$linktoelem = $form->showLinkToObjectBlock($object, null, array('websiteaccount'));
$somethingshown = $form->showLinkedObjectBlock($object, $linktoelem);
print '</div><div class="fichehalfright"><div class="ficheaddleft">';
$MAXEVENT = 10;
// List of actions on element
include_once DOL_DOCUMENT_ROOT . '/core/class/html.formactions.class.php';
$formactions = new FormActions($db);
$somethingshown = $formactions->showactions($object, 'websiteaccount', $socid, 1, '', $MAXEVENT);
print '</div></div></div>';
}
// Presend form
$modelmail='websiteaccount';
$defaulttopic='Information';
$diroutput = $conf->website->dir_output;
$trackid = 'websiteaccount'.$object->id;
include DOL_DOCUMENT_ROOT.'/core/tpl/card_presend.tpl.php';
}
// End of page
llxFooter();
$db->close();