Location: PHPKode > projects > MyPhpMoney > myphpmoney_2.0/public_html/account.php
<?php
/**
 * $Id: account.php 420 2007-05-24 18:32:09Z hpfn $
 *
 * Author     : courou&#64;users.sourceforge.net
 * Website    : http://allreponse.ath.cx
 *
 * Support    : http://sourceforge.net/projects/myphpmoney/
 * CVS        : http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/myphpmoney/
 */

/**
 * INCLUDE FILE
 */
     require_once 'config/settings.inc.php';

/**
 * ENTER IN THE SESSION OR BUILD THE LOGIN FORM
 */
     if (SQL_VerifSession()) {

/**
 * IF NO ID ACCOUNT (DEFAULT ID)
 */
     if (!isset($_POST['ID'])) {
     	$_POST['ID'] = SQL_IdAccount('');
     } else {
     	 $_POST['ID'] = SQL_Clean($_POST['ID']);
     }	 
     $name_account = SQL_NameAccount($_POST['ID']);

/**
 * DEFINE VARIABLE GLOBALS
 */
      $PageOrder     = 'account';
      $cont          = array();
      $sum_spent     = '';
      $sum_received  = '';
      $ids_mods      = '';         ## for recup the id account mod modif
      $submit        = '';         ## for recup the submit value (dupliquer)
      $selectAccount = '';         ## For change this account
      $affecters     = '';         ## for depense or recette
      $_MPM['BlockInclude']  = 0;  ## for the include template

      $_N_ID    = SQL_RecupId(1);
      $id_cat   = SQL_RecupId(0);
      $id_tiers = SQL_RecupId(4);
      $ID_TIERS = SQL_SearchInThird(0, $_POST['ID']);
      if ( isset($_POST['date']) ) {
      	$_POST['date'] = SQL_CLean($_POST['date']);
      	$_DATE    = preg_replace('/^([0-9]{1,2})-([0-9]{1,2})-([0-9]{2,4})$/', '\3-\2-\1', $_POST['date']);
      } else {
      	$_DATE = '';
      }
      if (  isset($_POST['tiers']) ) {
      	$_POST['tiers'] = SQL_Clean($_POST['tiers']);
      	$ID_COREL = SQL_SearchInThird(1, $_POST['tiers']);
      } else {
      	$ID_COREL = '';
      }

/**
 * DEFINE VARIABLE
 */
     if (!isset($_POST['opt'])) $_POST['opt'] = '';

/**
 * FOR RELOAD DUPLIQ ACTION
 */
     if ($_POST['opt'] != 'MODIF_THIS_ACCOUNT') {
       $sess->unregister('sess_reload');
     }

/**
 * SWITCH ACTION (RENAME - ADD - DUPLIQUER)
 */
     switch($_POST['opt']) {

           ## UPDATE THE VALIDE IMAGE YES OR NOT
           default :
               if (isset($_POST['VALID_IMG']) && is_array($_POST['VALID_IMG'])) {
                   while(list($kobj,$vobj) = each($_POST['VALID_IMG'])) {
                    $hid = explode('|',$kobj);

		    $hid[0] = SQL_Clean($hid[0]);		
                       $IdAcct = SQL_SearchIdCorel(1,$hid[0]);
                       if ($hid[1] == 0) {
                           if ($IdAcct > 1) {
                              SQL_UpdateAccount(0,'',1,'',1,$IdAcct);
                          }
                       SQL_UpdateAccount(0,'',1,'',1,$hid[0]);
                       } else if ($hid[1] == 1) {

                          if ($IdAcct > 1) {
                              SQL_UpdateAccount(0,'',0,'',1,$IdAcct);
                          }
                        SQL_UpdateAccount(0,'',0,'',1,$hid[0]);
                       } ## end of $hid[1]
                   } ## end of while
             } ## end of is_isset && is_array()

             ## DELETE THE ACCOUNT NUMBER
             if (isset($_POST['SUPP_ACCOUNT'])) {
                $val_del = explode('|',$_POST['SUPP_ACCOUNT']);
                  ## CORRELATION EXISTE
                  if ($val_del[1] == 1) {
		  	$_POST['SUPP_ACCOUNT'] = SQL_Clean($_POST['SUPP_ACCOUNT']);	
                       $Corel = SQL_SearchIdCorel(1,$_POST['SUPP_ACCOUNT']);
                       $Compte_Corel = SQL_Search_AcctCorel(1,$Corel,1);

                       SQL_DeleteAccount(1,$Corel,'',0);

                   SQL_RecupSolde($Compte_Corel);
                  }

	     $val_del[0] = SQL_CLean($val_del[0]);	
             SQL_DeleteAccount(1,$val_del[0],'',0);
             SQL_RecupSolde($_POST['ID']);
            } ## end of isset($_POST['SUPP_ACCOUNT']
      break;
     /**
      * SWITCH -- ADD THE NEWS ACCOUNT OPERATION
      */
            case 'ADD_ACCOUNT' :
            if (($_POST['ID'] && $_POST['date'] && $_POST['cat'] && $_POST['paie'] && $_POST['affecter']) != '') {

            if (isset($_POST['MOD_IF']) && is_array($_POST['MOD_IF']) && $_POST['MOD_IF']['0'] == $_VAR['DUPLIQ']) {
               $submit = $_VAR['DUPLIQ']; ## DUPLIQ
            }

               /**
                * THE VALUE ET NAME OF POST VARIABLE
                */
                    if ($_POST['affecter'] == 1) { 
		    	$_RECETTE = 0; 
			$_DEPENSE = SQL_Clean($_POST['paie']);
		    }
                    if ($_POST['affecter'] == 2) { 
		    	$_DEPENSE = 0; 
			$_RECETTE = SQL_Clean($_POST['paie']);
		    }
                    if ($_POST['cat'] == __PART_ID__) {
		    	$_COREL = bcadd($_N_ID,1); 
		    } else {
		    	$_COREL = 0;
		    }
		    
		    $_POST['R'] = SQL_Clean($_POST['R']);
		    $_POST['numero_id'] = SQL_Clean($_POST['numero_id']);
		    $_POST['commentaires'] = SQL_Clean($_POST['commentaires']);
		    $_POST['news_cat'] = SQL_Clean($_POST['news_cat']);
		    $_POST['news_tiers'] = SQL_Clean($_POST['news_tiers']);
		    $_POST['cat'] = SQL_Clean($_POST['cat']);
		    $_POST['paie'] = SQL_Clean($_POST['paie']);
		
                     ## NEWS ENTRY FOR THE THIRD AND PART
                     if ($_POST['cat'] == __ANOTHER_ACCOUNT__) {
                         if (($_POST['news_cat'] && $_POST['news_tiers']) != '') {

                              $result = SQL_VerifPostAcct
                                        (
                                             1,
                                             bcsub($_N_ID,1),
                                             0,
                                             $_POST['R'],
                                             $_POST['numero_id'],
                                             $_DATE,
                                             bcsub($id_cat,1),
                                             bcsub($id_tiers,1),
                                             $_POST['commentaires'],
                                             $_DEPENSE,
                                             $_RECETTE,
                                             $_POST['ID'],
                                             'NULL',
                                             0
                                        );

                                if (!$result) {
				      $id_cat = SQL_BuildCat($_POST['news_cat'],$id_cat);
				      $id_tiers = SQL_BuildTiers($_POST['news_tiers'],$id_cat,$id_tiers);
                                      if (isset($id_cat) && $id_cat != __PART_ID__) {
                                        ## Inserer
                                        SQL_InsertAccount
                                        (
                                                   $_N_ID,
                                                   $_POST['numero_id'],
                                                   1,
                                                   $_POST['R'],
                                                   $_DATE,
                                                   $id_cat,
                                                   $id_tiers,
                                                   $_COREL,
                                                   $_POST['commentaires'],
                                                   $_DEPENSE,
                                                   $_RECETTE,
                                                   $_POST['ID'],
                                                   0,
                                                   0
                                        );

                                        ## Dupliquer
                                        if ($submit == $_VAR['DUPLIQ']) {
                                         SQL_InsertAccount
                                         (
                                                   bcadd($_N_ID,1),
                                                   $_POST['numero_id'],
                                                   1,
                                                   $_POST['R'],
                                                   $_DATE,
                                                   $id_cat,
                                                   $id_tiers,
                                                   $_COREL,
                                                   $_POST['commentaires'],
                                                   $_DEPENSE,
                                                   $_RECETTE,
                                                   $_POST['ID'],
                                                   0,
                                                   0
                                         );
                                        }
                                      SQL_RecupSolde($_POST['ID']);
                                      }
                                 } ## end of $result

                              } ## end of $_POST['news_cat'] && $_POST['news_tiers'] != ''
                         } ## end of  of $_POST['cat'] == __ANOTHER_ACCOUNT__

                         ## NEWS ENTRY FOR THE THIRD ONLY
                         else if ($_POST['tiers'] == __ANOTHER_ACCOUNT__) {

                              $result = SQL_VerifPostAcct
                                        (
                                             1,
                                             bcsub($_N_ID,1),
                                             0,
                                             $_POST['R'],
                                             $_POST['numero_id'],
                                             $_DATE,
                                             $_POST['cat'],
                                             bcsub($id_tiers,1),
                                             $_POST['commentaires'],
                                             $_DEPENSE,
                                             $_RECETTE,
                                             $_POST['ID'],
                                             'NULL',
                                             0
                                        );
                             if (!$result) {
                              $id_tiers = SQL_BuildTiers($_POST['news_tiers'],$_POST['cat'],$id_tiers);

                                 ## Inserer
                                  SQL_InsertAccount
                                  (
                                           $_N_ID,
                                           $_POST['numero_id'],
                                           1,
                                           $_POST['R'],
                                           $_DATE,
                                           $_POST['cat'],
                                           $id_tiers,
                                           $_COREL,
                                           $_POST['commentaires'],
                                           $_DEPENSE,
                                           $_RECETTE,
                                           $_POST['ID'],
                                           0,
                                           0
                                 );

                                ## Dupliquer
                                if ($submit == $_VAR['DUPLIQ']) {
                                 SQL_InsertAccount
                                 (
                                           bcadd($_N_ID,1),
                                           $_POST['numero_id'],
                                           1,
                                           $_POST['R'],
                                           $_DATE,
                                           $_POST['cat'],
                                           $id_tiers,
                                           $_COREL,
                                           $_POST['commentaires'],
                                           $_DEPENSE,
                                           $_RECETTE,
                                           $_POST['ID'],
                                           0,
                                           0
                                 );
                                }
                             SQL_RecupSolde($_POST['ID']);
                             } ## end of !$result

                         } ## end of  of $_POST['tiers'] == __ANOTHER_ACCOUNT__

                         ## NO NEWS ENTRY FOR THIRD AND PART
                         else if ($_POST['cat'] != __ANOTHER_ACCOUNT__ || $_POST['tiers'] != __ANOTHER_ACCOUNT__) {
                              if ($_POST['cat'] == __PART_ID__) {
                                $result = SQL_VerifPostAcct
                                          (
                                             1,
                                             $_N_ID,
                                             $_COREL,
                                             $_POST['R'],
                                             $_POST['numero_id'],
                                             $_DATE,
                                             $_POST['cat'],
                                             $_POST['tiers'],
                                             $_POST['commentaires'],
                                             $_DEPENSE,
                                             $_RECETTE,
                                             $_POST['ID'],
                                             'NULL',
                                             1
                                          );
                              } else {
                                $result = SQL_VerifPostAcct
                                          (
                                             1,
                                             bcsub($_N_ID,1),
                                             0,
                                             $_POST['R'],
                                             $_POST['numero_id'],
                                             $_DATE,
                                             $_POST['cat'],
                                             $_POST['tiers'],
                                             $_POST['commentaires'],
                                             $_DEPENSE,
                                             $_RECETTE,
                                             $_POST['ID'],
                                             'NULL',
                                             0
                                         );
                              }

                             if (!$result) {
                                 ## Inserer
                                 SQL_InsertAccount
                                 (
                                             $_N_ID,
                                             $_POST['numero_id'],
                                             1,
                                             $_POST['R'],
                                             $_DATE,
                                             $_POST['cat'],
                                             $_POST['tiers'],
                                             $_COREL,
                                             $_POST['commentaires'],
                                             $_DEPENSE,
                                             $_RECETTE,
                                             $_POST['ID'],
                                             0,
                                             0
                                 );

                                 ## Dupliquer
                                 if ($submit == $_VAR['DUPLIQ']) {
                                    if ($_POST['cat'] == __PART_ID__) {
                                      $id_account = bcadd($_N_ID,2);
                                      $id_corel   = bcadd($_COREL,2);
                                    } else {
                                      $id_account = bcadd($_N_ID,1);
                                      $id_corel   = 0;
                                    }

                                  SQL_InsertAccount
                                  (
                                             $id_account,
                                             $_POST['numero_id'],
                                             1,
                                             $_POST['R'],
                                             $_DATE,
                                             $_POST['cat'],
                                             $_POST['tiers'],
                                             $id_corel,
                                             $_POST['commentaires'],
                                             $_DEPENSE,
                                             $_RECETTE,
                                             $_POST['ID'],
                                             0,
                                             0
                                  );
                                 }
                                 SQL_RecupSolde($_POST['ID']);

                                 if ($_POST['cat'] == __PART_ID__) {
                                     ## Inserer
                                     SQL_InsertAccount
                                     (
                                                $_COREL,
                                                $_POST['numero_id'],
                                                1,
                                                $_POST['R'],
                                                $_DATE,
                                                $_POST['cat'],
                                                $ID_TIERS,
                                                $_N_ID,
                                                $_POST['commentaires'],
                                                $_RECETTE,
                                                $_DEPENSE,
                                                $ID_COREL,
                                                0,
                                                0
                                     );

                                    ## Dupliquer
                                    if ($submit == $_VAR['DUPLIQ']) {
                                     SQL_InsertAccount
                                     (
                                                bcadd($_COREL,2),
                                                $_POST['numero_id'],
                                                1,
                                                $_POST['R'],
                                                $_DATE,
                                                $_POST['cat'],
                                                $ID_TIERS,
                                                bcadd($_N_ID,2),
                                                $_POST['commentaires'],
                                                $_RECETTE,
                                                $_DEPENSE,
                                                $ID_COREL,
                                                0,
                                                0
                                     );
                                    }
                                  SQL_RecupSolde($ID_COREL);
                                  } ## end of $_POST['cat'] == __PART_ID__
                             } ## end of $result

                         } ## end of $_POST['cat'] != __ANOTHER_ACCOUNT__ || ....
            } ## end of all $_POST != ''
      break;
     /**
      * SWITCH -- MODIF THE ACCOUNT OPERATION
      */
            case 'MODIF_THIS_ACCOUNT':
            if (isset($_POST['MOD_IF']) && is_array($_POST['MOD_IF']) && !$sess->is_registered('sess_reload')) {

            while(list($kmods,$sub) = each($_POST['MOD_IF'])) {
                 $ids_mods = SQL_Clean($kmods); ## MODIF
                 $submit   = $sub;   ## DUPLIQ
            }

            ## For change this account
            if (isset($_POST['MODIF_IF_ACCOUNT']) && $_POST['MODIF_IF_ACCOUNT'] != '' && isset($_POST['cat'])
               && $_POST['cat'] != __PART_ID__ && isset($_POST['ID']) && $_POST['ID'] != $_POST['MODIF_IF_ACCOUNT']) {
            $selectAccount = $_POST['MODIF_IF_ACCOUNT'];
            }

            if ($_POST['affecter'] == 1) {
	    	$_RECETTE = 0; 
		$_DEPENSE = $_POST['paie'];
	    }
            if ($_POST['affecter'] == 2) {
	    	$_DEPENSE = 0;
		$_RECETTE = $_POST['paie'];
	    }

             $valid_db->query (
                    "SELECT NUMID,VALID_OP,DATE_FORMAT(DATES,'%d-%m-%Y')
                    AS DATES,THIRD,CAT,COMMENTS,SOUTT,IMP,COREL
                    FROM ".$_MPM['table'][1]."
                    WHERE TEMPID=1
                    AND OPID='".$ids_mods."'
                    AND USERID='".$sess_pid."'
                    AND ACCOUNT='".$_POST['ID']."'"
             );

                 if ($valid_db->num_rows() == 1) {
                  $valid_db->next_record();

                 if ($_POST['R'] != $valid_db->f('VALID_OP'))
                     $cont[] .= "VALID_OP='".$_POST['R']."'";
                 if ($_POST['date'] != $valid_db->f('DATES'))
                     $cont[] .= "DATES='$_DATE'";
                 if ($_POST['commentaires'] != $valid_db->f('COMMENTS'))
                     $cont[] .= "COMMENTS='".$_POST['commentaires']."'";
                 if ($_POST['cat'] == __PART_ID__ && $valid_db->f('CAT') != __PART_ID__) {
                     $cont[] .= "COREL='".bcadd($_N_ID,1)."'";
                 } else if ($valid_db->f('CAT') == __PART_ID__) {
                     if ($_POST['cat'] == __PART_ID__) {
                        $cont[] .= "COREL='".$valid_db->f('COREL')."'";

                         ## Modifier
                         SQL_UpdateAllAccount
                         (
                             $_POST['R'],
                             $_POST['numero_id'],
                             $_DATE,
                             $ID_TIERS,
                             $_DEPENSE,
                             $_RECETTE,
                             $ID_COREL,
                             $_POST['commentaires'],
                             '',
                             1,
                             $valid_db->f('COREL')
                         );

                        ## Dupliquer
                        if ($submit == $_VAR['DUPLIQ']) {
                         SQL_InsertAccount
                         (
                                   $_N_ID,
                                   $_POST['numero_id'],
                                   1,
                                   $_POST['R'],
                                   $_DATE,
                                   $_POST['cat'],
                                   $_POST['tiers'],
                                   bcadd($_N_ID,1),
                                   $_POST['commentaires'],
                                   $_DEPENSE,
                                   $_RECETTE,
                                   $_POST['ID'],
                                   0,
                                   0
                         );
                        } ## end of if ($submit == $_VAR['DUPLIQ'])
                     SQL_RecupSolde($ID_COREL);
                     } else {
                        $cont[] .= "COREL='0'";
                        if ($ID_COREL == '') $ID_COREL = SQL_SearchInThird(1,$valid_db->f('THIRD'));

                        SQL_DeleteAccount(1,$valid_db->f('COREL'),'',0);
                        SQL_RecupSolde($ID_COREL);
                     }
                 }
                 else {
                     $cont[] .= "COREL='0'";
                 }
                 if ($_POST['cat'] != $valid_db->f('CAT')) {
                     if ($_POST['cat'] == __PART_ID__ && $valid_db->f('CAT') != __PART_ID__) {
                          $cont[] .= "CAT='".$_POST['cat']."'";

                         ## Modifier
                         SQL_InsertAccount
                         (
                                   bcadd($_N_ID,1),
                                   $_POST['numero_id'],
                                   1,
                                   $_POST['R'],
                                   $_DATE,
                                   $_POST['cat'],
                                   $ID_TIERS,
                                   $_N_ID,
                                   $_POST['commentaires'],
                                   $_RECETTE,
                                   $_DEPENSE,
                                   $ID_COREL,
                                   0,
                                   0
                         );

                        ## Dupliquer
                        if ($submit == $_VAR['DUPLIQ']) {
                         SQL_InsertAccount
                         (
                                   bcadd($_N_ID,3),
                                   $_POST['numero_id'],
                                   1,
                                   $_POST['R'],
                                   $_DATE,
                                   $_POST['cat'],
                                   $ID_TIERS,
                                   bcadd($_N_ID,2),
                                   $_POST['commentaires'],
                                   $_RECETTE,
                                   $_DEPENSE,
                                   $ID_COREL,
                                   0,
                                   0
                         );
                        } ## end of if ($submit == $_VAR['DUPLIQ'])
                     SQL_RecupSolde($ID_COREL);
                     } else if ($_POST['cat'] == __ANOTHER_ACCOUNT__) {
                          $cont[] .= "CAT='".SQL_BuildCat($_POST['news_cat'],$id_cat)."'";
                          $id_tiers = SQL_BuildTiers($_POST['news_tiers'],$id_cat,$id_tiers);
                          $cont[] .= "THIRD='$id_tiers'";
                     } else {
                          $cont[] .= "CAT='".$_POST['cat']."'";
                     }
                 }
                 if (isset($_POST['tiers']) && $_POST['tiers'] != $valid_db->f('THIRD')) {
                     if ($_POST['tiers'] == __ANOTHER_ACCOUNT__) {
                          $id_tiers = SQL_BuildTiers($_POST['news_tiers'],$_POST['cat'],$id_tiers);
                          $cont[] .= "THIRD='$id_tiers'";
                     }
                     else if (isset($_POST['tiers'])) {
                          $cont[] .= "THIRD='".$_POST['tiers']."'";
                     }
                 }

             if ($valid_db->f('IMP') == 0)      $paies = $valid_db->f('SOUTT');
             else if ($valid_db->f('SOUTT') == 0) $paies = $valid_db->f('IMP');

             if ($_POST['paie'] != $paies) {

                 if ($_POST['affecter'] == 1) {
                      $cont[] .= "SOUTT='".$_POST['paie']."'";
                      $cont[] .= "IMP='0'";
                 } else if ($_POST['affecter'] == 2) {
                      $cont[] .= "SOUTT='0'";
                      $cont[] .= "IMP='".$_POST['paie']."'";
                 }
             }
             if ($_POST['affecter'] == 1 && $valid_db->f('SOUTT') == 0) {
                      $cont[] .= "IMP='0'";
                      $cont[] .= "SOUTT='".$_POST['paie']."'";
             } else if ($_POST['affecter'] == 2 && $valid_db->f('IMP') == 0) {
                      $cont[] .= "SOUTT='0'";
                      $cont[] .= "IMP='".$_POST['paie']."'";
             }

             if (isset($_POST['numero_id']) && $_POST['numero_id'] != $valid_db->f('NUMID')) {
                      $cont[] .= "NUMID='".$_POST['numero_id']."'";
             } else {
                      $cont[] .= "NUMID='".$valid_db->f('NUMID')."'";
             }

            ## Change this operation for the new account
            if ($selectAccount != '') $cont[] .= "ACCOUNT='".$selectAccount."'";

        if (sizeof($cont) > 0) $liste = join($cont," , ");

             if ($_POST['cat'] != '' && $valid_db->f('CAT') == __PART_ID__) {

               ## Modifier
               SQL_UpdateAccount(8,$liste,'','',1,$ids_mods);

               ## Dupliquer
               if ($submit == $_VAR['DUPLIQ']) {
                SQL_InsertAccount
                (
                        bcadd($_N_ID,1),
                        $_POST['numero_id'],
                        1,
                        $_POST['R'],
                        $_DATE,
                        $_POST['cat'],
                        $ID_TIERS,
                        $_N_ID,
                        $_POST['commentaires'],
                        $_RECETTE,
                        $_DEPENSE,
                        $ID_COREL,
                        0,
                        0
                );
               } ## end of if ($submit == $_VAR['DUPLIQ'])
             SQL_RecupSolde($_POST['ID']);
             }
             else if ($_POST['cat'] == __PART_ID__ && $valid_db->f('CAT') != __PART_ID__) {

               ## Modifier
               SQL_UpdateAccount(7,$liste,$_N_ID,$_POST['ID'],1,$ids_mods);

               ## Dupliquer
               if ($submit == $_VAR['DUPLIQ']) {
                SQL_InsertAccount
                (
                        bcadd($_N_ID,2),
                        $_POST['numero_id'],
                        1,
                        $_POST['R'],
                        $_DATE,
                        $_POST['cat'],
                        $_POST['tiers'],
                        bcadd($_N_ID,3),
                        $_POST['commentaires'],
                        $_DEPENSE,
                        $_RECETTE,
                        $_POST['ID'],
                        0,
                        0
                );
               } ## end of if ($submit == $_VAR['DUPLIQ'])
             SQL_RecupSolde($_POST['ID']);
             }
             else {

               ## Modifier
               SQL_UpdateAccount(6,$liste,'',$_POST['ID'],1,$ids_mods);
               if ($selectAccount != '') SQL_RecupSolde($_POST['ID']);

               ## Change this operation for the new account
               ## This place is important (must be after the SQL_UpdateAccount)
               if ($selectAccount != '') {
                  $_POST['ID'] = $selectAccount;
                  $name_account = SQL_NameAccount($_POST['ID']);
               }

               ## Dupliquer
               if ($submit == $_VAR['DUPLIQ']) {
                SQL_InsertAccount
                (
                        $_N_ID,
                        $_POST['numero_id'],
                        1,
                        $_POST['R'],
                        $_DATE,
                        isset($_POST['cat']) && $_POST['cat'] != __ANOTHER_ACCOUNT__ ? $_POST['cat'] : $id_cat,
                        isset($_POST['tiers']) && $_POST['tiers'] != __ANOTHER_ACCOUNT__ ? $_POST['tiers'] : $id_tiers,
                        0,
                        $_POST['commentaires'],
                        $_DEPENSE,
                        $_RECETTE,
                        $_POST['ID'],
                        0,
                        0
                 );
               } ## end of if ($submit == $_VAR['DUPLIQ'])
              SQL_RecupSolde($_POST['ID']);
             }
        } ## end of if ($valid_db->num_rows() == 1)

        $sess_reload = 1;
      $sess->register('sess_reload');
      } ## end of if (isset($_POST['MOD_IF']) && !$sess->is_registered('sess_reload'))

      ## RETURN DEFAULT VALUE FOR THE FORM -- NOT RELOAD SO NECESSARY
      $_POST['opt'] = 'ADD_ACCOUNT';
      break;
      } ## end of switch $opt

/**
 * BUILD THE HEADER (THIS PLACE IS IMPORTANTE FOR MENU SELECT ADD ACCOUNT)
 */
     XHTML_header(1,1,1,1,0,0,0,1);

/**
 * RECUP THE ID FOR THE MODIFIED ACCOUNT OPERATION
 */
     if (isset($_POST['MODIF_ACCOUNT']) && is_array($_POST['MODIF_ACCOUNT'])) {
          while(list($kmod) = each($_POST['MODIF_ACCOUNT'])) $id_mod = $kmod;
     }

/**
 * BUILD DETAIL LIST FOR THE ACCOUNT LIST
 */
    if (isset($_POST['date'])) $_RECUP = explode('-',SQL_Clean($_POST['date']));
    if (isset($_RECUP) && is_array($_RECUP)) $The_mois = "$_RECUP[1]-$_RECUP[2]";
    else if (!isset($_POST['The_mois']) || $_POST['The_mois'] == '') $The_mois = date('m-Y', time());
    else $The_mois = SQL_Clean($_POST['The_mois']);

    if (!isset($_POST['ID'])) $_POST['ID'] = SQL_IdAccount('');
    if ($_POST['opt'] == '') $_POST['opt'] = 'ADD_ACCOUNT';

/**
 * SQL ORDER BY ... ASC ... DESC
 */
       SQL_Orderby($PageOrder,1);
       if (isset($_POST['order1'][$PageOrder]) && strpos($_POST['order1'][$PageOrder], "_") !== false ) {
       $this_order = explode("_",$_POST['order1'][$PageOrder]);
          if ($this_order[1] == 0) $order = $this_order[0];
          if (!isset($order))      $order = 'asc';
      } else {
        $order = 'asc';
     }

/**
 * TITLE FOR ACCOUNT NAME
 */
      printf("\n<h1 class=\"centerColor\">%s [%s] %s</h1>\n",$_VAR['LANG_ACCOUNT_4'],$name_account,XHTML_OPEN_CLOSE());

/**
 * ADD THE NEW OPERATE
 */
      if ($order == 'desc') include_once $_MPM['file_newop']; else include_once  $_MPM['file_listop'];

/**
 * SEPARATOR HR
 */
      echo "\n<div id=\"LayerTable2\" class=\"centerhr\"><div class=\"blockhr2\"><hr /></div><br /></div>\n";

/**
 * LIST FOR OPERATE
 */
      if ($order == 'desc') include_once  $_MPM['file_listop']; else include_once $_MPM['file_newop'];

     } else {
          XHTML_DisplayLogin();
     } ## end if (SQL_VerifSession())
/**
 * BUILD THE FOOTER
 */
     XHTML_footer();
Return current item: MyPhpMoney