isChecked($deviceArray, $device) ? 'checked' : ''; } public function getDeviceWHChk($deviceArray, $device) { return $this->isChecked($deviceArray, $device) ? 'display:none' : 'display:inline-block'; } public function getDeviceAmount($amountArray, $device) { return $this->isValidAmountArray($amountArray, $device) ? $amountArray['d' . $device['device_id'] . '_amount'] : ''; } private function isChecked($deviceArray, $device) { return isset($deviceArray) && $deviceArray['d' . $device['device_id']] != 'x'; } private function isValidAmountArray($amountArray, $device) { return isset($amountArray) && $amountArray['d' . $device['device_id'] . '_amount'] != ''; } private function isCheckedForDailyIncomeHUF($deviceArray) { return isset($deviceArray) && $deviceArray['_daily_HUF'] != 'x'; } private function isCheckedForDailyIncomeEUR($deviceArray) { return isset($deviceArray) && $deviceArray['_daily_EUR'] != 'x'; } public function getCheckedDailyIncomeHUF($deviceArray) { return $this->isCheckedForDailyIncomeHUF($deviceArray) ? 'checked' : ''; } public function getDailyAmountHUFChk($deviceArray) { return $this->isCheckedForDailyIncomeHUF($deviceArray) ? 'display:none' : 'display:inline-block'; } public function getCheckedDailyIncomeEUR($deviceArray) { return $this->isCheckedForDailyIncomeEUR($deviceArray) ? 'checked' : ''; } public function getDailyAmountEURChk($deviceArray) { return $this->isCheckedForDailyIncomeEUR($deviceArray) ? 'display:none' : 'display:inline-block'; } public function getJSONArray($array) { $jsonArray = []; foreach ($_REQUEST['withholding'] as $whgroup) { foreach ($whgroup as $dkey => $dvalue) { if (stripos($dkey, '_amount') == false) { $OK = $dvalue == '1' ? 'OK' : ''; $jsonArray[$dkey] = $OK; } else { $value = $dvalue != '' ? $dvalue : ''; $jsonArray[$dkey] = $value; } } } return $jsonArray; } public function getDeviceArray($PackageHistoryClosed) { $deviceArray = []; $dataArray = json_decode($PackageHistoryClosed->note_public); foreach ($dataArray as $key => $value) { if (strpos($key, '_amount') == false) { $deviceArray[$key] = $value == 'OK' ? 1 : 'x'; } } return $deviceArray; } public function getAmountArray($PackageHistoryClosed) { $amountArray = []; $dataArray = json_decode($PackageHistoryClosed->note_public); foreach ($dataArray as $key => $value) { if (strpos($key, '_amount') == true) { $amountArray[$key] = $value != '' ? $value : ''; } } return $amountArray; } public function getHeader($object, $user_id, $idmenu) { global $db, $langs, $conf; $langs->load("settlements@settlements"); $h = 0; $head = array(); $head[$h][0] = dol_buildpath("/settlements/dailyclosing_card.php", 1) . '?user_id=' . $user_id . '&idmenu=' . $idmenu . '&mainmenu=settlements&leftmenu='; $head[$h][1] = $langs->trans("DailyClosing"); $head[$h][2] = 'card'; $h++; $head[$h][0] = dol_buildpath("/settlements/dailyclosing_list.php", 1) . '?user_id=' . $user_id . '&idmenu=' . $idmenu . '&mainmenu=settlements&leftmenu='; $head[$h][1] = $langs->trans("DailyClosingHistory"); $head[$h][2] = 'list'; $h++; complete_head_from_modules($conf, $langs, $object, $head, $h, 'group@settlements'); return $head; } public function getAllHistoryRecords($sql) { global $db; $historyRecords = []; $result = $db->query($sql); while ($row = pg_fetch_assoc($result)) { $historyRecords[] = $row; } return $historyRecords; } function setRowColor($rownum) { return $rownum % 2 == 0 ? '#b0c4de' : 'white'; } private function setStatus($status) { return $status ? 'Closed' : 'Open'; } function tableDrawerForDailyClosing($allHistoryRecords, $idmenu) { $rownum = 0; foreach ($allHistoryRecords as $record) { $url = '/custom/settlements/dailyclosinghistory_card.php?id=' . $record['rowid'] . '&user_id=' . $record['user_id'] . '&idmenu=' . $idmenu . '&mainmenu=settlements&leftmenu='; $bgcolor = $this->setRowColor($rownum); print ' ' . $record['rowid'] . ''; print '' . $record['date_creation'] . ''; print '' . $record['lastname'] . ' ' . $record['firstname'] . ''; print '' . $this->setStatus($record['status']) . ''; print ''; $rownum++; } } function get1stBlocHistorykDataOpen($id) { global $db; $packageHistoryRecordObj = new PackageHistory($db); $packageHistoryRecordObj->fetch($id); /* $sql = "SELECT pack.label as packetlabel, gt.label as grouptool, ph.fk_group_id, ph.user_id, ph.package_id, ph.rowid, gu.fk_settlements_group, gr.ref as usergroup, ph.date_creation FROM public.llx_rollerstorage_packagehistory AS ph INNER JOIN llx_settlements_package as pack ON pack.rowid=ph.package_id INNER JOIN llx_settlements_grouptools as gt ON gt.rowid = ph.fk_group_id INNER JOIN llx_settlements_groupusers as gu ON gu.fk_user = ph.user_id INNER JOIN llx_settlements_group as gr ON gr.rowid=gu.fk_settlements_group WHERE ph.rowid = {$id}"; $data = $db->query($sql); $packageHistoryObj = pg_fetch_object($data); return $packageHistoryObj;*/ return $packageHistoryRecordObj; } function get1stBlocHistorykData($id) { global $db; $packageHistoryObj = new PackageHistory($db); $packageHistoryObj->fetch($id); return $packageHistoryObj; } function get1stBlocHistorykDataClosed($id) { global $db; $packageHistoryObj = new PackageHistory($db); $packageHistoryObj->fetch($id); return $packageHistoryObj; } function getStatus($rowid) { global $db; $packageHistoryObj = new PackageHistory($db); $result = $packageHistoryObj->fetch($rowid); return $packageHistoryObj->status; } function closeRecord($id) { global $db, $user; $packageHistoryObj = new PackageHistory($db); $packageHistoryObj->fetch($id); $packageHistoryObj->status = 1; return $packageHistoryObj->update($user); } function getWithholdingRecords($withholdingArray) { foreach ($withholdingArray as $key => $value) { $device_id = $this->getDeviceIdFromString($key); $withholdingRecords[$device_id] = $value; } return $withholdingRecords; } function getDevicesList($devicesArray, $withholdingRecords) { foreach ($devicesArray as $devicevalue) { $withholding = isset($withholdingRecords[$devicevalue['device_id']]) ? $withholdingRecords[$devicevalue['device_id']] : ''; $block2ndArray[] = ["rowid" => $devicevalue['rowid'], "device_id" => $devicevalue['device_id'], "title" => $devicevalue['title'], "ref" => $devicevalue["ref"], "status" => $devicevalue['status'], "withholding" => $withholding]; } return $block2ndArray; } function getDailyIncomes($changes) { $block3rdArray = []; if ($changes) { foreach ($changes as $change) { $tmpArray = explode('_', $change['ref']); $block3rdArray[$tmpArray[1]] = $change['title']; } } return $block3rdArray; } private function getDeviceIdFromString($key) { return substr($key, 1); } function unprintedFActures($group_id, $user_id, $from) { global $db, $langs; $to = date("Y-m-d H:i:s", dol_now()); $sql = "SELECT f.rowid, f.ref, e.label, f.datec, f.total_ttc, f.multicurrency_code, f.fk_statut FROM llx_facture AS f INNER JOIN llx_entity AS e ON e.rowid = f.entity WHERE f.fk_user_author = {$user_id} AND f.datec >= (SELECT un.date_creation FROM public.llx_settlements_usernaplo AS un WHERE un.user_id = {$user_id} AND un.group_user_id = {$group_id} AND un.status = 1 /*AND date_trunc('day', un.date_creation) = CURRENT_DATE*/ ORDER BY un.rowid LIMIT 1) AND f.datec BETWEEN '{$from}' AND '{$to}' AND NOT EXISTS (SELECT 1 FROM llx_bbus_bbticketinvoiceprinting AS b WHERE b.fk_facture = f.rowid) ORDER BY f.rowid DESC;"; //print $sql; $data = $db->query($sql); $result = pg_fetch_all($data); print ''; print ''; if (!empty($result)) { foreach ($result as $record) { print ''; } } else { print ''; } print ''; } function printedFactures($group_id, $user_id) { global $db, $langs; $now = date("Y-m-d H:i:s", dol_now()); $array = []; $sql = "SELECT f.rowid FROM llx_facture AS f INNER JOIN llx_entity AS e ON e.rowid = f.entity WHERE f.fk_user_author = {$user_id} AND f.datec >= (SELECT un.date_creation FROM public.llx_settlements_usernaplo AS un WHERE un.user_id = {$user_id} AND un.group_user_id = {$group_id} AND un.status = 1 ORDER BY un.rowid LIMIT 1) AND f.datec <= '{$now}' AND EXISTS (SELECT 1 FROM llx_bbus_bbticketinvoiceprinting AS b WHERE b.fk_facture = f.rowid) ORDER BY f.rowid DESC;"; //print $sql; $data = $db->query($sql); while ($row = pg_fetch_assoc($data)) { $array[] = $row['rowid']; } return $array; } function setStatut($statut) { switch ($statut) { case '0': return 'Tervezet'; break; case '2': return 'Fizetve'; break; case '1': return 'Nem fizetett'; break; } } function getTheNumberOfPrints($facture_id) { global $db; $array = []; $number = 0; $sql = "SELECT tip.fk_facture, tip.product_id, count(tip.product_id) FROM llx_bbus_bbticketinvoiceprinting as tip WHERE tip.fk_facture = {$facture_id} GROUP BY tip.fk_facture, tip.product_id"; $data = $db->query($sql); while ($row = $db->fetch_object($data)) { $array[$row->fk_facture][$row->product_id] = $row->count; } $firstKey = array_key_first($array); $firstValue = $array[$firstKey]; $number = reset($firstValue); return $number > 1 ? '
' . $number . '
' : '
' . $number . '
'; } }