diff --git a/html/ajax_card.php b/html/ajax_card.php index 1250a7fd4..9ba548fbd 100644 --- a/html/ajax_card.php +++ b/html/ajax_card.php @@ -252,7 +252,7 @@ case 'st': { $html.=_("Aucune catégorie de fiche ne correspondant à". " votre demande"); - $html.=$sql; + if ( DEBUG ) $html.=$sql; } else { @@ -396,6 +396,9 @@ case 'ac': $msg=_(' d\'administration'); $base=''; break; + case FICHE_TYPE_CONTACT: + $msg=(' de contacts'); + $base=''; } $html=''; diff --git a/include/adm.inc.php b/include/adm.inc.php index 3f36d824e..ab4e03869 100644 --- a/include/adm.inc.php +++ b/include/adm.inc.php @@ -58,7 +58,7 @@ if ( isset($_POST['delete_card'] ) ) $f_id=$_REQUEST['f_id']; - $fiche=new Customer($cn,$f_id); + $fiche=new Admin($cn,$f_id); $fiche->remove(); $low_action="list"; @@ -82,7 +82,7 @@ if ( $low_action == "list" ) echo HtmlInput::request_to_hidden(array('ac')); $sel_card=new ISelect('cat'); $sel_card->value=$cn->make_array('select fd_id, fd_label from fiche_def '. - ' where frd_id='.FICHE_TYPE_ADM_TAX.' or frd_id ='.FICHE_TYPE_FIN. + ' where frd_id='.FICHE_TYPE_ADM_TAX. ' order by fd_label ',1); $sel_card->selected=(isset($_GET['cat']))?$_GET['cat']:-1; $sel_card->javascript=' onchange="submit(this);"'; @@ -140,32 +140,11 @@ if ( $low_action == "list" ) if ( $low_action == 'detail') { /* Menu */ - require_once('adm_card.inc.php'); + require_once('category_card.inc.php'); exit(); } -if ( $low_action=="insert" ) -{ - /* security : check if user can add card */ - if ( $g_user->check_action(FICADD) == 0 ) - { - alert('Vous ne pouvez pas ajouter de fiche'); - return; - } - $customer=new Customer($cn); - $customer->Save($_REQUEST['fd_id']); - echo '
'; - echo ""; - echo $customer->Display(true); - echo "
"; - $retour=new IAction(); - $retour->label="Retour"; - $retour->value="?p_action=adm&".dossier::get(); - echo $retour->input(); - echo '
'; - -} html_page_stop(); ?> diff --git a/include/adm_card.inc.php b/include/adm_card.inc.php deleted file mode 100644 index 9424dba42..000000000 --- a/include/adm_card.inc.php +++ /dev/null @@ -1,151 +0,0 @@ -name='retour'; -$return->label='Retour'; -$return->value='?ac='.$_REQUEST['ac'].'&'.$str_dossier; -$root='?ac='.$_REQUEST['ac']."&sb=detail&f_id=".$_REQUEST["f_id"].'&'.$str_dossier; -$ss_action=( isset ($_REQUEST['sc'] ))? $_REQUEST['sc']: ''; -switch ($ss_action) -{ -case 'dc': - $def=1; - break; -case 'sv': /* all the actions (mail,meeting...) */ - $def=2; - break; -case 'cn': - $def=3; - break; -case 'op': - $def=4; - break; -case 'bal': - $def=7; - break; -case 'let': - $def=6; - break; -default: - $def=1; - $ss_action='dc'; -} -$f=new Fiche($cn,$_REQUEST['f_id']); -echo '
'; -echo ShowItem(array( - array($root."&sc=dc",_('Fiche'),_('Détail de la fiche'),1), - array($root.'&sc=sv',_('Suivi'),_('Suivi adm, devis, bon de commande, courrier'),2), - array($root.'&sc=cn',_('Contact'),_('Liste de contacts de cette administration'),3), - array($root.'&sc=op',_('Opérations'),_('Toutes les opérations'),4), - array($root.'&sc=bal',_('Balance'),_('Balance du fournisseur'),7), - array($root.'&sc=let',_('Lettrage'),_('Opérations & Lettrages'),6), - array('?ac='.$_REQUEST['ac']."&".dossier::get(),_('Retour liste'),_('Retour à la liste des administration'),5) - ), - 'H',"mtitle","mtitle",$def,' '); -echo '
'; -echo '
'; -echo '

'.$f->get_quick_code()." ".$f->strAttribut(ATTR_DEF_NAME).'

'; -echo '
'; -echo ''; - -//--------------------------------------------------------------------------- -// Show Detail of a card and category -//--------------------------------------------------------------------------- -if ( $ss_action == 'dc' ) -{ - require_once('detail_adm.inc.php'); -} -//--------------------------------------------------------------------------- -// Follow up : mail, bons de commande, livraison, rendez-vous... -//--------------------------------------------------------------------------- -if ( $ss_action == 'sv' ) -{ - require_once('suivi_adm.inc.php'); -} -/*---------------------------------------------------------------------- - * Operation all the operation of this customer - * - * ----------------------------------------------------------------------*/ -if ( $ss_action == 'op') -{ - require_once('operation_adm.inc.php'); -} -/*---------------------------------------------------------------------- - * All the contact - * - *----------------------------------------------------------------------*/ -if ( $ss_action == 'cn') -{ - echo '
'; - echo dossier::hidden(); - $f=new Fiche($cn,$_REQUEST['f_id']); - $contact=new Contact($cn); - $contact->company=$f->get_quick_code(); - echo $contact->summary(""); - - $sql=' select fd_id from fiche_def where frd_id='.FICHE_TYPE_CONTACT; - $filter=$cn->make_list($sql); - if ( empty ($filter)) - { - echo ''; - echo _("Vous devez aller dans fiche et créer une catégorie pour les contacts"); - echo ''; - exit(); - } - /* Add button */ - $f_add_button=new IButton('add_card'); - $f_add_button->label=_('Créer une nouvelle fiche'); - $f_add_button->set_attribute('ipopup','ipopcard'); - - $f_add_button->set_attribute('filter',$filter); - $f_add_button->javascript=" select_card_type(this);"; - - echo $f_add_button->input(); - echo '
'; -} -/*------------------------------------------------------------------------- - * Balance of the card - *-------------------------------------------------------------------------*/ -if ( $ss_action=='bal') - { - require_once('balance_card.inc.php'); - } -/*---------------------------------------------------------------------------- - * Lettering - *----------------------------------------------------------------------------*/ -if ( $def==6 ) -{ - require_once('lettering.gestion.inc.php'); -} diff --git a/include/bank.inc.php b/include/bank.inc.php new file mode 100644 index 000000000..3ca31573e --- /dev/null +++ b/include/bank.inc.php @@ -0,0 +1,146 @@ +check_action(FICADD) == 0 ) + { + alert('Vous ne pouvez pas enlever de fiche'); + return; + } + + $f_id=$_REQUEST['f_id']; + + $fiche=new Bank($cn,$f_id); + $fiche->remove(); + $low_action="list"; + +} + +//----------------------------------------------------- +// list of supplier +//----------------------------------------------------- +if ( $low_action == "list" ) +{ + + ?> +
+
+
+ ', + $a); + $sel_card=new ISelect('cat'); + $sel_card->value=$cn->make_array('select fd_id, fd_label from fiche_def '. + ' where frd_id='.FICHE_TYPE_FIN. + ' order by fd_label ',1); + $sel_card->selected=(isset($_GET['cat']))?$_GET['cat']:-1; + $sel_card->javascript=' onchange="submit(this);"'; + echo _('Catégorie :').$sel_card->input(); + $nooperation=new ICheckBox('noop'); + $nooperation->selected=(isset($_GET['noop']))?true:false; + echo _('Inclure les banques sans opération :').$nooperation->input(); + + ?> + + +
+
+ '; + echo $supplier->Summary($search,'supplier',$sql,$noop); + + + echo '
'; + echo '
'; + echo '
'; + if ($g_user->check_action(FICADD)==1) + { + /* Add button */ + $f_add_button=new IButton('add_card'); + $f_add_button->label=_('Créer une nouvelle fiche'); + $f_add_button->set_attribute('win_refresh','yes'); + + $f_add_button->set_attribute('type_cat',FICHE_TYPE_FIN); + $f_add_button->javascript=" select_card_type(this);"; + echo $f_add_button->input(); + + $f_cat_button=new IButton('add_cat'); + $f_cat_button->set_attribute('type_cat',FICHE_TYPE_FIN); + $f_cat_button->label=_('Ajout d\'une catégorie'); + $f_cat_button->javascript='add_category(this)'; + echo $f_cat_button->input(); + } + + echo '
'; + echo ''; + + +} +/*---------------------------------------------------------------------- + * Detail for a card, Suivi, Contact, Operation,... * + * cc stands for supplier card + *----------------------------------------------------------------------*/ +if ( $low_action == 'detail') +{ + /* Menu */ + require_once('category_card.inc.php'); + exit(); +} + + + +html_page_stop(); +?> diff --git a/include/supplier_card.inc.php b/include/category_card.inc.php similarity index 90% rename from include/supplier_card.inc.php rename to include/category_card.inc.php index caf44f058..b3f5c0163 100644 --- a/include/supplier_card.inc.php +++ b/include/category_card.inc.php @@ -16,7 +16,7 @@ * along with PhpCompta; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -/* $Revision$ */ +/* $Revision: 4565 $ */ // Copyright Author Dany De Bontridder ddebontridder@yahoo.fr @@ -31,10 +31,6 @@ require_once('class_contact.php'); $str_dossier=Dossier::get(); /* $sub_action = sb = detail */ /* $cn database conx */ -$return=new IAction(); -$return->name='retour'; -$return->label='Retour'; -$return->value='?ac='.$_REQUEST['ac'].'&'.$str_dossier; $root='?ac='.$_REQUEST['ac']."&sb=detail&f_id=".$_REQUEST["f_id"].'&'.$str_dossier; $ss_action=( isset ($_REQUEST['sc'] ))? $_REQUEST['sc']: ''; switch ($ss_action) @@ -70,8 +66,7 @@ echo ShowItem(array( array($root.'&sc=cn',_('Contact'),_('Liste de contacts de ce fournisseur'),3), array($root.'&sc=op',_('Opérations'),_('Toutes les opérations'),4), array($root.'&sc=bal',_('Balance'),_('Balance du fournisseur'),7), - array($root.'&sc=let',_('Lettrage'),_('Opérations & Lettrages'),6), - array('?ac='.$_REQUEST['ac'].'&'.dossier::get(),_('Retour liste'),_('Retour à la liste des fournisseurs'),5) + array($root.'&sc=let',_('Lettrage'),_('Opérations & Lettrages'),6) ), 'H',"mtitle","mtitle",$def,' '); echo ''; @@ -86,14 +81,14 @@ echo ''; //--------------------------------------------------------------------------- if ( $ss_action == 'dc' ) { - require_once('detail_supplier.inc.php'); + require_once('category_detail.inc.php'); } //--------------------------------------------------------------------------- // Follow up : mail, bons de commande, livraison, rendez-vous... //--------------------------------------------------------------------------- if ( $ss_action == 'sv' ) { - require_once('suivi_supplier.inc.php'); + require_once('category_followup.inc.php'); } /*---------------------------------------------------------------------- * Operation all the operation of this customer @@ -101,7 +96,7 @@ if ( $ss_action == 'sv' ) * ----------------------------------------------------------------------*/ if ( $ss_action == 'op') { - require_once('operation_supplier.inc.php'); + require_once('category_operation.inc.php'); } /*------------------------------------------------------------------------- * Balance of the card @@ -135,7 +130,6 @@ if ( $ss_action == 'cn') /* Add button */ $f_add_button=new IButton('add_card'); $f_add_button->label=_('Créer une nouvelle fiche'); - $f_add_button->set_attribute('ipopup','ipopcard'); $f_add_button->set_attribute('filter',$filter); $f_add_button->javascript=" select_card_type(this);"; diff --git a/include/detail_supplier.inc.php b/include/category_detail.inc.php similarity index 95% rename from include/detail_supplier.inc.php rename to include/category_detail.inc.php index e7db4dd1c..f5e0c175d 100644 --- a/include/detail_supplier.inc.php +++ b/include/category_detail.inc.php @@ -16,10 +16,9 @@ * along with PhpCompta; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -/* $Revision$ */ +/* $Revision: 4701 $ */ // Copyright Author Dany De Bontridder ddebontridder@yahoo.fr -require_once('class_customer.php'); /*!\file * \brief this file will handle all the actions for a specific customer ( * contact,operation,invoice and financial) @@ -49,7 +48,7 @@ $f_id=$_REQUEST['f_id']; echo '
'; if ( isset($_POST['mod'])) echo hb(_('Information sauvée')); -$supplier=new Supplier($cn,$f_id); +$supplier=new Fiche($cn,$f_id); $p_readonly=($g_user->check_action(FICADD)==0)?true:false; if ( ! $p_readonly) echo '
'; echo dossier::hidden(); @@ -70,7 +69,6 @@ if ( ! $p_readonly) echo HtmlInput::submit('delete_card',_('Effacer cette fiche'),'onclick="return confirm(\'Confirmer effacement ?\');"'); echo '
'; } -echo $return->input(); echo '
'; diff --git a/include/suivi_supplier.inc.php b/include/category_followup.inc.php similarity index 98% rename from include/suivi_supplier.inc.php rename to include/category_followup.inc.php index f34e10cd8..0c5e1f052 100644 --- a/include/suivi_supplier.inc.php +++ b/include/category_followup.inc.php @@ -16,7 +16,7 @@ * along with PhpCompta; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -/* $Revision$ */ +/* $Revision: 4320 $ */ // Copyright Author Dany De Bontridder ddebontridder@yahoo.fr diff --git a/include/operation_supplier.inc.php b/include/category_operation.inc.php similarity index 98% rename from include/operation_supplier.inc.php rename to include/category_operation.inc.php index c21e2a2c4..96358803b 100644 --- a/include/operation_supplier.inc.php +++ b/include/category_operation.inc.php @@ -16,7 +16,7 @@ * along with PhpCompta; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -/* $Revision$ */ +/* $Revision: 4301 $ */ // Copyright Author Dany De Bontridder ddebontridder@yahoo.fr diff --git a/include/class_bank.php b/include/class_bank.php new file mode 100644 index 000000000..de6020aae --- /dev/null +++ b/include/class_bank.php @@ -0,0 +1,59 @@ +fiche_def_ref=FICHE_TYPE_FIN; + parent::__construct($p_cn,$p_id) ; + } + + + +} + +?> diff --git a/include/class_contact.php b/include/class_contact.php index e2f573382..c49860721 100644 --- a/include/class_contact.php +++ b/include/class_contact.php @@ -76,12 +76,15 @@ class contact extends Fiche } // Get The result Array $step_contact=$this->GetAll($offset,$search.$extra_sql.$p_sql); - if ( $all_contact == 0 ) return ""; + + if ( $all_contact == 0 ) return ""; $r=$bar; $r.=' + + @@ -116,17 +119,15 @@ class contact extends Fiche // add popup for detail if ( $l_company_name !="") { - $l_company_name=sprintf("%s - %s", - $contact->strAttribut(ATTR_DEF_COMPANY), - $contact->strAttribut(ATTR_DEF_COMPANY), - $l_company_name - ); + $l_company_name=HtmlInput::card_detail($contact->strAttribut(ATTR_DEF_COMPANY),$l_company_name,'style="text-decoration:underline;"'); } $r.=""; $qcode=$contact->strAttribut(ATTR_DEF_QUICKCODE); $r.='"; $r.=""; + $r.=""; + $r.=""; $r.=""; $r.="". ""; diff --git a/include/class_document.php b/include/class_document.php index 4b4384ed0..3ca59e20a 100644 --- a/include/class_document.php +++ b/include/class_document.php @@ -974,8 +974,9 @@ class Document || strlen(trim( ${'e_march'.$counter.'_price'} )) ==0 || strlen(trim(${'e_quant'.$counter})) ==0) return ""; - - $r=round(${$id}*${$quant},2); + bcscale(4); + $r=bcmul(${$id},${$quant}); + $r=round($r,2); break; case 'VEN_TVAC': @@ -986,7 +987,7 @@ class Document if ( ! isset(${'e_march'.$counter.'_price'})|| !isset(${'e_quant'.$counter})) return ""; // check that something is sold if ( ${'e_march'.$counter.'_price'} == 0 || ${'e_quant'.$counter} == 0 ) return ""; - bcscale(2); + bcscale(4); // if TVA not exist if ( ! isset(${$id})) $r= bcmul(${$price},${$quant}); @@ -994,12 +995,13 @@ class Document $r= bcmul(${$price},${$quant}); $r=bcadd($r,${$id}); } + $r=round($r,2); return $r; break; case 'TOTAL_VEN_HTVA': extract($p_array); - + bcscale(4); $sum=0.0; for ($i=0;$i<$nb_item;$i++) { @@ -1012,8 +1014,8 @@ class Document strlen(trim(${$qt})) == 0 || ${$qt}==0 || ${$sell}==0) continue; - $sum+=${$sell}*${$qt}; - $sum=round($sum,2); + $tmp1=bcmul(${$sell},${$qt}); + $sum=bcadd($sum,$tmp1); } @@ -1022,7 +1024,7 @@ class Document case 'TOTAL_VEN_TVAC': extract($p_array); $sum=0.0; - bcscale(2); + bcscale(4); for ($i=0;$i<$nb_item;$i++) { $tva='e_march'.$i.'_tva_amount'; diff --git a/include/class_fiche.php b/include/class_fiche.php index 99471a468..cafd9eab0 100644 --- a/include/class_fiche.php +++ b/include/class_fiche.php @@ -468,7 +468,7 @@ class Fiche { $w=new ICard("av_text".$attr->ad_id); // filter on frd_id - $sql=' select fd_id from fiche_def where frd_id in ('.FICHE_TYPE_CLIENT.','.FICHE_TYPE_FOURNISSEUR.','.FICHE_TYPE_ADM_TAX.')'; + $sql=' select fd_id from fiche_def where frd_id in ('.FICHE_TYPE_CLIENT.','.FICHE_TYPE_FOURNISSEUR.','.FICHE_TYPE_ADM_TAX.','.FICHE_TYPE_FIN.')'; $filter=$this->cn->make_list($sql); $w->set_attribute('ipopup','ipopcard'); $w->set_attribute('typecard',$filter); @@ -612,7 +612,8 @@ class Fiche { $w = new ICard("av_text" . $r->ad_id); // filter on frd_id - $sql = ' select fd_id from fiche_def where frd_id in (' . FICHE_TYPE_CLIENT . ',' . FICHE_TYPE_FOURNISSEUR . ',' . FICHE_TYPE_ADM_TAX . ')'; + $sql = ' select fd_id from fiche_def where frd_id in (' . FICHE_TYPE_CLIENT . ',' . FICHE_TYPE_FOURNISSEUR . ',' . FICHE_TYPE_ADM_TAX . ' + ,'.FICHE_TYPE_FIN.')'; $filter = $this->cn->make_list($sql); $w->extra = $filter; $w->extra2 = 0; @@ -829,7 +830,7 @@ class Fiche { $exist=$this->cn->count_sql("select f_id from fiche join fiche_def using (fd_id) ". " join fiche_detail using(f_id) ". - " where frd_id in (8,9,14) and ad_id=".ATTR_DEF_QUICKCODE. + " where frd_id in (4,8,9,14) and ad_id=".ATTR_DEF_QUICKCODE. " and ad_value='".sql_string($value)."'"); if ( $exist == 0 && sql_string($value) != null ) { @@ -1000,7 +1001,7 @@ class Fiche { $exist=$this->cn->exec_sql("select f_id from fiche join fiche_def using (fd_id) ". " join fiche_detail using (f_id) ". - " where frd_id in (8,9,14) and ad_id=$1 ". + " where frd_id in (4,8,9,14) and ad_id=$1 ". " and ad_value=upper($2)", array(ATTR_DEF_QUICKCODE,$value)); diff --git a/include/class_pre_operation.php b/include/class_pre_operation.php index f1321c442..54034f7f1 100644 --- a/include/class_pre_operation.php +++ b/include/class_pre_operation.php @@ -63,8 +63,7 @@ class Pre_operation } function delete () { - $sql="delete from op_predef where od_id=".$this->od_id. - " and od_direct ='".$this->od_direct."'"; + $sql="delete from op_predef where od_id=".$this->od_id; $this->db->exec_sql($sql); } /*!\brief save the predef check first is the name is unique diff --git a/include/client.inc.php b/include/client.inc.php index 166c32731..17b148668 100644 --- a/include/client.inc.php +++ b/include/client.inc.php @@ -25,11 +25,7 @@ require_once("class_iselect.php"); require_once("class_ihidden.php"); require_once("class_customer.php"); require_once("class_ibutton.php"); -require_once('class_iaction.php'); require_once('class_fiche_def.php'); -require_once('class_iaction.php'); -require_once('class_fiche_def.php'); -require_once('class_ipopup.php'); @@ -137,30 +133,9 @@ if ($low_action == "list") if ( $low_action == 'detail') { /* Menu */ - require_once('client_card.inc.php'); + require_once('category_card.inc.php'); exit(); } - if ($low_action == "insert") - { - /* security : check if user can add card */ - if ($g_user->check_action(FICADD) == 0) - { - alert('Vous ne pouvez pas ajouter de fiche'); - return; - } - - $customer = new Customer($cn); - $customer->Save($_REQUEST['fd_id']); - echo '
'; - echo "
Quick Code NomPrénomSociété Téléphone email Fax
'.$qcode. "".$contact->strAttribut(ATTR_DEF_NAME)."".$contact->strAttribut(ATTR_DEF_FIRST_NAME)."".$l_company_name."".$contact->strAttribut(ATTR_DEF_TEL)."".$contact->strAttribut(ATTR_DEF_EMAIL)." ".$contact->strAttribut(ATTR_DEF_FAX)."
"; - echo $customer->Display(true); - echo "
"; - $retour = new IAction(); - $retour->label = "Retour"; - $retour->value = "?ac=" . $_REQUEST["ac"] . "&" . dossier::get(); - echo $retour->input(); - echo ''; - } html_page_stop(); ?> diff --git a/include/client_card.inc.php b/include/client_card.inc.php deleted file mode 100644 index f871b3874..000000000 --- a/include/client_card.inc.php +++ /dev/null @@ -1,150 +0,0 @@ -'; -echo ShowItem(array( - array($root."&sc=dc",_('Fiche'),_('Détail de la fiche'),1), - array($root.'&sc=sv',_('Suivi'),_('Suivi client, devis, bon de commande, courrier'),2), - array($root.'&sc=cn',_('Contact'),_('Liste de contacts de ce client'),3), - array($root.'&sc=op',_('Opérations'),_('Toutes les opérations'),4), - array($root.'&sc=bal',_('Balance'),_('Balance du client'),7), - array($root.'&sc=let',_('Lettrage'),_('Opérations & Lettrages'),6), - array('?ac='.$_REQUEST['ac'].'&'.dossier::get(),_('Retour liste'),_('Retour à la liste des clients'),5) - ), - 'H',"mtitle","mtitle",$def,''); -echo ''; -echo '
'; -echo '
'; -echo '

