Commit 3f6c1205485cb000a227b58b1617a0859cf9e4ec

Authored by Florian HENRY
1 parent e84ef7af
Exists in 3.5 and in 1 other branch 3.6

j'attend demain

accountingex/admin/fiche.php
... ... @@ -118,6 +118,28 @@ else if ($action == 'edit') {
118 118 header("Location: " . $_SERVER ["PHP_SELF"] . "?id=" . $id);
119 119 exit();
120 120 }
  121 +} else if ($action == 'disable') {
  122 +
  123 + $result = $accounting->fetch($id);
  124 + if (! empty($accounting->id)) {
  125 + $result = $accounting->account_desactivate($user);
  126 + }
  127 +
  128 + $action = 'update';
  129 + if ($result < 0) {
  130 + setEventMessage($accounting->error, 'errors');
  131 + }
  132 +} else if ($action == 'enable') {
  133 +
  134 + $result = $accounting->fetch($id);
  135 +
  136 + if (! empty($accounting->id)) {
  137 + $result = $accounting->account_activate($user);
  138 + }
  139 + $action = 'update';
  140 + if ($result < 0) {
  141 + setEventMessage($accounting->error, 'errors');
  142 + }
121 143 } else if ($action == 'delete') {
122 144  
123 145 $result = $accounting->fetch($id);
... ... @@ -144,6 +166,8 @@ llxheader(&#39;&#39;, $langs-&gt;trans(&#39;AccountAccounting&#39;));
144 166 $form = new Form($db);
145 167 $htmlacc = new FormVentilation($db);
146 168  
  169 +$linkback = '<a href="' . DOL_URL_ROOT . '/accountingex/admin/account.php">' . $langs->trans("BackToChartofaccounts") . '</a>';
  170 +
147 171 if ($action == 'create') {
148 172  
149 173 print_fiche_titre($langs->trans('NewAccount'));
... ...
accountingex/class/html.formventilation.class.php
... ... @@ -87,6 +87,7 @@ class FormVentilation extends Form {
87 87 * @param string $selectedid pcg_type
88 88 * @param string $htmlname of combo list
89 89 * @param int $showempty en empty line
  90 + * @param array $event js event array
90 91 *
91 92 * @return string with HTML select
92 93 */
... ... @@ -102,7 +103,7 @@ class FormVentilation extends Form {
102 103 $sql .= " AND aa.active = 1";
103 104 $sql .= " ORDER BY aa.account_number";
104 105  
105   - dol_syslog(get_class($this) . "::select_account_parent sql=" . $sql, LOG_DEBUG);
  106 + dol_syslog(get_class($this) . "::select_account sql=" . $sql, LOG_DEBUG);
106 107 $resql = $this->db->query($sql);
107 108 if ($resql) {
108 109  
... ... @@ -135,6 +136,60 @@ class FormVentilation extends Form {
135 136 }
136 137  
137 138 /**
  139 + * Return list of the accounts with label
  140 + *
  141 + * @param string $selectedid pcg_type
  142 + * @param string $htmlname of combo list
  143 + * @param int $showempty en empty line
  144 + *
  145 + * @return string with HTML select
  146 + */
  147 + function select_account_parent($selectid, $htmlname = 'account_parent', $showempty = 0, $event = array()) {
  148 + global $conf, $user, $langs;
  149 +
  150 + $out = '';
  151 +
  152 + $sql = "SELECT DISTINCT aa.account_number, aa.label, aa.rowid, aa.fk_pcg_version";
  153 + $sql .= " FROM " . MAIN_DB_PREFIX . "accountingaccount as aa";
  154 + $sql .= " INNER JOIN " . MAIN_DB_PREFIX . "accounting_system as asy ON aa.fk_pcg_version = asy.pcg_version";
  155 + $sql .= " AND asy.rowid = ".$conf->global->CHARTOFACCOUNTS;
  156 + $sql .= " AND aa.active = 1";
  157 + $sql .= " ORDER BY aa.account_number";
  158 +
  159 + dol_syslog ( get_class ( $this ) . "::select_account_parent sql=" . $sql, LOG_DEBUG );
  160 + $resql = $this->db->query ( $sql );
  161 + if ($resql) {
  162 +
  163 + $out .= ajax_combobox ( $htmlname, $event );
  164 +
  165 +
  166 + $out .= '<select id="' . $htmlname . '" class="flat" name="' . $htmlname . '">';
  167 + if ($showempty)
  168 + $out .= '<option value="-1"></option>';
  169 + $num = $this->db->num_rows ( $resql );
  170 + $i = 0;
  171 + if ($num) {
  172 + while ( $i < $num ) {
  173 + $obj = $this->db->fetch_object ( $resql );
  174 + $label = $obj->account_number.'-'.$obj->label;
  175 +
  176 + if (($selectid != '') && $selectid == $obj->account_number) {
  177 + $out .= '<option value="' . $obj->rowid . '" selected="selected">' . $label . '</option>';
  178 + } else {
  179 + $out .= '<option value="' . $obj->rowid . '">' . $label . '</option>';
  180 + }
  181 + $i ++;
  182 + }
  183 + }
  184 + $out .= '</select>';
  185 + } else {
  186 + dol_print_error ( $this->db );
  187 + }
  188 + $this->db->free ( $resql );
  189 + return $out;
  190 + }
  191 +
  192 + /**
138 193 * Return list of pcg with label
139 194 *
140 195 * @param string $selectedid pcg_type
... ...