Merge branch 'develop' of git@github.com:Dolibarr/dolibarr.git into develop
This commit is contained in:
commit
f9fb73ee82
@ -133,7 +133,7 @@ $tabsql[2] = "SELECT d.rowid as rowid, d.code_departement as code, d.nom as libe
|
||||
$tabsql[3] = "SELECT r.rowid as rowid, r.code_region as code, r.nom as libelle, r.fk_pays as country_id, c.code as country_code, c.label as country, r.active FROM ".MAIN_DB_PREFIX."c_regions as r, ".MAIN_DB_PREFIX."c_country as c WHERE r.fk_pays=c.rowid and c.active=1";
|
||||
$tabsql[4] = "SELECT rowid as rowid, code, label, active FROM ".MAIN_DB_PREFIX."c_country";
|
||||
$tabsql[5] = "SELECT c.rowid as rowid, c.code as code, c.label, c.active FROM ".MAIN_DB_PREFIX."c_civility AS c";
|
||||
$tabsql[6] = "SELECT a.id as rowid, a.code as code, a.libelle AS libelle, a.type, a.active, a.module, a.position FROM ".MAIN_DB_PREFIX."c_actioncomm AS a";
|
||||
$tabsql[6] = "SELECT a.id as rowid, a.code as code, a.libelle AS libelle, a.type, a.active, a.module, a.color, a.position FROM ".MAIN_DB_PREFIX."c_actioncomm AS a";
|
||||
$tabsql[7] = "SELECT a.id as rowid, a.code as code, a.libelle AS libelle, a.accountancy_code as accountancy_code, a.deductible, c.code as country_code, c.label as country, a.fk_pays as country_id, a.active FROM ".MAIN_DB_PREFIX."c_chargesociales AS a, ".MAIN_DB_PREFIX."c_country as c WHERE a.fk_pays=c.rowid and c.active=1";
|
||||
$tabsql[8] = "SELECT t.id as rowid, t.code as code, t.libelle, t.fk_country as country_id, c.code as country_code, c.label as country, t.active FROM ".MAIN_DB_PREFIX."c_typent as t LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON t.fk_country=c.rowid";
|
||||
$tabsql[9] = "SELECT code_iso as code, label, unicode, active FROM ".MAIN_DB_PREFIX."c_currencies";
|
||||
@ -187,7 +187,7 @@ $tabfield[2] = "code,libelle,region_id,region,country"; // "code,libelle,regio
|
||||
$tabfield[3] = "code,libelle,country_id,country";
|
||||
$tabfield[4] = "code,label";
|
||||
$tabfield[5] = "code,label";
|
||||
$tabfield[6] = "code,libelle,type,position";
|
||||
$tabfield[6] = "code,libelle,type,color,position";
|
||||
$tabfield[7] = "code,libelle,country_id,country,accountancy_code,deductible";
|
||||
$tabfield[8] = "code,libelle,country_id,country";
|
||||
$tabfield[9] = "code,label,unicode";
|
||||
@ -214,7 +214,7 @@ $tabfieldvalue[2] = "code,libelle,region"; // "code,libelle,region"
|
||||
$tabfieldvalue[3] = "code,libelle,country";
|
||||
$tabfieldvalue[4] = "code,label";
|
||||
$tabfieldvalue[5] = "code,label";
|
||||
$tabfieldvalue[6] = "code,libelle,type,position";
|
||||
$tabfieldvalue[6] = "code,libelle,type,color,position";
|
||||
$tabfieldvalue[7] = "code,libelle,country,accountancy_code,deductible";
|
||||
$tabfieldvalue[8] = "code,libelle,country";
|
||||
$tabfieldvalue[9] = "code,label,unicode";
|
||||
@ -241,7 +241,7 @@ $tabfieldinsert[2] = "code_departement,nom,fk_region";
|
||||
$tabfieldinsert[3] = "code_region,nom,fk_pays";
|
||||
$tabfieldinsert[4] = "code,label";
|
||||
$tabfieldinsert[5] = "code,label";
|
||||
$tabfieldinsert[6] = "code,libelle,type,position";
|
||||
$tabfieldinsert[6] = "code,libelle,type,color,position";
|
||||
$tabfieldinsert[7] = "code,libelle,fk_pays,accountancy_code,deductible";
|
||||
$tabfieldinsert[8] = "code,libelle,fk_country";
|
||||
$tabfieldinsert[9] = "code_iso,label,unicode";
|
||||
|
||||
@ -93,7 +93,10 @@ if (! empty($_POST['removedassigned']))
|
||||
$idtoremove=$_POST['removedassigned'];
|
||||
if (! empty($_SESSION['assignedtouser'])) $tmpassigneduserids=dol_json_decode($_SESSION['assignedtouser'],1);
|
||||
else $tmpassigneduserids=array();
|
||||
unset($tmpassigneduserids[$idtoremove]);
|
||||
foreach ($tmpassigneduserids as $key => $val)
|
||||
{
|
||||
if ($val['id'] == $idtoremove) unset($tmpassigneduserids[$key]);
|
||||
}
|
||||
//var_dump($_POST['removedassigned']);exit;
|
||||
$_SESSION['assignedtouser']=dol_json_encode($tmpassigneduserids);
|
||||
$donotclearsession=1;
|
||||
@ -105,11 +108,14 @@ if (! empty($_POST['removedassigned']))
|
||||
if (GETPOST('addassignedtouser') || GETPOST('updateassignedtouser'))
|
||||
{
|
||||
// Add a new user
|
||||
if (GETPOST('affectedto') > 0)
|
||||
if (GETPOST('assignedtouser') > 0)
|
||||
{
|
||||
$assignedtouser=array();
|
||||
if (! empty($_SESSION['assignedtouser'])) $assignedtouser=dol_json_decode($_SESSION['assignedtouser'], true);
|
||||
$assignedtouser[GETPOST('affectedto')]=array('transparency'=>GETPOST('transparency'),'mandatory'=>1);
|
||||
if (! empty($_SESSION['assignedtouser']))
|
||||
{
|
||||
$assignedtouser=dol_json_decode($_SESSION['assignedtouser'], true);
|
||||
}
|
||||
$assignedtouser[GETPOST('assignedtouser')]=array('id'=>GETPOST('assignedtouser'), 'transparency'=>GETPOST('transparency'),'mandatory'=>1);
|
||||
$_SESSION['assignedtouser']=dol_json_encode($assignedtouser);
|
||||
}
|
||||
$donotclearsession=1;
|
||||
@ -202,22 +208,23 @@ if ($action == 'add')
|
||||
$object->percentage = $percentage;
|
||||
$object->duree=((float) (GETPOST('dureehour') * 60) + (float) GETPOST('dureemin')) * 60;
|
||||
|
||||
$listofuserid=dol_json_decode($_SESSION['assignedtouser']);
|
||||
$listofuserid=array();
|
||||
if (! empty($_SESSION['assignedtouser'])) $listofuserid=dol_json_decode($_SESSION['assignedtouser']);
|
||||
$i=0;
|
||||
foreach($listofuserid as $key => $value)
|
||||
{
|
||||
if ($i == 0) // First entry
|
||||
{
|
||||
$usertodo=new User($db);
|
||||
if ($key > 0)
|
||||
if ($value['id'] > 0)
|
||||
{
|
||||
$usertodo->fetch($key);
|
||||
$usertodo->fetch($value['id']);
|
||||
}
|
||||
$object->usertodo = $usertodo;
|
||||
$object->transparency = (GETPOST("transparency")=='on'?1:0);
|
||||
}
|
||||
|
||||
$object->userassigned[$key]=array('id'=>$key, 'transparency'=>(GETPOST("transparency")=='on'?1:0));
|
||||
$object->userassigned[$value['id']]=array('id'=>$value['id'], 'transparency'=>(GETPOST("transparency")=='on'?1:0));
|
||||
|
||||
$i++;
|
||||
}
|
||||
@ -233,12 +240,15 @@ if ($action == 'add')
|
||||
}
|
||||
|
||||
$object->note = trim($_POST["note"]);
|
||||
|
||||
if (isset($_POST["contactid"])) $object->contact = $contact;
|
||||
|
||||
if (GETPOST('socid','int') > 0)
|
||||
{
|
||||
$societe = new Societe($db);
|
||||
$societe->fetch(GETPOST('socid','int'));
|
||||
$object->societe = $societe;
|
||||
$object->societe = $societe; // deprecated
|
||||
$object->thirdparty = $societe;
|
||||
}
|
||||
|
||||
// Special for module webcal and phenix
|
||||
@ -281,6 +291,8 @@ if ($action == 'add')
|
||||
{
|
||||
if (! $object->error)
|
||||
{
|
||||
unset($_SESSION['assignedtouser']);
|
||||
|
||||
$db->commit();
|
||||
if (! empty($backtopage))
|
||||
{
|
||||
@ -337,6 +349,7 @@ if ($action == 'update')
|
||||
if ($p2min == -1) $p2min='0';
|
||||
|
||||
$object->fetch($id);
|
||||
$object->fetch_userassigned();
|
||||
|
||||
$datep=dol_mktime($fulldayevent?'00':$aphour, $fulldayevent?'00':$apmin, 0, $_POST["apmonth"], $_POST["apday"], $_POST["apyear"]);
|
||||
$datef=dol_mktime($fulldayevent?'23':$p2hour, $fulldayevent?'59':$p2min, $fulldayevent?'59':'0', $_POST["p2month"], $_POST["p2day"], $_POST["p2year"]);
|
||||
@ -349,8 +362,10 @@ if ($action == 'update')
|
||||
$object->priority = $_POST["priority"];
|
||||
$object->fulldayevent= $_POST["fullday"]?1:0;
|
||||
$object->location = GETPOST('location');
|
||||
$object->societe->id = $_POST["socid"];
|
||||
$object->contact->id = $_POST["contactid"];
|
||||
$object->socid = $_POST["socid"];
|
||||
$object->contactid = $_POST["contactid"];
|
||||
$object->societe->id = $_POST["socid"]; // deprecated
|
||||
$object->contact->id = $_POST["contactid"]; // deprecated
|
||||
$object->fk_project = $_POST["projectid"];
|
||||
$object->note = $_POST["note"];
|
||||
$object->pnote = $_POST["note"];
|
||||
@ -363,26 +378,26 @@ if ($action == 'update')
|
||||
setEventMessages($langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("DateEnd")),$object->errors,'errors');
|
||||
$action = 'edit';
|
||||
}
|
||||
|
||||
// Users
|
||||
$listofuserid=dol_json_decode($_SESSION['assignedtouser']);
|
||||
$i=0;
|
||||
foreach($listofuserid as $key => $value)
|
||||
$listofuserid=array();
|
||||
//$assignedtouser=(GETPOST("assignedtouser") >0)?GETPOST("assignedtouser"):(! empty($object->usertodo->id) && $object->usertodo->id > 0 ? $object->usertodo->id : 0);
|
||||
$assignedtouser=(! empty($object->usertodo->id) && $object->usertodo->id > 0 ? $object->usertodo->id : 0);
|
||||
if ($assignedtouser) $listofuserid[$assignedtouser]=array('id'=>$assignedtouser, 'mandatory'=>0, 'transparency'=>$object->transparency); // Owner first
|
||||
|
||||
if (! empty($_SESSION['assignedtouser']))
|
||||
{
|
||||
if ($i == 0) // First entry
|
||||
// Restore array with key with same value than param 'id'
|
||||
$tmplist1=dol_json_decode($_SESSION['assignedtouser'], true); $tmplist2=array();
|
||||
foreach($tmplist1 as $key => $val)
|
||||
{
|
||||
$usertodo=new User($db);
|
||||
if ($key > 0)
|
||||
{
|
||||
$usertodo->fetch($key);
|
||||
}
|
||||
$object->usertodo = $usertodo;
|
||||
$object->transparency=(GETPOST("transparency")=='on'?1:0);
|
||||
if ($val['id'] && $val['id'] != $assignedtouser) $listofuserid[$val['id']]=$val;
|
||||
}
|
||||
}
|
||||
|
||||
$object->userassigned[$key]=array('id'=>$key, 'transparency'=>(GETPOST("transparency")=='on'?1:0));
|
||||
|
||||
$i++;
|
||||
$object->userassigned=array(); // Clear old content
|
||||
foreach($listofuserid as $key => $val)
|
||||
{
|
||||
$object->userassigned[$val['id']]=array('id'=>$val['id'], 'mandatory'=>0, 'transparency'=>(GETPOST("transparency")=='on'?1:0));
|
||||
}
|
||||
|
||||
if (! empty($conf->global->AGENDA_ENABLE_DONEBY))
|
||||
@ -424,6 +439,8 @@ if ($action == 'update')
|
||||
|
||||
if ($result > 0)
|
||||
{
|
||||
unset($_SESSION['assignedtouser']);
|
||||
|
||||
$db->commit();
|
||||
}
|
||||
else
|
||||
@ -438,6 +455,7 @@ if ($action == 'update')
|
||||
{
|
||||
if (! empty($backtopage))
|
||||
{
|
||||
unset($_SESSION['assignedtouser']);
|
||||
header("Location: ".$backtopage);
|
||||
exit;
|
||||
}
|
||||
@ -474,6 +492,8 @@ if ($action == 'confirm_delete' && GETPOST("confirm") == 'yes')
|
||||
if ($action == 'mupdate')
|
||||
{
|
||||
$object->fetch($id);
|
||||
$object->fetch_userassigned();
|
||||
|
||||
$shour = dol_print_date($object->datep,"%H");
|
||||
$smin = dol_print_date($object->datep, "%M");
|
||||
|
||||
@ -645,13 +665,21 @@ if ($action == 'create')
|
||||
|
||||
// Assigned to
|
||||
print '<tr><td class="nowrap">'.$langs->trans("ActionAffectedTo").'</td><td>';
|
||||
$listofuserid=array();
|
||||
if (empty($donotclearsession))
|
||||
{
|
||||
$assignedtouser=GETPOST("affectedtouser")?GETPOST("affectedtouser"):(! empty($object->usertodo->id) && $object->usertodo->id > 0 ? $object->usertodo->id : $user->id);
|
||||
$_SESSION['assignedtouser']=dol_json_encode(array($assignedtouser=>array('transparency'=>1,'mandatory'=>1)));
|
||||
$assignedtouser=GETPOST("assignedtouser")?GETPOST("assignedtouser"):(! empty($object->usertodo->id) && $object->usertodo->id > 0 ? $object->usertodo->id : $user->id);
|
||||
if ($assignedtouser) $listofuserid[$assignedtouser]=array('id'=>$assignedtouser,'mandatory'=>0,'transparency'=>$object->transparency); // Owner first
|
||||
$_SESSION['assignedtouser']=dol_json_encode($listofuserid);
|
||||
}
|
||||
print $form->select_dolusers_forevent(($action=='create'?'add':'update'),'affectedto',1);
|
||||
//print $form->select_dolusers(GETPOST("affectedto")?GETPOST("affectedto"):(! empty($object->usertodo->id) && $object->usertodo->id > 0 ? $object->usertodo->id : $user->id),'affectedto',1);
|
||||
/*
|
||||
if (empty($donotclearsession))
|
||||
{
|
||||
$assignedtouser=GETPOST("assignedtouser")?GETPOST("assignedtouser"):(! empty($object->usertodo->id) && $object->usertodo->id > 0 ? $object->usertodo->id : $user->id);
|
||||
$_SESSION['assignedtouser']=dol_json_encode(array($assignedtouser=>array('id'=>$assignedtouser,'transparency'=>1,'mandatory'=>1)));
|
||||
}*/
|
||||
print $form->select_dolusers_forevent(($action=='create'?'add':'update'),'assignedtouser',1);
|
||||
//print $form->select_dolusers(GETPOST("assignedtouser")?GETPOST("assignedtouser"):(! empty($object->usertodo->id) && $object->usertodo->id > 0 ? $object->usertodo->id : $user->id),'affectedto',1);
|
||||
print '</td></tr>';
|
||||
|
||||
print '</table>';
|
||||
@ -771,22 +799,17 @@ if ($action == 'create')
|
||||
// View or edit
|
||||
if ($id > 0)
|
||||
{
|
||||
$result=$object->fetch($id);
|
||||
$object->fetch_optionals($id,$extralabels);
|
||||
$result1=$object->fetch($id);
|
||||
$result2=$object->fetch_thirdparty();
|
||||
$result3=$object->fetch_userassigned();
|
||||
$result4=$object->fetch_optionals($id,$extralabels);
|
||||
|
||||
if ($result < 0)
|
||||
if ($result1 < 0 || $result2 < 0 || $result3 < 0 || $result4 < 0)
|
||||
{
|
||||
dol_print_error($db,$object->error);
|
||||
exit;
|
||||
}
|
||||
|
||||
$societe = new Societe($db);
|
||||
if ($object->societe->id)
|
||||
{
|
||||
$result=$societe->fetch($object->societe->id);
|
||||
}
|
||||
$object->societe = $societe;
|
||||
|
||||
if ($object->author->id > 0) { $tmpuser=new User($db); $res=$tmpuser->fetch($object->author->id); $object->author=$tmpuser; }
|
||||
if ($object->usermod->id > 0) { $tmpuser=new User($db); $res=$tmpuser->fetch($object->usermod->id); $object->usermod=$tmpuser; }
|
||||
if ($object->usertodo->id > 0) { $tmpuser=new User($db); $res=$tmpuser->fetch($object->usertodo->id); $object->usertodo=$tmpuser; }
|
||||
@ -901,11 +924,12 @@ if ($id > 0)
|
||||
$listofuserid=array();
|
||||
if (empty($donotclearsession))
|
||||
{
|
||||
if (is_object($object->usertodo)) $listofuserid[$object->usertodo->id]=array('id'=>$object->usertodo->id,'transparency'=>$object->transparency);
|
||||
if (is_object($object->usertodo)) $listofuserid[$object->usertodo->id]=array('id'=>$object->usertodo->id,'transparency'=>$object->transparency); // Owner first
|
||||
$listofuserid=array_merge($listofuserid,$object->userassigned);
|
||||
$_SESSION['assignedtouser']=dol_json_encode($listofuserid);
|
||||
}
|
||||
print $form->select_dolusers_forevent(($action=='create'?'add':'update'),'affectedto',1);
|
||||
//print $form->select_dolusers($object->usertodo->id>0?$object->usertodo->id:-1,'affectedto',1);
|
||||
print $form->select_dolusers_forevent(($action=='create'?'add':'update'),'assignedtouser',1);
|
||||
//print $form->select_dolusers($object->usertodo->id>0?$object->usertodo->id:-1,'assignedtouser',1);
|
||||
print '</td></tr>';
|
||||
|
||||
print '</table><br><br><table class="border" width="100%">';
|
||||
@ -934,12 +958,12 @@ if ($id > 0)
|
||||
print '<td>';
|
||||
$events=array();
|
||||
$events[]=array('method' => 'getContacts', 'url' => dol_buildpath('/core/ajax/contacts.php',1), 'htmlname' => 'contactid', 'params' => array('add-customer-contact' => 'disabled'));
|
||||
print $form->select_company($object->societe->id,'socid','',1,1,0,$events);
|
||||
print $form->select_company($object->thirdparty->id,'socid','',1,1,0,$events);
|
||||
print '</td>';
|
||||
|
||||
// Contact
|
||||
print '<td>'.$langs->trans("Contact").'</td><td width="30%">';
|
||||
$form->select_contacts($object->societe->id, $object->contact->id,'contactid',1);
|
||||
$form->select_contacts($object->thirdparty->id, $object->contact->id,'contactid',1);
|
||||
print '</td></tr>';
|
||||
}
|
||||
|
||||
@ -953,7 +977,7 @@ if ($id > 0)
|
||||
$langs->load("project");
|
||||
|
||||
print '<tr><td width="30%" valign="top">'.$langs->trans("Project").'</td><td colspan="3">';
|
||||
$numprojet=$formproject->select_projects($object->societe->id,$object->fk_project,'projectid');
|
||||
$numprojet=$formproject->select_projects($object->thirdparty->id,$object->fk_project,'projectid');
|
||||
if ($numprojet==0)
|
||||
{
|
||||
print ' <a href="../../projet/card.php?socid='.$societe->id.'&action=create">'.$langs->trans("AddProject").'</a>';
|
||||
@ -1094,8 +1118,17 @@ if ($id > 0)
|
||||
}
|
||||
|
||||
// Assigned to
|
||||
print '<tr><td width="30%" class="nowrap">'.$langs->trans("ActionAffectedTo").'</td><td>';
|
||||
if ($object->usertodo->id > 0) print $object->usertodo->getNomUrl(1);
|
||||
//if ($object->usertodo->id > 0) print $object->usertodo->getNomUrl(1);
|
||||
print '<tr><td width="30%" class="nowrap">'.$langs->trans("ActionAffectedTo").'</td><td>';
|
||||
$listofuserid=array();
|
||||
if (empty($donotclearsession))
|
||||
{
|
||||
if (is_object($object->usertodo)) $listofuserid[$object->usertodo->id]=array('id'=>$object->usertodo->id,'transparency'=>$object->transparency); // Owner first
|
||||
$listofuserid=array_merge($listofuserid,$object->userassigned);
|
||||
$_SESSION['assignedtouser']=dol_json_encode($listofuserid);
|
||||
//var_dump($_SESSION['assignedtouser']);
|
||||
}
|
||||
print $form->select_dolusers_forevent('view','assignedtouser',1);
|
||||
print '</td></tr>';
|
||||
|
||||
print '</table><br><br><table class="border" width="100%">';
|
||||
@ -1118,12 +1151,12 @@ if ($id > 0)
|
||||
// Third party - Contact
|
||||
if ($conf->societe->enabled)
|
||||
{
|
||||
print '<tr><td width="30%">'.$langs->trans("ActionOnCompany").'</td><td>'.($object->societe->id?$object->societe->getNomUrl(1):$langs->trans("None"));
|
||||
if ($object->societe->id && $object->type_code == 'AC_TEL')
|
||||
print '<tr><td width="30%">'.$langs->trans("ActionOnCompany").'</td><td>'.($object->thirdparty->id?$object->thirdparty->getNomUrl(1):$langs->trans("None"));
|
||||
if (is_object($object->thirdparty) && $object->thirdparty->id > 0 && $object->type_code == 'AC_TEL')
|
||||
{
|
||||
if ($object->societe->fetch($object->societe->id))
|
||||
if ($object->thirdparty->fetch($object->thirdparty->id))
|
||||
{
|
||||
print "<br>".dol_print_phone($object->societe->phone);
|
||||
print "<br>".dol_print_phone($object->thirdparty->phone);
|
||||
}
|
||||
}
|
||||
print '</td>';
|
||||
|
||||
@ -62,15 +62,16 @@ class ActionComm extends CommonObject
|
||||
var $priority; // Small int (0 By default)
|
||||
var $note; // Description
|
||||
|
||||
var $userassigned; // Array of user ids
|
||||
var $userassigned = array(); // Array of user ids
|
||||
var $usertodo; // Object user of owner
|
||||
var $userdone; // Object user that did action (deprecated)
|
||||
|
||||
var $socid;
|
||||
var $contactid;
|
||||
var $societe; // Company linked to action (optional)
|
||||
var $contact; // Contact linked to action (optional)
|
||||
var $fk_project; // Id of project (optional)
|
||||
|
||||
|
||||
// Properties for links to other objects
|
||||
var $fk_element; // Id of record
|
||||
var $elementtype; // Type of record. This if property ->element of object linked to.
|
||||
@ -191,10 +192,10 @@ class ActionComm extends CommonObject
|
||||
$sql.= (isset($this->durationp) && $this->durationp >= 0 && $this->durationp != ''?"'".$this->durationp."'":"null").","; // deprecated
|
||||
$sql.= (isset($this->type_id)?$this->type_id:"null").",";
|
||||
$sql.= (isset($this->code)?" '".$this->code."'":"null").",";
|
||||
$sql.= (isset($this->societe->id) && $this->societe->id > 0?" '".$this->societe->id."'":"null").",";
|
||||
$sql.= (isset($this->socid) && $this->socid > 0?" '".$this->socid."'":"null").",";
|
||||
$sql.= (isset($this->fk_project) && $this->fk_project > 0?" '".$this->fk_project."'":"null").",";
|
||||
$sql.= " '".$this->db->escape($this->note)."',";
|
||||
$sql.= (isset($this->contact->id) && $this->contact->id > 0?"'".$this->contact->id."'":"null").",";
|
||||
$sql.= (isset($this->contactid) && $this->contactid > 0?"'".$this->contactid."'":"null").",";
|
||||
$sql.= (isset($user->id) && $user->id > 0 ? "'".$user->id."'":"null").",";
|
||||
$sql.= (isset($this->usertodo->id) && $this->usertodo->id > 0?"'".$this->usertodo->id."'":"null").",";
|
||||
$sql.= (isset($this->userdone->id) && $this->userdone->id > 0?"'".$this->userdone->id."'":"null").",";
|
||||
@ -211,22 +212,43 @@ class ActionComm extends CommonObject
|
||||
{
|
||||
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."actioncomm","id");
|
||||
|
||||
// Actions on extra fields (by external module or standard code)
|
||||
$hookmanager->initHooks(array('actioncommdao'));
|
||||
$parameters=array('actcomm'=>$this->id);
|
||||
$reshook=$hookmanager->executeHooks('insertExtraFields',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks
|
||||
if (empty($reshook))
|
||||
// Now insert assignedusers
|
||||
if (! $error)
|
||||
{
|
||||
foreach($this->userassigned as $key => $val)
|
||||
{
|
||||
$sql ="INSERT INTO ".MAIN_DB_PREFIX."actioncomm_resources(fk_actioncomm, element_type, fk_element, mandatory, transparency, answer_status)";
|
||||
$sql.=" VALUES(".$this->id.", 'user', ".$val['id'].", ".($val['mandatory']?$val['mandatory']:'0').", ".($val['transparency']?$val['transparency']:'0').", ".($val['answer_status']?$val['answer_status']:'0').")";
|
||||
|
||||
$resql = $this->db->query($sql);
|
||||
if (! $resql)
|
||||
{
|
||||
$error++;
|
||||
$this->errors[]=$this->db->lasterror();
|
||||
}
|
||||
//var_dump($sql);exit;
|
||||
}
|
||||
}
|
||||
|
||||
if (! $error)
|
||||
{
|
||||
if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used
|
||||
{
|
||||
$result=$this->insertExtraFields();
|
||||
if ($result < 0)
|
||||
{
|
||||
$error++;
|
||||
}
|
||||
}
|
||||
// Actions on extra fields (by external module or standard code)
|
||||
$hookmanager->initHooks(array('actioncommdao'));
|
||||
$parameters=array('actcomm'=>$this->id);
|
||||
$reshook=$hookmanager->executeHooks('insertExtraFields',$parameters,$this,$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=$this->insertExtraFields();
|
||||
if ($result < 0)
|
||||
{
|
||||
$error++;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if ($reshook < 0) $error++;
|
||||
}
|
||||
else if ($reshook < 0) $error++;
|
||||
|
||||
if (! $error && ! $notrigger)
|
||||
{
|
||||
@ -336,10 +358,12 @@ class ActionComm extends CommonObject
|
||||
$this->location = $obj->location;
|
||||
$this->transparency = $obj->transparency;
|
||||
|
||||
$this->socid = $obj->fk_soc; // To have fetch_thirdparty method working
|
||||
$this->societe->id = $obj->fk_soc;
|
||||
$this->contact->id = $obj->fk_contact;
|
||||
$this->fk_project = $obj->fk_project;
|
||||
$this->socid = $obj->fk_soc; // To have fetch_thirdparty method working
|
||||
$this->contactid = $obj->fk_contact;
|
||||
$this->fk_project = $obj->fk_project; // To have fetch_project method working
|
||||
|
||||
$this->societe->id = $obj->fk_soc; // For backward compatibility
|
||||
$this->contact->id = $obj->fk_contact; // For backward compatibility
|
||||
|
||||
$this->fk_element = $obj->fk_element;
|
||||
$this->elementtype = $obj->elementtype;
|
||||
@ -354,6 +378,34 @@ class ActionComm extends CommonObject
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Initialize this->userassigned array
|
||||
*
|
||||
* @return int <0 if KO, >0 if OK
|
||||
*/
|
||||
function fetch_userassigned()
|
||||
{
|
||||
global $langs;
|
||||
$sql.="SELECT fk_actioncomm, element_type, fk_element, answer_status, mandatory, transparency";
|
||||
$sql.=" FROM ".MAIN_DB_PREFIX."actioncomm_resources";
|
||||
$sql.=" WHERE element_type = 'user' AND fk_actioncomm = ".$this->id;
|
||||
$resql2=$this->db->query($sql);
|
||||
if ($resql2)
|
||||
{
|
||||
while ($obj = $this->db->fetch_object($resql2))
|
||||
{
|
||||
$this->userassigned[$obj->fk_element]=array('id'=>$obj->fk_element, 'mandatory'=>$obj->mandatory, 'answer_status'=>$obj->answer_status, 'transparency'=>$obj->transparency);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
dol_print_error($this->db);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete event from database
|
||||
*
|
||||
@ -498,7 +550,28 @@ class ActionComm extends CommonObject
|
||||
}
|
||||
else if ($reshook < 0) $error++;
|
||||
|
||||
if (! $notrigger)
|
||||
// Now insert assignedusers
|
||||
if (! $error)
|
||||
{
|
||||
$sql ="DELETE FROM ".MAIN_DB_PREFIX."actioncomm_resources where fk_actioncomm = ".$this->id." AND element_type = 'user'";
|
||||
$resql = $this->db->query($sql);
|
||||
|
||||
foreach($this->userassigned as $key => $val)
|
||||
{
|
||||
$sql ="INSERT INTO ".MAIN_DB_PREFIX."actioncomm_resources(fk_actioncomm, element_type, fk_element, mandatory, transparency, answer_status)";
|
||||
$sql.=" VALUES(".$this->id.", 'user', ".$val['id'].", ".($val['manadatory']?$val['manadatory']:'0').", ".($val['transparency']?$val['transparency']:'0').", ".($val['answer_status']?$val['answer_status']:'0').")";
|
||||
|
||||
$resql = $this->db->query($sql);
|
||||
if (! $resql)
|
||||
{
|
||||
$error++;
|
||||
$this->errors[]=$this->db->lasterror();
|
||||
}
|
||||
//var_dump($sql);exit;
|
||||
}
|
||||
}
|
||||
|
||||
if (! $error && ! $notrigger)
|
||||
{
|
||||
// Call trigger
|
||||
$result=$this->call_trigger('ACTION_MODIFY',$user);
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
/* Copyright (C) 2002-2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
* Copyright (C) 2004-2005 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2004-2014 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
|
||||
@ -37,6 +37,7 @@ class CActionComm
|
||||
var $type;
|
||||
var $libelle;
|
||||
var $active;
|
||||
var $color;
|
||||
|
||||
var $type_actions=array();
|
||||
|
||||
@ -59,7 +60,7 @@ class CActionComm
|
||||
*/
|
||||
function fetch($id)
|
||||
{
|
||||
$sql = "SELECT id, code, type, libelle, active";
|
||||
$sql = "SELECT id, code, type, libelle, color, active";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."c_actioncomm";
|
||||
if (is_numeric($id)) $sql.= " WHERE id=".$id;
|
||||
else $sql.= " WHERE code='".$id."'";
|
||||
@ -77,12 +78,13 @@ class CActionComm
|
||||
$this->type = $obj->type;
|
||||
$this->libelle = $obj->libelle;
|
||||
$this->active = $obj->active;
|
||||
$this->color = $obj->color;
|
||||
|
||||
$this->db->free($resql);
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
{
|
||||
$this->db->free($resql);
|
||||
return 0;
|
||||
}
|
||||
@ -95,7 +97,7 @@ class CActionComm
|
||||
}
|
||||
|
||||
/**
|
||||
* Return list of event types
|
||||
* Return list of event types: array(id=>label) or array(code=>label)
|
||||
*
|
||||
* @param int $active 1 or 0 to filter on event state active or not ('' by default = no filter)
|
||||
* @param string $idorcode 'id' or 'code'
|
||||
@ -111,7 +113,7 @@ class CActionComm
|
||||
$repid = array();
|
||||
$repcode = array();
|
||||
|
||||
$sql = "SELECT id, code, libelle, module, type";
|
||||
$sql = "SELECT id, code, libelle, module, type, color";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."c_actioncomm";
|
||||
if ($active != '') $sql.=" WHERE active=".$active;
|
||||
if (! empty($excludetype)) $sql.=($active != ''?" AND":" WHERE")." type <> '".$excludetype."'";
|
||||
|
||||
@ -60,12 +60,7 @@ $object = new ActionComm($db);
|
||||
if ($objectid > 0)
|
||||
{
|
||||
$ret = $object->fetch($objectid);
|
||||
if ($ret > 0) {
|
||||
$company=new Societe($db);
|
||||
$company->fetch($object->societe->id);
|
||||
$object->societe=$company; // For backward compatibility
|
||||
$object->thirdparty=$company;
|
||||
}
|
||||
$object->fetch_thirdparty();
|
||||
}
|
||||
|
||||
// Get parameters
|
||||
@ -112,7 +107,7 @@ if ($object->id > 0)
|
||||
|
||||
$now=dol_now();
|
||||
$delay_warning=$conf->global->MAIN_DELAY_ACTIONS_TODO*24*60*60;
|
||||
|
||||
|
||||
dol_fiche_head($head, 'documents', $langs->trans("Action"),0,'action');
|
||||
|
||||
// Affichage fiche action en mode visu
|
||||
@ -202,17 +197,17 @@ if ($object->id > 0)
|
||||
print '<tr><td width="30%" class="nowrap">'.$langs->trans("ActionAffectedTo").'</td><td>';
|
||||
if ($object->usertodo->id > 0) print $object->usertodo->getNomUrl(1);
|
||||
print '</td></tr>';
|
||||
|
||||
|
||||
print '</table><br><br><table class="border" width="100%">';
|
||||
|
||||
|
||||
// Third party - Contact
|
||||
print '<tr><td width="30%">'.$langs->trans("ActionOnCompany").'</td><td>'.($object->societe->id?$object->societe->getNomUrl(1):$langs->trans("None"));
|
||||
if ($object->societe->id && $object->type_code == 'AC_TEL')
|
||||
print '<tr><td width="30%">'.$langs->trans("ActionOnCompany").'</td><td>'.($object->thirdparty->id?$object->thirdparty->getNomUrl(1):$langs->trans("None"));
|
||||
if (is_object($object->thirdparty) && $object->thirdparty->id > 0 && $object->type_code == 'AC_TEL')
|
||||
{
|
||||
if ($object->societe->fetch($object->societe->id))
|
||||
if ($object->thirdparty->fetch($object->thirdparty->id))
|
||||
{
|
||||
print "<br>".dol_print_phone($object->societe->phone);
|
||||
print "<br>".dol_print_phone($object->thirdparty->phone);
|
||||
}
|
||||
}
|
||||
print '</td>';
|
||||
|
||||
@ -410,6 +410,8 @@ if ($resql)
|
||||
$event->location=$obj->location;
|
||||
$event->transparency=$obj->transparency;
|
||||
|
||||
$event->socid=$obj->fk_soc;
|
||||
$event->contactid=$obj->fk_contact;
|
||||
$event->societe->id=$obj->fk_soc;
|
||||
$event->contact->id=$obj->fk_contact;
|
||||
|
||||
@ -656,7 +658,7 @@ jQuery(document).ready(function() {
|
||||
if (ids == \'none\') /* No event */
|
||||
{
|
||||
/* alert(\'no event\'); */
|
||||
url = "'.DOL_URL_ROOT.'/comm/action/card.php?action=create&affectedto="+userid+"&datep="+year+month+day+hour+min+"00&backtopage='.urlencode($_SERVER["PHP_SELF"].'?year='.$year.'&month='.$month.'&day='.$day).'"
|
||||
url = "'.DOL_URL_ROOT.'/comm/action/card.php?action=create&assignedtouser="+userid+"&datep="+year+month+day+hour+min+"00&backtopage='.urlencode($_SERVER["PHP_SELF"].'?year='.$year.'&month='.$month.'&day='.$day).'"
|
||||
window.location.href = url;
|
||||
}
|
||||
else if (ids.indexOf(",") > -1) /* There is several events */
|
||||
@ -779,7 +781,7 @@ function show_day_events2($username, $day, $month, $year, $monthshown, $style, &
|
||||
}
|
||||
//$cssclass=$cssclass.' '.$cssclass.'_day_'.$ymd;
|
||||
|
||||
// Show rect of event
|
||||
// Define all rects with event (cases1 is first half hour, cases2 is second half hour)
|
||||
for ($h = $begin_h; $h < $end_h; $h++)
|
||||
{
|
||||
$color = ''; //init
|
||||
@ -797,12 +799,22 @@ function show_day_events2($username, $day, $month, $year, $monthshown, $style, &
|
||||
$busy=$event->transparency;
|
||||
$cases1[$h][$event->id]['busy']=$busy;
|
||||
$cases1[$h][$event->id]['string']=dol_print_date($event->date_start_in_calendar,'dayhour').' - '.dol_print_date($event->date_end_in_calendar,'dayhour').' - '.$event->label;
|
||||
$cases1[$h][$event->id]['typecode']=$event->type_code;
|
||||
if ($event->socid)
|
||||
{
|
||||
$cases1[$h][$event->id]['string'].='xxx';
|
||||
}
|
||||
}
|
||||
if ($event->date_start_in_calendar < $c && $dateendtouse > $b)
|
||||
{
|
||||
$busy=$event->transparency;
|
||||
$cases2[$h][$event->id]['busy']=$busy;
|
||||
$cases2[$h][$event->id]['string']=dol_print_date($event->date_start_in_calendar,'dayhour').' - '.dol_print_date($event->date_end_in_calendar,'dayhour').' - '.$event->label;
|
||||
$cases1[$h][$event->id]['typecode']=$event->type_code;
|
||||
if ($event->socid)
|
||||
{
|
||||
$cases2[$h][$event->id]['string'].='xxx';
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -812,6 +824,8 @@ function show_day_events2($username, $day, $month, $year, $monthshown, $style, &
|
||||
$cases2[$h][$event->id]['busy']=$busy;
|
||||
$cases1[$h][$event->id]['string']=$event->label;
|
||||
$cases2[$h][$event->id]['string']=$event->label;
|
||||
$cases1[$h][$event->id]['typecode']=$event->type_code;
|
||||
$cases2[$h][$event->id]['typecode']=$event->type_code;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -664,10 +664,12 @@ if ($action == 'send' && ! GETPOST('addfile') && ! GETPOST('removedfile') && ! G
|
||||
}
|
||||
|
||||
// Go back to draft
|
||||
if ($action == 'modif' && $user->rights->propal->creer) {
|
||||
if ($action == 'modif' && $user->rights->propal->creer)
|
||||
{
|
||||
$object->set_draft($user);
|
||||
|
||||
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) {
|
||||
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE))
|
||||
{
|
||||
// Define output language
|
||||
$outputlangs = $langs;
|
||||
if (! empty($conf->global->MAIN_MULTILANGS)) {
|
||||
@ -2010,26 +2012,34 @@ if ($action == 'create')
|
||||
$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)) {
|
||||
foreach ($extrafields->attribute_label as $key => $label) {
|
||||
if ($action == 'edit_extras') {
|
||||
if (empty($reshook) && ! empty($extrafields->attribute_label))
|
||||
{
|
||||
foreach ($extrafields->attribute_label as $key => $label)
|
||||
{
|
||||
if ($action == 'edit_extras')
|
||||
{
|
||||
$value = (isset($_POST ["options_" . $key]) ? $_POST ["options_" . $key] : $object->array_options ["options_" . $key]);
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
$value = $object->array_options ["options_" . $key];
|
||||
}
|
||||
if ($extrafields->attribute_type [$key] == 'separate') {
|
||||
if ($extrafields->attribute_type [$key] == 'separate')
|
||||
{
|
||||
print $extrafields->showSeparator($key);
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<tr><td';
|
||||
if (! empty($extrafields->attribute_required [$key]))
|
||||
print ' class="fieldrequired"';
|
||||
if (! empty($extrafields->attribute_required [$key])) print ' class="fieldrequired"';
|
||||
print '>' . $label . '</td><td colspan="5">';
|
||||
// Convert date into timestamp format
|
||||
if (in_array($extrafields->attribute_type [$key], array('date','datetime'))) {
|
||||
$value = isset($_POST ["options_" . $key]) ? dol_mktime($_POST ["options_" . $key . "hour"], $_POST ["options_" . $key . "min"], 0, $_POST ["options_" . $key . "month"], $_POST ["options_" . $key . "day"], $_POST ["options_" . $key . "year"]) : $db->jdate($object->array_options ['options_' . $key]);
|
||||
}
|
||||
|
||||
if ($action == 'edit_extras' && $user->rights->propal->creer && GETPOST('attribute') == $key) {
|
||||
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 . '">';
|
||||
@ -2041,7 +2051,9 @@ if ($action == 'create')
|
||||
print '<input type="submit" class="button" value="' . $langs->trans('Modify') . '">';
|
||||
|
||||
print '</form>';
|
||||
} else {
|
||||
}
|
||||
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>';
|
||||
|
||||
@ -34,9 +34,9 @@
|
||||
*/
|
||||
|
||||
include_once DOL_DOCUMENT_ROOT.'/core/class/commoninvoice.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT .'/product/class/product.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT .'/societe/class/client.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT .'/margin/lib/margins.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/societe/class/client.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/margin/lib/margins.lib.php';
|
||||
|
||||
|
||||
/**
|
||||
@ -3263,11 +3263,10 @@ class Facture extends CommonInvoice
|
||||
|
||||
|
||||
/**
|
||||
* \class FactureLigne
|
||||
* \brief Classe permettant la gestion des lignes de factures
|
||||
* Gere des lignes de la table llx_facturedet
|
||||
* Class to manage invoice lines.
|
||||
* Saved into database table llx_facturedet
|
||||
*/
|
||||
class FactureLigne extends CommonInvoiceLine
|
||||
class FactureLigne extends CommonInvoiceLine
|
||||
{
|
||||
var $db;
|
||||
var $error;
|
||||
|
||||
@ -149,6 +149,68 @@ if ($action == 'update' && ! $_POST["cancel"] && $user->rights->tax->charges->cr
|
||||
}
|
||||
}
|
||||
|
||||
// Action clone object
|
||||
if ($action == 'confirm_clone' && $confirm != 'yes') { $action=''; }
|
||||
if ($action == 'confirm_clone' && $confirm == 'yes' && ($user->rights->tax->charges->creer))
|
||||
{
|
||||
|
||||
$db->begin();
|
||||
|
||||
$originalId = $id;
|
||||
|
||||
$object = new ChargeSociales($db);
|
||||
$object->fetch($id);
|
||||
|
||||
if ($object->id > 0)
|
||||
{
|
||||
$object->paye = 0;
|
||||
$object->id = $object->ref = null;
|
||||
|
||||
if(GETPOST('clone_for_next_month') != '') {
|
||||
|
||||
$object->date_ech = strtotime('+1month', $object->date_ech);
|
||||
$object->periode = strtotime('+1month', $object->periode);
|
||||
}
|
||||
|
||||
if ($object->check())
|
||||
{
|
||||
$id = $object->create($user);
|
||||
if ($id > 0)
|
||||
{
|
||||
$db->commit();
|
||||
$db->close();
|
||||
|
||||
header("Location: ".$_SERVER["PHP_SELF"]."?id=".$id);
|
||||
exit;
|
||||
}
|
||||
else
|
||||
{
|
||||
$id=$originalId;
|
||||
$db->rollback();
|
||||
|
||||
if (count($object->errors))
|
||||
{
|
||||
setEventMessage($object->errors, 'errors');
|
||||
dol_print_error($db,$object->errors);
|
||||
}
|
||||
else
|
||||
{
|
||||
setEventMessage($langs->trans($object->error), 'errors');
|
||||
dol_print_error($db,$object->error);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$db->rollback();
|
||||
dol_print_error($db,$object->error);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
@ -239,7 +301,18 @@ if ($id > 0)
|
||||
$head=tax_prepare_head($object);
|
||||
|
||||
dol_fiche_head($head, 'card', $langs->trans("SocialContribution"),0,'bill');
|
||||
|
||||
|
||||
// Clone confirmation
|
||||
if ($action === 'clone')
|
||||
{
|
||||
$formclone=array(
|
||||
array('type' => 'checkbox', 'name' => 'clone_for_next_month','label' => $langs->trans("CloneTaxForNextMonth"), 'value' => 1),
|
||||
|
||||
);
|
||||
|
||||
print $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id,$langs->trans('CloneTax'),$langs->trans('ConfirmCloneTax',$object->ref),'confirm_clone',$formclone,'yes');
|
||||
}
|
||||
|
||||
// Confirmation de la suppression de la charge
|
||||
if ($action == 'paid')
|
||||
{
|
||||
@ -419,6 +492,12 @@ if ($id > 0)
|
||||
{
|
||||
print "<a class=\"butAction\" href=\"".DOL_URL_ROOT."/compta/sociales/charges.php?id=$object->id&action=paid\">".$langs->trans("ClassifyPaid")."</a>";
|
||||
}
|
||||
|
||||
// Clone
|
||||
if ($user->rights->tax->charges->creer)
|
||||
{
|
||||
print "<a class=\"butAction\" href=\"".dol_buildpath("/compta/sociales/charges.php",1). "?id=$object->id&action=clone\">".$langs->trans("ToClone")."</a>";
|
||||
}
|
||||
|
||||
// Delete
|
||||
if ($user->rights->tax->charges->supprimer)
|
||||
|
||||
@ -106,7 +106,24 @@ class ChargeSociales extends CommonObject
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
/*
|
||||
* Check if a social contribution can be created into database
|
||||
*
|
||||
*/
|
||||
function check() {
|
||||
|
||||
$newamount=price2num($this->amount,'MT');
|
||||
|
||||
// Validation parametres
|
||||
if (! $newamount > 0 || empty($this->date_ech) || empty($this->periode))
|
||||
{
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a social contribution into database
|
||||
@ -121,12 +138,11 @@ class ChargeSociales extends CommonObject
|
||||
// Nettoyage parametres
|
||||
$newamount=price2num($this->amount,'MT');
|
||||
|
||||
// Validation parametres
|
||||
if (! $newamount > 0 || empty($this->date_ech) || empty($this->periode))
|
||||
{
|
||||
$this->error="ErrorBadParameter";
|
||||
return -2;
|
||||
}
|
||||
if(!$this->check()) {
|
||||
$this->error="ErrorBadParameter";
|
||||
return -2;
|
||||
}
|
||||
|
||||
|
||||
$this->db->begin();
|
||||
|
||||
|
||||
@ -358,10 +358,14 @@ abstract class CommonInvoice extends CommonObject
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
require_once DOL_DOCUMENT_ROOT .'/core/class/commonobjectline.class.php';
|
||||
|
||||
/**
|
||||
* Parent class of all other business classes for details of elements (invoices, contracts, proposals, orders, ...)
|
||||
*/
|
||||
abstract class CommonInvoiceLine extends CommonObject
|
||||
abstract class CommonInvoiceLine extends CommonObjectLine
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@ -2153,327 +2153,6 @@ abstract class CommonObject
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Function to get extra fields of a member into $this->array_options
|
||||
* This method is in most cases called by method fetch of objects but you can call it separately.
|
||||
*
|
||||
* @param int $rowid Id of line
|
||||
* @param array $optionsArray Array resulting of call of extrafields->fetch_name_optionals_label()
|
||||
* @return int <0 if error, 0 if no optionals to find nor found, 1 if a line is found and optional loaded
|
||||
*/
|
||||
function fetch_optionals($rowid='',$optionsArray='')
|
||||
{
|
||||
if (empty($rowid)) $rowid=$this->id;
|
||||
|
||||
if (! is_array($optionsArray))
|
||||
{
|
||||
// optionsArray not already loaded, so we load it
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
|
||||
$extrafields = new ExtraFields($this->db);
|
||||
$optionsArray = $extrafields->fetch_name_optionals_label($this->table_element);
|
||||
}
|
||||
|
||||
// Request to get complementary values
|
||||
if (count($optionsArray) > 0)
|
||||
{
|
||||
$sql = "SELECT rowid";
|
||||
foreach ($optionsArray as $name => $label)
|
||||
{
|
||||
$sql.= ", ".$name;
|
||||
}
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX.$this->table_element."_extrafields";
|
||||
$sql.= " WHERE fk_object = ".$rowid;
|
||||
|
||||
dol_syslog(get_class($this)."::fetch_optionals", LOG_DEBUG);
|
||||
$resql=$this->db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
$numrows=$this->db->num_rows($resql);
|
||||
if ($numrows)
|
||||
{
|
||||
$tab = $this->db->fetch_array($resql);
|
||||
|
||||
foreach ($tab as $key => $value)
|
||||
{
|
||||
// Test fetch_array ! is_int($key) because fetch_array seult is a mix table with Key as alpha and Key as int (depend db engine)
|
||||
if ($key != 'rowid' && $key != 'tms' && $key != 'fk_member' && ! is_int($key))
|
||||
{
|
||||
// we can add this attribute to adherent object
|
||||
$this->array_options["options_".$key]=$value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$this->db->free($resql);
|
||||
|
||||
if ($numrows) return $numrows;
|
||||
else return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
dol_print_error($this->db);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete all extra fields values for the current object.
|
||||
*
|
||||
* @return int <0 if KO, >0 if OK
|
||||
*/
|
||||
function deleteExtraFields()
|
||||
{
|
||||
global $langs;
|
||||
|
||||
$error=0;
|
||||
|
||||
$this->db->begin();
|
||||
|
||||
$sql_del = "DELETE FROM ".MAIN_DB_PREFIX.$this->table_element."_extrafields WHERE fk_object = ".$this->id;
|
||||
dol_syslog(get_class($this)."::deleteExtraFields delete", LOG_DEBUG);
|
||||
$resql=$this->db->query($sql_del);
|
||||
if (! $resql)
|
||||
{
|
||||
$this->error=$this->db->lasterror();
|
||||
$this->db->rollback();
|
||||
return -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->db->commit();
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add/Update all extra fields values for the current object.
|
||||
* All data to describe values to insert are stored into $this->array_options=array('keyextrafield'=>'valueextrafieldtoadd')
|
||||
*
|
||||
* @return int -1=error, O=did nothing, 1=OK
|
||||
*/
|
||||
function insertExtraFields()
|
||||
{
|
||||
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
|
||||
$langs->load('admin');
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
|
||||
$extrafields = new ExtraFields($this->db);
|
||||
$optionsArray = $extrafields->fetch_name_optionals_label($this->table_element);
|
||||
|
||||
foreach($this->array_options as $key => $value)
|
||||
{
|
||||
$attributeKey = substr($key,8); // Remove 'options_' prefix
|
||||
$attributeType = $extrafields->attribute_type[$attributeKey];
|
||||
$attributeSize = $extrafields->attribute_size[$attributeKey];
|
||||
$attributeLabel = $extrafields->attribute_label[$attributeKey];
|
||||
switch ($attributeType)
|
||||
{
|
||||
case 'int':
|
||||
if (!is_numeric($value) && $value!='')
|
||||
{
|
||||
$error++; $this->errors[]=$langs->trans("ExtraFieldHasWrongValue",$attributeLabel);
|
||||
return -1;
|
||||
}
|
||||
elseif ($value=='')
|
||||
{
|
||||
$this->array_options[$key] = null;
|
||||
}
|
||||
break;
|
||||
case 'price':
|
||||
$this->array_options[$key] = price2num($this->array_options[$key]);
|
||||
break;
|
||||
case 'date':
|
||||
$this->array_options[$key]=$this->db->idate($this->array_options[$key]);
|
||||
break;
|
||||
case 'datetime':
|
||||
$this->array_options[$key]=$this->db->idate($this->array_options[$key]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
$this->db->begin();
|
||||
|
||||
$sql_del = "DELETE FROM ".MAIN_DB_PREFIX.$this->table_element."_extrafields WHERE fk_object = ".$this->id;
|
||||
dol_syslog(get_class($this)."::insertExtraFields delete", LOG_DEBUG);
|
||||
$this->db->query($sql_del);
|
||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX.$this->table_element."_extrafields (fk_object";
|
||||
foreach($this->array_options as $key => $value)
|
||||
{
|
||||
$attributeKey = substr($key,8); // Remove 'options_' prefix
|
||||
// Add field of attribut
|
||||
if ($extrafields->attribute_type[$attributeKey] != 'separate') // Only for other type of separate
|
||||
$sql.=",".$attributeKey;
|
||||
}
|
||||
$sql .= ") VALUES (".$this->id;
|
||||
foreach($this->array_options as $key => $value)
|
||||
{
|
||||
$attributeKey = substr($key,8); // Remove 'options_' prefix
|
||||
// Add field o fattribut
|
||||
if($extrafields->attribute_type[$attributeKey] != 'separate') // Only for other type of separate)
|
||||
{
|
||||
if ($this->array_options[$key] != '')
|
||||
{
|
||||
$sql.=",'".$this->db->escape($this->array_options[$key])."'";
|
||||
}
|
||||
else
|
||||
{
|
||||
$sql.=",null";
|
||||
}
|
||||
}
|
||||
}
|
||||
$sql.=")";
|
||||
|
||||
dol_syslog(get_class($this)."::insertExtraFields insert", LOG_DEBUG);
|
||||
$resql = $this->db->query($sql);
|
||||
if (! $resql)
|
||||
{
|
||||
$this->error=$this->db->lasterror();
|
||||
$this->db->rollback();
|
||||
return -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->db->commit();
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
else return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to show lines of extrafields with output datas
|
||||
*
|
||||
* @param object $extrafields Extrafield Object
|
||||
* @param string $mode Show output (view) or input (edit) for extrafield
|
||||
* @param array $params Optionnal parameters
|
||||
* @param string $keyprefix Prefix string to add into name and id of field (can be used to avoid duplicate names)
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function showOptionals($extrafields, $mode='view', $params=0, $keyprefix='')
|
||||
{
|
||||
global $_POST, $conf;
|
||||
|
||||
$out = '';
|
||||
|
||||
if (count($extrafields->attribute_label) > 0)
|
||||
{
|
||||
$out .= "\n";
|
||||
$out .= '<!-- showOptionalsInput --> ';
|
||||
$out .= "\n";
|
||||
|
||||
$e = 0;
|
||||
foreach($extrafields->attribute_label as $key=>$label)
|
||||
{
|
||||
if (is_array($params) && count($params)>0) {
|
||||
if (array_key_exists('colspan',$params)) {
|
||||
$colspan=$params['colspan'];
|
||||
}
|
||||
}else {
|
||||
$colspan='3';
|
||||
}
|
||||
switch($mode) {
|
||||
case "view":
|
||||
$value=$this->array_options["options_".$key];
|
||||
break;
|
||||
case "edit":
|
||||
$value=(isset($_POST["options_".$key])?$_POST["options_".$key]:$this->array_options["options_".$key]);
|
||||
break;
|
||||
}
|
||||
if ($extrafields->attribute_type[$key] == 'separate')
|
||||
{
|
||||
$out .= $extrafields->showSeparator($key);
|
||||
}
|
||||
else
|
||||
{
|
||||
$csstyle='';
|
||||
if (is_array($params) && count($params)>0) {
|
||||
if (array_key_exists('style',$params)) {
|
||||
$csstyle=$params['style'];
|
||||
}
|
||||
}
|
||||
if ( !empty($conf->global->MAIN_EXTRAFIELDS_USE_TWO_COLUMS) && ($e % 2) == 0)
|
||||
{
|
||||
$out .= '<tr '.$csstyle.'>';
|
||||
$colspan='0';
|
||||
}
|
||||
else
|
||||
{
|
||||
$out .= '<tr '.$csstyle.'>';
|
||||
}
|
||||
// Convert date into timestamp format
|
||||
if (in_array($extrafields->attribute_type[$key],array('date','datetime')))
|
||||
{
|
||||
$value = isset($_POST["options_".$key])?dol_mktime($_POST["options_".$key."hour"], $_POST["options_".$key."min"], 0, $_POST["options_".$key."month"], $_POST["options_".$key."day"], $_POST["options_".$key."year"]):$this->db->jdate($this->array_options['options_'.$key]);
|
||||
}
|
||||
|
||||
if($extrafields->attribute_required[$key])
|
||||
$label = '<span class="fieldrequired">'.$label.'</span>';
|
||||
|
||||
$out .= '<td>'.$label.'</td>';
|
||||
$out .='<td'.($colspan?' colspan="'.$colspan.'"':'').'>';
|
||||
|
||||
switch($mode) {
|
||||
case "view":
|
||||
$out .= $extrafields->showOutputField($key,$value);
|
||||
break;
|
||||
case "edit":
|
||||
$out .= $extrafields->showInputField($key,$value,'',$keyprefix);
|
||||
break;
|
||||
}
|
||||
|
||||
$out .= '</td>'."\n";
|
||||
|
||||
if (! empty($conf->global->MAIN_EXTRAFIELDS_USE_TWO_COLUMS) && (($e % 2) == 1)) $out .= '</tr>';
|
||||
else $out .= '</tr>';
|
||||
$e++;
|
||||
}
|
||||
}
|
||||
$out .= "\n";
|
||||
$out .= '<!-- /showOptionalsInput --> ';
|
||||
$out .= '
|
||||
<script type="text/javascript">
|
||||
jQuery(document).ready(function() {
|
||||
function showOptions(child_list, parent_list)
|
||||
{
|
||||
var val = $("select[name=\"options_"+parent_list+"\"]").val();
|
||||
var parentVal = parent_list + ":" + val;
|
||||
if(val > 0) {
|
||||
$("select[name=\""+child_list+"\"] option[parent]").hide();
|
||||
$("select[name=\""+child_list+"\"] option[parent=\""+parentVal+"\"]").show();
|
||||
} else {
|
||||
$("select[name=\""+child_list+"\"] option").show();
|
||||
}
|
||||
}
|
||||
function setListDependencies() {
|
||||
jQuery("select option[parent]").parent().each(function() {
|
||||
var child_list = $(this).attr("name");
|
||||
var parent = $(this).find("option[parent]:first").attr("parent");
|
||||
var infos = parent.split(":");
|
||||
var parent_list = infos[0];
|
||||
$("select[name=\"options_"+parent_list+"\"]").change(function() {
|
||||
showOptions(child_list, parent_list);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
setListDependencies();
|
||||
});
|
||||
</script>';
|
||||
}
|
||||
return $out;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Function to check if an object is used by others.
|
||||
* Check is done into this->childtables. There is no check into llx_element_element.
|
||||
@ -3473,38 +3152,6 @@ abstract class CommonObject
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Call trigger based on this instance
|
||||
* NB: Error from trigger are stacked in interface->errors
|
||||
* 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 User $user Object user
|
||||
* @return int Result of run_triggers
|
||||
*/
|
||||
function call_trigger($trigger_name, $user)
|
||||
{
|
||||
global $langs,$conf;
|
||||
|
||||
include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
|
||||
$interface=new Interfaces($this->db);
|
||||
$result=$interface->run_triggers($trigger_name,$this,$user,$langs,$conf);
|
||||
|
||||
if ($result < 0)
|
||||
{
|
||||
if (!empty($this->errors))
|
||||
{
|
||||
$this->errors=array_merge($this->errors,$interface->errors);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->errors=$interface->errors;
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Common function for all objects extending CommonObject for generating documents
|
||||
*
|
||||
@ -3597,4 +3244,366 @@ abstract class CommonObject
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Functions common to commonobject and commonobjectline */
|
||||
|
||||
|
||||
/* For triggers */
|
||||
|
||||
|
||||
/**
|
||||
* Call trigger based on this instance
|
||||
* NB: Error from trigger are stacked in interface->errors
|
||||
* 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 User $user Object user
|
||||
* @return int Result of run_triggers
|
||||
*/
|
||||
function call_trigger($trigger_name, $user)
|
||||
{
|
||||
global $langs,$conf;
|
||||
|
||||
include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
|
||||
$interface=new Interfaces($this->db);
|
||||
$result=$interface->run_triggers($trigger_name,$this,$user,$langs,$conf);
|
||||
|
||||
if ($result < 0)
|
||||
{
|
||||
if (!empty($this->errors))
|
||||
{
|
||||
$this->errors=array_merge($this->errors,$interface->errors);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->errors=$interface->errors;
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
/* Functions for extrafields */
|
||||
|
||||
|
||||
/**
|
||||
* Function to get extra fields of a member into $this->array_options
|
||||
* This method is in most cases called by method fetch of objects but you can call it separately.
|
||||
*
|
||||
* @param int $rowid Id of line
|
||||
* @param array $optionsArray Array resulting of call of extrafields->fetch_name_optionals_label()
|
||||
* @return int <0 if error, 0 if no optionals to find nor found, 1 if a line is found and optional loaded
|
||||
*/
|
||||
function fetch_optionals($rowid='',$optionsArray='')
|
||||
{
|
||||
if (empty($rowid)) $rowid=$this->id;
|
||||
|
||||
if (! is_array($optionsArray))
|
||||
{
|
||||
// optionsArray not already loaded, so we load it
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
|
||||
$extrafields = new ExtraFields($this->db);
|
||||
$optionsArray = $extrafields->fetch_name_optionals_label($this->table_element);
|
||||
}
|
||||
|
||||
// Request to get complementary values
|
||||
if (count($optionsArray) > 0)
|
||||
{
|
||||
$sql = "SELECT rowid";
|
||||
foreach ($optionsArray as $name => $label)
|
||||
{
|
||||
$sql.= ", ".$name;
|
||||
}
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX.$this->table_element."_extrafields";
|
||||
$sql.= " WHERE fk_object = ".$rowid;
|
||||
|
||||
dol_syslog(get_class($this)."::fetch_optionals", LOG_DEBUG);
|
||||
$resql=$this->db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
$numrows=$this->db->num_rows($resql);
|
||||
if ($numrows)
|
||||
{
|
||||
$tab = $this->db->fetch_array($resql);
|
||||
|
||||
foreach ($tab as $key => $value)
|
||||
{
|
||||
// Test fetch_array ! is_int($key) because fetch_array seult is a mix table with Key as alpha and Key as int (depend db engine)
|
||||
if ($key != 'rowid' && $key != 'tms' && $key != 'fk_member' && ! is_int($key))
|
||||
{
|
||||
// we can add this attribute to adherent object
|
||||
$this->array_options["options_".$key]=$value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$this->db->free($resql);
|
||||
|
||||
if ($numrows) return $numrows;
|
||||
else return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
dol_print_error($this->db);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete all extra fields values for the current object.
|
||||
*
|
||||
* @return int <0 if KO, >0 if OK
|
||||
*/
|
||||
function deleteExtraFields()
|
||||
{
|
||||
global $langs;
|
||||
|
||||
$error=0;
|
||||
|
||||
$this->db->begin();
|
||||
|
||||
$sql_del = "DELETE FROM ".MAIN_DB_PREFIX.$this->table_element."_extrafields WHERE fk_object = ".$this->id;
|
||||
dol_syslog(get_class($this)."::deleteExtraFields delete", LOG_DEBUG);
|
||||
$resql=$this->db->query($sql_del);
|
||||
if (! $resql)
|
||||
{
|
||||
$this->error=$this->db->lasterror();
|
||||
$this->db->rollback();
|
||||
return -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->db->commit();
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add/Update all extra fields values for the current object.
|
||||
* All data to describe values to insert are stored into $this->array_options=array('keyextrafield'=>'valueextrafieldtoadd')
|
||||
*
|
||||
* @return int -1=error, O=did nothing, 1=OK
|
||||
*/
|
||||
function insertExtraFields()
|
||||
{
|
||||
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
|
||||
$langs->load('admin');
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
|
||||
$extrafields = new ExtraFields($this->db);
|
||||
$optionsArray = $extrafields->fetch_name_optionals_label($this->table_element);
|
||||
|
||||
foreach($this->array_options as $key => $value)
|
||||
{
|
||||
$attributeKey = substr($key,8); // Remove 'options_' prefix
|
||||
$attributeType = $extrafields->attribute_type[$attributeKey];
|
||||
$attributeSize = $extrafields->attribute_size[$attributeKey];
|
||||
$attributeLabel = $extrafields->attribute_label[$attributeKey];
|
||||
switch ($attributeType)
|
||||
{
|
||||
case 'int':
|
||||
if (!is_numeric($value) && $value!='')
|
||||
{
|
||||
$error++; $this->errors[]=$langs->trans("ExtraFieldHasWrongValue",$attributeLabel);
|
||||
return -1;
|
||||
}
|
||||
elseif ($value=='')
|
||||
{
|
||||
$this->array_options[$key] = null;
|
||||
}
|
||||
break;
|
||||
case 'price':
|
||||
$this->array_options[$key] = price2num($this->array_options[$key]);
|
||||
break;
|
||||
case 'date':
|
||||
$this->array_options[$key]=$this->db->idate($this->array_options[$key]);
|
||||
break;
|
||||
case 'datetime':
|
||||
$this->array_options[$key]=$this->db->idate($this->array_options[$key]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
$this->db->begin();
|
||||
|
||||
$sql_del = "DELETE FROM ".MAIN_DB_PREFIX.$this->table_element."_extrafields WHERE fk_object = ".$this->id;
|
||||
dol_syslog(get_class($this)."::insertExtraFields delete", LOG_DEBUG);
|
||||
$this->db->query($sql_del);
|
||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX.$this->table_element."_extrafields (fk_object";
|
||||
foreach($this->array_options as $key => $value)
|
||||
{
|
||||
$attributeKey = substr($key,8); // Remove 'options_' prefix
|
||||
// Add field of attribut
|
||||
if ($extrafields->attribute_type[$attributeKey] != 'separate') // Only for other type of separate
|
||||
$sql.=",".$attributeKey;
|
||||
}
|
||||
$sql .= ") VALUES (".$this->id;
|
||||
foreach($this->array_options as $key => $value)
|
||||
{
|
||||
$attributeKey = substr($key,8); // Remove 'options_' prefix
|
||||
// Add field o fattribut
|
||||
if($extrafields->attribute_type[$attributeKey] != 'separate') // Only for other type of separate)
|
||||
{
|
||||
if ($this->array_options[$key] != '')
|
||||
{
|
||||
$sql.=",'".$this->db->escape($this->array_options[$key])."'";
|
||||
}
|
||||
else
|
||||
{
|
||||
$sql.=",null";
|
||||
}
|
||||
}
|
||||
}
|
||||
$sql.=")";
|
||||
|
||||
dol_syslog(get_class($this)."::insertExtraFields insert", LOG_DEBUG);
|
||||
$resql = $this->db->query($sql);
|
||||
if (! $resql)
|
||||
{
|
||||
$this->error=$this->db->lasterror();
|
||||
$this->db->rollback();
|
||||
return -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->db->commit();
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
else return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to show lines of extrafields with output datas
|
||||
*
|
||||
* @param object $extrafields Extrafield Object
|
||||
* @param string $mode Show output (view) or input (edit) for extrafield
|
||||
* @param array $params Optionnal parameters
|
||||
* @param string $keyprefix Prefix string to add into name and id of field (can be used to avoid duplicate names)
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function showOptionals($extrafields, $mode='view', $params=0, $keyprefix='')
|
||||
{
|
||||
global $_POST, $conf;
|
||||
|
||||
$out = '';
|
||||
|
||||
if (count($extrafields->attribute_label) > 0)
|
||||
{
|
||||
$out .= "\n";
|
||||
$out .= '<!-- showOptionalsInput --> ';
|
||||
$out .= "\n";
|
||||
|
||||
$e = 0;
|
||||
foreach($extrafields->attribute_label as $key=>$label)
|
||||
{
|
||||
if (is_array($params) && count($params)>0) {
|
||||
if (array_key_exists('colspan',$params)) {
|
||||
$colspan=$params['colspan'];
|
||||
}
|
||||
}else {
|
||||
$colspan='3';
|
||||
}
|
||||
switch($mode) {
|
||||
case "view":
|
||||
$value=$this->array_options["options_".$key];
|
||||
break;
|
||||
case "edit":
|
||||
$value=(isset($_POST["options_".$key])?$_POST["options_".$key]:$this->array_options["options_".$key]);
|
||||
break;
|
||||
}
|
||||
if ($extrafields->attribute_type[$key] == 'separate')
|
||||
{
|
||||
$out .= $extrafields->showSeparator($key);
|
||||
}
|
||||
else
|
||||
{
|
||||
$csstyle='';
|
||||
if (is_array($params) && count($params)>0) {
|
||||
if (array_key_exists('style',$params)) {
|
||||
$csstyle=$params['style'];
|
||||
}
|
||||
}
|
||||
if ( !empty($conf->global->MAIN_EXTRAFIELDS_USE_TWO_COLUMS) && ($e % 2) == 0)
|
||||
{
|
||||
$out .= '<tr '.$csstyle.'>';
|
||||
$colspan='0';
|
||||
}
|
||||
else
|
||||
{
|
||||
$out .= '<tr '.$csstyle.'>';
|
||||
}
|
||||
// Convert date into timestamp format
|
||||
if (in_array($extrafields->attribute_type[$key],array('date','datetime')))
|
||||
{
|
||||
$value = isset($_POST["options_".$key])?dol_mktime($_POST["options_".$key."hour"], $_POST["options_".$key."min"], 0, $_POST["options_".$key."month"], $_POST["options_".$key."day"], $_POST["options_".$key."year"]):$this->db->jdate($this->array_options['options_'.$key]);
|
||||
}
|
||||
|
||||
if($extrafields->attribute_required[$key])
|
||||
$label = '<span class="fieldrequired">'.$label.'</span>';
|
||||
|
||||
$out .= '<td>'.$label.'</td>';
|
||||
$out .='<td'.($colspan?' colspan="'.$colspan.'"':'').'>';
|
||||
|
||||
switch($mode) {
|
||||
case "view":
|
||||
$out .= $extrafields->showOutputField($key,$value);
|
||||
break;
|
||||
case "edit":
|
||||
$out .= $extrafields->showInputField($key,$value,'',$keyprefix);
|
||||
break;
|
||||
}
|
||||
|
||||
$out .= '</td>'."\n";
|
||||
|
||||
if (! empty($conf->global->MAIN_EXTRAFIELDS_USE_TWO_COLUMS) && (($e % 2) == 1)) $out .= '</tr>';
|
||||
else $out .= '</tr>';
|
||||
$e++;
|
||||
}
|
||||
}
|
||||
$out .= "\n";
|
||||
$out .= '<!-- /showOptionalsInput --> ';
|
||||
$out .= '
|
||||
<script type="text/javascript">
|
||||
jQuery(document).ready(function() {
|
||||
function showOptions(child_list, parent_list)
|
||||
{
|
||||
var val = $("select[name=\"options_"+parent_list+"\"]").val();
|
||||
var parentVal = parent_list + ":" + val;
|
||||
if(val > 0) {
|
||||
$("select[name=\""+child_list+"\"] option[parent]").hide();
|
||||
$("select[name=\""+child_list+"\"] option[parent=\""+parentVal+"\"]").show();
|
||||
} else {
|
||||
$("select[name=\""+child_list+"\"] option").show();
|
||||
}
|
||||
}
|
||||
function setListDependencies() {
|
||||
jQuery("select option[parent]").parent().each(function() {
|
||||
var child_list = $(this).attr("name");
|
||||
var parent = $(this).find("option[parent]:first").attr("parent");
|
||||
var infos = parent.split(":");
|
||||
var parent_list = infos[0];
|
||||
$("select[name=\"options_"+parent_list+"\"]").change(function() {
|
||||
showOptions(child_list, parent_list);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
setListDependencies();
|
||||
});
|
||||
</script>';
|
||||
}
|
||||
return $out;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -26,36 +26,12 @@
|
||||
* Parent class for class inheritance lines of business objects
|
||||
* This class is useless for the moment so no inherit are done on it
|
||||
*/
|
||||
abstract class CommonObjectLine
|
||||
abstract class CommonObjectLine extends CommonObject
|
||||
{
|
||||
/**
|
||||
* Call trigger based on this instance
|
||||
* NB: Error from trigger are stacked in interface->errors
|
||||
* 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 User $user Object user
|
||||
* @return int Result of run_triggers
|
||||
*/
|
||||
function call_trigger($trigger_name, $user)
|
||||
{
|
||||
global $langs,$conf;
|
||||
// TODO
|
||||
|
||||
include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
|
||||
$interface=new Interfaces($this->db);
|
||||
$result=$interface->run_triggers($trigger_name,$this,$user,$langs,$conf);
|
||||
if ($result < 0)
|
||||
{
|
||||
if (!empty($this->errors))
|
||||
{
|
||||
$this->errors=array_merge($this->errors,$interface->errors);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->errors=$interface->errors;
|
||||
}
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
// Currently we need function at end of file CommonObject for all object lines. Should find a way to avoid duplicate code.
|
||||
|
||||
// For the moment we use the extends on CommonObject until PHP min is 5.4 so use Traits.
|
||||
}
|
||||
|
||||
|
||||
@ -804,8 +804,10 @@ class Form
|
||||
// Construct $out and $outarray
|
||||
$out.= '<select id="'.$htmlname.'" class="flat" name="'.$htmlname.'">'."\n";
|
||||
|
||||
$textifempty=' ';
|
||||
if (! empty($conf->use_javascript_ajax) || $forcecombo) $textifempty=' ';
|
||||
$textifempty='';
|
||||
// Do not use textempty = ' ' or ' ' here, or search on key will search on ' key'.
|
||||
//$textifempty=' ';
|
||||
//if (! empty($conf->use_javascript_ajax) || $forcecombo) $textifempty='';
|
||||
if ($showempty) $out.= '<option value="-1">'.$textifempty.'</option>'."\n";
|
||||
|
||||
$num = $this->db->num_rows($resql);
|
||||
@ -1275,6 +1277,7 @@ class Form
|
||||
|
||||
/**
|
||||
* Return select list of users. Selected users are stored into session.
|
||||
* List of users are provided into $_SESSION['assignedtouser'].
|
||||
*
|
||||
* @param string $action Value for $action
|
||||
* @param string $htmlname Field name in form
|
||||
@ -1295,23 +1298,35 @@ class Form
|
||||
global $conf,$user,$langs;
|
||||
|
||||
$userstatic=new User($this->db);
|
||||
$out='';
|
||||
|
||||
// Method with no ajax
|
||||
//$out.='<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
|
||||
$out.='<input type="hidden" class="removedassignedhidden" name="removedassigned" value="">';
|
||||
$out.='<script type="text/javascript" language="javascript">jQuery(document).ready(function () { jQuery(".removedassigned").click(function() { jQuery(".removedassignedhidden").val(jQuery(this).val()); });})</script>';
|
||||
$out.=$this->select_dolusers('', $htmlname, $show_empty, $exclude, $disabled, $include, $enableonly, $force_entity, $maxlength, $showstatus, $morefilter);
|
||||
$out.='<input type="submit" class="button" name="'.$action.'assignedtouser" value="'.dol_escape_htmltag($langs->trans("Add")).'">';
|
||||
if ($action == 'view')
|
||||
{
|
||||
$out.='';
|
||||
}
|
||||
else
|
||||
{
|
||||
$out.='<input type="hidden" class="removedassignedhidden" name="removedassigned" value="">';
|
||||
$out.='<script type="text/javascript" language="javascript">jQuery(document).ready(function () { jQuery(".removedassigned").click(function() { jQuery(".removedassignedhidden").val(jQuery(this).val()); });})</script>';
|
||||
$out.=$this->select_dolusers('', $htmlname, $show_empty, $exclude, $disabled, $include, $enableonly, $force_entity, $maxlength, $showstatus, $morefilter);
|
||||
$out.='<input type="submit" class="button" name="'.$action.'assignedtouser" value="'.dol_escape_htmltag($langs->trans("Add")).'">';
|
||||
}
|
||||
$assignedtouser=array();
|
||||
if (!empty($_SESSION['assignedtouser'])) $assignedtouser=dol_json_decode($_SESSION['assignedtouser'], true);
|
||||
if (count($assignedtouser)) $out.='<br>';
|
||||
$i=0;
|
||||
if (!empty($_SESSION['assignedtouser']))
|
||||
{
|
||||
$assignedtouser=dol_json_decode($_SESSION['assignedtouser'], true);
|
||||
}
|
||||
if (count($assignedtouser) && $action != 'view') $out.='<br>';
|
||||
$i=0; $ownerid=0;
|
||||
foreach($assignedtouser as $key => $value)
|
||||
{
|
||||
$userstatic->fetch($key);
|
||||
if ($value['id'] == $ownerid) continue;
|
||||
$userstatic->fetch($value['id']);
|
||||
$out.=$userstatic->getNomUrl(1);
|
||||
if ($i == 0) $out.=' ('.$langs->trans("Owner").')';
|
||||
$out.=' <input type="image" style="border: 0px;" src="'.img_picto($langs->trans("Remove"), 'delete', '', 0, 1).'" value="'.$userstatic->id.'" class="removedassigned" id="removedassigned_'.$userstatic->id.'" name="removedassigned_'.$userstatic->id.'">';
|
||||
if ($i == 0) { $ownerid = $value['id']; $out.=' ('.$langs->trans("Owner").')'; }
|
||||
if ($i > 0 && $action != 'view') $out.=' <input type="image" style="border: 0px;" src="'.img_picto($langs->trans("Remove"), 'delete', '', 0, 1).'" value="'.$userstatic->id.'" class="removedassigned" id="removedassigned_'.$userstatic->id.'" name="removedassigned_'.$userstatic->id.'">';
|
||||
//$out.=' '.($value['mandatory']?$langs->trans("Mandatory"):$langs->trans("Optional"));
|
||||
//$out.=' '.($value['transparency']?$langs->trans("Busy"):$langs->trans("NotBusy"));
|
||||
$out.='<br>';
|
||||
|
||||
@ -254,7 +254,7 @@ function dol_json_decode($json, $assoc=false)
|
||||
|
||||
foreach ($array as $key => $value)
|
||||
{
|
||||
$object->{$key} = $value;
|
||||
if ($key) $object->{$key} = $value;
|
||||
}
|
||||
|
||||
return $object;
|
||||
|
||||
@ -194,7 +194,8 @@ if (empty($inputalsopricewithtax)) $inputalsopricewithtax=0;
|
||||
|
||||
<?php
|
||||
//Line extrafield
|
||||
if (!empty($extrafieldsline)) {
|
||||
if (!empty($extrafieldsline))
|
||||
{
|
||||
print $line->showOptionals($extrafieldsline,'view',array('style'=>$bcdd[$var],'colspan'=>$coldisplay));
|
||||
}
|
||||
?>
|
||||
|
||||
@ -20,6 +20,8 @@
|
||||
|
||||
ALTER TABLE llx_bank_account ADD COLUMN fk_user_author integer;
|
||||
|
||||
ALTER TABLE llx_c_actioncomm ADD COLUMN color varchar(9);
|
||||
|
||||
ALTER TABLE llx_propal ADD COLUMN fk_user_modif integer after fk_user_author;
|
||||
ALTER TABLE llx_commande ADD COLUMN fk_user_modif integer after fk_user_author;
|
||||
ALTER TABLE llx_facture ADD COLUMN fk_user_modif integer after fk_user_author;
|
||||
@ -131,6 +133,8 @@ ALTER TABLE llx_user ADD COLUMN weeklyhours double(16,8);
|
||||
|
||||
ALTER TABLE llx_projet_task_time ADD COLUMN task_datehour datetime after task_date;
|
||||
|
||||
ALTER TABLE llx_actioncomm_resources CHANGE COLUMN transparent transparency smallint default 1;
|
||||
|
||||
|
||||
-- Localtaxes by thirds
|
||||
ALTER TABLE llx_c_tva MODIFY COLUMN localtax1 varchar(10);
|
||||
@ -1071,11 +1075,11 @@ CREATE TABLE llx_fichinterdet_extrafields
|
||||
|
||||
ALTER TABLE llx_fichinterdet_extrafields ADD INDEX idx_ficheinterdet_extrafields (fk_object);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS llx_usergroup_extrafields (
|
||||
CREATE TABLE llx_usergroup_extrafields (
|
||||
rowid integer AUTO_INCREMENT PRIMARY KEY,
|
||||
tms timestamp,
|
||||
fk_object integer NOT NULL,
|
||||
import_key varchar(14) -- import key
|
||||
) ENGINE=InnoDB ;
|
||||
) ENGINE=innodb;
|
||||
|
||||
ALTER TABLE llx_usergroup_extrafields ADD INDEX idx_usergroup_extrafields (fk_object);
|
||||
|
||||
@ -142,7 +142,7 @@ update llx_societe set barcode = null where (rowid, barcode) in (select max_rowi
|
||||
drop table tmp_societe_double;
|
||||
|
||||
|
||||
UPDATE llx_projet_task SET fk_task_parent = 0 WHERE fk_task_parent = rowid
|
||||
UPDATE llx_projet_task SET fk_task_parent = 0 WHERE fk_task_parent = rowid;
|
||||
|
||||
|
||||
UPDATE llx_actioncomm set fk_user_action = fk_user_done where fk_user_done > 0 and (fk_user_action is null or fk_user_action = 0);
|
||||
|
||||
@ -23,10 +23,10 @@
|
||||
create table llx_actioncomm_resources
|
||||
(
|
||||
rowid integer AUTO_INCREMENT PRIMARY KEY,
|
||||
fk_actioncomm integer NOT NULL,
|
||||
element_type varchar(50) NOT NULL,
|
||||
fk_element integer NOT NULL,
|
||||
fk_actioncomm integer NOT NULL, -- Id into llx_actioncomm
|
||||
element_type varchar(50) NOT NULL, -- Type of resource ('user', 'resource')
|
||||
fk_element integer NOT NULL, -- Id into table llx_user or llx_resource
|
||||
answer_status varchar(50) NULL,
|
||||
mandatory smallint,
|
||||
transparent smallint
|
||||
mandatory smallint,
|
||||
transparency smallint default 1 -- Used to say if event is 1=OPAQUE=busy or 0=TRANSPARENT
|
||||
) ENGINE=innodb;
|
||||
|
||||
@ -24,8 +24,9 @@ create table llx_c_actioncomm
|
||||
code varchar(12) NOT NULL,
|
||||
type varchar(10) DEFAULT 'system' NOT NULL,
|
||||
libelle varchar(48) NOT NULL,
|
||||
module varchar(16) DEFAULT NULL,
|
||||
module varchar(16) DEFAULT NULL,
|
||||
active tinyint DEFAULT 1 NOT NULL,
|
||||
todo tinyint,
|
||||
color varchar(9),
|
||||
position integer NOT NULL DEFAULT 0
|
||||
)ENGINE=innodb;
|
||||
|
||||
@ -132,7 +132,7 @@ if ($ok)
|
||||
}
|
||||
}
|
||||
|
||||
// Affiche version
|
||||
// Show database version
|
||||
if ($ok)
|
||||
{
|
||||
$version=$db->getVersion();
|
||||
@ -143,12 +143,15 @@ if ($ok)
|
||||
//print '<td align="right">'.join('.',$versionarray).'</td></tr>';
|
||||
}
|
||||
|
||||
// Force l'affichage de la progression
|
||||
// Show wait message
|
||||
print '<tr><td colspan="2">'.$langs->trans("PleaseBePatient").'</td></tr>';
|
||||
flush();
|
||||
|
||||
|
||||
// Run repair SQL file
|
||||
/* Start action here */
|
||||
|
||||
|
||||
// run_sql: Run repair SQL file
|
||||
if ($ok)
|
||||
{
|
||||
$dir = "mysql/migration/";
|
||||
@ -191,86 +194,169 @@ if ($ok)
|
||||
}
|
||||
|
||||
|
||||
// Search list of fields declared and list of fields created into databases and create fields missing
|
||||
$extrafields=new ExtraFields($db);
|
||||
$listofmodulesextra=array('societe'=>'societe','adherent'=>'adherent','product'=>'product',
|
||||
'socpeople'=>'socpeople', 'commande'=>'commande', 'facture'=>'facture',
|
||||
'commande_fournisseur'=>'commande_fournisseur', 'actioncomm'=>'actioncomm',
|
||||
'adherent_type'=>'adherent_type','user'=>'user','projet'=>'projet', 'projet_task'=>'projet_task');
|
||||
foreach($listofmodulesextra as $tablename => $elementtype)
|
||||
// sync_extrafields: Search list of fields declared and list of fields created into databases and create fields missing
|
||||
if ($ok)
|
||||
{
|
||||
// Get list of fields
|
||||
$tableextra=MAIN_DB_PREFIX.$tablename.'_extrafields';
|
||||
$extrafields=new ExtraFields($db);
|
||||
$listofmodulesextra=array('societe'=>'societe','adherent'=>'adherent','product'=>'product',
|
||||
'socpeople'=>'socpeople', 'commande'=>'commande', 'facture'=>'facture',
|
||||
'commande_fournisseur'=>'commande_fournisseur', 'actioncomm'=>'actioncomm',
|
||||
'adherent_type'=>'adherent_type','user'=>'user','projet'=>'projet', 'projet_task'=>'projet_task');
|
||||
foreach($listofmodulesextra as $tablename => $elementtype)
|
||||
{
|
||||
// Get list of fields
|
||||
$tableextra=MAIN_DB_PREFIX.$tablename.'_extrafields';
|
||||
|
||||
// Define $arrayoffieldsdesc
|
||||
$arrayoffieldsdesc=$extrafields->fetch_name_optionals_label($elementtype);
|
||||
// Define $arrayoffieldsdesc
|
||||
$arrayoffieldsdesc=$extrafields->fetch_name_optionals_label($elementtype);
|
||||
|
||||
// Define $arrayoffieldsfound
|
||||
$arrayoffieldsfound=array();
|
||||
$resql=$db->DDLDescTable($tableextra);
|
||||
if ($resql)
|
||||
{
|
||||
print '<tr><td>Check availability of extra field for '.$tableextra."<br>\n";
|
||||
$i=0;
|
||||
while($obj=$db->fetch_object($resql))
|
||||
{
|
||||
$fieldname=$fieldtype='';
|
||||
if (preg_match('/mysql/',$db->type))
|
||||
{
|
||||
$fieldname=$obj->Field;
|
||||
$fieldtype=$obj->Type;
|
||||
}
|
||||
else
|
||||
{
|
||||
$fieldname = isset($obj->Key)?$obj->Key:$obj->attname;
|
||||
$fieldtype = isset($obj->Type)?$obj->Type:'varchar';
|
||||
}
|
||||
// Define $arrayoffieldsfound
|
||||
$arrayoffieldsfound=array();
|
||||
$resql=$db->DDLDescTable($tableextra);
|
||||
if ($resql)
|
||||
{
|
||||
print '<tr><td>Check availability of extra field for '.$tableextra."<br>\n";
|
||||
$i=0;
|
||||
while($obj=$db->fetch_object($resql))
|
||||
{
|
||||
$fieldname=$fieldtype='';
|
||||
if (preg_match('/mysql/',$db->type))
|
||||
{
|
||||
$fieldname=$obj->Field;
|
||||
$fieldtype=$obj->Type;
|
||||
}
|
||||
else
|
||||
{
|
||||
$fieldname = isset($obj->Key)?$obj->Key:$obj->attname;
|
||||
$fieldtype = isset($obj->Type)?$obj->Type:'varchar';
|
||||
}
|
||||
|
||||
if (empty($fieldname)) continue;
|
||||
if (in_array($fieldname,array('rowid','tms','fk_object','import_key'))) continue;
|
||||
$arrayoffieldsfound[$fieldname]=array('type'=>$fieldtype);
|
||||
}
|
||||
if (empty($fieldname)) continue;
|
||||
if (in_array($fieldname,array('rowid','tms','fk_object','import_key'))) continue;
|
||||
$arrayoffieldsfound[$fieldname]=array('type'=>$fieldtype);
|
||||
}
|
||||
|
||||
// If it does not match, we create fields
|
||||
foreach($arrayoffieldsdesc as $code => $label)
|
||||
{
|
||||
if (! in_array($code,array_keys($arrayoffieldsfound)))
|
||||
{
|
||||
print 'Found field '.$code.' declared into '.MAIN_DB_PREFIX.'extrafields table but not found into desc of table '.$tableextra." -> ";
|
||||
$type=$extrafields->attribute_type[$code]; $value=$extrafields->attribute_size[$code]; $attribute=''; $default=''; $extra=''; $null='null';
|
||||
$field_desc=array(
|
||||
'type'=>$type,
|
||||
'value'=>$value,
|
||||
'attribute'=>$attribute,
|
||||
'default'=>$default,
|
||||
'extra'=>$extra,
|
||||
'null'=>$null
|
||||
);
|
||||
//var_dump($field_desc);exit;
|
||||
// If it does not match, we create fields
|
||||
foreach($arrayoffieldsdesc as $code => $label)
|
||||
{
|
||||
if (! in_array($code,array_keys($arrayoffieldsfound)))
|
||||
{
|
||||
print 'Found field '.$code.' declared into '.MAIN_DB_PREFIX.'extrafields table but not found into desc of table '.$tableextra." -> ";
|
||||
$type=$extrafields->attribute_type[$code]; $value=$extrafields->attribute_size[$code]; $attribute=''; $default=''; $extra=''; $null='null';
|
||||
$field_desc=array(
|
||||
'type'=>$type,
|
||||
'value'=>$value,
|
||||
'attribute'=>$attribute,
|
||||
'default'=>$default,
|
||||
'extra'=>$extra,
|
||||
'null'=>$null
|
||||
);
|
||||
//var_dump($field_desc);exit;
|
||||
|
||||
$result=$db->DDLAddField($tableextra,$code,$field_desc,"");
|
||||
if ($result < 0)
|
||||
{
|
||||
print "KO ".$db->lasterror."<br>\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
print "OK<br>\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
$result=$db->DDLAddField($tableextra,$code,$field_desc,"");
|
||||
if ($result < 0)
|
||||
{
|
||||
print "KO ".$db->lasterror."<br>\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
print "OK<br>\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
print "</td><td> </td></tr>\n";
|
||||
}
|
||||
print "</td><td> </td></tr>\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Clean data into ecm_directories table
|
||||
clean_data_ecm_directories();
|
||||
|
||||
// clean_data_ecm_dir: Clean data into ecm_directories table
|
||||
if ($ok)
|
||||
{
|
||||
clean_data_ecm_directories();
|
||||
}
|
||||
|
||||
|
||||
// Check and clean linked elements
|
||||
if (GETPOST('clean_linked_elements'))
|
||||
|
||||
/* From here, actions need a parameter */
|
||||
|
||||
|
||||
|
||||
// clean_linked_elements: Check and clean linked elements
|
||||
if ($ok && GETPOST('restore_thirdparties_logos'))
|
||||
{
|
||||
//$exts=array('gif','png','jpg');
|
||||
|
||||
$ext='';
|
||||
//foreach($exts as $ext)
|
||||
//{
|
||||
$sql="SELECT s.rowid, s.nom as name, s.logo FROM ".MAIN_DB_PREFIX."societe as s ORDER BY s.nom";
|
||||
$resql=$db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
$num=$db->num_rows($resql);
|
||||
$i=0;
|
||||
|
||||
while($i < $num)
|
||||
{
|
||||
$obj=$db->fetch_object($resql);
|
||||
|
||||
/*
|
||||
$name=preg_replace('/é/','',$obj->name);
|
||||
$name=preg_replace('/ /','_',$name);
|
||||
$name=preg_replace('/\'/','',$name);
|
||||
*/
|
||||
|
||||
$tmp=explode('.',$obj->logo);
|
||||
$name=$tmp[0];
|
||||
if (isset($tmp[1])) $ext='.'.$tmp[1];
|
||||
|
||||
if (! empty($name))
|
||||
{
|
||||
$filetotest=$dolibarr_main_data_root.'/societe/logos/'.$name.$ext;
|
||||
$filetotestsmall=$dolibarr_main_data_root.'/societe/logos/thumbs/'.$name.$ext;
|
||||
$exists=dol_is_file($filetotest);
|
||||
print 'Check thirdparty '.$obj->rowid.' name='.$obj->name.' logo='.$obj->logo.' file '.$filetotest." exists=".$exists."<br>\n";
|
||||
if ($exists)
|
||||
{
|
||||
$filetarget=$dolibarr_main_data_root.'/societe/'.$obj->rowid.'/logos/'.$name.$ext;
|
||||
$filetargetsmall=$dolibarr_main_data_root.'/societe/'.$obj->rowid.'/logos/thumbs/'.$name.'_small'.$ext;
|
||||
$existt=dol_is_file($filetarget);
|
||||
if (! $existt)
|
||||
{
|
||||
dol_mkdir($dolibarr_main_data_root.'/societe/'.$obj->rowid.'/logos');
|
||||
|
||||
print " -> Copy file ".$filetotest." -> ".$filetarget."<br>\n";
|
||||
dol_copy($filetotest, $filetarget, '', 0);
|
||||
}
|
||||
|
||||
$existtt=dol_is_file($filetargetsmall);
|
||||
if (! $existtt)
|
||||
{
|
||||
dol_mkdir($dolibarr_main_data_root.'/societe/'.$obj->rowid.'/logos/thumbs');
|
||||
|
||||
print " -> Copy file ".$filetotestsmall." -> ".$filetargetsmall."<br>\n";
|
||||
dol_copy($filetotestsmall, $filetargetsmall, '', 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$ok=0;
|
||||
dol_print_error($db);
|
||||
}
|
||||
//}
|
||||
}
|
||||
|
||||
|
||||
// clean_linked_elements: Check and clean linked elements
|
||||
if ($ok && GETPOST('clean_linked_elements'))
|
||||
{
|
||||
// propal => order
|
||||
print "</td><td>".checkLinkedElements('propal', 'commande')."</td></tr>\n";
|
||||
@ -292,8 +378,8 @@ if (GETPOST('clean_linked_elements'))
|
||||
}
|
||||
|
||||
|
||||
// Run purge of directory
|
||||
if (GETPOST('purge'))
|
||||
// clean_orphelin_dir: Run purge of directory
|
||||
if ($ok && GETPOST('clean_orphelin_dir'))
|
||||
{
|
||||
$conf->setValues($db);
|
||||
|
||||
|
||||
@ -343,8 +343,8 @@ if (! GETPOST("action") || preg_match('/upgrade/i',GETPOST('action')))
|
||||
// No specific scripts
|
||||
|
||||
// Tasks to do always and only into last targeted version
|
||||
$afterversionarray=explode('.','3.4.9'); // target is after this
|
||||
$beforeversionarray=explode('.','3.5.9'); // target is before this
|
||||
$afterversionarray=explode('.','3.6.9'); // target is after this
|
||||
$beforeversionarray=explode('.','3.7.9'); // target is before this
|
||||
if (versioncompare($versiontoarray,$afterversionarray) >= 0 && versioncompare($versiontoarray,$beforeversionarray) <= 0)
|
||||
{
|
||||
// Reload modules (this must be always and only into last targeted version)
|
||||
|
||||
@ -204,3 +204,6 @@ ACCOUNTING_VAT_ACCOUNT=Default accountancy code for collecting VAT
|
||||
ACCOUNTING_VAT_BUY_ACCOUNT=Default accountancy code for paying VAT
|
||||
ACCOUNTING_ACCOUNT_CUSTOMER=Accountancy code by default for customer thirdparties
|
||||
ACCOUNTING_ACCOUNT_SUPPLIER=Accountancy code by default for supplier thirdparties
|
||||
CloneTax=Clone a social contribution
|
||||
ConfirmCloneTax=Confirm the clone of a social contribution
|
||||
CloneTaxForNextMonth=Clone it for next month
|
||||
@ -323,8 +323,6 @@ class Project extends CommonObject
|
||||
$this->note_private = $obj->note_private;
|
||||
$this->note_public = $obj->note_public;
|
||||
$this->socid = $obj->fk_soc;
|
||||
$this->societe=(object)array();// To avoid warning on next line
|
||||
$this->societe->id = $obj->fk_soc; // TODO For backward compatibility
|
||||
$this->user_author_id = $obj->fk_user_creat;
|
||||
$this->public = $obj->public;
|
||||
$this->statut = $obj->fk_statut;
|
||||
|
||||
@ -72,8 +72,10 @@ class User extends CommonObject
|
||||
var $datem;
|
||||
|
||||
//! If this is defined, it is an external user
|
||||
var $societe_id;
|
||||
var $contact_id;
|
||||
var $societe_id; // deprecated
|
||||
var $contact_id; // deprecated
|
||||
var $socid;
|
||||
var $contactid;
|
||||
|
||||
var $fk_member;
|
||||
var $fk_user;
|
||||
@ -237,8 +239,10 @@ class User extends CommonObject
|
||||
$this->datelastlogin = $this->db->jdate($obj->datel);
|
||||
$this->datepreviouslogin = $this->db->jdate($obj->datep);
|
||||
|
||||
$this->societe_id = $obj->fk_societe;
|
||||
$this->contact_id = $obj->fk_socpeople;
|
||||
$this->societe_id = $obj->fk_societe; // deprecated
|
||||
$this->contact_id = $obj->fk_socpeople; // deprecated
|
||||
$this->socid = $obj->fk_societe;
|
||||
$this->contactid = $obj->fk_socpeople;
|
||||
$this->fk_member = $obj->fk_member;
|
||||
$this->fk_user = $obj->fk_user;
|
||||
|
||||
|
||||
@ -433,10 +433,10 @@ function createActionComm($authentication,$actioncomm)
|
||||
$newobject->datep=$actioncomm['datep'];
|
||||
$newobject->datef=$actioncomm['datef'];
|
||||
$newobject->type_code=$actioncomm['type_code'];
|
||||
$newobject->societe->id=$actioncomm['socid'];
|
||||
$newobject->socid=$actioncomm['socid'];
|
||||
$newobject->fk_project=$actioncomm['projectid'];
|
||||
$newobject->note=$actioncomm['note'];
|
||||
$newobject->contact->id=$actioncomm['contactid'];
|
||||
$newobject->contactid=$actioncomm['contactid'];
|
||||
$newobject->usertodo->id=$actioncomm['usertodo'];
|
||||
$newobject->userdone->id=$actioncomm['userdone'];
|
||||
$newobject->label=$actioncomm['label'];
|
||||
@ -517,21 +517,21 @@ function updateActionComm($authentication,$actioncomm)
|
||||
if (! $error)
|
||||
{
|
||||
$objectfound=false;
|
||||
|
||||
|
||||
$object=new ActionComm($db);
|
||||
$result=$object->fetch($actioncomm['id']);
|
||||
|
||||
|
||||
if (!empty($object->id)) {
|
||||
|
||||
|
||||
$objectfound=true;
|
||||
|
||||
$object->datep=$actioncomm['datep'];
|
||||
$object->datef=$actioncomm['datef'];
|
||||
$object->type_code=$actioncomm['type_code'];
|
||||
$object->societe->id=$actioncomm['socid'];
|
||||
$object->socid=$actioncomm['socid'];
|
||||
$object->contactid=$actioncomm['contactid'];
|
||||
$object->fk_project=$actioncomm['projectid'];
|
||||
$object->note=$actioncomm['note'];
|
||||
$object->contact->id=$actioncomm['contactid'];
|
||||
$object->usertodo->id=$actioncomm['usertodo'];
|
||||
$object->userdone->id=$actioncomm['userdone'];
|
||||
$object->label=$actioncomm['label'];
|
||||
@ -541,7 +541,7 @@ function updateActionComm($authentication,$actioncomm)
|
||||
$object->location=$actioncomm['location'];
|
||||
$object->fk_element=$actioncomm['fk_element'];
|
||||
$object->elementtype=$actioncomm['elementtype'];
|
||||
|
||||
|
||||
//Retreive all extrafield for actioncomm
|
||||
// fetch optionals attributes and labels
|
||||
$extrafields=new ExtraFields($db);
|
||||
@ -551,7 +551,7 @@ function updateActionComm($authentication,$actioncomm)
|
||||
$key='options_'.$key;
|
||||
$object->array_options[$key]=$actioncomm[$key];
|
||||
}
|
||||
|
||||
|
||||
$db->begin();
|
||||
|
||||
$result=$object->update($fuser);
|
||||
|
||||
@ -126,7 +126,7 @@ class AllTests
|
||||
require_once dirname(__FILE__).'/ContratTest.php';
|
||||
$suite->addTestSuite('ContratTest');
|
||||
|
||||
require_once dirname(__FILE__).'/FichInterTest.php';
|
||||
require_once dirname(__FILE__).'/FichinterTest.php';
|
||||
$suite->addTestSuite('FichinterTest');
|
||||
|
||||
require_once dirname(__FILE__).'/PropalTest.php';
|
||||
|
||||
Loading…
Reference in New Issue
Block a user