Exemplo n.º 1
0
 function Add($array)
 {
     /** 
      * Check needed info
      */
     $p_nom_mod = HtmlInput::default_value('nom_mod', "", $array);
     $p_fd_description = HtmlInput::default_value('fd_description', "", $array);
     $p_class_base = HtmlInput::default_value('class_base', "", $array);
     $p_fiche_def = HtmlInput::default_value('FICHE_REF', "", $array);
     $p_create = HtmlInput::default_value('create', "off", $array);
     // If there is no description then add a empty one
     if (!isset($p_fd_description)) {
         $p_fd_description = "";
     }
     // Format correctly the name of the cat. of card
     $p_nom_mod = sql_string($p_nom_mod);
     // Name can't be empty
     if (strlen(trim($p_nom_mod)) == 0) {
         alert(_('Le nom de la catégorie ne peut pas être vide'));
         return 1;
     }
     // $p_fiche_def can't be empty
     if (strlen(trim($p_fiche_def)) == 0) {
         alert(_('Un modéle de catégorie est obligatoire'));
         return 1;
     }
     /* check if the cat. name already exists */
     $sql = "select count(*) from fiche_Def where upper(fd_label)=upper(\$1)";
     $count = $this->cn->get_value($sql, array(trim($p_nom_mod)));
     if ($count != 0) {
         echo alert(_('Catégorie existante'));
         return 1;
     }
     // Set the value of fiche_def.fd_create_account
     // automatic creation for 'poste comptable'
     if ($p_create == "on" && strlen(trim($p_class_base)) != 0) {
         $p_create = 'true';
     } else {
         $p_create = 'false';
     }
     // Class is valid ?
     if (sql_string($p_class_base) != null || $p_class_base != '' && strpos(',', $p_class_base) != 0) {
         // p_class is a valid number
         $sql = "insert into fiche_def(fd_label,fd_class_base,frd_id,fd_create_account,fd_description)\n                 values (\$1,\$2,\$3,\$4,\$5) returning fd_id";
         $fd_id = $this->cn->get_value($sql, array($p_nom_mod, $p_class_base, $p_fiche_def, $p_create, $p_fd_description));
         // p_class must be added to tmp_pcmn if it is a single accounting
         if (strpos(',', $p_class_base) == 0) {
             $sql = "select account_add(\$1,\$2)";
             $Res = $this->cn->exec_sql($sql, array($p_class_base, $p_nom_mod));
         }
         // Get the fd_id
         $fd_id = $this->cn->get_current_seq('s_fdef');
         // update jnt_fic_attr
         $sql = sprintf("insert into jnt_fic_attr(fd_id,ad_id,jnt_order)\n\t\t\t\t\t values (%d,%d,10)", $fd_id, ATTR_DEF_ACCOUNT);
         $Res = $this->cn->exec_sql($sql);
     } else {
         //There is no class base not even as default
         $sql = "insert into fiche_def(fd_label,frd_id,fd_create_account,fd_description) values (\$1,\$2,\$3,\$4) returning fd_id";
         $this->id = $this->cn->get_value($sql, array($p_nom_mod, $p_fiche_def, $p_create, $p_fd_description));
         // Get the fd_id
         $fd_id = $this->cn->get_current_seq('s_fdef');
     }
     // Get the default attr_def from attr_min
     $def_attr = $this->get_attr_min($p_fiche_def);
     //if defaut attr not null
     // build the sql insert for the table attr_def
     if (sizeof($def_attr) != 0) {
         // insert all the mandatory fields into jnt_fiche_attr
         $jnt_order = 10;
         foreach ($def_attr as $i => $v) {
             $order = $jnt_order;
             if ($v['ad_id'] == ATTR_DEF_NAME) {
                 $order = 0;
             }
             $count = $this->cn->get_value("select count(*) from jnt_fic_attr where fd_id=\$1 and ad_id=\$2", array($fd_id, $v['ad_id']));
             if ($count == 0) {
                 $sql = sprintf("insert into jnt_fic_Attr(fd_id,ad_id,jnt_order)\n                             values (%d,%s,%d)", $fd_id, $v['ad_id'], $order);
                 $this->cn->exec_sql($sql);
                 $jnt_order += 10;
             }
         }
     }
     $this->id = $fd_id;
     return 0;
 }
