Merge branch 'develop' of git@github.com:Dolibarr/dolibarr.git into develop

This commit is contained in:
Florian HENRY 2014-09-24 10:04:01 +02:00
commit f9fb73ee82
27 changed files with 945 additions and 621 deletions

View File

@ -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[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[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[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[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[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"; $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[3] = "code,libelle,country_id,country";
$tabfield[4] = "code,label"; $tabfield[4] = "code,label";
$tabfield[5] = "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[7] = "code,libelle,country_id,country,accountancy_code,deductible";
$tabfield[8] = "code,libelle,country_id,country"; $tabfield[8] = "code,libelle,country_id,country";
$tabfield[9] = "code,label,unicode"; $tabfield[9] = "code,label,unicode";
@ -214,7 +214,7 @@ $tabfieldvalue[2] = "code,libelle,region"; // "code,libelle,region"
$tabfieldvalue[3] = "code,libelle,country"; $tabfieldvalue[3] = "code,libelle,country";
$tabfieldvalue[4] = "code,label"; $tabfieldvalue[4] = "code,label";
$tabfieldvalue[5] = "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[7] = "code,libelle,country,accountancy_code,deductible";
$tabfieldvalue[8] = "code,libelle,country"; $tabfieldvalue[8] = "code,libelle,country";
$tabfieldvalue[9] = "code,label,unicode"; $tabfieldvalue[9] = "code,label,unicode";
@ -241,7 +241,7 @@ $tabfieldinsert[2] = "code_departement,nom,fk_region";
$tabfieldinsert[3] = "code_region,nom,fk_pays"; $tabfieldinsert[3] = "code_region,nom,fk_pays";
$tabfieldinsert[4] = "code,label"; $tabfieldinsert[4] = "code,label";
$tabfieldinsert[5] = "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[7] = "code,libelle,fk_pays,accountancy_code,deductible";
$tabfieldinsert[8] = "code,libelle,fk_country"; $tabfieldinsert[8] = "code,libelle,fk_country";
$tabfieldinsert[9] = "code_iso,label,unicode"; $tabfieldinsert[9] = "code_iso,label,unicode";

View File

@ -93,7 +93,10 @@ if (! empty($_POST['removedassigned']))
$idtoremove=$_POST['removedassigned']; $idtoremove=$_POST['removedassigned'];
if (! empty($_SESSION['assignedtouser'])) $tmpassigneduserids=dol_json_decode($_SESSION['assignedtouser'],1); if (! empty($_SESSION['assignedtouser'])) $tmpassigneduserids=dol_json_decode($_SESSION['assignedtouser'],1);
else $tmpassigneduserids=array(); else $tmpassigneduserids=array();
unset($tmpassigneduserids[$idtoremove]); foreach ($tmpassigneduserids as $key => $val)
{
if ($val['id'] == $idtoremove) unset($tmpassigneduserids[$key]);
}
//var_dump($_POST['removedassigned']);exit; //var_dump($_POST['removedassigned']);exit;
$_SESSION['assignedtouser']=dol_json_encode($tmpassigneduserids); $_SESSION['assignedtouser']=dol_json_encode($tmpassigneduserids);
$donotclearsession=1; $donotclearsession=1;
@ -105,11 +108,14 @@ if (! empty($_POST['removedassigned']))
if (GETPOST('addassignedtouser') || GETPOST('updateassignedtouser')) if (GETPOST('addassignedtouser') || GETPOST('updateassignedtouser'))
{ {
// Add a new user // Add a new user
if (GETPOST('affectedto') > 0) if (GETPOST('assignedtouser') > 0)
{ {
$assignedtouser=array(); $assignedtouser=array();
if (! empty($_SESSION['assignedtouser'])) $assignedtouser=dol_json_decode($_SESSION['assignedtouser'], true); if (! empty($_SESSION['assignedtouser']))
$assignedtouser[GETPOST('affectedto')]=array('transparency'=>GETPOST('transparency'),'mandatory'=>1); {
$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); $_SESSION['assignedtouser']=dol_json_encode($assignedtouser);
} }
$donotclearsession=1; $donotclearsession=1;
@ -202,22 +208,23 @@ if ($action == 'add')
$object->percentage = $percentage; $object->percentage = $percentage;
$object->duree=((float) (GETPOST('dureehour') * 60) + (float) GETPOST('dureemin')) * 60; $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; $i=0;
foreach($listofuserid as $key => $value) foreach($listofuserid as $key => $value)
{ {
if ($i == 0) // First entry if ($i == 0) // First entry
{ {
$usertodo=new User($db); $usertodo=new User($db);
if ($key > 0) if ($value['id'] > 0)
{ {
$usertodo->fetch($key); $usertodo->fetch($value['id']);
} }
$object->usertodo = $usertodo; $object->usertodo = $usertodo;
$object->transparency = (GETPOST("transparency")=='on'?1:0); $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++; $i++;
} }
@ -233,12 +240,15 @@ if ($action == 'add')
} }
$object->note = trim($_POST["note"]); $object->note = trim($_POST["note"]);
if (isset($_POST["contactid"])) $object->contact = $contact; if (isset($_POST["contactid"])) $object->contact = $contact;
if (GETPOST('socid','int') > 0) if (GETPOST('socid','int') > 0)
{ {
$societe = new Societe($db); $societe = new Societe($db);
$societe->fetch(GETPOST('socid','int')); $societe->fetch(GETPOST('socid','int'));
$object->societe = $societe; $object->societe = $societe; // deprecated
$object->thirdparty = $societe;
} }
// Special for module webcal and phenix // Special for module webcal and phenix
@ -281,6 +291,8 @@ if ($action == 'add')
{ {
if (! $object->error) if (! $object->error)
{ {
unset($_SESSION['assignedtouser']);
$db->commit(); $db->commit();
if (! empty($backtopage)) if (! empty($backtopage))
{ {
@ -337,6 +349,7 @@ if ($action == 'update')
if ($p2min == -1) $p2min='0'; if ($p2min == -1) $p2min='0';
$object->fetch($id); $object->fetch($id);
$object->fetch_userassigned();
$datep=dol_mktime($fulldayevent?'00':$aphour, $fulldayevent?'00':$apmin, 0, $_POST["apmonth"], $_POST["apday"], $_POST["apyear"]); $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"]); $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->priority = $_POST["priority"];
$object->fulldayevent= $_POST["fullday"]?1:0; $object->fulldayevent= $_POST["fullday"]?1:0;
$object->location = GETPOST('location'); $object->location = GETPOST('location');
$object->societe->id = $_POST["socid"]; $object->socid = $_POST["socid"];
$object->contact->id = $_POST["contactid"]; $object->contactid = $_POST["contactid"];
$object->societe->id = $_POST["socid"]; // deprecated
$object->contact->id = $_POST["contactid"]; // deprecated
$object->fk_project = $_POST["projectid"]; $object->fk_project = $_POST["projectid"];
$object->note = $_POST["note"]; $object->note = $_POST["note"];
$object->pnote = $_POST["note"]; $object->pnote = $_POST["note"];
@ -363,26 +378,26 @@ if ($action == 'update')
setEventMessages($langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("DateEnd")),$object->errors,'errors'); setEventMessages($langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("DateEnd")),$object->errors,'errors');
$action = 'edit'; $action = 'edit';
} }
// Users // Users
$listofuserid=dol_json_decode($_SESSION['assignedtouser']); $listofuserid=array();
$i=0; //$assignedtouser=(GETPOST("assignedtouser") >0)?GETPOST("assignedtouser"):(! empty($object->usertodo->id) && $object->usertodo->id > 0 ? $object->usertodo->id : 0);
foreach($listofuserid as $key => $value) $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 ($val['id'] && $val['id'] != $assignedtouser) $listofuserid[$val['id']]=$val;
if ($key > 0)
{
$usertodo->fetch($key);
}
$object->usertodo = $usertodo;
$object->transparency=(GETPOST("transparency")=='on'?1:0);
} }
}
$object->userassigned[$key]=array('id'=>$key, 'transparency'=>(GETPOST("transparency")=='on'?1:0)); $object->userassigned=array(); // Clear old content
foreach($listofuserid as $key => $val)
$i++; {
$object->userassigned[$val['id']]=array('id'=>$val['id'], 'mandatory'=>0, 'transparency'=>(GETPOST("transparency")=='on'?1:0));
} }
if (! empty($conf->global->AGENDA_ENABLE_DONEBY)) if (! empty($conf->global->AGENDA_ENABLE_DONEBY))
@ -424,6 +439,8 @@ if ($action == 'update')
if ($result > 0) if ($result > 0)
{ {
unset($_SESSION['assignedtouser']);
$db->commit(); $db->commit();
} }
else else
@ -438,6 +455,7 @@ if ($action == 'update')
{ {
if (! empty($backtopage)) if (! empty($backtopage))
{ {
unset($_SESSION['assignedtouser']);
header("Location: ".$backtopage); header("Location: ".$backtopage);
exit; exit;
} }
@ -474,6 +492,8 @@ if ($action == 'confirm_delete' && GETPOST("confirm") == 'yes')
if ($action == 'mupdate') if ($action == 'mupdate')
{ {
$object->fetch($id); $object->fetch($id);
$object->fetch_userassigned();
$shour = dol_print_date($object->datep,"%H"); $shour = dol_print_date($object->datep,"%H");
$smin = dol_print_date($object->datep, "%M"); $smin = dol_print_date($object->datep, "%M");
@ -645,13 +665,21 @@ if ($action == 'create')
// Assigned to // Assigned to
print '<tr><td class="nowrap">'.$langs->trans("ActionAffectedTo").'</td><td>'; print '<tr><td class="nowrap">'.$langs->trans("ActionAffectedTo").'</td><td>';
$listofuserid=array();
if (empty($donotclearsession)) if (empty($donotclearsession))
{ {
$assignedtouser=GETPOST("affectedtouser")?GETPOST("affectedtouser"):(! empty($object->usertodo->id) && $object->usertodo->id > 0 ? $object->usertodo->id : $user->id); $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('transparency'=>1,'mandatory'=>1))); 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 '</td></tr>';
print '</table>'; print '</table>';
@ -771,22 +799,17 @@ if ($action == 'create')
// View or edit // View or edit
if ($id > 0) if ($id > 0)
{ {
$result=$object->fetch($id); $result1=$object->fetch($id);
$object->fetch_optionals($id,$extralabels); $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); dol_print_error($db,$object->error);
exit; 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->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->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; } 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(); $listofuserid=array();
if (empty($donotclearsession)) 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); $_SESSION['assignedtouser']=dol_json_encode($listofuserid);
} }
print $form->select_dolusers_forevent(($action=='create'?'add':'update'),'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,'affectedto',1); //print $form->select_dolusers($object->usertodo->id>0?$object->usertodo->id:-1,'assignedtouser',1);
print '</td></tr>'; print '</td></tr>';
print '</table><br><br><table class="border" width="100%">'; print '</table><br><br><table class="border" width="100%">';
@ -934,12 +958,12 @@ if ($id > 0)
print '<td>'; print '<td>';
$events=array(); $events=array();
$events[]=array('method' => 'getContacts', 'url' => dol_buildpath('/core/ajax/contacts.php',1), 'htmlname' => 'contactid', 'params' => array('add-customer-contact' => 'disabled')); $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>'; print '</td>';
// Contact // Contact
print '<td>'.$langs->trans("Contact").'</td><td width="30%">'; 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>'; print '</td></tr>';
} }
@ -953,7 +977,7 @@ if ($id > 0)
$langs->load("project"); $langs->load("project");
print '<tr><td width="30%" valign="top">'.$langs->trans("Project").'</td><td colspan="3">'; 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) if ($numprojet==0)
{ {
print ' &nbsp; <a href="../../projet/card.php?socid='.$societe->id.'&action=create">'.$langs->trans("AddProject").'</a>'; print ' &nbsp; <a href="../../projet/card.php?socid='.$societe->id.'&action=create">'.$langs->trans("AddProject").'</a>';
@ -1094,8 +1118,17 @@ if ($id > 0)
} }
// Assigned to // 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 '</td></tr>';
print '</table><br><br><table class="border" width="100%">'; print '</table><br><br><table class="border" width="100%">';
@ -1118,12 +1151,12 @@ if ($id > 0)
// Third party - Contact // Third party - Contact
if ($conf->societe->enabled) if ($conf->societe->enabled)
{ {
print '<tr><td width="30%">'.$langs->trans("ActionOnCompany").'</td><td>'.($object->societe->id?$object->societe->getNomUrl(1):$langs->trans("None")); print '<tr><td width="30%">'.$langs->trans("ActionOnCompany").'</td><td>'.($object->thirdparty->id?$object->thirdparty->getNomUrl(1):$langs->trans("None"));
if ($object->societe->id && $object->type_code == 'AC_TEL') 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>'; print '</td>';

View File

@ -62,15 +62,16 @@ class ActionComm extends CommonObject
var $priority; // Small int (0 By default) var $priority; // Small int (0 By default)
var $note; // Description var $note; // Description
var $userassigned; // Array of user ids var $userassigned = array(); // Array of user ids
var $usertodo; // Object user of owner var $usertodo; // Object user of owner
var $userdone; // Object user that did action (deprecated) var $userdone; // Object user that did action (deprecated)
var $socid;
var $contactid;
var $societe; // Company linked to action (optional) var $societe; // Company linked to action (optional)
var $contact; // Contact linked to action (optional) var $contact; // Contact linked to action (optional)
var $fk_project; // Id of project (optional) var $fk_project; // Id of project (optional)
// Properties for links to other objects // Properties for links to other objects
var $fk_element; // Id of record var $fk_element; // Id of record
var $elementtype; // Type of record. This if property ->element of object linked to. 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->durationp) && $this->durationp >= 0 && $this->durationp != ''?"'".$this->durationp."'":"null").","; // deprecated
$sql.= (isset($this->type_id)?$this->type_id:"null").","; $sql.= (isset($this->type_id)?$this->type_id:"null").",";
$sql.= (isset($this->code)?" '".$this->code."'":"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.= (isset($this->fk_project) && $this->fk_project > 0?" '".$this->fk_project."'":"null").",";
$sql.= " '".$this->db->escape($this->note)."',"; $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($user->id) && $user->id > 0 ? "'".$user->id."'":"null").",";
$sql.= (isset($this->usertodo->id) && $this->usertodo->id > 0?"'".$this->usertodo->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").","; $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"); $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."actioncomm","id");
// Actions on extra fields (by external module or standard code) // Now insert assignedusers
$hookmanager->initHooks(array('actioncommdao')); if (! $error)
$parameters=array('actcomm'=>$this->id); {
$reshook=$hookmanager->executeHooks('insertExtraFields',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks foreach($this->userassigned as $key => $val)
if (empty($reshook)) {
$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 // Actions on extra fields (by external module or standard code)
{ $hookmanager->initHooks(array('actioncommdao'));
$result=$this->insertExtraFields(); $parameters=array('actcomm'=>$this->id);
if ($result < 0) $reshook=$hookmanager->executeHooks('insertExtraFields',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks
{ if (empty($reshook))
$error++; {
} 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) if (! $error && ! $notrigger)
{ {
@ -336,10 +358,12 @@ class ActionComm extends CommonObject
$this->location = $obj->location; $this->location = $obj->location;
$this->transparency = $obj->transparency; $this->transparency = $obj->transparency;
$this->socid = $obj->fk_soc; // To have fetch_thirdparty method working $this->socid = $obj->fk_soc; // To have fetch_thirdparty method working
$this->societe->id = $obj->fk_soc; $this->contactid = $obj->fk_contact;
$this->contact->id = $obj->fk_contact; $this->fk_project = $obj->fk_project; // To have fetch_project method working
$this->fk_project = $obj->fk_project;
$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->fk_element = $obj->fk_element;
$this->elementtype = $obj->elementtype; $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 * Delete event from database
* *
@ -498,7 +550,28 @@ class ActionComm extends CommonObject
} }
else if ($reshook < 0) $error++; 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 // Call trigger
$result=$this->call_trigger('ACTION_MODIFY',$user); $result=$this->call_trigger('ACTION_MODIFY',$user);

View File

@ -1,6 +1,6 @@
<?php <?php
/* Copyright (C) 2002-2003 Rodolphe Quiedeville <rodolphe@quiedeville.org> /* 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 * 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 * it under the terms of the GNU General Public License as published by
@ -37,6 +37,7 @@ class CActionComm
var $type; var $type;
var $libelle; var $libelle;
var $active; var $active;
var $color;
var $type_actions=array(); var $type_actions=array();
@ -59,7 +60,7 @@ class CActionComm
*/ */
function fetch($id) 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"; $sql.= " FROM ".MAIN_DB_PREFIX."c_actioncomm";
if (is_numeric($id)) $sql.= " WHERE id=".$id; if (is_numeric($id)) $sql.= " WHERE id=".$id;
else $sql.= " WHERE code='".$id."'"; else $sql.= " WHERE code='".$id."'";
@ -77,12 +78,13 @@ class CActionComm
$this->type = $obj->type; $this->type = $obj->type;
$this->libelle = $obj->libelle; $this->libelle = $obj->libelle;
$this->active = $obj->active; $this->active = $obj->active;
$this->color = $obj->color;
$this->db->free($resql); $this->db->free($resql);
return 1; return 1;
} }
else else
{ {
$this->db->free($resql); $this->db->free($resql);
return 0; 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 int $active 1 or 0 to filter on event state active or not ('' by default = no filter)
* @param string $idorcode 'id' or 'code' * @param string $idorcode 'id' or 'code'
@ -111,7 +113,7 @@ class CActionComm
$repid = array(); $repid = array();
$repcode = 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"; $sql.= " FROM ".MAIN_DB_PREFIX."c_actioncomm";
if ($active != '') $sql.=" WHERE active=".$active; if ($active != '') $sql.=" WHERE active=".$active;
if (! empty($excludetype)) $sql.=($active != ''?" AND":" WHERE")." type <> '".$excludetype."'"; if (! empty($excludetype)) $sql.=($active != ''?" AND":" WHERE")." type <> '".$excludetype."'";

View File

@ -60,12 +60,7 @@ $object = new ActionComm($db);
if ($objectid > 0) if ($objectid > 0)
{ {
$ret = $object->fetch($objectid); $ret = $object->fetch($objectid);
if ($ret > 0) { $object->fetch_thirdparty();
$company=new Societe($db);
$company->fetch($object->societe->id);
$object->societe=$company; // For backward compatibility
$object->thirdparty=$company;
}
} }
// Get parameters // Get parameters
@ -112,7 +107,7 @@ if ($object->id > 0)
$now=dol_now(); $now=dol_now();
$delay_warning=$conf->global->MAIN_DELAY_ACTIONS_TODO*24*60*60; $delay_warning=$conf->global->MAIN_DELAY_ACTIONS_TODO*24*60*60;
dol_fiche_head($head, 'documents', $langs->trans("Action"),0,'action'); dol_fiche_head($head, 'documents', $langs->trans("Action"),0,'action');
// Affichage fiche action en mode visu // 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>'; 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 '</td></tr>'; print '</td></tr>';
print '</table><br><br><table class="border" width="100%">'; print '</table><br><br><table class="border" width="100%">';
// Third party - Contact // Third party - Contact
print '<tr><td width="30%">'.$langs->trans("ActionOnCompany").'</td><td>'.($object->societe->id?$object->societe->getNomUrl(1):$langs->trans("None")); print '<tr><td width="30%">'.$langs->trans("ActionOnCompany").'</td><td>'.($object->thirdparty->id?$object->thirdparty->getNomUrl(1):$langs->trans("None"));
if ($object->societe->id && $object->type_code == 'AC_TEL') 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>'; print '</td>';

View File

@ -410,6 +410,8 @@ if ($resql)
$event->location=$obj->location; $event->location=$obj->location;
$event->transparency=$obj->transparency; $event->transparency=$obj->transparency;
$event->socid=$obj->fk_soc;
$event->contactid=$obj->fk_contact;
$event->societe->id=$obj->fk_soc; $event->societe->id=$obj->fk_soc;
$event->contact->id=$obj->fk_contact; $event->contact->id=$obj->fk_contact;
@ -656,7 +658,7 @@ jQuery(document).ready(function() {
if (ids == \'none\') /* No event */ if (ids == \'none\') /* No event */
{ {
/* alert(\'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; window.location.href = url;
} }
else if (ids.indexOf(",") > -1) /* There is several events */ 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; //$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++) for ($h = $begin_h; $h < $end_h; $h++)
{ {
$color = ''; //init $color = ''; //init
@ -797,12 +799,22 @@ function show_day_events2($username, $day, $month, $year, $monthshown, $style, &
$busy=$event->transparency; $busy=$event->transparency;
$cases1[$h][$event->id]['busy']=$busy; $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]['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) if ($event->date_start_in_calendar < $c && $dateendtouse > $b)
{ {
$busy=$event->transparency; $busy=$event->transparency;
$cases2[$h][$event->id]['busy']=$busy; $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; $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 else
@ -812,6 +824,8 @@ function show_day_events2($username, $day, $month, $year, $monthshown, $style, &
$cases2[$h][$event->id]['busy']=$busy; $cases2[$h][$event->id]['busy']=$busy;
$cases1[$h][$event->id]['string']=$event->label; $cases1[$h][$event->id]['string']=$event->label;
$cases2[$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; break;
} }
} }

View File

@ -664,10 +664,12 @@ if ($action == 'send' && ! GETPOST('addfile') && ! GETPOST('removedfile') && ! G
} }
// Go back to draft // Go back to draft
if ($action == 'modif' && $user->rights->propal->creer) { if ($action == 'modif' && $user->rights->propal->creer)
{
$object->set_draft($user); $object->set_draft($user);
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE))
{
// Define output language // Define output language
$outputlangs = $langs; $outputlangs = $langs;
if (! empty($conf->global->MAIN_MULTILANGS)) { 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 $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified
// by // by
// hook // hook
if (empty($reshook) && ! empty($extrafields->attribute_label)) { if (empty($reshook) && ! empty($extrafields->attribute_label))
foreach ($extrafields->attribute_label as $key => $label) { {
if ($action == 'edit_extras') { foreach ($extrafields->attribute_label as $key => $label)
{
if ($action == 'edit_extras')
{
$value = (isset($_POST ["options_" . $key]) ? $_POST ["options_" . $key] : $object->array_options ["options_" . $key]); $value = (isset($_POST ["options_" . $key]) ? $_POST ["options_" . $key] : $object->array_options ["options_" . $key]);
} else { }
else
{
$value = $object->array_options ["options_" . $key]; $value = $object->array_options ["options_" . $key];
} }
if ($extrafields->attribute_type [$key] == 'separate') { if ($extrafields->attribute_type [$key] == 'separate')
{
print $extrafields->showSeparator($key); print $extrafields->showSeparator($key);
} else { }
else
{
print '<tr><td'; print '<tr><td';
if (! empty($extrafields->attribute_required [$key])) if (! empty($extrafields->attribute_required [$key])) print ' class="fieldrequired"';
print ' class="fieldrequired"';
print '>' . $label . '</td><td colspan="5">'; print '>' . $label . '</td><td colspan="5">';
// Convert date into timestamp format // Convert date into timestamp format
if (in_array($extrafields->attribute_type [$key], array('date','datetime'))) { 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]); $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 '<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="action" value="update_extras">';
print '<input type="hidden" name="attribute" value="' . $key . '">'; 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 '<input type="submit" class="button" value="' . $langs->trans('Modify') . '">';
print '</form>'; print '</form>';
} else { }
else
{
print $extrafields->showOutputField($key, $value); print $extrafields->showOutputField($key, $value);
if ($object->statut == 0 && $user->rights->propal->creer) 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 '<a href="' . $_SERVER['PHP_SELF'] . '?id=' . $object->id . '&action=edit_extras&attribute=' . $key . '">' . img_picto('', 'edit') . ' ' . $langs->trans('Modify') . '</a>';

View File

@ -34,9 +34,9 @@
*/ */
include_once DOL_DOCUMENT_ROOT.'/core/class/commoninvoice.class.php'; 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.'/product/class/product.class.php';
require_once DOL_DOCUMENT_ROOT .'/societe/class/client.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.'/margin/lib/margins.lib.php';
/** /**
@ -3263,11 +3263,10 @@ class Facture extends CommonInvoice
/** /**
* \class FactureLigne * Class to manage invoice lines.
* \brief Classe permettant la gestion des lignes de factures * Saved into database table llx_facturedet
* Gere des lignes de la table llx_facturedet
*/ */
class FactureLigne extends CommonInvoiceLine class FactureLigne extends CommonInvoiceLine
{ {
var $db; var $db;
var $error; var $error;

View File

@ -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); $head=tax_prepare_head($object);
dol_fiche_head($head, 'card', $langs->trans("SocialContribution"),0,'bill'); 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 // Confirmation de la suppression de la charge
if ($action == 'paid') 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&amp;action=paid\">".$langs->trans("ClassifyPaid")."</a>"; print "<a class=\"butAction\" href=\"".DOL_URL_ROOT."/compta/sociales/charges.php?id=$object->id&amp;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&amp;action=clone\">".$langs->trans("ToClone")."</a>";
}
// Delete // Delete
if ($user->rights->tax->charges->supprimer) if ($user->rights->tax->charges->supprimer)

View File

@ -106,7 +106,24 @@ class ChargeSociales extends CommonObject
return -1; 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 * Create a social contribution into database
@ -121,12 +138,11 @@ class ChargeSociales extends CommonObject
// Nettoyage parametres // Nettoyage parametres
$newamount=price2num($this->amount,'MT'); $newamount=price2num($this->amount,'MT');
// Validation parametres if(!$this->check()) {
if (! $newamount > 0 || empty($this->date_ech) || empty($this->periode)) $this->error="ErrorBadParameter";
{ return -2;
$this->error="ErrorBadParameter"; }
return -2;
}
$this->db->begin(); $this->db->begin();

View File

@ -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, ...) * 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
{ {
} }

View File

@ -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. * Function to check if an object is used by others.
* Check is done into this->childtables. There is no check into llx_element_element. * 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 * 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;
}
} }

View File

@ -26,36 +26,12 @@
* Parent class for class inheritance lines of business objects * Parent class for class inheritance lines of business objects
* This class is useless for the moment so no inherit are done on it * This class is useless for the moment so no inherit are done on it
*/ */
abstract class CommonObjectLine abstract class CommonObjectLine extends CommonObject
{ {
/** // TODO
* 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'; // Currently we need function at end of file CommonObject for all object lines. Should find a way to avoid duplicate code.
$interface=new Interfaces($this->db);
$result=$interface->run_triggers($trigger_name,$this,$user,$langs,$conf); // For the moment we use the extends on CommonObject until PHP min is 5.4 so use Traits.
if ($result < 0)
{
if (!empty($this->errors))
{
$this->errors=array_merge($this->errors,$interface->errors);
}
else
{
$this->errors=$interface->errors;
}
}
return $result;
}
} }

View File

@ -804,8 +804,10 @@ class Form
// Construct $out and $outarray // Construct $out and $outarray
$out.= '<select id="'.$htmlname.'" class="flat" name="'.$htmlname.'">'."\n"; $out.= '<select id="'.$htmlname.'" class="flat" name="'.$htmlname.'">'."\n";
$textifempty=' '; $textifempty='';
if (! empty($conf->use_javascript_ajax) || $forcecombo) $textifempty='&nbsp;'; // Do not use textempty = ' ' or '&nbsp;' 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"; if ($showempty) $out.= '<option value="-1">'.$textifempty.'</option>'."\n";
$num = $this->db->num_rows($resql); $num = $this->db->num_rows($resql);
@ -1275,6 +1277,7 @@ class Form
/** /**
* Return select list of users. Selected users are stored into session. * 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 $action Value for $action
* @param string $htmlname Field name in form * @param string $htmlname Field name in form
@ -1295,23 +1298,35 @@ class Form
global $conf,$user,$langs; global $conf,$user,$langs;
$userstatic=new User($this->db); $userstatic=new User($this->db);
$out='';
// Method with no ajax // Method with no ajax
//$out.='<form method="POST" action="'.$_SERVER["PHP_SELF"].'">'; //$out.='<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
$out.='<input type="hidden" class="removedassignedhidden" name="removedassigned" value="">'; if ($action == 'view')
$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.='';
$out.='<input type="submit" class="button" name="'.$action.'assignedtouser" value="'.dol_escape_htmltag($langs->trans("Add")).'">'; }
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(); $assignedtouser=array();
if (!empty($_SESSION['assignedtouser'])) $assignedtouser=dol_json_decode($_SESSION['assignedtouser'], true); if (!empty($_SESSION['assignedtouser']))
if (count($assignedtouser)) $out.='<br>'; {
$i=0; $assignedtouser=dol_json_decode($_SESSION['assignedtouser'], true);
}
if (count($assignedtouser) && $action != 'view') $out.='<br>';
$i=0; $ownerid=0;
foreach($assignedtouser as $key => $value) foreach($assignedtouser as $key => $value)
{ {
$userstatic->fetch($key); if ($value['id'] == $ownerid) continue;
$userstatic->fetch($value['id']);
$out.=$userstatic->getNomUrl(1); $out.=$userstatic->getNomUrl(1);
if ($i == 0) $out.=' ('.$langs->trans("Owner").')'; if ($i == 0) { $ownerid = $value['id']; $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 && $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['mandatory']?$langs->trans("Mandatory"):$langs->trans("Optional"));
//$out.=' '.($value['transparency']?$langs->trans("Busy"):$langs->trans("NotBusy")); //$out.=' '.($value['transparency']?$langs->trans("Busy"):$langs->trans("NotBusy"));
$out.='<br>'; $out.='<br>';

View File

@ -254,7 +254,7 @@ function dol_json_decode($json, $assoc=false)
foreach ($array as $key => $value) foreach ($array as $key => $value)
{ {
$object->{$key} = $value; if ($key) $object->{$key} = $value;
} }
return $object; return $object;

View File

@ -194,7 +194,8 @@ if (empty($inputalsopricewithtax)) $inputalsopricewithtax=0;
<?php <?php
//Line extrafield //Line extrafield
if (!empty($extrafieldsline)) { if (!empty($extrafieldsline))
{
print $line->showOptionals($extrafieldsline,'view',array('style'=>$bcdd[$var],'colspan'=>$coldisplay)); print $line->showOptionals($extrafieldsline,'view',array('style'=>$bcdd[$var],'colspan'=>$coldisplay));
} }
?> ?>

View File

@ -20,6 +20,8 @@
ALTER TABLE llx_bank_account ADD COLUMN fk_user_author integer; 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_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_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; 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_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 -- Localtaxes by thirds
ALTER TABLE llx_c_tva MODIFY COLUMN localtax1 varchar(10); 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); 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, rowid integer AUTO_INCREMENT PRIMARY KEY,
tms timestamp, tms timestamp,
fk_object integer NOT NULL, fk_object integer NOT NULL,
import_key varchar(14) -- import key import_key varchar(14) -- import key
) ENGINE=InnoDB ; ) ENGINE=innodb;
ALTER TABLE llx_usergroup_extrafields ADD INDEX idx_usergroup_extrafields (fk_object); ALTER TABLE llx_usergroup_extrafields ADD INDEX idx_usergroup_extrafields (fk_object);

View File

@ -142,7 +142,7 @@ update llx_societe set barcode = null where (rowid, barcode) in (select max_rowi
drop table tmp_societe_double; 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); 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);

View File

@ -23,10 +23,10 @@
create table llx_actioncomm_resources create table llx_actioncomm_resources
( (
rowid integer AUTO_INCREMENT PRIMARY KEY, rowid integer AUTO_INCREMENT PRIMARY KEY,
fk_actioncomm integer NOT NULL, fk_actioncomm integer NOT NULL, -- Id into llx_actioncomm
element_type varchar(50) NOT NULL, element_type varchar(50) NOT NULL, -- Type of resource ('user', 'resource')
fk_element integer NOT NULL, fk_element integer NOT NULL, -- Id into table llx_user or llx_resource
answer_status varchar(50) NULL, answer_status varchar(50) NULL,
mandatory smallint, mandatory smallint,
transparent smallint transparency smallint default 1 -- Used to say if event is 1=OPAQUE=busy or 0=TRANSPARENT
) ENGINE=innodb; ) ENGINE=innodb;

View File

@ -24,8 +24,9 @@ create table llx_c_actioncomm
code varchar(12) NOT NULL, code varchar(12) NOT NULL,
type varchar(10) DEFAULT 'system' NOT NULL, type varchar(10) DEFAULT 'system' NOT NULL,
libelle varchar(48) NOT NULL, libelle varchar(48) NOT NULL,
module varchar(16) DEFAULT NULL, module varchar(16) DEFAULT NULL,
active tinyint DEFAULT 1 NOT NULL, active tinyint DEFAULT 1 NOT NULL,
todo tinyint, todo tinyint,
color varchar(9),
position integer NOT NULL DEFAULT 0 position integer NOT NULL DEFAULT 0
)ENGINE=innodb; )ENGINE=innodb;

View File

@ -132,7 +132,7 @@ if ($ok)
} }
} }
// Affiche version // Show database version
if ($ok) if ($ok)
{ {
$version=$db->getVersion(); $version=$db->getVersion();
@ -143,12 +143,15 @@ if ($ok)
//print '<td align="right">'.join('.',$versionarray).'</td></tr>'; //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>'; print '<tr><td colspan="2">'.$langs->trans("PleaseBePatient").'</td></tr>';
flush(); flush();
// Run repair SQL file /* Start action here */
// run_sql: Run repair SQL file
if ($ok) if ($ok)
{ {
$dir = "mysql/migration/"; $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 // sync_extrafields: Search list of fields declared and list of fields created into databases and create fields missing
$extrafields=new ExtraFields($db); if ($ok)
$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 $extrafields=new ExtraFields($db);
$tableextra=MAIN_DB_PREFIX.$tablename.'_extrafields'; $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 // Define $arrayoffieldsdesc
$arrayoffieldsdesc=$extrafields->fetch_name_optionals_label($elementtype); $arrayoffieldsdesc=$extrafields->fetch_name_optionals_label($elementtype);
// Define $arrayoffieldsfound // Define $arrayoffieldsfound
$arrayoffieldsfound=array(); $arrayoffieldsfound=array();
$resql=$db->DDLDescTable($tableextra); $resql=$db->DDLDescTable($tableextra);
if ($resql) if ($resql)
{ {
print '<tr><td>Check availability of extra field for '.$tableextra."<br>\n"; print '<tr><td>Check availability of extra field for '.$tableextra."<br>\n";
$i=0; $i=0;
while($obj=$db->fetch_object($resql)) while($obj=$db->fetch_object($resql))
{ {
$fieldname=$fieldtype=''; $fieldname=$fieldtype='';
if (preg_match('/mysql/',$db->type)) if (preg_match('/mysql/',$db->type))
{ {
$fieldname=$obj->Field; $fieldname=$obj->Field;
$fieldtype=$obj->Type; $fieldtype=$obj->Type;
} }
else else
{ {
$fieldname = isset($obj->Key)?$obj->Key:$obj->attname; $fieldname = isset($obj->Key)?$obj->Key:$obj->attname;
$fieldtype = isset($obj->Type)?$obj->Type:'varchar'; $fieldtype = isset($obj->Type)?$obj->Type:'varchar';
} }
if (empty($fieldname)) continue; if (empty($fieldname)) continue;
if (in_array($fieldname,array('rowid','tms','fk_object','import_key'))) continue; if (in_array($fieldname,array('rowid','tms','fk_object','import_key'))) continue;
$arrayoffieldsfound[$fieldname]=array('type'=>$fieldtype); $arrayoffieldsfound[$fieldname]=array('type'=>$fieldtype);
} }
// If it does not match, we create fields // If it does not match, we create fields
foreach($arrayoffieldsdesc as $code => $label) foreach($arrayoffieldsdesc as $code => $label)
{ {
if (! in_array($code,array_keys($arrayoffieldsfound))) 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." -> "; 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'; $type=$extrafields->attribute_type[$code]; $value=$extrafields->attribute_size[$code]; $attribute=''; $default=''; $extra=''; $null='null';
$field_desc=array( $field_desc=array(
'type'=>$type, 'type'=>$type,
'value'=>$value, 'value'=>$value,
'attribute'=>$attribute, 'attribute'=>$attribute,
'default'=>$default, 'default'=>$default,
'extra'=>$extra, 'extra'=>$extra,
'null'=>$null 'null'=>$null
); );
//var_dump($field_desc);exit; //var_dump($field_desc);exit;
$result=$db->DDLAddField($tableextra,$code,$field_desc,""); $result=$db->DDLAddField($tableextra,$code,$field_desc,"");
if ($result < 0) if ($result < 0)
{ {
print "KO ".$db->lasterror."<br>\n"; print "KO ".$db->lasterror."<br>\n";
} }
else else
{ {
print "OK<br>\n"; print "OK<br>\n";
} }
} }
} }
print "</td><td>&nbsp;</td></tr>\n"; print "</td><td>&nbsp;</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 " &nbsp; &nbsp; &nbsp; -> 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 " &nbsp; &nbsp; &nbsp; -> 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 // propal => order
print "</td><td>".checkLinkedElements('propal', 'commande')."</td></tr>\n"; print "</td><td>".checkLinkedElements('propal', 'commande')."</td></tr>\n";
@ -292,8 +378,8 @@ if (GETPOST('clean_linked_elements'))
} }
// Run purge of directory // clean_orphelin_dir: Run purge of directory
if (GETPOST('purge')) if ($ok && GETPOST('clean_orphelin_dir'))
{ {
$conf->setValues($db); $conf->setValues($db);

View File

@ -343,8 +343,8 @@ if (! GETPOST("action") || preg_match('/upgrade/i',GETPOST('action')))
// No specific scripts // No specific scripts
// Tasks to do always and only into last targeted version // Tasks to do always and only into last targeted version
$afterversionarray=explode('.','3.4.9'); // target is after this $afterversionarray=explode('.','3.6.9'); // target is after this
$beforeversionarray=explode('.','3.5.9'); // target is before this $beforeversionarray=explode('.','3.7.9'); // target is before this
if (versioncompare($versiontoarray,$afterversionarray) >= 0 && versioncompare($versiontoarray,$beforeversionarray) <= 0) if (versioncompare($versiontoarray,$afterversionarray) >= 0 && versioncompare($versiontoarray,$beforeversionarray) <= 0)
{ {
// Reload modules (this must be always and only into last targeted version) // Reload modules (this must be always and only into last targeted version)

View File

@ -204,3 +204,6 @@ ACCOUNTING_VAT_ACCOUNT=Default accountancy code for collecting VAT
ACCOUNTING_VAT_BUY_ACCOUNT=Default accountancy code for paying VAT ACCOUNTING_VAT_BUY_ACCOUNT=Default accountancy code for paying VAT
ACCOUNTING_ACCOUNT_CUSTOMER=Accountancy code by default for customer thirdparties ACCOUNTING_ACCOUNT_CUSTOMER=Accountancy code by default for customer thirdparties
ACCOUNTING_ACCOUNT_SUPPLIER=Accountancy code by default for supplier 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

View File

@ -323,8 +323,6 @@ class Project extends CommonObject
$this->note_private = $obj->note_private; $this->note_private = $obj->note_private;
$this->note_public = $obj->note_public; $this->note_public = $obj->note_public;
$this->socid = $obj->fk_soc; $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->user_author_id = $obj->fk_user_creat;
$this->public = $obj->public; $this->public = $obj->public;
$this->statut = $obj->fk_statut; $this->statut = $obj->fk_statut;

View File

@ -72,8 +72,10 @@ class User extends CommonObject
var $datem; var $datem;
//! If this is defined, it is an external user //! If this is defined, it is an external user
var $societe_id; var $societe_id; // deprecated
var $contact_id; var $contact_id; // deprecated
var $socid;
var $contactid;
var $fk_member; var $fk_member;
var $fk_user; var $fk_user;
@ -237,8 +239,10 @@ class User extends CommonObject
$this->datelastlogin = $this->db->jdate($obj->datel); $this->datelastlogin = $this->db->jdate($obj->datel);
$this->datepreviouslogin = $this->db->jdate($obj->datep); $this->datepreviouslogin = $this->db->jdate($obj->datep);
$this->societe_id = $obj->fk_societe; $this->societe_id = $obj->fk_societe; // deprecated
$this->contact_id = $obj->fk_socpeople; $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_member = $obj->fk_member;
$this->fk_user = $obj->fk_user; $this->fk_user = $obj->fk_user;

View File

@ -433,10 +433,10 @@ function createActionComm($authentication,$actioncomm)
$newobject->datep=$actioncomm['datep']; $newobject->datep=$actioncomm['datep'];
$newobject->datef=$actioncomm['datef']; $newobject->datef=$actioncomm['datef'];
$newobject->type_code=$actioncomm['type_code']; $newobject->type_code=$actioncomm['type_code'];
$newobject->societe->id=$actioncomm['socid']; $newobject->socid=$actioncomm['socid'];
$newobject->fk_project=$actioncomm['projectid']; $newobject->fk_project=$actioncomm['projectid'];
$newobject->note=$actioncomm['note']; $newobject->note=$actioncomm['note'];
$newobject->contact->id=$actioncomm['contactid']; $newobject->contactid=$actioncomm['contactid'];
$newobject->usertodo->id=$actioncomm['usertodo']; $newobject->usertodo->id=$actioncomm['usertodo'];
$newobject->userdone->id=$actioncomm['userdone']; $newobject->userdone->id=$actioncomm['userdone'];
$newobject->label=$actioncomm['label']; $newobject->label=$actioncomm['label'];
@ -517,21 +517,21 @@ function updateActionComm($authentication,$actioncomm)
if (! $error) if (! $error)
{ {
$objectfound=false; $objectfound=false;
$object=new ActionComm($db); $object=new ActionComm($db);
$result=$object->fetch($actioncomm['id']); $result=$object->fetch($actioncomm['id']);
if (!empty($object->id)) { if (!empty($object->id)) {
$objectfound=true; $objectfound=true;
$object->datep=$actioncomm['datep']; $object->datep=$actioncomm['datep'];
$object->datef=$actioncomm['datef']; $object->datef=$actioncomm['datef'];
$object->type_code=$actioncomm['type_code']; $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->fk_project=$actioncomm['projectid'];
$object->note=$actioncomm['note']; $object->note=$actioncomm['note'];
$object->contact->id=$actioncomm['contactid'];
$object->usertodo->id=$actioncomm['usertodo']; $object->usertodo->id=$actioncomm['usertodo'];
$object->userdone->id=$actioncomm['userdone']; $object->userdone->id=$actioncomm['userdone'];
$object->label=$actioncomm['label']; $object->label=$actioncomm['label'];
@ -541,7 +541,7 @@ function updateActionComm($authentication,$actioncomm)
$object->location=$actioncomm['location']; $object->location=$actioncomm['location'];
$object->fk_element=$actioncomm['fk_element']; $object->fk_element=$actioncomm['fk_element'];
$object->elementtype=$actioncomm['elementtype']; $object->elementtype=$actioncomm['elementtype'];
//Retreive all extrafield for actioncomm //Retreive all extrafield for actioncomm
// fetch optionals attributes and labels // fetch optionals attributes and labels
$extrafields=new ExtraFields($db); $extrafields=new ExtraFields($db);
@ -551,7 +551,7 @@ function updateActionComm($authentication,$actioncomm)
$key='options_'.$key; $key='options_'.$key;
$object->array_options[$key]=$actioncomm[$key]; $object->array_options[$key]=$actioncomm[$key];
} }
$db->begin(); $db->begin();
$result=$object->update($fuser); $result=$object->update($fuser);

View File

@ -126,7 +126,7 @@ class AllTests
require_once dirname(__FILE__).'/ContratTest.php'; require_once dirname(__FILE__).'/ContratTest.php';
$suite->addTestSuite('ContratTest'); $suite->addTestSuite('ContratTest');
require_once dirname(__FILE__).'/FichInterTest.php'; require_once dirname(__FILE__).'/FichinterTest.php';
$suite->addTestSuite('FichinterTest'); $suite->addTestSuite('FichinterTest');
require_once dirname(__FILE__).'/PropalTest.php'; require_once dirname(__FILE__).'/PropalTest.php';