mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2025-02-20 13:46:52 +01:00
[ task #731 ] Uniformize ref generation
This commit is contained in:
parent
fc46a02573
commit
a811121daf
|
|
@ -283,8 +283,25 @@ class Contrat extends CommonObject
|
|||
global $langs, $conf;
|
||||
|
||||
$error=0;
|
||||
|
||||
// Definition du nom de module de numerotation de commande
|
||||
$soc = new Societe($this->db);
|
||||
$soc->fetch($this->socid);
|
||||
|
||||
// Class of company linked to order
|
||||
$result=$soc->set_as_client();
|
||||
|
||||
// Define new ref
|
||||
if (! $error && (preg_match('/^[\(]?PROV/i', $this->ref)))
|
||||
{
|
||||
$num = $this->getNextNumRef($soc);
|
||||
}
|
||||
else
|
||||
{
|
||||
$num = $this->ref;
|
||||
}
|
||||
|
||||
$sql = "UPDATE ".MAIN_DB_PREFIX."contrat SET statut = 1";
|
||||
$sql = "UPDATE ".MAIN_DB_PREFIX."contrat SET ref = '".$num."', statut = 1";
|
||||
$sql .= " WHERE rowid = ".$this->id . " AND statut = 0";
|
||||
|
||||
$resql = $this->db->query($sql);
|
||||
|
|
@ -647,6 +664,16 @@ class Contrat extends CommonObject
|
|||
$error=0;
|
||||
|
||||
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."contrat");
|
||||
|
||||
// Mise a jour ref
|
||||
$sql = 'UPDATE '.MAIN_DB_PREFIX."contrat SET ref='(PROV".$this->id.")' WHERE rowid=".$this->id;
|
||||
if ($this->db->query($sql))
|
||||
{
|
||||
if ($this->id)
|
||||
{
|
||||
$this->ref="(PROV".$this->id.")";
|
||||
}
|
||||
}
|
||||
|
||||
// Insert contacts commerciaux ('SALESREPSIGN','contrat')
|
||||
$result=$this->add_contact($this->commercial_signature_id,'SALESREPSIGN','internal');
|
||||
|
|
|
|||
|
|
@ -158,27 +158,35 @@ if (GETPOST('remonth') && GETPOST('reday') && GETPOST('reyear'))
|
|||
|
||||
if ($action == 'add' && $user->rights->contrat->creer)
|
||||
{
|
||||
$object->socid = $socid;
|
||||
$object->date_contrat = $datecontrat;
|
||||
|
||||
// Check
|
||||
if (empty($datecontrat))
|
||||
{
|
||||
$error++;
|
||||
$mesg='<div class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Date")).'</div>';
|
||||
$action='create';
|
||||
}
|
||||
|
||||
if ($socid<1)
|
||||
{
|
||||
setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Customer")),'errors');
|
||||
$action='create';
|
||||
$error++;
|
||||
}
|
||||
|
||||
if (! $error)
|
||||
{
|
||||
$object->socid = $socid;
|
||||
$object->date_contrat = $datecontrat;
|
||||
|
||||
$object->commercial_suivi_id = GETPOST('commercial_suivi_id','int');
|
||||
$object->commercial_signature_id = GETPOST('commercial_signature_id','int');
|
||||
$object->commercial_suivi_id = GETPOST('commercial_suivi_id','int');
|
||||
$object->commercial_signature_id = GETPOST('commercial_signature_id','int');
|
||||
|
||||
$object->note = GETPOST('note','alpha');
|
||||
$object->fk_project = GETPOST('projectid','int');
|
||||
$object->remise_percent = GETPOST('remise_percent','alpha');
|
||||
$object->ref = GETPOST('ref','alpha');
|
||||
$object->note = GETPOST('note','alpha');
|
||||
$object->fk_project = GETPOST('projectid','int');
|
||||
$object->remise_percent = GETPOST('remise_percent','alpha');
|
||||
$object->ref = GETPOST('ref','alpha');
|
||||
|
||||
// Check
|
||||
if (empty($datecontrat))
|
||||
{
|
||||
$error++;
|
||||
$mesg='<div class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Date")).'</div>';
|
||||
$action='create';
|
||||
}
|
||||
|
||||
if (! $error)
|
||||
{
|
||||
$result = $object->create($user,$langs,$conf);
|
||||
if ($result > 0)
|
||||
{
|
||||
|
|
@ -612,7 +620,7 @@ if ($action == 'create')
|
|||
dol_htmloutput_errors($mesg,'');
|
||||
|
||||
$soc = new Societe($db);
|
||||
$soc->fetch($socid);
|
||||
if ($socid>0) $soc->fetch($socid);
|
||||
|
||||
$object->date_contrat = dol_now();
|
||||
|
||||
|
|
@ -628,22 +636,39 @@ if ($action == 'create')
|
|||
print '<table class="border" width="100%">';
|
||||
|
||||
// Ref
|
||||
print '<tr><td>'.$langs->trans("Ref").'</td>';
|
||||
print '<td><input type="text" maxlength="30" name="ref" size="20" value="'.$numct.'"></td></tr>';
|
||||
print '<tr><td class="fieldrequired">'.$langs->trans('Ref').'</td><td colspan="2">'.$langs->trans("Draft").'</td></tr>';
|
||||
|
||||
// Customer
|
||||
print '<tr><td>'.$langs->trans("Customer").'</td><td>'.$soc->getNomUrl(1).'</td></tr>';
|
||||
print '<tr>';
|
||||
print '<td class="fieldrequired">'.$langs->trans('Customer').'</td>';
|
||||
if($socid>0)
|
||||
{
|
||||
print '<td colspan="2">';
|
||||
print $soc->getNomUrl(1);
|
||||
print '<input type="hidden" name="socid" value="'.$soc->id.'">';
|
||||
print '</td>';
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<td colspan="2">';
|
||||
print $form->select_company('','socid','s.client = 1',1);
|
||||
print '</td>';
|
||||
}
|
||||
print '</tr>'."\n";
|
||||
|
||||
// Ligne info remises tiers
|
||||
print '<tr><td>'.$langs->trans('Discount').'</td><td>';
|
||||
if ($soc->remise_client) print $langs->trans("CompanyHasRelativeDiscount",$soc->remise_client);
|
||||
else print $langs->trans("CompanyHasNoRelativeDiscount");
|
||||
$absolute_discount=$soc->getAvailableDiscounts();
|
||||
print '. ';
|
||||
if ($absolute_discount) print $langs->trans("CompanyHasAbsoluteDiscount",price($absolute_discount),$langs->trans("Currency".$conf->currency));
|
||||
else print $langs->trans("CompanyHasNoAbsoluteDiscount");
|
||||
print '.';
|
||||
print '</td></tr>';
|
||||
if($socid>0)
|
||||
{
|
||||
// Ligne info remises tiers
|
||||
print '<tr><td>'.$langs->trans('Discounts').'</td><td colspan="2">';
|
||||
if ($soc->remise_client) print $langs->trans("CompanyHasRelativeDiscount",$soc->remise_client);
|
||||
else print $langs->trans("CompanyHasNoRelativeDiscount");
|
||||
print '. ';
|
||||
$absolute_discount=$soc->getAvailableDiscounts();
|
||||
if ($absolute_discount) print $langs->trans("CompanyHasAbsoluteDiscount",price($absolute_discount),$langs->trans("Currency".$conf->currency));
|
||||
else print $langs->trans("CompanyHasNoAbsoluteDiscount");
|
||||
print '.';
|
||||
print '</td></tr>';
|
||||
}
|
||||
|
||||
// Commercial suivi
|
||||
print '<tr><td width="20%" nowrap><span class="fieldrequired">'.$langs->trans("TypeContact_contrat_internal_SALESREPFOLL").'</span></td><td>';
|
||||
|
|
@ -760,8 +785,19 @@ else
|
|||
*/
|
||||
if ($action == 'valid')
|
||||
{
|
||||
//$numfa = contrat_get_num($soc);
|
||||
$ret=$form->form_confirm($_SERVER['PHP_SELF']."?id=".$object->id,$langs->trans("ValidateAContract"),$langs->trans("ConfirmValidateContract"),"confirm_valid",'',0,1);
|
||||
$ref = substr($object->ref, 1, 4);
|
||||
if ($ref == 'PROV')
|
||||
{
|
||||
$numref = $object->getNextNumRef($soc);
|
||||
}
|
||||
else
|
||||
{
|
||||
$numref = $object->ref;
|
||||
}
|
||||
|
||||
$text=$langs->trans('ConfirmValidateContract',$numref);
|
||||
|
||||
$ret=$form->form_confirm($_SERVER['PHP_SELF']."?id=".$object->id,$langs->trans("ValidateAContract"),$text,"confirm_valid",'',0,1);
|
||||
if ($ret == 'html') print '<br>';
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -653,7 +653,7 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after,&$tabMenu
|
|||
{
|
||||
$langs->load("contracts");
|
||||
$newmenu->add("/contrat/index.php?leftmenu=contracts", $langs->trans("Contracts"), 0, $user->rights->contrat->lire, '', $mainmenu, 'contracts');
|
||||
$newmenu->add("/societe/societe.php?leftmenu=contracts", $langs->trans("NewContract"), 1, $user->rights->contrat->creer);
|
||||
$newmenu->add("/contrat/fiche.php?&action=create&leftmenu=contracts", $langs->trans("NewContract"), 1, $user->rights->contrat->creer);
|
||||
$newmenu->add("/contrat/liste.php?leftmenu=contracts", $langs->trans("List"), 1, $user->rights->contrat->lire);
|
||||
$newmenu->add("/contrat/services.php?leftmenu=contracts", $langs->trans("MenuServices"), 1, $user->rights->contrat->lire);
|
||||
if ($leftmenu=="contracts") $newmenu->add("/contrat/services.php?leftmenu=contracts&mode=0", $langs->trans("MenuInactiveServices"), 2, $user->rights->contrat->lire);
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ SearchAContract=Cercar un contracte
|
|||
DeleteAContract=Eliminar un contracte
|
||||
CloseAContract=Tancar un contracte
|
||||
ConfirmDeleteAContract=Esteu segur de voler eliminar aquest contracte?
|
||||
ConfirmValidateContract=Esteu segur de voler validar aquest contracte?
|
||||
ConfirmValidateContract=Esteu segur de voler validar aquest contracte sota la referència <b>%s</b>?
|
||||
ConfirmCloseContract=Esteu segur de voler tancar aquest contracte?
|
||||
ConfirmCloseService=Esteu segur de voler tancar aquest servei?
|
||||
ValidateAContract=Validar un contracte
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ SearchAContract=Search a contract
|
|||
DeleteAContract=Delete a contract
|
||||
CloseAContract=Close a contract
|
||||
ConfirmDeleteAContract=Are you sure you want to delete this contract and all its services ?
|
||||
ConfirmValidateContract=Are you sure you want to validate this contract ?
|
||||
ConfirmValidateContract=Are you sure you want to validate this contract under name <b>%s</b> ?
|
||||
ConfirmCloseContract=This will close all services (active or not). Are you sure you want to close this contract ?
|
||||
ConfirmCloseService=Are you sure you want to close this service with date <b>%s</b> ?
|
||||
ValidateAContract=Validate a contract
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ SearchAContract=Buscar un contrato
|
|||
DeleteAContract=Eliminar un contrato
|
||||
CloseAContract=Cerrar un contrato
|
||||
ConfirmDeleteAContract=¿Está seguro de querer eliminar este contrato?
|
||||
ConfirmValidateContract=¿Está seguro de querer validar este contrato?
|
||||
ConfirmValidateContract=¿Está seguro de querer validar este contrato bajo la referencia <b>%s</b> ?
|
||||
ConfirmCloseContract=¿Está seguro de querer cerrar este contrato?
|
||||
ConfirmCloseService=¿Está seguro de querer cerrar este servicio?
|
||||
ValidateAContract=Validar un contrato
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ SearchAContract=Rechercher un contrat
|
|||
DeleteAContract=Supprimer un contrat
|
||||
CloseAContract=Clôturer un contrat
|
||||
ConfirmDeleteAContract=Êtes-vous sûr de vouloir supprimer ce contrat et tous ses services ?
|
||||
ConfirmValidateContract=Êtes-vous sûr de vouloir valider ce contrat ?
|
||||
ConfirmValidateContract=Êtes-vous sûr de vouloir valider ce contrat sous la référence <b>%s</b> ?
|
||||
ConfirmCloseContract=Ceci fermera tous les services actifs et inactifs. Êtes-vous sûr de vouloir clôturer ce contrat ?
|
||||
ConfirmCloseService=Êtes-vous sûr de vouloir fermer ce service à la date du <b>%s</b> ?
|
||||
ValidateAContract=Valider un contrat
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user