'.$f->get_quick_code()." ".$f->strAttribut(ATTR_DEF_NAME).'

'; -echo '
'; -echo '
'; - -//--------------------------------------------------------------------------- -// Show Detail of a card and category -//--------------------------------------------------------------------------- -if ( $ss_action == 'dc' ) -{ - require_once('detail_client.inc.php'); -} -//--------------------------------------------------------------------------- -// Follow up : mail, bons de commande, livraison, rendez-vous... -//--------------------------------------------------------------------------- -if ( $ss_action == 'sv' ) -{ - require_once('suivi_client.inc.php'); -} -/*---------------------------------------------------------------------- - * Operation all the operation of this customer - * - * ----------------------------------------------------------------------*/ -if ( $ss_action == 'op') -{ - require_once('operation_client.inc.php'); -} -/*---------------------------------------------------------------------- - * All the contact - * - *----------------------------------------------------------------------*/ -if ( $ss_action == 'cn') -{ - echo '
'; - echo dossier::hidden(); - $f=new Fiche($cn,$_REQUEST['f_id']); - $contact=new Contact($cn); - $contact->company=$f->get_quick_code(); - echo $contact->summary(); - - $sql=' select fd_id from fiche_def where frd_id='.FICHE_TYPE_CONTACT; - $filter=$cn->make_list($sql); - if ( empty ($filter)) - { - echo ''; - echo _("Vous devez aller dans fiche et créer une catégorie pour les contacts"); - echo ''; - exit(); - } - /* Add button */ - $f_add_button=new IButton('add_card'); - $f_add_button->label=_('Créer une nouvelle fiche'); - $f_add_button->set_attribute('ipopup','ipopcard'); - - $f_add_button->set_attribute('filter',$filter); - $f_add_button->javascript=" select_card_type(this);"; - - echo $f_add_button->input(); - echo '
'; -} -/*---------------------------------------------------------------------------- - * Lettering - *----------------------------------------------------------------------------*/ -if ( $def==6 ) -{ - require_once('lettering.gestion.inc.php'); -} -/*------------------------------------------------------------------------- - * Balance of the card - *-------------------------------------------------------------------------*/ -if ( $ss_action=='bal') - { - require_once('balance_card.inc.php'); - } diff --git a/include/contact.inc.php b/include/contact.inc.php index 68029b600..5ce60e6bf 100644 --- a/include/contact.inc.php +++ b/include/contact.inc.php @@ -15,215 +15,140 @@ * 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 -//!\brief File for adding contact, contact is a kind of fiche -require_once("class_icard.php"); -require_once("class_ispan.php"); +/* !\brief include from client.inc.php and concerned only the contact card and + * the contact category + */ require_once("class_iselect.php"); require_once("class_ihidden.php"); -require_once('class_contact.php'); -/*! \file - * \brief the contact class is derived from the class fiche - * the contact is in fact a card but more specific - * This file is included from the module "Gestion" +require_once("class_contact.php"); +require_once("class_ibutton.php"); +require_once('class_fiche_def.php'); + + + +$low_action = (isset($_REQUEST['sb'])) ? $_REQUEST['sb'] : "list"; +/* ! \file + * \brief Called from the module "Gestion" to manage the contact */ +$href=basename($_SERVER['PHP_SELF']); -$sub_action=(isset($_REQUEST['sa']))?$_REQUEST['sa']:""; - -// if this page is called from another menu (customer, supplier,...) -// a button back is added -if ( isset ($_REQUEST['url'])) -{ - $retour=HtmlInput::button_anchor('Retour',urldecode($_REQUEST['url'])); - - $h_url=sprintf('',urldecode($_REQUEST['url'])); -} -else -{ - $retour=""; - $h_url=""; -} - -// Menu -// Remove a card -if ( isset ($_POST['delete']) ) -{ - $f_id=$_REQUEST['f_id']; - - $fiche=new contact($cn,$f_id); - $fiche->remove(); - $sub_action="list"; -} -//----------------------------------------------------- -// Add card -if ( $sub_action=="insert" ) -{ - $contact=new Contact($cn); - $contact->Save($_REQUEST['fd_id']); - echo $retour; - echo ""; - echo $contact->Display(true); - echo "
"; - echo $retour; - -} - -//----------------------------------------------------- -// Save modification -if ( isset ($_POST['mod'])) -{ - // modification is asked - $f_id=$_REQUEST['f_id']; - - $contact=new contact($cn,$f_id); - $contact->Save(); - $sub_action="list"; -} // by default open liste -if ( $sub_action == "" ) - $sub_action="list"; +if ($low_action == "") + $low_action = "list"; + + //----------------------------------------------------- -//Display a blank card -if ( $sub_action=="blank") +// Remove a card +//----------------------------------------------------- +if (isset($_POST['delete_card'])) { - $retour_action=HtmlInput::button_anchor('Retour', "commercial.php?p_action=contact&$str_dossier"); + if ($g_user->check_action(FICADD) == 0) + { + alert(j(_('Vous ne pouvez pas enlever de fiche'))); + return; + } - echo '
'; + $f_id = $_REQUEST['f_id']; - echo $retour_action; - $c=new contact($cn); - echo '
blank($_GET['fd_id']); - echo HtmlInput::submit('Sauve','Sauve'); - echo '
'; - echo $retour_action; - echo '
'; + $fiche = new Contact($cn, $f_id); + $fiche->remove(); + $low_action = "list"; } + //----------------------------------------------------- -// list -if ( $sub_action == "list" ) +// list of contact +//----------------------------------------------------- +if ($low_action == "list") { ?>
- -
- ', - $a); - ?> - - -
+
+
+ ', $a); + $sel_card = new ISelect('cat'); + $sel_card->value = $cn->make_array('select fd_id, fd_label from fiche_def ' . + ' where frd_id=' . FICHE_TYPE_CONTACT . + ' order by fd_label ', 1); + $sel_card->selected = (isset($_GET['cat'])) ? $_GET['cat'] : -1; + $sel_card->javascript = ' onchange="submit(this);"'; + + echo _('Catégorie :') . $sel_card->input(); + + $sl_company=new ISelect("sel_company"); + $sl_company->value = $cn->make_array('select distinct ad_value,ad_value from fiche_detail as fd' . + ' join fiche as f1 on (f1.f_id=fd.f_id) join fiche_def as fdf on (f1.fd_id=fdf.fd_id) + where + ad_id='.ATTR_DEF_COMPANY. " and frd_id= ".FICHE_TYPE_CONTACT. + ' order by 1', 1); + $sl_company->selected = (isset($_GET['sel_company'])) ? $_GET['sel_company'] : ''; + echo _('Société :') . $sl_company->input(); + + ?> + + +
+
+ company=$_GET['sel_company']; + } + } + + echo '
'; + echo $client->Summary($search,"contact",$sql); -
- '; + echo '
'; + echo '
'; + /* Add button */ + $f_add_button = new IButton('add_card'); + $f_add_button->label = _('Créer une nouvelle fiche'); + $f_add_button->set_attribute('win_refresh', 'yes'); + $f_add_button->set_attribute('type_cat', FICHE_TYPE_CONTACT); + $f_add_button->javascript = " select_card_type(this);"; + echo $f_add_button->input(); - $w=new ICard(); - $w->name='qcode'; - $w->value=$qcode; - $w->label='qcode'; - $w->table=0; - $w->jrn=0; - $w->extra='4,8,9,14'; - echo $w->input(); + $f_cat_button=new IButton('add_cat'); + $f_cat_button->set_attribute('ipopup','ipop_cat'); + $f_cat_button->set_attribute('type_cat',FICHE_TYPE_CONTACT); + $f_cat_button->label=_('Ajout d\'une catégorie'); + $f_cat_button->javascript='add_category(this)'; + echo $f_cat_button->input(); - - $sp=new ISpan(); - echo $sp->input("qcode_label",$qcode).""; - - - ?> - - - -
- - -
- - > - - - name="fd_id"; - $w->value= $cn->make_array("select fd_id,fd_label from fiche_def where ". - " frd_id=".FICHE_TYPE_CONTACT); -// if array is empty show an warning and stops - if ( sizeof ($w->value) == 0 ) -{ - echo '

