New: Rend le mode de rglement et conditions de rglement par defaut de la socit facultatif

This commit is contained in:
Laurent Destailleur 2006-02-25 13:06:35 +00:00
parent 2bb7e4818c
commit b900fbe9be
3 changed files with 78 additions and 67 deletions

View File

@ -45,11 +45,16 @@ $langs->load("bills");
$langs->load("contracts"); $langs->load("contracts");
if ($conf->fichinter->enabled) $langs->load("interventions"); if ($conf->fichinter->enabled) $langs->load("interventions");
llxHeader('',$langs->trans('CustomerCard')); // Protection quand utilisateur externe
$socid = isset($_GET["socid"])?$_GET["socid"]:'';
if ($user->societe_id > 0)
{
$socid = $user->societe_id;
}
$sortorder=$_GET["sortorder"]; $sortorder=$_GET["sortorder"];
$sortfield=$_GET["sortfield"]; $sortfield=$_GET["sortfield"];
if (! $sortorder) $sortorder="ASC"; if (! $sortorder) $sortorder="ASC";
if (! $sortfield) $sortfield="nom"; if (! $sortfield) $sortfield="nom";
@ -65,16 +70,20 @@ if ($_POST["action"] == 'setconditions')
$societe = new Societe($db, $_GET["socid"]); $societe = new Societe($db, $_GET["socid"]);
$societe->cond_reglement=$_POST['cond_reglement_id']; $societe->cond_reglement=$_POST['cond_reglement_id'];
$sql = "UPDATE ".MAIN_DB_PREFIX."societe SET cond_reglement='".$_POST['cond_reglement_id']."' WHERE idp='".$socid."'"; $sql = "UPDATE ".MAIN_DB_PREFIX."societe SET cond_reglement='".$_POST['cond_reglement_id'];
$sql.= "' WHERE idp='".$_GET["socid"]."'";
$result = $db->query($sql); $result = $db->query($sql);
if (! $result) dolibarr_print_error($result);
} }
// mode de règlement // mode de règlement
if ($_POST["action"] == 'setmode') if ($_POST["action"] == 'setmode')
{ {
$societe = new Societe($db, $_GET["socid"]); $societe = new Societe($db, $_GET["socid"]);
$societe->mode_reglement=$_POST['mode_reglement_id']; $societe->mode_reglement=$_POST['mode_reglement_id'];
$sql = "UPDATE ".MAIN_DB_PREFIX."societe SET mode_reglement='".$_POST['mode_reglement_id']."' WHERE idp='".$socid."'"; $sql = "UPDATE ".MAIN_DB_PREFIX."societe SET mode_reglement='".$_POST['mode_reglement_id'];
$sql.= "' WHERE idp='".$_GET["socid"]."'";
$result = $db->query($sql); $result = $db->query($sql);
if (! $result) dolibarr_print_error($result);
} }
// assujétissement à la TVA // assujétissement à la TVA
if ($_POST["action"] == 'setassujtva') if ($_POST["action"] == 'setassujtva')
@ -83,6 +92,7 @@ if ($_POST["action"] == 'setassujtva')
$societe->tva_assuj=$_POST['assujtva_value']; $societe->tva_assuj=$_POST['assujtva_value'];
$sql = "UPDATE ".MAIN_DB_PREFIX."societe SET tva_assuj='".$_POST['assujtva_value']."' WHERE idp='".$socid."'"; $sql = "UPDATE ".MAIN_DB_PREFIX."societe SET tva_assuj='".$_POST['assujtva_value']."' WHERE idp='".$socid."'";
$result = $db->query($sql); $result = $db->query($sql);
if (! $result) dolibarr_print_error($result);
} }
if ($action == 'recontact') if ($action == 'recontact')
@ -90,6 +100,7 @@ if ($action == 'recontact')
$dr = mktime(0, 0, 0, $remonth, $reday, $reyear); $dr = mktime(0, 0, 0, $remonth, $reday, $reyear);
$sql = "INSERT INTO ".MAIN_DB_PREFIX."soc_recontact (fk_soc, datere, author) VALUES ($socid, $dr,'". $user->login ."')"; $sql = "INSERT INTO ".MAIN_DB_PREFIX."soc_recontact (fk_soc, datere, author) VALUES ($socid, $dr,'". $user->login ."')";
$result = $db->query($sql); $result = $db->query($sql);
if (! $result) dolibarr_print_error($result);
} }
if ($action == 'stcomm') if ($action == 'stcomm')
@ -102,7 +113,7 @@ if ($action == 'stcomm')
if ($result) if ($result)
{ {
$sql = "UPDATE ".MAIN_DB_PREFIX."societe SET fk_stcomm=$stcommid WHERE idp=$socid"; $sql = "UPDATE ".MAIN_DB_PREFIX."societe SET fk_stcomm=$stcommid WHERE idp=".$socid;
$result = $db->query($sql); $result = $db->query($sql);
} }
else else
@ -142,12 +153,9 @@ if ($mode == 'search') {
} }
} }
// Protection quand utilisateur externe
$_socid = isset($_GET["socid"])?$_GET["socid"]:'';
if ($user->societe_id > 0) llxHeader('',$langs->trans('CustomerCard'));
{
$_socid = $user->societe_id;
}
/********************************************************************************* /*********************************************************************************
@ -155,12 +163,12 @@ if ($user->societe_id > 0)
* Mode fiche * Mode fiche
* *
*********************************************************************************/ *********************************************************************************/
if ($_socid > 0) if ($socid > 0)
{ {
// On recupere les donnees societes par l'objet // On recupere les donnees societes par l'objet
$objsoc = new Societe($db); $objsoc = new Societe($db);
$objsoc->id=$_socid; $objsoc->id=$socid;
$objsoc->fetch($_socid,$to); $objsoc->fetch($socid,$to);
$dac = strftime("%Y-%m-%d %H:%M", time()); $dac = strftime("%Y-%m-%d %H:%M", time());
if ($errmesg) if ($errmesg)
@ -301,7 +309,7 @@ if ($_socid > 0)
print '<tr><td>'.$langs->trans("Type").'</td><td>'.$objsoc->typent.'</td><td>'.$langs->trans("Staff").'</td><td nowrap>'.$objsoc->effectif.'</td></tr>'; print '<tr><td>'.$langs->trans("Type").'</td><td>'.$objsoc->typent.'</td><td>'.$langs->trans("Staff").'</td><td nowrap>'.$objsoc->effectif.'</td></tr>';
} }
// soumis à TVA ou pas // Assujeti à TVA ou pas
print '<tr>'; print '<tr>';
/* print '<table width="100%" class="nobordernopadding"><tr><td nowrap>'; /* print '<table width="100%" class="nobordernopadding"><tr><td nowrap>';
print $langs->trans('VATIsUsed'); print $langs->trans('VATIsUsed');
@ -324,6 +332,46 @@ if ($_socid > 0)
print '</td>'; print '</td>';
print '</tr>'; print '</tr>';
// Conditions de réglement par défaut
$langs->load('bills');
$html = new Form($db);
print '<tr><td nowrap>';
print '<table width="100%" class="nobordernopadding"><tr><td nowrap>';
print $langs->trans('PaymentConditions');
print '<td>';
if ($_GET['action'] != 'editconditions') print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editconditions&amp;socid='.$objsoc->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'].'?socid='.$objsoc->id,$objsoc->cond_reglement,'cond_reglement_id',-1,1);
}
else
{
$html->form_conditions_reglement($_SERVER['PHP_SELF'].'?socid='.$objsoc->id,$objsoc->cond_reglement,'none');
}
print "</td>";
print '</tr>';
// Mode de règlement
print '<tr><td nowrap>';
print '<table width="100%" class="nobordernopadding"><tr><td nowrap>';
print $langs->trans('PaymentMode');
print '<td>';
if ($_GET['action'] != 'editmode') print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editmode&amp;socid='.$objsoc->id.'">'.img_edit($langs->trans('SetMode'),1).'</a></td>';
print '</tr></table>';
print '</td><td colspan="3">';
if ($_GET['action'] == 'editmode')
{
$html->form_modes_reglement($_SERVER['PHP_SELF'].'?socid='.$objsoc->id,$objsoc->mode_reglement,'mode_reglement_id');
}
else
{
$html->form_modes_reglement($_SERVER['PHP_SELF'].'?socid='.$objsoc->id,$objsoc->mode_reglement,'none');
}
print "</td>";
print '</tr>';
// Remise permanente // Remise permanente
print '<tr><td nowrap>'; print '<tr><td nowrap>';
print '<table width="100%" class="nobordernopadding"><tr><td nowrap>'; print '<table width="100%" class="nobordernopadding"><tr><td nowrap>';
@ -370,49 +418,6 @@ if ($_socid > 0)
print '</td><td colspan="3">'.$objsoc->price_level."</td>"; print '</td><td colspan="3">'.$objsoc->price_level."</td>";
print '</tr>'; print '</tr>';
} }
if($conf->facture->enabled)
{
// conditions de règlement
$langs->load('bills');
$html = new Form($db);
print '<tr><td nowrap>';
print '<table width="100%" class="nobordernopadding"><tr><td nowrap>';
print $langs->trans('PaymentConditions');
print '<td>';
if ($_GET['action'] != 'editconditions') print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editconditions&amp;socid='.$objsoc->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'].'?socid='.$objsoc->id,$objsoc->cond_reglement,'cond_reglement_id');
}
else
{
$html->form_conditions_reglement($_SERVER['PHP_SELF'].'?socid='.$objsoc->id,$objsoc->cond_reglement,'none');
}
print "</td>";
print '</tr>';
// mode de règlement
print '<tr><td nowrap>';
print '<table width="100%" class="nobordernopadding"><tr><td nowrap>';
print $langs->trans('PaymentMode');
print '<td>';
if ($_GET['action'] != 'editmode') print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editmode&amp;socid='.$objsoc->id.'">'.img_edit($langs->trans('SetMode'),1).'</a></td>';
print '</tr></table>';
print '</td><td colspan="3">';
if ($_GET['action'] == 'editmode')
{
$html->form_modes_reglement($_SERVER['PHP_SELF'].'?socid='.$objsoc->id,$objsoc->mode_reglement,'mode_reglement_id');
}
else
{
$html->form_modes_reglement($_SERVER['PHP_SELF'].'?socid='.$objsoc->id,$objsoc->mode_reglement,'none');
}
print "</td>";
print '</tr>';
}
print "</table>"; print "</table>";

View File

@ -777,14 +777,16 @@ class Form
* \param selected Id du type de paiement présélectionné * \param selected Id du type de paiement présélectionné
* \param htmlname Nom de la zone select * \param htmlname Nom de la zone select
* \param filtertype Pour filtre * \param filtertype Pour filtre
* \param addempty Ajoute entrée vide
*/ */
function select_conditions_paiements($selected='',$htmlname='condid',$filtertype=-1) function select_conditions_paiements($selected='',$htmlname='condid',$filtertype=-1,$addempty=0)
{ {
global $langs; global $langs;
$this->load_cache_conditions_paiements(); $this->load_cache_conditions_paiements();
print '<select class="flat" name="'.$htmlname.'">'; print '<select class="flat" name="'.$htmlname.'">';
if ($addempty) print '<option value="0">&nbsp;</option>';
foreach($this->cache_conditions_paiements_code as $id => $code) foreach($this->cache_conditions_paiements_code as $id => $code)
{ {
if ($selected == $id) if ($selected == $id)
@ -800,7 +802,8 @@ class Form
} }
print '</select>'; print '</select>';
} }
/**
/**
* \brief Retourne la liste des types de paiements possibles * \brief Retourne la liste des types de paiements possibles
* \param selected Id du type de paiement présélectionné * \param selected Id du type de paiement présélectionné
* \param htmlname Nom de la zone select * \param htmlname Nom de la zone select
@ -1297,12 +1300,13 @@ class Form
} }
/** /**
* \brief Affiche formulaire de selection de conditions de paiement * \brief Affiche formulaire de selection de conditions de paiement
* \param page Page * \param page Page
* \param selected Id condition présélectionnée * \param selected Id condition présélectionnée
* \param htmlname Nom du formulaire select * \param htmlname Nom du formulaire select
* \param addempty Ajoute entrée vide
*/ */
function form_conditions_reglement($page, $selected='', $htmlname='cond_reglement_id') function form_conditions_reglement($page, $selected='', $htmlname='cond_reglement_id', $addempty=0)
{ {
global $langs; global $langs;
if ($htmlname != "none") if ($htmlname != "none")
@ -1311,7 +1315,7 @@ class Form
print '<input type="hidden" name="action" value="setconditions">'; print '<input type="hidden" name="action" value="setconditions">';
print '<table class="noborder" cellpadding="0" cellspacing="0">'; print '<table class="noborder" cellpadding="0" cellspacing="0">';
print '<tr><td>'; print '<tr><td>';
$this->select_conditions_paiements($selected,$htmlname); $this->select_conditions_paiements($selected,$htmlname,-1,$addempty);
print '</td>'; print '</td>';
print '<td align="left"><input type="submit" class="button" value="'.$langs->trans("Modify").'"></td>'; print '<td align="left"><input type="submit" class="button" value="'.$langs->trans("Modify").'"></td>';
print '</tr></table></form>'; print '</tr></table></form>';
@ -1327,6 +1331,7 @@ class Form
} }
} }
} }
/** /**
* \brief Affiche formulaire de selection de l'assujétissement à la TVA * \brief Affiche formulaire de selection de l'assujétissement à la TVA
* \param page Page * \param page Page

View File

@ -60,3 +60,4 @@ alter table llx_actioncomm modify datea datetime;
alter table llx_actioncomm add column datec datetime after id; alter table llx_actioncomm add column datec datetime after id;
alter table llx_actioncomm add column datep datetime after datec; alter table llx_actioncomm add column datep datetime after datec;
alter table llx_actioncomm add column tms timestamp after datea; alter table llx_actioncomm add column tms timestamp after datea;