Ejemplo n.º 1
0
 public function search($word, $coords, $distance = 5, $limit = 25, $offset = 0)
 {
     $collection = $tmp = $idEtabs = [];
     $nb = $incr = 0;
     $services = rdb('geo', 'service')->select('id')->where(['family', 'LIKE', '%' . $word . '%'])->where(['code', 'LIKE', '%' . $word . '%'], 'OR')->where(['label', 'LIKE', '%' . $word . '%'], 'OR')->exec(true);
     foreach ($services as $service) {
         $sEtabs = $service->pivots(rdb('geo', 'etablissement')->model())->exec();
         foreach ($sEtabs as $sEtab) {
             $idEtabs[] = $sEtab['etablissement_id'];
         }
     }
     $idEtabs = array_unique($idEtabs);
     $db = Model::Location();
     $odm = $db->getOdm();
     $coll = $odm->selectCollection($db->collection);
     $coll->ensureIndex(['value' => '2d', 'object_motor' => 1, 'object_database' => 1, 'object_table' => 1]);
     $filter = ["value" => ['$within' => ['$center' => [[floatval($coords['lng']), floatval($coords['lat'])], floatval($distance / 111.12)]]], 'object_motor' => 'dbredis', 'object_database' => 'geo', 'object_table' => 'etablissement'];
     $results = $coll->find($filter);
     foreach ($results as $result) {
         if (Arrays::in($result['object_id'], $idEtabs)) {
             $etab = rdb('geo', 'etablissement')->find($result['object_id']);
             $distances = distanceKmMiles($coords['lng'], $coords['lat'], $etab->lng, $etab->lat);
             $distance = $distances['km'];
             $item = $etab->assoc();
             $item['distance'] = $distance;
             $collection[] = $item;
         }
     }
     $collection = $this->orderBy($collection, 'distance');
     if ($limit == 0) {
         return $collection;
     } else {
         return array_slice($collection, $offset, $limit);
     }
 }
Ejemplo n.º 2
0
 public function __construct()
 {
     $this->locale = session('web')->getLanguage();
     $this->db = rdb('lang', 'dictionary');
     $defaultLng = Config::get('application.language', DEFAULT_LANGUAGE);
     $this->mustTranslate = $defaultLng != $this->locale;
 }
Ejemplo n.º 3
0
 private function checkedBanned($ip)
 {
     $row = rdb('core', 'flood')->inCache(false)->where(['ip', '=', (int) str_replace('.', '', $ip)])->first(true);
     if (!$row) {
         rdb('core', 'flood')->create(['ip' => (int) str_replace('.', '', $ip), 'num' => 1])->save();
     } else {
         $num = (int) $row->num;
         $num++;
         $row->setNum($num)->save();
         if ($num >= Config::get('application.flood.max.time', 3)) {
             rdb('core', 'banned')->create(['ip' => (int) str_replace('.', '', $ip)])->save();
         }
     }
 }
Ejemplo n.º 4
0
Archivo: Api.php Proyecto: schpill/thin
 public static function can($auth, $resource, $action)
 {
     if (empty($auth)) {
         self::unauthorized();
     }
     if (2 == (int) $auth->is_admin) {
         $rigth = rdb('api', 'right')->where(['resource', '=', $resource])->where(['action', '=', $action])->where(['user_id', '=', $auth->user_id])->first(true);
         if (empty($right)) {
             self::unauthorized();
         }
         $can = (int) $right->can;
         if (2 == $can) {
             self::unauthorized();
         }
     }
 }
Ejemplo n.º 5
0
 function lap_perpanjang()
 {
     $n = 0;
     $data = array();
     $datax = array();
     $no_spb = $_POST['no_spb'];
     $data['ae'] = $this->Admin_model->is_oto('lelang/list_lelang', 'e');
     $data = $this->Admin_model->show_list('perpanjang_spb', "where pp_stat='N' group by no_spb order by no_spb", 'distinct(no_spb) as no_spb,pp_ke,sum(pp_bayar) as ppbayar');
     if ($data->num_rows > 0) {
         foreach ($data->result() as $row) {
             $n++;
             $pp_ke = $this->Admin_model->show_single_field("lelang", "pp_stat", "where no_spb='" . $row->no_spb . "'");
             $pp_ke == '' ? $gb = 'checkout.gif' : ($gb = '44.png');
             $pp_ke == '' ? $grb = 'D' : ($grb = '');
             echo "\n<tr class='xx' id='" . $row->no_spb . "' align='center'>\r\n\t\t\t\t  <td class='kotak' align='left'>" . rdb('spb', 'id_barang', 'id_barang', "where no_spb='" . $row->no_spb . "'") . "</td>\t\r\n\t\t\t\t  <td class='kotak' align='center'>" . substr($row->no_spb, 0, 5) . "</td>\t\r\n\t\t\t\t  <td class='kotak' align='left'>" . ShortTgl(rdb('spb', 'tgl_spb', 'tgl_spb', "where no_spb='" . $row->no_spb . "'"), true) . "</td>\t\r\n\t\t\t\t  <td class='kotak' align='left'>" . rdb('spb', 'nama_spb', 'nama_spb', "where no_spb='" . $row->no_spb . "'") . "</td>\t\r\n\t\t\t\t  <td class='kotak' align='right'>" . number_format(rdb('spb', 'taksir_spb', 'taksir_spb', "where no_spb='" . $row->no_spb . "'"), 2) . "</td>\t\r\n\t\t\t\t  <td class='kotak' align='right'>" . number_format(rdb('spb', 'nilai_spb', 'nilai_spb', "where no_spb='" . $row->no_spb . "'"), 2) . "</td>\t\r\n\t\t\t\t  <td class='kotak'>" . $row->pp_ke . " x</td>\t\r\n\t\t\t\t  <td class='kotak'>" . TglfromSql(getNextDays(rdb('spb', 'tgl_spb', 'tgl_spb', "where no_spb='" . $row->no_spb . "'"), $row->pp_ke * 30)) . "</td>\r\n\t\t\t\t  <td id='c-1-{$n}' class='kotak'><img src='" . base_url() . "asset/images/{$gb}' id='ck-{$n}' class='pros' onclick=\"upd_lelang('" . $row->no_spb . "','{$grb}');\"></td>";
             echo " </tr>\n";
         }
     } else {
         echo "Tidak ada barang yang akan di lelang";
     }
 }
Ejemplo n.º 6
0
 public function run($name, $when, $event, $args = [])
 {
     Timer::start();
     Cli::show("Start of execution", 'SUCCESS');
     $db = rdb('cron', 'task');
     $dbCron = $db->firstOrCreate(['name' => $name]);
     $nextDb = $dbCron->next;
     $cron = CronExpression::factory($when);
     $next = $cron->getNextRunDate()->format('Y-m-d-H-i-s');
     list($y, $m, $d, $h, $i, $s) = explode('-', $next, 6);
     $timestamp = mktime($h, $i, $s, $m, $d, $y);
     if ($nextDb) {
         if ($nextDb < $timestamp) {
             Cli::show("Execution {$name}", 'COMMENT');
             call_user_func_array($event, $args);
             $dbCron->setNext($timestamp)->save();
         }
     } else {
         $dbCron->setNext($timestamp)->save();
     }
     Cli::show('Elapsed time: ' . Timer::get() . ' s.', 'INFO');
     Cli::show("End of execution", 'SUCCESS');
 }
