New: Possibilité de modifier la date de fin de validité

Look: Uniformisation propales-factures
This commit is contained in:
Laurent Destailleur 2005-11-04 20:45:02 +00:00
parent 1e68ae0d50
commit f6c15147c9
3 changed files with 188 additions and 86 deletions

View File

@ -80,6 +80,7 @@ if ($_POST['action'] == 'confirm_delete' && $_POST['confirm'] == 'yes')
$brouillon = 1; $brouillon = 1;
} }
Header('Location: propal.php'); Header('Location: propal.php');
exit;
} }
if ($_POST['action'] == 'confirm_validate' && $_POST['confirm'] == 'yes') if ($_POST['action'] == 'confirm_validate' && $_POST['confirm'] == 'yes')
@ -88,17 +89,26 @@ if ($_POST['action'] == 'confirm_validate' && $_POST['confirm'] == 'yes')
{ {
$propal = new Propal($db); $propal = new Propal($db);
$propal->fetch($_GET['propalid']); $propal->fetch($_GET['propalid']);
$propal->update_price($_GET['propalid']); $result=$propal->update_price($_GET['propalid']);
propale_pdf_create($db, $_GET['propalid'], $propal->modelpdf); propale_pdf_create($db, $_GET['propalid'], $propal->modelpdf);
$propal->valid($user); $result=$propal->valid($user);
} }
Header ('Location: propal.php?propalid='.$_GET['propalid']); Header ('Location: propal.php?propalid='.$_GET['propalid']);
exit;
}
if ($_POST['action'] == 'setecheance')
{
$propal = new Propal($db);
$propal->fetch($_GET['propalid']);
$result=$propal->set_echeance($user,mktime(12, 1, 1, $_POST['echmonth'], $_POST['echday'], $_POST['echyear']));
if ($result < 0) dolibarr_print_error($db,$propal->error);
} }
if ($_POST['action'] == 'add') if ($_POST['action'] == 'add')
{ {
$propal = new Propal($db, $_GET['socidp']); $propal = new Propal($db, $_GET['socidp']);
$propal->datep = mktime(12, 1 , 1, $_POST['remonth'], $_POST['reday'], $_POST['reyear']); $propal->datep = mktime(12, 1, 1, $_POST['remonth'], $_POST['reday'], $_POST['reyear']);
$propal->duree_validite = $_POST['duree_validite']; $propal->duree_validite = $_POST['duree_validite'];
@ -138,24 +148,23 @@ if ($_POST['action'] == 'add')
if ($_GET['action'] == 'pdf') if ($_GET['action'] == 'pdf')
{ {
$propal = new Propal($db); $propal = new Propal($db);
$propal->fetch($_GET['propalid']); $propal->fetch($_GET['propalid']);
propale_pdf_create($db, $_GET['propalid'], $propal->modelpdf); propale_pdf_create($db, $_GET['propalid'], $propal->modelpdf);
} }
/*
* Cloture de la propale
*/
if ($_POST['action'] == 'setstatut' && $user->rights->propale->cloturer) if ($_POST['action'] == 'setstatut' && $user->rights->propale->cloturer)
{ {
/* $propal = new Propal($db);
* Cloture de la propale $propal->fetch($_GET['propalid']);
*/ $propal->cloture($user, $_POST['statut'], $_POST['note']);
$propal = new Propal($db);
$propal->fetch($_GET['propalid']);
$propal->cloture($user, $_POST['statut'], $_POST['note']);
} }
/* /*
* Envoi de la propale par mail * Envoi de la propale par mail
*
*/ */
if ($_POST['action'] == 'send') if ($_POST['action'] == 'send')
{ {
@ -362,6 +371,7 @@ if ($_POST['action'] == 'set_contact')
llxHeader(); llxHeader();
$html = new Form($db);
/* /*
* Affichage fiche propal en mode visu * Affichage fiche propal en mode visu
@ -370,7 +380,6 @@ llxHeader();
if ($_GET['propalid'] > 0) if ($_GET['propalid'] > 0)
{ {
if ($msg) print "$msg<br>"; if ($msg) print "$msg<br>";
$html = new Form($db);
$propal = new Propal($db); $propal = new Propal($db);
$propal->fetch($_GET['propalid']); $propal->fetch($_GET['propalid']);
@ -450,7 +459,9 @@ if ($_GET['propalid'] > 0)
print '<table class="border" width="100%">'; print '<table class="border" width="100%">';
$rowspan=6; $rowspan=6;
print '<tr><td>'.$langs->trans('Company').'</td><td colspan="3">';
// Société
print '<tr><td>'.$langs->trans('Company').'</td><td colspan="5">';
if ($societe->client == 1) if ($societe->client == 1)
{ {
$url ='fiche.php?socid='.$societe->id; $url ='fiche.php?socid='.$societe->id;
@ -460,27 +471,77 @@ if ($_GET['propalid'] > 0)
$url = DOL_URL_ROOT.'/comm/prospect/fiche.php?socid='.$societe->id; $url = DOL_URL_ROOT.'/comm/prospect/fiche.php?socid='.$societe->id;
} }
print '<a href="'.$url.'">'.$societe->nom.'</a></td>'; print '<a href="'.$url.'">'.$societe->nom.'</a></td>';
print '<td align="left">Conditions de réglement</td>';
print '<td>'.'&nbsp;'.'</td>';
print '</tr>'; print '</tr>';
// Dates
print '<tr><td>'.$langs->trans('Date').'</td><td colspan="3">'; print '<tr><td>'.$langs->trans('Date').'</td><td colspan="3">';
print dolibarr_print_date($propal->date,'%a %d %B %Y'); print dolibarr_print_date($propal->date,'%a %d %B %Y');
print '</td>'; print '</td>';
print '<td>'.$langs->trans('DateEndPropal').'</td><td>'; print '<td>';
if ($propal->fin_validite) print '<table class="nobordernopadding" width="100%"><tr><td>';
print $langs->trans('DateEndPropal');
print '</td>';
if ($_GET['action'] != 'editecheance' && $propal->brouillon) print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editecheance&amp;propalid='.$propal->id.'">'.img_edit($langs->trans('SetConditions'),1).'</a></td>';
print '</tr></table>';
print '<td>';
if ($propal->brouillon && $_GET['action'] == 'editecheance')
{ {
print dolibarr_print_date($propal->fin_validite,'%a %d %B %Y'); print '<form action="'.$_SERVER["PHP_SELF"].'?propalid='.$propal->id.'" method="post">';
if ($propal->statut == 1 && $propal->fin_validite < (time() - $conf->propal->cloture->warning_delay)) print img_warning($langs->trans("Late")); print '<input type="hidden" name="action" value="setecheance">';
$html->select_date($propal->fin_validite,'ech');
print '<input type="submit" class="button" value="'.$langs->trans('Modify').'">';
print '</form>';
} }
else else
{ {
print $langs->trans("Unknown"); if ($propal->fin_validite)
{
print dolibarr_print_date($propal->fin_validite,'%a %d %B %Y');
if ($propal->statut == 1 && $propal->fin_validite < (time() - $conf->propal->cloture->warning_delay)) print img_warning($langs->trans("Late"));
}
else
{
print $langs->trans("Unknown");
}
} }
print '</td>'; print '</td>';
print '</tr>'; print '</tr>';
// Conditions et modes de réglement
print '<tr><td>';
print '<table class="nobordernopadding" width="100%"><tr><td>';
print $langs->trans('PaymentConditions');
print '</td>';
// if ($_GET['action'] != 'editconditions' && $propal->brouillon) print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editconditions&amp;facid='.$propal->id.'">'.img_edit($langs->trans('SetConditions'),1).'</a></td>';
print '</tr></table>';
print '</td><td colspan="3">';
if ($_GET['action'] == 'editconditions')
{
$html->form_conditions_reglement($_SERVER['PHP_SELF'].'?propalid='.$propal->id,$propal->cond_reglement_id,'cond_reglement_id');
}
else
{
$html->form_conditions_reglement($_SERVER['PHP_SELF'].'?propalid='.$propal->id,$propal->cond_reglement_id,'none');
}
print '</td>';
print '<td width="25%">';
print '<table class="nobordernopadding" width="100%"><tr><td>';
print $langs->trans('PaymentMode');
print '</td>';
// if ($_GET['action'] != 'editmode' && $propal->brouillon) print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editmode&amp;facid='.$propal->id.'">'.img_edit($langs->trans('SetMode'),1).'</a></td>';
print '</tr></table>';
print '</td><td width="25%">';
if ($_GET['action'] == 'editmode')
{
$html->form_modes_reglement($_SERVER['PHP_SELF'].'?propalid='.$propal->id,$propal->mode_reglement_id,'mode_reglement_id');
}
else
{
$html->form_modes_reglement($_SERVER['PHP_SELF'].'?propalid='.$propal->id,$propal->mode_reglement_id,'none');
}
print '</td></tr>';
// Destinataire // Destinataire
$langs->load('mails'); $langs->load('mails');
print '<tr>'; print '<tr>';
@ -502,7 +563,7 @@ if ($_GET['propalid'] > 0)
print '<td colspan="2">'; print '<td colspan="2">';
print '<form action="propal.php?propalid='.$propal->id.'" method="post">'; print '<form action="propal.php?propalid='.$propal->id.'" method="post">';
print '<input type="hidden" name="action" value="set_contact">'; print '<input type="hidden" name="action" value="set_contact">';
$form->select_contacts($societe->id, $propal->contactid, 'contactidp'); $html->select_contacts($societe->id, $propal->contactid, 'contactidp');
print '</td><td>'; print '</td><td>';
print '<input type="submit" class="button" value="'.$langs->trans('Modify').'">'; print '<input type="submit" class="button" value="'.$langs->trans('Modify').'">';
print '</form>'; print '</form>';
@ -513,7 +574,7 @@ if ($_GET['propalid'] > 0)
if (!empty($propal->contactid)) if (!empty($propal->contactid))
{ {
print '<td colspan="3">'; print '<td colspan="3">';
include_once(DOL_DOCUMENT_ROOT."/contact.class.php"); require_once(DOL_DOCUMENT_ROOT.'/contact.class.php');
$contact=new Contact($db); $contact=new Contact($db);
$contact->fetch($propal->contactid); $contact->fetch($propal->contactid);
print '<a href="'.DOL_URL_ROOT.'/contact/fiche.php?id='.$propal->contactid.'" title="'.$langs->trans('ShowContact').'">'; print '<a href="'.DOL_URL_ROOT.'/contact/fiche.php?id='.$propal->contactid.'" title="'.$langs->trans('ShowContact').'">';
@ -952,7 +1013,7 @@ if ($_GET['propalid'] > 0)
$var=true; $var=true;
$form->show_documents('propal',$filename,$filedir,$urlsource,$genallowed,$delallowed,$propal->modelpdf); $html->show_documents('propal',$filename,$filedir,$urlsource,$genallowed,$delallowed,$propal->modelpdf);
/* /*
@ -1168,56 +1229,56 @@ else
$var=true; $var=true;
while ($i < min($num,$limit)) while ($i < min($num,$limit))
{ {
$objp = $db->fetch_object($result); $objp = $db->fetch_object($result);
$now = time(); $now = time();
$var=!$var; $var=!$var;
print '<tr '.$bc[$var].'>'; print '<tr '.$bc[$var].'>';
print '<td><a href="propal.php?propalid='.$objp->propalid.'">'.img_object($langs->trans('ShowPropal'),'propal').' '.$objp->ref."</a></td>\n"; print '<td><a href="propal.php?propalid='.$objp->propalid.'">'.img_object($langs->trans('ShowPropal'),'propal').' '.$objp->ref."</a></td>\n";
if ($objp->client == 1) if ($objp->client == 1)
{ {
$url = DOL_URL_ROOT.'/comm/fiche.php?socid='.$objp->idp; $url = DOL_URL_ROOT.'/comm/fiche.php?socid='.$objp->idp;
} }
else else
{ {
$url = DOL_URL_ROOT.'/comm/prospect/fiche.php?socid='.$objp->idp; $url = DOL_URL_ROOT.'/comm/prospect/fiche.php?socid='.$objp->idp;
} }
print '<td><a href="'.$url.'">'.img_object($langs->trans('ShowCompany'),'company').' '.$objp->nom.'</a></td>'; print '<td><a href="'.$url.'">'.img_object($langs->trans('ShowCompany'),'company').' '.$objp->nom.'</a></td>';
// Date propale // Date propale
print '<td align="center">'; print '<td align="center">';
$y = strftime('%Y',$objp->dp); $y = strftime('%Y',$objp->dp);
$m = strftime('%m',$objp->dp); $m = strftime('%m',$objp->dp);
print strftime('%d',$objp->dp)."\n"; print strftime('%d',$objp->dp)."\n";
print ' <a href="propal.php?year='.$y.'&amp;month='.$m.'">'; print ' <a href="propal.php?year='.$y.'&amp;month='.$m.'">';
print dolibarr_print_date($objp->dp,'%b')."</a>\n"; print dolibarr_print_date($objp->dp,'%b')."</a>\n";
print ' <a href="propal.php?year='.$y.'">'; print ' <a href="propal.php?year='.$y.'">';
print strftime('%Y',$objp->dp)."</a></td>\n"; print strftime('%Y',$objp->dp)."</a></td>\n";
// Date fin validite // Date fin validite
if ( $now > $objp->dfv && $objp->dfv > 0 ) if ($objp->dfv)
{ {
print '<td align="center">'.dolibarr_print_date($objp->dfv); print '<td align="center">'.dolibarr_print_date($objp->dfv);
if ($objp->fk_statut == 1 && $objp->dfv < (time() - $conf->propal->cloture->warning_delay)) print img_warning($langs->trans("Late")); if ($objp->fk_statut == 1 && $objp->dfv < (time() - $conf->propal->cloture->warning_delay)) print img_warning($langs->trans("Late"));
print '</td>'; print '</td>';
} }
else else
{ {
print '<td>&nbsp;</td>'; print '<td>&nbsp;</td>';
} }
print '<td align="right">'.price($objp->price)."</td>\n"; print '<td align="right">'.price($objp->price)."</td>\n";
$propal=New Propal($db); $propal=New Propal($db);
print '<td align="center">'.$propal->LibStatut($objp->fk_statut,0)."</td>\n"; print '<td align="center">'.$propal->LibStatut($objp->fk_statut,0)."</td>\n";
print "</tr>\n"; print "</tr>\n";
$total = $total + $objp->price; $total = $total + $objp->price;
$subtotal = $subtotal + $objp->price; $subtotal = $subtotal + $objp->price;
$i++; $i++;
} }
print '</table>'; print '</table>';
$db->free($result); $db->free($result);
} }

View File

@ -1154,7 +1154,7 @@ else
if ($_GET['action'] == 'valid') if ($_GET['action'] == 'valid')
{ {
$numfa = facture_get_num($soc); $numfa = facture_get_num($soc);
$html->form_confirm('facture.php?facid='.$fac->id,$langs->trans('ValidateBill'),$langs->trans('ConfirmValidateBill',$numfa),'confirm_valid'); $html->form_confirm($_SERVER["PHP_SELF"].'?facid='.$fac->id,$langs->trans('ValidateBill'),$langs->trans('ConfirmValidateBill',$numfa),'confirm_valid');
print '<br />'; print '<br />';
} }
@ -1163,7 +1163,7 @@ else
*/ */
if ($_GET['action'] == 'payed') if ($_GET['action'] == 'payed')
{ {
$html->form_confirm('facture.php?facid='.$fac->id,$langs->trans('ClassifyPayed'),$langs->trans('ConfirmClassifyPayedBill',$fac->ref),'confirm_payed'); $html->form_confirm($_SERVER["PHP_SELF"].'?facid='.$fac->id,$langs->trans('ClassifyPayed'),$langs->trans('ConfirmClassifyPayedBill',$fac->ref),'confirm_payed');
print '<br />'; print '<br />';
} }
@ -1180,10 +1180,14 @@ else
* Facture * Facture
*/ */
print '<table class="border" width="100%">'; print '<table class="border" width="100%">';
// Société
print '<tr><td>'.$langs->trans('Company').'</td>'; print '<tr><td>'.$langs->trans('Company').'</td>';
print '<td colspan="5">'; print '<td colspan="5">';
print '<a href="fiche.php?socid='.$soc->id.'">'.$soc->nom.'</a></td>'; print '<a href="fiche.php?socid='.$soc->id.'">'.$soc->nom.'</a></td>';
print '</tr>';
// Dates
print '<tr><td>'.$langs->trans('Date').'</td>'; print '<tr><td>'.$langs->trans('Date').'</td>';
print '<td colspan="3">'.dolibarr_print_date($fac->date,'%A %d %B %Y').'</td>'; print '<td colspan="3">'.dolibarr_print_date($fac->date,'%A %d %B %Y').'</td>';
print '<td>'.$langs->trans('DateClosing').'</td><td>' . dolibarr_print_date($fac->date_lim_reglement,'%A %d %B %Y'); print '<td>'.$langs->trans('DateClosing').'</td><td>' . dolibarr_print_date($fac->date_lim_reglement,'%A %d %B %Y');
@ -1195,7 +1199,7 @@ else
print '<table class="nobordernopadding" width="100%"><tr><td>'; print '<table class="nobordernopadding" width="100%"><tr><td>';
print $langs->trans('PaymentConditions'); print $langs->trans('PaymentConditions');
print '</td>'; print '</td>';
if ($_GET['action'] != 'editconditions' && $fac->brouillon) print '<td align="right"><a href="facture.php?action=editconditions&amp;facid='.$fac->id.'">'.img_edit($langs->trans('SetConditions'),1).'</a></td>'; if ($_GET['action'] != 'editconditions' && $fac->brouillon) print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editconditions&amp;facid='.$fac->id.'">'.img_edit($langs->trans('SetConditions'),1).'</a></td>';
print '</tr></table>'; print '</tr></table>';
print '</td><td colspan="3">'; print '</td><td colspan="3">';
if ($_GET['action'] == 'editconditions') if ($_GET['action'] == 'editconditions')
@ -1211,7 +1215,7 @@ else
print '<table class="nobordernopadding" width="100%"><tr><td>'; print '<table class="nobordernopadding" width="100%"><tr><td>';
print $langs->trans('PaymentMode'); print $langs->trans('PaymentMode');
print '</td>'; print '</td>';
if ($_GET['action'] != 'editmode' && $fac->brouillon) print '<td align="right"><a href="facture.php?action=editmode&amp;facid='.$fac->id.'">'.img_edit($langs->trans('SetMode'),1).'</a></td>'; if ($_GET['action'] != 'editmode' && $fac->brouillon) print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editmode&amp;facid='.$fac->id.'">'.img_edit($langs->trans('SetMode'),1).'</a></td>';
print '</tr></table>'; print '</tr></table>';
print '</td><td width="25%">'; print '</td><td width="25%">';
if ($_GET['action'] == 'editmode') if ($_GET['action'] == 'editmode')

View File

@ -87,15 +87,17 @@ if ( $action == 'delete' )
llxHeader(); llxHeader();
$form = new Form($db); $html = new Form($db);
/* /*
* *
* Mode fiche * Mode fiche
* *
*/ */
if ($_GET["propalid"]) if ($_GET["propalid"] > 0)
{ {
if ($msg) print "$msg<br>";
$propal = new Propal($db); $propal = new Propal($db);
$propal->fetch($_GET["propalid"]); $propal->fetch($_GET["propalid"]);
$h=0; $h=0;
@ -153,7 +155,9 @@ if ($_GET["propalid"])
print '<table class="border" width="100%">'; print '<table class="border" width="100%">';
$rowspan=6; $rowspan=6;
print '<tr><td>'.$langs->trans('Company').'</td><td colspan="3">';
// Société
print '<tr><td>'.$langs->trans('Company').'</td><td colspan="5">';
if ($societe->client == 1) if ($societe->client == 1)
{ {
$url ='fiche.php?socid='.$societe->id; $url ='fiche.php?socid='.$societe->id;
@ -163,10 +167,9 @@ if ($_GET["propalid"])
$url = DOL_URL_ROOT.'/comm/prospect/fiche.php?socid='.$societe->id; $url = DOL_URL_ROOT.'/comm/prospect/fiche.php?socid='.$societe->id;
} }
print '<a href="'.$url.'">'.$societe->nom.'</a></td>'; print '<a href="'.$url.'">'.$societe->nom.'</a></td>';
print '<td align="left">Conditions de réglement</td>';
print '<td>'.'&nbsp;'.'</td>';
print '</tr>'; print '</tr>';
// Dates
print '<tr><td>'.$langs->trans('Date').'</td><td colspan="3">'; print '<tr><td>'.$langs->trans('Date').'</td><td colspan="3">';
print dolibarr_print_date($propal->date,'%a %d %B %Y'); print dolibarr_print_date($propal->date,'%a %d %B %Y');
print '</td>'; print '</td>';
@ -184,6 +187,40 @@ if ($_GET["propalid"])
print '</td>'; print '</td>';
print '</tr>'; print '</tr>';
// Conditions et modes de réglement
print '<tr><td>';
print '<table class="nobordernopadding" width="100%"><tr><td>';
print $langs->trans('PaymentConditions');
print '</td>';
if ($_GET['action'] != 'editconditions' && $prop->brouillon) print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editconditions&amp;facid='.$prop->id.'">'.img_edit($langs->trans('SetConditions'),1).'</a></td>';
print '</tr></table>';
print '</td><td colspan="3">';
if ($_GET['action'] == 'editconditions')
{
$html->form_conditions_reglement($_SERVER['PHP_SELF'].'?facid='.$prop->id,$prop->cond_reglement_id,'cond_reglement_id');
}
else
{
$html->form_conditions_reglement($_SERVER['PHP_SELF'].'?facid='.$prop->id,$prop->cond_reglement_id,'none');
}
print '</td>';
print '<td width="25%">';
print '<table class="nobordernopadding" width="100%"><tr><td>';
print $langs->trans('PaymentMode');
print '</td>';
if ($_GET['action'] != 'editmode' && $prop->brouillon) print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editmode&amp;facid='.$prop->id.'">'.img_edit($langs->trans('SetMode'),1).'</a></td>';
print '</tr></table>';
print '</td><td width="25%">';
if ($_GET['action'] == 'editmode')
{
$html->form_modes_reglement($_SERVER['PHP_SELF'].'?facid='.$prop->id,$prop->mode_reglement_id,'mode_reglement_id');
}
else
{
$html->form_modes_reglement($_SERVER['PHP_SELF'].'?facid='.$prop->id,$prop->mode_reglement_id,'none');
}
print '</td></tr>';
// Destinataire // Destinataire
$langs->load('mails'); $langs->load('mails');
print '<tr>'; print '<tr>';
@ -205,7 +242,7 @@ if ($_GET["propalid"])
print '<td colspan="2">'; print '<td colspan="2">';
print '<form action="propal.php?propalid='.$propal->id.'" method="post">'; print '<form action="propal.php?propalid='.$propal->id.'" method="post">';
print '<input type="hidden" name="action" value="set_contact">'; print '<input type="hidden" name="action" value="set_contact">';
$form->select_contacts($societe->id, $propal->contactid, 'contactidp'); $html->select_contacts($societe->id, $propal->contactid, 'contactidp');
print '</td><td>'; print '</td><td>';
print '<input type="submit" class="button" value="'.$langs->trans('Modify').'">'; print '<input type="submit" class="button" value="'.$langs->trans('Modify').'">';
print '</form>'; print '</form>';
@ -469,7 +506,7 @@ if ($_GET["propalid"])
$var=true; $var=true;
$form->show_documents('propal',$filename,$filedir,$urlsource,$genallowed,$delallowed); $html->show_documents('propal',$filename,$filedir,$urlsource,$genallowed,$delallowed);
/* /*