diff --git a/htdocs/comm/fiche.php b/htdocs/comm/fiche.php
index 562c48875ed..af3a209c32c 100644
--- a/htdocs/comm/fiche.php
+++ b/htdocs/comm/fiche.php
@@ -45,11 +45,16 @@ $langs->load("bills");
$langs->load("contracts");
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"];
$sortfield=$_GET["sortfield"];
-
if (! $sortorder) $sortorder="ASC";
if (! $sortfield) $sortfield="nom";
@@ -65,16 +70,20 @@ if ($_POST["action"] == 'setconditions')
$societe = new Societe($db, $_GET["socid"]);
$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);
+ if (! $result) dolibarr_print_error($result);
}
// mode de règlement
if ($_POST["action"] == 'setmode')
{
$societe = new Societe($db, $_GET["socid"]);
$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);
+ if (! $result) dolibarr_print_error($result);
}
// assujétissement à la TVA
if ($_POST["action"] == 'setassujtva')
@@ -83,6 +92,7 @@ if ($_POST["action"] == 'setassujtva')
$societe->tva_assuj=$_POST['assujtva_value'];
$sql = "UPDATE ".MAIN_DB_PREFIX."societe SET tva_assuj='".$_POST['assujtva_value']."' WHERE idp='".$socid."'";
$result = $db->query($sql);
+ if (! $result) dolibarr_print_error($result);
}
if ($action == 'recontact')
@@ -90,6 +100,7 @@ if ($action == 'recontact')
$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 ."')";
$result = $db->query($sql);
+ if (! $result) dolibarr_print_error($result);
}
if ($action == 'stcomm')
@@ -102,7 +113,7 @@ if ($action == 'stcomm')
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);
}
else
@@ -142,12 +153,9 @@ if ($mode == 'search') {
}
}
-// Protection quand utilisateur externe
-$_socid = isset($_GET["socid"])?$_GET["socid"]:'';
-if ($user->societe_id > 0)
-{
- $_socid = $user->societe_id;
-}
+
+
+llxHeader('',$langs->trans('CustomerCard'));
/*********************************************************************************
@@ -155,12 +163,12 @@ if ($user->societe_id > 0)
* Mode fiche
*
*********************************************************************************/
-if ($_socid > 0)
+if ($socid > 0)
{
// On recupere les donnees societes par l'objet
$objsoc = new Societe($db);
- $objsoc->id=$_socid;
- $objsoc->fetch($_socid,$to);
+ $objsoc->id=$socid;
+ $objsoc->fetch($socid,$to);
$dac = strftime("%Y-%m-%d %H:%M", time());
if ($errmesg)
@@ -301,7 +309,7 @@ if ($_socid > 0)
print '
'.$langs->trans("Type").' '.$objsoc->typent.' '.$langs->trans("Staff").' '.$objsoc->effectif.' ';
}
- // soumis à TVA ou pas
+ // Assujeti à TVA ou pas
print '';
/* print '';
print $langs->trans('VATIsUsed');
@@ -324,6 +332,46 @@ if ($_socid > 0)
print ' ';
print ' ';
+ // Conditions de réglement par défaut
+ $langs->load('bills');
+ $html = new Form($db);
+ print '';
+ print '';
+ print ' ';
+ 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 " ";
+ print ' ';
+
+ // Mode de règlement
+ print '';
+ print '';
+ print ' ';
+ 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 " ";
+ print ' ';
+
// Remise permanente
print '';
print '';
@@ -370,50 +418,7 @@ if ($_socid > 0)
print ' '.$objsoc->price_level." ";
print ' ';
}
- if($conf->facture->enabled)
- {
- // conditions de règlement
- $langs->load('bills');
- $html = new Form($db);
- print '';
- print '';
- print ' ';
- 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 " ";
- print ' ';
- // mode de règlement
- print '';
- print '';
- print ' ';
- 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 " ";
- print ' ';
- }
-
+
print "
";
print " \n";
diff --git a/htdocs/html.form.class.php b/htdocs/html.form.class.php
index 41e70dec78a..11b70d818ac 100644
--- a/htdocs/html.form.class.php
+++ b/htdocs/html.form.class.php
@@ -777,14 +777,16 @@ class Form
* \param selected Id du type de paiement présélectionné
* \param htmlname Nom de la zone select
* \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;
$this->load_cache_conditions_paiements();
print '';
+ if ($addempty) print ' ';
foreach($this->cache_conditions_paiements_code as $id => $code)
{
if ($selected == $id)
@@ -800,7 +802,8 @@ class Form
}
print ' ';
}
-/**
+
+ /**
* \brief Retourne la liste des types de paiements possibles
* \param selected Id du type de paiement présélectionné
* \param htmlname Nom de la zone select
@@ -1297,12 +1300,13 @@ class Form
}
/**
- * \brief Affiche formulaire de selection de conditions de paiement
- * \param page Page
- * \param selected Id condition présélectionnée
- * \param htmlname Nom du formulaire select
+ * \brief Affiche formulaire de selection de conditions de paiement
+ * \param page Page
+ * \param selected Id condition présélectionnée
+ * \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;
if ($htmlname != "none")
@@ -1311,7 +1315,7 @@ class Form
print ' ';
print '';
@@ -1327,6 +1331,7 @@ class Form
}
}
}
+
/**
* \brief Affiche formulaire de selection de l'assujétissement à la TVA
* \param page Page
diff --git a/mysql/migration/2.0.0-2.1.0.sql b/mysql/migration/2.0.0-2.1.0.sql
index e25eb41e4e8..19aa2d0640e 100644
--- a/mysql/migration/2.0.0-2.1.0.sql
+++ b/mysql/migration/2.0.0-2.1.0.sql
@@ -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 datep datetime after datec;
alter table llx_actioncomm add column tms timestamp after datea;
+