New: [ task #314 ] Can define if prof id are mandatory or not

This commit is contained in:
simnandez 2012-11-30 21:23:12 +01:00 committed by Laurent Destailleur
parent 4f2f56fced
commit c365dbc679
7 changed files with 85 additions and 41 deletions

View File

@ -62,10 +62,12 @@ For users:
- New: Can choose menu entry to show with external site module.
- New: Add hidden option MAIN_PDF_MARGIN_LEFT, MAIN_PDF_MARGIN_RIGHT, MAIN_PDF_MARGIN_TOP, MAIN_PDF_MARGIN_BOTTOM
to force margins of generated PDF.
- New: [ task #314 ] Can define if prof id are mandatory or not
New experimental modules:
- New: Add margin management module.
- New: Add commissions management module.
- Fix: [ bug #499 ]: Supplier order input method not translated
- Fix: No images into product description lines as PDF generation does
not work with this.

View File

@ -21,6 +21,7 @@ ErrorThisContactIsAlreadyDefinedAsThisType=Aquest contacte ja està definit com
ErrorCashAccountAcceptsOnlyCashMoney=Aquesta compte bancari és de tipus caixa i només accepta el mètode de pagament de tipus <b>espècie</b>.
ErrorFromToAccountsMustDiffers=El compte origen i destinació han de ser diferents.
ErrorBadThirdPartyName=Nom de tercer incorrecte
ErrorProdIdIsMandatory=El %s es obligatori
ErrorBadCustomerCodeSyntax=La sintaxi del codi client és incorrecta
ErrorCustomerCodeRequired=Codi client obligatori
ErrorCustomerCodeAlreadyUsed=Codi de client ja utilitzat

View File

@ -25,6 +25,7 @@ ErrorThisContactIsAlreadyDefinedAsThisType=This contact is already defined as co
ErrorCashAccountAcceptsOnlyCashMoney=This bank account is a cash account, so it accepts payments of type cash only.
ErrorFromToAccountsMustDiffers=Source and targets bank accounts must be different.
ErrorBadThirdPartyName=Bad value for third party name
ErrorProdIdIsMandatory=The %s is mandatory
ErrorBadCustomerCodeSyntax=Bad syntax for customer code
ErrorCustomerCodeRequired=Customer code required
ErrorCustomerCodeAlreadyUsed=Customer code already used

View File

@ -21,6 +21,7 @@ ErrorThisContactIsAlreadyDefinedAsThisType=Este contacto ya está definido como
ErrorCashAccountAcceptsOnlyCashMoney=Esta cuenta bancaria es de tipo caja y solo acepta el método de pago de tipo <b>especie</b>.
ErrorFromToAccountsMustDiffers=La cuenta origen y destino deben ser diferentes.
ErrorBadThirdPartyName=Nombre de tercero incorrecto
ErrorProdIdIsMandatory=El %s es obligatorio
ErrorBadCustomerCodeSyntax=La sintaxis del código cliente es incorrecta
ErrorCustomerCodeRequired=Código cliente obligatorio
ErrorCustomerCodeAlreadyUsed=Código de cliente ya utilizado

View File

@ -26,6 +26,7 @@ ErrorThisContactIsAlreadyDefinedAsThisType=Ce contact est déjà défini comme c
ErrorCashAccountAcceptsOnlyCashMoney=Ce compte bancaire est de type caisse et n'accepte que les mode de règlement de type <b>espèce</b>.
ErrorFromToAccountsMustDiffers=Le compte source et destination doivent être différents.
ErrorBadThirdPartyName=Nom de tiers incorrect
ErrorProdIdIsMandatory=Le %s est obligatoire
ErrorBadCustomerCodeSyntax=La syntaxe du code client est incorrecte
ErrorCustomerCodeRequired=Code client obligatoire
ErrorCustomerCodeAlreadyUsed=Code client déjà utilisé

View File

@ -550,6 +550,10 @@ $profid[2][0]=$langs->trans("ProfId3");
$profid[2][1]=$langs->transcountry('ProfId3', $mysoc->country_code);
$profid[3][0]=$langs->trans("ProfId4");
$profid[3][1]=$langs->transcountry('ProfId4', $mysoc->country_code);
$profid[4][0]=$langs->trans("ProfId5");
$profid[4][1]=$langs->transcountry('ProfId5', $mysoc->country_code);
$profid[5][0]=$langs->trans("ProfId6");
$profid[5][1]=$langs->transcountry('ProfId6', $mysoc->country_code);
$var = true;
$i=0;
@ -557,44 +561,47 @@ $i=0;
$nbofloop=count($profid);
while ($i < $nbofloop)
{
$var = !$var;
print '<tr '.$bc[$var].'>';
print '<td>'.$profid[$i][0]."</td><td>\n";
print $profid[$i][1];
print '</td>';
$idprof_unique ='SOCIETE_IDPROF'.($i+1).'_UNIQUE';
$idprof_mandatory ='SOCIETE_IDPROF'.($i+1).'_MANDATORY';
$verif=(empty($conf->global->$idprof_unique)?false:true);
$mandatory=(empty($conf->global->$idprof_mandatory)?false:true);
if ($verif)
if ($profid[$i][1]!='-')
{
print '<td align="center"><a href="'.$_SERVER['PHP_SELF'].'?action=setprofid&value='.($i+1).'&status=0">';
print img_picto($langs->trans("Activated"),'switch_on');
print '</a></td>';
}
else
{
print '<td align="center"><a href="'.$_SERVER['PHP_SELF'].'?action=setprofid&value='.($i+1).'&status=1">';
print img_picto($langs->trans("Disabled"),'switch_off');
print '</a></td>';
}
$var = !$var;
if ($mandatory)
{
print '<td align="center"><a href="'.$_SERVER['PHP_SELF'].'?action=setprofidmandatory&value='.($i+1).'&status=0">';
print img_picto($langs->trans("Activated"),'switch_on');
print '</a></td>';
}
else
{
print '<td align="center"><a href="'.$_SERVER['PHP_SELF'].'?action=setprofidmandatory&value='.($i+1).'&status=1">';
print img_picto($langs->trans("Disabled"),'switch_off');
print '</a></td>';
print '<tr '.$bc[$var].'>';
print '<td>'.$profid[$i][0]."</td><td>\n";
print $profid[$i][1];
print '</td>';
$idprof_unique ='SOCIETE_IDPROF'.($i+1).'_UNIQUE';
$idprof_mandatory ='SOCIETE_IDPROF'.($i+1).'_MANDATORY';
$verif=(empty($conf->global->$idprof_unique)?false:true);
$mandatory=(empty($conf->global->$idprof_mandatory)?false:true);
if ($verif)
{
print '<td align="center"><a href="'.$_SERVER['PHP_SELF'].'?action=setprofid&value='.($i+1).'&status=0">';
print img_picto($langs->trans("Activated"),'switch_on');
print '</a></td>';
}
else
{
print '<td align="center"><a href="'.$_SERVER['PHP_SELF'].'?action=setprofid&value='.($i+1).'&status=1">';
print img_picto($langs->trans("Disabled"),'switch_off');
print '</a></td>';
}
if ($mandatory)
{
print '<td align="center"><a href="'.$_SERVER['PHP_SELF'].'?action=setprofidmandatory&value='.($i+1).'&status=0">';
print img_picto($langs->trans("Activated"),'switch_on');
print '</a></td>';
}
else
{
print '<td align="center"><a href="'.$_SERVER['PHP_SELF'].'?action=setprofidmandatory&value='.($i+1).'&status=1">';
print img_picto($langs->trans("Disabled"),'switch_off');
print '</a></td>';
}
print "</tr>\n";
}
print "</tr>\n";
$i++;
}

View File

@ -5,7 +5,7 @@
* Copyright (C) 2005 Eric Seigne <eric.seigne@ryxeo.com>
* Copyright (C) 2005-2012 Regis Houssin <regis@dolibarr.fr>
* Copyright (C) 2008 Patrick Raguin <patrick.raguin@auguria.net>
* Copyright (C) 2010-2011 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2010-2012 Juanjo Menent <jmenent@2byte.es>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -202,9 +202,18 @@ if (empty($reshook))
$error++; $errors[] = $langs->trans("ErrorSupplierModuleNotEnabled");
$action = ($action=='add'?'create':'edit');
}
// We set country_id, country_code and country for the selected country
$object->country_id=GETPOST('country_id')?GETPOST('country_id'):$mysoc->country_id;
if ($object->country_id)
{
$tmparray=getCountry($object->country_id,'all');
$object->country_code=$tmparray['code'];
$object->country=$tmparray['label'];
}
// Check for duplicate prof id
for ($i = 1; $i < 3; $i++)
// Check for duplicate or mandatory prof id
for ($i = 1; $i < 5; $i++)
{
$slabel="idprof".$i;
$_POST[$slabel]=trim($_POST[$slabel]);
@ -218,8 +227,18 @@ if (empty($reshook))
$action = ($action=='add'?'create':'edit');
}
}
$idprof_mandatory ='SOCIETE_IDPROF'.($i).'_MANDATORY';
if (! $vallabel && ! empty($conf->global->$idprof_mandatory))
{
$langs->load("errors");
$error++;
$errors[] = $langs->trans("ErrorProdIdIsMandatory", $langs->transcountry('ProfId'.$i, $object->country_code));
$action = ($action=='add'?'create':'edit');
}
}
}
if (! $error)
{
if ($action == 'add')
@ -293,7 +312,7 @@ if (empty($reshook))
// Gestion du logo de la société
}
else
{
{
$error=$object->error; $errors=$object->errors;
}
@ -834,7 +853,13 @@ else
if ($idprof!='-')
{
if (($j % 2) == 0) print '<tr>';
print '<td>'.$idprof.'</td><td>';
$idprof_mandatory ='SOCIETE_IDPROF'.($i).'_MANDATORY';
if(empty($conf->global->$idprof_mandatory))
print '<td>'.$idprof.'</td><td>';
else
print '<td><span class="fieldrequired">'.$idprof.'</td><td>';
$key='idprof'.$i;
print $formcompany->get_input_id_prof($i,'idprof'.$i,$object->$key,$object->country_code);
print '</td>';
@ -1271,7 +1296,13 @@ else
if ($idprof!='-')
{
if (($j % 2) == 0) print '<tr>';
print '<td>'.$idprof.'</td><td>';
$idprof_mandatory ='SOCIETE_IDPROF'.($i).'_MANDATORY';
if(empty($conf->global->$idprof_mandatory))
print '<td>'.$idprof.'</td><td>';
else
print '<td><span class="fieldrequired">'.$idprof.'</td><td>';
$key='idprof'.$i;
print $formcompany->get_input_id_prof($i,'idprof'.$i,$object->$key,$object->country_code);
print '</td>';