$last_day = $a[1]->last_day();
// filter on period
$date_from = new IDate('from_periode');
$date_to = new IDate('to_periode');
$year = $g_user->get_exercice();
$date_from->value = isset($_REQUEST['from_periode']) && isDate($_REQUEST['from_periode']) != 0 ? $_REQUEST['from_periode'] : $first_day;
$date_to->value = isset($_REQUEST['to_periode']) && isDate($_REQUEST['to_periode']) != 0 ? $_REQUEST['to_periode'] : $last_day;
echo td(_('Depuis') . $date_from->input());
echo td(_('Jusque ') . $date_to->input());
$letter = new ICheckbox('letter');
$letter->selected = isset($_REQUEST['letter']) ? true : false;
$from_poste = new IPoste('from_poste');
$from_poste->value = HtmlInput::default_value('from_poste', '', $_REQUEST);
$from_poste->set_attribute('account', 'from_poste');
$to_poste = new IPoste('to_poste');
$to_poste->value = HtmlInput::default_value('to_poste', '', $_REQUEST);
$to_poste->set_attribute('account', 'to_poste');
$solded = new ICheckbox('solded');
$solded->selected = isset($_REQUEST['solded']) ? true : false;
echo '<tr>';
echo td(_('Depuis le poste')) . td($from_poste->input());
echo '</tr>';
echo '<tr>';
echo td(_("Jusqu'au poste")) . td($to_poste->input());
echo '</tr>';
echo '<tr>';
echo td(_('Uniquement les opérations non lettrées'));
echo td($letter->input());
echo '</tr>';
echo '<tr>';
echo td(_('Uniquement les comptes non soldés'));
Exemplo n.º 3
0
	</div>
    <div style="clear:both;"></div>
    <div class="name">