Ejemplo n.º 7
0
<?php

link_js('zetro_number.js,list_nasabah.js', 'asset/js,application/views/sdm/js');
$user_aktiv = $this->session->userdata("userid");
panel_begin('Black List', '');
$zb = new zetro_listBuilder('asset/bin/zetro_form.cfg');
$zb->ListHeader('nasabah', '70%', 'listTable');
$no = 0;
echo "<tbody>";
//($page+1);
foreach ($list->result_array() as $lst) {
    $no++;
    echo "<tr class='xx' id='" . $lst['ktp_spb'] . "' align='left'>\n\r\n\t\t   <td class='kotak' align='center'>{$no}</td>\r\n\t\t   <td class='kotak'>" . $lst['nama_spb'] . "{$ae}</td>\r\n\t\t   <td class='kotak'>" . $lst['ktp_spb'] . "</td>\r\n\t\t   <td class='kotak'>" . $lst['almnasabah'] . "</td>\r\n\t\t   <td class='kotak' width='8%' align='center'>";
    $bls = rdb('blacklist', 'ktp_spb', 'ktp_spb', "where ktp_spb='" . $lst['ktp_spb'] . "'");
    if ($ae == 'Y' || $user_aktiv == 'Superuser') {
        $zb->event($lst['ktp_spb']);
    }
    echo "</td></tr>\n";
}
echo "</tbody></table>";
panel_end();
popup_start('Edit Data Nasabah', 500, 300, 'frm2');
$zb = new zetro_frmBuilder('asset/bin/zetro_form.cfg');
$zb->AddBarisKosong(true);
$zb->BuildForm('nasabah', true, '80%');
popup_end('');
?>
<input type='text' id='prs' value='bcl'>
<script language='javascript'>
	$(document).ready(function(e) {
		$('img.edit').hide();
Ejemplo n.º 8
0
function penomoran($table, $fieldnomor)
{
    $nom = rdb($table, $fieldnomor, $fieldnomor, "order by {$fieldnomor} desc limit 1");
    if ($nom == "") {
        $nomor = date('Ymd') . "-0001";
    } else {
        $noms = explode("-", $nom);
        if (strlen((int) $noms[1]) == 1) {
            $nomor = date('Ymd') . "-000" . ($noms[1] + 1);
        } else {
            if (strlen((int) $noms[1]) == 2) {
                $nomor = date('Ymd') . "-00" . ($noms[1] + 1);
            } else {
                if (strlen((int) $noms[1]) == 3) {
                    $nomor = date('Ymd') . "-0" . ($noms[1] + 1);
                } else {
                    if (strlen((int) $noms[1]) == 4) {
                        $nomor = date('Ymd') . "-" . ($noms[1] + 1);
                    }
                }
            }
        }
    }
    return $nomor;
}
Ejemplo n.º 9
0
 function BuildListData($pk = '', $nuberInFirstColumn = true)
 {
     $n = 0;
     $flds = array();
     //echo $this->sql;
     $rs = mysql_query($this->sql) or die(mysql_error());
     if (mysql_num_rows($rs)) {
         $fldx = "";
         while ($rw = mysql_fetch_array($rs)) {
             $n++;
             if ($this->statu == true) {
                 foreach ($this->fields as $fld) {
                     empty($flds[$fld]) ? $flds[$fld] = $rw[$fld] : ($flds[$fld] = $flds[$fld] + $rw[$fld]);
                 }
             }
             $pk == '' ? $id = $rw['id'] : ($id = $rw[$pk]);
             echo "<tr class='xx' id='nm-" . str_replace(' ', '_', $id) . "'>\n";
             echo $nuberInFirstColumn == true ? "<td class='kotak' align='center'>{$n}</td>\n" : "";
             for ($i = 0; $i < count($this->data); $i++) {
                 $jenis = explode('.', $this->data[$i]);
                 $this->nom(str_replace(' ', '_', $id));
                 if ($jenis[1] == 't') {
                     echo "<td class='kotak' align='center'>" . tglfromSql($rw[$jenis[0]]) . "</td>\n";
                 } else {
                     if ($jenis[1] == 'd') {
                         echo "<td class='kotak' align='right'>" . number_format($rw[$jenis[0]], 2, '.', ',') . "</td>\n";
                     } else {
                         if ($jenis[1] == 'dn') {
                             echo $this->edit == 'y' ? "<td class='kotak' align='left' nowrap>" . $this->field_inline($i + 1, number_format($rw[$jenis[0]], 2)) . "</td>\n" : "<td class='kotak' align='right'>" . number_format($rw[$jenis[0]], 2, '.', ',') . "</td>\n";
                         } else {
                             echo !empty($this->kolom) && $this->kolom == $jenis[0] ? "<td class='kotak' align='left'>" . rdb($this->tabel, $this->field, '', "where " . $this->kolom . "='" . $rw[$jenis[0]] . "'") . "</td>\n" : "<td class='kotak' align='left'>" . $rw[$jenis[0]] . "</td>\n";
                         }
                     }
                 }
             }
             //add icon action eq; edit icon, delete icon, process icon
             echo $this->aksi == true ? "<td class='kotak' align='center' >" . $this->event($this->section . '-' . str_replace(' ', '_', $id), '', $this->jenis) . "</td></tr>\n" : "</tr>\n";
         }
     } else {
         //if data not found in database
         echo "<tr class='xx'><td class='kotak' align='center'><img src='" . base_url() . "asset/images/16/warning_16.png'></td>\r\n\t\t\t\t<td class='kotak' colspan='" . (count($this->data) + 1) . "'>\r\n\t\t\t\tData not found in database...(0)</td></tr>";
     }
     //add sub total
     if ($this->statu == true) {
         $clm = explode(",", $this->kol);
         echo "<tr class='xx j_info' align='right'>\r\n\t\t\t\t  <td colspan='" . ($clm[0] - 1) . "' class='kotak'><b>TOTAL</b></td>";
         // for ($z=0;$z<count($clm);$z++){
         foreach ($flds as $z) {
             echo !empty($flds) ? "<td class='kotak'>" . number_format($z, 2) . "</td>" : "<td class='kotak'>" . $z . "</td>";
         }
         $jmlkolom = $clm[0] + count($clm) - 1;
         $totalkolom = count($this->data) + 1;
         if ($totalkolom - $jmlkolom > 0) {
             for ($n = 1; $n <= $totalkolom - $jmlkolom; $n++) {
                 echo "<td class='kotak'>&nbsp;</td>";
             }
         }
         echo "</tr>";
     }
 }
Ejemplo n.º 10
0
 function list_vendor()
 {
     $data = array();
     $n = 0;
     $nama = empty($_POST['nama']) ? $where = "where ID_Jenis='2'" : ($where = "where Nama like '%" . $_POST['nama'] . "%' and ID_Jenis='2'");
     $data = $this->Admin_model->show_list('mst_anggota', $where . ' order by Nama');
     foreach ($data as $row) {
         $n++;
         //tr('xx\' onClick="_show_detail(\''.$row->ID.'\');" attr=\'ax').
         $cek = rdb('inv_pembelian', 'ID_Pemasok', 'ID_Pemasok', "where ID_Pemasok='" . $row->ID . "'");
         echo tr() . td($n, 'center') . td($row->No_Agt, 'center') . td($row->Nama, 'xx\' onClick="_show_detail(\'' . $row->ID . '\',\'' . $row->Nama . '\');" attr=\'ax') . td($row->Alamat) . td($row->Kota) . td($row->Propinsi) . td($row->Telepon) . td($row->Faksimili) . td($cek == '' ? img_aksi($row->ID, true, 'del') : '', 'center') . _tr();
     }
 }
Ejemplo n.º 11
0
 function print_label()
 {
     $data = array();
     $datax = array();
     $kolom = 2;
     $n = 0;
     $nn = 0;
     $datax['list'] = $this->Admin_model->show_list('labeling', "where pp_stat='Y' order by no_spb");
     $data = $this->Admin_model->show_list('labeling', "where pp_stat='Y' order by no_spb");
     //print_r($data->result_array());
     foreach ($data->result_array() as $row) {
         $nama_spb = '';
         $no_spb = '';
         $jw = '';
         $jt_tmpo = '';
         $nilai_spb = '';
         $barang = '';
         $nama_spb = substr(rdb('spb', 'nama_spb', 'nama_spb', "where no_spb='" . $row['no_spb'] . "'"), 0, 10);
         $no_spb = substr($row['no_spb'], 0, 5);
         $jw = $row['jw_spb'];
         $jt_tmpo = tglfromSql($row['jt_spb']);
         $nilai_spb = number_format($row['nilai_spb'], 0);
         $barang = $row['id_barang'];
         $datane = array($nama_spb, $no_spb, $jw, $jt_tmpo, $nilai_spb, $barang);
         $this->print_slip($n, $datane);
         $n++;
         $this->Admin_model->upd_data("labeling", "set pp_stat='P'", "where no_spb='" . $row['no_spb'] . "'");
     }
     $n > 1 ? $z = $n % ($n / 2) : ($z = '');
     $z == 1 || ($z = '') ? $zz = 1 : ($zz = 0);
     $this->print_slip($n + $zz, '');
     $this->print_slip($n + $zz + 1, '');
     $this->load->view('master/print_label', $datax);
 }
//echo $a->getColWidth();
// set lebar tiap kolom tabel transaksi
$a->SetWidths(array(10, 70, 60, 15, 30));
// set align tiap kolom tabel transaksi
$a->SetAligns(array("C", "L", "L", "C", "R"));
$a->SetFont('Arial', 'B', 10);
$a->SetFont('Arial', '', 9);
//$rec = $temp_rec->result();
$n = 0;
$harga = 0;
$hgb = 0;
$hargaj = 0;
$jml = 0;
foreach ($temp_rec as $r) {
    $n++;
    $a->Row(array($n, $r->Nama, rdb('mst_departemen', 'Departemen', 'Departemen', "where ID='" . $r->ID_Dept . "'"), $r->Cicilan, number_format($r->Total, 2)));
    //sub tlot
    $harga = $harga + $r->Total;
}
$a->SetFont('Arial', 'B', 10);
$a->SetFillColor(225, 225, 225);
$a->Cell(155, 8, "TOTAL", 1, 0, 'R', true);
$a->Cell(30, 8, number_format($harga, 2), 1, 0, 'R', true);
$a->Output('application/logs/' . $this->session->userdata('userid') . '_rekap_penjualan.pdf', 'F');
//show pdf output in frame
$path = 'application/views/laporan';
$img = " <img src='" . base_url() . "asset/images/back.png' onclick='js:window.history.back();' style='cursor:pointer' title='click for select other filter data'>";
link_js('auto_sugest.js,lap_beli.js,jquery.fixedheader.js', 'asset/js,' . $path . '/js,asset/js');
panel_begin('Print Preview', '', 'Back' . $img);
?>
		  <iframe src="<?php 
Ejemplo n.º 13
0
 function detail_kreditur()
 {
     $data = array();
     $n = 0;
     $ID = $_POST['ID'];
     $ID_Agt = $_POST['ID_Agt'];
     $data['Agt'] = rdb('mst_anggota', 'Nama', 'Nama', "where ID='" . $_POST['ID_Agt'] . "'");
     $data['Dept'] = rdb('mst_departemen', 'Departemen', 'Departemen', "where ID='" . rdb('mst_anggota', 'ID_Dept', 'ID_Dept', "where ID='" . $_POST['ID_Agt'] . "'") . "'");
     $data['ID_Agt'] = $ID_Agt;
     $this->load->view('member/member_pinjaman_barang_detail', $data);
 }
Ejemplo n.º 14
0
 function get_nm_material($str, $limit, $fld, $dest = '')
 {
     $data = array();
     $where = $dest == '' ? '' : $dest;
     $sql = "select * from inv_barang where {$fld} like '" . $str . "%' {$where} order by kode,nama_barang limit {$limit}";
     //echo $sql;
     $dest == '' ? $dest = 'Nama_Barang' : ($dest = $dest);
     $rw = mysql_query($sql) or die(mysql_error());
     while ($row = mysql_fetch_object($rw)) {
         $data[] = array('data' => $row->{$fld}, 'description' => $row->{$dest}, 'jenis' => $row->ID_Jenis, 'kategori' => $row->ID_Kategori, 'satuan' => $row->ID_Satuan, 'nm_satuan' => rdb('inv_barang_satuan', 'Satuan', 'Satuan', "where ID='" . $row->ID_Satuan . "'"), 'nm_jenis' => rdb('inv_barang_jenis', 'JenisBarang', 'JenisBarang', "where ID='" . $row->ID_Jenis . "'"), 'status' => $row->Status, 'kode' => $row->Kode, 'pemasok' => $row->ID_Pemasok . "-" . rdb('inv_pemasok', 'Pemasok', 'Pemasok', "where ID='" . $row->ID_Pemasok . "'"), 'hargabeli' => $row->Harga_Beli, 'id_pemasok' => $row->ID_Pemasok, 'hargajual' => $row->Harga_Jual, 'id_barang' => $row->ID, 'nm_kategori' => rdb('inv_barang_kategori', 'Kategori', 'Kategori', "where ID='" . $row->ID_Kategori . "'"));
     }
     return $data;
 }
Ejemplo n.º 15
0
 public function makeModel($key)
 {
     list($db, $table) = explode('_', $key, 2);
     return rdb($db, $table)->model();
 }
Ejemplo n.º 16
0
function myModel($table)
{
    return rdb(SITE_NAME, $table);
}
Ejemplo n.º 17
0
 function get_no_jurnal($str, $limit)
 {
     $data = array();
     $sql = "select * from jurnal where Nomor like '%{$str}%' order by NoUrut desc limit {$limit}";
     $rs = mysql_query($sql) or die(mysql_error());
     while ($rw = mysql_fetch_object($rs)) {
         $data[] = array('data' => $rw->Nomor, 'description' => $rw->Keterangan, 'NoUrut' => $rw->NoUrut, 'ID_Bulan' => $rw->ID_Bulan, 'Tahun' => $rw->Tahun, 'ID' => $rw->ID, 'Nomor' => $rw->Nomor, 'Tahun' => $rw->Tahun, 'Tanggal' => tglfromSql($rw->Tanggal), 'ID_Unit' => rdb('unit_jurnal', 'Unit', 'Unit', "where ID='" . $rw->ID_Unit . "'"));
     }
     return $data;
 }
Ejemplo n.º 18
0
        $a->Cell(10, 8, $nn, 1, 0, 'R', true);
        $a->cell(20, 8, tglfromSql($r2->Tanggal), 1, 0, 'C', true);
        $a->cell(20, 8, $r2->Nomor, 1, 0, 'C', true);
        $a->Cell(70, 8, $r2->ID_Jenis == '1' || $r2->ID_Jenis == '5' ? $r2->Jenis_Jual : $r2->Jenis_Jual . " : " . $r2->ID_Post . " - " . $r2->Deskripsi, 1, 0, "L", true);
        $a->Cell(73, 8, $r2->ID_Jenis == '1' || $r2->ID_Jenis == '5' ? "" : "Jatuh Tempo  Tanggal : " . tglfromSql($r2->Tgl_Cicilan), 1, 1, 'L', true);
        $a->SetFont('Arial', '', 9);
        $Grp = " and p.ID_Anggota='" . $r2->ID_Anggota . "' and dt.ID_Jual='" . $r2->ID_Jual . "'";
        $dataz = $this->kasir_model->detail_trans_jual($where, $Grp, $orderby);
        foreach ($dataz as $rr2) {
            $x++;
            $a->Row(array('', $x, $rr2->Kode, ucwords($rr2->Nama_Barang), number_format($rr2->Jumlah, 2), $r2->Satuan, number_format($rr2->Harga, 2), number_format($rr2->Harga * $rr2->Jumlah, 2)));
            $hgb = $r2->ID_Jenis == '5' ? $hgb - $rr2->Harga * $rr2->Jumlah : $hgb + $rr2->Harga * $rr2->Jumlah;
        }
    }
    //sub tlot
    $hargaj = rdb('inv_pembayaran', 'ppn', 'sum(ppn) as ppn', "where no_transaksi='" . $r->NoUrut . "' and year(doc_date)='" . $r->Tahun . "'");
    $harga = $harga + ($hgb - $hargaj);
    if ($hargaj != 0) {
        $a->SetFont('Arial', 'I', 10);
        $a->SetFillColor(242, 239, 219);
        $a->Cell(163, 8, "Potongan", 1, 0, 'R', true);
        $a->Cell(30, 8, number_format($hargaj, 2), 1, 1, 'R', true);
    }
    $a->SetFont('Arial', 'B', 10);
    $a->SetFillColor(242, 239, 219);
    $a->Cell(163, 8, "Sub Total", 1, 0, 'R', true);
    $a->Cell(30, 8, number_format($hgb - $hargaj, 2), 1, 1, 'R', true);
    //grand total
}
$a->SetFont('Arial', 'B', 10);
$a->SetFillColor(225, 225, 225);
Ejemplo n.º 19
0
$a->SetFont('Arial', '', 10);
// set lebar tiap kolom tabel transaksi
$a->SetWidths(array(10, 25, 15, 25, 112, 32, 32, 25));
// set align tiap kolom tabel transaksi
$a->SetAligns(array("C", "C", "C", "C", "L", "R", "R", "R", "R"));
$a->SetFont('Arial', 'B', 10);
//$a->Ln(1);
$a->SetFont('Arial', '', 9);
//$rec = $temp_rec->result();
$n = 0;
$s_pokok = 0;
$s_wajib = 0;
$s_kusus = 0;
foreach ($temp_rec as $r) {
    $n++;
    $a->Row(array($n, tglfromSql($r->Tanggal), rdb('unit_jurnal', 'unit', 'unit', "where ID='" . $r->ID_Unit . "'"), $r->Nomor, $r->Ket, number_format($r->Debet, 2), number_format($r->Kredit, 2), number_format($r->Debet - $r->Kredit, 2)));
    $s_pokok = $s_pokok + $r->Debet;
    $s_wajib = $s_wajib + $r->Kredit;
}
/**/
$a->SetFont('Arial', 'B', 9);
$a->SetFillColor(225, 225, 225);
$a->Cell(187, 8, "TOTAL", 1, 0, 'R', true);
$a->Cell(32, 8, number_format($s_pokok, 2), 1, 0, 'R', true);
$a->Cell(32, 8, number_format($s_wajib, 2), 1, 0, 'R', true);
$a->Cell(25, 8, number_format($s_pokok - $s_wajib, 2), 1, 0, 'R', true);
$a->Output('application/logs/' . $this->session->userdata('userid') . '_jurnal.pdf', 'F');
//show pdf output in frame
$path = 'application/views/_laporan';
$img = " <img src='" . base_url() . "asset/images/back.png' onclick='js:window.history.back();' style='cursor:pointer' title='click for select other filter data'>";
link_js('auto_sugest.js,lap_beli.js,jquery.fixedheader.js', 'asset/js,' . $path . '/js,asset/js');
Ejemplo n.º 20
0
 public function mic($zip = 21000, $city = 'dijon')
 {
     $db = rdb('michelin', 'resto');
     $page = 1;
     $url = "http://restaurant.michelin.fr/ajaxSearchRestaurant/france/{$zip}-{$city}/page-##page##";
     $urlTo = str_replace('##page##', $page, $url);
     $etabs = redis()->get("resto.mic.{$zip}.{$city}");
     if (!$etabs) {
         $restos = [];
         $json = dwn($urlTo);
         $etabs = json_decode($json, true);
         $asyncPoiList = isAke($etabs, 'asyncPoiList', []);
         $stats = isAke($asyncPoiList, 'stats', []);
         $nbresults = (int) isAke($stats, 'tag_vm_nbresults_total', 0);
         $Oj = isAke($asyncPoiList, 'Oj', []);
         $restos = array_merge($restos, $Oj);
         $nbPages = ceil($nbresults / 18);
         for ($i = 2; $i <= $nbPages; $i++) {
             $urlTo = str_replace('##page##', $i, $url);
             $json = dwn($urlTo);
             $etabs = json_decode($json, true);
             $asyncPoiList = isAke($etabs, 'asyncPoiList', []);
             $Oj = isAke($asyncPoiList, 'Oj', []);
             $restos = array_merge($restos, $Oj);
         }
         redis()->set("resto.mic.{$zip}.{$city}", serialize($restos));
     } else {
         $etabs = unserialize($etabs);
         foreach ($etabs as $etab) {
             $id = isAke($etab, 'id', false);
             if (false !== $id) {
                 $infoUrl = "http://vmrest.viamichelin.com/apir/2/FindPOIByCriteria.json/RESTAURANT/fra?&filter=poi_id%20in%20%5B{$id}%5D&obfuscation=true&ie=UTF-8&charset=UTF-8&callback=JSE.cr.pv[0].cv&authKey=JSBS20111110142911566673070414&lg=fra&nocache=1433580926785";
                 $data = redis()->get("restos.mic.{$id}");
                 if (!$data) {
                     $html = dwn($infoUrl);
                     $json = Utils::cut('cv(', '}]}]})', $html) . '}]}]}';
                     $data = json_decode($json, true);
                     $resto = isAke($data, 'Oj', []);
                     if (!empty($resto)) {
                         $resto = current($resto);
                         $datasheets = isAke($resto, 'datasheets', []);
                         if (!empty($datasheets)) {
                             $numFound = false;
                             foreach ($datasheets as $ds) {
                                 $ds['poi_id'] = $id;
                                 $dts_id = isAke($ds, 'dts_id', 'a');
                                 if (is_numeric($dts_id)) {
                                     $numFound = true;
                                 }
                                 $resto = $ds;
                             }
                             redis()->set("restos.mic.{$id}", serialize($resto));
                         }
                     }
                 } else {
                     $data = unserialize($data);
                     $data['phone'] = (string) $data['phone'];
                     $data['local_phone'] = (string) $data['local_phone'];
                     $row = $db->firstOrCreate(['poi_id' => $data['poi_id']]);
                     foreach ($data as $k => $v) {
                         if (fnmatch('*phone*', $k)) {
                             $v = str_replace('+', '', $v);
                         }
                         $row->{$k} = $v;
                     }
                     $row->save();
                 }
             }
         }
         dd($row);
     }
 }
