La recherche raccourci sur les propals regarde aussi dans la description des lignes

This commit is contained in:
Laurent Destailleur 2005-08-24 22:38:00 +00:00
parent dd113c6cef
commit b3abf0da5b
2 changed files with 103 additions and 95 deletions

View File

@ -96,9 +96,13 @@ if ($conf->propal->enabled && $user->rights->propale->lire) {
print '<form method="post" action="'.DOL_URL_ROOT.'/comm/propal.php">'; print '<form method="post" action="'.DOL_URL_ROOT.'/comm/propal.php">';
print '<table class="noborder" width="100%">'; print '<table class="noborder" width="100%">';
print '<tr class="liste_titre"><td colspan="3">'.$langs->trans("SearchAProposal").'</td></tr>'; print '<tr class="liste_titre"><td colspan="3">'.$langs->trans("SearchAProposal").'</td></tr>';
print '<tr '.$bc[$var].'><td nowrap>'; print '<tr '.$bc[$var].'>';
print $langs->trans("Ref").':</td><td><input type="text" class="flat" name="sf_ref" size="18"></td><td><input type="submit" value="'.$langs->trans("Search").'" class="button"></td></tr>'; print '<td nowrap>'.$langs->trans("Ref").':</td><td><input type="text" class="flat" name="sf_ref" size="18"></td>';
print "</table></form><br>\n"; print '<td rowspan="2"><input type="submit" value="'.$langs->trans("Search").'" class="button"></td></tr>';
print '<tr '.$bc[$var].'><td nowrap>'.$langs->trans("Other").':</td><td><input type="text" class="flat" name="sall" size="18"></td>';
print '</tr>';
print "</table></form>\n";
print "<br>";
} }
/* /*

View File

@ -46,6 +46,7 @@ require_once('../propal.class.php');
require_once('../actioncomm.class.php'); require_once('../actioncomm.class.php');
require_once(DOL_DOCUMENT_ROOT.'/lib/CMailFile.class.php'); require_once(DOL_DOCUMENT_ROOT.'/lib/CMailFile.class.php');
$sall=isset($_GET["sall"])?$_GET["sall"]:$_POST["sall"];
if (isset($_GET["msg"])) { $msg=urldecode($_GET["msg"]); } if (isset($_GET["msg"])) { $msg=urldecode($_GET["msg"]); }
$year=isset($_GET["year"])?$_GET["year"]:""; $year=isset($_GET["year"])?$_GET["year"]:"";
$month=isset($_GET["month"])?$_GET["month"]:""; $month=isset($_GET["month"])?$_GET["month"]:"";
@ -64,6 +65,7 @@ $NBLINES=4;
$form=new Form($db); $form=new Form($db);
/******************************************************************************/ /******************************************************************************/
/* Actions */ /* Actions */
/******************************************************************************/ /******************************************************************************/
@ -139,103 +141,103 @@ if ($_POST['action'] == 'setstatut' && $user->rights->propale->cloturer)
*/ */
if ($_POST['action'] == 'send') if ($_POST['action'] == 'send')
{ {
$langs->load('mails'); $langs->load('mails');
$propal= new Propal($db); $propal= new Propal($db);
if ( $propal->fetch($_POST['propalid']) ) if ( $propal->fetch($_POST['propalid']) )
{ {
$propalref = sanitize_string($propal->ref); $propalref = sanitize_string($propal->ref);
$file = $conf->propal->dir_output . '/' . $propalref . '/' . $propalref . '.pdf'; $file = $conf->propal->dir_output . '/' . $propalref . '/' . $propalref . '.pdf';
if (is_readable($file)) if (is_readable($file))
{ {
$soc = new Societe($db, $propal->socidp); $soc = new Societe($db, $propal->socidp);
if ($_POST['sendto']) if ($_POST['sendto'])
{ {
// Le destinataire a été fourni via le champ libre // Le destinataire a été fourni via le champ libre
$sendto = $_POST['sendto']; $sendto = $_POST['sendto'];
$sendtoid = 0; $sendtoid = 0;
} }
elseif ($_POST['receiver']) elseif ($_POST['receiver'])
{ {
// Le destinataire a été fourni via la liste déroulante // Le destinataire a été fourni via la liste déroulante
$sendto = $soc->contact_get_email($_POST['receiver']); $sendto = $soc->contact_get_email($_POST['receiver']);
$sendtoid = $_POST['receiver']; $sendtoid = $_POST['receiver'];
} }
if (strlen($sendto)) if (strlen($sendto))
{ {
$from = $_POST['fromname'] . ' <' . $_POST['frommail'] .'>'; $from = $_POST['fromname'] . ' <' . $_POST['frommail'] .'>';
$replyto = $_POST['replytoname']. ' <' . $_POST['replytomail'].'>'; $replyto = $_POST['replytoname']. ' <' . $_POST['replytomail'].'>';
$message = $_POST['message']; $message = $_POST['message'];
if ($_POST['action'] == 'send') if ($_POST['action'] == 'send')
{ {
$subject = $langs->trans('Propal').' '.$propal->ref; $subject = $langs->trans('Propal').' '.$propal->ref;
$actiontypeid=3; $actiontypeid=3;
$actionmsg ='Mail envoyé par '.$from.' à '.$sendto.'.<br>'; $actionmsg ='Mail envoyé par '.$from.' à '.$sendto.'.<br>';
if ($message) if ($message)
{ {
$actionmsg.='Texte utilisé dans le corps du message:<br>'; $actionmsg.='Texte utilisé dans le corps du message:<br>';
$actionmsg.=$message; $actionmsg.=$message;
} }
$actionmsg2='Envoi Propal par mail'; $actionmsg2='Envoi Propal par mail';
}
$filepath[0] = $file;
$filename[0] = $propal->ref.'.pdf';
$mimetype[0] = 'application/pdf';
if ($_FILES['addedfile']['tmp_name'])
{
$filepath[1] = $_FILES['addedfile']['tmp_name'];
$filename[1] = $_FILES['addedfile']['name'];
$mimetype[1] = $_FILES['addedfile']['type'];
} }
// Envoi de la facture
$mailfile = new CMailFile($subject,$sendto,$from,$message,$filepath,$mimetype,$filename,$sendtocc); $filepath[0] = $file;
if ($mailfile->sendfile()) $filename[0] = $propal->ref.'.pdf';
{ $mimetype[0] = 'application/pdf';
$msg='<div class="ok">'.$langs->trans('MailSuccessfulySent',$from,$sendto).'.</div>'; if ($_FILES['addedfile']['tmp_name'])
// Insertion action {
include_once('../contact.class.php'); $filepath[1] = $_FILES['addedfile']['tmp_name'];
$actioncomm = new ActionComm($db); $filename[1] = $_FILES['addedfile']['name'];
$actioncomm->type_id = $actiontypeid; $mimetype[1] = $_FILES['addedfile']['type'];
$actioncomm->label = $actionmsg2; }
$actioncomm->note = $actionmsg; // Envoi de la facture
$actioncomm->date = time(); // L'action est faite maintenant $mailfile = new CMailFile($subject,$sendto,$from,$message,$filepath,$mimetype,$filename,$sendtocc);
$actioncomm->percent = 100; if ($mailfile->sendfile())
$actioncomm->contact = new Contact($db,$sendtoid); {
$actioncomm->societe = new Societe($db,$propal->socidp); $msg='<div class="ok">'.$langs->trans('MailSuccessfulySent',$from,$sendto).'.</div>';
$actioncomm->user = $user; // User qui a fait l'action // Insertion action
$actioncomm->propalrowid = $propal->id; include_once('../contact.class.php');
$ret=$actioncomm->add($user); // User qui saisi l'action $actioncomm = new ActionComm($db);
if ($ret < 0) $actioncomm->type_id = $actiontypeid;
{ $actioncomm->label = $actionmsg2;
dolibarr_print_error($db); $actioncomm->note = $actionmsg;
} $actioncomm->date = time(); // L'action est faite maintenant
else $actioncomm->percent = 100;
{ $actioncomm->contact = new Contact($db,$sendtoid);
// Renvoie sur la fiche $actioncomm->societe = new Societe($db,$propal->socidp);
Header('Location: propal.php?propalid='.$propal->id.'&msg='.urlencode($msg)); $actioncomm->user = $user; // User qui a fait l'action
exit; $actioncomm->propalrowid = $propal->id;
} $ret=$actioncomm->add($user); // User qui saisi l'action
} if ($ret < 0)
else {
{ dolibarr_print_error($db);
$msg='<div class="error">'.$langs->trans('ErrorFailedToSendMail',$from,$sendto).' - '.$actioncomm->error.'</div>'; }
} else
} {
else // Renvoie sur la fiche
{ Header('Location: propal.php?propalid='.$propal->id.'&msg='.urlencode($msg));
$msg='<div class="error">'.$langs->trans('ErrorMailRecipientIsEmpty').' !</div>'; exit;
dolibarr_syslog('Le mail du destinataire est vide'); }
} }
} else
else {
{ $msg='<div class="error">'.$langs->trans('ErrorFailedToSendMail',$from,$sendto).' - '.$actioncomm->error.'</div>';
dolibarr_syslog('Impossible de lire :'.$file); }
} }
else
{
$msg='<div class="error">'.$langs->trans('ErrorMailRecipientIsEmpty').' !</div>';
dolibarr_syslog('Le mail du destinataire est vide');
}
}
else
{
dolibarr_syslog('Impossible de lire :'.$file);
}
} }
else else
{ {
dolibarr_syslog('Impossible de lire les données de la propale. Le fichier propal n\'a peut-être pas été généré.'); dolibarr_syslog('Impossible de lire les données de la propale. Le fichier propal n\'a peut-être pas été généré.');
} }
} }
@ -1044,6 +1046,7 @@ else
$sql = 'SELECT s.nom, s.idp, s.client, p.rowid as propalid, p.price, p.ref, p.fk_statut, '.$db->pdate('p.datep').' as dp,'.$db->pdate('p.fin_validite').' as dfv'; $sql = 'SELECT s.nom, s.idp, s.client, p.rowid as propalid, p.price, p.ref, p.fk_statut, '.$db->pdate('p.datep').' as dp,'.$db->pdate('p.fin_validite').' as dfv';
$sql.= ' FROM '.MAIN_DB_PREFIX.'societe as s, '.MAIN_DB_PREFIX.'propal as p'; $sql.= ' FROM '.MAIN_DB_PREFIX.'societe as s, '.MAIN_DB_PREFIX.'propal as p';
if ($sall) $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'propaldet as pd ON p.rowid=pd.fk_propal';
$sql.= ' WHERE p.fk_soc = s.idp'; $sql.= ' WHERE p.fk_soc = s.idp';
if (!empty($_GET['search_ref'])) if (!empty($_GET['search_ref']))
@ -1058,6 +1061,7 @@ else
{ {
$sql .= " AND p.price='".$_GET['search_montant_ht']."'"; $sql .= " AND p.price='".$_GET['search_montant_ht']."'";
} }
if ($sall) $sql.= " AND (s.nom like '%".$sall."%' OR p.note like '%".$sall."%' OR pd.description like '%".$sall."%')";
if ($_GET['socidp']) if ($_GET['socidp'])
{ {
$sql .= ' AND s.idp = '.$_GET['socidp']; $sql .= ' AND s.idp = '.$_GET['socidp'];