diff --git a/html/test.php b/html/test.php index 1a9e7d1eb..33633cb63 100644 --- a/html/test.php +++ b/html/test.php @@ -69,7 +69,8 @@ $array=array( array(29,'ITVA popup'), array(30,'Ereg and preg_match'), array(31,'IBOX'), - array(32,'Acc_Operation & children') + array(32,'Acc_Operation & children'), + array(33,'Ledger : reverse op') ); $r='
'; $r.=''; - $op=new Pre_operation($cn); - $op->p_jrn=$id; - $op->od_direct='t'; - if ($op->count() != 0 ) { - echo HtmlInput::submit('use_opd','Utilisez une op.prédéfinie'); - echo $op->show_button(); - } - echo '
'; - exit(); - } - - if ( isset($_POST['post_id' ])) { - - echo '
'; - echo $a->show_form($_POST,1); - echo HtmlInput::button('add','Ajout d\'une ligne','onClick="quick_writing_add_row()"'); - echo HtmlInput::submit('save_it',"Sauver"); - echo '
'; - exit(); - } - if ( isset($_POST['save_it' ])) { - print 'saving'; - $array=$_POST; - $array['save_opd']=1; - try { - $a->save($array); - } catch (Exception $e) { - alert($e->getMessage()); - echo '
'; - - echo $a->show_form($_POST); - echo HtmlInput::submit('post_id','Try me'); - echo '
'; - - } - exit(); - } - // The GET at the end because automatically repost when you don't - // specify the url in the METHOD field - if ( isset ($_GET['use_opd'])) { - $op=new Pre_op_advanced($cn); - $op->set_od_id($_REQUEST['pre_def']); - //$op->p_jrn=$id; - - $p_post=$op->compute_array(); - - echo '
'; - - echo $a->show_form($p_post); - echo HtmlInput::submit('post_id','Use predefined operation'); - echo '
'; - exit(); - - } - }// if case = '' - if ( $pCase == 'search') { - html_page_start(); - $cn=new Database(dossier::id()); - $ledger=new Acc_Ledger($cn,0); - $_SESSION['g_user']='phpcompta'; - $_SESSION['g_pass']='phpcompta'; - echo $ledger->search_form('ALL'); - } - } + /*!\brief return the last p_limit operation into an array *\param $p_limit is the max of operation to return *\return $p_array of Action object @@ -2430,4 +2527,126 @@ array } return $ret; } + //////////////////////////////////////////////////////////////////////////////// + // TEST MODULE + //////////////////////////////////////////////////////////////////////////////// + /*! + * \brief this function is intended to test this class + */ + static function test_me($pCase='') + { + if ( $pCase=='') { + echo Acc_Reconciliation::$javascript; + html_page_start(); + $cn=new Database(dossier::id()); + $_SESSION['g_user']='phpcompta'; + $_SESSION['g_pass']='phpcompta'; + + $id=(isset ($_REQUEST['p_jrn']))?$_REQUEST['p_jrn']:-1; + $a=new Acc_Ledger($cn,$id); + $a->with_concerned=true; + // Vide + echo '
'; + echo $a->select_ledger()->input(); + echo HtmlInput::submit('go','Test it'); + echo '
'; + if ( isset($_POST['go'])) { + echo "Ok "; + echo '
'; + echo $a->show_form(); + echo HtmlInput::submit('post_id','Try me'); + echo '
'; + // Show the predef operation + // Don't forget the p_jrn + echo '
'; + echo dossier::hidden(); + echo ''; + $op=new Pre_operation($cn); + $op->p_jrn=$id; + $op->od_direct='t'; + if ($op->count() != 0 ) { + echo HtmlInput::submit('use_opd','Utilisez une op.prédéfinie'); + echo $op->show_button(); + } + echo '
'; + exit(); + } + + if ( isset($_POST['post_id' ])) { + + echo '
'; + echo $a->show_form($_POST,1); + echo HtmlInput::button('add','Ajout d\'une ligne','onClick="quick_writing_add_row()"'); + echo HtmlInput::submit('save_it',"Sauver"); + echo '
'; + exit(); + } + if ( isset($_POST['save_it' ])) { + print 'saving'; + $array=$_POST; + $array['save_opd']=1; + try { + $a->save($array); + } catch (Exception $e) { + alert($e->getMessage()); + echo '
'; + + echo $a->show_form($_POST); + echo HtmlInput::submit('post_id','Try me'); + echo '
'; + + } + exit(); + } + // The GET at the end because automatically repost when you don't + // specify the url in the METHOD field + if ( isset ($_GET['use_opd'])) { + $op=new Pre_op_advanced($cn); + $op->set_od_id($_REQUEST['pre_def']); + //$op->p_jrn=$id; + + $p_post=$op->compute_array(); + + echo '
'; + + echo $a->show_form($p_post); + echo HtmlInput::submit('post_id','Use predefined operation'); + echo '
'; + exit(); + + } + }// if case = '' + /////////////////////////////////////////////////////////////////////////// + // search + if ( $pCase == 'search') { + html_page_start(); + $cn=new Database(dossier::id()); + $ledger=new Acc_Ledger($cn,0); + $_SESSION['g_user']='phpcompta'; + $_SESSION['g_pass']='phpcompta'; + echo $ledger->search_form('ALL'); + } + /////////////////////////////////////////////////////////////////////////// + // reverse + // Give yourself the var and check in your tables + /////////////////////////////////////////////////////////////////////////// + if ( $pCase=='reverse') { + $cn=new Database (dossier::id()); + $jr_internal='OD-01-272'; + try { + $cn->start(); + $jrn_def_id=$cn->get_value('select jr_def_id from jrn where jr_internal=$1',array($jr_internal)); + $ledger=new Acc_Ledger($cn,$jrn_def_id); + $ledger->jr_id=$cn->get_value('select jr_id from jrn where jr_internal=$1',array($jr_internal)); + + echo "Ouvrez le fichier ".__FILE__." à la ligne ".__LINE__." pour changer jr_internal et vérifier le résultat de l'extourne"; + + $ledger->reverse('01.07.2010'); + } catch (Exception $e) { + $cn->rollback(); + var_dump($e); + } + $cn->commit(); + } + } } diff --git a/include/class_lettering.php b/include/class_lettering.php index 85f05578f..e01f82f61 100644 --- a/include/class_lettering.php +++ b/include/class_lettering.php @@ -75,6 +75,34 @@ class Lettering else throw new Exception (__FILE__.":".__LINE__.$p_string.'Erreur attribut inexistant'); } + /** + *Use to just insert a couple of lettered operation + */ + function insert_couple($j_id1,$j_id2) { + $jl_id=$this->db->get_next_seq("jnt_letter_jl_id_seq"); + $this->db->exec_sql('insert into jnt_letter(jl_id) values($1)', + array($jl_id)); + /* take needed data */ + $first=$this->db->get_value('select j_debit from jrnx where j_id=$1',array($j_id1)); + if ( $this->db->count() == 0 ) throw new Exception ('Opération non existante'); + + $second=$this->db->get_value('select j_debit from jrnx where j_id=$1',array($j_id2)); + if ( $this->db->count() == 0 ) throw new Exception ('Opération non existante'); + /* insert */ + if ( $first == 't') { + // save into letter_deb + $ld_id=$this->db->get_value('insert into letter_deb(j_id,jl_id) values($1,$2) returning ld_id',array($j_id1,$jl_id)); + }else { + $lc_id=$this->db->get_value('insert into letter_cred(j_id,jl_id) values($1,$2) returning lc_id',array($j_id1,$jl_id)); + } + if ( $second == 't') { + // save into letter_deb + $ld_id=$this->db->get_value('insert into letter_deb(j_id,jl_id) values($1,$2) returning ld_id',array($j_id2,$jl_id)); + }else { + $lc_id=$this->db->get_value('insert into letter_cred(j_id,jl_id) values($1,$2) returning lc_id',array($j_id2,$jl_id)); + } + + } public function get_info() { return var_export(self::$variable,true); } public function verify() { // Verify that the elt we want to add is correct diff --git a/release-note b/release-note index 63f71e8d9..9ee6c739e 100644 --- a/release-note +++ b/release-note @@ -9,8 +9,7 @@ 8. TODO18 Acc_Account_Ledger::HtmlTable et Fiche::HtmlTable, il manque la sécurité pour filtrer les journaux 9. Ajout d'une FK TODO1 réecriture de quant_* la liaison avec la jrn se fait à travers jr_id et non pas jr_internal qui n'est pas indexé. Conséquence : réécriture de code, correction modop, ... - -TODO2 Object pour extourner proprement une operation, le fichier annulation.php devient inutile (deprecated) depend de TODO1 TODO10 +10. TODO2 Object pour extourner proprement une operation, le fichier annulation.php devient inutile (deprecated) depend de TODO1 TODO10 IDEE6, categorie de fiche, changer la présentation diff --git a/sql/upgrade.sql b/sql/upgrade.sql index efcae3cbb..76e05e071 100644 --- a/sql/upgrade.sql +++ b/sql/upgrade.sql @@ -9,4 +9,17 @@ ALTER TABLE quant_sold REFERENCES jrn (jr_internal) MATCH SIMPLE ON UPDATE CASCADE ON DELETE CASCADE; +ALTER TABLE stock_goods + ADD CONSTRAINT stock_goods_j_id_fkey FOREIGN KEY (j_id) + REFERENCES jrnx (j_id) MATCH SIMPLE + ON UPDATE cascade ON DELETE cascade; +ALTER TABLE jrn_rapt + ADD CONSTRAINT jrn_rapt_jr_id_fkey FOREIGN KEY (jr_id) + REFERENCES jrn (jr_id) MATCH SIMPLE + ON UPDATE cascade ON DELETE cascade; +ALTER TABLE jrn_rapt + ADD CONSTRAINT jrn_rapt_jra_concerned_fkey FOREIGN KEY (jra_concerned) + REFERENCES jrn (jr_id) MATCH SIMPLE + ON UPDATE cascade ON DELETE cascade; + commit;