Ejemplo n.º 21
0
 function data_pinjaman()
 {
     $data = array();
     $detail = array();
     $n = 0;
     $x = 0;
     $stat = '';
     $saldo = 0;
     $ID_Agt = $_POST['ID_Agt'];
     $data = $this->member_model->data_pinjaman($ID_Agt);
     if ($_POST['cBayar'] == 'par') {
         if (count($data) > 0) {
             foreach ($data as $r) {
                 $n++;
                 $x = 0;
                 echo "<tr class='list_genap' id='n-" . $r->ID . "'>\r\n\t\t\t\t\t\t<td class='kotak' colspan='2' nowrap ><b>{$n}.&nbsp;&nbsp; Tanggal : " . tglfromSql($r->Tanggal) . " - No. Faktur :" . rdb('inv_penjualan', 'Nomor', 'Nomor', "where NoUrut='" . $r->ID . "' and Tanggal='" . $r->Tanggal . "'") . "</b></td>\r\n\t\t\t\t\t\t<td class='kotak'  align='right'><b>" . number_format($r->jml_pinjaman, 2) . "</b></td>\r\n\t\t\t\t\t\t<td class='kotak'></td>\r\n\t\t\t\t\t\t<td class='kotak'></td>\r\n\t\t\t\t\t\t<td class='kotak' colspan='1' nowrap >" . $r->keterangan . "\r\n\t\t\t\t\t\t<input type='hidden' id='ID_Pinj' value='" . $r->ID . "'></td>\r\n\t\t\t\t\t\t</tr>";
                 $detail = $this->member_model->data_setoran($ID_Agt, $r->ID);
                 $stat = '';
                 foreach ($detail as $d) {
                     $x++;
                     $saldo = $r->jml_pinjaman - ($saldo + $d->Kredit);
                     echo "<tr class='xx'>\r\n\t\t\t\t\t\t\t<td class='kotak' align='center'>{$x}</td>\r\n\t\t\t\t\t\t\t<td class='kotak' >&nbsp;&nbsp;&bull;" . tglfromSql($d->Tanggal) . "</td>\r\n\t\t\t\t\t\t\t<td class='kotak'></td>\r\n\t\t\t\t\t\t\t<td class='kotak' align='right'>" . number_format($d->Kredit, 2) . "<input type='hidden' class='w70 angka' value='" . $d->Kredit . "'></td>\r\n\t\t\t\t\t\t\t<td class='kotak' align='right'>" . number_format($d->saldo, 2) . "</td>\r\n\t\t\t\t\t\t\t<td class='kotak' >\r\n\t\t\t\t\t\t\t\t<table width='100%' style='border-collapse:collapse'>\r\n\t\t\t\t\t\t\t\t<tr><td width='75%' id='r-" . $d->ID . "'>" . $d->keterangan . "</td>\r\n\t\t\t\t\t\t\t\t<td width='25%' align='right'>" . img_aksi($d->ID, true) . "</td>\r\n\t\t\t\t\t\t\t\t</tr></table>\r\n\t\t\t\t\t\t\t</td>\r\n\t\t\t\t\t\t\t</tr>";
                     $stat = $d->saldo == 0 ? number_format($d->Kredit, 2) : '';
                 }
                 for ($i = 1; $i <= $r->lama_cicilan - $x; $i++) {
                     $i == $r->lama_cicilan ? $cil = $r->cicilan_end : ($cil = $r->cicilan);
                     //($stat=='')?$stat="<img src='".base_url()."asset/img/checkout.gif' id='g-".$i."' onclick=\"bayar($i);\"":$stat=$stat;
                     echo "<tr class='xx' id='r-" . $r->ID . "'>\r\n\t\t\t\t\t\t\t<td class='kotak' align='center'>&nbsp;</td>\r\n\t\t\t\t\t\t\t<td class='kotak' >Pembayaran Ke " . $r->lama_cicilan . "</td>\r\n\t\t\t\t\t\t\t<td class='kotak' align='right'>&nbsp;</td>\r\n\t\t\t\t\t\t\t<td class='kotak' align='right'>" . number_format($r->Saldo, 2) . "</td>\r\n\t\t\t\t\t\t\t<td class='kotak'  align='right' nowrap >";
                     echo $stat == '' ? "<img src='" . base_url() . "asset/img/checkout.gif' id='g-" . $r->ID . "' onclick=\"bayar('" . $r->ID . "','" . $r->Tahun . "');\">" : $stat;
                     echo "</td>\r\n\t\t\t\t\t\t\t<td class='kotak' align='right'>&nbsp;</td>\r\n\t\t\t\t\t\t\t</tr>";
                 }
             }
         } else {
             echo tr() . td('Tidak ada tagihan', 'kotak\' colspan=\'6') . _tr();
         }
     } else {
         $jml = 0;
         $kred = 0;
         $sal = 0;
         foreach ($data as $r) {
             $n++;
             echo tr('xx') . td("<b>{$n}. Tanggal : " . tglfromSql($r->Tanggal) . " - No. Faktur :" . rdb('inv_penjualan', 'Nomor', 'Nomor', "where NoUrut='" . $r->ID . "' and Tanggal='" . $r->Tanggal . "'"), 'left\' nowrap colspan=\'2') . td(number_format($r->jml_pinjaman, 2), 'right') . td(number_format($r->Kredit, 2), 'right') . td(number_format($r->Saldo, 2), 'right') . td($r->keterangan, 'left\' nowrap=\'nowrap') . _tr();
             $jml = $jml + $r->jml_pinjaman;
             $kred = $kred + $r->Kredit;
             $sal = $sal + $r->Saldo;
         }
         echo tr('xx  list_genap', "r-" . $r->ID_Agt) . td('<b>Total Tagihan</b>', 'right\' colspan=\'2') . td('<b>' . number_format($jml, 2) . '</b>', 'right') . td('<b>' . number_format($kred, 2) . '</b>', 'right') . td('<b>' . number_format($sal, 2) . '</b>', 'right') . td($sal != 0 ? "<img src='" . base_url() . "asset/img/checkout.gif' id='g-" . $r->ID_Agt . "' onclick=\"bayarAll('" . $r->ID_Agt . "','" . $r->Tahun . "');\">" : '<b>LUNAS</b>', 'center') . _tr();
     }
 }