<?php 
if ($cn->get_value("select count(*) from profile join profile_user using (p_id)\n\t\twhere user_name=\$1 and with_calc=true", array($_SESSION['g_user'])) == 1) {
    echo '<div id="calc">';
    echo IButton::show_calc();
    echo '</div>';
}
if ($cn->get_value("select count(*) from profile join profile_user using (p_id)\n\t\twhere user_name=\$1 and with_direct_form=true", array($_SESSION['g_user'])) == 1) {
    ?>
	<div id="direct">
	<form method="get">
		<?php 
    echo HtmlInput::default_value('ac', '', $_REQUEST);
    ?>
		<?php 
    echo Dossier::hidden();
    ?>
		<?php 
    $direct = new IText('ac');
    $direct->style = 'class="input_text"';
    $direct->value = '';
    $direct->size = 20;
    echo $direct->input();
    $gDossier = dossier::id();
    ?>
		<div id="ac_choices" class="autocomplete" style="width:150"></div>
		<?php 
    echo HtmlInput::submit('go', _('Aller'));
Exemplo n.º 4
0
 function search_box($p_array)
 {
     // Declaration
     global $g_user;
     $wrepo = HtmlInput::select_stock($this->cn, "wrepo", 'R');
     $wrepo->value[] = array('value' => -1, 'label' => 'Tous les dépôts');
     $wdate_start = new IDate('wdate_start');
     $wdate_end = new IDate('wdate_end');
     $wamount_start = new INum('wamount_start');
     $wamount_end = new INum('wamount_end');
     $wcard = new ICard('wcard');
     $wcode_stock = new ICard('wcode_stock');
     $wdirection = new ISelect("wdirection");
     // value
     $wrepo->selected = HtmlInput::default_value("wrepo", -1, $p_array);
     // Date start / end
     $exercice = $g_user->get_exercice();
     $periode = new Periode($this->cn);
     list($periode_start, $periode_end) = $periode->get_limit($exercice);
     $wdate_start->value = HtmlInput::default_value("wdate_start", $periode_start->first_day(), $p_array);
     $wdate_end->value = HtmlInput::default_value("wdate_end", $periode_end->last_day(), $p_array);
     //amounts
     $wamount_start->value = HtmlInput::default_value("wamount_start", 0, $p_array);
     $wamount_end->value = HtmlInput::default_value("wamount_end", 0, $p_array);
     //Card
     $wcard->extra = "all";
     $wcard->set_attribute("typecard", "all");
     $wcard->value = HtmlInput::default_value("wcard", "", $p_array);
     //Card stock
     $wcode_stock->extra = " [sql] fd_id=500000 ";
     $wcode_stock->set_attribute("typecard", "[sql] fd_id=500000");
     $wcode_stock->value = HtmlInput::default_value("wcard", "", $p_array);
     // Repository
     $wcode_stock->value = HtmlInput::default_value("wcode_stock", "", $p_array);
     //Direction
     $wdirection->value = array(array('value' => "-1", 'label' => "Tout"), array('value' => "c", 'label' => "OUT"), array('value' => "d", 'label' => "IN"));
     $wdirection->selected = HtmlInput::default_value("wdirection", "-1", $p_array);
     require_once NOALYSS_INCLUDE . '/template/stock_histo_search.php';
 }
Exemplo n.º 5
0
 /**
  *@brief get the parameters
  */
 function get_request()
 {
     parent::get_request();
     $this->card_poste = HtmlInput::default_value('card_poste', 1, $_GET);
 }
Exemplo n.º 6
0
    $ck_lev2->selected = true;
}
if (HtmlInput::default_value('lvl3', false, $_GET) !== false) {
    $ck_lev3->selected = true;
}
echo '<li>' . $ck_lev1->input() . _('Niveau 1') . '</li>';
echo '<li>' . $ck_lev2->input() . _('Niveau 2') . '</li>';
echo '<li>' . $ck_lev3->input() . _('Niveau 3') . '</li>';
echo '</ul>';
$unsold = new ICheckBox('unsold');
if (HtmlInput::default_value('unsold', false, $_GET) !== false) {
    $unsold->selected = true;
}
// previous exercice if checked
$previous_exc = new ICheckBox('previous_exc');
if (HtmlInput::default_value('previous_exc', false, $_GET) !== false) {
    $previous_exc->selected = true;
}
$from_poste = new IPoste();
$from_poste->name = "from_poste";
$from_poste->set_attribute('ipopup', 'ipop_account');
$from_poste->set_attribute('label', 'from_poste_label');
$from_poste->set_attribute('account', 'from_poste');
$from_poste->value = isset($_GET['from_poste']) ? $_GET['from_poste'] : "";
$from_span = new ISpan("from_poste_label", "");
$to_poste = new IPoste();
$to_poste->name = "to_poste";
$to_poste->set_attribute('ipopup', 'ipop_account');
$to_poste->set_attribute('label', 'to_poste_label');
$to_poste->set_attribute('account', 'to_poste');
$to_poste->value = isset($_GET['to_poste']) ? $_GET['to_poste'] : "";
Exemplo n.º 7
0
 /**
  * Return an array, used by Stock_Goods::input 
  * @global type $cn
  * @param type $p_array
  * @throws Exception
  */
 function take_last_inventory($p_array)
 {
     global $cn;
     $year = HtmlInput::default_value("p_exercice", "", $p_array);
     $depot = HtmlInput::default_value("p_depot", "", $p_array);
     if ($year == "") {
         throw new Exception(_('Inventaire invalide'), 10);
     }
     if ($depot == "") {
         throw new Exception(_('Dépôt invalide'), 20);
     }
     // compute state_exercice
     $periode = new Periode($cn);
     $periode->p_id = $cn->get_value("select min(p_id) from parm_periode where p_exercice=\$1", array($year));
     $first_day = $periode->first_day();
     // compute array for stock
     $array['state_exercice'] = $first_day;
     $stock = new Stock($cn);
     $rowid = $stock->build_tmp_table($array);
     // compute first day of the next year
     $next_year = $year + 1;
     $periode = new Periode($cn);
     $periode->p_id = $cn->get_value("select min(p_id) from parm_periode where p_exercice=\$1", array($next_year));
     if ($periode->p_id == "") {
         $array['p_date'] = "";
     } else {
         $array['p_date'] = $periode->first_day();
     }
     // Compute an array compatible with Stock_Goods::input
     $array['p_motif'] = _('Inventaire ') . $year;
     $array['p_depot'] = $depot;
     $result = $cn->get_array("\n                select sg_code,sum(coalesce(s_qin,0)-coalesce(s_qout,0)) tot_\n                from tmp_stockgood_detail \n                where \n                s_id=\$1 and r_id=\$2 \n                group by sg_code", array($rowid, $depot));
     for ($e = 0; $e < count($result); $e++) {
         $array['sg_code' . $e] = $result[$e]['sg_code'];
         $array['sg_quantity' . $e] = $result[$e]['tot_'];
     }
     $array['row'] = $e;
     return $array;
 }
