Qual: Clean a lot of deprecated code

This commit is contained in:
Laurent Destailleur 2014-09-24 01:35:29 +02:00
parent d6385fe1cc
commit a4d8739477
6 changed files with 51 additions and 53 deletions

View File

@ -240,12 +240,15 @@ if ($action == 'add')
}
$object->note = trim($_POST["note"]);
if (isset($_POST["contactid"])) $object->contact = $contact;
if (GETPOST('socid','int') > 0)
{
$societe = new Societe($db);
$societe->fetch(GETPOST('socid','int'));
$object->societe = $societe;
$object->societe = $societe; // deprecated
$object->thirdparty = $societe;
}
// Special for module webcal and phenix
@ -359,8 +362,10 @@ if ($action == 'update')
$object->priority = $_POST["priority"];
$object->fulldayevent= $_POST["fullday"]?1:0;
$object->location = GETPOST('location');
$object->societe->id = $_POST["socid"];
$object->contact->id = $_POST["contactid"];
$object->socid = $_POST["socid"];
$object->contactid = $_POST["contactid"];
$object->societe->id = $_POST["socid"]; // deprecated
$object->contact->id = $_POST["contactid"]; // deprecated
$object->fk_project = $_POST["projectid"];
$object->note = $_POST["note"];
$object->pnote = $_POST["note"];
@ -795,22 +800,16 @@ if ($action == 'create')
if ($id > 0)
{
$result1=$object->fetch($id);
$result2=$object->fetch_userassigned();
$result3=$object->fetch_optionals($id,$extralabels);
$result2=$object->fetch_thirdparty();
$result3=$object->fetch_userassigned();
$result4=$object->fetch_optionals($id,$extralabels);
if ($result1 < 0 || $result2 < 0 || $result3 < 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; }
@ -959,12 +958,12 @@ if ($id > 0)
print '<td>';
$events=array();
$events[]=array('method' => 'getContacts', 'url' => dol_buildpath('/core/ajax/contacts.php',1), 'htmlname' => 'contactid', 'params' => array('add-customer-contact' => 'disabled'));
print $form->select_company($object->societe->id,'socid','',1,1,0,$events);
print $form->select_company($object->thirdparty->id,'socid','',1,1,0,$events);
print '</td>';
// Contact
print '<td>'.$langs->trans("Contact").'</td><td width="30%">';
$form->select_contacts($object->societe->id, $object->contact->id,'contactid',1);
$form->select_contacts($object->thirdparty->id, $object->contact->id,'contactid',1);
print '</td></tr>';
}
@ -978,7 +977,7 @@ if ($id > 0)
$langs->load("project");
print '<tr><td width="30%" valign="top">'.$langs->trans("Project").'</td><td colspan="3">';
$numprojet=$formproject->select_projects($object->societe->id,$object->fk_project,'projectid');
$numprojet=$formproject->select_projects($object->thirdparty->id,$object->fk_project,'projectid');
if ($numprojet==0)
{
print ' &nbsp; <a href="../../projet/card.php?socid='.$societe->id.'&action=create">'.$langs->trans("AddProject").'</a>';
@ -1152,12 +1151,12 @@ if ($id > 0)
// Third party - Contact
if ($conf->societe->enabled)
{
print '<tr><td width="30%">'.$langs->trans("ActionOnCompany").'</td><td>'.($object->societe->id?$object->societe->getNomUrl(1):$langs->trans("None"));
if ($object->societe->id && $object->type_code == 'AC_TEL')
print '<tr><td width="30%">'.$langs->trans("ActionOnCompany").'</td><td>'.($object->thirdparty->id?$object->thirdparty->getNomUrl(1):$langs->trans("None"));
if (is_object($object->thirdparty) && $object->thirdparty->id > 0 && $object->type_code == 'AC_TEL')
{
if ($object->societe->fetch($object->societe->id))
if ($object->thirdparty->fetch($object->thirdparty->id))
{
print "<br>".dol_print_phone($object->societe->phone);
print "<br>".dol_print_phone($object->thirdparty->phone);
}
}
print '</td>';

View File

@ -192,10 +192,10 @@ class ActionComm extends CommonObject
$sql.= (isset($this->durationp) && $this->durationp >= 0 && $this->durationp != ''?"'".$this->durationp."'":"null").","; // deprecated
$sql.= (isset($this->type_id)?$this->type_id:"null").",";
$sql.= (isset($this->code)?" '".$this->code."'":"null").",";
$sql.= (isset($this->societe->id) && $this->societe->id > 0?" '".$this->societe->id."'":"null").",";
$sql.= (isset($this->socid) && $this->socid > 0?" '".$this->socid."'":"null").",";
$sql.= (isset($this->fk_project) && $this->fk_project > 0?" '".$this->fk_project."'":"null").",";
$sql.= " '".$this->db->escape($this->note)."',";
$sql.= (isset($this->contact->id) && $this->contact->id > 0?"'".$this->contact->id."'":"null").",";
$sql.= (isset($this->contactid) && $this->contactid > 0?"'".$this->contactid."'":"null").",";
$sql.= (isset($user->id) && $user->id > 0 ? "'".$user->id."'":"null").",";
$sql.= (isset($this->usertodo->id) && $this->usertodo->id > 0?"'".$this->usertodo->id."'":"null").",";
$sql.= (isset($this->userdone->id) && $this->userdone->id > 0?"'".$this->userdone->id."'":"null").",";
@ -358,10 +358,12 @@ class ActionComm extends CommonObject
$this->location = $obj->location;
$this->transparency = $obj->transparency;
$this->socid = $obj->fk_soc; // To have fetch_thirdparty method working
$this->societe->id = $obj->fk_soc;
$this->contact->id = $obj->fk_contact;
$this->fk_project = $obj->fk_project;
$this->socid = $obj->fk_soc; // To have fetch_thirdparty method working
$this->contactid = $obj->fk_contact;
$this->fk_project = $obj->fk_project; // To have fetch_project method working
$this->societe->id = $obj->fk_soc; // For backward compatibility
$this->contact->id = $obj->fk_contact; // For backward compatibility
$this->fk_element = $obj->fk_element;
$this->elementtype = $obj->elementtype;

View File

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

View File

@ -323,8 +323,6 @@ class Project extends CommonObject
$this->note_private = $obj->note_private;
$this->note_public = $obj->note_public;
$this->socid = $obj->fk_soc;
$this->societe=(object)array();// To avoid warning on next line
$this->societe->id = $obj->fk_soc; // TODO For backward compatibility
$this->user_author_id = $obj->fk_user_creat;
$this->public = $obj->public;
$this->statut = $obj->fk_statut;

View File

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

View File

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