Ejemplo n.º 22
0
 function laba_graph($thn, $bln)
 {
     $t_days = cal_days_in_month(CAL_GREGORIAN, $bln, $thn);
     $xml = fopen($this->user . '_graph_labarugi.xml', 'w');
     fwrite($xml, "<graph caption='Grafik Aliran Kas' subcaption='Periode :" . nBulan($bln) . " " . $thn . "' xAxisName='Bulan' yAxisName='Value' showValues= '1' showLabels='1' showValues='2'>\r\n");
     //create category by jenis penjuallan ( tunai,giro,cheque,Kredit,return
     fwrite($xml, "<categories>\r\n");
     //while($rw=mysql_fetch_object($rcat)){
     for ($i = 1; $i <= $t_days; $i++) {
         fwrite($xml, "<category name='" . $i . "'/>\r\n");
     }
     fwrite($xml, "</categories>\r\n");
     $color = array('', '1D8BD1', 'F1683C', '2AD62A', 'DBDC25', 'D2DCDD');
     fwrite($xml, "<dataset seriesName='Rugi Laba' color='" . $color[3] . "'>\r\n");
     for ($x = 1; $x <= $t_days; $x++) {
         $ii = strlen($x) == 1 ? '0' . $x : $x;
         $val = 0;
         $laba = 0;
         $cat1 = "select sum(dt.jumlah*dt.harga) as Jual,sum(dt.Jumlah*b.Harga_Beli) as Harga_Beli\r\n\t\t\t\t\t\tfrom inv_penjualan_detail as dt\r\n\t\t\t\t\t\tleft join inv_material_stok as b\r\n\t\t\t\t\t\ton b.id_barang=dt.ID_Barang and b.batch=dt.Batch\r\n\t\t\t\t\t\twhere Tanggal ='" . $thn . '-' . $bln . '-' . $ii . "' and ID_Jenis!='5'\r\n\t\t\t\t\t\tgroup by concat(dt.Tanggal)\r\n\t\t\t\t\t\torder by dt.Tanggal";
         $val = rdb('mst_kas_trans', 'jumlah', "sum(jumlah) as jumlah", "where tgl_trans='" . $thn . '-' . $bln . '-' . $ii . "' group by tgl_trans order by tgl_trans");
         $rcat1 = mysql_query($cat1) or die(mysql_error());
         while ($rw1 = mysql_fetch_object($rcat1)) {
             $laba = $rw1->Jual - $rw1->Harga_Beli;
         }
         $val = $val == '' && $laba == '' ? '' : $laba - $val;
         fwrite($xml, "<set name='" . $ii . "'  value='" . $val . "'/>\r\n");
     }
     fwrite($xml, "</dataset>\r\n");
     fwrite($xml, "</graph>\r\n");
 }
