function save($data)
 {
     App::import('Model', 'AccountingBukuBesar');
     App::import('Model', 'AccountingAccount');
     $bukubesar = new AccountingBukuBesar();
     $account = new AccountingAccount();
     //$type = $this->AccountingTransactionType
     //			->findById($data['AccountingTransaction']['accounting_transaction_type_id']);
     //$data['AccountingTransaction']['account_debit_id'] = $type['AccountingTransactionType']['account_debit_id'];
     //$data['AccountingTransaction']['account_credit_id'] = $type['AccountingTransactionType']['account_credit_id'];
     if (parent::save($data)) {
         $bukus = array(array('AccountingBukuBesar' => array('accounting_account_id' => $data['AccountingTransaction']['account_debit_id'], 'accounting_transaction_id' => $this->id, 'estimates' => 'DEBIT', 'amount' => $data['AccountingTransaction']['amount'], 'debit' => $data['AccountingTransaction']['amount'], 'credit' => 0)), array('AccountingBukuBesar' => array('accounting_account_id' => $data['AccountingTransaction']['account_credit_id'], 'accounting_transaction_id' => $this->id, 'estimates' => 'CREDIT', 'amount' => $data['AccountingTransaction']['amount'], 'debit' => 0, 'credit' => $data['AccountingTransaction']['amount'])));
         foreach ($bukus as $buku) {
             $b = $bukubesar->find('all', array('conditions' => array('AccountingBukuBesar.accounting_transaction_id' => $buku['AccountingBukuBesar']['accounting_transaction_id'], 'AccountingBukuBesar.estimates' => $buku['AccountingBukuBesar']['estimates'])));
             if (count($b) === 0) {
                 $bukubesar->create();
             } else {
                 $bukubesar->id = $b[0]['AccountingBukuBesar']['id'];
             }
             $bukubesar->save($buku);
             $parent = $account->read(null, $buku['AccountingBukuBesar']['accounting_account_id']);
             if ($parent['AccountingAccount']['parent_id'] == 14) {
                 $bukubesar->create();
                 $bukubesar->save(array('AccountingBukuBesar' => array('accounting_account_id' => 18, 'accounting_transaction_id' => $this->id, 'estimates' => 'DEBIT', 'amount' => $buku['AccountingBukuBesar']['amount'], 'debit' => $buku['AccountingBukuBesar']['amount'], 'credit' => 0)));
             }
             if ($parent['AccountingAccount']['parent_id'] == 2) {
                 $bukubesar->create();
                 $bukubesar->save(array('AccountingBukuBesar' => array('accounting_account_id' => 18, 'accounting_transaction_id' => $this->id, 'estimates' => 'CREDIT', 'amount' => $buku['AccountingBukuBesar']['amount'], 'debit' => 0, 'credit' => $buku['AccountingBukuBesar']['amount'])));
             }
         }
         return true;
     } else {
         return false;
     }
 }
