Skip to content

Commit

Permalink
Merge branch 'develop' of git@github.com:Dolibarr/dolibarr.git into d…
Browse files Browse the repository at this point in the history
…evelop
  • Loading branch information
FHenry committed Sep 24, 2014
2 parents 518d23f + cdca651 commit f9fb73e
Show file tree
Hide file tree
Showing 27 changed files with 1,042 additions and 718 deletions.
8 changes: 4 additions & 4 deletions htdocs/admin/dict.php
Expand Up @@ -133,7 +133,7 @@
$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";
Expand Down Expand Up @@ -187,7 +187,7 @@
$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";
Expand All @@ -214,7 +214,7 @@
$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";
Expand All @@ -241,7 +241,7 @@
$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";
Expand Down
137 changes: 85 additions & 52 deletions htdocs/comm/action/card.php
Expand Up @@ -93,7 +93,10 @@
$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;
Expand All @@ -105,11 +108,14 @@
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;
Expand Down Expand Up @@ -202,22 +208,23 @@
$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++;
}
Expand All @@ -233,12 +240,15 @@
}

$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
Expand Down Expand Up @@ -281,6 +291,8 @@
{
if (! $object->error)
{
unset($_SESSION['assignedtouser']);

$db->commit();
if (! empty($backtopage))
{
Expand Down Expand Up @@ -337,6 +349,7 @@
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"]);
Expand All @@ -349,8 +362,10 @@
$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"];
Expand All @@ -363,26 +378,26 @@
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))
Expand Down Expand Up @@ -424,6 +439,8 @@

if ($result > 0)
{
unset($_SESSION['assignedtouser']);

$db->commit();
}
else
Expand All @@ -438,6 +455,7 @@
{
if (! empty($backtopage))
{
unset($_SESSION['assignedtouser']);
header("Location: ".$backtopage);
exit;
}
Expand Down Expand Up @@ -474,6 +492,8 @@
if ($action == 'mupdate')
{
$object->fetch($id);
$object->fetch_userassigned();

$shour = dol_print_date($object->datep,"%H");
$smin = dol_print_date($object->datep, "%M");

Expand Down Expand Up @@ -645,13 +665,21 @@ function setdatefields()

// 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>';
Expand Down Expand Up @@ -771,22 +799,17 @@ function setdatefields()
// 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; }
Expand Down Expand Up @@ -901,11 +924,12 @@ function setdatefields()
$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%">';
Expand Down Expand Up @@ -934,12 +958,12 @@ function setdatefields()
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>';
}

Expand All @@ -953,7 +977,7 @@ function setdatefields()
$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 ' &nbsp; <a href="../../projet/card.php?socid='.$societe->id.'&action=create">'.$langs->trans("AddProject").'</a>';
Expand Down Expand Up @@ -1094,8 +1118,17 @@ function setdatefields()
}

// 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%">';
Expand All @@ -1118,12 +1151,12 @@ function setdatefields()
// 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>';
Expand Down

0 comments on commit f9fb73e

Please sign in to comment.