Ejemplo n.º 23
0
 public function retrieve($model, $pivot)
 {
     if (!is_object($model)) {
         throw new Exception('the first argument must be a model.');
     }
     if (!strlen($model->id)) {
         throw new Exception("attach method requires a valid model 1.");
     }
     $names = [(string) $model->db()->table, (string) $pivot];
     asort($names);
     $from = current($names);
     $to = end($names);
     if ($from == $model->db()->table) {
         $rows = Model::Pivot()->where(['from_table', '=', (string) $from])->where(['from_id', '=', (int) $model->id])->where(['from_db', '=', (string) $model->db()->db])->where(['to_table', '=', (string) $pivot])->exec(true);
     } else {
         $rows = Model::Pivot()->where(['from_table', '=', (string) $from])->where(['to_id', '=', (int) $model->id])->where(['to_db', '=', (string) $model->db()->db])->where(['to_table', '=', (string) $model->db()->table])->exec(true);
     }
     $collection = lib('collection');
     foreach ($rows as $row) {
         $tab = $row->toArray();
         unset($tab['to_db']);
         unset($tab['to_table']);
         unset($tab['to_id']);
         unset($tab['from_db']);
         unset($tab['from_table']);
         unset($tab['from_id']);
         unset($tab['id']);
         unset($tab['created_at']);
         unset($tab['updated_at']);
         if ($from == $model->db()->table) {
             $object = rdb((string) $row->to_db, (string) $row->to_table)->find((int) $row->to_id)->toArray();
         } else {
             $object = rdb((string) $row->from_db, (string) $row->from_table)->find((int) $row->from_id)->toArray();
         }
         if (!empty($tab)) {
             $object['pivot'] = $tab;
         }
         $collection[] = $object;
     }
     return $collection;
 }
