From 0732193013084bdd48f6214e552e54b530c61886 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 10 Jul 2005 14:51:20 +0000 Subject: [PATCH] Look: Mise aux normes visuelles des onglets propal. --- htdocs/comm/addpropal.php | 4 +- htdocs/comm/propal.php | 534 ++++++++++----------- htdocs/comm/propal/document.php | 20 +- htdocs/comm/propal/info.php | 14 +- htdocs/comm/propal/note.php | 20 +- htdocs/compta/propal.php | 790 +++++++++++++++++++------------- 6 files changed, 783 insertions(+), 599 deletions(-) diff --git a/htdocs/comm/addpropal.php b/htdocs/comm/addpropal.php index e2b0b8a30cb..ad089b249b9 100644 --- a/htdocs/comm/addpropal.php +++ b/htdocs/comm/addpropal.php @@ -101,7 +101,7 @@ if ($_GET["action"] == 'create') print ""; print ''.$langs->trans("Author").''.$user->fullname.''; - print 'Durée de validité '.$langs->trans("days").''; + print ''.$langs->trans("ValidityDuration").' '.$langs->trans("days").''; /* * Destinataire de la propale @@ -167,7 +167,7 @@ if ($_GET["action"] == 'create') if ($numprojet==0) { - print 'Cette société n\'a pas de projet.
'; + print $langs->trans("NoProject").' - '; print 'id.'&action=create>'.$langs->trans("AddProject").''; } else diff --git a/htdocs/comm/propal.php b/htdocs/comm/propal.php index b62e00cbc05..b04d1d2b730 100644 --- a/htdocs/comm/propal.php +++ b/htdocs/comm/propal.php @@ -20,7 +20,6 @@ * * $Id$ * $Source$ - * */ /** @@ -33,6 +32,7 @@ require('./pre.inc.php'); $langs->load('companies'); $langs->load('propal'); +$langs->load('compta'); $langs->load('bills'); $user->getrights('propale'); @@ -376,10 +376,14 @@ if ($_GET['propalid']) $h=0; $head[$h][0] = DOL_URL_ROOT.'/comm/propal.php?propalid='.$propal->id; - $head[$h][1] = $langs->trans('Card'); + $head[$h][1] = $langs->trans('CommercialCard'); $hselected=$h; $h++; + $head[$h][0] = DOL_URL_ROOT.'/compta/propal.php?propalid='.$propal->id; + $head[$h][1] = $langs->trans('AccountancyCard'); + $h++; + $head[$h][0] = DOL_URL_ROOT.'/comm/propal/note.php?propalid='.$propal->id; $head[$h][1] = $langs->trans('Note'); $h++; @@ -412,14 +416,10 @@ if ($_GET['propalid']) $sql = 'SELECT s.nom, s.idp, p.price, p.fk_projet,p.remise, p.tva, p.total, p.ref,'.$db->pdate('p.datep').' as dp, c.id as statut, c.label as lst, p.note, x.firstname, x.name, x.fax, x.phone, x.email, p.fk_user_author, p.fk_user_valid, p.fk_user_cloture, p.datec, p.date_valid, p.date_cloture'; $sql .= ' FROM '.MAIN_DB_PREFIX.'societe as s, '.MAIN_DB_PREFIX.'propal as p, '.MAIN_DB_PREFIX.'c_propalst as c, '.MAIN_DB_PREFIX.'socpeople as x'; $sql .= ' WHERE p.fk_soc = s.idp AND p.fk_statut = c.id AND x.idp = p.fk_soc_contact AND p.rowid = '.$propal->id; - - if ($socidp) - { - $sql .= ' AND s.idp = '.$socidp; - } + if ($socidp) $sql .= ' AND s.idp = '.$socidp; $result = $db->query($sql); - if ( $result ) + if ($result) { if ($db->num_rows($result)) { @@ -427,10 +427,9 @@ if ($_GET['propalid']) $societe = new Societe($db); $societe->fetch($obj->idp); - // \todo faire en sorte que la form respecte à nouveau la norme - // problème : sans javascript, ça va être chaud... + print ''; - $rowspan=8; + $rowspan=7; print ''; - print ''; + print ''; + print ''; + print ''; + print ''; @@ -456,6 +458,8 @@ if ($_GET['propalid']) } print ''; print ''; + + // Receiver $langs->load('mails'); print ''; print ''; @@ -488,10 +492,6 @@ if ($_GET['propalid']) print ''; print $contact->firstname.' '.$contact->name; print ''; - if ($contact->email) - { - print ' <'.$contact->email.'>'; - } } } } @@ -502,44 +502,49 @@ if ($_GET['propalid']) print ''; - print ''; if ($conf->projet->enabled) { $langs->load('projects'); $numprojet = $societe->has_projects(); - if (!$numprojet) + print ''; } else { if ($propal->statut == 0 && $user->rights->propale->creer) { + print ''; } else { if (!empty($propal->projetidp)) { + print ''; } + else { + print ''; + } } } } - print ''; - - $author = new User($db, $obj->fk_user_author); - $author->fetch(''); - print ''; + print ''; print ''; if ($propal->brouillon == 1 && $user->rights->propale->creer) @@ -573,21 +578,6 @@ if ($_GET['propalid']) print ''; } - if ($_GET['action'] == 'statut') - { - print ''; - print '
'.$langs->trans('Company').''; if ($societe->client == 1) { @@ -441,7 +440,10 @@ if ($_GET['propalid']) $url = DOL_URL_ROOT.'/comm/prospect/fiche.php?socid='.$societe->id; } print ''.$societe->nom.'Conditions de réglement :
Conditions de réglement'.' '.'
'.$langs->trans('Date').''; print dolibarr_print_date($propal->date); print '
'.$langs->trans('MailTo').''.$langs->trans('Note').' :
'. nl2br($propal->note).'
'.$langs->trans('Projects').''; + print '
'.$langs->trans('Project').''; + if (! $numprojet) { - print 'Cette société n\'a pas de projet.
'; - print 'id.'&action=create>'.$langs->trans('AddProject').''; + print $langs->trans("NoProject").'
'; + print 'id.'&action=create>'.$langs->trans('AddProject').''; + print ''; print '
'; print ''; $form->select_projects($societe->id, $propal->projetidp, 'projetidp'); print ''; print '
'; + print '
'; $proj = new Project($db); $proj->fetch($propal->projetidp); print ''; print $proj->title; print ''; + print ' 
'.$langs->trans('Author').''.$author->fullname.'
'.$langs->trans('GlobalDiscount').'
'; - print ''; - print '
Clôturer comme : '; - print ''; - print '
'.$langs->trans('Comments').' :
'; - } - /* * Lignes de propale * @@ -751,236 +741,256 @@ if ($_GET['propalid']) print "\n"; print ''; } + print '
'; - } - /* - * Fin Ajout ligne - * - */ - print ''; - - /* - * Barre d'actions - */ - if ($propal->statut < 2) - { - print '
'; - - // Valid - if ($propal->statut == 0) - { - if ($user->rights->propale->valider) - { - print ''.$langs->trans('Valid').''; - } - } - - // Save - if ($propal->statut == 1) - { - if ($user->rights->propale->creer) - { - print ''.$langs->trans('Edit').''; - } - } - - // Build PDF - if ($propal->statut < 2 && $user->rights->propale->creer) - { - print ''.$langs->trans('BuildPDF').''; - } - - // Send - if ($propal->statut == 1) - { - if ($user->rights->propale->envoyer) - { - $forbidden_chars=array('/','\\',':','*','?','"','<','>','|','[',']',',',';','='); - $propref = str_replace($forbidden_chars,'_',$obj->ref); - $file = $conf->propal->dir_output . '/'.$propref.'/'.$propref.'.pdf'; - if (file_exists($file)) - { - print ''.$langs->trans('Send').''; - } - } - } - - // Delete - if ($propal->statut == 0) - { - if ($user->rights->propale->supprimer) - { - print ''.$langs->trans('Delete').''; - } - } - - // Close - if ($propal->statut != 0) - { - if ($propal->statut == 1 && $user->rights->propale->cloturer) - { - print ''.$langs->trans('Close').''; - } - } - print '

'; - } - - - - /* - * - */ - if ($propal->brouillon == 1) - { - print '
'; - print ''; - } - print '
'; - print_titre($langs->trans('Documents')); - - - /* - * - */ - print ''; - $forbidden_chars=array('/','\\',':','*','?','"','<','>','|','[',']',',',';','='); - $propref = str_replace($forbidden_chars,'_',$propal->ref); - $file = $conf->propal->dir_output . '/'.$propref.'/'.$propref.'.pdf'; - $relativepath = $propref.'/'.$propref.'.pdf'; - - $var=true; - - if (file_exists($file)) - { - print ''; - print ''; - print ''; - print ''; - } - - if ($propal->brouillon == 1 && $user->rights->propale->creer) - { - print ''; - } - print "
'.$langs->trans('Propal').' PDF'.$propal->ref.'.pdf'.filesize($file). ' bytes'.strftime('%d %B %Y %H:%M:%S',filemtime($file)).'
Modèle'; - $html = new Form($db); - $modelpdf = new Propal_Model_pdf($db); - $html->select_array('modelpdf',$modelpdf->liste_array(),$propal->modelpdf); - print ''; - print '
\n"; - - /* - * Si le module commandes est activé ... - */ - if($conf->commande->enabled) - { - $nb_commande = sizeof($propal->commande_liste_array()); - if ($nb_commande > 0) - { - $coms = $propal->associated_orders(); - print '
'; - print ''; - for ($i = 0 ; $i < $nb_commande ; $i++) - { - print '\n"; - print "\n"; - } - print '
Commande(s) rattachée(s)
'.$coms[$i]->ref."
'; - } - } - 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) - { - $num = $db->num_rows($result); - if ($num) - { - print_titre($langs->trans('ActionsOnPropal')); - $i = 0; - $total = 0; - print ''; - print ''; - print "\n"; - - $var=true; - while ($i < $num) - { - $objp = $db->fetch_object($result); - $var=!$var; - print ''; - print ''; - print '\n"; - print ''; - $authoract = new User($db); - $authoract->id = $objp->fk_user_author; - $authoract->fetch(''); - print ''; - print "\n"; - $i++; - } - print '
'.$langs->trans('Ref').''.$langs->trans('Date').''.$langs->trans('Action').''.$langs->trans('By').'
'.img_object($langs->trans('ShowTask'),'task').' '.$objp->id.''.dolibarr_print_date($objp->da)."'.stripslashes($objp->label).''.$authoract->code.'
'; - } - } - else - { - dolibarr_print_error($db); - } - - print '
'; - - if ($propal->brouillon == 1) - { - print '
'; - } - - /* - * - * - */ - if ($_GET['action'] == 'presend') - { - print '
'; - print_titre($langs->trans('SendPropalByMail')); - - $liste[0]=" "; - foreach ($societe->contact_email_array() as $key=>$value) { - $liste[$key]=$value; - } - - // Créé l'objet formulaire mail - include_once('../html.formmail.class.php'); - $formmail = new FormMail($db); - $formmail->fromname = $user->fullname; - $formmail->frommail = $user->email; - $formmail->withfrom=1; - $formmail->withto=$liste; - $formmail->withcc=1; - $formmail->withtopic=$langs->trans('SendPropalRef','__PROPREF__'); - $formmail->withfile=1; - $formmail->withbody=1; - // Tableau des substitutions - $formmail->substit['__PROPREF__']=$propal->ref; - // Tableau des paramètres complémentaires - $formmail->param['action']='send'; - $formmail->param['models']='propal_send'; - $formmail->param['propalid']=$propal->id; - $formmail->param['returnurl']=DOL_URL_ROOT.'/comm/propal.php?propalid='.$propal->id; - - $formmail->show_form(); } } else { dolibarr_print_error($db); } + + print ''; + + /* + * Formulaire cloture (signé ou non) + */ + if ($_GET['action'] == 'statut') + { + print '
'; + print ''; + print ''; + print '
'.$langs->trans("CloseAs").': '; + print ''; + print ''; + print '
'.$langs->trans('Note').':
'; + } + + + /* + * Barre d'actions + */ + if ($propal->statut < 2) + { + print '
'; + + // Valid + if ($propal->statut == 0) + { + if ($user->rights->propale->valider) + { + print ''.$langs->trans('Valid').''; + } + } + + // Save + if ($propal->statut == 1) + { + if ($user->rights->propale->creer) + { + print ''.$langs->trans('Edit').''; + } + } + + // Build PDF + if ($propal->statut < 2 && $user->rights->propale->creer) + { + print ''.$langs->trans('BuildPDF').''; + } + + // Send + if ($propal->statut == 1) + { + if ($user->rights->propale->envoyer) + { + $forbidden_chars=array('/','\\',':','*','?','"','<','>','|','[',']',',',';','='); + $propref = str_replace($forbidden_chars,'_',$obj->ref); + $file = $conf->propal->dir_output . '/'.$propref.'/'.$propref.'.pdf'; + if (file_exists($file)) + { + print ''.$langs->trans('Send').''; + } + } + } + + // Close + if ($propal->statut != 0) + { + if ($propal->statut == 1 && $user->rights->propale->cloturer) + { + print ''.$langs->trans('Close').''; + } + } + + // Delete + if ($propal->statut == 0) + { + if ($user->rights->propale->supprimer) + { + print ''.$langs->trans('Delete').''; + } + } + + print '
'; + } + + + print '
'; + + /* + * Documents + */ + if ($propal->brouillon == 1) + { + print '
'; + print ''; + } + print_titre($langs->trans('Documents')); + + print ''; + $forbidden_chars=array('/','\\',':','*','?','"','<','>','|','[',']',',',';','='); + $propref = str_replace($forbidden_chars,'_',$propal->ref); + $file = $conf->propal->dir_output . '/'.$propref.'/'.$propref.'.pdf'; + $relativepath = $propref.'/'.$propref.'.pdf'; + + $var=true; + + if (file_exists($file)) + { + print ''; + print ''; + print ''; + print ''; + } + + if ($propal->brouillon == 1 && $user->rights->propale->creer) + { + print ''; + } + print "
'.$langs->trans('Propal').' PDF'.$propal->ref.'.pdf'.filesize($file). ' bytes'.strftime('%d %B %Y %H:%M:%S',filemtime($file)).'
Modèle'; + $html = new Form($db); + $modelpdf = new Propal_Model_pdf($db); + $html->select_array('modelpdf',$modelpdf->liste_array(),$propal->modelpdf); + print ''; + print '
\n"; + + if ($propal->brouillon == 1) + { + print '
'; + } + + + /* + * Si le module commandes est activé ... + */ + if($conf->commande->enabled) + { + $nb_commande = sizeof($propal->commande_liste_array()); + if ($nb_commande > 0) + { + $coms = $propal->associated_orders(); + print '
'; + print ''; + for ($i = 0 ; $i < $nb_commande ; $i++) + { + print '\n"; + print "\n"; + } + print '
Commande(s) rattachée(s)
'.$coms[$i]->ref."
'; + } + } + + 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) + { + $num = $db->num_rows($result); + if ($num) + { + print_titre($langs->trans('ActionsOnPropal')); + $i = 0; + $total = 0; + print ''; + print ''; + print "\n"; + + $var=true; + while ($i < $num) + { + $objp = $db->fetch_object($result); + $var=!$var; + print ''; + print ''; + print '\n"; + print ''; + $authoract = new User($db); + $authoract->id = $objp->fk_user_author; + $authoract->fetch(''); + print ''; + print "\n"; + $i++; + } + print '
'.$langs->trans('Ref').''.$langs->trans('Date').''.$langs->trans('Action').''.$langs->trans('By').'
'.img_object($langs->trans('ShowTask'),'task').' '.$objp->id.''.dolibarr_print_date($objp->da)."'.stripslashes($objp->label).''.$authoract->code.'
'; + } + } + else + { + dolibarr_print_error($db); + } + + print '
'; + + + + /* + * Action presend + * + */ + if ($_GET['action'] == 'presend') + { + print '
'; + print_titre($langs->trans('SendPropalByMail')); + + $liste[0]=" "; + foreach ($societe->contact_email_array() as $key=>$value) { + $liste[$key]=$value; + } + + // Créé l'objet formulaire mail + include_once('../html.formmail.class.php'); + $formmail = new FormMail($db); + $formmail->fromname = $user->fullname; + $formmail->frommail = $user->email; + $formmail->withfrom=1; + $formmail->withto=$liste; + $formmail->withcc=1; + $formmail->withtopic=$langs->trans('SendPropalRef','__PROPREF__'); + $formmail->withfile=1; + $formmail->withbody=1; + // Tableau des substitutions + $formmail->substit['__PROPREF__']=$propal->ref; + // Tableau des paramètres complémentaires + $formmail->param['action']='send'; + $formmail->param['models']='propal_send'; + $formmail->param['propalid']=$propal->id; + $formmail->param['returnurl']=DOL_URL_ROOT.'/comm/propal.php?propalid='.$propal->id; + + $formmail->show_form(); + } + } else { diff --git a/htdocs/comm/propal/document.php b/htdocs/comm/propal/document.php index d4458c381ea..b60ccd087dc 100644 --- a/htdocs/comm/propal/document.php +++ b/htdocs/comm/propal/document.php @@ -22,10 +22,10 @@ */ /** - \file htdocs/comm/propal/document.php - \ingroup propale - \brief Page de gestion des documents attachées à une proposition commerciale - \version $Revision$ + \file htdocs/comm/propal/document.php + \ingroup propale + \brief Page de gestion des documents attachées à une proposition commerciale + \version $Revision$ */ require('./pre.inc.php'); @@ -97,10 +97,14 @@ if ($propalid > 0) $h=0; - $head[$h][0] = DOL_URL_ROOT.'/comm/propal.php?propalid='.$propal->id; - $head[$h][1] = $langs->trans('Card'); - $h++; - + $head[$h][0] = DOL_URL_ROOT.'/comm/propal.php?propalid='.$propal->id; + $head[$h][1] = $langs->trans('CommercialCard'); + $h++; + + $head[$h][0] = DOL_URL_ROOT.'/compta/propal.php?propalid='.$propal->id; + $head[$h][1] = $langs->trans('AccountancyCard'); + $h++; + $head[$h][0] = DOL_URL_ROOT.'/comm/propal/note.php?propalid='.$propal->id; $head[$h][1] = $langs->trans('Note'); $h++; diff --git a/htdocs/comm/propal/info.php b/htdocs/comm/propal/info.php index 3af8b831958..d38c07a299a 100644 --- a/htdocs/comm/propal/info.php +++ b/htdocs/comm/propal/info.php @@ -21,7 +21,8 @@ * */ -/*! \file htdocs/comm/propal/info.php +/** + \file htdocs/comm/propal/info.php \ingroup propale \brief Page d'affichage des infos d'une proposition commerciale \version $Revision$ @@ -36,10 +37,13 @@ if (!$user->rights->propale->lire) accessforbidden(); require('../../propal.class.php'); + + /* * * */ + llxHeader(); if ($_GET['propalid']) @@ -52,7 +56,11 @@ if ($_GET['propalid']) $h=0; $head[$h][0] = DOL_URL_ROOT.'/comm/propal.php?propalid='.$propal->id; - $head[$h][1] = $langs->trans('Card'); + $head[$h][1] = $langs->trans('CommercialCard'); + $h++; + + $head[$h][0] = DOL_URL_ROOT.'/compta/propal.php?propalid='.$propal->id; + $head[$h][1] = $langs->trans('AccountancyCard'); $h++; $head[$h][0] = DOL_URL_ROOT.'/comm/propal/note.php?propalid='.$propal->id; @@ -81,5 +89,5 @@ if ($_GET['propalid']) $db->close(); } -llxFooter('Dernière modification $Date$ révision $Revision$'); +llxFooter('$Date$ - $Revision$'); ?> diff --git a/htdocs/comm/propal/note.php b/htdocs/comm/propal/note.php index e1c18e5b346..310280c0a3e 100644 --- a/htdocs/comm/propal/note.php +++ b/htdocs/comm/propal/note.php @@ -23,10 +23,10 @@ */ /** - \file htdocs/comm/propal/note.php - \ingroup propale - \brief Fiche d'information sur une proposition commerciale - \version $Revision$ + \file htdocs/comm/propal/note.php + \ingroup propale + \brief Fiche d'information sur une proposition commerciale + \version $Revision$ */ require('./pre.inc.php'); @@ -75,10 +75,14 @@ if ($_GET['propalid']) { $h=0; - $head[$h][0] = DOL_URL_ROOT.'/comm/propal.php?propalid='.$propal->id; - $head[$h][1] = $langs->trans('Card'); - $h++; - + $head[$h][0] = DOL_URL_ROOT.'/comm/propal.php?propalid='.$propal->id; + $head[$h][1] = $langs->trans('CommercialCard'); + $h++; + + $head[$h][0] = DOL_URL_ROOT.'/compta/propal.php?propalid='.$propal->id; + $head[$h][1] = $langs->trans('AccountancyCard'); + $h++; + $head[$h][0] = DOL_URL_ROOT.'/comm/propal/note.php?propalid='.$propal->id; $head[$h][1] = $langs->trans('Note'); $hselected=$h; diff --git a/htdocs/compta/propal.php b/htdocs/compta/propal.php index e5edbe14849..ddc5b89293c 100644 --- a/htdocs/compta/propal.php +++ b/htdocs/compta/propal.php @@ -94,340 +94,498 @@ if ($_GET["propalid"]) { $propal = new Propal($db); $propal->fetch($_GET["propalid"]); + $h=0; - if ($valid == 1) + $head[$h][0] = DOL_URL_ROOT.'/comm/propal.php?propalid='.$propal->id; + $head[$h][1] = $langs->trans('CommercialCard'); + $h++; + + $head[$h][0] = DOL_URL_ROOT.'/compta/propal.php?propalid='.$propal->id; + $head[$h][1] = $langs->trans('AccountancyCard'); + $hselected=$h; + $h++; + + $head[$h][0] = DOL_URL_ROOT.'/comm/propal/note.php?propalid='.$propal->id; + $head[$h][1] = $langs->trans('Note'); + $h++; + + $head[$h][0] = DOL_URL_ROOT.'/comm/propal/info.php?propalid='.$propal->id; + $head[$h][1] = $langs->trans('Info'); + $h++; + + $head[$h][0] = DOL_URL_ROOT.'/comm/propal/document.php?propalid='.$propal->id; + $head[$h][1] = $langs->trans('Documents'); + $h++; + + dolibarr_fiche_head($head, $hselected, $langs->trans('Proposal').': '.$propal->ref); + + + /* + * Fiche propal + * + */ + $sql = 'SELECT s.nom, s.idp, p.price, p.fk_projet,p.remise, p.tva, p.total, p.ref,'.$db->pdate('p.datep').' as dp, c.id as statut, c.label as lst, p.note, x.firstname, x.name, x.fax, x.phone, x.email, p.fk_user_author, p.fk_user_valid, p.fk_user_cloture, p.datec, p.date_valid, p.date_cloture'; + $sql .= ' FROM '.MAIN_DB_PREFIX.'societe as s, '.MAIN_DB_PREFIX.'propal as p, '.MAIN_DB_PREFIX.'c_propalst as c, '.MAIN_DB_PREFIX.'socpeople as x'; + $sql .= ' WHERE p.fk_soc = s.idp AND p.fk_statut = c.id AND x.idp = p.fk_soc_contact AND p.rowid = '.$propal->id; + if ($socidp) $sql .= ' AND s.idp = '.$socidp; + + $result = $db->query($sql); + if ($result) + { + if ($db->num_rows($result)) + { + $obj = $db->fetch_object($result); + + $societe = new Societe($db); + $societe->fetch($obj->idp); + + print ''; + $rowspan=7; + print ''; + print ''; + print ''; + print ''; + + print ''; + + print ''; + print ''; + + // Receiver + $langs->load('mails'); + print ''; + print ''; + print ''; + + if ($conf->projet->enabled && $propal->projetidp) + $rowspan++; + + print ''; + + print ''; + if ($conf->projet->enabled) + { + $langs->load('projects'); + $numprojet = $societe->has_projects(); + print ''; + } + else + { + if ($propal->statut == 0 && $user->rights->propale->creer) + { + print ''; + } + else + { + if (!empty($propal->projetidp)) + { + print ''; + } + else { + print ''; + } + } + } + } + print ''; + + print ''; + if ($propal->brouillon == 1 && $user->rights->propale->creer) + { + print ''; + print ''; + print ''; + print ''; + } + else + { + print ''; + } + print ''; + + print ''; + print ''; + print ''; + + print ''; + print ''; + print ''; + print ''; + print ''; + 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.'Conditions de réglement'.' '.'
'.$langs->trans('Date').''; + print dolibarr_print_date($propal->date); + print ''.$langs->trans('DateEndPropal').''; + if ($propal->fin_validite) + { + print dolibarr_print_date($propal->fin_validite); + } + else { + print $langs->trans("Unknown"); + } + print '
'.$langs->trans('MailTo').''; + + $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 '
'; + print ''; + $form->select_contacts($societe->id, $propal->contactid, 'contactidp'); + print ''; + 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 '
'.$langs->trans('Note').' :
'. nl2br($propal->note).'
'.$langs->trans('Project').''; + if (! $numprojet) + { + print $langs->trans("NoProject").''; + print 'id.'&action=create>'.$langs->trans('AddProject').''; + print ''; + print '
'; + print ''; + $form->select_projects($societe->id, $propal->projetidp, 'projetidp'); + print ''; + print '
'; + print '
'; + $proj = new Project($db); + $proj->fetch($propal->projetidp); + print ''; + print $proj->title; + print ''; + print ' 
'.$langs->trans('GlobalDiscount').'
% '; + print ''; + print ' ?'; + print ''.$propal->remise_percent.' %
'.$langs->trans('AmountHT').''.price($obj->price).''.$conf->monnaie.'
'.$langs->trans('VAT').''.price($propal->total_tva).''.$conf->monnaie.'
'.$langs->trans('AmountTTC').''.price($propal->total_ttc).''.$conf->monnaie.'
'.$langs->trans('Status').''.$propal->getLibStatut().'

'; + 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 ''; + print ''; + print ''; + print ''; + print ''; + print ''; + 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 ''; + } + else + { + print '\n"; + } + print ''; + print '\n"; + print ''; + if ($objp->remise_percent > 0) + { + print '\n"; + } + else + { + print ''; + } + print '\n"; + + // Icone d'edition et suppression + if ($propal->statut == 0 && $user->rights->propale->creer) + { + print ''; + 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 '
'.$langs->trans('Description').''.$langs->trans('VAT').''.$langs->trans('PriceUHT').''.$langs->trans('Qty').''.$langs->trans('Discount').''.$langs->trans('AmountHT').'  
'; + 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 ''.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 "'.$objp->tva_tx.' %'.price($objp->subprice)."'.$objp->qty.''.$objp->remise_percent." % '.price($objp->subprice*$objp->qty*(100-$objp->remise_percent)/100)."'; + print img_edit(); + print ''; + print img_delete(); + print '  

'; + + } + } + else + { + dolibarr_print_error($db); + } + + print ''; + + + /* + * Boutons Actions + */ + if ($obj->statut <> 4 && $user->societe_id == 0) { - $propal->valid($user->id); + print '
'; + + if ($obj->statut == 2 && $user->rights->facture->creer) + { + print '".$langs->trans("BuildBill").""; + } + + if ($obj->statut == 2 && $num_fac_asso) + { + print '".$langs->trans("ClassifyBilled").""; + } + + print "
"; } + + + + print '\n"; + print "
'; + + /* + * Documents + */ + if ($propal->brouillon == 1) + { + print '
'; + print ''; + } + print_titre($langs->trans('Documents')); + + print ''; + $forbidden_chars=array('/','\\',':','*','?','"','<','>','|','[',']',',',';','='); + $propref = str_replace($forbidden_chars,'_',$propal->ref); + $file = $conf->propal->dir_output . '/'.$propref.'/'.$propref.'.pdf'; + $relativepath = $propref.'/'.$propref.'.pdf'; + + $var=true; + + if (file_exists($file)) + { + print ''; + print ''; + print ''; + print ''; + } + + if ($propal->brouillon == 1 && $user->rights->propale->creer) + { + print ''; + } + print "
'.$langs->trans('Propal').' PDF'.$propal->ref.'.pdf'.filesize($file). ' bytes'.strftime('%d %B %Y %H:%M:%S',filemtime($file)).'
Modèle'; + $html = new Form($db); + $modelpdf = new Propal_Model_pdf($db); + $html->select_array('modelpdf',$modelpdf->liste_array(),$propal->modelpdf); + print ''; + print '
\n"; + + if ($propal->brouillon == 1) + { + print '
'; + } + + /* - * - */ - print ""; - print ""; - print "
Proposition commerciale : $propal->ref
"; - /* - * - */ - $sql = "SELECT s.nom, s.idp, p.price, p.fk_projet,p.remise, p.tva, p.total, p.ref,".$db->pdate("p.datep")." as dp, c.id as statut, c.label as lst, p.note, x.firstname, x.name, x.fax, x.phone, x.email, p.fk_user_author, p.fk_user_valid, p.fk_user_cloture, p.datec, p.date_valid, p.date_cloture"; - $sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."propal as p, ".MAIN_DB_PREFIX."c_propalst as c, ".MAIN_DB_PREFIX."socpeople as x"; - $sql .= " WHERE p.fk_soc = s.idp AND p.fk_statut = c.id AND x.idp = p.fk_soc_contact AND p.rowid = ".$propal->id; + * Factures associees + */ + $sql = "SELECT f.facnumber, f.total,".$db->pdate("f.datef")." as df, f.rowid as facid, f.fk_user_author, f.paye"; + $sql .= " FROM ".MAIN_DB_PREFIX."facture as f, ".MAIN_DB_PREFIX."fa_pr as fp WHERE fp.fk_facture = f.rowid AND fp.fk_propal = ".$propal->id; $result = $db->query($sql); - - if ( $result ) + if ($result) { - $obj = $db->fetch_object($result); - - if ($db->num_rows()) - { - $color1 = "#e0e0e0"; - - print ''; - - print ''; - print ""; - // - - print ''; - - if ($obj->fk_projet) - { - $projet = new Project($db); - $projet->fetch($obj->fk_projet); - print ''; - } - print ""; - /* - * - */ - - print ""; - /* - * - */ - - print ""; - - /* - * - */ - - $totalht = $propal->price ; - - print ""; - /* - * - */ - print ''; - /* - * - */ - print ""; - $file = $conf->propal->dir_output. "/$obj->ref/$obj->ref.pdf"; - $relativepath = "$obj->ref/$obj->ref.pdf"; - - if (file_exists($file)) { - print ''; - } - print ''; - /* - * - */ - print ''; - - print ''; - - - print "
'.$langs->trans("Company").''.$obj->nom.'Note :
". nl2br($obj->note)."
'.$langs->trans("Date").''.dolibarr_print_date($obj->dp).'
'.$langs->trans("Project").''; - print ''; - print $projet->title.'
Destinataire$obj->firstname $obj->name <$obj->email>
".$langs->trans("AmountHT")."".price($obj->price + $obj->remise)." euros
".$langs->trans("Discount")."".price($obj->remise)." euros
".$langs->trans("TotalHT")."".price($totalht)." euros
'.$langs->trans("Author").''; - $author = new User($db, $obj->fk_user_author); - $author->fetch(''); - print $author->fullname.'
".$langs->trans("Propal")." PDF'.$obj->ref.'.pdf
'.$langs->trans("Status").' :'.$obj->lst.'
"; - - if ($action == 'statut') - { - print "
id."\" method=\"post\">"; - print ""; - print "'; - print '

'; - print "
"; - } - - - print ""; - - print "
"; - - /* - * Factures associees - */ - $sql = "SELECT f.facnumber, f.total,".$db->pdate("f.datef")." as df, f.rowid as facid, f.fk_user_author, f.paye"; - $sql .= " FROM ".MAIN_DB_PREFIX."facture as f, ".MAIN_DB_PREFIX."fa_pr as fp WHERE fp.fk_facture = f.rowid AND fp.fk_propal = ".$propal->id; - - $result = $db->query($sql); - if ($result) - { - $num_fac_asso = $db->num_rows($result); - $i = 0; $total = 0; - print "
"; - if ($num_fac_asso > 1) - { - print_titre("Factures associées"); - } - else - { - print_titre("Facture associée"); - } - print ''; - print ""; - print ''; - print ''; - print ''; - print ''; - print "\n"; - - $var=True; - while ($i < $num_fac_asso) - { - $objp = $db->fetch_object(); - $var=!$var; - print ""; - print "\n"; - print "\n"; - if ($objp->fk_user_author <> $user->id) - { - $fuser = new User($db, $objp->fk_user_author); - $fuser->fetch(); - print "\n"; - } - else - { - print "\n"; - } - print ''; - print ""; - $total = $total + $objp->total; - $i++; - } - print "\n"; - print "
'.$langs->trans("Ref").''.$langs->trans("Date").''.$langs->trans("Author").''.$langs->trans("Price").'
facid\">$objp->facnumber"; - if ($objp->paye) - { - print " (payée)"; - } - print "".dolibarr_print_date($objp->df)."".$fuser->fullname."".$user->fullname."'.price($objp->total).'
".$langs->trans("TotalHT")."".price($total)."
"; - $db->free(); - } - print "
"; - - /* - * Que si le module commande est actif ! - */ - if($conf->commande->enabled) - { - $nb_commande = sizeof($propal->commande_liste_array()); - if ($nb_commande > 0) - { - $coms = $propal->commande_liste_array(); - print '
'; - - if ($nb_commande == 1) - { - print "\n"; - } - else - { - print "\n"; - - for ($i = 0 ; $i < $nb_commande ; $i++) - { - print '\n"; - print "\n"; - } - } - print "
Commande rattachée : "; - print ''; - print img_file(); - print ' '.$coms[$i].""; - print "
Commandes rattachées
'.$coms[$i]."
"; - } - } - - /* - * - * Actions - * - */ - if ($obj->statut <> 4 && $user->societe_id == 0) - { - print '
'; - - if ($obj->statut == 2 && $user->rights->facture->creer) - { - print '"; - } - else - { - print ''; - } - - print ''; - print ''; - print ''; - - if ($obj->statut == 2 && $num_fac_asso) - { - print ""; - } - else - { - print ''; - } - print "
'; - print "id."&action=create\">Emettre une facture----[id."&action=setstatut&statut=4\">Facturée]-
"; - } - - } else { - print "Num rows = " . $db->num_rows(); - print "

$sql"; - } - - /* - * Produits - */ - print_titre("Produits"); - + $num_fac_asso = $db->num_rows($result); + $i = 0; $total = 0; + print "
"; + if ($num_fac_asso > 1) print_titre($langs->trans("RelatedBills")); + else print_titre($langs->trans("RelatedBill")); print ''; print ""; - print ''; - print ''; + print ''; + print ''; + print ''; + print ''; + print "\n"; - $sql = "SELECT pt.rowid, p.label as product, p.ref, pt.price, pt.qty, p.rowid as prodid, pt.remise_percent"; - $sql .= " FROM ".MAIN_DB_PREFIX."propaldet as pt, ".MAIN_DB_PREFIX."product as p WHERE pt.fk_product = p.rowid AND pt.fk_propal =".$propal->id; - $sql .= " ORDER BY pt.rowid ASC"; - if ($db->query($sql)) + $var=True; + while ($i < $num_fac_asso) { - $num = $db->num_rows(); - $i = 0; - $var=True; - while ($i < $num) + $objp = $db->fetch_object(); + $var=!$var; + print ""; + print '\n"; - print ''; - print ""; - print ''; - print "\n"; - $i++; + print " (payée)"; } - } - - $sql = "SELECT pt.rowid, pt.description as product, pt.price, pt.qty, pt.remise_percent"; - $sql .= " FROM ".MAIN_DB_PREFIX."propaldet as pt WHERE pt.fk_propal = ".$propal->id." AND pt.fk_product = 0"; - $sql .= " ORDER BY pt.rowid ASC"; - if ($db->query($sql)) - { - $num = $db->num_rows(); - $i = 0; - while ($i < $num) + print "\n"; + print "\n"; + if ($objp->fk_user_author <> $user->id) { - $objp = $db->fetch_object(); - $var=!$var; - print "\n"; - print ''; - print ''; - print ''; - print "\n"; - $i++; + $fuser = new User($db, $objp->fk_user_author); + $fuser->fetch(); + print "\n"; } + else + { + print "\n"; + } + print ''; + print ""; + $total = $total + $objp->total; + $i++; } - else - { - print $sql; - } - - print '
'.$langs->trans("Ref").''.$langs->trans("Product").''.$langs->trans("Price").''.$langs->trans("Discount").''.$langs->trans("Qty").'
'.$langs->trans("Ref").''.$langs->trans("Date").''.$langs->trans("Author").''.$langs->trans("Price").'
'.img_object($langs->trans("ShowBill"),"bill").' '.$objp->facnumber.''; + if ($objp->paye) { - $objp = $db->fetch_object(); - $var=!$var; - print "
[$objp->ref]'.$objp->product.'".price($objp->price)."'.$objp->remise_percent.' %".$objp->qty."
".dolibarr_print_date($objp->df)."
 '.$objp->product.''.price($objp->price).''.$objp->remise_percent.' %".$objp->qty."
