Skip to content

Commit

Permalink
cvsimport
Browse files Browse the repository at this point in the history
  • Loading branch information
eldy committed Aug 14, 2011
2 parents 53b25ed + 859b410 commit 2ca36e6
Show file tree
Hide file tree
Showing 10 changed files with 82 additions and 180 deletions.
25 changes: 7 additions & 18 deletions htdocs/comm/propal/contact.php
Expand Up @@ -20,7 +20,7 @@
* \file htdocs/comm/propal/contact.php
* \ingroup propal
* \brief Onglet de gestion des contacts de propal
* \version $Id: contact.php,v 1.44 2011/08/14 02:11:45 eldy Exp $
* \version $Id: contact.php,v 1.45 2011/08/14 03:13:50 eldy Exp $
*/

require("../../main.inc.php");
Expand Down Expand Up @@ -81,26 +81,15 @@
}
}

// bascule du statut d'un contact
// Bascule du statut d'un contact
if ($action == 'swapstatut' && $user->rights->propale->creer)
{
$propal = new Propal($db);
if ($propal->fetch($id))
if ($propal->fetch($id) > 0)
{
$contact = $propal->detail_contact($ligne);
$id_type_contact = $contact->fk_c_type_contact;
$statut = ($contact->statut == 4) ? 5 : 4;

$result = $propal->update_contact($ligne, $statut, $id_type_contact);
if ($result >= 0)
{
$db->commit();
} else
{
dol_print_error($db, "result=$result");
$db->rollback();
}
} else
$result=$propal->swapContactStatus(GETPOST('ligne'));
}
else
{
dol_print_error($db);
}
Expand Down Expand Up @@ -384,5 +373,5 @@

$db->close();

llxFooter('$Date: 2011/08/14 02:11:45 $');
llxFooter('$Date: 2011/08/14 03:13:50 $');
?>
23 changes: 6 additions & 17 deletions htdocs/commande/contact.php
Expand Up @@ -21,7 +21,7 @@
* \file htdocs/commande/contact.php
* \ingroup commande
* \brief Onglet de gestion des contacts de commande
* \version $Id: contact.php,v 1.44 2011/08/14 02:11:45 eldy Exp $
* \version $Id: contact.php,v 1.45 2011/08/14 03:13:50 eldy Exp $
*/

require("../main.inc.php");
Expand Down Expand Up @@ -80,22 +80,11 @@
if ($_GET["action"] == 'swapstatut' && $user->rights->commande->creer)
{
$commande = new Commande($db);
if ($commande->fetch($_GET["id"]))
if ($commande->fetch(GETPOST("id")))
{
$contact = $commande->detail_contact($_GET["ligne"]);
$id_type_contact = $contact->fk_c_type_contact;
$statut = ($contact->statut == 4) ? 5 : 4;

$result = $commande->update_contact($_GET["ligne"], $statut, $id_type_contact);
if ($result >= 0)
{
$db->commit();
} else
{
dol_print_error($db, "result=$result");
$db->rollback();
}
} else
$result=$commande->swapContactStatus(GETPOST('ligne'));
}
else
{
dol_print_error($db);
}
Expand Down Expand Up @@ -376,5 +365,5 @@

$db->close();

llxFooter('$Date: 2011/08/14 02:11:45 $');
llxFooter('$Date: 2011/08/14 03:13:50 $');
?>
25 changes: 7 additions & 18 deletions htdocs/compta/facture/contact.php
Expand Up @@ -20,7 +20,7 @@
* \file htdocs/compta/facture/contact.php
* \ingroup facture
* \brief Onglet de gestion des contacts des factures
* \version $Id: contact.php,v 1.49 2011/08/14 02:11:46 eldy Exp $
* \version $Id: contact.php,v 1.50 2011/08/14 03:13:50 eldy Exp $
*/