Aucune fiche de catégories contact

'; - echo '

allez dans fiche creation et choississez contact comme sorte

'; - exit(); - } - echo $w->input(); - - ?> - - - -
-
- company=$qcode; - } - echo $retour; - echo '
'; - echo $contact->Summary($search); + echo '
'; echo '
'; - echo $retour; } -//----------------------------------------------------- -// Show Detail -if ( $sub_action == 'detail' ) +/*---------------------------------------------------------------------- + * Detail for a card, Suivi, Contact, Operation,... * + * cc stands for contact card + *----------------------------------------------------------------------*/ +if ( $low_action == 'detail') { - $f_id=$_REQUEST['f_id']; - echo '
'; - $contact=new contact($cn,$f_id); - echo $retour; - echo '
'; - echo dossier::hidden(); - echo $contact->Display(false); - $w=new IHidden(); - $w->name="p_action"; - $w->value="contact"; - echo $w->input(); - $w->name="f_id"; - $w->value=$f_id; - echo $w->input(); - - echo HtmlInput::submit('mod','Sauver les modifications'); - echo ''; - echo HtmlInput::submit('delete','Effacer cette fiche'); - echo '
'; - echo $retour; - echo '
'; + /* Menu */ + require_once('category_card.inc.php'); + exit(); } -html_page_stop(); - + html_page_stop(); +?> diff --git a/include/detail_adm.inc.php b/include/detail_adm.inc.php deleted file mode 100644 index bf3b3af97..000000000 --- a/include/detail_adm.inc.php +++ /dev/null @@ -1,76 +0,0 @@ -Save(); - -} - -echo '
'; -$f_id=$_REQUEST['f_id']; -echo '
'; -if ( isset($_POST['mod'])) echo hb('Information sauvée'); - -$adm=new Fiche($cn,$f_id); -$p_readonly=($g_user->check_action(FICADD)==0)?true:false; -if ( ! $p_readonly) echo '
'; -echo dossier::hidden(); -echo HtmlInput::hidden('sb','detail'); -echo HtmlInput::hidden('dc','cc'); -echo $adm->Display($p_readonly); -$w=new IHidden(); -$w->name="p_action"; -$w->value="adm"; -echo $w->input(); -$w->name="f_id"; -$w->value=$f_id; -echo $w->input(); -if ( ! $p_readonly) -{ - echo HtmlInput::submit('mod',_('Sauver les modifications')); - echo HtmlInput::reset(_("Annuler")); - echo HtmlInput::submit('delete_card','Effacer cette fiche','onclick="return confirm(\'Confirmer effacement ?\');"'); - echo '
'; -} -echo $return->input(); -echo '
'; - - diff --git a/include/detail_client.inc.php b/include/detail_client.inc.php deleted file mode 100644 index 71b8f8601..000000000 --- a/include/detail_client.inc.php +++ /dev/null @@ -1,76 +0,0 @@ -Save(); - -} - -echo '
'; -$f_id=$_REQUEST['f_id']; -echo '
'; -if ( isset($_POST['mod'])) echo hb(_('Information sauvée')); - -$client=new Customer($cn,$f_id); -$p_readonly=($g_user->check_action(FICADD)==0)?true:false; -if ( ! $p_readonly) echo '
'; -echo dossier::hidden(); -echo HtmlInput::hidden('sb','detail'); -echo HtmlInput::hidden('dc','cc'); -echo $client->Display($p_readonly); -$w=new IHidden(); -$w->name="p_action"; -$w->value="client"; -echo $w->input(); -$w->name="f_id"; -$w->value=$f_id; -echo $w->input(); -if ( ! $p_readonly) -{ - echo HtmlInput::submit('mod',_('Sauver les modifications')); - echo HtmlInput::reset(_("Annuler")); - echo HtmlInput::submit('delete_card',_('Effacer cette fiche'),'onclick="return confirm(\'Confirmer effacement ?\');"'); - echo '
'; -} -echo $return; -echo '
'; - - diff --git a/include/export_anc_acc_list.php b/include/export_anc_acc_list.php deleted file mode 100644 index 5a3ef5b54..000000000 --- a/include/export_anc_acc_list.php +++ /dev/null @@ -1,34 +0,0 @@ -get_request(); -$atable->export_csv(); \ No newline at end of file diff --git a/include/export_poste_detail.php b/include/export_poste_detail.php deleted file mode 100644 index 14e302fd8..000000000 --- a/include/export_poste_detail.php +++ /dev/null @@ -1,161 +0,0 @@ -Check(); -$User->check_dossier($gDossier); - -if ( isset ( $_REQUEST['poste_fille']) ) -{ //choisit de voir tous les postes - $a_poste=$cn->get_array("select pcm_val from tmp_pcmn where pcm_val::text like $1||'%'",array($_REQUEST["poste_id"])); -} -else -{ - $a_poste=$cn->get_array("select pcm_val from tmp_pcmn where pcm_val = $1",array($_REQUEST['poste_id'])); -} - -if ( ! isset ($_REQUEST['oper_detail'])) -{ - if ( count($a_poste) == 0 ) - exit; - - foreach ($a_poste as $pos) - { - $Poste=new Acc_Account_Ledger($cn,$pos['pcm_val']); - $name=$Poste->get_name(); - list($array,$tot_deb,$tot_cred)=$Poste->get_row_date( $_REQUEST['from_periode'], - $_REQUEST['to_periode'], - $_GET['ople'] - ); - if ( count($Poste->row ) == 0 ) - continue; - - echo '"Poste";'. - '"n° pièce";'. - '"Lib.";'. - "\"Code interne\";". - "\"Date\";". - "\"Description\";". - "\"Débit\";". - "\"Crédit\";". - "\"Prog.\""; - printf("\n"); - - $prog=0; - foreach ( $Poste->row as $op ) - { - $diff=bcsub($op['deb_montant'],$op['cred_montant']); - $prog=bcadd($prog,$diff); - echo '"'.$pos['pcm_val'].'";'. - '"'.$op['jr_pj_number'].'"'.";". - '"'.$name.'";'. - '"'.$op['jr_internal'].'"'.";". - '"'.$op['j_date_fmt'].'"'.";". - '"'.$op['description'].'";'. - nb($op['deb_montant']).";". - nb($op['cred_montant']).";". - nb(abs($prog)); - printf("\n"); - - - } - $solde_type=($tot_deb>$tot_cred)?"solde débiteur":"solde créditeur"; - $diff=abs($tot_deb-$tot_cred); - printf( - '"'."$solde_type".'"'.";". - nb($diff).";". - nb($tot_deb).";". - nb($tot_cred)."\n"); - } -} -else -{ - /* detail of all operation */ - if ( count($a_poste) == 0 ) - exit; - - foreach ($a_poste as $pos) - { - $Poste=new Acc_Account_Ledger($cn,$pos['pcm_val']); - $Poste->get_name(); - list($array,$tot_deb,$tot_cred)=$Poste->get_row_date( $_REQUEST['from_periode'], - $_REQUEST['to_periode'] - ); - if ( count($Poste->row ) == 0 ) - continue; - - echo '"Poste";'. - '"Lib.";'. - '"QuickCode";'. - "\"Code interne\";". - "\"Date\";". - "\"Description\";". - "\"Montant\";". - "\"D/C\""; - printf("\n"); - - - foreach ( $Poste->row as $a ) - { - $op=new Acc_Operation($cn); - $op->jr_id=$a['jr_id']; - $result=$op->get_jrnx_detail(); - foreach ( $result as $r) - { - printf('"%s";"%s";"%s";"%s";"%s";"%s";"%s";%12.2f;"%s"', - $r['j_poste'], - $r['pcm_lib'], - $r['j_qcode'], - $r['jr_internal'], - $r['jr_date'], - $a['description'], - $a['jr_pj_number'], - nb($r['j_montant']), - $r['debit']); - printf("\r\n"); - - } - - - - } - } - exit; -} -?> diff --git a/include/export_table_csv.php b/include/export_table_csv.php deleted file mode 100644 index 56716a9c0..000000000 --- a/include/export_table_csv.php +++ /dev/null @@ -1,34 +0,0 @@ -get_request(); -$atable->export_csv(); \ No newline at end of file diff --git a/include/operation_adm.inc.php b/include/operation_adm.inc.php deleted file mode 100644 index 45062541a..000000000 --- a/include/operation_adm.inc.php +++ /dev/null @@ -1,41 +0,0 @@ -get_quick_code(); -$_GET['qcode']=$qcode; -$_REQUEST['qcode']=$qcode; - -$var_array=compute_variable('ledger_type=ALL'); -put_global($var_array); -require_once ('history_operation.inc.php'); - diff --git a/include/operation_client.inc.php b/include/operation_client.inc.php deleted file mode 100644 index ea4c6f8b3..000000000 --- a/include/operation_client.inc.php +++ /dev/null @@ -1,41 +0,0 @@ -get_quick_code(); -$_GET['qcode']=$qcode; -$_REQUEST['qcode']=$qcode; -$var_array=compute_variable('ledger_type=ALL'); -put_global($var_array); -require_once ('history_operation.inc.php'); - - diff --git a/include/preod.inc.php b/include/preod.inc.php index 70a74bd16..05013423d 100644 --- a/include/preod.inc.php +++ b/include/preod.inc.php @@ -64,16 +64,13 @@ if ( $sa == 'jrn' ) { $op=new Pre_operation($cn); $op->set_jrn($_GET['jrn']); - if ( isset($_GET['direct'])) - { - $op->od_direct='true'; - } - else - { - $op->od_direct='false'; - } - $array=$op->get_list_ledger(); - if ( empty($array) == true ) + $is_ods = $cn->get_value("select count(*) + from jrn_def where + jrn_def_id=$1 + and jrn_def_type='ODS'", array($_GET['jrn'])); + $op->od_direct = ($is_ods > 0) ? 't' : 'f'; + $array = $op->get_list_ledger(); + if (empty($array) == true) { echo "Aucun enregistrement"; exit(); diff --git a/include/suivi_adm.inc.php b/include/suivi_adm.inc.php deleted file mode 100644 index 2fbb4cbec..000000000 --- a/include/suivi_adm.inc.php +++ /dev/null @@ -1,48 +0,0 @@ -get_quick_code(); -$_REQUEST['qcode']=$fiche->get_quick_code(); -echo '
'; -require_once('action.common.inc.php'); -echo '
'; diff --git a/include/suivi_client.inc.php b/include/suivi_client.inc.php deleted file mode 100644 index cedc5abe3..000000000 --- a/include/suivi_client.inc.php +++ /dev/null @@ -1,50 +0,0 @@ -get_quick_code(); -$_REQUEST['qcode']=$fiche->get_quick_code(); -echo '
'; -require_once('action.common.inc.php'); -echo '
'; diff --git a/include/supplier.inc.php b/include/supplier.inc.php index 222207f6c..889916866 100644 --- a/include/supplier.inc.php +++ b/include/supplier.inc.php @@ -115,7 +115,6 @@ if ( $low_action == "list" ) /* Add button */ $f_add_button=new IButton('add_card'); $f_add_button->label=_('Créer une nouvelle fiche'); - $f_add_button->set_attribute('ipopup','ipop_newcard'); $f_add_button->set_attribute('win_refresh','yes'); $f_add_button->set_attribute('type_cat',FICHE_TYPE_FOURNISSEUR); @@ -123,7 +122,6 @@ if ( $low_action == "list" ) echo $f_add_button->input(); $f_cat_button=new IButton('add_cat'); - $f_cat_button->set_attribute('ipopup','ipop_cat'); $f_cat_button->set_attribute('type_cat',FICHE_TYPE_FOURNISSEUR); $f_cat_button->label=_('Ajout d\'une catégorie'); $f_cat_button->javascript='add_category(this)'; @@ -142,32 +140,11 @@ if ( $low_action == "list" ) if ( $low_action == 'detail') { /* Menu */ - require_once('supplier_card.inc.php'); + require_once('category_card.inc.php'); exit(); } -if ( $low_action=="insert" ) -{ - /* security : check if user can add card */ - if ( $g_user->check_action(FICADD) == 0 ) - { - alert('Vous ne pouvez pas ajouter de fiche'); - return; - } - $supplier=new Supplier($cn); - $supplier->Save($_REQUEST['fd_id']); - echo '
'; - echo ""; - echo $supplier->Display(true); - echo "
"; - $retour=new IAction(); - $retour->label="Retour"; - $retour->value="?p_action=supplier&".dossier::get(); - echo $retour->input(); - echo '
'; - -} html_page_stop(); ?> diff --git a/sql/upgrade.sql b/sql/upgrade.sql new file mode 100644 index 000000000..d9d757547 --- /dev/null +++ b/sql/upgrade.sql @@ -0,0 +1,52 @@ +CREATE OR REPLACE FUNCTION comptaproc.check_balance(p_grpt integer) + RETURNS numeric AS +$BODY$ +declare + amount_jrnx_debit numeric; + amount_jrnx_credit numeric; + amount_jrn numeric; +begin + select coalesce(sum (j_montant),0) into amount_jrnx_credit + from jrnx + where + j_grpt=p_grpt + and j_debit=false; + + select coalesce(sum (j_montant),0) into amount_jrnx_debit + from jrnx + where + j_grpt=p_grpt + and j_debit=true; + + select coalesce(jr_montant,0) into amount_jrn + from jrn + where + jr_grpt_id=p_grpt; + + if ( amount_jrnx_debit != amount_jrnx_credit ) + then + return abs(amount_jrnx_debit-amount_jrnx_credit); + end if; + if ( amount_jrn != amount_jrnx_credit) + then + return -1*abs(amount_jrn - amount_jrnx_credit); + end if; + return 0; +end; +$BODY$ + LANGUAGE plpgsql; + +update op_predef set od_direct='t' where od_jrn_type='ODS'; + +INSERT INTO menu_ref( + me_code, me_menu, me_file, me_url, me_description, me_parameter, + me_javascript, me_type) + VALUES ('BK', 'Banque', 'bank.inc.php', null, 'Information Banque', null,null,'ME'); + +INSERT INTO profile_menu( + me_code, me_code_dep, p_id, p_order, p_type_display, pm_default) + VALUES ('BK', 'GESTION', 1, 4, 'E', 0); +INSERT INTO profile_menu( + me_code, me_code_dep, p_id, p_order, p_type_display, pm_default) + VALUES ('BK', 'GESTION', 2, 4, 'E', 0); +