Merge branch 'develop' of https://github.com/Dolibarr/dolibarr.git into develop
This commit is contained in:
commit
852a657e89
@ -1159,14 +1159,11 @@ else if ($action == 'update_extras')
|
||||
{
|
||||
// Fill array 'array_options' with data from update form
|
||||
$extralabels=$extrafields->fetch_name_optionals_label($object->table_element);
|
||||
$ret = $extrafields->setOptionalsFromPost($extralabels,$object);
|
||||
$ret = $extrafields->setOptionalsFromPost($extralabels,$object,GETPOST('attribute'));
|
||||
if($ret < 0) $error++;
|
||||
|
||||
if($ret < 0) {
|
||||
$error++;
|
||||
$action = 'edit_extras';
|
||||
}
|
||||
|
||||
if(!$error) {
|
||||
if (! $error)
|
||||
{
|
||||
// Actions on extra fields (by external module or standard code)
|
||||
// FIXME le hook fait double emploi avec le trigger !!
|
||||
$hookmanager->initHooks(array('propaldao'));
|
||||
@ -1174,17 +1171,16 @@ else if ($action == 'update_extras')
|
||||
$reshook=$hookmanager->executeHooks('insertExtraFields',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks
|
||||
if (empty($reshook))
|
||||
{
|
||||
if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used
|
||||
$result=$object->insertExtraFields();
|
||||
if ($result < 0)
|
||||
{
|
||||
$result=$object->insertExtraFields();
|
||||
if ($result < 0)
|
||||
{
|
||||
$error++;
|
||||
}
|
||||
$error++;
|
||||
}
|
||||
}
|
||||
else if ($reshook < 0) $error++;
|
||||
}
|
||||
|
||||
if ($error) $action = 'edit_extras';
|
||||
}
|
||||
|
||||
if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB) && $user->rights->propal->creer)
|
||||
@ -1893,20 +1889,12 @@ else
|
||||
print '</tr>';
|
||||
}
|
||||
|
||||
// Other attributes
|
||||
// Other attributes (TODO Move this into an include)
|
||||
$res=$object->fetch_optionals($object->id,$extralabels);
|
||||
$parameters=array('colspan' => ' colspan="3"');
|
||||
$reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
|
||||
if (empty($reshook) && ! empty($extrafields->attribute_label))
|
||||
{
|
||||
if ($action == 'edit_extras')
|
||||
{
|
||||
print '<form enctype="multipart/form-data" action="'.$_SERVER["PHP_SELF"].'" method="post" name="formsoc">';
|
||||
print '<input type="hidden" name="action" value="update_extras">';
|
||||
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
||||
print '<input type="hidden" name="id" value="'.$object->id.'">';
|
||||
}
|
||||
|
||||
foreach($extrafields->attribute_label as $key=>$label)
|
||||
{
|
||||
if ($action == 'edit_extras') {
|
||||
@ -1929,35 +1917,28 @@ else
|
||||
$value = isset($_POST["options_".$key])?dol_mktime($_POST["options_".$key."hour"], $_POST["options_".$key."min"], 0, $_POST["options_".$key."month"], $_POST["options_".$key."day"], $_POST["options_".$key."year"]):$db->jdate($object->array_options['options_'.$key]);
|
||||
}
|
||||
|
||||
if ($action == 'edit_extras' && $user->rights->propal->creer)
|
||||
if ($action == 'edit_extras' && $user->rights->propal->creer && GETPOST('attribute') == $key)
|
||||
{
|
||||
print '<form enctype="multipart/form-data" action="'.$_SERVER["PHP_SELF"].'" method="post" name="formsoc">';
|
||||
print '<input type="hidden" name="action" value="update_extras">';
|
||||
print '<input type="hidden" name="attribute" value="'.$key.'">';
|
||||
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
||||
print '<input type="hidden" name="id" value="'.$object->id.'">';
|
||||
|
||||
print $extrafields->showInputField($key,$value);
|
||||
|
||||
print '<input type="submit" class="button" value="'.$langs->trans('Modify').'">';
|
||||
|
||||
print '</form>';
|
||||
}
|
||||
else
|
||||
{
|
||||
print $extrafields->showOutputField($key,$value);
|
||||
if ($object->statut == 0 && $user->rights->propal->creer) print '<a href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&action=edit_extras&attribute='.$key.'">'.img_picto('','edit').' '.$langs->trans('Modify').'</a>';
|
||||
}
|
||||
print '</td></tr>'."\n";
|
||||
}
|
||||
}
|
||||
|
||||
if(count($extrafields->attribute_label) > 0) {
|
||||
|
||||
if ($action == 'edit_extras' && $user->rights->propal->creer)
|
||||
{
|
||||
print '<tr><td></td><td colspan="5">';
|
||||
print '<input type="submit" class="button" value="'.$langs->trans('Modify').'">';
|
||||
print '</form>';
|
||||
print '</td></tr>';
|
||||
|
||||
}
|
||||
else {
|
||||
if ($object->statut == 0 && $user->rights->propal->creer)
|
||||
{
|
||||
print '<tr><td></td><td><a href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&action=edit_extras">'.img_picto('','edit').' '.$langs->trans('Modify').'</a></td></tr>';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Amount HT
|
||||
|
||||
@ -1179,12 +1179,11 @@ else if ($action == 'update_extras')
|
||||
{
|
||||
// Fill array 'array_options' with data from update form
|
||||
$extralabels=$extrafields->fetch_name_optionals_label($object->table_element);
|
||||
$ret = $extrafields->setOptionalsFromPost($extralabels,$object);
|
||||
$ret = $extrafields->setOptionalsFromPost($extralabels,$object,GETPOST('attribute'));
|
||||
if($ret < 0) $error++;
|
||||
|
||||
if($ret < 0)
|
||||
$error++;
|
||||
|
||||
if(!$error) {
|
||||
if (! $error)
|
||||
{
|
||||
// Actions on extra fields (by external module or standard code)
|
||||
// FIXME le hook fait double emploi avec le trigger !!
|
||||
$hookmanager->initHooks(array('orderdao'));
|
||||
@ -1192,22 +1191,16 @@ else if ($action == 'update_extras')
|
||||
$reshook=$hookmanager->executeHooks('insertExtraFields',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks
|
||||
if (empty($reshook))
|
||||
{
|
||||
if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used
|
||||
$result=$object->insertExtraFields();
|
||||
if ($result < 0)
|
||||
{
|
||||
$result=$object->insertExtraFields();
|
||||
if ($result < 0)
|
||||
{
|
||||
$error++;
|
||||
}
|
||||
$error++;
|
||||
}
|
||||
}
|
||||
else if ($reshook < 0) $error++;
|
||||
}
|
||||
else
|
||||
{
|
||||
$action = 'edit_extras';
|
||||
}
|
||||
|
||||
|
||||
if ($error) $action = 'edit_extras';
|
||||
}
|
||||
|
||||
/*
|
||||
@ -2208,20 +2201,12 @@ else
|
||||
print '</tr>';
|
||||
}
|
||||
|
||||
// Other attributes
|
||||
// Other attributes (TODO Move this into an include)
|
||||
$res=$object->fetch_optionals($object->id,$extralabels);
|
||||
$parameters=array('colspan' => ' colspan="3"');
|
||||
$reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
|
||||
if (empty($reshook) && ! empty($extrafields->attribute_label))
|
||||
{
|
||||
if ($action == 'edit_extras')
|
||||
{
|
||||
print '<form enctype="multipart/form-data" action="'.$_SERVER["PHP_SELF"].'" method="post" name="formsoc">';
|
||||
print '<input type="hidden" name="action" value="update_extras">';
|
||||
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
||||
print '<input type="hidden" name="id" value="'.$object->id.'">';
|
||||
}
|
||||
|
||||
foreach($extrafields->attribute_label as $key=>$label)
|
||||
{
|
||||
if ($action == 'edit_extras') {
|
||||
@ -2244,35 +2229,27 @@ else
|
||||
$value = isset($_POST["options_".$key])?dol_mktime($_POST["options_".$key."hour"], $_POST["options_".$key."min"], 0, $_POST["options_".$key."month"], $_POST["options_".$key."day"], $_POST["options_".$key."year"]):$db->jdate($object->array_options['options_'.$key]);
|
||||
}
|
||||
|
||||
if ($action == 'edit_extras' && $user->rights->commande->creer)
|
||||
if ($action == 'edit_extras' && $user->rights->commande->creer && GETPOST('attribute') == $key)
|
||||
{
|
||||
print '<form enctype="multipart/form-data" action="'.$_SERVER["PHP_SELF"].'" method="post" name="formsoc">';
|
||||
print '<input type="hidden" name="action" value="update_extras">';
|
||||
print '<input type="hidden" name="attribute" value="'.$key.'">';
|
||||
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
||||
print '<input type="hidden" name="id" value="'.$object->id.'">';
|
||||
|
||||
print $extrafields->showInputField($key,$value);
|
||||
|
||||
print '<input type="submit" class="button" value="'.$langs->trans('Modify').'">';
|
||||
print '</form>';
|
||||
}
|
||||
else
|
||||
{
|
||||
print $extrafields->showOutputField($key,$value);
|
||||
if ($object->statut == 0 && $user->rights->commande->creer) print '<a href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&action=edit_extras&attribute='.$key.'">'.img_picto('','edit').' '.$langs->trans('Modify').'</a>';
|
||||
}
|
||||
print '</td></tr>'."\n";
|
||||
}
|
||||
}
|
||||
|
||||
if(count($extrafields->attribute_label) > 0) {
|
||||
|
||||
if ($action == 'edit_extras' && $user->rights->commande->creer)
|
||||
{
|
||||
print '<tr><td></td><td colspan="5">';
|
||||
print '<input type="submit" class="button" value="'.$langs->trans('Modify').'">';
|
||||
print '</form>';
|
||||
print '</td></tr>';
|
||||
|
||||
}
|
||||
else {
|
||||
if ($object->statut == 0 && $user->rights->commande->creer)
|
||||
{
|
||||
print '<tr><td></td><td><a href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&action=edit_extras">'.img_picto('','edit').' '.$langs->trans('Modify').'</a></td></tr>';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$rowspan=4;
|
||||
|
||||
@ -1926,11 +1926,11 @@ if ($action == 'update_extras')
|
||||
{
|
||||
// Fill array 'array_options' with data from add form
|
||||
$extralabels=$extrafields->fetch_name_optionals_label($object->table_element);
|
||||
$ret = $extrafields->setOptionalsFromPost($extralabels,$object);
|
||||
if($ret < 0)
|
||||
$error++;
|
||||
$ret = $extrafields->setOptionalsFromPost($extralabels,$object,GETPOST('attribute'));
|
||||
if ($ret < 0) $error++;
|
||||
|
||||
if(!$error) {
|
||||
if (! $error)
|
||||
{
|
||||
// Actions on extra fields (by external module or standard code)
|
||||
// FIXME le hook fait double emploi avec le trigger !!
|
||||
$hookmanager->initHooks(array('invoicedao'));
|
||||
@ -1938,22 +1938,16 @@ if ($action == 'update_extras')
|
||||
$reshook=$hookmanager->executeHooks('insertExtraFields',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks
|
||||
if (empty($reshook))
|
||||
{
|
||||
if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used
|
||||
$result=$object->insertExtraFields();
|
||||
if ($result < 0)
|
||||
{
|
||||
$result=$object->insertExtraFields();
|
||||
if ($result < 0)
|
||||
{
|
||||
$error++;
|
||||
}
|
||||
$error++;
|
||||
}
|
||||
}
|
||||
else if ($reshook < 0) $error++;
|
||||
}
|
||||
else
|
||||
{
|
||||
$action = 'edit_extras';
|
||||
}
|
||||
|
||||
|
||||
if ($error) $action = 'edit_extras';
|
||||
}
|
||||
|
||||
|
||||
@ -3413,21 +3407,13 @@ else if ($id > 0 || ! empty($ref))
|
||||
print '</tr>';
|
||||
}
|
||||
|
||||
// Other attributes
|
||||
// Other attributes (TODO Move this into an include)
|
||||
$res=$object->fetch_optionals($object->id,$extralabels);
|
||||
$parameters=array('colspan' => ' colspan="2"');
|
||||
$reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
|
||||
if (empty($reshook) && ! empty($extrafields->attribute_label))
|
||||
{
|
||||
|
||||
if ($action == 'edit_extras')
|
||||
{
|
||||
print '<form enctype="multipart/form-data" action="'.$_SERVER["PHP_SELF"].'" method="post" name="formsoc">';
|
||||
print '<input type="hidden" name="action" value="update_extras">';
|
||||
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
||||
print '<input type="hidden" name="id" value="'.$object->id.'">';
|
||||
}
|
||||
|
||||
foreach($extrafields->attribute_label as $key=>$label)
|
||||
{
|
||||
if ($action == 'edit_extras') {
|
||||
@ -3450,35 +3436,27 @@ else if ($id > 0 || ! empty($ref))
|
||||
$value = isset($_POST["options_".$key])?dol_mktime($_POST["options_".$key."hour"], $_POST["options_".$key."min"], 0, $_POST["options_".$key."month"], $_POST["options_".$key."day"], $_POST["options_".$key."year"]):$db->jdate($object->array_options['options_'.$key]);
|
||||
}
|
||||
|
||||
if ($action == 'edit_extras' && $user->rights->facture->creer)
|
||||
if ($action == 'edit_extras' && $user->rights->facture->creer && GETPOST('attribute') == $key)
|
||||
{
|
||||
print '<form enctype="multipart/form-data" action="'.$_SERVER["PHP_SELF"].'" method="post" name="formsoc">';
|
||||
print '<input type="hidden" name="action" value="update_extras">';
|
||||
print '<input type="hidden" name="attribute" value="'.$key.'">';
|
||||
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
||||
print '<input type="hidden" name="id" value="'.$object->id.'">';
|
||||
|
||||
print $extrafields->showInputField($key,$value);
|
||||
|
||||
print '<input type="submit" class="button" value="'.$langs->trans('Modify').'">';
|
||||
print '</form>';
|
||||
}
|
||||
else
|
||||
{
|
||||
print $extrafields->showOutputField($key,$value);
|
||||
if ($object->statut == 0 && $user->rights->facture->creer) print '<a href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&action=edit_extras&attribute='.$key.'">'.img_picto('','edit').' '.$langs->trans('Modify').'</a>';
|
||||
}
|
||||
print '</td></tr>'."\n";
|
||||
}
|
||||
}
|
||||
|
||||
if(count($extrafields->attribute_label) > 0) {
|
||||
|
||||
if ($action == 'edit_extras' && $user->rights->facture->creer)
|
||||
{
|
||||
print '<tr><td></td><td colspan="5">';
|
||||
print '<input type="submit" class="button" value="'.$langs->trans('Modify').'">';
|
||||
print '</form>';
|
||||
print '</td></tr>';
|
||||
|
||||
}
|
||||
else {
|
||||
if ($object->statut == 0 && $user->rights->facture->creer)
|
||||
{
|
||||
print '<tr><td></td><td><a href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&action=edit_extras">'.img_picto('','edit').' '.$langs->trans('Modify').'</a></td></tr>';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
print '</table><br>';
|
||||
|
||||
@ -146,7 +146,9 @@ if ($action == 'create')
|
||||
/* ************************************************************************** */
|
||||
if ($action == 'edit' && ! empty($attrname))
|
||||
{
|
||||
print "<br>";
|
||||
$langs->load("members");
|
||||
|
||||
print "<br>";
|
||||
print_titre($langs->trans("FieldEdition", $attrname));
|
||||
|
||||
require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php';
|
||||
|
||||
@ -2142,10 +2142,12 @@ abstract class CommonObject
|
||||
*/
|
||||
function insertExtraFields()
|
||||
{
|
||||
global $langs;
|
||||
global $conf,$langs;
|
||||
|
||||
$error=0;
|
||||
|
||||
if (! empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) return 0; // For avoid conflicts if trigger used
|
||||
|
||||
if (! empty($this->array_options))
|
||||
{
|
||||
// Check parameters
|
||||
@ -2249,7 +2251,7 @@ abstract class CommonObject
|
||||
|
||||
$out = '';
|
||||
|
||||
if(count($extrafields->attribute_label) > 0)
|
||||
if (count($extrafields->attribute_label) > 0)
|
||||
{
|
||||
$out .= "\n";
|
||||
$out .= '<!-- showOptionalsInput --> ';
|
||||
|
||||
@ -688,54 +688,52 @@ class ExtraFields
|
||||
{
|
||||
$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');
|
||||
|
||||
// 0 1 : tableName
|
||||
// 1 2 : label field name Nom du champ contenant le libelle
|
||||
// 2 3 : key fields name (if differ of rowid)
|
||||
// 3 4 : key field parent (for dependent lists)
|
||||
// 4 5 : where clause filter on column or table extrafield, syntax field='value' or extra.field=value
|
||||
|
||||
|
||||
$keyList='rowid';
|
||||
|
||||
if (count($InfoFieldList)>=3) {
|
||||
if (count($InfoFieldList) > 3 && ! empty($InfoFieldList[3]))
|
||||
{
|
||||
list($parentName, $parentField) = explode('|', $InfoFieldList[3]);
|
||||
$keyList.= ', '.$parentField;
|
||||
}
|
||||
if (count($InfoFieldList)>=4 && !empty($InfoFieldList[4])) {
|
||||
if (count($InfoFieldList) > 4 && ! empty($InfoFieldList[4]))
|
||||
{
|
||||
if (strpos($InfoFieldList[4], 'extra')!==false) {
|
||||
$keyList='main.'.$InfoFieldList[2].' as rowid';
|
||||
}else {
|
||||
} else {
|
||||
$keyList=$InfoFieldList[2].' as rowid';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$fields_label = explode('|',$InfoFieldList[1]);
|
||||
if(is_array($fields_label)) {
|
||||
$keyList .=', ';
|
||||
$keyList .= implode(', ', $fields_label);
|
||||
}
|
||||
|
||||
$fields_label = explode('|',$InfoFieldList[1]);
|
||||
if(is_array($fields_label)) {
|
||||
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])) {
|
||||
|
||||
if (!empty($InfoFieldList[4]))
|
||||
{
|
||||
//We have to join on extrafield table
|
||||
if (strpos($InfoFieldList[4], 'extra')!==false) {
|
||||
if (strpos($InfoFieldList[4], 'extra')!==false)
|
||||
{
|
||||
$sql.= ' as main, '.MAIN_DB_PREFIX .$InfoFieldList[0].'_extrafields as extra';
|
||||
$sql.= ' WHERE extra.fk_object=main.'.$InfoFieldList[2]. ' AND '.$InfoFieldList[4];
|
||||
}else {
|
||||
$sql.= ' WHERE '.$InfoFieldList[4];
|
||||
$sqlwhere.= ' AND extra.fk_object=main.'.$InfoFieldList[2]. ' AND '.$InfoFieldList[4];
|
||||
}
|
||||
else
|
||||
{
|
||||
$sqlwhere.= ' AND '.$InfoFieldList[4];
|
||||
}
|
||||
}
|
||||
//$sql.= ' WHERE entity = '.$conf->entity;
|
||||
if (in_array($InfoFieldList[0],array('tablewithentity'))) $sqlwhere.= ' AND entity = '.$conf->entity; // Some tables may have field, some other not. For the moment we disable it.
|
||||
$sql.=preg_replace('/^ AND /','',$sqlwhere);
|
||||
//print $sql;
|
||||
|
||||
dol_syslog(get_class($this).'::showInputField type=sellist sql='.$sql);
|
||||
@ -807,6 +805,9 @@ class ExtraFields
|
||||
}
|
||||
$this->db->free($resql);
|
||||
}
|
||||
else {
|
||||
print 'Error in request '.$sql.' '.$this->db->lasterror().'. Check setup of extra parameters.<br>';
|
||||
}
|
||||
}
|
||||
$out.='</select>';
|
||||
}
|
||||
@ -1005,13 +1006,14 @@ class ExtraFields
|
||||
}
|
||||
|
||||
/**
|
||||
* Fill array_options array for object by extrafields value (using for data send by forms)
|
||||
* Fill array_options property of object by extrafields value (using for data sent by forms)
|
||||
*
|
||||
* @param array $extralabels $array of extrafields
|
||||
* @param object &$object object
|
||||
* @param object &$object Object
|
||||
* @param string $onlykey Only following key is filled
|
||||
* @return int 1 if array_options set / 0 if no value
|
||||
*/
|
||||
function setOptionalsFromPost($extralabels,&$object)
|
||||
function setOptionalsFromPost($extralabels,&$object,$onlykey='')
|
||||
{
|
||||
global $_POST, $langs;
|
||||
$nofillrequired='';// For error when required field left blank
|
||||
@ -1022,6 +1024,8 @@ class ExtraFields
|
||||
// Get extra fields
|
||||
foreach ($extralabels as $key => $value)
|
||||
{
|
||||
if (! empty($onlykey) && $key != $onlykey) continue;
|
||||
|
||||
$key_type = $this->attribute_type[$key];
|
||||
if($this->attribute_required[$key] && !GETPOST("options_$key",2))
|
||||
{
|
||||
|
||||
@ -3664,7 +3664,7 @@ class Form
|
||||
* @param string $typehour if 'select' then input hour and input min is a combo, if 'text' input hour is in text and input min is a combo
|
||||
* @return void
|
||||
*/
|
||||
function select_duration($prefix,$iSecond='',$disabled=0,$typehour='select')
|
||||
function select_duration($prefix, $iSecond='', $disabled=0, $typehour='select')
|
||||
{
|
||||
global $langs;
|
||||
|
||||
@ -3680,7 +3680,7 @@ class Form
|
||||
if ($typehour=='select')
|
||||
{
|
||||
print '<select class="flat" name="'.$prefix.'hour"'.($disabled?' disabled="disabled"':'').'>';
|
||||
for ($hour = 0; $hour < 24; $hour++)
|
||||
for ($hour = 0; $hour < 25; $hour++) // For a duration, we allow 24 hours
|
||||
{
|
||||
print '<option value="'.$hour.'"';
|
||||
if ($hourSelected == $hour)
|
||||
|
||||
@ -1,29 +1,29 @@
|
||||
<?php
|
||||
/* Copyright (C) 2002-2007 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
* Copyright (C) 2004-2012 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com>
|
||||
* Copyright (C) 2011-2013 Juanjo Menent <jmenent@2byte.es>
|
||||
* Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro>
|
||||
*
|
||||
* 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/>.
|
||||
*/
|
||||
* Copyright (C) 2004-2013 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com>
|
||||
* Copyright (C) 2011-2013 Juanjo Menent <jmenent@2byte.es>
|
||||
* Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro>
|
||||
*
|
||||
* 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/fichinter/fiche.php
|
||||
* \brief Fichier fiche intervention
|
||||
* \ingroup ficheinter
|
||||
*/
|
||||
* \brief Fichier fiche intervention
|
||||
* \ingroup ficheinter
|
||||
*/
|
||||
|
||||
require '../main.inc.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
|
||||
@ -79,16 +79,22 @@ $object = new Fichinter($db);
|
||||
$extrafields = new ExtraFields($db);
|
||||
$extralabels=$extrafields->fetch_name_optionals_label($object->table_element);
|
||||
|
||||
// Load object
|
||||
if ($id > 0 || ! empty($ref))
|
||||
{
|
||||
$ret=$object->fetch($id, $ref);
|
||||
if ($ret > 0) $ret=$object->fetch_thirdparty();
|
||||
if ($ret < 0) dol_print_error('',$object->error);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Actions
|
||||
*/
|
||||
*/
|
||||
|
||||
if ($action == 'confirm_validate' && $confirm == 'yes' && $user->rights->ficheinter->creer)
|
||||
{
|
||||
$object->fetch($id);
|
||||
$object->fetch_thirdparty();
|
||||
|
||||
$result = $object->setValid($user);
|
||||
if ($result >= 0)
|
||||
{
|
||||
@ -114,9 +120,6 @@ if ($action == 'confirm_validate' && $confirm == 'yes' && $user->rights->fichein
|
||||
|
||||
else if ($action == 'confirm_modify' && $confirm == 'yes' && $user->rights->ficheinter->creer)
|
||||
{
|
||||
$object->fetch($id);
|
||||
$object->fetch_thirdparty();
|
||||
|
||||
$result = $object->setDraft($user);
|
||||
if ($result >= 0)
|
||||
{
|
||||
@ -309,8 +312,6 @@ else if ($action == 'add' && $user->rights->ficheinter->creer)
|
||||
|
||||
else if ($action == 'update' && $user->rights->ficheinter->creer)
|
||||
{
|
||||
$object->fetch($id);
|
||||
|
||||
$object->socid = $socid;
|
||||
$object->fk_project = GETPOST('projectid','int');
|
||||
$object->fk_contrat = GETPOST('contratid','int');
|
||||
@ -326,11 +327,9 @@ else if ($action == 'update' && $user->rights->ficheinter->creer)
|
||||
|
||||
/*
|
||||
* Build doc
|
||||
*/
|
||||
*/
|
||||
else if ($action == 'builddoc' && $user->rights->ficheinter->creer) // En get ou en post
|
||||
{
|
||||
$object->fetch($id);
|
||||
$object->fetch_thirdparty();
|
||||
$object->fetch_lines();
|
||||
|
||||
// Save last template used to generate document
|
||||
@ -357,25 +356,21 @@ else if ($action == 'builddoc' && $user->rights->ficheinter->creer) // En get ou
|
||||
// Remove file in doc form
|
||||
else if ($action == 'remove_file')
|
||||
{
|
||||
if ($object->fetch($id))
|
||||
{
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
|
||||
|
||||
$object->fetch_thirdparty();
|
||||
$object->fetch_thirdparty();
|
||||
|
||||
$langs->load("other");
|
||||
$upload_dir = $conf->ficheinter->dir_output;
|
||||
$file = $upload_dir . '/' . GETPOST('file');
|
||||
$ret=dol_delete_file($file,0,0,0,$object);
|
||||
if ($ret) setEventMessage($langs->trans("FileWasRemoved", GETPOST('urlfile')));
|
||||
else setEventMessage($langs->trans("ErrorFailToDeleteFile", GETPOST('urlfile')), 'errors');
|
||||
}
|
||||
$langs->load("other");
|
||||
$upload_dir = $conf->ficheinter->dir_output;
|
||||
$file = $upload_dir . '/' . GETPOST('file');
|
||||
$ret=dol_delete_file($file,0,0,0,$object);
|
||||
if ($ret) setEventMessage($langs->trans("FileWasRemoved", GETPOST('urlfile')));
|
||||
else setEventMessage($langs->trans("ErrorFailToDeleteFile", GETPOST('urlfile')), 'errors');
|
||||
}
|
||||
|
||||
// Set into a project
|
||||
else if ($action == 'classin' && $user->rights->ficheinter->creer)
|
||||
{
|
||||
$object->fetch($id);
|
||||
$result=$object->setProject(GETPOST('projectid','int'));
|
||||
if ($result < 0) dol_print_error($db,$object->error);
|
||||
}
|
||||
@ -383,15 +378,12 @@ else if ($action == 'classin' && $user->rights->ficheinter->creer)
|
||||
// Set into a contract
|
||||
else if ($action == 'setcontrat' && $user->rights->contrat->creer)
|
||||
{
|
||||
$object->fetch($id);
|
||||
$result=$object->set_contrat($user,GETPOST('contratid','int'));
|
||||
if ($result < 0) dol_print_error($db,$object->error);
|
||||
}
|
||||
|
||||
else if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->ficheinter->supprimer)
|
||||
{
|
||||
$object->fetch($id);
|
||||
$object->fetch_thirdparty();
|
||||
$result=$object->delete($user);
|
||||
if ($result<0) {
|
||||
setEventMessage($object->error,'errors');
|
||||
@ -403,19 +395,16 @@ else if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->fich
|
||||
|
||||
else if ($action == 'setdescription' && $user->rights->ficheinter->creer)
|
||||
{
|
||||
$object->fetch($id);
|
||||
$result=$object->set_description($user,GETPOST('description'));
|
||||
if ($result < 0) dol_print_error($db,$object->error);
|
||||
}
|
||||
else if ($action == 'setnote_public' && $user->rights->ficheinter->creer)
|
||||
{
|
||||
$object->fetch($id);
|
||||
$result=$object->update_note(dol_html_entity_decode(GETPOST('note_public'), ENT_QUOTES),'_public');
|
||||
if ($result < 0) dol_print_error($db,$object->error);
|
||||
}
|
||||
else if ($action == 'setnote_private' && $user->rights->ficheinter->creer)
|
||||
{
|
||||
$object->fetch($id);
|
||||
$result=$object->update_note(dol_html_entity_decode(GETPOST('note_private'), ENT_QUOTES), '_private');
|
||||
if ($result < 0) dol_print_error($db,$object->error);
|
||||
}
|
||||
@ -433,13 +422,15 @@ else if ($action == "addline" && $user->rights->ficheinter->creer)
|
||||
$mesg='<div class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Duration")).'</div>';
|
||||
$error++;
|
||||
}
|
||||
if (GETPOST('durationhour','int') >= 24 && GETPOST('durationmin','int') > 0)
|
||||
{
|
||||
$mesg='<div class="error">'.$langs->trans("ErrorValueTooHigh").'</div>';
|
||||
$error++;
|
||||
}
|
||||
if (! $error)
|
||||
{
|
||||
$db->begin();
|
||||
|
||||
$ret=$object->fetch($id);
|
||||
$object->fetch_thirdparty();
|
||||
|
||||
$desc=GETPOST('np_desc');
|
||||
$date_intervention = dol_mktime(GETPOST('dihour','int'), GETPOST('dimin','int'), 0, GETPOST('dimonth','int'), GETPOST('diday','int'), GETPOST('diyear','int'));
|
||||
$duration = convertTime2Seconds(GETPOST('durationhour','int'), GETPOST('durationmin','int'));
|
||||
@ -482,7 +473,6 @@ else if ($action == "addline" && $user->rights->ficheinter->creer)
|
||||
// Classify Billed
|
||||
else if ($action == 'classifybilled' && $user->rights->ficheinter->creer)
|
||||
{
|
||||
$object->fetch($id);
|
||||
$result=$object->setBilled();
|
||||
if ($result > 0)
|
||||
{
|
||||
@ -582,8 +572,6 @@ else if ($action == 'confirm_deleteline' && $confirm == 'yes' && $user->rights->
|
||||
|
||||
else if ($action == 'up' && $user->rights->ficheinter->creer)
|
||||
{
|
||||
$object->fetch($id);
|
||||
$object->fetch_thirdparty();
|
||||
$object->line_up(GETPOST('line_id','int'));
|
||||
|
||||
// Define output language
|
||||
@ -603,8 +591,6 @@ else if ($action == 'up' && $user->rights->ficheinter->creer)
|
||||
|
||||
else if ($action == 'down' && $user->rights->ficheinter->creer)
|
||||
{
|
||||
$object->fetch($id);
|
||||
$object->fetch_thirdparty();
|
||||
$object->line_down(GETPOST('line_id','int'));
|
||||
|
||||
// Define output language
|
||||
@ -661,159 +647,148 @@ if ($action == 'send' && ! GETPOST('cancel','alpha') && (empty($conf->global->MA
|
||||
{
|
||||
$langs->load('mails');
|
||||
|
||||
if ($object->fetch($id) > 0)
|
||||
if (GETPOST('sendto','alpha'))
|
||||
{
|
||||
$object->fetch_thirdparty();
|
||||
|
||||
if (GETPOST('sendto','alpha'))
|
||||
// Le destinataire a ete fourni via le champ libre
|
||||
$sendto = GETPOST('sendto','alpha');
|
||||
$sendtoid = 0;
|
||||
}
|
||||
elseif (GETPOST('receiver','alpha') != '-1')
|
||||
{
|
||||
// Recipient was provided from combo list
|
||||
if (GETPOST('receiver','alpha') == 'thirdparty') // Id of third party
|
||||
{
|
||||
// Le destinataire a ete fourni via le champ libre
|
||||
$sendto = GETPOST('sendto','alpha');
|
||||
$sendto = $object->client->email;
|
||||
$sendtoid = 0;
|
||||
}
|
||||
elseif (GETPOST('receiver','alpha') != '-1')
|
||||
else // Id du contact
|
||||
{
|
||||
// Recipient was provided from combo list
|
||||
if (GETPOST('receiver','alpha') == 'thirdparty') // Id of third party
|
||||
$sendto = $object->client->contact_get_property(GETPOST('receiver'),'email');
|
||||
$sendtoid = GETPOST('receiver','alpha');
|
||||
}
|
||||
}
|
||||
|
||||
if (dol_strlen($sendto))
|
||||
{
|
||||
$langs->load("commercial");
|
||||
|
||||
$from = GETPOST('fromname','alpha') . ' <' . GETPOST('frommail','alpha') .'>';
|
||||
$replyto = GETPOST('replytoname','alpha'). ' <' . GETPOST('replytomail','alpha').'>';
|
||||
$message = GETPOST('message');
|
||||
$sendtocc = GETPOST('sendtocc','alpha');
|
||||
$deliveryreceipt = GETPOST('deliveryreceipt','alpha');
|
||||
|
||||
if ($action == 'send')
|
||||
{
|
||||
if (strlen(GETPOST('subject','alphs'))) $subject = GETPOST('subject','alpha');
|
||||
else $subject = $langs->transnoentities('Intervention').' '.$object->ref;
|
||||
$actiontypecode='AC_OTH_AUTO';
|
||||
$actionmsg = $langs->transnoentities('MailSentBy').' '.$from.' '.$langs->transnoentities('To').' '.$sendto.".\n";
|
||||
if ($message)
|
||||
{
|
||||
$sendto = $object->client->email;
|
||||
$sendtoid = 0;
|
||||
}
|
||||
else // Id du contact
|
||||
{
|
||||
$sendto = $object->client->contact_get_property(GETPOST('receiver'),'email');
|
||||
$sendtoid = GETPOST('receiver','alpha');
|
||||
$actionmsg.=$langs->transnoentities('MailTopic').": ".$subject."\n";
|
||||
$actionmsg.=$langs->transnoentities('TextUsedInTheMessageBody').":\n";
|
||||
$actionmsg.=$message;
|
||||
}
|
||||
$actionmsg2=$langs->transnoentities('Action'.$actiontypecode);
|
||||
}
|
||||
|
||||
if (dol_strlen($sendto))
|
||||
// Create form object
|
||||
include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php';
|
||||
$formmail = new FormMail($db);
|
||||
|
||||
$attachedfiles=$formmail->get_attached_files();
|
||||
$filepath = $attachedfiles['paths'];
|
||||
$filename = $attachedfiles['names'];
|
||||
$mimetype = $attachedfiles['mimes'];
|
||||
|
||||
// Envoi de la propal
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php';
|
||||
$mailfile = new CMailFile($subject,$sendto,$from,$message,$filepath,$mimetype,$filename,$sendtocc,'',$deliveryreceipt,-1);
|
||||
if ($mailfile->error)
|
||||
{
|
||||
$langs->load("commercial");
|
||||
|
||||
$from = GETPOST('fromname','alpha') . ' <' . GETPOST('frommail','alpha') .'>';
|
||||
$replyto = GETPOST('replytoname','alpha'). ' <' . GETPOST('replytomail','alpha').'>';
|
||||
$message = GETPOST('message');
|
||||
$sendtocc = GETPOST('sendtocc','alpha');
|
||||
$deliveryreceipt = GETPOST('deliveryreceipt','alpha');
|
||||
|
||||
if ($action == 'send')
|
||||
$mesg='<div class="error">'.$mailfile->error.'</div>';
|
||||
}
|
||||
else
|
||||
{
|
||||
$result=$mailfile->sendfile();
|
||||
if ($result)
|
||||
{
|
||||
if (strlen(GETPOST('subject','alphs'))) $subject = GETPOST('subject','alpha');
|
||||
else $subject = $langs->transnoentities('Intervention').' '.$object->ref;
|
||||
$actiontypecode='AC_OTH_AUTO';
|
||||
$actionmsg = $langs->transnoentities('MailSentBy').' '.$from.' '.$langs->transnoentities('To').' '.$sendto.".\n";
|
||||
if ($message)
|
||||
{
|
||||
$actionmsg.=$langs->transnoentities('MailTopic').": ".$subject."\n";
|
||||
$actionmsg.=$langs->transnoentities('TextUsedInTheMessageBody').":\n";
|
||||
$actionmsg.=$message;
|
||||
$mesg=$langs->trans('MailSuccessfulySent',$mailfile->getValidAddress($from,2),$mailfile->getValidAddress($sendto,2));
|
||||
setEventMessage($mesg);
|
||||
$error=0;
|
||||
|
||||
// Initialisation donnees
|
||||
$object->sendtoid = $sendtoid;
|
||||
$object->actiontypecode = $actiontypecode;
|
||||
$object->actionmsg = $actionmsg;
|
||||
$object->actionmsg2 = $actionmsg2;
|
||||
$object->fk_element = $object->id;
|
||||
$object->elementtype = $object->element;
|
||||
|
||||
// Appel des triggers
|
||||
include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
|
||||
$interface=new Interfaces($db);
|
||||
$result=$interface->run_triggers('FICHINTER_SENTBYMAIL',$object,$user,$langs,$conf);
|
||||
if ($result < 0) {
|
||||
$error++; $this->errors=$interface->errors;
|
||||
}
|
||||
$actionmsg2=$langs->transnoentities('Action'.$actiontypecode);
|
||||
}
|
||||
// Fin appel triggers
|
||||
|
||||
// Create form object
|
||||
include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php';
|
||||
$formmail = new FormMail($db);
|
||||
|
||||
$attachedfiles=$formmail->get_attached_files();
|
||||
$filepath = $attachedfiles['paths'];
|
||||
$filename = $attachedfiles['names'];
|
||||
$mimetype = $attachedfiles['mimes'];
|
||||
|
||||
// Envoi de la propal
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php';
|
||||
$mailfile = new CMailFile($subject,$sendto,$from,$message,$filepath,$mimetype,$filename,$sendtocc,'',$deliveryreceipt,-1);
|
||||
if ($mailfile->error)
|
||||
{
|
||||
$mesg='<div class="error">'.$mailfile->error.'</div>';
|
||||
if ($error)
|
||||
{
|
||||
dol_print_error($db);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Redirect here
|
||||
// This avoid sending mail twice if going out and then back to page
|
||||
header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$result=$mailfile->sendfile();
|
||||
if ($result)
|
||||
$langs->load("other");
|
||||
$mesg='<div class="error">';
|
||||
if ($mailfile->error)
|
||||
{
|
||||
$mesg=$langs->trans('MailSuccessfulySent',$mailfile->getValidAddress($from,2),$mailfile->getValidAddress($sendto,2));
|
||||
setEventMessage($mesg);
|
||||
$error=0;
|
||||
|
||||
// Initialisation donnees
|
||||
$object->sendtoid = $sendtoid;
|
||||
$object->actiontypecode = $actiontypecode;
|
||||
$object->actionmsg = $actionmsg;
|
||||
$object->actionmsg2 = $actionmsg2;
|
||||
$object->fk_element = $object->id;
|
||||
$object->elementtype = $object->element;
|
||||
|
||||
// Appel des triggers
|
||||
include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
|
||||
$interface=new Interfaces($db);
|
||||
$result=$interface->run_triggers('FICHINTER_SENTBYMAIL',$object,$user,$langs,$conf);
|
||||
if ($result < 0) {
|
||||
$error++; $this->errors=$interface->errors;
|
||||
}
|
||||
// Fin appel triggers
|
||||
|
||||
if ($error)
|
||||
{
|
||||
dol_print_error($db);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Redirect here
|
||||
// This avoid sending mail twice if going out and then back to page
|
||||
header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$langs->load("other");
|
||||
$mesg='<div class="error">';
|
||||
if ($mailfile->error)
|
||||
{
|
||||
$mesg.=$langs->trans('ErrorFailedToSendMail',$from,$sendto);
|
||||
$mesg.='<br>'.$mailfile->error;
|
||||
}
|
||||
else
|
||||
{
|
||||
$mesg.='No mail sent. Feature is disabled by option MAIN_DISABLE_ALL_MAILS';
|
||||
}
|
||||
$mesg.='</div>';
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$langs->load("other");
|
||||
$mesg='<div class="error">'.$langs->trans('ErrorMailRecipientIsEmpty').' !</div>';
|
||||
dol_syslog('Recipient email is empty');
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$langs->load("other");
|
||||
$mesg='<div class="error">'.$langs->trans('ErrorFailedToReadEntity',$langs->trans("Intervention")).'</div>';
|
||||
dol_syslog('Impossible de lire les donnees de l\'intervention. Le fichier intervention n\'a peut-etre pas ete genere.');
|
||||
}
|
||||
$mesg.=$langs->trans('ErrorFailedToSendMail',$from,$sendto);
|
||||
$mesg.='<br>'.$mailfile->error;
|
||||
}
|
||||
else
|
||||
{
|
||||
$mesg.='No mail sent. Feature is disabled by option MAIN_DISABLE_ALL_MAILS';
|
||||
}
|
||||
$mesg.='</div>';
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$langs->load("other");
|
||||
$mesg='<div class="error">'.$langs->trans('ErrorMailRecipientIsEmpty').' !</div>';
|
||||
dol_syslog('Recipient email is empty');
|
||||
}
|
||||
|
||||
$action='presend';
|
||||
}
|
||||
|
||||
else if ($action == 'update_extras')
|
||||
{
|
||||
$object->fetch($id);
|
||||
// Fill array 'array_options' with data from update form
|
||||
$extralabels=$extrafields->fetch_name_optionals_label($object->table_element);
|
||||
$ret = $extrafields->setOptionalsFromPost($extralabels,$object);
|
||||
|
||||
// Actions on extra fields (by external module or standard code)
|
||||
// FIXME le hook fait double emploi avec le trigger !!
|
||||
$hookmanager->initHooks(array('interventiondao'));
|
||||
$parameters=array('id'=>$object->id);
|
||||
$reshook=$hookmanager->executeHooks('insertExtraFields',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks
|
||||
if (empty($reshook))
|
||||
$ret = $extrafields->setOptionalsFromPost($extralabels,$object,GETPOST('attribute'));
|
||||
if ($ret < 0) $error++;
|
||||
|
||||
if (! $error)
|
||||
{
|
||||
if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used
|
||||
// Actions on extra fields (by external module or standard code)
|
||||
// FIXME le hook fait double emploi avec le trigger !!
|
||||
$hookmanager->initHooks(array('interventiondao'));
|
||||
$parameters=array('id'=>$object->id);
|
||||
$reshook=$hookmanager->executeHooks('insertExtraFields',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks
|
||||
if (empty($reshook))
|
||||
{
|
||||
$result=$object->insertExtraFields();
|
||||
if ($result < 0)
|
||||
@ -821,16 +796,16 @@ else if ($action == 'update_extras')
|
||||
$error++;
|
||||
}
|
||||
}
|
||||
else if ($reshook < 0) $error++;
|
||||
}
|
||||
else if ($reshook < 0) $error++;
|
||||
|
||||
if ($error) $action = 'edit_extras';
|
||||
}
|
||||
|
||||
if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB) && $user->rights->ficheinter->creer)
|
||||
{
|
||||
if ($action == 'addcontact')
|
||||
{
|
||||
$result = $object->fetch($id);
|
||||
|
||||
if ($result > 0 && $id > 0)
|
||||
{
|
||||
$contactid = (GETPOST('userid','int') ? GETPOST('userid','int') : GETPOST('contactid','int'));
|
||||
@ -859,20 +834,12 @@ if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB) && $user->rights->ficheint
|
||||
// bascule du statut d'un contact
|
||||
else if ($action == 'swapstatut')
|
||||
{
|
||||
if ($object->fetch($id))
|
||||
{
|
||||
$result=$object->swapContactStatus(GETPOST('ligne','int'));
|
||||
}
|
||||
else
|
||||
{
|
||||
dol_print_error($db);
|
||||
}
|
||||
$result=$object->swapContactStatus(GETPOST('ligne','int'));
|
||||
}
|
||||
|
||||
// Efface un contact
|
||||
else if ($action == 'deletecontact')
|
||||
{
|
||||
$object->fetch($id);
|
||||
$result = $object->delete_contact(GETPOST('lineid','int'));
|
||||
|
||||
if ($result >= 0)
|
||||
@ -901,8 +868,8 @@ if ($action == 'create')
|
||||
{
|
||||
/*
|
||||
* Mode creation
|
||||
* Creation d'une nouvelle fiche d'intervention
|
||||
*/
|
||||
* Creation d'une nouvelle fiche d'intervention
|
||||
*/
|
||||
|
||||
$soc=new Societe($db);
|
||||
|
||||
@ -1285,19 +1252,11 @@ else if ($id > 0 || ! empty($ref))
|
||||
// Statut
|
||||
print '<tr><td>'.$langs->trans("Status").'</td><td>'.$object->getLibStatut(4).'</td></tr>';
|
||||
|
||||
// Other attributes
|
||||
// Other attributes (TODO Move this into an include)
|
||||
$parameters=array('colspan' => ' colspan="3"');
|
||||
$reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
|
||||
if (empty($reshook) && ! empty($extrafields->attribute_label))
|
||||
{
|
||||
if ($action == 'edit_extras')
|
||||
{
|
||||
print '<form enctype="multipart/form-data" action="'.$_SERVER["PHP_SELF"].'" method="post" name="formfichinter">';
|
||||
print '<input type="hidden" name="action" value="update_extras">';
|
||||
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
||||
print '<input type="hidden" name="id" value="'.$object->id.'">';
|
||||
}
|
||||
|
||||
foreach($extrafields->attribute_label as $key=>$label)
|
||||
{
|
||||
if ($action == 'edit_extras') {
|
||||
@ -1319,35 +1278,27 @@ else if ($id > 0 || ! empty($ref))
|
||||
{
|
||||
$value = isset($_POST["options_".$key])?dol_mktime($_POST["options_".$key."hour"], $_POST["options_".$key."min"], 0, $_POST["options_".$key."month"], $_POST["options_".$key."day"], $_POST["options_".$key."year"]):$db->jdate($object->array_options['options_'.$key]);
|
||||
}
|
||||
if ($action == 'edit_extras' && $user->rights->ficheinter->creer)
|
||||
if ($action == 'edit_extras' && $user->rights->ficheinter->creer && GETPOST('attribute') == $key)
|
||||
{
|
||||
print '<form enctype="multipart/form-data" action="'.$_SERVER["PHP_SELF"].'" method="post" name="formfichinter">';
|
||||
print '<input type="hidden" name="action" value="update_extras">';
|
||||
print '<input type="hidden" name="attribute" value="'.$key.'">';
|
||||
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
||||
print '<input type="hidden" name="id" value="'.$object->id.'">';
|
||||
|
||||
print $extrafields->showInputField($key,$value);
|
||||
|
||||
print '<input type="submit" class="button" value="'.$langs->trans('Modify').'">';
|
||||
print '</form>';
|
||||
}
|
||||
else
|
||||
{
|
||||
print $extrafields->showOutputField($key,$value);
|
||||
if ($object->statut == 0 && $user->rights->ficheinter->creer) print '<a href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&action=edit_extras&attribute='.$key.'">'.img_picto('','edit').' '.$langs->trans('Modify').'</a>';
|
||||
}
|
||||
print '</td></tr>'."\n";
|
||||
}
|
||||
}
|
||||
|
||||
if(count($extrafields->attribute_label) > 0) {
|
||||
|
||||
if ($action == 'edit_extras' && $user->rights->ficheinter->creer)
|
||||
{
|
||||
print '<tr><td></td><td colspan="3">';
|
||||
print '<input type="submit" class="button" value="'.$langs->trans('Modify').'">';
|
||||
print '</form>';
|
||||
print '</td></tr>';
|
||||
|
||||
}
|
||||
else {
|
||||
if ($object->statut == 0 && $user->rights->ficheinter->creer)
|
||||
{
|
||||
print '<tr><td></td><td><a href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&action=edit_extras">'.img_picto('','edit').' '.$langs->trans('Modify').'</a></td></tr>';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
print "</table><br>";
|
||||
|
||||
@ -972,6 +972,8 @@ ExtraFieldsThirdParties=Complementary attributes (thirdparty)
|
||||
ExtraFieldsContacts=Complementary attributes (contact/address)
|
||||
ExtraFieldsMember=Complementary attributes (member)
|
||||
ExtraFieldsMemberType=Complementary attributes (member type)
|
||||
ExtraFieldsCustomerOrders=Complementary attributes (orders)
|
||||
ExtraFieldsCustomerInvoices=Complementary attributes (invoices)
|
||||
ExtraFieldsSupplierOrders=Complementary attributes (orders)
|
||||
ExtraFieldsSupplierInvoices=Complementary attributes (invoices)
|
||||
ExtraFieldsProject=Complementary attributes (projects)
|
||||
@ -1003,6 +1005,7 @@ BrowserIsKO=You are using the web browser %s. This browser is known to be a bad
|
||||
XDebugInstalled=XDebug est chargé.
|
||||
XCacheInstalled=XCache is loaded.
|
||||
AddRefInList=Display customer/supplier ref into list (select list or combobox) and most of hyperlink
|
||||
FieldEdition=Edition of field %s
|
||||
##### Module password generation
|
||||
PasswordGenerationStandard=Return a password generated according to internal Dolibarr algorithm: 8 characters containing shared numbers and characters in lowercase.
|
||||
PasswordGenerationNone=Do not suggest any generated password. Password must be type in manually.
|
||||
|
||||
@ -118,7 +118,6 @@ LastMembers=Last %s members
|
||||
LastMembersModified=Last %s modified members
|
||||
LastSubscriptionsModified=Last %s modified subscriptions
|
||||
AttributeName=Attribute name
|
||||
FieldEdition=Edition of field %s
|
||||
String=String
|
||||
Text=Text
|
||||
Int=Int
|
||||
|
||||
@ -972,6 +972,8 @@ ExtraFieldsThirdParties=Attributs supplémentaires (tiers)
|
||||
ExtraFieldsContacts=Attributs supplémentaires (contacts/adresses)
|
||||
ExtraFieldsMember=Attributs supplémentaires (adhérents)
|
||||
ExtraFieldsMemberType=Attributs supplémentaires (type d'adhérents)
|
||||
ExtraFieldsCustomerOrders=Attributs supplémentaires (commandes)
|
||||
ExtraFieldsCustomerInvoices=Attributs supplémentaires (factures)
|
||||
ExtraFieldsSupplierOrders=Attributs supplémentaires (commandes)
|
||||
ExtraFieldsCustomerInvoices=Attributs supplémentaires (factures clients)
|
||||
ExtraFieldsSupplierInvoices=Attributs supplémentaires (factures)
|
||||
@ -1016,6 +1018,7 @@ EncryptedPasswordInDatabase=Permettre le chiffrement des mots de passe dans la b
|
||||
DisableForgetPasswordLinkOnLogonPage=Ne pas afficher le lien "Mot de passe oublié" sur la page de connexion
|
||||
UsersSetup=Configuration du module utilisateurs
|
||||
UserMailRequired=Email requis pour créer un nouvel utilisateur
|
||||
FieldEdition=Édition du champ %s
|
||||
##### Company setup #####
|
||||
CompanySetup=Configuration du module Tiers
|
||||
CompanyCodeChecker=Modèle de génération et contrôle des codes tiers (clients/fournisseurs)
|
||||
|
||||
@ -118,7 +118,6 @@ LastMembers=Les %s derniers adhérents
|
||||
LastMembersModified=Les %s derniers adhérents modifiés
|
||||
LastSubscriptionsModified=Les %s dernières adhésions modifiées
|
||||
AttributeName=Nom de l'attribut
|
||||
FieldEdition=Édition du champ %s
|
||||
String=Chaîne
|
||||
Text=Texte long
|
||||
Int=Numérique
|
||||
|
||||
Loading…
Reference in New Issue
Block a user