require("../../main.inc.php");
Expand Down Expand Up @@ -79,22 +79,11 @@
if ($_GET["action"] == 'swapstatut' && $user->rights->facture->creer)
{
$facture = new Facture($db);
if ($facture->fetch($_GET["facid"]))
if ($facture->fetch(GETPOST("facid")))
{
$contact = $facture->detail_contact($_GET["ligne"]);
$id_type_contact = $contact->fk_c_type_contact;
$statut = ($contact->statut == 4) ? 5 : 4;

$result = $facture->update_contact($_GET["ligne"], $statut, $id_type_contact);
if ($result >= 0)
{
$db->commit();
} else
{
dol_print_error($db, "result=$result");
$db->rollback();
}
} else
$result=$facture->swapContactStatus(GETPOST('ligne'));
}
else
{
dol_print_error($db);
}
Expand Down Expand Up @@ -135,7 +124,7 @@
/* Mode vue et edition */
/* */
/* *************************************************************************** */
if (isset($mesg)) print $mesg;
dol_htmloutput_mesg($mesg);

$id = $_GET['facid'];
$ref= $_GET['ref'];
Expand Down Expand Up @@ -371,5 +360,5 @@

$db->close();

llxFooter('$Date: 2011/08/14 02:11:46 $');
llxFooter('$Date: 2011/08/14 03:13:50 $');
?>
25 changes: 5 additions & 20 deletions htdocs/contrat/contact.php
Expand Up @@ -20,7 +20,7 @@
\file htdocs/contrat/contact.php
\ingroup contrat
\brief Onglet de gestion des contacts des contrats
\version $Id: contact.php,v 1.47 2011/08/14 02:11:46 eldy Exp $
\version $Id: contact.php,v 1.48 2011/08/14 03:13:50 eldy Exp $
*/

