Location: PHPKode > projects > MyPhpMoney > myphpmoney_2.0/public_html/newop.php
<?php
/**
 * $Id: newop.php 418 2007-05-17 17:29:45Z 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/
 *
 * Suggested by Bernard BOISJOT
 */

$_POST['ID'] = SQL_Clean($_POST['ID']);

/**
 * RECUP THE VALUE FOR CONTRUCT THE MODIFIED ACCOUNT FORMULAIRE
 */
 if (isset($sess_pid) && is_object($sess) && $sess->is_registered('sess_pid')) {
     if (isset($_POST['MODIF_ACCOUNT']) && is_array($_POST['MODIF_ACCOUNT'])) {

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

              if ($db->f('IMP') == 0) {
                    $paies = $db->f('SOUTT');
                    $affecters = 1;
              }

              if ($db->f('SOUTT') == 0) {
                    $paies = $db->f('IMP');
                    $affecters = 2;
              }

            $_POST['opt']           = 'MODIF_THIS_ACCOUNT';
            $_POST['date']          = $db->f('DATES');
            $_POST['commentaires']  = $db->f('COMMENTS');
            $_POST['paie']          = $paies;
            $_POST['numero_id']     = $db->f('NUMID');
            $_POST['R']             = $db->f('VALID_OP');
            $_POST['tiers']         = $db->f('THIRD');
            $_POST['cat']           = $db->f('CAT');
            $_POST['affecter']      = $affecters;
           }
     }

