diff --git a/htdocs/comm/propal.php3 b/htdocs/comm/propal.php3 index c8984c59b8c..97352f6c5ae 100644 --- a/htdocs/comm/propal.php3 +++ b/htdocs/comm/propal.php3 @@ -55,7 +55,7 @@ if ($action == 'add') $propal = new Propal($db, $socidp); $propal->remise = $remise; - $propal->datep = $db->idate(mktime(12, 1 , 1, $pmonth, $pday, $pyear)); + $propal->datep = $db->idate(mktime(12, 1 , 1, $remonth, $reday, $reyear)); $propal->contactid = $contactidp; $propal->projetidp = $projetidp; @@ -104,7 +104,32 @@ if ($action == 'setstatut') $propal->cloture($user->id, $statut, $note); } -elseif ( $action == 'delete' ) + +if ($HTTP_POST_VARS["action"] == 'addligne') +{ + /* + * Ajout d'une ligne produit dans la propale + */ + if ($HTTP_POST_VARS["idprod"]) + { + $propal = new Propal($db); + $propal->id = $propalid; + $propal->insert_product($HTTP_POST_VARS["idprod"], $HTTP_POST_VARS["qty"]); + } +} + +if ($action == 'del_ligne') +{ + /* + * Supprime une ligne produit dans la propale + */ + $propal = new Propal($db); + $propal->id = $propalid; + $propal->delete_product($ligne); + +} + +if ( $action == 'delete' ) { $sql = "DELETE FROM llx_propal WHERE rowid = $propalid;"; if ( $db->query($sql) ) @@ -243,23 +268,30 @@ if ($propalid) { } - print ""; + if ($obj->statut == 0) + { + + $sql = "SELECT p.rowid,p.label,p.ref,p.price FROM llx_product as p ORDER BY p.ref"; + if ( $db->query($sql) ) + { + $opt = ""; + if ($result) + { + $num = $db->num_rows(); $i = 0; + while ($i < $num) + { + $objp = $db->fetch_object( $i); + $opt .= "\n"; + $i++; + } + } + $db->free(); + } + else + { + print $db->error(); + } + print ''; + print ''; + print ""; + print ''; + print ''; + print "\n"; + print ''; + + } + print "
"; + /* * Produits */ - $sql = "SELECT p.label as product, p.ref, pt.price, pt.qty"; + print_titre("Produits"); + + print ''; + print ""; + print ""; + print ""; + if ($obj->statut == 0) + { + print ""; + } + print "\n"; + + $sql = "SELECT pt.rowid,p.label as product, p.ref, pt.price, pt.qty"; $sql .= " FROM llx_propaldet as pt, llx_product as p WHERE pt.fk_product = p.rowid AND pt.fk_propal = $propalid"; $result = $db->query($sql); if ($result) { $num = $db->num_rows(); - $i = 0; $total = 0; - print "

Produits

RéfProduitPrixQté. 
"; - print ""; - print ""; - print ""; - print "\n"; + $i = 0; $var=True; @@ -271,56 +303,111 @@ if ($propalid) { print "\n"; print "\n"; print "\n"; + if ($obj->statut == 0) + { + print ''; + } print ""; - $total = $total + $objp->price; + $i++; } - print "
RéfProduitPrixQté.
[$objp->ref]$objp->product".price($objp->price)."".$objp->qty."Supprimer
"; } - /* - * - */ - print "
"; + /* * Actions */ print "

"; - if ($obj->statut == 0) { - print ""; - } else { - if ($obj->statut == 1) { - print ""; - } else { - print ""; + if ($obj->statut == 0) + { + print ""; } - } + else + { + if ($obj->statut == 1) + { + print ""; + } + else + { + print ""; + } + } /* * */ - print '"; + if ($obj->statut < 2) + { + print '"; + } + else + { + print ""; + } /* * */ - if ($obj->statut == 1) { - $file = $conf->propal->outputdir. "/$obj->ref/$obj->ref.pdf"; - if (file_exists($file)) { - print ""; - } else { - print ""; + if ($obj->statut == 1) + { + $file = PROPALE_OUTPUTDIR. "/$obj->ref/$obj->ref.pdf"; + if (file_exists($file)) + { + print ""; + } + else + { + print ''; + } + } + else + { + print ""; + } + if ($obj->statut == 0) + { + print ""; + } + else + { + print ""; } - } else { - print ""; - } - if ($obj->statut == 0) { - print ""; - } else { - print ""; - } print "
[Supprimer][Cloturer]-[Supprimer][Cloturer]-[Générer][Générer]-"; - print "[Envoyer la propale par mail]! Propale non generee !"; + print "[Envoyer la proposition]! Propale non generee !-[Valider]--[Valider]-
"; /* * @@ -330,165 +417,184 @@ if ($propalid) { * Send * */ - if ($action == 'send') { - $file = $GLOBALS["GLJ_ROOT"] . "/www-sys/doc/propal/$obj->ref/$obj->ref.pdf"; - if (file_exists($file)) { + if ($action == 'send') + { + $file = PROPALE_OUTPUTDIR . "/$obj->ref/$obj->ref.pdf"; + if (file_exists($file)) + { - $subject = "Notre proposition commerciale $obj->ref"; - $message = "Veuillez trouver ci-joint notre proposition commerciale $obj->ref\n\nCordialement\n\n"; - $filepath = $file ; - $filename = "$obj->ref.pdf"; - $mimetype = "application/pdf"; + $subject = "Notre proposition commerciale $obj->ref"; + $message = "Veuillez trouver ci-joint notre proposition commerciale $obj->ref\n\nCordialement\n\n"; + $filepath = $file ; + $filename = "$obj->ref.pdf"; + $mimetype = "application/pdf"; - $replyto = "$replytoname <$replytomail>"; + $replyto = "$replytoname <$replytomail>"; - $mailfile = new CMailFile($subject,$sendto,$replyto,$message,$filepath,$mimetype, $filename); + $mailfile = new CMailFile($subject,$sendto,$replyto,$message,$filepath,$mimetype, $filename); - if ( $mailfile->sendfile() ) { + if ( $mailfile->sendfile() ) + { - print "

envoyé à $sendto"; - print "

envoyé par ".htmlentities($replyto); - } else { - print "!! erreur d'envoi"; - } - } - /* - * Enregistre l'action - * - * Ne fonctionne pas, a corriger ! - */ + print "

envoyé à $sendto"; + print "

envoyé par ".htmlentities($replyto); + } + else + { + print "!! erreur d'envoi"; + } + } + /* + * Enregistre l'action + * + * Ne fonctionne pas, a corriger ! + */ - if ( $db->query($sql) ) { - $sql = "INSERT INTO llx_actioncomm (datea,fk_action,fk_soc, propalrowid,note, fk_user_author) "; - $sql .= " VALUES (now(), 3, $obj->idp, $propalid, 'Envoyée à $sendto',$user->id);"; - if (! $db->query($sql) ) { - print $db->error(); - print "

$sql

"; - } - } else { - print $db->error(); - } - } - /* - * - */ - print "
"; - print ""; - print ''; - } - - print "
"; - print "Documents générés
"; - print ""; + if ( $db->query($sql) ) + { + $sql = "INSERT INTO llx_actioncomm (datea,fk_action,fk_soc, propalrowid,note, fk_user_author) "; + $sql .= " VALUES (now(), 3, $obj->idp, $propalid, 'Envoyée à $sendto',$user->id);"; + if (! $db->query($sql) ) { + print $db->error(); + print "

$sql

"; + } + } + else + { + print $db->error(); + } + } + /* + * + */ + + print "
"; + print_titre("Documents générés"); + print ""; + + $file = PROPALE_OUTPUTDIR . "/$obj->ref/$obj->ref.pdf"; + if (file_exists($file)) + { + print ""; + print ''; + print ''; + print ''; + } + + print "
Propale PDF'.$obj->ref.'.pdf'.filesize($file). ' bytes'.strftime("%d %b %Y %H:%M:%S",filemtime($file)).'
\n"; + /* + * + */ + print "
"; + print_titre("Propale envoyée"); + /* + * + */ + $sql = "SELECT ".$db->pdate("a.datea"). " as da, note, fk_user_author" ; + $sql .= " FROM llx_actioncomm as a WHERE a.fk_soc = $obj->idp AND a.propalrowid = $propalid "; + + if ( $db->query($sql) ) + { + $num = $db->num_rows(); + $i = 0; $total = 0; + print ""; + print "\n"; + + while ($i < $num) + { + $objp = $db->fetch_object( $i); + print "\n"; + $authoract = new User($db); + $authoract->id = $objp->fk_user_author; + $authoract->fetch(''); + print "\n"; + print ""; + $i++; + } + print "
DateAuteur
".strftime("%d %B %Y %H:%M:%S",$objp->da)."$authoract->code
$objp->note
"; + $db->free(); + } + else + { + print $db->error(); + } + /* + * + */ + print "
"; + /* + * + * + */ + if ($action == 'presend') + { + $replytoname = $conf->propal->replytoname; + $replytomail = $conf->propal->replytomail; + + $from_name = $user->fullname ; //$conf->propal->fromtoname; + $from_mail = $user->email; //conf->propal->fromtomail; + + print "
\n"; + print "\n"; + print "\n"; - $file = PROPALE_OUTPUTDIR . "/$obj->ref/$obj->ref.pdf"; - if (file_exists($file)) + print_titre("Envoyer la propale par mail"); + print ""; + print ""; + print ""; + print ""; + print ""; + print ""; + + print "
Destinataire$obj->firstname $obj->nameemail\">
Expediteur$from_name$from_mail
Reply-to$replytoname$replytomail
"; + print ""; + print "
"; + } + + } + else { - print "
Propale PDF'.$obj->ref.'.pdf
\n"; - /* - * - */ - print ""; - print "Propale envoyée
"; - /* - * - */ - $sql = "SELECT ".$db->pdate("a.datea"). " as da, note, fk_user_author" ; - $sql .= " FROM llx_actioncomm as a WHERE a.fk_soc = $obj->idp AND a.propalrowid = $propalid "; - - if ( $db->query($sql) ) { - $num = $db->num_rows(); - $i = 0; $total = 0; - print ""; - print "\n"; - - while ($i < $num) { - $objp = $db->fetch_object( $i); - print "\n"; - $authoract = new User($db); - $authoract->id = $objp->fk_user_author; - $authoract->fetch(''); - print "\n"; - print ""; - $i++; + print "Num rows = " . $db->num_rows(); + print "

$sql"; } - print "

DateAuteur
".strftime("%d %B %Y %H:%M:%S",$objp->da)."$authoract->code
$objp->note
"; - $db->free(); - } else { - print $db->error(); - } /* + * Voir le suivi des actions * - */ - print ""; - /* * * */ - if ($action == 'presend') { - $sendto = "rq@lolix.org"; - - $replytoname = $conf->propal->replytoname; - $replytomail = $conf->propal->replytomail; - - $from_name = $user->fullname ; //$conf->propal->fromtoname; - $from_mail = $user->email; //conf->propal->fromtomail; - - print "
\n"; - print "\n"; - print "\n"; - print "\n"; - - print "

Envoyer la propale par mail"; - print ""; - print ""; - print ""; - print ""; - print ""; - print ""; - - print "
Destinataire$obj->firstname $obj->nameemail\">
Expediteur$from_name$from_mail
Reply-to$replytoname$replytomail
"; - print ""; - print "

"; - } - - } else { - print "Num rows = " . $db->num_rows(); + if ($suivi) + { + $validor = new User($db, $obj->fk_user_valid); + $validor->fetch(''); + $cloturor = new User($db, $obj->fk_user_cloture); + $cloturor->fetch(''); + + print '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 + { + print $db->error(); print "

$sql"; } - /* - * 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 '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 { - print $db->error(); - print "

$sql"; - } - + /* *