forked from Wavyzz/dolibarr
Qual: Uniformize error management, add transaction level
Fix: Could not reset birthday
This commit is contained in:
@@ -454,8 +454,8 @@ class ActionComm extends CommonObject
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Charge les informations d'ordre info dans l'objet facture
|
* Charge les informations d'ordre info dans l'objet facture
|
||||||
* \param id Id de la facture a charger
|
* @param id Id de la facture a charger
|
||||||
*/
|
*/
|
||||||
function info($id)
|
function info($id)
|
||||||
{
|
{
|
||||||
@@ -502,9 +502,9 @@ class ActionComm extends CommonObject
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Retourne le libelle du statut de la commande
|
* Return label of status
|
||||||
* \param mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto
|
* @param mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto
|
||||||
* \return string Libelle
|
* @return string Libelle
|
||||||
*/
|
*/
|
||||||
function getLibStatut($mode)
|
function getLibStatut($mode)
|
||||||
{
|
{
|
||||||
@@ -512,10 +512,10 @@ class ActionComm extends CommonObject
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Renvoi le libelle d'un statut donne
|
* Return label of action status
|
||||||
* \param percent Pourcentage avancement
|
* @param percent Percent
|
||||||
* \param mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto
|
* @param mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto
|
||||||
* \return string Libelle
|
* @return string Label
|
||||||
*/
|
*/
|
||||||
function LibStatut($percent,$mode)
|
function LibStatut($percent,$mode)
|
||||||
{
|
{
|
||||||
@@ -523,7 +523,7 @@ class ActionComm extends CommonObject
|
|||||||
|
|
||||||
if ($mode == 0)
|
if ($mode == 0)
|
||||||
{
|
{
|
||||||
if ($percent==0) return $langs->trans('StatusActionToDo');
|
if ($percent==0) return $langs->trans('StatusActionToDo').' (0%)';
|
||||||
if ($percent > 0 && $percent < 100) return $langs->trans('StatusActionInProcess').' ('.$percent.'%)';
|
if ($percent > 0 && $percent < 100) return $langs->trans('StatusActionInProcess').' ('.$percent.'%)';
|
||||||
if ($percent >= 100) return $langs->trans('StatusActionDone').' (100%)';
|
if ($percent >= 100) return $langs->trans('StatusActionDone').' (100%)';
|
||||||
}
|
}
|
||||||
@@ -541,9 +541,9 @@ class ActionComm extends CommonObject
|
|||||||
}
|
}
|
||||||
if ($mode == 3)
|
if ($mode == 3)
|
||||||
{
|
{
|
||||||
if ($percent==0) return img_picto($langs->trans("Status").': '.$langs->trans('StatusActionToDo'),'statut1');
|
if ($percent==0) return img_picto($langs->trans("Status").': '.$langs->trans('StatusActionToDo').' (0%)','statut1');
|
||||||
if ($percent > 0 && $percent < 100) return img_picto($langs->trans("Status").': '.$langs->trans('StatusActionInProcess').' ('.$percent.'%)','statut3');
|
if ($percent > 0 && $percent < 100) return img_picto($langs->trans("Status").': '.$langs->trans('StatusActionInProcess').' ('.$percent.'%)','statut3');
|
||||||
if ($percent >= 100) return img_picto($langs->trans("Status").': '.$langs->trans('StatusActionDone'),'statut6');
|
if ($percent >= 100) return img_picto($langs->trans("Status").': '.$langs->trans('StatusActionDone').' (100%)','statut6');
|
||||||
}
|
}
|
||||||
if ($mode == 4)
|
if ($mode == 4)
|
||||||
{
|
{
|
||||||
@@ -560,20 +560,20 @@ class ActionComm extends CommonObject
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Renvoie nom clicable (avec eventuellement le picto)
|
* Renvoie nom clicable (avec eventuellement le picto)
|
||||||
* \param withpicto 0=Pas de picto, 1=Inclut le picto dans le lien, 2=Picto seul
|
* @param withpicto 0=Pas de picto, 1=Inclut le picto dans le lien, 2=Picto seul
|
||||||
* \param maxlength Nombre de caracteres max dans libelle
|
* @param maxlength Nombre de caracteres max dans libelle
|
||||||
* \param class Force style class on a link
|
* @param class Force style class on a link
|
||||||
* \param option ''=Link to action,'birthday'=Link to contact
|
* @param option ''=Link to action,'birthday'=Link to contact
|
||||||
* \return string Chaine avec URL
|
* @return string Chaine avec URL
|
||||||
* \remarks Utilise $this->id, $this->code et $this->libelle
|
* @remarks Utilise $this->id, $this->code et $this->libelle
|
||||||
*/
|
*/
|
||||||
function getNomUrl($withpicto=0,$maxlength=0,$classname='',$option='')
|
function getNomUrl($withpicto=0,$maxlength=0,$classname='',$option='')
|
||||||
{
|
{
|
||||||
global $langs;
|
global $langs;
|
||||||
|
|
||||||
$result='';
|
$result='';
|
||||||
if ($option=='birthday') $lien = '<a '.($classname?'class="'.$classname.'" ':'').'href="'.DOL_URL_ROOT.'/contact/perso.php?id='.$this->id.'">';
|
if ($option=='birthday') $lien = '<a '.($classname?'class="'.$classname.'" ':'').'href="'.DOL_URL_ROOT.'/contact/perso.php?id='.$this->id.'">'.img_object('','contact').' ';
|
||||||
else $lien = '<a '.($classname?'class="'.$classname.'" ':'').'href="'.DOL_URL_ROOT.'/comm/action/fiche.php?id='.$this->id.'">';
|
else $lien = '<a '.($classname?'class="'.$classname.'" ':'').'href="'.DOL_URL_ROOT.'/comm/action/fiche.php?id='.$this->id.'">';
|
||||||
$lienfin='</a>';
|
$lienfin='</a>';
|
||||||
|
|
||||||
|
|||||||
@@ -22,7 +22,7 @@
|
|||||||
/**
|
/**
|
||||||
* \file htdocs/comm/action/index.php
|
* \file htdocs/comm/action/index.php
|
||||||
* \ingroup agenda
|
* \ingroup agenda
|
||||||
* \brief Page accueil des rapports des actions
|
* \brief Home page of calendar events
|
||||||
* \version $Id$
|
* \version $Id$
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -580,6 +580,7 @@ function show_day_events($db, $day, $month, $year, $monthshown, $style, &$action
|
|||||||
print $action->getNomUrl(0,$nbofchartoshow,'cal_event','birthday');
|
print $action->getNomUrl(0,$nbofchartoshow,'cal_event','birthday');
|
||||||
}
|
}
|
||||||
print '</td>';
|
print '</td>';
|
||||||
|
// Status - Percent
|
||||||
print '<td align="right" nowrap="nowrap">';
|
print '<td align="right" nowrap="nowrap">';
|
||||||
if ($action->type_code != 'BIRTHDAY') print $action->getLibStatut(3);
|
if ($action->type_code != 'BIRTHDAY') print $action->getLibStatut(3);
|
||||||
else print ' ';
|
else print ' ';
|
||||||
|
|||||||
@@ -77,9 +77,9 @@ class Contact extends CommonObject
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Constructeur de l'objet contact
|
* Constructor of class Contact
|
||||||
* \param DB Habler d'acces base
|
* @param DB Habler d'acces base
|
||||||
* \param id Id contact
|
* @param id Id contact
|
||||||
*/
|
*/
|
||||||
function Contact($DB, $id=0)
|
function Contact($DB, $id=0)
|
||||||
{
|
{
|
||||||
@@ -90,16 +90,19 @@ class Contact extends CommonObject
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Add a contact into database
|
* Add a contact into database
|
||||||
* \param user Object user that create
|
* @param user Object user that create
|
||||||
* \return int <0 if KO, >0 if OK
|
* @return int <0 if KO, >0 if OK
|
||||||
*/
|
*/
|
||||||
function create($user)
|
function create($user)
|
||||||
{
|
{
|
||||||
global $conf, $langs;
|
global $conf, $langs;
|
||||||
|
|
||||||
|
$error=0;
|
||||||
$now=dol_now();
|
$now=dol_now();
|
||||||
|
|
||||||
|
$this->db->begin();
|
||||||
|
|
||||||
// Clean parameters
|
// Clean parameters
|
||||||
$this->name=trim($this->name);
|
$this->name=trim($this->name);
|
||||||
if (! $this->socid) $this->socid = 0;
|
if (! $this->socid) $this->socid = 0;
|
||||||
@@ -122,36 +125,64 @@ class Contact extends CommonObject
|
|||||||
{
|
{
|
||||||
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."socpeople");
|
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."socpeople");
|
||||||
|
|
||||||
|
if (! $error)
|
||||||
|
{
|
||||||
$result=$this->update($this->id, $user, 1);
|
$result=$this->update($this->id, $user, 1);
|
||||||
if ($result < 0)
|
if ($result < 0)
|
||||||
{
|
{
|
||||||
$this->error=$this->db->error();
|
$error++;
|
||||||
return -2;
|
$this->error=$this->db->lasterror();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (! $error)
|
||||||
|
{
|
||||||
|
$result=$this->update_perso($this->id, $user);
|
||||||
|
if ($result < 0)
|
||||||
|
{
|
||||||
|
$error++;
|
||||||
|
$this->error=$this->db->lasterror();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! $error)
|
||||||
|
{
|
||||||
// Appel des triggers
|
// Appel des triggers
|
||||||
include_once(DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php");
|
include_once(DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php");
|
||||||
$interface=new Interfaces($this->db);
|
$interface=new Interfaces($this->db);
|
||||||
$result=$interface->run_triggers('CONTACT_CREATE',$this,$user,$langs,$conf);
|
$result=$interface->run_triggers('CONTACT_CREATE',$this,$user,$langs,$conf);
|
||||||
if ($result < 0) { $error++; $this->errors=$interface->errors; }
|
if ($result < 0) { $error++; $this->errors=$interface->errors; }
|
||||||
// Fin appel triggers
|
// Fin appel triggers
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! $error)
|
||||||
|
{
|
||||||
|
$this->db->commit();
|
||||||
return $this->id;
|
return $this->id;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$this->error=$this->db->error();
|
$this->db->rollback();
|
||||||
|
dol_syslog("Contact::create ".$this->error, LOG_ERR);
|
||||||
|
return -2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$this->error=$this->db->lasterror();
|
||||||
|
|
||||||
|
$this->db->rollback();
|
||||||
dol_syslog("Contact::create ".$this->error, LOG_ERR);
|
dol_syslog("Contact::create ".$this->error, LOG_ERR);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Update informations into database
|
* Update informations into database
|
||||||
* \param id Id du contact a mettre a jour
|
* @param id Id du contact a mettre a jour
|
||||||
* \param user Objet utilisateur qui effectue la mise a jour
|
* @param user Objet utilisateur qui effectue la mise a jour
|
||||||
* \param notrigger 0=non, 1=oui
|
* @param notrigger 0=non, 1=oui
|
||||||
* \return int <0 if KO, >0 if OK
|
* @return int <0 if KO, >0 if OK
|
||||||
*/
|
*/
|
||||||
function update($id, $user=0, $notrigger=0)
|
function update($id, $user=0, $notrigger=0)
|
||||||
{
|
{
|
||||||
@@ -226,10 +257,9 @@ class Contact extends CommonObject
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$this->db->rollback();
|
|
||||||
|
|
||||||
$this->error=$this->db->lasterror().' sql='.$sql;
|
$this->error=$this->db->lasterror().' sql='.$sql;
|
||||||
dol_syslog("Contact::update Error ".$this->error,LOG_ERR);
|
dol_syslog("Contact::update Error ".$this->error,LOG_ERR);
|
||||||
|
$this->db->rollback();
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -323,29 +353,20 @@ class Contact extends CommonObject
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/**
|
||||||
* \brief Mise a jour des alertes
|
* Update field alert birthday
|
||||||
* \param id id du contact
|
* @param id Id of contact
|
||||||
* \param user Utilisateur qui demande l'alerte
|
* @param user User asking to change alert or birthday
|
||||||
|
* @return int
|
||||||
*/
|
*/
|
||||||
function update_perso($id, $user=0)
|
function update_perso($id, $user=0)
|
||||||
{
|
{
|
||||||
|
$error=0;
|
||||||
|
$result=false;
|
||||||
|
|
||||||
// Mis a jour contact
|
// Mis a jour contact
|
||||||
$sql = "UPDATE ".MAIN_DB_PREFIX."socpeople SET rowid=".$id;
|
$sql = "UPDATE ".MAIN_DB_PREFIX."socpeople SET rowid=".$id;
|
||||||
|
$sql .= ", birthday=".($this->birthday ? "'".$this->db->idate($this->birthday)."'" : "null");
|
||||||
if ($this->birthday) // <0 si avant 1970, >0 si apres 1970
|
|
||||||
{
|
|
||||||
if (preg_match('/^[0-9]+\-/',$this->birthday))
|
|
||||||
{
|
|
||||||
// Si date = chaine (ne devrait pas arriver)
|
|
||||||
$sql .= ", birthday='".$this->birthday."'";
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// Si date = timestamp
|
|
||||||
$sql .= ", birthday=".$this->db->idate($this->birthday);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if ($user) $sql .= ", fk_user_modif=".$user->id;
|
if ($user) $sql .= ", fk_user_modif=".$user->id;
|
||||||
$sql .= " WHERE rowid=".$id;
|
$sql .= " WHERE rowid=".$id;
|
||||||
//print "update_perso: ".$this->birthday.'-'.$this->db->idate($this->birthday);
|
//print "update_perso: ".$this->birthday.'-'.$this->db->idate($this->birthday);
|
||||||
@@ -353,7 +374,8 @@ class Contact extends CommonObject
|
|||||||
$resql = $this->db->query($sql);
|
$resql = $this->db->query($sql);
|
||||||
if (! $resql)
|
if (! $resql)
|
||||||
{
|
{
|
||||||
$this->error=$this->db->error();
|
$error++;
|
||||||
|
$this->error=$this->db->lasterror();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Mis a jour alerte birthday
|
// Mis a jour alerte birthday
|
||||||
@@ -370,7 +392,8 @@ class Contact extends CommonObject
|
|||||||
$result = $this->db->query($sql);
|
$result = $this->db->query($sql);
|
||||||
if (!$result)
|
if (!$result)
|
||||||
{
|
{
|
||||||
$this->error='Echec sql='.$sql;
|
$error++;
|
||||||
|
$this->error=$this->db->lasterror();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -385,9 +408,11 @@ class Contact extends CommonObject
|
|||||||
$result = $this->db->query($sql);
|
$result = $this->db->query($sql);
|
||||||
if (! $result)
|
if (! $result)
|
||||||
{
|
{
|
||||||
$this->error='Echec sql='.$sql;
|
$error++;
|
||||||
|
$this->error=$this->db->lasterror();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -110,6 +110,10 @@ else
|
|||||||
// Creation contact
|
// Creation contact
|
||||||
if ($_POST["action"] == 'add' && $user->rights->societe->contact->creer)
|
if ($_POST["action"] == 'add' && $user->rights->societe->contact->creer)
|
||||||
{
|
{
|
||||||
|
$error=0;
|
||||||
|
|
||||||
|
$db->begin();
|
||||||
|
|
||||||
$object->socid = $_POST["socid"];
|
$object->socid = $_POST["socid"];
|
||||||
|
|
||||||
$object->name = $_POST["name"];
|
$object->name = $_POST["name"];
|
||||||
@@ -130,8 +134,13 @@ else
|
|||||||
$object->priv = $_POST["priv"];
|
$object->priv = $_POST["priv"];
|
||||||
$object->note = $_POST["note"];
|
$object->note = $_POST["note"];
|
||||||
|
|
||||||
|
// Note: Correct date should be completed with location to have exact GM time of birth.
|
||||||
|
$object->birthday = dol_mktime(0,0,0,$_POST["birthdaymonth"],$_POST["birthdayday"],$_POST["birthdayyear"]);
|
||||||
|
$object->birthday_alert = $_POST["birthday_alert"];
|
||||||
|
|
||||||
if (! $_POST["name"])
|
if (! $_POST["name"])
|
||||||
{
|
{
|
||||||
|
$error++;
|
||||||
array_push($errors,$langs->trans("ErrorFieldRequired",$langs->transnoentities("Lastname").' / '.$langs->transnoentities("Label")));
|
array_push($errors,$langs->trans("ErrorFieldRequired",$langs->transnoentities("Lastname").' / '.$langs->transnoentities("Label")));
|
||||||
$_GET["action"] = $_POST["action"] = 'create';
|
$_GET["action"] = $_POST["action"] = 'create';
|
||||||
}
|
}
|
||||||
@@ -139,16 +148,23 @@ else
|
|||||||
if ($_POST["name"])
|
if ($_POST["name"])
|
||||||
{
|
{
|
||||||
$id = $object->create($user);
|
$id = $object->create($user);
|
||||||
if ($id > 0)
|
if ($id <= 0)
|
||||||
{
|
{
|
||||||
|
$error++;
|
||||||
|
$errors=array($object->error);
|
||||||
|
$_GET["action"] = $_POST["action"] = 'create';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! $error && $id > 0)
|
||||||
|
{
|
||||||
|
$db->commit();
|
||||||
Header("Location: fiche.php?id=".$id);
|
Header("Location: fiche.php?id=".$id);
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$errors=array($object->error);
|
$db->rollback();
|
||||||
$_GET["action"] = $_POST["action"] = 'create';
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -357,21 +373,21 @@ else
|
|||||||
/*
|
/*
|
||||||
* Onglets
|
* Onglets
|
||||||
*/
|
*/
|
||||||
if ($_GET["id"] > 0)
|
if (GETPOST("id") > 0)
|
||||||
{
|
{
|
||||||
// Si edition contact deja existant
|
// Si edition contact deja existant
|
||||||
$contact = new Contact($db);
|
$object = new Contact($db);
|
||||||
$return=$contact->fetch($_GET["id"], $user);
|
$return=$object->fetch(GETPOST("id"), $user);
|
||||||
if ($return <= 0)
|
if ($return <= 0)
|
||||||
{
|
{
|
||||||
dol_print_error('',$contact->error);
|
dol_print_error('',$object->error);
|
||||||
$_GET["id"]=0;
|
$_GET["id"]=0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Affichage onglets
|
* Affichage onglets
|
||||||
*/
|
*/
|
||||||
$head = contact_prepare_head($contact);
|
$head = contact_prepare_head($object);
|
||||||
|
|
||||||
dol_fiche_head($head, 'card', $langs->trans("Contact"), 0, 'contact');
|
dol_fiche_head($head, 'card', $langs->trans("Contact"), 0, 'contact');
|
||||||
}
|
}
|
||||||
@@ -429,8 +445,8 @@ else
|
|||||||
print '<table class="border" width="100%">';
|
print '<table class="border" width="100%">';
|
||||||
|
|
||||||
// Name
|
// Name
|
||||||
print '<tr><td width="15%" class="fieldrequired">'.$langs->trans("Lastname").' / '.$langs->trans("Label").'</td><td><input name="name" type="text" size="30" maxlength="80" value="'.(isset($_POST["name"])?$_POST["name"]:$object->name).'"></td>';
|
print '<tr><td width="20%" class="fieldrequired">'.$langs->trans("Lastname").' / '.$langs->trans("Label").'</td><td width="30%"><input name="name" type="text" size="30" maxlength="80" value="'.(isset($_POST["name"])?$_POST["name"]:$object->name).'"></td>';
|
||||||
print '<td width="20%">'.$langs->trans("Firstname").'</td><td width="25%"><input name="firstname" type="text" size="30" maxlength="80" value="'.(isset($_POST["firstname"])?$_POST["firstname"]:$object->firstname).'"></td></tr>';
|
print '<td width="20%">'.$langs->trans("Firstname").'</td><td width="30%"><input name="firstname" type="text" size="30" maxlength="80" value="'.(isset($_POST["firstname"])?$_POST["firstname"]:$object->firstname).'"></td></tr>';
|
||||||
|
|
||||||
// Company
|
// Company
|
||||||
if ($socid > 0)
|
if ($socid > 0)
|
||||||
@@ -511,9 +527,43 @@ else
|
|||||||
// Note
|
// Note
|
||||||
print '<tr><td valign="top">'.$langs->trans("Note").'</td><td colspan="3" valign="top"><textarea name="note" cols="70" rows="'.ROWS_3.'">'.(isset($_POST["note"])?$_POST["note"]:$object->note).'</textarea></td></tr>';
|
print '<tr><td valign="top">'.$langs->trans("Note").'</td><td colspan="3" valign="top"><textarea name="note" cols="70" rows="'.ROWS_3.'">'.(isset($_POST["note"])?$_POST["note"]:$object->note).'</textarea></td></tr>';
|
||||||
|
|
||||||
print '<tr><td align="center" colspan="4"><input type="submit" class="button" value="'.$langs->trans("Add").'"></td></tr>';
|
|
||||||
print "</table><br>";
|
print "</table><br>";
|
||||||
|
|
||||||
|
|
||||||
|
// Add personnal information
|
||||||
|
print_fiche_titre('<div class="comboperso">'.$langs->trans("PersonalInformations").'</div>','','');
|
||||||
|
|
||||||
|
print '<table class="border" width="100%">';
|
||||||
|
|
||||||
|
// Date To Birth
|
||||||
|
print '<tr><td width="20%">'.$langs->trans("DateToBirth").'</td><td width="30%">';
|
||||||
|
$html=new Form($db);
|
||||||
|
if ($object->birthday)
|
||||||
|
{
|
||||||
|
print $html->select_date($object->birthday,'birthday',0,0,0,"perso");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
print $html->select_date('','birthday',0,0,1,"perso");
|
||||||
|
}
|
||||||
|
print '</td>';
|
||||||
|
|
||||||
|
print '<td colspan="2">'.$langs->trans("Alert").': ';
|
||||||
|
if ($object->birthday_alert)
|
||||||
|
{
|
||||||
|
print '<input type="checkbox" name="birthday_alert" checked></td>';
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
print '<input type="checkbox" name="birthday_alert"></td>';
|
||||||
|
}
|
||||||
|
print '</tr>';
|
||||||
|
|
||||||
|
print "</table><br>";
|
||||||
|
|
||||||
|
|
||||||
|
print '<center><input type="submit" class="button" value="'.$langs->trans("Add").'"></center>';
|
||||||
|
|
||||||
print "</form>";
|
print "</form>";
|
||||||
}
|
}
|
||||||
elseif (GETPOST("action") == 'edit' && GETPOST("id"))
|
elseif (GETPOST("action") == 'edit' && GETPOST("id"))
|
||||||
@@ -544,14 +594,14 @@ else
|
|||||||
|
|
||||||
if ($conf->use_javascript_ajax)
|
if ($conf->use_javascript_ajax)
|
||||||
{
|
{
|
||||||
print "\n".'<script type="text/javascript" language="javascript">';
|
print '<script type="text/javascript" language="javascript">';
|
||||||
print 'jQuery(document).ready(function () {
|
print 'jQuery(document).ready(function () {
|
||||||
jQuery("#selectpays_id").change(function() {
|
jQuery("#selectpays_id").change(function() {
|
||||||
document.formsoc.action.value="edit";
|
document.formsoc.action.value="edit";
|
||||||
document.formsoc.submit();
|
document.formsoc.submit();
|
||||||
});
|
});
|
||||||
})';
|
})';
|
||||||
print '</script>'."\n";
|
print '</script>';
|
||||||
}
|
}
|
||||||
|
|
||||||
print '<form method="post" action="'.$_SERVER["PHP_SELF"].'?id='.GETPOST("id").'" name="formsoc">';
|
print '<form method="post" action="'.$_SERVER["PHP_SELF"].'?id='.GETPOST("id").'" name="formsoc">';
|
||||||
@@ -569,11 +619,11 @@ else
|
|||||||
print '</td></tr>';
|
print '</td></tr>';
|
||||||
|
|
||||||
// Name
|
// Name
|
||||||
print '<tr><td class="fieldrequired">'.$langs->trans("Lastname").' / '.$langs->trans("Label").'</td><td><input name="name" type="text" size="20" maxlength="80" value="'.(isset($_POST["name"])?$_POST["name"]:$object->name).'"></td>';
|
print '<tr><td width="20%" class="fieldrequired">'.$langs->trans("Lastname").' / '.$langs->trans("Label").'</td><td width="30%"><input name="name" type="text" size="20" maxlength="80" value="'.(isset($_POST["name"])?$_POST["name"]:$object->name).'"></td>';
|
||||||
print '<td width="20%">'.$langs->trans("Firstname").'</td><td width="25%"><input name="firstname" type="text" size="20" maxlength="80" value="'.(isset($_POST["firstname"])?$_POST["firstname"]:$object->firstname).'"></td></tr>';
|
print '<td width="20%">'.$langs->trans("Firstname").'</td><td width="30%"><input name="firstname" type="text" size="20" maxlength="80" value="'.(isset($_POST["firstname"])?$_POST["firstname"]:$object->firstname).'"></td></tr>';
|
||||||
|
|
||||||
// Company
|
// Company
|
||||||
print '<tr><td width="20%">'.$langs->trans("Company").'</td>';
|
print '<tr><td>'.$langs->trans("Company").'</td>';
|
||||||
print '<td colspan="3">';
|
print '<td colspan="3">';
|
||||||
print $form->select_societes(isset($_POST["socid"])?$_POST["socid"]:($object->socid?$object->socid:-1),'socid','',1);
|
print $form->select_societes(isset($_POST["socid"])?$_POST["socid"]:($object->socid?$object->socid:-1),'socid','',1);
|
||||||
print '</td>';
|
print '</td>';
|
||||||
@@ -680,12 +730,13 @@ else
|
|||||||
else print $langs->trans("NoDolibarrAccess");
|
else print $langs->trans("NoDolibarrAccess");
|
||||||
print '</td></tr>';
|
print '</td></tr>';
|
||||||
|
|
||||||
print '<tr><td colspan="4" align="center">';
|
print '</table><br>';
|
||||||
|
|
||||||
|
print '<center>';
|
||||||
print '<input type="submit" class="button" name="save" value="'.$langs->trans("Save").'">';
|
print '<input type="submit" class="button" name="save" value="'.$langs->trans("Save").'">';
|
||||||
print ' ';
|
print ' ';
|
||||||
print '<input type="submit" class="button" name="cancel" value="'.$langs->trans("Cancel").'">';
|
print '<input type="submit" class="button" name="cancel" value="'.$langs->trans("Cancel").'">';
|
||||||
print '</td></tr>';
|
print '</center>';
|
||||||
print '</table>';
|
|
||||||
|
|
||||||
print "</form>";
|
print "</form>";
|
||||||
}
|
}
|
||||||
@@ -724,7 +775,7 @@ else
|
|||||||
|
|
||||||
// Name
|
// Name
|
||||||
print '<tr><td width="20%">'.$langs->trans("Lastname").'</td><td width="30%">'.$object->name.'</td>';
|
print '<tr><td width="20%">'.$langs->trans("Lastname").'</td><td width="30%">'.$object->name.'</td>';
|
||||||
print '<td width="25%">'.$langs->trans("Firstname").'</td><td width="25%">'.$object->firstname.'</td></tr>';
|
print '<td width="20%">'.$langs->trans("Firstname").'</td><td width="30%">'.$object->firstname.'</td></tr>';
|
||||||
|
|
||||||
// Company
|
// Company
|
||||||
print '<tr><td>'.$langs->trans("Company").'</td><td colspan="3">';
|
print '<tr><td>'.$langs->trans("Company").'</td><td colspan="3">';
|
||||||
|
|||||||
@@ -36,6 +36,7 @@ $contactid = isset($_GET["id"])?$_GET["id"]:'';
|
|||||||
if ($user->societe_id) $socid=$user->societe_id;
|
if ($user->societe_id) $socid=$user->societe_id;
|
||||||
$result = restrictedArea($user, 'contact', $contactid, 'socpeople');
|
$result = restrictedArea($user, 'contact', $contactid, 'socpeople');
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Action
|
* Action
|
||||||
*/
|
*/
|
||||||
@@ -102,8 +103,8 @@ if ($_GET["action"] == 'edit')
|
|||||||
print '</td></tr>';
|
print '</td></tr>';
|
||||||
|
|
||||||
// Name
|
// Name
|
||||||
print '<tr><td>'.$langs->trans("Lastname").'</td><td>'.$contact->nom.'</td>';
|
print '<tr><td width="20%">'.$langs->trans("Lastname").'</td><td width="30%">'.$contact->nom.'</td>';
|
||||||
print '<td>'.$langs->trans("Firstname").'</td><td width="25%">'.$contact->prenom.'</td>';
|
print '<td width="20%">'.$langs->trans("Firstname").'</td><td width="30%">'.$contact->prenom.'</td>';
|
||||||
|
|
||||||
// Company
|
// Company
|
||||||
if ($contact->socid > 0)
|
if ($contact->socid > 0)
|
||||||
@@ -128,20 +129,13 @@ if ($_GET["action"] == 'edit')
|
|||||||
// Date To Birth
|
// Date To Birth
|
||||||
print '<tr><td>'.$langs->trans("DateToBirth").'</td><td>';
|
print '<tr><td>'.$langs->trans("DateToBirth").'</td><td>';
|
||||||
$html=new Form($db);
|
$html=new Form($db);
|
||||||
if ($contact->birthday)
|
print $html->select_date($contact->birthday,'birthday',0,0,1,"perso");
|
||||||
{
|
|
||||||
print $html->select_date($contact->birthday,'birthday',0,0,0,"perso");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
print $html->select_date('','birthday',0,0,1,"perso");
|
|
||||||
}
|
|
||||||
print '</td>';
|
print '</td>';
|
||||||
|
|
||||||
print '<td colspan="2">'.$langs->trans("Alert").': ';
|
print '<td colspan="2">'.$langs->trans("Alert").': ';
|
||||||
if ($contact->birthday_alert)
|
if ($contact->birthday_alert)
|
||||||
{
|
{
|
||||||
print '<input type="checkbox" name="birthday_alert" checked></td>';
|
print '<input type="checkbox" name="birthday_alert" checked="true"></td>';
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -149,8 +143,13 @@ if ($_GET["action"] == 'edit')
|
|||||||
}
|
}
|
||||||
print '</tr>';
|
print '</tr>';
|
||||||
|
|
||||||
print '<tr><td colspan="4" align="center"><input class="button" type="submit" value="'.$langs->trans("Save").'"></td></tr>';
|
print "</table><br>";
|
||||||
print "</table>";
|
|
||||||
|
print '<center>';
|
||||||
|
print '<input type="submit" class="button" name="save" value="'.$langs->trans("Save").'">';
|
||||||
|
print ' ';
|
||||||
|
print '<input type="submit" class="button" name="cancel" value="'.$langs->trans("Cancel").'">';
|
||||||
|
print '</center>';
|
||||||
|
|
||||||
print "</form>";
|
print "</form>";
|
||||||
}
|
}
|
||||||
@@ -167,8 +166,8 @@ else
|
|||||||
print '</td></tr>';
|
print '</td></tr>';
|
||||||
|
|
||||||
// Name
|
// Name
|
||||||
print '<tr><td>'.$langs->trans("Lastname").'</td><td>'.$contact->name.'</td>';
|
print '<tr><td width="20%">'.$langs->trans("Lastname").'</td><td width="30%">'.$contact->name.'</td>';
|
||||||
print '<td>'.$langs->trans("Firstname").'</td><td width="25%">'.$contact->firstname.'</td></tr>';
|
print '<td width="20%">'.$langs->trans("Firstname").'</td><td width="30%">'.$contact->firstname.'</td></tr>';
|
||||||
|
|
||||||
// Company
|
// Company
|
||||||
if ($contact->socid > 0)
|
if ($contact->socid > 0)
|
||||||
|
|||||||
@@ -379,11 +379,18 @@ function formatDate(date,format)
|
|||||||
* getDateFromFormat(date_string, format_string) Purpose: This function takes a
|
* getDateFromFormat(date_string, format_string) Purpose: This function takes a
|
||||||
* date string and a format string. It parses the date string with format and it
|
* date string and a format string. It parses the date string with format and it
|
||||||
* returns the date as a javascript Date() object. If date does not match
|
* returns the date as a javascript Date() object. If date does not match
|
||||||
* format, it returns 0. The format string can use the following tags: Field |
|
* format, it returns 0. The format string can use the following tags:
|
||||||
* Tags -------------+------------------------------- Year | yyyy (4 digits), yy
|
* Field | Tags
|
||||||
* (2 digits) Month | MM (2 digits) Day of Month | dd (2 digits) Hour (1-12) |
|
* -------------+-----------------------------------
|
||||||
* hh (2 digits) Hour (0-23) | HH (2 digits) Minute | mm (2 digits) Second | ss
|
* Year | yyyy (4 digits), yy (2 digits)
|
||||||
* (2 digits) Author: Laurent Destailleur Licence: GPL
|
* Month | MM (2 digits)
|
||||||
|
* Day of Month | dd (2 digits)
|
||||||
|
* Hour (1-12) | hh (2 digits)
|
||||||
|
* Hour (0-23) | HH (2 digits)
|
||||||
|
* Minute | mm (2 digits)
|
||||||
|
* Second | ss (2 digits)
|
||||||
|
* Author: Laurent Destailleur
|
||||||
|
* Licence: GPL
|
||||||
* ==================================================================
|
* ==================================================================
|
||||||
*/
|
*/
|
||||||
function getDateFromFormat(val,format)
|
function getDateFromFormat(val,format)
|
||||||
@@ -394,6 +401,8 @@ function getDateFromFormat(val,format)
|
|||||||
val=val+"";
|
val=val+"";
|
||||||
format=format+"";
|
format=format+"";
|
||||||
|
|
||||||
|
if (val == '') return 0;
|
||||||
|
|
||||||
var now=new Date();
|
var now=new Date();
|
||||||
var year=now.getYear(); if (year.length < 4) { year=""+(year-0+1900); }
|
var year=now.getYear(); if (year.length < 4) { year=""+(year-0+1900); }
|
||||||
var month=now.getMonth()+1;
|
var month=now.getMonth()+1;
|
||||||
|
|||||||
Reference in New Issue
Block a user