".$fuser->fullname."".$user->fullname."'.price($objp->total).'
'; - - - /* - * Voir le suivi des actions - */ - if ($suivi) - { - $validor = new User($db, $obj->fk_user_valid); - $validor->fetch(''); - $cloturor = new User($db, $obj->fk_user_cloture); - $cloturor->fetch(''); - - print '

Cacher le suivi des actions '; - print ''; - print ''; - print ''; - print ''; - - print ''; - print ''; - - print ''; - print ''; - print '
 NomDate
Création'.$author->fullname.''.$obj->datec.'
Validation'.$validor->fullname.' '.$obj->date_valid.' 
Cloture'.$cloturor->fullname.' '.$obj->date_cloture.' 
'; - } - else - { - print '

Voir le suivi des actions '; - } - - } else { - dolibarr_print_error($db); + print "

".$langs->trans("TotalHT")."".price($total)."
"; + $db->free(); } + /* + * Commandes associées + */ + if($conf->commande->enabled) + { + $nb_commande = sizeof($propal->commande_liste_array()); + if ($nb_commande > 0) + { + $coms = $propal->commande_liste_array(); + print '
'; + + if ($nb_commande == 1) + { + print "\n"; + } + else + { + print "\n"; + + for ($i = 0 ; $i < $nb_commande ; $i++) + { + print '\n"; + print "\n"; + } + } + print "
Commande rattachée : "; + print ''; + print img_file(); + print ' '.$coms[$i].""; + print "
Commandes rattachées
'.$coms[$i]."
"; + } + } + + + print ''; + + // \todo Mettre ici les traces des envois par mail + + + + + + print ''; + + } else { /**