Esempio n. 2
0
                        $msg .= '<div><font color="red">' . $langs->trans("ErrorDB") . ' : ' . $langs->trans("Product") . ' ' . $productid . ' ' . $langs->trans("NotVentilatedinAccount") . ' : ' . length_accountg($accounting->account_number) . '<br/> <pre>' . $sql . '</pre></font></div>';
                    }
                }
                $cpt++;
            }
        } else {
            $msg .= '<div><font color="red">' . $langs->trans("AnyLineVentilate") . '</font></div>';
        }
        $msg .= '<div><font color="red">' . $langs->trans("EndProcessing") . '</font></div>';
    }
}
$form = new FormVentilation($db);
// Defaut AccountingAccount RowId Product / Service
// at this time ACCOUNTING_SERVICE_SOLD_ACCOUNT & ACCOUNTING_PRODUCT_SOLD_ACCOUNT are account number not accountingacount rowid
// so we need to get those default value rowid first
$accounting = new AccountingAccount($db);
// TODO: we should need to check if result is a really exist accountaccount rowid.....
$aarowid_servbuy = $accounting->fetch('', $conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT, 1);
$aarowid_prodbuy = $accounting->fetch('', $conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT, 1);
$aarowid_servsell = $accounting->fetch('', $conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT, 1);
$aarowid_prodsell = $accounting->fetch('', $conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT, 1);
$aacompta_servbuy = !empty($conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT : $langs->trans("CodeNotDef");
$aacompta_prodbuy = !empty($conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT : $langs->trans("CodeNotDef");
$aacompta_servsell = !empty($conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT : $langs->trans("CodeNotDef");
$aacompta_prodsell = !empty($conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT : $langs->trans("CodeNotDef");
// Purge search criteria
if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter")) {
    $search_ref = '';
    $search_label = '';
    $search_desc = '';
}
Esempio n. 3
0
 */
if ($action == 'ventil' && !empty($btn_ventil)) {
    print '<div><font color="red">' . $langs->trans("Processing") . '...</font></div>';
    if (!empty($codeventil) && !empty($mesCasesCochees)) {
        print '<div><font color="red">' . count($mesCasesCochees) . ' ' . $langs->trans("SelectedLines") . '</font></div>';
        $mesCodesVentilChoisis = $codeventil;
        $cpt = 0;
        foreach ($mesCasesCochees as $maLigneCochee) {
            $maLigneCourante = explode("_", $maLigneCochee);
            $monId = $maLigneCourante[0];
            $monNumLigne = $maLigneCourante[1];
            $monCompte = $mesCodesVentilChoisis[$monNumLigne];
            $sql = " UPDATE " . MAIN_DB_PREFIX . "facturedet";
            $sql .= " SET fk_code_ventilation = " . $monCompte;
            $sql .= " WHERE rowid = " . $monId;
            $accountventilated = new AccountingAccount($db);
            $accountventilated->fetch($monCompte, '');
            dol_syslog("/accountancy/customer/list.php sql=" . $sql, LOG_DEBUG);
            if ($db->query($sql)) {
                print '<div><font color="green">' . $langs->trans("Lineofinvoice") . ' ' . $monId . ' - ' . $langs->trans("VentilatedinAccount") . ' : ' . length_accountg($accountventilated->account_number) . '</font></div>';
            } else {
                print '<div><font color="red">' . $langs->trans("ErrorDB") . ' : ' . $langs->trans("Lineofinvoice") . ' ' . $monId . ' - ' . $langs->trans("NotVentilatedinAccount") . ' : ' . length_accountg($accountventilated->account_number) . '<br/> <pre>' . $sql . '</pre></font></div>';
            }
            $cpt++;
        }
    } else {
        print '<div><font color="red">' . $langs->trans("AnyLineVentilate") . '</font></div>';
    }
    print '<div><font color="red">' . $langs->trans("EndProcessing") . '</font></div>';
}
/*
Esempio n. 4
0
     print '<input type="submit" class="button" value="' . $langs->trans("Save") . '">';
     print '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
     print '<input type="submit" name="cancel" class="button" value="' . $langs->trans("Cancel") . '">';
     print '</div>';
     print '</form>';
 } else {
     $linkback = '<a href="../admin/account.php">' . $langs->trans("BackToChartofaccounts") . '</a>';
     dol_fiche_head($head, 'card', $langs->trans('AccountAccounting'), 0, 'billr');
     print '<table class="border" width="100%">';
     // Account number
     print '<tr><td width="25%">' . $langs->trans("AccountNumber") . '</td>';
     print '<td>' . $accounting->account_number . '</td>';
     print '<td align="right" width="25%">' . $linkback . '</td></tr>';
     print '<tr><td>' . $langs->trans("Label") . '</td>';
     print '<td colspan="2">' . $accounting->label . '</td></tr>';
     $accp = new AccountingAccount($db);
     if (!empty($accounting->account_parent)) {
         $accp->fetch($accounting->account_parent, '');
     }
     print '<tr><td>' . $langs->trans("Accountparent") . '</td>';
     print '<td colspan="2">' . $accp->account_number . ' - ' . $accp->label . '</td></tr>';
     print '<tr><td>' . $langs->trans("Pcgtype") . '</td>';
     print '<td colspan="2">' . $accounting->pcg_type . '</td></tr>';
     print '<tr><td>' . $langs->trans("Pcgsubtype") . '</td>';
     print '<td colspan="2">' . $accounting->pcg_subtype . '</td></tr>';
     print '<tr><td>' . $langs->trans("Activated") . '</td>';
     print '<td colspan="2">';
     if (empty($accounting->active)) {
         print img_picto($langs->trans("Disabled"), 'switch_off');
     } else {
         print img_picto($langs->trans("Activated"), 'switch_on');
Esempio n. 5
0
    $sortfield = "f.datef, f.facnumber, l.rowid";
}
if (!$sortorder) {
    if ($conf->global->ACCOUNTING_LIST_SORT_VENTILATION_TODO > 0) {
        $sortorder = " DESC ";
    }
}
// Security check
if ($user->societe_id > 0) {
    accessforbidden();
}
if (!$user->rights->accounting->ventilation->dispatch) {
    accessforbidden();
}
$formventilation = new FormVentilation($db);
$accounting = new AccountingAccount($db);
$aarowid_s = $accounting->fetch('', $conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT, 1);
$aarowid_p = $accounting->fetch('', $conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT, 1);
// Purge search criteria
if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter")) {
    $search_ref = '';
    $search_invoice = '';
    $search_label = '';
    $search_desc = '';
    $search_amount = '';
    $search_account = '';
    $search_vat = '';
}
/*
 * View
 */
Esempio n. 6
0
     print "<tr " . $bc[$var] . ">";
     print "<td>" . $date . "</td>";
     print "<td>" . $invoicestatic->getNomUrl(1) . "</td>";
     $companystatic->id = $tabcompany[$key]['id'];
     $companystatic->name = $tabcompany[$key]['name'];
     $companystatic->client = $tabcompany[$key]['code_client'];
     print "<td>" . length_accounta($k);
     print "</td><td>" . $langs->trans("ThirdParty");
     print ' (' . $companystatic->getNomUrl(0, 'customer', 16) . ')';
     print "</td><td align='right'>" . ($mt >= 0 ? price($mt) : '') . "</td>";
     print "<td align='right'>" . ($mt < 0 ? price(-$mt) : '') . "</td>";
 }
 print "</tr>";
 // Product / Service
 foreach ($tabht[$key] as $k => $mt) {
     $accountingaccount = new AccountingAccount($db);
     $accountingaccount->fetch(null, $k);
     if ($mt) {
         print "<tr " . $bc[$var] . ">";
         print "<td>" . $date . "</td>";
         print "<td>" . $invoicestatic->getNomUrl(1) . "</td>";
         print "<td>" . length_accountg($k) . "</td>";
         print "<td>" . $accountingaccount->label . "</td>";
         print "<td align='right'>" . ($mt < 0 ? price(-$mt) : '') . "</td>";
         print "<td align='right'>" . ($mt >= 0 ? price($mt) : '') . "</td>";
         print "</tr>";
     }
 }
 // VAT
 foreach ($tabtva[$key] as $k => $mt) {
     if ($mt) {
Esempio n. 7
0
 print '</tr>';
 print '<tr class="liste_titre">';
 print '<td class="liste_titre"><input type="text" class="flat" size="15" name="search_account" value="' . $search_account . '"></td>';
 print '<td class="liste_titre"><input type="text" class="flat" size="15" name="search_label" value="' . $search_label . '"></td>';
 print '<td class="liste_titre"><input type="text" class="flat" size="15" name="search_accountparent" value="' . $search_accountparent . '"></td>';
 print '<td class="liste_titre"><input type="text" class="flat" size="15" name="search_pcgtype" value="' . $search_pcgtype . '"></td>';
 print '<td class="liste_titre"><input type="text" class="flat" size="15" name="search_pcgsubtype" value="' . $search_pcgsubtype . '"></td>';
 print '<td class="liste_titre">&nbsp;</td>';
 print '<td align="right" colspan="2" class="liste_titre">';
 print '<input type="image" class="liste_titre" src="' . img_picto($langs->trans("Search"), 'search.png', '', '', 1) . '" name="button_search" value="' . dol_escape_htmltag($langs->trans("Search")) . '" title="' . dol_escape_htmltag($langs->trans("Search")) . '">';
 print '&nbsp;';
 print '<input type="image" class="liste_titre" src="' . img_picto($langs->trans("Search"), 'searchclear.png', '', '', 1) . '" name="button_removefilter" value="' . dol_escape_htmltag($langs->trans("RemoveFilter")) . '" title="' . dol_escape_htmltag($langs->trans("RemoveFilter")) . '">';
 print '</td>';
 print '</tr>';
 $var = false;
 $accountstatic = new AccountingAccount($db);
 while ($i < min($num, $limit)) {
     $obj = $db->fetch_object($resql);
     $accountstatic->id = $obj->rowid;
     $accountstatic->label = $obj->label;
     $accountstatic->account_number = $obj->account_number;
     print '<tr ' . $bc[$var] . '>';
     print '<td>' . $accountstatic->getNomUrl(1) . '</td>';
     print '<td>' . $obj->label . '</td>';
     print '<td>' . $obj->account_parent . '</td>';
     print '<td>' . $obj->pcg_type . '</td>';
     print '<td>' . $obj->pcg_subtype . '</td>';
     print '<td>';
     if (empty($obj->active)) {
         print '<a href="' . $_SERVER["PHP_SELF"] . '?id=' . $obj->rowid . '&action=enable">';
         print img_picto($langs->trans("Disabled"), 'switch_off');
if (!$user->admin) {
    accessforbidden();
}
llxHeader('', $langs->trans("ImportAccount"));
$to_import = GETPOST("mesCasesCochees");
if ($_POST["action"] == 'import') {
    print '<div><font color="red">' . $langs->trans("Processing") . '...</font></div>';
    if (is_array($to_import) && count($to_import) > 0) {
        print '<div><font color="red">' . count($to_import) . ' ' . $langs->trans("SelectedLines") . '</font></div>';
        $sql = 'SELECT pcg_version FROM ' . MAIN_DB_PREFIX . 'accounting_system WHERE rowid=' . $conf->global->CHARTOFACCOUNTS;
        $result = $db->query($sql);
        if ($result && $db->num_rows($result) > 0) {
            $obj = $db->fetch_object($result);
            $cpt = 0;
            foreach ($to_import as $maLigneCochee) {
                $accounting = new AccountingAccount($db);
                $monLabel = GETPOST('label' . $maLigneCochee);
                $monParentAccount = GETPOST('AccountParent' . $maLigneCochee);
                $monType = GETPOST('pcgType' . $maLigneCochee);
                $monSubType = GETPOST('pcgSubType' . $maLigneCochee);
                $accounting->fk_pcg_version = $obj->pcg_version;
                $accounting->account_number = $maLigneCochee;
                $accounting->label = $monLabel;
                $accounting->account_parent = $monParentAccount;
                $accounting->pcg_type = $monType;
                $accounting->pcg_subtype = $monSubType;
                $accounting->active = 1;
                $result = $accounting->create($user);
                if ($result > 0) {
                    setEventMessage($langs->trans("AccountingAccountAdd"), 'mesgs');
                } else {
Esempio n. 9
0
 print '<tr class="liste_titre">';
 print '<td class="liste_titre"><input type="text" class="flat" size="15" name="search_account" value="' . $search_account . '"></td>';
 print '<td class="liste_titre"><input type="text" class="flat" size="15" name="search_label" value="' . $search_label . '"></td>';
 print '<td class="liste_titre"><input type="text" class="flat" size="15" name="search_accountparent" value="' . $search_accountparent . '"></td>';
 print '<td class="liste_titre"><input type="text" class="flat" size="15" name="search_pcgtype" value="' . $search_pcgtype . '"></td>';
 print '<td class="liste_titre"><input type="text" class="flat" size="15" name="search_pcgsubtype" value="' . $search_pcgsubtype . '"></td>';
 print '<td class="liste_titre">&nbsp;</td>';
 print '<td align="right" colspan="2" class="liste_titre">';
 print '<input type="image" class="liste_titre" src="' . img_picto($langs->trans("Search"), 'search.png', '', '', 1) . '" name="button_search" value="' . dol_escape_htmltag($langs->trans("Search")) . '" title="' . dol_escape_htmltag($langs->trans("Search")) . '">';
 print '&nbsp;';
 print '<input type="image" class="liste_titre" src="' . img_picto($langs->trans("Search"), 'searchclear.png', '', '', 1) . '" name="button_removefilter" value="' . dol_escape_htmltag($langs->trans("RemoveFilter")) . '" title="' . dol_escape_htmltag($langs->trans("RemoveFilter")) . '">';
 print '</td>';
 print '</tr>';
 $var = false;
 $accountstatic = new AccountingAccount($db);
 $accountparent = new AccountingAccount($db);
 while ($i < min($num, $limit)) {
     $obj = $db->fetch_object($resql);
     $accountstatic->id = $obj->rowid;
     $accountstatic->label = $obj->label;
     $accountstatic->account_number = $obj->account_number;
     print '<tr ' . $bc[$var] . '>';
     print '<td>' . $accountstatic->getNomUrl(1) . '</td>';
     print '<td>' . $obj->label . '</td>';
     if ($obj->account_parent) {
         $accountparent->id = $obj->rowid2;
         $accountparent->label = $obj->label2;
         $accountparent->account_number = $obj->account_number2;
         print '<td>' . $accountparent->getNomUrl(1) . '</td>';
     } else {
         print '<td>&nbsp;</td>';
Esempio n. 10
0
    $sortfield = "f.datef, f.facnumber, l.rowid";
}
if (!$sortorder) {
    if ($conf->global->ACCOUNTING_LIST_SORT_VENTILATION_TODO > 0) {
        $sortorder = " DESC ";
    }
}
// Security check
if ($user->societe_id > 0) {
    accessforbidden();
}
if (!$user->rights->accounting->ventilation->dispatch) {
    accessforbidden();
}
$formventilation = new FormVentilation($db);
$accounting = new AccountingAccount($db);
$aarowid_s = $accounting->fetch('', ACCOUNTING_SERVICE_SOLD_ACCOUNT);
$aarowid_p = $accounting->fetch('', ACCOUNTING_PRODUCT_SOLD_ACCOUNT);
// Purge search criteria
if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter")) {
    $search_ref = '';
    $search_invoice = '';
    $search_label = '';
    $search_desc = '';
    $search_amount = '';
    $search_account = '';
    $search_vat = '';
}
/*
 * View
 */
Esempio n. 11
0
    $page = 0;
}
$offset = $conf->liste_limit * $page;
$pageprev = $page - 1;
$pagenext = $page + 1;
if (!$sortfield) {
    $sortfield = "aa.account_number";
}
if (!$sortorder) {
    $sortorder = "ASC";
}
if ($action == 'delete') {
    $formconfirm = $html->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $id, $langs->trans('DeleteAccount'), $langs->trans('ConfirmDeleteAccount'), 'confirm_delete', '', 0, 1);
    print $formconfirm;
}
$accounting = new AccountingAccount($db);
if ($action == 'disable') {
    if ($accounting->fetch($id)) {
        $result = $accounting->account_desactivate($id);
    }
    $action = 'update';
    if ($result < 0) {
        setEventMessage($accounting->error, 'errors');
    }
} else {
    if ($action == 'enable') {
        if ($accounting->fetch($id)) {
            $result = $accounting->account_activate($id);
        }
        $action = 'update';
        if ($result < 0) {