Ejemplo n.º 24
0
 public function take($what, $where = null, $object = false)
 {
     $collection = [];
     if (is_string($what)) {
         if (fnmatch('*,*', $what)) {
             $what = str_replace(' ', '', $what);
             $what = explode(',', $what);
         } else {
             $what = [$what];
         }
         $res = empty($this->results) ? $this->orm->get($object) : $this->results;
         foreach ($res as $r) {
             if (is_object($r)) {
                 $row = $r->assoc();
             } else {
                 $row = $r;
             }
             foreach ($what as $fk) {
                 if (!fnmatch('*s', $fk)) {
                     $value = isAke($row, $fk . '_id', false);
                     if (false !== $value) {
                         $query = rdb($this->db, $fk)->where(['id', '=', (int) $value]);
                         if (!empty($where) && is_array($where)) {
                             $first = current($where);
                             if (is_string($first)) {
                                 $query = $query->where($where);
                             } else {
                                 $query = $query->multiQuery($where);
                             }
                         }
                         $obj = $query->first($object);
                         if ($obj) {
                             if (is_object($r)) {
                                 $r->{$fk} = $obj;
                             } else {
                                 $row[$fk] = $obj;
                             }
                             $collection[] = is_object($r) ? $r : $row;
                         }
                     }
                 } else {
                     $query = rdb($this->db, substr($fk, 0, -1))->where([$this->table . '_id', '=', (int) $row['id']]);
                     if (!empty($where) && is_array($where)) {
                         $first = current($where);
                         if (is_string($first)) {
                             $query = $query->where($where);
                         } else {
                             $query = $query->multiQuery($where);
                         }
                     }
                     $objs = $query->get($object);
                     if (!empty($objs)) {
                         if (is_object($r)) {
                             $r->{$fk} = $objs;
                         } else {
                             $row[$fk] = $objs;
                         }
                         $collection[] = is_object($r) ? $r : $row;
                     }
                 }
             }
         }
     }
     $this->results = $collection;
     return $this;
 }
