Fix: Create and updtae line of contract

This commit is contained in:
Laurent Destailleur 2008-04-06 19:34:55 +00:00
parent 08af4cbbfe
commit 8c4faadcb1
7 changed files with 288 additions and 114 deletions

View File

@ -272,9 +272,9 @@ class Contrat extends CommonObject
} }
/** /**
* \brief Chargement depuis la base des donn<EFBFBD>es du contrat * \brief Chargement depuis la base des donnees du contrat
* \param id Id du contrat <EFBFBD> charger * \param id Id du contrat a charger
* \return int <0 si ko, id du contrat charg<EFBFBD> si ok * \return int <0 si ko, id du contrat charge si ok
*/ */
function fetch($id) function fetch($id)
{ {
@ -284,7 +284,7 @@ class Contrat extends CommonObject
$sql.= " fk_projet,"; $sql.= " fk_projet,";
$sql.= " fk_commercial_signature, fk_commercial_suivi,"; $sql.= " fk_commercial_signature, fk_commercial_suivi,";
$sql.= " note, note_public"; $sql.= " note, note_public";
$sql.= " FROM ".MAIN_DB_PREFIX."contrat WHERE rowid = $id"; $sql.= " FROM ".MAIN_DB_PREFIX."contrat WHERE rowid = ".$id;
dolibarr_syslog("Contrat::fetch sql=".$sql); dolibarr_syslog("Contrat::fetch sql=".$sql);
$resql = $this->db->query($sql) ; $resql = $this->db->query($sql) ;
@ -801,7 +801,7 @@ class Contrat extends CommonObject
$remise_percent=0; $remise_percent=0;
} }
dolibarr_syslog("Contrat::UpdateLine $rowid, $desc, $pu, $qty, $remise_percent, $date_start, $date_end, $tvatx"); dolibarr_syslog("Contrat::UpdateLine $rowid, $desc, $pu, $qty, $remise_percent, $date_start, $date_end, $date_debut_reel, $date_fin_reel, $tvatx");
$this->db->begin(); $this->db->begin();
@ -821,24 +821,30 @@ class Contrat extends CommonObject
else { $sql.=",date_ouverture=null"; } else { $sql.=",date_ouverture=null"; }
if ($date_fin_reel > 0) { $sql.= ",date_cloture=".$this->db->idate($date_fin_reel); } if ($date_fin_reel > 0) { $sql.= ",date_cloture=".$this->db->idate($date_fin_reel); }
else { $sql.=",date_cloture=null"; } else { $sql.=",date_cloture=null"; }
$sql .= " WHERE rowid = ".$rowid;
$sql .= " WHERE rowid = $rowid ;";
dolibarr_syslog("Contrat::UpdateLine sql=".$sql);
$result = $this->db->query($sql); $result = $this->db->query($sql);
if ($result) if ($result)
{ {
$this->update_price(); $result=$this->update_price();
if ($result >= 0)
$this->db->commit(); {
$this->db->commit();
return 1; return 1;
}
else
{
$this->db->rollback();
dolibarr_syslog("Contrat::UpdateLigne Erreur -2");
return -2;
}
} }
else else
{ {
$this->db->rollback(); $this->db->rollback();
$this->error=$this->db->error(); $this->error=$this->db->error();
dolibarr_syslog("Contrat::UpdateLigne Erreur -1"); dolibarr_syslog("Contrat::UpdateLigne Erreur -1");
return -1; return -1;
} }
} }
@ -846,28 +852,36 @@ class Contrat extends CommonObject
/** /**
* \brief Delete a contract line * \brief Delete a contract line
* \param idline Id of line to delete * \param idline Id of line to delete
* \param user User that delete
* \return int >0 if OK, <0 if KO * \return int >0 if OK, <0 if KO
*/ */
function delete_line($idline) function delete_line($idline,$user)
{ {
global $conf; global $conf, $langs;
if ($contrat->statut == 0 || if ($contrat->statut == 0 ||
($contrat->statut == 1 && $conf->global->CONTRAT_EDITWHENVALIDATED) ) ($contrat->statut == 1 && $conf->global->CONTRAT_EDITWHENVALIDATED) )
{ {
$sql = "DELETE FROM ".MAIN_DB_PREFIX."contratdet"; $sql = "DELETE FROM ".MAIN_DB_PREFIX."contratdet";
$sql.= " WHERE rowid =".$idline; $sql.= " WHERE rowid=".$idline;
dolibarr_syslog("Contratdet::delete sql=".$sql);
$resql = $this->db->query($sql);
if (! $resql)
{
$this->error="Error ".$this->db->lasterror();
dolibarr_syslog("Contratdet::delete ".$this->error, LOG_ERR);
return -1;
}
// Appel des triggers
include_once(DOL_DOCUMENT_ROOT . "/interfaces.class.php");
$interface=new Interfaces($this->db);
$result=$interface->run_triggers('CONTRACTLINE_DELETE',$this,$user,$langs,$conf);
if ($result < 0) { $error++; $this->errors=$interface->errors; }
// Fin appel triggers
dolibarr_syslog("Contrat::delete_line sql=".$sql); return 1;
if ($this->db->query($sql) )
{
$this->update_price();
return 1;
}
else
{
return -1;
}
} }
else else
{ {
@ -1113,28 +1127,40 @@ class Contrat extends CommonObject
class ContratLigne class ContratLigne
{ {
var $db; var $db; //!< To store db handler
var $error; var $error; //!< To return error code (or message)
var $errors=array(); //!< To return several error codes (or messages)
//var $element='contratdet'; //!< Id that identify managed objects
//var $table_element='contratdet'; //!< Name of table without prefix where object is stored
var $id; var $id;
var $desc;
var $libelle; var $tms;
var $product_desc; var $fk_contrat;
var $qty; var $fk_product;
var $ref; var $statut; // 4 active, 5 closed
var $tva_tx; var $label;
var $subprice; var $description;
var $remise_percent; var $date_commande;
var $price; var $date_ouverture_prevue; // date start planned
var $fk_product; var $date_ouverture; // date start real
var $date_fin_validite; // date end planned
var $statut; // 4=actif, 5=clos var $date_cloture; // date end real
var $date_debut_prevue; var $tva_tx;
var $date_debut_reel; var $qty;
var $date_fin_prevue; var $remise_percent;
var $date_fin_reel; var $remise;
var $fk_remise_except;
var $datem; var $subprice;
var $price_ht;
var $total_ht;
var $total_tva;
var $total_ttc;
var $info_bits;
var $fk_user_author;
var $fk_user_ouverture;
var $fk_user_cloture;
var $commentaire;
/** /**
@ -1210,53 +1236,187 @@ class ContratLigne
} }
} }
/** /*
* \brief Chargement depuis la base des donn<EFBFBD>es du contrat * \brief Load object in memory from database
* \param id Id du contrat <EFBFBD> charger * \param id id object
* \return int <0 si ko, id du contrat charg<EFBFBD> si ok * \param user User that load
* \return int <0 if KO, >0 if OK
*/ */
function fetch($id) function fetch($id, $user=0)
{ {
$sql = "SELECT rowid, fk_contrat, fk_product, ".$this->db->pdate("tms")." as datem,"; global $langs;
$sql.= " statut,"; $sql = "SELECT";
$sql.= " label,"; $sql.= " t.rowid,";
$sql.= " description";
$sql.= " FROM ".MAIN_DB_PREFIX."contratdet WHERE rowid = ".$id; $sql.= " ".$this->db->pdate('t.tms')." as tms,";
$sql.= " t.fk_contrat,";
$sql.= " t.fk_product,";
$sql.= " t.statut,";
$sql.= " t.label,";
$sql.= " t.description,";
$sql.= " ".$this->db->pdate('t.date_commande')." as date_commande,";
$sql.= " ".$this->db->pdate('t.date_ouverture_prevue')." as date_ouverture_prevue,";
$sql.= " ".$this->db->pdate('t.date_ouverture')." as date_ouverture,";
$sql.= " ".$this->db->pdate('t.date_fin_validite')." as date_fin_validite,";
$sql.= " ".$this->db->pdate('t.date_cloture')." as date_cloture,";
$sql.= " t.tva_tx,";
$sql.= " t.qty,";
$sql.= " t.remise_percent,";
$sql.= " t.remise,";
$sql.= " t.fk_remise_except,";
$sql.= " t.subprice,";
$sql.= " t.price_ht,";
$sql.= " t.total_ht,";
$sql.= " t.total_tva,";
$sql.= " t.total_ttc,";
$sql.= " t.info_bits,";
$sql.= " t.fk_user_author,";
$sql.= " t.fk_user_ouverture,";
$sql.= " t.fk_user_cloture,";
$sql.= " t.commentaire";
$sql.= " FROM ".MAIN_DB_PREFIX."contratdet as t";
$sql.= " WHERE t.rowid = ".$id;
dolibarr_syslog("ContratLigne::fetch sql=".$sql); dolibarr_syslog("Contratdet::fetch sql=".$sql, LOG_DEBUG);
$resql = $this->db->query($sql) ; $resql=$this->db->query($sql);
if ($resql) if ($resql)
{ {
$obj = $this->db->fetch_object($resql); if ($this->db->num_rows($resql))
if ($obj)
{ {
$this->id = $obj->rowid; $obj = $this->db->fetch_object($resql);
$this->fk_contrat = $obj->fk_contrat;
$this->fk_product = $obj->fk_product; $this->id = $obj->rowid;
$this->datem = $obj->datem;
$this->statut = $obj->statut; $this->tms = $obj->tms;
$this->label = $obj->label; $this->fk_contrat = $obj->fk_contrat;
$this->description = $obj->description; $this->fk_product = $obj->fk_product;
$this->statut = $obj->statut;
$this->db->free($resql); $this->label = $obj->label;
return $this->id; $this->description = $obj->description;
} $this->date_commande = $obj->date_commande;
else $this->date_ouverture_prevue = $obj->date_ouverture_prevue;
{ $this->date_ouverture = $obj->date_ouverture;
$this->error="Contract line not found"; $this->date_fin_validite = $obj->date_fin_validite;
dolibarr_syslog("ContratLigne::Fetch ".$this->error,LOG_ERROR); $this->date_cloture = $obj->date_cloture;
return -2; $this->tva_tx = $obj->tva_tx;
$this->qty = $obj->qty;
$this->remise_percent = $obj->remise_percent;
$this->remise = $obj->remise;
$this->fk_remise_except = $obj->fk_remise_except;
$this->subprice = $obj->subprice;
$this->price_ht = $obj->price_ht;
$this->total_ht = $obj->total_ht;
$this->total_tva = $obj->total_tva;
$this->total_ttc = $obj->total_ttc;
$this->info_bits = $obj->info_bits;
$this->fk_user_author = $obj->fk_user_author;
$this->fk_user_ouverture = $obj->fk_user_ouverture;
$this->fk_user_cloture = $obj->fk_user_cloture;
$this->commentaire = $obj->commentaire;
} }
$this->db->free($resql);
return 1;
} }
else else
{ {
$this->error=$this->db->error(); $this->error="Error ".$this->db->lasterror();
dolibarr_syslog("ContratLigne::Fetch ".$this->error,LOG_ERROR); dolibarr_syslog("Contratdet::fetch ".$this->error, LOG_ERR);
return -1; return -1;
} }
} }
/*
* \brief Update database
* \param user User that modify
* \param notrigger 0=no, 1=yes (no update trigger)
* \return int <0 if KO, >0 if OK
*/
function update($user=0, $notrigger=0)
{
global $conf, $langs;
// Clean parameters
$this->fk_contrat=trim($this->fk_contrat);
$this->fk_product=trim($this->fk_product);
$this->statut=trim($this->statut);
$this->label=trim($this->label);
$this->description=trim($this->description);
$this->tva_tx=trim($this->tva_tx);
$this->qty=trim($this->qty);
$this->remise_percent=trim($this->remise_percent);
$this->remise=trim($this->remise);
$this->fk_remise_except=trim($this->fk_remise_except);
$this->subprice=price2num($this->subprice);
$this->price_ht=price2num($this->price_ht);
$this->total_ht=trim($this->total_ht);
$this->total_tva=trim($this->total_tva);
$this->total_ttc=trim($this->total_ttc);
$this->info_bits=trim($this->info_bits);
$this->fk_user_author=trim($this->fk_user_author);
$this->fk_user_ouverture=trim($this->fk_user_ouverture);
$this->fk_user_cloture=trim($this->fk_user_cloture);
$this->commentaire=trim($this->commentaire);
// Check parameters
// Put here code to add control on parameters values
// Update request
$sql = "UPDATE ".MAIN_DB_PREFIX."contratdet SET";
$sql.= " fk_contrat='".$this->fk_contrat."',";
$sql.= " fk_product='".$this->fk_product."',";
$sql.= " statut='".$this->statut."',";
$sql.= " label='".addslashes($this->label)."',";
$sql.= " description='".addslashes($this->description)."',";
$sql.= " date_commande=".($this->date_commande!=''?$this->db->idate($this->date_commande):"null").",";
$sql.= " date_ouverture_prevue=".($this->date_ouverture_prevue!=''?$this->db->idate($this->date_ouverture_prevue):"null").",";
$sql.= " date_ouverture=".($this->date_ouverture!=''?$this->db->idate($this->date_ouverture):"null").",";
$sql.= " date_fin_validite=".($this->date_fin_validite!=''?$this->db->idate($this->date_fin_validite):"null").",";
$sql.= " date_cloture=".($this->date_cloture!=''?$this->db->idate($this->date_cloture):"null").",";
$sql.= " tva_tx='".$this->tva_tx."',";
$sql.= " qty='".$this->qty."',";
$sql.= " remise_percent='".$this->remise_percent."',";
$sql.= " remise='".$this->remise."',";
$sql.= " fk_remise_except=".($this->fk_remise_except?"'".$this->fk_remise_except."'":"null").",";
$sql.= " subprice='".$this->subprice."',";
$sql.= " price_ht='".$this->price_ht."',";
$sql.= " total_ht='".$this->total_ht."',";
$sql.= " total_tva='".$this->total_tva."',";
$sql.= " total_ttc='".$this->total_ttc."',";
$sql.= " info_bits='".$this->info_bits."',";
$sql.= " fk_user_author='".$this->fk_user_author."',";
$sql.= " fk_user_ouverture='".$this->fk_user_ouverture."',";
$sql.= " fk_user_cloture='".$this->fk_user_cloture."',";
$sql.= " commentaire='".addslashes($this->commentaire)."'";
$sql.= " WHERE rowid=".$this->id;
dolibarr_syslog("Contratdet::update sql=".$sql, LOG_DEBUG);
$resql = $this->db->query($sql);
if (! $resql)
{
$this->error="Error ".$this->db->lasterror();
dolibarr_syslog("Contratdet::update ".$this->error, LOG_ERR);
return -1;
}
if (! $notrigger)
{
// Appel des triggers
include_once(DOL_DOCUMENT_ROOT . "/interfaces.class.php");
$interface=new Interfaces($this->db);
$result=$interface->run_triggers('MYOBJECT_MODIFY',$this,$user,$langs,$conf);
if ($result < 0) { $error++; $this->errors=$interface->errors; }
// Fin appel triggers
}
return 1;
}
/** /**
* \brief Mise a jour en base des champs total_xxx de ligne * \brief Mise a jour en base des champs total_xxx de ligne
* \remarks Utilise par migration * \remarks Utilise par migration
@ -1273,7 +1433,7 @@ class ContratLigne
$sql.= ",total_ttc=".price2num($this->total_ttc,'MT').""; $sql.= ",total_ttc=".price2num($this->total_ttc,'MT')."";
$sql.= " WHERE rowid = ".$this->rowid; $sql.= " WHERE rowid = ".$this->rowid;
dolibarr_syslog("ContratLigne::update_total sql=$sql"); dolibarr_syslog("ContratLigne::update_total sql=".$sql);
$resql=$this->db->query($sql); $resql=$this->db->query($sql);
if ($resql) if ($resql)

View File

@ -224,7 +224,8 @@ if ($_POST["action"] == 'addligne' && $user->rights->contrat->creer)
$prod = new Product($db, $_POST['p_idprod']); $prod = new Product($db, $_POST['p_idprod']);
$prod->fetch($_POST['p_idprod']); $prod->fetch($_POST['p_idprod']);
$tva_tx = get_default_tva($mysoc,$fac->client,$prod->tva_tx); $tva_tx = get_default_tva($mysoc,$contrat->client,$prod->tva_tx);
$tva_npr = get_default_npr($mysoc,$contrat->client,$prod->tva_npr);
// On defini prix unitaire // On defini prix unitaire
if ($conf->global->PRODUIT_MULTIPRICES == 1) if ($conf->global->PRODUIT_MULTIPRICES == 1)
@ -304,28 +305,33 @@ if ($_POST["action"] == 'addligne' && $user->rights->contrat->creer)
if ($_POST["action"] == 'updateligne' && $user->rights->contrat->creer && ! $_POST["cancel"]) if ($_POST["action"] == 'updateligne' && $user->rights->contrat->creer && ! $_POST["cancel"])
{ {
$contrat = new Contrat($db,"",$_GET["id"]); $contratline = new ContratLigne($db);
if ($contrat->fetch($_GET["id"])) if ($contratline->fetch($_POST["elrowid"]))
{ {
$result = $contrat->updateline($_POST["elrowid"], $db->begin();
$_POST["eldesc"],
$_POST["elprice"], if ($date_start_real_update == '') $date_start_real_update=$contratline->date_ouverture;
$_POST["elqty"], if ($date_end_real_update == '') $date_end_real_update=$contratline->date_cloture;
$_POST["elremise_percent"],
$date_start_update, $contratline->description=$_POST["eldesc"];
$date_end_update, $contratline->price_ht=$_POST["elprice"];
$_POST["eltva_tx"], $contratline->subprice=$_POST["elprice"];
$date_start_real_update, $contratline->qty=$_POST["elqty"];
$date_end_real_update $contratline->remise_percent=$_POST["elremise_percent"];
); $contratline->date_ouverture_prevue=$date_start_update;
$contratline->date_ouverture=$date_start_real_update;
$contratline->date_fin_validite=$date_end_update;
$contratline->date_cloture=$date_end_real_update;
$contratline->tva_tx=$_POST["eltva_tx"];
$result=$contratline->update($user);
if ($result > 0) if ($result > 0)
{ {
$db->commit(); $db->commit();
} }
else else
{ {
dolibarr_print_error($db,"result=$result"); dolibarr_print_error($db,'Failed to update contrat_det');
$db->rollback(); $db->rollback();
} }
} }
@ -704,11 +710,11 @@ else
$servicepos=(isset($_REQUEST["servicepos"])?$_REQUEST["servicepos"]:1); $servicepos=(isset($_REQUEST["servicepos"])?$_REQUEST["servicepos"]:1);
$nbofservices=sizeof($contrat->lignes); $nbofservices=sizeof($contrat->lignes);
$colorb='333333'; $colorb='333333';
/* /*
* Lignes de contrats * Lignes de contrats
*/ */
// Menu list of services // Menu list of services
print '<table class="noborder" width="100%">'; // Array with (n*2)+1 lines print '<table class="noborder" width="100%">'; // Array with (n*2)+1 lines
$cursorline=1; $cursorline=1;

View File

@ -25,7 +25,8 @@ ServicesOnSell=Services on sell
ServicesNotOnSell=Services out of sell ServicesNotOnSell=Services out of sell
InternalRef=Internal reference InternalRef=Internal reference
LastRecorded=Last products/services on sell recorded LastRecorded=Last products/services on sell recorded
LastRecordedProductsAndServices=Last %s products/services recorded LastRecordedProductsAndServices=Last %s precorded roducts/services
LastModifiedProductsAndServices=Last %s modified products/services
LastRecordedProducts=Last %s products recorded LastRecordedProducts=Last %s products recorded
LastRecordedServices=Last %s services recorded LastRecordedServices=Last %s services recorded
LastProducts=Last products LastProducts=Last products

View File

@ -26,7 +26,8 @@ ServicesOnSell=Servicios en venta
ServicesNotOnSell=Servicios fuera de venta ServicesNotOnSell=Servicios fuera de venta
InternalRef=Referencia interna InternalRef=Referencia interna
LastRecorded=Ultimos productos/servicios en venta registrados LastRecorded=Ultimos productos/servicios en venta registrados
LastRecordedProductsAndServices=Los %s últimos productos/servicios registrados LastRecordedProductsAndServices=Los %s últimos productos/servicios registrados
LastModifiedProductsAndServices=Los %s últimos productos/servicios registrados
LastRecordedProducts=Los %s últimos productos registrados LastRecordedProducts=Los %s últimos productos registrados
LastRecordedServices=Los %s últimos servicios registrados LastRecordedServices=Los %s últimos servicios registrados
LastProducts=Ultimos productos LastProducts=Ultimos productos

View File

@ -28,6 +28,7 @@ ServicesNotOnSell=Services hors vente
InternalRef=Référence interne InternalRef=Référence interne
LastRecorded=Derniers produits/services en vente enregistrés LastRecorded=Derniers produits/services en vente enregistrés
LastRecordedProductsAndServices=Les %s derniers produits/services enregistrés LastRecordedProductsAndServices=Les %s derniers produits/services enregistrés
LastModifiedProductsAndServices=Les %s derniers produits/services modifiés
LastRecordedProducts=Les %s derniers produits enregistrés LastRecordedProducts=Les %s derniers produits enregistrés
LastRecordedServices=Les %s derniers services enregistrés LastRecordedServices=Les %s derniers services enregistrés
LastProducts=Derniers produits LastProducts=Derniers produits

View File

@ -1906,9 +1906,10 @@ class Product extends CommonObject
* \brief Renvoie nom clicable (avec eventuellement le picto) * \brief Renvoie nom clicable (avec eventuellement le picto)
* \param withpicto Inclut le picto dans le lien * \param withpicto Inclut le picto dans le lien
* \param option Sur quoi pointe le lien * \param option Sur quoi pointe le lien
* \param maxlength Maxlength of ref
* \return string Chaine avec URL * \return string Chaine avec URL
*/ */
function getNomUrl($withpicto=0,$option='') function getNomUrl($withpicto=0,$option='',$maxlength=0)
{ {
global $langs; global $langs;
@ -1916,12 +1917,14 @@ class Product extends CommonObject
$lien = '<a href="'.DOL_URL_ROOT.'/product/fiche.php?id='.$this->id.'">'; $lien = '<a href="'.DOL_URL_ROOT.'/product/fiche.php?id='.$this->id.'">';
$lienfin='</a>'; $lienfin='</a>';
$newref=$this->ref;
if ($maxlength) $newref=dolibarr_trunc($newref,$maxlength);
if ($withpicto) { if ($withpicto) {
if ($this->type == 0) $result.=($lien.img_object($langs->trans("ShowProduct"),'product').$lienfin.' '); if ($this->type == 0) $result.=($lien.img_object($langs->trans("ShowProduct").' '.$this->ref,'product').$lienfin.' ');
if ($this->type == 1) $result.=($lien.img_object($langs->trans("ShowService"),'service').$lienfin.' '); if ($this->type == 1) $result.=($lien.img_object($langs->trans("ShowService").' '.$this->ref,'service').$lienfin.' ');
} }
$result.=$lien.$this->ref.$lienfin; $result.=$lien.$newref.$lienfin;
return $result; return $result;
} }

View File

@ -123,7 +123,8 @@ print '</td><td valign="top" width="70%" class="notopnoleftnoright">';
* Derniers produits/services en vente * Derniers produits/services en vente
*/ */
$max=15; $max=15;
$sql = "SELECT p.rowid, p.label, p.price, p.ref, p.fk_product_type, p.envente"; $sql = "SELECT p.rowid, p.label, p.price, p.ref, p.fk_product_type, p.envente,";
$sql.= " ".$db->pdate("tms")." as datem";
$sql.= " FROM ".MAIN_DB_PREFIX."product as p"; $sql.= " FROM ".MAIN_DB_PREFIX."product as p";
if ($conf->categorie->enabled && !$user->rights->categorie->voir) if ($conf->categorie->enabled && !$user->rights->categorie->voir)
{ {
@ -134,7 +135,7 @@ $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product_subproduct as sp ON p.rowid = sp.fk
$sql.= " WHERE sp.fk_product_subproduct IS NULL"; $sql.= " WHERE sp.fk_product_subproduct IS NULL";
if ($conf->categorie->enabled && !$user->rights->categorie->voir) $sql.= " AND IFNULL(c.visible,1)=1 "; if ($conf->categorie->enabled && !$user->rights->categorie->voir) $sql.= " AND IFNULL(c.visible,1)=1 ";
if (isset($_GET["type"])) $sql.= " AND p.fk_product_type = ".$_GET["type"]; if (isset($_GET["type"])) $sql.= " AND p.fk_product_type = ".$_GET["type"];
$sql.= " ORDER BY p.datec DESC "; $sql.= " ORDER BY p.tms DESC ";
$sql.= $db->plimit($max,0); $sql.= $db->plimit($max,0);
$result = $db->query($sql) ; $result = $db->query($sql) ;
@ -146,7 +147,7 @@ if ($result)
if ($num > 0) if ($num > 0)
{ {
$transRecordedType = $langs->trans("LastRecordedProductsAndServices",$max); $transRecordedType = $langs->trans("LastModifiedProductsAndServices",$max);
if (isset($_GET["type"]) && $_GET["type"] == 0) $transRecordedType = $langs->trans("LastRecordedProducts",$max); if (isset($_GET["type"]) && $_GET["type"] == 0) $transRecordedType = $langs->trans("LastRecordedProducts",$max);
if (isset($_GET["type"]) && $_GET["type"] == 1) $transRecordedType = $langs->trans("LastRecordedServices",$max); if (isset($_GET["type"]) && $_GET["type"] == 1) $transRecordedType = $langs->trans("LastRecordedServices",$max);
@ -176,13 +177,14 @@ if ($result)
$var=!$var; $var=!$var;
print "<tr $bc[$var]>"; print "<tr $bc[$var]>";
print '<td nowrap="nowrap"><a href="fiche.php?id='.$objp->rowid.'">'; print '<td nowrap="nowrap"><a href="fiche.php?id='.$objp->rowid.'">';
if ($objp->fk_product_type==1) print img_object($langs->trans("ShowService"),"service"); $staticproduct->id=$objp->rowid;
else print img_object($langs->trans("ShowProduct"),"product"); $staticproduct->ref=$objp->ref;
print "</a> <a href=\"fiche.php?id=$objp->rowid\">$objp->ref</a></td>\n"; $staticproduct->type=$objp->fk_product_type;
print '<td>'.dolibarr_trunc($objp->label,40).'</td>'; print $staticproduct->getNomUrl(1,'',16);
print "</td>\n";
print '<td>'.dolibarr_trunc($objp->label,32).'</td>';
print "<td>"; print "<td>";
if ($objp->fk_product_type==1) print $langs->trans("ShowService"); print dolibarr_print_date($objp->datem,'day');
else print $langs->trans("ShowProduct");
print "</td>"; print "</td>";
print '<td align="right" nowrap="nowrap">'; print '<td align="right" nowrap="nowrap">';
print $staticproduct->LibStatut($objp->envente,5); print $staticproduct->LibStatut($objp->envente,5);