diff --git a/htdocs/compta/propal.php b/htdocs/compta/propal.php
index 9cea1cb99fd..a5110363b71 100644
--- a/htdocs/compta/propal.php
+++ b/htdocs/compta/propal.php
@@ -32,7 +32,7 @@ require("./pre.inc.php");
$user->getrights('facture');
$user->getrights('propale');
if (!$user->rights->propale->lire)
- accessforbidden();
+ accessforbidden();
if ($conf->projet->enabled) require_once '../project.class.php';
if ($conf->commande->enabled) require_once '../commande/commande.class.php';
@@ -43,48 +43,50 @@ require_once("../propal.class.php");
// Sécurité accés client
if ($user->societe_id > 0)
{
- $action = '';
- $socidp = $user->societe_id;
+ $action = '';
+ $socidp = $user->societe_id;
}
if ($_GET["action"] == 'setstatut')
{
- /*
- * Classée la facture comme facturée
- */
- $propal = new Propal($db);
- $propal->id = $_GET["propalid"];
- $propal->cloture($user, $_GET["statut"], $note);
+ /*
+ * Classée la facture comme facturée
+ */
+ $propal = new Propal($db);
+ $propal->id = $_GET["propalid"];
+ $propal->cloture($user, $_GET["statut"], $note);
}
if ( $action == 'delete' )
{
- $sql = "DELETE FROM ".MAIN_DB_PREFIX."propal WHERE rowid = $propalid;";
- if ( $db->query($sql) )
+ $sql = "DELETE FROM ".MAIN_DB_PREFIX."propal WHERE rowid = $propalid;";
+ if ( $db->query($sql) )
{
-
- $sql = "DELETE FROM ".MAIN_DB_PREFIX."propaldet WHERE fk_propal = $propalid ;";
- if ( $db->query($sql) )
+
+ $sql = "DELETE FROM ".MAIN_DB_PREFIX."propaldet WHERE fk_propal = $propalid ;";
+ if ( $db->query($sql) )
{
- print '
';
+ $rowspan=6;
+ print '| '.$langs->trans('Company').' | ';
+ if ($societe->client == 1)
+ {
+ $url ='fiche.php?socid='.$societe->id;
+ }
+ else
+ {
+ $url = DOL_URL_ROOT.'/comm/prospect/fiche.php?socid='.$societe->id;
+ }
+ print ''.$societe->nom.' | ';
+ print 'Conditions de réglement | ';
+ print ''.' '.' | ';
+ print '
';
+
+ print '| '.$langs->trans('Date').' | ';
+ print dolibarr_print_date($propal->date);
+ print ' | ';
+
+ print ''.$langs->trans('DateEndPropal').' | ';
+ if ($propal->fin_validite)
+ {
+ print dolibarr_print_date($propal->fin_validite);
+ }
+ else
+ {
+ print $langs->trans("Unknown");
+ }
+ print ' |
';
+
+ // Receiver
+ $langs->load('mails');
+ print '| '.$langs->trans('MailTo').' | ';
+ print '';
+
+ $dests=$societe->contact_array($societe->id);
+ $numdest = count($dests);
+ if ($numdest==0)
+ {
+ print 'Cette societe n\'a pas de contact, veuillez en créer un avant de faire votre proposition commerciale ';
+ print ''.$langs->trans('AddContact').'';
+ }
+ else
+ {
+ if ($propal->statut == 0 && $user->rights->propale->creer)
{
- $obj = $db->fetch_object($result);
-
- $societe = new Societe($db);
- $societe->fetch($obj->idp);
-
- print '';
- $rowspan=6;
- print '| '.$langs->trans('Company').' | ';
- if ($societe->client == 1)
- {
- $url ='fiche.php?socid='.$societe->id;
- }
- else
- {
- $url = DOL_URL_ROOT.'/comm/prospect/fiche.php?socid='.$societe->id;
- }
- print ''.$societe->nom.' | ';
- print 'Conditions de réglement | ';
- print ''.' '.' | ';
- print ' ';
-
- print '| '.$langs->trans('Date').' | ';
- print dolibarr_print_date($propal->date);
- print ' | ';
-
- print ''.$langs->trans('DateEndPropal').' | ';
- if ($propal->fin_validite)
- {
- print dolibarr_print_date($propal->fin_validite);
- }
- else {
- print $langs->trans("Unknown");
- }
- print ' | ';
- print ' ';
-
- // Receiver
- $langs->load('mails');
- print '';
- print '| '.$langs->trans('MailTo').' | ';
- print '';
-
- $dests=$societe->contact_array($societe->id);
- $numdest = count($dests);
- if ($numdest==0)
- {
- print 'Cette societe n\'a pas de contact, veuillez en créer un avant de faire votre proposition commerciale ';
- print ''.$langs->trans('AddContact').'';
- }
- else
- {
- if ($propal->statut == 0 && $user->rights->propale->creer)
- {
- print '';
- }
- else
- {
- if (!empty($propal->contactid))
- {
- require_once(DOL_DOCUMENT_ROOT.'/contact.class.php');
- $contact=new Contact($db);
- $contact->fetch($propal->contactid);
- print '';
- print $contact->firstname.' '.$contact->name;
- print '';
- }
- }
- }
- print ' | ';
-
- if ($conf->projet->enabled)
- $rowspan++;
-
- print ''.$langs->trans('Note').' : '. nl2br($propal->note).' | ';
-
- if ($conf->projet->enabled)
- {
- $langs->load("projects");
- print '| '.$langs->trans('Project').' | ';
- $numprojet = $societe->has_projects();
- print '';
- if (! $numprojet)
- {
- print $langs->trans("NoProject").' | ';
- print 'id.'&action=create>'.$langs->trans('AddProject').'';
- print ' | ';
- }
- else
- {
- if ($propal->statut == 0 && $user->rights->propale->creer)
- {
- print '';
- print '';
- print ' | ';
- }
- else
- {
- if (!empty($propal->projetidp))
- {
- print '';
- $proj = new Project($db);
- $proj->fetch($propal->projetidp);
- print '';
- print $proj->title;
- print '';
- print ' | ';
- }
- else {
- print ' | ';
- }
- }
- }
- print ' ';
- }
-
- print '| '.$langs->trans('GlobalDiscount').' | ';
- if ($propal->brouillon == 1 && $user->rights->propale->creer)
- {
- print '';
- }
- else
- {
- print ''.$propal->remise_percent.' % | ';
- }
- print ' ';
-
- print '| '.$langs->trans('AmountHT').' | ';
- print ''.price($obj->price).' | ';
- print ''.$langs->trans("Currency".$conf->monnaie).' | ';
-
- print '| '.$langs->trans('VAT').' | '.price($propal->total_tva).' | ';
- print ''.$langs->trans("Currency".$conf->monnaie).' | ';
- print '| '.$langs->trans('AmountTTC').' | '.price($propal->total_ttc).' | ';
- print ''.$langs->trans("Currency".$conf->monnaie).' | ';
- print '| '.$langs->trans('Status').' | '.$propal->getLibStatut().' | ';
- print ' ';
- if ($propal->brouillon == 1 && $user->rights->propale->creer)
- {
- print '';
- }
-
- /*
- * Lignes de propale
- *
- */
- $sql = 'SELECT pt.rowid, pt.description, pt.price, pt.fk_product, pt.qty, pt.tva_tx, pt.remise_percent, pt.subprice, p.label as product, p.ref, p.fk_product_type, p.rowid as prodid';
- $sql .= ' FROM '.MAIN_DB_PREFIX.'propaldet as pt LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON pt.fk_product=p.rowid';
- $sql .= ' WHERE pt.fk_propal = '.$propal->id;
- $sql .= ' ORDER BY pt.rowid ASC';
- $result = $db->query($sql);
- if ($result)
- {
- $num_lignes = $db->num_rows($result);
- $i = 0;
- $total = 0;
-
- print '';
- if ($num_lignes)
- {
- print '';
- print '| '.$langs->trans('Description').' | ';
- print ''.$langs->trans('VAT').' | ';
- print ''.$langs->trans('PriceUHT').' | ';
- print ''.$langs->trans('Qty').' | ';
- print ''.$langs->trans('Discount').' | ';
- print ''.$langs->trans('AmountHT').' | ';
- print ' | | ';
- print " \n";
- }
- $var=True;
- while ($i < $num_lignes)
- {
- $objp = $db->fetch_object($result);
- $var=!$var;
- if ($_GET['action'] != 'editline' || $_GET['rowid'] != $objp->rowid)
- {
- print '';
- if ($objp->fk_product > 0)
- {
- print '| ';
- if ($objp->fk_product_type)
- print img_object($langs->trans('ShowService'),'service');
- else
- print img_object($langs->trans('ShowProduct'),'product');
- print ' '.stripslashes(nl2br($objp->description?$objp->description:$objp->product)).'';
- if ($objp->date_start && $objp->date_end)
- {
- print ' (Du '.dolibarr_print_date($objp->date_start).' au '.dolibarr_print_date($objp->date_end).')';
- }
- if ($objp->date_start && ! $objp->date_end)
- {
- print ' (A partir du '.dolibarr_print_date($objp->date_start).')';
- }
- if (! $objp->date_start && $objp->date_end)
- {
- print " (Jusqu'au ".dolibarr_print_date($objp->date_end).')';
- }
- print ' | ';
- }
- else
- {
- print ''.stripslashes(nl2br($objp->description));
- if ($objp->date_start && $objp->date_end)
- {
- print ' (Du '.dolibarr_print_date($objp->date_start).' au '.dolibarr_print_date($objp->date_end).')';
- }
- if ($objp->date_start && ! $objp->date_end)
- {
- print ' (A partir du '.dolibarr_print_date($objp->date_start).')';
- }
- if (! $objp->date_start && $objp->date_end)
- {
- print " (Jusqu'au ".dolibarr_print_date($objp->date_end).')';
- }
- print " | \n";
- }
- print ''.$objp->tva_tx.' % | ';
- print ''.price($objp->subprice)." | \n";
- print ''.$objp->qty.' | ';
- if ($objp->remise_percent > 0)
- {
- print ''.$objp->remise_percent." % | \n";
- }
- else
- {
- print ' | ';
- }
- print ''.price($objp->subprice*$objp->qty*(100-$objp->remise_percent)/100)." | \n";
-
- // Icone d'edition et suppression
- if ($propal->statut == 0 && $user->rights->propale->creer)
- {
- print '';
- print img_edit();
- print ' | ';
- print '';
- print img_delete();
- print ' | ';
- }
- else
- {
- print ' | | ';
- }
- print ' ';
- }
- // Update ligne de facture
- // \todo
-
-
- $total = $total + ($objp->qty * $objp->price);
- $i++;
- }
- $db->free($result);
- }
- else
- {
- dolibarr_print_error($db);
- }
-
- print ' ';
-
+ print '';
}
- }
- else
- {
- dolibarr_print_error($db);
- }
+ else
+ {
+ if (!empty($propal->contactid))
+ {
+ require_once(DOL_DOCUMENT_ROOT.'/contact.class.php');
+ $contact=new Contact($db);
+ $contact->fetch($propal->contactid);
+ print '';
+ print $contact->firstname.' '.$contact->name;
+ print '';
+ }
+ }
+ }
+ print ' | ';
+
+ if ($conf->projet->enabled)
+ $rowspan++;
+
+ print ''.$langs->trans('Note').' : '. nl2br($propal->note).' |
';
+
+ if ($conf->projet->enabled)
+ {
+ $langs->load("projects");
+ print '| '.$langs->trans('Project').' | ';
+ $numprojet = $societe->has_projects();
+ print '';
+ if (! $numprojet)
+ {
+ print $langs->trans("NoProject").' | ';
+ print 'id.'&action=create>'.$langs->trans('AddProject').'';
+ print ' | ';
+ }
+ else
+ {
+ if ($propal->statut == 0 && $user->rights->propale->creer)
+ {
+ print '';
+ print '';
+ print ' | ';
+ }
+ else
+ {
+ if (!empty($propal->projetidp))
+ {
+ print '';
+ $proj = new Project($db);
+ $proj->fetch($propal->projetidp);
+ print '';
+ print $proj->title;
+ print '';
+ print ' | ';
+ }
+ else {
+ print ' | ';
+ }
+ }
+ }
+ print '
';
+ }
+
+ print '| '.$langs->trans('GlobalDiscount').' | ';
+ if ($propal->brouillon == 1 && $user->rights->propale->creer)
+ {
+ print '';
+ }
+ else
+ {
+ print ''.$propal->remise_percent.' % | ';
+ }
+ print '
';
- print '';
+ print '| '.$langs->trans('AmountHT').' | ';
+ print ''.price($obj->price).' | ';
+ print ''.$langs->trans("Currency".$conf->monnaie).' |
';
+
+ print '| '.$langs->trans('VAT').' | '.price($propal->total_tva).' | ';
+ print ''.$langs->trans("Currency".$conf->monnaie).' |
';
+ print '| '.$langs->trans('AmountTTC').' | '.price($propal->total_ttc).' | ';
+ print ''.$langs->trans("Currency".$conf->monnaie).' |
';
+ print '| '.$langs->trans('Status').' | '.$propal->getLibStatut().' |
';
+ print '
';
+ if ($num_lignes)
+ {
+ print '';
+ print '| '.$langs->trans('Description').' | ';
+ print ''.$langs->trans('VAT').' | ';
+ print ''.$langs->trans('PriceUHT').' | ';
+ print ''.$langs->trans('Qty').' | ';
+ print ''.$langs->trans('Discount').' | ';
+ print ''.$langs->trans('AmountHT').' | ';
+ print ' | | ';
+ print "
\n";
+ }
+ $var=True;
+ while ($i < $num_lignes)
+ {
+ $objp = $db->fetch_object($resql);
+ $var=!$var;
+ if ($_GET['action'] != 'editline' || $_GET['rowid'] != $objp->rowid)
+ {
+ print '';
+ if ($objp->fk_product > 0)
+ {
+ print '| ';
+ if ($objp->fk_product_type)
+ print img_object($langs->trans('ShowService'),'service');
+ else
+ print img_object($langs->trans('ShowProduct'),'product');
+ print ' '.stripslashes(nl2br($objp->description?$objp->description:$objp->product)).'';
+ if ($objp->date_start && $objp->date_end)
+ {
+ print ' (Du '.dolibarr_print_date($objp->date_start).' au '.dolibarr_print_date($objp->date_end).')';
+ }
+ if ($objp->date_start && ! $objp->date_end)
+ {
+ print ' (A partir du '.dolibarr_print_date($objp->date_start).')';
+ }
+ if (! $objp->date_start && $objp->date_end)
+ {
+ print " (Jusqu'au ".dolibarr_print_date($objp->date_end).')';
+ }
+ print ' | ';
+ }
+ else
+ {
+ print ''.stripslashes(nl2br($objp->description));
+ if ($objp->date_start && $objp->date_end)
+ {
+ print ' (Du '.dolibarr_print_date($objp->date_start).' au '.dolibarr_print_date($objp->date_end).')';
+ }
+ if ($objp->date_start && ! $objp->date_end)
+ {
+ print ' (A partir du '.dolibarr_print_date($objp->date_start).')';
+ }
+ if (! $objp->date_start && $objp->date_end)
+ {
+ print " (Jusqu'au ".dolibarr_print_date($objp->date_end).')';
+ }
+ print " | \n";
+ }
+ print ''.$objp->tva_tx.' % | ';
+ print ''.price($objp->subprice)." | \n";
+ print ''.$objp->qty.' | ';
+ if ($objp->remise_percent > 0)
+ {
+ print ''.$objp->remise_percent." % | \n";
+ }
+ else
+ {
+ print ' | ';
+ }
+ print ''.price($objp->subprice*$objp->qty*(100-$objp->remise_percent)/100)." | \n";
+
+ print ' | | ';
+
+ print '
';
+ }
+ // Update ligne de facture
+ // \todo
+
+
+ $total = $total + ($objp->qty * $objp->price);
+ $i++;
+ }
+ $db->free($resql);
+ }
+ else
+ {
+ dolibarr_print_error($db);
+ }
+
+ print '
';
+
+ }
+ }
+ else
+ {
+ dolibarr_print_error($db);
+ }
+
+ print '';
- /*
- * Boutons Actions
- */
- if ($obj->statut <> 4 && $user->societe_id == 0)
+ /*
+ * Boutons Actions
+ */
+ if ($obj->statut <> 4 && $user->societe_id == 0)
{
- print '';
+ print '| ';
- /*
- * Documents
- */
- if ($propal->brouillon == 1)
- {
- print ' | ';
+ print ' | ';
- /*
- * Liste des actions propres à la propal
- */
- $sql = 'SELECT id, '.$db->pdate('a.datea'). ' as da, label, note, fk_user_author' ;
- $sql .= ' FROM '.MAIN_DB_PREFIX.'actioncomm as a';
- $sql .= ' WHERE a.fk_soc = '.$obj->idp.' AND a.propalrowid = '.$propal->id ;
- $result = $db->query($sql);
- if ($result)
+ /*
+ * Liste des actions propres à la propal
+ */
+ $sql = 'SELECT id, '.$db->pdate('a.datea'). ' as da, label, note, fk_user_author' ;
+ $sql .= ' FROM '.MAIN_DB_PREFIX.'actioncomm as a';
+ $sql .= ' WHERE a.fk_soc = '.$obj->idp.' AND a.propalrowid = '.$propal->id ;
+ $resql = $db->query($sql);
+ if ($resql)
+ {
+ $num = $db->num_rows($resql);
+ if ($num)
{
- $num = $db->num_rows($result);
- if ($num)
- {
- print_titre($langs->trans('ActionsOnPropal'));
- $i = 0;
- $total = 0;
- $var=true;
+ print_titre($langs->trans('ActionsOnPropal'));
+ $i = 0;
+ $total = 0;
+ $var=true;
- print '';
- print '| '.$langs->trans('Ref').' | '.$langs->trans('Date').' | '.$langs->trans('Action').' | '.$langs->trans('By').' | ';
- print "\n";
+ print '';
+ print '| '.$langs->trans('Ref').' | '.$langs->trans('Date').' | '.$langs->trans('Action').' | '.$langs->trans('By').' | ';
+ print "\n";
- while ($i < $num)
- {
- $objp = $db->fetch_object($result);
- $var=!$var;
- print '';
- print '| '.img_object($langs->trans('ShowTask'),'task').' '.$objp->id.' | ';
- print ''.dolibarr_print_date($objp->da)." | \n";
- print ''.stripslashes($objp->label).' | ';
- $authoract = new User($db);
- $authoract->id = $objp->fk_user_author;
- $authoract->fetch('');
- print ''.$authoract->code.' | ';
- print " \n";
- $i++;
- }
- print ' ';
- }
- }
- else
- {
- dolibarr_print_error($db);
+ while ($i < $num)
+ {
+ $objp = $db->fetch_object($resql);
+ $var=!$var;
+ print '';
+ print '| '.img_object($langs->trans('ShowTask'),'task').' '.$objp->id.' | ';
+ print ''.dolibarr_print_date($objp->da)." | \n";
+ print ''.stripslashes($objp->label).' | ';
+ $authoract = new User($db);
+ $authoract->id = $objp->fk_user_author;
+ $authoract->fetch('');
+ print ''.$authoract->code.' | ';
+ print " \n";
+ $i++;
+ }
+ print ' ';
}
+ }
+ else
+ {
+ dolibarr_print_error($db);
+ }
- print ' | ';
+ print ' |
';
} else {
- /**
- *
- * Mode Liste des propales
- *
- */
+ /**
+ *
+ * Mode Liste des propales
+ *
+ */
- if (! $sortfield) $sortfield="p.datep";
- if (! $sortorder) $sortorder="DESC";
- if ($page == -1) $page = 0 ;
+ if (! $sortfield) $sortfield="p.datep";
+ if (! $sortorder) $sortorder="DESC";
+ if ($page == -1) $page = 0 ;
- $pageprev = $page - 1;
- $pagenext = $page + 1;
- $limit = $conf->liste_limit;
- $offset = $limit * $page ;
+ $pageprev = $page - 1;
+ $pagenext = $page + 1;
+ $limit = $conf->liste_limit;
+ $offset = $limit * $page ;
- $sql = "SELECT s.nom, s.idp, p.rowid as propalid, p.price, p.ref, p.fk_statut, ".$db->pdate("p.datep")." as dp";
- $sql.= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."propal as p ";
- $sql.= " WHERE p.fk_soc = s.idp";
- if ($socidp) $sql .= " AND s.idp = $socidp";
- if ($viewstatut <> '') $sql .= " AND p.fk_statut in ($viewstatut)"; // viewstatut peut etre combinaisons séparé par virgules
- if ($month > 0) $sql .= " AND date_format(p.datep, '%Y-%m') = '$year-$month'";
- if ($year > 0) $sql .= " AND date_format(p.datep, '%Y') = $year";
- $sql .= " ORDER BY $sortfield $sortorder, p.rowid DESC ";
- $sql .= $db->plimit($limit + 1,$offset);
+ $sql = "SELECT s.nom, s.idp, p.rowid as propalid, p.price, p.ref, p.fk_statut, ".$db->pdate("p.datep")." as dp";
+ $sql.= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."propal as p ";
+ $sql.= " WHERE p.fk_soc = s.idp";
+ if ($socidp) $sql .= " AND s.idp = $socidp";
+ if ($viewstatut <> '') $sql .= " AND p.fk_statut in ($viewstatut)"; // viewstatut peut etre combinaisons séparé par virgules
+ if ($month > 0) $sql .= " AND date_format(p.datep, '%Y-%m') = '$year-$month'";
+ if ($year > 0) $sql .= " AND date_format(p.datep, '%Y') = $year";
+ $sql .= " ORDER BY $sortfield $sortorder, p.rowid DESC ";
+ $sql .= $db->plimit($limit + 1,$offset);
- if ( $db->query($sql) )
+ if ( $db->query($sql) )
{
- $num = $db->num_rows();
+ $num = $db->num_rows();
- $propalstatic=new Propal($db);
+ $propalstatic=new Propal($db);
- print_barre_liste($langs->trans("Proposals"), $page, "propal.php","&socidp=$socidp",$sortfield,$sortorder,'',$num);
+ print_barre_liste($langs->trans("Proposals"), $page, "propal.php","&socidp=$socidp",$sortfield,$sortorder,'',$num);
- $i = 0;
- print "