/**
 * BUILD FORMULAIRE FOR ADD ACCOUNT AND MODIFIED ACCOUNT (SAME CODE)
 */
          $_MPM['BeginMixed'] = array
          (
               'LANG_ACCOUNT_17'    => $_VAR['LANG_ACCOUNT_17'],
               'LANG_ACCOUNT_18'    => $_VAR['LANG_ACCOUNT_18'],
               'LANG_ACCOUNT_21'    => $_VAR['LANG_ACCOUNT_21'],
               'LANG_ACCOUNT_24'    => $_VAR['LANG_ACCOUNT_24'],
               'LANG_ACCOUNT_25'    => $_VAR['LANG_ACCOUNT_25'],
               'LANG_ACCOUNT_26'    => $_VAR['LANG_ACCOUNT_26'],
               'LANG_ACCOUNT_27'    => $_VAR['LANG_ACCOUNT_27'],
               'ACCOUNT_ANOTHER'    => $_VAR['ACCOUNT_ANOTHER'],
               'SIMUL_ENTER_FORM_2' => $_VAR['SIMUL_ENTER_FORM_2'],
               'THIS_ACTION_MODE'   => $_POST['opt'],
               'SIMUL_FORM_2'       => $_VAR['SIMUL_FORM_2'],
               'SCROLL'             => $order == 'desc' ? 'THAT' : 'THIS',
               'NAME_COMPTE'        => $name_account
          );
          XHTML_SetFile('form_add_account.tpl','',0);

          $db->query (
                    "SELECT DISTINCT CAT,CATID
                    FROM ".$_MPM['table'][0]."
                    WHERE USERID='$sess_pid'
                    AND CAT <> ''
                    ".$_MPM['other_open']." ".$_MPM['other']."
                    ORDER BY CAT ASC"
           );

     $tpl->set_block('FILE_form_add_account.tpl', 'BOUCLE_ADD_ACCOUNT', 'BLOCK_form_add_account.tpl');
     while ($db->next_record()) {

     $tpl->set_var(array(
       'SEQUENCE_ID'      => $db->f('CATID'),
       'SEQUENCE_VALUE'   => $tools->Reduit_chaine($db->f('CAT'),__LENGTH_ACCOUNT__,0),
       'SELECTED'         => isset($_POST['cat']) && ($_POST['cat'] == $db->f('CATID')) && ($_POST['opt'] != 'ADD_ACCOUNT')
                                   ? ' selected="selected"' : ''
     ));
     $tpl->parse('BLOCK_form_add_account.tpl','BOUCLE_ADD_ACCOUNT',true);
     } ## end of while

   $nb_account = SQL_CountThird(__PART_ID__);
   $_MPM['BoucleMixed'] = array
   (
     'ID_ACCOUNT'         => $_POST['ID'],
     'ACCOUNT_ADD_VAL_1'  => isset($_POST['date']) && ($_POST['date'] != '') && ($_POST['opt'] != 'ADD_ACCOUNT')
                               ? $_POST['date'] : date('d-m-Y'),
     'ACCOUNT_ADD_VAL_2'  => isset($_POST['commentaires']) && ($_POST['commentaires'] != '') && ($_POST['opt'] != 'ADD_ACCOUNT')
                               ? stripslashes($_POST['commentaires']) : '',
     'ACCOUNT_ADD_VAL_3'  => isset($_POST['paie']) && ($_POST['paie'] != '') && ($_POST['opt'] != 'ADD_ACCOUNT')
                               ? $_POST['paie'] : '0.00',
     'ACCOUNT_ADD_VAL_4'  => isset($_POST['numero_id']) && ($_POST['numero_id'] != '') && ($_POST['opt'] != 'ADD_ACCOUNT')
                               ? $_POST['numero_id'] : '',
     'SELECTED_1'         => isset($_POST['cat']) && ($_POST['cat'] != '') && ($_POST['opt'] != 'ADD_ACCOUNT')
                               ? '' : ' selected="selected"',
     'SELECTED_AFF_1'     => isset($_POST['affecter']) && ($_POST['affecter'] == 1) && ($_POST['opt'] != 'ADD_ACCOUNT')
                               ? ' selected="selected"' : '',
     'SELECTED_AFF_2'     => isset($_POST['affecter']) && ($_POST['affecter'] == 2) && ($_POST['opt'] != 'ADD_ACCOUNT')
                               ? ' selected="selected"' : '',
     'CHECKED_R_1'        => isset($_POST['R']) && ($_POST['R'] == 1) && ($_POST['opt'] != 'ADD_ACCOUNT')
                               ? ' checked="checked"' : '',
     'CHECKED_R_2'        => isset($_POST['R']) && ($_POST['R'] == 1) && ($_POST['opt'] != 'ADD_ACCOUNT')
                               ? '' : ' checked="checked"',
     'CHOIX_LANG_ACCOUNT' => isset($_POST['MODIF_ACCOUNT']) && is_array($_POST['MODIF_ACCOUNT'])
                               ? $_VAR['LANG_ACCOUNT_34'] : $_VAR['LANG_ACCOUNT_23'],
     'CHOIX_DUPLIQ'       => $_POST['opt'] == 'ADD_ACCOUNT' || isset($_POST['cat']) && $_POST['cat'] == 1 || $nb_account <= 1
                               ? 'changeName_hidden();' : 'changeName_show();',
     'VERIF_BUTTON'       => $_POST['opt'] == 'MODIF_THIS_ACCOUNT' && $nb_account > 1 ? 1 : 0,
     'CHOIX_ACCOUNT_S'    => $nb_account > 1 ? SQL_ChangeAccount($_POST['ID']) : '',
     'NBR_ACCOUNT'        => isset($id_mod) ? $id_mod : '',
     'CHOIX_MODIF'        => $_POST['opt'] == 'ADD_ACCOUNT' ? $_VAR['VALIDER'] : $_VAR['MODIF'],
     'DUPLIQ'             => $_VAR['DUPLIQ'],
     'CHANG_ACCOUNT_NAME' => $_VAR['CHANG_ACCOUNT_NAME']
   );
XHTML_SetFile('form_add_account.tpl',array_merge($_MPM['BeginMixed'],$_MPM['BoucleMixed']),4);
}
Return current item: MyPhpMoney