Exemplo n.º 8
0
    die('Appel direct ne sont pas permis');
}
require_once NOALYSS_INCLUDE . '/class_acc_payment.php';
require_once NOALYSS_INCLUDE . '/class_sort_table.php';
//---------------------------------------------------------------------------
// Common variable
$td = '<TD>';
$etd = '</td>';
$tr = '<tr>';
$etr = '</tr>';
$th = '<th>';
$eth = '</th>';
/*!\file
 * \brief payment mode
 */
$sb = HtmlInput::default_value('sb', "", $_REQUEST);
echo '<div class="content">';
//----------------------------------------------------------------------
// change
if ($sb == 'change') {
    if (!isset($_GET['id'])) {
        exit;
    }
    $row = new Acc_Payment($cn, $_GET['id']);
    $row->load();
    echo '<form method="post" id="modify_acc_pay_frm" onsubmit="return confirm_box(\'modify_acc_pay_frm\',\'' . _('Vous confirmez') . '\')">';
    echo dossier::hidden();
    echo HtmlInput::hidden('sa', 'mp');
    echo HtmlInput::hidden('sb', 'save');
    echo HtmlInput::hidden('id', $row->get_parameter("id"));
    echo HtmlInput::hidden('delete_ck', 0);
Exemplo n.º 9
0
 /**
 * @brief save the data of a repartition key.
 * @param received an array
 * index :
 *   - key_id : key_distribution.kd_id
 *   - row : array of key_distribution.ke_id (row
 *   - pa : array of plan_analytic.pa_id (column)
 *   - po_id : double array, 
 *              first index is the row
 *              second  index is the first plan, the second the second plan...(column)
 *   - percent array, one per row
 *   - jrn : array of available ledgers
 * @note  if po_id == -1 then it is replaced by null, this why the pa_id is needed : to identify
 *  the column
 * @verbatim
 
    'key_id' => string '1' (length=1)
    'row' => 
      array
        0 => string '1' (length=1)
        1 => string '2' (length=1)
        2 => string '3' (length=1)
    'pa' => 
      array
        0 => string '1' (length=1)
        1 => string '2' (length=1)
    'po_id' => 
      array
        0 => 
          array
            0 => string '1' (length=1)
            1 => string '8' (length=1)
        1 => 
          array
            0 => string '2' (length=1)
            1 => string '-1' (length=2)
        2 => 
          array
            0 => string '3' (length=1)
            1 => string '8' (length=1)
    'percent' => 
      array
        0 => string '50.0000' (length=7)
        1 => string '20.0000' (length=7)
        2 => string '30.0000' (length=7)
    'jrn' => 
      array
        0 => string '3' (length=1)
        1 => string '2' (length=1)
  @endverbatim
 * 
 */
 function save($p_array)
 {
     global $cn;
     $this->verify($p_array);
     $cn->start();
     // for each row
     $a_row = $p_array['row'];
     $a_ledger = HtmlInput::default_value("jrn", array(), $p_array);
     $a_percent = $p_array['percent'];
     $a_po_id = $p_array['po_id'];
     $a_plan = $p_array['pa'];
     try {
         $this->key->setp('name', $p_array['name_key']);
         $this->key->setp('description', $p_array['description_key']);
         $this->key->save();
         for ($i = 0; $i < count($a_row); $i++) {
             //save key_distribution_row
             $key_row = new Anc_Key_Detail_SQL($cn);
             $key_row->setp('id', $a_row[$i]);
             $key_row->setp('key', $this->key->getp('id'));
             $key_row->setp('row', $i + 1);
             $key_row->setp('percent', $a_percent[$i]);
             $key_row->save();
             //
             // Save each activity + percent
             $cn->exec_sql('delete from key_distribution_activity where ke_id=$1', array($key_row->getp('id')));
             // Don't save row with 0 %
             if ($a_percent[$i] == 0) {
                 $key_row->delete();
                 continue;
             }
             for ($j = 0; $j < count($a_po_id[$i]); $j++) {
                 $activity = new Anc_Key_Activity_SQL($cn);
                 $activity->setp('detail', $key_row->ke_id);
                 $value = $a_po_id[$i][$j] == -1 ? null : $a_po_id[$i][$j];
                 $activity->setp('activity', $value);
                 $activity->setp('plan', $a_plan[$j]);
                 $activity->save();
             }
         }
         // delete all from key_distribution_ledger
         $cn->exec_sql('delete from key_distribution_ledger where kd_id=$1', array($this->key->getp('id')));
         for ($k = 0; $k < count($a_ledger); $k++) {
             $ledger = new Anc_Key_Ledger_SQL($cn);
             $ledger->kd_id = $this->key->getp('id');
             $ledger->jrn_def_id = $a_ledger[$k];
             $ledger->save();
         }
         $cn->commit();
     } catch (Exception $e) {
         if (DEBUG) {
             echo $e->getTraceAsString();
             var_dump($_POST);
         } else {
             echo _('erreur');
         }
         $cn->rollback();
     }
 }
Exemplo n.º 10
0
}
require_once NOALYSS_INCLUDE . '/class_itext.php';
require_once NOALYSS_INCLUDE . '/class_ihidden.php';
require_once NOALYSS_INCLUDE . '/class_ibutton.php';
require_once NOALYSS_INCLUDE . '/class_database.php';
require_once NOALYSS_INCLUDE . '/ac_common.php';
require_once NOALYSS_INCLUDE . '/class_dossier.php';
require_once NOALYSS_INCLUDE . '/class_anc_account.php';
require_once NOALYSS_INCLUDE . '/class_anc_plan.php';
require_once NOALYSS_INCLUDE . '/function_javascript.php';
echo HtmlInput::title_box(_("Recherche activité"), $ctl);
//------------- FORM ----------------------------------
echo '<FORM id="anc_search_form" METHOD="GET" onsubmit="search_anc_form(this);return false">';
echo '<span>' . _('Recherche') . ':';
$texte = new IText('plabel');
$texte->value = HtmlInput::default_value('plabel', "", $_GET);
echo $texte->input();
echo '</span>';
echo dossier::hidden();
$hid = new IHidden();
echo $hid->input("c1", $_REQUEST['c1']);
echo $hid->input("c2", $_REQUEST['c2']);
echo $hid->input("go");
echo HtmlInput::submit("go", _("Recherche"));
echo '</form>';
//------------- FORM ----------------------------------
if (isset($_REQUEST['go'])) {
    $cn = Dossier::connect();
    $plan = new Anc_Plan($cn, $_REQUEST['c2']);
    $plan->pa_id = $_REQUEST['c2'];
    if ($plan->exist() == false) {
Exemplo n.º 11
0
 *
 */
if (!defined('ALLOWED')) {
    die('Appel direct ne sont pas permis');
}
require_once NOALYSS_INCLUDE . '/class_dossier.php';
require_once NOALYSS_INCLUDE . '/ac_common.php';
require_once NOALYSS_INCLUDE . '/class_database.php';
require_once NOALYSS_INCLUDE . '/class_user.php';
require_once NOALYSS_INCLUDE . '/user_menu.php';
require_once NOALYSS_INCLUDE . '/class_acc_ledger.php';
$gDossier = dossier::id();
global $cn;
$show_menu = 1;
$ledger = new Acc_Ledger($cn, -1);
$sa = HtmlInput::default_value("sa", "", $_REQUEST);
//////////////////////////////////////////////////////////////////////////
// Perform request action : update
//////////////////////////////////////////////////////////////////////////
$action_frm = HtmlInput::default_value_post('action_frm', '');
if ($action_frm == 'update') {
    try {
        $ledger->id = $_POST['p_jrn'];
        if ($ledger->load() == -1) {
            throw new Exception(_('Journal inexistant'));
        }
        $ledger->verify_ledger($_POST);
        $ledger->update($_POST);
        $show_menu = 1;
    } catch (Exception $e) {
        alert($e->getMessage());