Ejemplo n.º 25
0
 public function getDataObject($object)
 {
     list($db, $table, $id) = explode('.', $object, 3);
     $dataObject = rdb($db, $table)->find($id);
     if ($dataObject) {
         return $dataObject;
     }
     return false;
 }
Ejemplo n.º 26
0
 function get_stock_limit()
 {
     $data = array();
     $n = 0;
     $where = $this->input->post('Kategori') == '' ? '' : "where im.ID_Kategori='" . $this->input->post('Kategori') . "' and ms.Stock<>'0'";
     $orderby = $this->input->post('orderby') ? '' : "order by " . str_replace('-', ',', $this->input->post('orderby')) . " ";
     $orderby .= $this->input->post('urutan') ? '' : ' ' . $this->input->post('urutan');
     $data['kategori'] = rdb('inv_barang_kategori', 'Kategori', 'Kategori', "where ID='" . $this->input->post('Kategori') . "'");
     $data['temp_rec'] = $this->report_model->stock_list($where, 'stocklimit', $orderby);
     $this->zetro_auth->menu_id(array('trans_beli'));
     $this->list_data($data);
     $this->View("laporan/transaksi/lap_stock_limit_print");
 }
Ejemplo n.º 27
0
 public function addZone($address)
 {
     $urlLocalisation = "http://search.mappy.net/search/1.0/find?q=" . urlencode($address) . "&favorite_country=250&language=FRE&loc_format=geojson";
     $keyJsonLocal = 'pois.' . sha1($address);
     $json = redis()->get($keyJsonLocal);
     if (!$json) {
         $json = dwn($urlLocalisation);
         redis()->set($keyJsonLocal, $json);
     }
     $tab = json_decode($json, true);
     if (isset($tab['addresses'])) {
         if (isset($tab['addresses']['features'])) {
             if (!empty($tab['addresses']['features'])) {
                 $coords = current($tab['addresses']['features']);
                 $bbox = isAke($coords, 'bbox', false);
                 if (false !== $bbox && count($bbox) == 4) {
                     $lng1 = str_replace(',', '.', $bbox[0]);
                     $lat1 = str_replace(',', '.', $bbox[1]);
                     $lng2 = str_replace(',', '.', $bbox[2]);
                     $lat2 = str_replace(',', '.', $bbox[3]);
                     return $zone = rdb('geo', 'zone')->firstOrCreate(['address' => Inflector::lower($address), 'lat1' => $lat1, 'lng1' => $lng1, 'lat2' => $lat2, 'lng2' => $lng2]);
                 }
             }
         }
     }
 }
Ejemplo n.º 28
0
 function get_bank()
 {
     $data = array();
     $str = $_GET['str'];
     $limit = $_GET['limit'];
     $fld = rdb('mst_anggota', 'Nama', 'Nama', "where ID='" . $_GET['fld'] . "'");
     $data = $this->inv_model->get_bank($str);
     echo json_encode($data);
 }
Ejemplo n.º 29
0
 function member_detail()
 {
     $data = array();
     $no_anggota = $_POST['no_anggota'];
     $data['kunci'] = $no_anggota;
     $data['no_anggota'] = $this->Admin_model->show_single_field('mst_anggota', 'No_Agt', "where ID='" . $no_anggota . "'");
     $data['nm_anggota'] = $this->Admin_model->show_single_field('mst_anggota', 'Nama', "where ID='" . $no_anggota . "'");
     $data['id_department'] = rdb('mst_departemen', 'Departemen', 'Departemen', "where ID='" . $this->Admin_model->show_single_field('mst_anggota', 'ID_Dept', "where ID='" . $no_anggota . "'") . "'");
     $data['transaksi'] = $this->member_model->summary_member_data($no_anggota);
     $this->load->view('member/member_detail', $data);
 }
