progress task

5410 -> fonction CRM
5306 -> Improve parameter setting
This commit is contained in:
sparkyx 2006-04-28 22:24:11 +00:00
parent cd1f646813
commit f56b101d7e
8 changed files with 490 additions and 139 deletions

View file

@ -22,6 +22,7 @@ include_once ("ac_common.php");
require_once("constant.php");
include_once ("postgres.php");
if ( isset ($_REQUEST['dos'] ) ) {
$_SESSION['g_dossier']=$_REQUEST['dos'];
$g_name=GetDossierName($_SESSION['g_dossier']);
@ -29,17 +30,33 @@ if ( isset ($_REQUEST['dos'] ) ) {
}
include_once ("postgres.php");
/* Admin. Dossier */
$rep=DbConnect($_SESSION['g_dossier']);
require_once ("class_user.php");
$User=new cl_user($rep);
$User->Check();
////////////////////////////////////////////////////////////////////////////////
// update preference
////////////////////////////////////////////////////////////////////////////////
if ( isset ( $_POST['style_user']) ) {
$User->update_global_pref('THEME',$_POST['style_user']);
$_SESSION['g_theme']=$_POST['style_user'];
}
// Met a jour le pagesize
if ( isset ( $_POST['p_size']) ) {
$User->update_global_pref('PAGESIZE',$_POST['p_size']);
$_SESSION['g_pagesize']=$_POST['p_size'];
}
///
html_page_start($_SESSION['g_theme']);
if ( ! isset ( $_SESSION['g_dossier'] ) ) {
echo "You must choose a Dossier ";
exit -2;
}
include_once ("postgres.php");
/* Admin. Dossier */
$rep=DbConnect();
require_once ("class_user.php");
$User=new cl_user($rep);
$User->Check();
include("preference.php");
include_once("user_menu.php");
@ -51,6 +68,9 @@ $p_action=(isset ($_REQUEST['p_action']))?$_REQUEST['p_action']:"";
echo ShowItem(array(
array('?p_action=client','Client'),
array('?p_action=fournisseur','Fournisseur'),
array('?p_action=suivi_courrier','Suivi courrier'),
array('?p_action=mbre','Membre'),
array('?p_action=pref','Préférence'),
array('login.php','Accueil',"Accueil"),
array('logout.php','logout',"Sortie")
),
@ -62,6 +82,13 @@ echo ShowItem(array(
$cn=DbConnect($_SESSION['g_dossier']);
////////////////////////////////////////////////////////////////////////////////
// p_action == pref
////////////////////////////////////////////////////////////////////////////////
if ( $p_action == "pref" )
{
require_once("pref.inc.php");
}
////////////////////////////////////////////////////////////////////////////////
// p_action == client
////////////////////////////////////////////////////////////////////////////////
if ( $p_action == "client" )

View file

@ -24,17 +24,21 @@ include_once ("class_user.php");
include_once ("postgres.php");
include ("user_menu.php");
include_once("class_invoice.php");
// Check user
$rep=DbConnect();
$User=new cl_user($rep);
$User->Check();
$g_dossier=(isset ($_REQUEST['dos']))?$_REQUEST['dos']:-1;
$_SESSION[ "g_dossier"]=$g_dossier;
if ( isset ($_REQUEST['dos']))
{
$_SESSION["g_dossier"]=$_REQUEST['dos'];
}
$g_dossier=(isset ($_SESSION['g_dossier']))?$_SESSION['g_dossier']:-1;
// List of customer select * from fiche_def where frd_id=9;
if ( $g_dossier==-1 ) {
echo "You must choose a Dossier ";
exit -2;
}
// Check user
$rep=DbConnect($g_dossier);
$User=new cl_user($rep);
$User->Check();
// Save Folder's name
$g_name=GetDossierName($g_dossier);
@ -46,6 +50,22 @@ if ( $User->CheckAction($g_dossier,FACT) == 0 ){
NoAccess();
exit -1;
}
////////////////////////////////////////////////////////////////////////////////
// update preference
////////////////////////////////////////////////////////////////////////////////
if ( isset ( $_POST['style_user']) ) {
$User->update_global_pref('THEME',$_POST['style_user']);
$_SESSION['g_theme']=$_POST['style_user'];
$User->theme=$_POST['style_user'];
}
// Met a jour le pagesize
if ( isset ( $_POST['p_size']) ) {
$User->update_global_pref('PAGESIZE',$_POST['p_size']);
$_SESSION['g_pagesize']=$_POST['p_size'];
}
///
html_page_start($User->theme);
$cn=DbConnect($g_dossier);
@ -56,6 +76,7 @@ echo "<H2 class=\"info\"> Facturation ".$_SESSION['g_name']." </H2>";
echo ShowItem(array(
array('?p_action=create_invoice&dos='.$g_dossier,'Nouvelle'),
array('?p_action=view_invoice&dos='.$g_dossier,'Voir'),
array('?p_action=pref','Préférence'),
array('parametre.php?p_action=invoice&dos='.$g_dossier,'Paramètre'),
array('login.php','Accueil',"Accueil"),
array('logout.php','logout',"Sortie")
@ -65,8 +86,16 @@ echo ShowItem(array(
// Action requested
//
////////////////////////////////////////////////////////////////////////////////
if ( isset ($_GET["p_action"] )) {
$action=$_GET["p_action"];
if ( isset ($_REQUEST["p_action"] )) {
$action=$_REQUEST["p_action"];
////////////////////////////////////////////////////////////////////////////////
// p_action == pref
////////////////////////////////////////////////////////////////////////////////
if ( $action == "pref" )
{
require_once("pref.inc.php");
}
////////////////////////////////////////////////////
// See All invoices
if ($action == "create_invoice" ) {

View file

@ -22,6 +22,7 @@
include_once ("ac_common.php");
html_page_start($_SESSION['g_theme']);
include_once ("postgres.php");
require_once("class_widget.php");
if ( isset ($_REQUEST['dos'] ) ) {
$_SESSION['g_dossier']=$_REQUEST['dos'];
@ -57,7 +58,7 @@ if ( $User->CheckAction($cn,PARM) == 0 ) {
}
// First action
$p_action="";
if ( isset($_REQUEST["p_action"]) ) {
$p_action=$_REQUEST["p_action"];
@ -65,13 +66,280 @@ if ( isset($_REQUEST["p_action"]) ) {
echo ShowMenuParam("parametre.php?p_action=".$p_action);
echo '<DIV CLASS="ccontent">';
// Devise
// sub action
$action="";
if ( isset ($_POST['action']) ) {
$action=$_POST['action'];
}
echo_debug("parametre",__LINE__,$_POST);
////////////////////////////////////////////////////////////////////////////////
// TVA RATE
////////////////////////////////////////////////////////////////////////////////
if ( $p_action == "tva" )
{
// Confirm remove
if ( isset ($_POST['confirm_rm']))
{
ExecSql($cn,'select tva_delete('.$_POST['tva_id'].')');
}
// confirm add
if ( isset ($_POST['confirm_add']))
{
extract($_POST);
$tva_id=FormatString($tva_id);
$tva_label=FormatString($tva_label);
$tva_rate=FormatString($tva_rate);
$tva_comment=FormatString($tva_comment);
$tva_poste=FormatString($tva_poste);
$err=0; // Error code
if ( isNumber($tva_id) == 0 ) {
$err=1;
}
if ( isNumber($tva_rate) == 0 ) {
$err=2;
}
if ( $err == 0 )
{
$Res=ExecSql($cn,
"select tva_insert($tva_id,'$tva_label','$tva_rate','$tva_comment','$tva_poste')");
$ret_sql=pg_fetch_row($Res);
$err=$ret_sql[0];
}
if ( $err != 0 )
{
$err_code=array(1=>"Tva id n\'est pas un nombre",
2=>"Taux tva invalide",
3=>"Label ne peut être vide",
4=>"Poste invalide",
5=>"Tva id doit être unique");
$str_err=$err_code[$err];
echo "<script>alert ('$str_err'); </script>";;
}
}
// confirm mod
if ( isset ($_POST['confirm_mod']))
{
extract($_POST);
$tva_id=FormatString($tva_id);
$tva_label=FormatString($tva_label);
$tva_rate=FormatString($tva_rate);
$tva_comment=FormatString($tva_comment);
$tva_poste=FormatString($tva_poste);
$err=0; // Error code
if ( isNumber($tva_id) == 0 ) {
$err=1;
}
if ( isNumber($tva_rate) == 0 ) {
$err=2;
}
if ( $err == 0 )
{
$Res=ExecSql($cn,
"select tva_modify($tva_id,'$tva_label','$tva_rate','$tva_comment','$tva_poste')");
$ret_sql=pg_fetch_row($Res);
$err=$ret_sql[0];
}
if ( $err != 0 )
{
$err_code=array(1=>"Tva id n\'est pas un nombre",
2=>"Taux tva invalide",
3=>"Label ne peut être vide",
4=>"Poste invalide",
5=>"Tva id doit être unique");
$str_err=$err_code[$err];
echo "<script>alert ('$str_err'); </script>";;
}
}
////////////////////////////////////////////////////////////////////////////////
// Display
$sql="select tva_id,tva_label,tva_rate,tva_comment,tva_poste from tva_rate order by tva_id";
$Res=ExecSql($cn,$sql);
?>
<TABLE>
<TR>
<th>Id</th>
<th>Label</TH>
<th>Taux</th>
<th>Commentaire</th>
<th>Poste</th>
</tr>
<?
$val=pg_fetch_all($Res);
echo_debug('parametre',__LINE__,$val);
foreach ( $val as $row)
{
// load value into an array
$index=$row['tva_id'] ;
$a[$index]=array(
'tva_label'=> $row['tva_label'],
'tva_rate'=>$row['tva_rate'],
'tva_comment'=>$row['tva_comment'],
'tva_poste'=>$row['tva_poste']
);
echo "<TR>";
echo '<FORM METHOD="POST">';
echo "<TD>";
echo $row['tva_id'];
echo "</TD>";
echo "<TD>";
echo $row['tva_label'];
echo "</TD>";
echo "<TD>";
echo $row['tva_rate'];
echo "</TD>";
echo "<TD>";
echo $row['tva_comment'];
echo "</TD>";
echo "<TD>";
echo $row['tva_poste'];
echo "</TD>";
echo "<TD>";
echo '<input type="submit" name="rm" value="Efface">';
echo '<input type="submit" name="mod" value="Modifie">';
$w=new widget("hidden");
$w->name="tva_id";
$w->value=$row['tva_id'];
echo $w->IOValue();
$w=new widget("hidden");
$w->name="p_action";
$w->value="tva";
echo $w->IOValue();
echo "</TD>";
echo '</FORM>';
echo "</TR>";
}
?>
</TABLE>
<? // if we add a vat we don't show this button
if ( ! isset ($_POST['add'])) { ?>
<form method="post">
<input type="submit" name="add" value="Ajouter un taux de tva">
<input type="hidden" name="p_action" value="tva">
</form>
<?
}
////////////////////////////////////////////////////////////////////////////////
// remove
if ( isset ( $_REQUEST['rm']))
{
echo_debug("parametre",__LINE__,"efface ".$_POST['tva_id']);
echo "Voulez-vous vraiment effacer ce taux ? ";
$index=$_POST['tva_id'];
?>
<table>
<TR>
<th>Label</TH>
<th>Taux</th>
<th>Commentaire</th>
<th>Poste</th>
</tr>
<tr>
<td> <? echo $a[$index]['tva_label']; ?></td>
<td> <? echo $a[$index]['tva_rate']; ?></td>
<td> <? echo $a[$index]['tva_comment']; ?></td>
<td> <? echo $a[$index]['tva_poste']; ?></td>
</Tr>
</table>
<?
echo '<FORM method="post">';
echo '<input type="hidden" name="tva_id" value="'.$index.'">';
echo '<input type="submit" name="confirm_rm" value="Confirme">';
echo "</form>";
}
////////////////////////////////////////////////////////////////////////////////
// add
if ( isset ( $_REQUEST['add']))
{
echo_debug("parametre",__LINE__,"add a line ");
echo "Tva à ajouter, l'id doit être différent pour chaque taux";
echo '<FORM method="post">';
?>
<table >
<TR>
<th>id</TH>
<th>Label</TH>
<th>Taux</th>
<th>Commentaire</th>
<th>Poste</th>
</tr>
<tr>
<td> <? $w=new widget("text");$w->size=5; echo $w->IOValue('tva_id','') ?></td>
<td> <? $w=new widget("text");$w->size=20; echo $w->IOValue('tva_label','') ?></td>
<td> <? $w=new widget("text");$w->size=5; echo $w->IOValue('tva_rate','') ?></td>
<td> <? $w=new widget("textarea"); $w->heigh=2;$w->width=20;echo $w->IOValue('tva_comment','') ?></td>
<td> <? $w=new widget("text"); $w->size=10;echo $w->IOValue('tva_poste','') ?></td>
</Tr>
</table>
<input type="submit" value="Confirme" name="confirm_add">
</FORM>
<? }
////////////////////////////////////////////////////////////////////////////////
// mod
if ( isset ( $_REQUEST['mod']))
{
echo_debug("parametre",__LINE__,"modifie ".$_POST['tva_id']);
echo "Tva à modifier";
$index=$_POST['tva_id'];
echo '<FORM method="post">';
echo '<input type="hidden" name="tva_id" value="'.$index.'">';
?>
<table>
<TR>
<th>Label</TH>
<th>Taux</th>
<th>Commentaire</th>
<th>Poste</th>
</tr>
<tr>
<td> <? $w=new widget("text");$w->size=20; echo $w->IOValue('tva_label',$a[$index]['tva_label']) ?></td>
<td> <? $w=new widget("text");$w->size=5; echo $w->IOValue('tva_rate',$a[$index]['tva_rate']) ?></td>
<td> <? $w=new widget("textarea"); $w->heigh=2;$w->width=20;
echo $w->IOValue('tva_comment',$a[$index]['tva_comment']) ?></td>
<td> <? $w=new widget("text");$w->size=5; echo $w->IOValue('tva_poste',$a[$index]['tva_poste']) ?></td>
</Tr>
</table>
<input type="submit" value="Confirme" name="confirm_mod">
</FORM>
<?
}
}
////////////////////////////////////////////////////////////////////////////////
// Account
////////////////////////////////////////////////////////////////////////////////
if ( $p_action == "poste" )
{
// modify
if ( $action == "mod" ) {
}
}
////////////////////////////////////////////////////////////////////////////////
// Currency
////////////////////////////////////////////////////////////////////////////////

View file

@ -250,13 +250,13 @@ a.mtitle {
}
a.mtitle:hover {
font-size:10px;
color:white;
background-color:#5D90CD;
// font-size:10px;
// color:white;
// background-color:#5D90CD;
text-decoration:none;
display:block;
border-style:groove;
border-color:blue;
border-color:gray;
}
a.cell {
text-decoration:none;

View file

@ -51,121 +51,6 @@ if ( isset ($_SESSION['g_dossier']) ) {
if ( $_SESSION['g_dossier'] != 0 )
ShowMenuCompta($_SESSION['g_dossier']);
}
echo '<DIV class="ccontent">';
if ( isset ($_POST['spass']) ) {
if ( $_POST['pass_1'] != $_POST['pass_2'] ) {
?>
<script>
alert("Les mots de passe ne correspondent pas. Mot de passe inchangé");
</script>
<?
}
else {
$l_pass=md5($_POST['pass_1']);
$Res=ExecSql($Rep,"update ac_users set use_pass='$l_pass' where use_login='".$_SESSION['g_user']."'");
$pass=$pass_1;
$_SESSION['g_pass']=$_POST['pass_1'];
$g_pass=$pass_1;
}
}
?>
<H2 CLASS="info"> Password</H2>
<FORM ACTION="user_pref.php" METHOD="POST">
<TABLE ALIGN="CENTER">
<TR><TD><input type="password" name="pass_1"></TD></TR>
<TR><TD><input type="password" name="pass_2"></TD></TR>
<TR><TD><input type="submit" name="spass" value="Change mot de passe"></TD></TR>
</TABLE>
</FORM>
<?
// charge tous les styles
$res=ExecSql($Rep,"select the_name from theme
order by the_name");
for ($i=0;$i < pg_NumRows($res);$i++){
$st=pg_fetch_array($res,$i);
$style[]=$st['the_name'];
}
// Formatte le display
$disp_style="<SELECT NAME=\"style_user\" >";
foreach ($style as $st){
if ( $st == $_SESSION['g_theme'] ) {
$disp_style.='<OPTION VALUE="'.$st.'" SELECTED>'.$st;
} else {
$disp_style.='<OPTION VALUE="'.$st.'">'.$st;
}
}
$disp_style.="</SELECT>";
?>
<H2 class="info">Thème</H2>
<FORM ACTION="user_pref.php" METHOD="post">
<TABLE ALIGN="center">
<TR>
<TD> Style </TD>
<TD> <? print $disp_style;?> </TD>
</TR>
<TR>
<td colspan=2> <INPUT TYPE="submit" Value="Sauve"></TD>
</TR>
</TABLE>
</FORM>
<?
// Si utilise un dossier alors propose de changer
// la periode par defaut
if ( isset ($_SESSION['g_dossier']) ) {
include_once("preference.php");
if ( isset ($_POST["sub_periode"] ) ) {
$periode=$_POST["periode"];
$User->SetPeriode($periode);
// SetUserPeriode($cn,$periode,$_SESSION['g_user']);
}
$l_user_per=$User->GetPeriode();
$l_form_per=FormPeriode($cn,$l_user_per);
?>
<H2 CLASS="info"> Période</H2>
<FORM ACTION="user_pref.php" METHOD="POST">
<TABLE ALIGN="CENTER">
<TR><TD>PERIODE</TD>
<? printf('<TD> %s </TD></TR>',$l_form_per); ?>
<TR><TD><input type="submit" name="sub_periode" value="Sauve"></TD></TR>
</TABLE>
</FORM>
<H2 CLASS="info"> Taille des pages</H2>
<FORM ACTION="user_pref.php" METHOD="POST">
<TABLE ALIGN="CENTER">
<TR><TD>Taille des pages</TD>
<TD>
<SELECT NAME="p_size">
<option value="25">25
<option value="50">50
<option value="100">100
<option value="150">150
<option value="200">200
<option value="-1">Illimité
<?
$label=($_SESSION['g_pagesize'] == -1)?'Illimité':$_SESSION['g_pagesize'];
echo '<option value="'.$_SESSION['g_pagesize'].'" selected>'.$label;
?>
</SELECT>
</TD></TR>
<TR><TD><input type="submit" name="sub_taille" value="Sauve"></TD></TR>
</TABLE>
</FORM>
<?
}
echo "</DIV>";
require_once("pref.inc.php");
html_page_stop();
?>

141
include/pref.inc.php Normal file
View file

@ -0,0 +1,141 @@
<?
/*
* This file is part of PhpCompta.
*
* PhpCompta is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* PhpCompta is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with PhpCompta; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/* $Revision$ */
// Copyright Author Dany De Bontridder ddebontridder@yahoo.fr
echo '<DIV class="ccontent">';
if ( isset ($_POST['spass']) ) {
if ( $_POST['pass_1'] != $_POST['pass_2'] ) {
?>
<script>
alert("Les mots de passe ne correspondent pas. Mot de passe inchangé");
</script>
<?
}
else {
$l_pass=md5($_POST['pass_1']);
$Res=ExecSql($Rep,"update ac_users set use_pass='$l_pass' where use_login='".$_SESSION['g_user']."'");
$pass=$_POST['pass_1'];
$_SESSION['g_pass']=$_POST['pass_1'];
$g_pass=$_POST['pass_1'];
}
}
$url=$_SERVER['REQUEST_URI'];
?>
<H2 CLASS="info"> Password</H2>
<FORM ACTION="<?echo $url;?>" METHOD="POST">
<TABLE ALIGN="CENTER">
<TR><TD><input type="password" name="pass_1"></TD></TR>
<TR><TD><input type="password" name="pass_2"></TD></TR>
<TR><TD><input type="submit" name="spass" value="Change mot de passe"></TD></TR>
</TABLE>
</FORM>
<?
$Rep=DbConnect();
// charge tous les styles
$res=ExecSql($Rep,"select the_name from theme
order by the_name");
for ($i=0;$i < pg_NumRows($res);$i++){
$st=pg_fetch_array($res,$i);
$style[]=$st['the_name'];
}
// Formatte le display
$disp_style="<SELECT NAME=\"style_user\" >";
foreach ($style as $st){
if ( $st == $_SESSION['g_theme'] ) {
$disp_style.='<OPTION VALUE="'.$st.'" SELECTED>'.$st;
} else {
$disp_style.='<OPTION VALUE="'.$st.'">'.$st;
}
}
$disp_style.="</SELECT>";
?>
<H2 class="info">Thème</H2>
<FORM ACTION="<? echo $url; ?>" METHOD="post">
<TABLE ALIGN="center">
<TR>
<TD> Style </TD>
<TD> <? print $disp_style;?> </TD>
</TR>
<TR>
<td colspan=2> <INPUT TYPE="submit" Value="Sauve"></TD>
</TR>
</TABLE>
</FORM>
<?
// Si utilise un dossier alors propose de changer
// la periode par defaut
if ( isset ($_SESSION['g_dossier']) ) {
include_once("preference.php");
if ( isset ($_POST["sub_periode"] ) ) {
$periode=$_POST["periode"];
$User->SetPeriode($periode);
// SetUserPeriode($cn,$periode,$_SESSION['g_user']);
}
$l_user_per=$User->GetPeriode();
$l_form_per=FormPeriode($cn,$l_user_per);
?>
<H2 CLASS="info"> Période</H2>
<FORM ACTION="<? echo $url;?>" METHOD="POST">
<TABLE ALIGN="CENTER">
<TR><TD>PERIODE</TD>
<? printf('<TD> %s </TD></TR>',$l_form_per); ?>
<TR><TD><input type="submit" name="sub_periode" value="Sauve"></TD></TR>
</TABLE>
</FORM>
<H2 CLASS="info"> Taille des pages</H2>
<FORM ACTION="<? echo $url;?>" METHOD="POST">
<TABLE ALIGN="CENTER">
<TR><TD>Taille des pages</TD>
<TD>
<SELECT NAME="p_size">
<option value="25">25
<option value="50">50
<option value="100">100
<option value="150">150
<option value="200">200
<option value="-1">Illimité
<?
$label=($_SESSION['g_pagesize'] == -1)?'Illimité':$_SESSION['g_pagesize'];
echo '<option value="'.$_SESSION['g_pagesize'].'" selected>'.$label;
?>
</SELECT>
</TD></TR>
<TR><TD><input type="submit" name="sub_taille" value="Sauve"></TD></TR>
</TABLE>
</FORM>
<?
}
echo "</DIV>";
?>

View file

@ -174,7 +174,7 @@ function ComputeVat($p_cn, $p_fiche,$p_quant,$p_price,$p_vat )
echo_debug('user_common',__LINE__,"ComputeVat tva id = $tva_id");
if ( $tva_id == null ) return -1;
// for each fiche find the tva_rate and tva_id
// find the tva_rate and tva_id
$a_vat=GetTvaRate($p_cn,$tva_id);
$vat_amount=null;
// Get the attribut price of the card(fiche)
@ -825,7 +825,7 @@ function isValid ($p_cn,$p_grpt_id) {
* Create a navigation_bar (pagesize)
*
* parm :
* - p_current first record number
* - p_offset first record number
* - p_line total of returned row
* - p_size current g_pagesize
* - p_page number of the page

View file

@ -633,6 +633,7 @@ function ShowMenuParam($p_action="")
array('parametre.php?p_action=company','Sociétés'),
array('parametre.php?p_action=devise','Devises'),
array('parametre.php?p_action=periode','Période'),
array('parametre.php?p_action=tva','Tva'),
array('user_sec.php','Sécurité'),
array('parametre.php?p_action=invoice','Facture'),
array('login.php','Accueil',"Accueil"),