require ("../main.inc.php");
Expand Down Expand Up @@ -78,25 +78,9 @@
if ($_GET["action"] == 'swapstatut' && $user->rights->contrat->creer)
{
$contrat = new Contrat($db);
if ($contrat->fetch($_GET["id"]))
if ($contrat->fetch(GETPOST("id")))
{
$db->begin();

$contact = $contrat->detail_contact($_GET["ligne"]);
$id_type_contact = $contact->fk_c_type_contact;

$statut = ($contact->statut == 4) ? 5 : 4;

$result = $contrat->update_contact($_GET["ligne"], $statut, $id_type_contact);
if ($result >= 0)
{
$db->commit();
}
else
{
dol_print_error($db, "result=$result");
$db->rollback();
}
$result=$contrat->swapContactStatus(GETPOST('ligne'));
}
else
{
Expand Down Expand Up @@ -130,6 +114,7 @@
$contactstatic=new Contact($db);
$userstatic=new User($db);

dol_htmloutput_mesg($mesg);

/* *************************************************************************** */
/* */
Expand Down Expand Up @@ -376,5 +361,5 @@

$db->close();

llxFooter('$Date: 2011/08/14 02:11:46 $');
llxFooter('$Date: 2011/08/14 03:13:50 $');
?>
48 changes: 27 additions & 21 deletions htdocs/core/class/commonobject.class.php
Expand Up @@ -21,7 +21,7 @@
* \file htdocs/core/class/commonobject.class.php
* \ingroup core
* \brief File of parent class of all other business classes (invoices, contracts, proposals, orders, ...)
* \version $Id: commonobject.class.php,v 1.155 2011/08/11 15:14:51 hregis Exp $
* \version $Id: commonobject.class.php,v 1.156 2011/08/14 03:13:50 eldy Exp $
*/


Expand Down Expand Up @@ -171,24 +171,24 @@ function add_contact($fk_socpeople, $type_contact, $source='external',$notrigger
* Update a link to contact line
* @param rowid Id of line contact-element
* @param statut New status of link
* @param type_contact_id Id of contact type
* @param type_contact_id Id of contact type (not modified if 0)
* @return int <0 if KO, >= 0 if OK
*/
function update_contact($rowid, $statut, $type_contact_id)
function update_contact($rowid, $statut, $type_contact_id=0)
{
// Insertion dans la base
$sql = "UPDATE ".MAIN_DB_PREFIX."element_contact set";
$sql.= " statut = ".$statut.",";
$sql.= " fk_c_type_contact = '".$type_contact_id ."'";
$sql.= " statut = ".$statut;
if ($type_contact_id) $sql.= ", fk_c_type_contact = '".$type_contact_id ."'";
$sql.= " where rowid = ".$rowid;
// Retour
if ( $this->db->query($sql) )
$resql=$this->db->query($sql);
if ($resql)
{
return 0;
}
else
{
dol_print_error($this->db);
$this->error=$this->db->lasterror();
return -1;
}
}
Expand All @@ -199,7 +199,7 @@ function update_contact($rowid, $statut, $type_contact_id)
* @param notrigger Disable all triggers
* @return int >0 if OK, <0 if KO
*/
function delete_contact($rowid,$notrigger=0)
function delete_contact($rowid, $notrigger=0)
{
global $user,$langs,$conf;

Expand Down Expand Up @@ -329,35 +329,41 @@ function liste_contact($statut=-1,$source='external',$list=0)
}
}

/**
* Return fetch cursor of a contact
* FIXME We should never return an open db cursor
* @param rowid L'identifiant du contact
* @return object L'objet construit par DoliDb.fetch_object
*/
function detail_contact($rowid)

/**
* Update status of a contact linked to object
*
* @param $rowid Id of link between object and contact
* @return int <0 if KO, >=0 if OK
*/
function swapContactStatus($rowid)
{
$sql = "SELECT ec.datecreate, ec.statut, ec.fk_socpeople, ec.fk_c_type_contact,";
$sql.= " tc.code, tc.libelle,";
$sql.= " s.fk_soc";
$sql.= " tc.code, tc.libelle";
//$sql.= ", s.fk_soc";
$sql.= " FROM (".MAIN_DB_PREFIX."element_contact as ec, ".MAIN_DB_PREFIX."c_type_contact as tc)";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."socpeople as s ON ec.fk_socpeople=s.rowid"; // Si contact de type external, alors il est li� � une societe
//$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."socpeople as s ON ec.fk_socpeople=s.rowid"; // Si contact de type external, alors il est lie a une societe
$sql.= " WHERE ec.rowid =".$rowid;
$sql.= " AND ec.fk_c_type_contact=tc.rowid";
$sql.= " AND tc.element = '".$this->element."'";

dol_syslog(get_class($object)."::swapContactStatus sql=".$sql);
$resql=$this->db->query($sql);
if ($resql)
{
$obj = $this->db->fetch_object($resql);
return $obj;
$newstatut = ($obj->statut == 4) ? 5 : 4;
$result = $this->update_contact($rowid, $newstatut);
$this->db->free($resql);
return $result;
}
else
{
$this->error=$this->db->error();
dol_print_error($this->db);
return null;
return -1;
}

}

/**
Expand Down
25 changes: 7 additions & 18 deletions htdocs/fichinter/contact.php
Expand Up @@ -20,7 +20,7 @@
* \file htdocs/fichinter/contact.php
* \ingroup fichinter
* \brief Onglet de gestion des contacts de fiche d'intervention
* \version $Id: contact.php,v 1.31 2011/08/14 02:11:45 eldy Exp $
* \version $Id: contact.php,v 1.32 2011/08/14 03:13:50 eldy Exp $
*/

require("../main.inc.php");
Expand Down Expand Up @@ -79,22 +79,11 @@
if ($_GET["action"] == 'swapstatut' && $user->rights->ficheinter->creer)
{
$fichinter = new Fichinter($db);
if ($fichinter->fetch($_GET["id"]))
if ($fichinter->fetch(GETPOST("id")))
{
$contact = $fichinter->detail_contact($_GET["ligne"]);
$id_type_contact = $contact->fk_c_type_contact;
$statut = ($contact->statut == 4) ? 5 : 4;

$result = $fichinter->update_contact($_GET["ligne"], $statut, $id_type_contact);
if ($result >= 0)
{
$db->commit();
} else
{
dol_print_error($db, "result=$result");
$db->rollback();
}
} else
$result=$fichinter->swapContactStatus(GETPOST('ligne'));
}
else
{
dol_print_error($db);
}
Expand Down Expand Up @@ -135,7 +124,7 @@
/* Mode vue et edition */
/* */
/* *************************************************************************** */
if (isset($mesg)) print $mesg;
dol_htmloutput_mesg($mesg);

$id = $_GET["id"];
if ($id > 0)
Expand Down Expand Up @@ -360,5 +349,5 @@

$db->close();

llxFooter('$Date: 2011/08/14 02:11:45 $');
llxFooter('$Date: 2011/08/14 03:13:50 $');
?>

0 comments on commit 2ca36e6

Please sign in to comment.