Ejemplo n.º 30
0
 public function searchNearByAddress($address, $query)
 {
     $collection = lib('collection');
     $coords = lib('geo')->getCoords($address);
     $url = 'http://search.mappy.net/search/1.0/find?extend_bbox=1&bbox=' . $coords['lat1'] . ',' . $coords['lng1'] . ',' . $coords['lat2'] . ',' . $coords['lng2'] . '&q=' . urlencode($query) . '&favorite_country=' . $coords['country_id'] . '&language=FRE&&max_results=199';
     dd($url);
     $key = 'serach.near.' . sha1($url);
     $json = redis()->get($key);
     if (!$json) {
         $json = dwn($url);
         redis()->set($key, $json);
     }
     $data = json_decode($json, true);
     $pois = isAke($data, 'pois', []);
     foreach ($pois as $service) {
         $dbService = rdb('geo', 'service')->where(['code', '=', $service['rubricId']])->first(true);
         if ($dbService) {
             $id = $dbService->id;
         } else {
             if (isset($service['allRubrics'])) {
                 if (count($service['allRubrics'])) {
                     foreach ($service['allRubrics'] as $rubrikA) {
                         $idr = isAke($rubrikA, 'id');
                         $lr = isAke($rubrikA, 'label');
                         $pr = isAke($rubrikA, 'rubricParentId');
                         if ($idr == $service['rubricId']) {
                             $spi = rdb('geo', 'service')->firstOrCreate(['code' => $idr])->setLabel($lr)->setFamily($pr)->save();
                             $id = $spi->id;
                         }
                     }
                 }
             }
         }
         $serviceproxIds = $supplements = [];
         $serviceproxIds[] = $id;
         $poi = $service['id'];
         $checkEtab = rdb('geo', 'etablissement')->where(['poi', '=', (string) $poi])->first(true);
         $add = $checkEtab ? false : true;
         unset($service['id']);
         if (false === $add) {
             $service['id'] = $checkEtab->id;
         }
         unset($service['offer']);
         unset($service['prov']);
         unset($service['pjBlocId']);
         unset($service['thematicId']);
         if (isset($service['tabs'])) {
             if (count($service['tabs'])) {
                 foreach ($service['tabs'] as $tmp) {
                     $tmpUrl = isAke($tmp, 'url', false);
                     $tmpId = isAke($tmp, 'appId', false);
                     if (false !== $tmpUrl && false !== $tmpId) {
                         $key = 'inf.' . $poi . '.' . $tmpId;
                         if ($tmpId == 'pj') {
                             $inf = redis()->get($key);
                             if (empty($inf)) {
                                 $infHtml = dwn($tmpUrl);
                                 $inf = substr($infHtml, strlen('callback('), -1);
                                 redis()->set($key, $inf);
                             }
                             $inf = json_decode($inf, true);
                             $t = isAke($inf, 'tabs', []);
                             if (!empty($t)) {
                                 foreach ($t as $tmpT) {
                                     $b = isAke($tmpT, 'blocks', []);
                                     $t = isAke($tmpT, 'tags', []);
                                     if (!empty($b)) {
                                         for ($ti = 0; $ti < count($b); $ti += 2) {
                                             $seg = $b[$ti];
                                             $seg2 = $b[$ti + 1];
                                             if (is_array($seg) && is_array($seg2)) {
                                                 $title = isAke($seg, 'title', false);
                                                 $kv = isAke($seg2, 'keyValue', false);
                                                 if (false !== $title && false !== $kv) {
                                                     $title = Inflector::urlize($title);
                                                     foreach ($kv as $tmpRow) {
                                                         $supplements[$title][] = [$tmpRow['key'] => $tmpRow['value']];
                                                     }
                                                 }
                                             }
                                         }
                                     }
                                 }
                             }
                         } elseif ($tmpId == 'indoor') {
                         } elseif ($tmpId == 'localbusinesspremium') {
                         } elseif ($tmpId == 'total') {
                         } elseif ($tmpId == 'totalaccess') {
                         } elseif ($tmpId == 'darty') {
                         } elseif ($tmpId == 'eleclerc') {
                         } elseif ($tmpId == 'moteurproduitpromo') {
                         } elseif ($tmpId == 'mappyshopping') {
                         } elseif ($tmpId == 'booking') {
                             $inf = redis()->get($key);
                             if (empty($inf)) {
                                 $infHtml = dwn($tmpUrl);
                                 $inf = substr($infHtml, strlen('callback('), -1);
                                 redis()->set($key, $inf);
                             }
                             $inf = json_decode($inf, true);
                             /* TODO */
                         } elseif ($tmpId == 'localbusinessdiscovery') {
                             $inf = redis()->get($key);
                             if (empty($inf)) {
                                 $infHtml = dwn($tmpUrl);
                                 $inf = substr($infHtml, strlen('callback('), -1);
                                 redis()->set($key, $inf);
                             }
                             $inf = json_decode($inf, true);
                             $t = isAke($inf, 'tabs', []);
                             if (!empty($t)) {
                                 foreach ($t as $tmpT) {
                                     $b = isAke($tmpT, 'blocks', []);
                                     if (!empty($b)) {
                                         foreach ($b as $tmpB) {
                                             $kv = isAke($tmpB, 'keyValue', false);
                                             if (false !== $kv) {
                                                 foreach ($kv as $tmpRow) {
                                                     $tmpK = Inflector::urlize($tmpRow['key']);
                                                     $supplements['infos'][$tmpK] = $tmpRow['value'];
                                                 }
                                             }
                                         }
                                     }
                                 }
                             }
                         } else {
                             $inf = redis()->get($key);
                             if (empty($inf)) {
                                 $infHtml = dwn($tmpUrl);
                                 $inf = substr($infHtml, strlen('callback('), -1);
                                 redis()->set($key, $inf);
                             }
                             $inf = json_decode($inf, true);
                         }
                     }
                 }
             }
         }
         unset($service['tabs']);
         unset($service['contextualPoiUrl']);
         unset($service['providerIds']);
         unset($service['pjRatingId']);
         unset($service['hasUnclaimableProvider']);
         unset($service['additionalInfos']);
         unset($service['additionalInfo']);
         unset($service['coordinateProvider']);
         unset($service['coordinateProvider3D']);
         unset($service['offerType']);
         unset($service['rubricId']);
         unset($service['closestPanoramicId']);
         if (isset($service['allRubrics'])) {
             if (count($service['allRubrics'])) {
                 foreach ($service['allRubrics'] as $rubrikA) {
                     $idr = isAke($rubrikA, 'id');
                     $lr = isAke($rubrikA, 'label');
                     $pr = isAke($rubrikA, 'rubricParentId');
                     $spi = rdb('geo', 'service')->firstOrCreate(['code' => $idr])->setLabel($lr)->setFamily($pr)->save();
                 }
             }
             unset($service['allRubrics']);
         }
         if (isset($service['additionalRubricIds'])) {
             if (count($service['additionalRubricIds'])) {
                 foreach ($service['additionalRubricIds'] as $newRubrique) {
                     $spi = rdb('geo', 'service')->firstOrCreate(['code' => $newRubrique]);
                     $serviceproxIds[] = $spi->id;
                 }
             }
         }
         unset($service['additionalRubricIds']);
         unset($service['brandIconUrl']);
         unset($service['slat']);
         unset($service['slng']);
         unset($service['salt']);
         unset($service['brand']);
         unset($service['indoors']);
         unset($service['visibleIn3D']);
         unset($service['townCode']);
         if (isset($service['town'])) {
             $service['city'] = $service['town'];
             unset($service['town']);
         }
         if (isset($service['positions3D'])) {
             if (isset($service['positions3D']['origin'])) {
                 if (isset($service['positions3D']['origin']['alt'])) {
                     $service['altitude'] = $service['positions3D']['origin']['alt'];
                     unset($service['positions3D']);
                 }
             }
         }
         if (isset($service['way'])) {
             $service['address'] = $service['way'];
             unset($service['way']);
         }
         if (isset($service['pCode'])) {
             $service['zip'] = $service['pCode'];
             unset($service['pCode']);
             unset($service['positions3D']);
         }
         if (isset($service['lat']) && isset($service['lng'])) {
             $distances = distanceKmMiles($coords['lng1'], $coords['lat1'], $service['lng'], $service['lat']);
             $service['distance'] = (double) $distances['km'];
         }
         ksort($service);
         $service['poi'] = $poi;
         if (false === $add) {
             $collection[] = $service;
         }
         if (true === $add) {
             $distance = $service['distance'];
             unset($service['distance']);
             $etab = rdb('geo', 'etablissement')->firstOrCreate($service)->setPoi($poi)->save();
             setLocation($etab, $etab->lng, $etab->lat);
             if (!empty($supplements)) {
                 foreach ($supplements as $supK => $supV) {
                     $setter = setter($supK);
                     $etab->{$setter}($supV);
                 }
                 $etab->save();
             }
             $fields = $etab->_keys();
             $sFields = array_merge(array_keys($service), array_keys($supplements));
             $except = ['id', 'poi', 'created_at', 'updated_at'];
             $resave = false;
             $expurge = [];
             foreach ($fields as $field) {
                 if (!in_array($field, $except)) {
                     if (!in_array($field, $sFields)) {
                         $expurge[] = $field;
                         $etab = $etab->expurge($field);
                         $resave = true;
                     }
                 }
             }
             if (true === $resave) {
                 $etab = $etab->save();
             }
             foreach ($serviceproxIds as $serviceproxId) {
                 $spTmp = rdb('geo', 'service')->find((int) $serviceproxId);
                 $spTmp->attach($etab);
             }
             $zone = rdb('geo', 'zone')->find(1);
             $zone->attach($etab);
             $service['new'] = true;
             $service['id'] = $etab->id;
             $service['distance'] = $distance;
         }
         $collection[] = $service;
     }
     if (!empty($collection)) {
         $tuples = $new = [];
         $collection->sortBy('distance');
         foreach ($collection as $row) {
             $hasPoi = isAke($row, 'poi', false);
             if (false === $hasPoi) {
                 $new[] = $row;
             } else {
                 $poi = sha1($hasPoi);
                 if (!in_array($poi, $tuples)) {
                     $tuples[] = $poi;
                     $new[] = $row;
                 }
             }
         }
         $collection = lib('collection', [$new]);
     }
     return $collection->toArray();
 }