function AddRemoveItem($xml, $action) { //find detail of item with id $id = $_POST["id"]; $price = findItem($xml, $id, "price"); $curQty = findItem($xml, $id, "quantity"); if ($_SESSION["cart"] != "") { $cart = $_SESSION["cart"]; //read the cart session into local variable if ($action == "Add") { if ($curQty > 0) { if (!isset($cart[$id])) { $qty = 1; // increase no of books by 1 $value = array(); $value["price"] = $price; $value["qty"] = $qty; $cart[$id] = $value; $_SESSION["cart"] = $cart; // save the adjusted cart to session variable //echo (toXml($cart)); // send XML form of CART to client } else { //if $value["qty"] > curQty //=> error $value = $cart[$id]; $value["price"] = $price; $value["qty"] = $value["qty"] + 1; $cart[$id] = $value; $_SESSION["cart"] = $cart; //subtracting 1 from the quantity available and adding 1 to the quantity on hold //echo (toXml($cart)); } } else { echo "sorry"; return; } } else { $value = $cart[$id]; $value["price"] = $price; $value["qty"] = $value["qty"] - 1; $cart[$id] = $value; if ($value["qty"] == 0) { unset($cart[$id]); } $_SESSION["cart"] = $cart; //echo (toXml($cart)); } } elseif ($action == "Add") { $value = array(); $value["price"] = $price; $value["qty"] = "1"; $cart = array(); $cart[$id] = $value; $_SESSION["cart"] = $cart; //echo (toXml($cart)); } updateCart($xml, $cart, $id, $action); }
public function generateInputFragments(&$charData, $nonCombat = false) { $inventory = lazyGetInventory($charData); $inventoryItems = $inventory->items; // We only want one InputFragment per item TYPE. $dedupedNames = []; foreach ($inventoryItems as $itemName) { $item = findItem($itemName); if (is_null($item)) { echo "ERROR: Bad item in inventory ({$itemName})!\n"; exit(14); } $useLocation = $item->useLocation; if ($nonCombat && $useLocation == ItemUse::CombatOnly) { continue; } if (!$nonCombat && $useLocation == ItemUse::NonCombatOnly) { continue; } if ($this->deDupeItemFragments($itemName, $dedupedNames)) { continue; } $this->commands[] = new InputFragment($itemName, function ($charData, $mapData) use($itemName, $nonCombat) { global $usingItem; return $usingItem->useItem($itemName, $charData, $mapData, $nonCombat); }); } $this->commands[] = new InputFragment("cancel", function ($charData, $mapData) use($nonCombat) { echo $nonCombat . "\n\n"; if (!$nonCombat) { echo "You close your bag, and go back to the fight.\n"; StateManager::ChangeState($charData, GameStates::Combat); } else { echo "Deciding against using an item, you go back to Adventuring.\n"; StateManager::ChangeState($charData, GameStates::Adventuring); } }); // Add unique identifiers to commands. $allocator = new UIDAllocator($this->commands); $allocator->Allocate(); }
<?php require __DIR__ . '/../includes/start.php'; $item_id = getvar("id"); $item = findItem($item_id); $item->shop; // Load that data for export $purchase = null; if (me()) { $purchase = findPurchase($item->id, me()->id); } $redirectUrl = "http" . (!empty($_SERVER['HTTPS']) ? "s" : "") . "://" . $_SERVER['HTTP_HOST'] . preg_replace('/item\\.php/', 'paid.php', $_SERVER['REQUEST_URI']); $pageTitle = "Purchase Item"; require __DIR__ . '/../includes/templates/header.php'; ?> <h1>Purchase Item</h1> <?php partial("breadcrumbs", ['category' => $item->category]); ?> <?php if (!$item) { ?> <div class="alert alert-danger"> That item doesn't appear to exist. Try searching for a different one. </div> <?php partial("search-bar", ['q' => ""]);
private function InitItemList($playerLevel, $distance) { // Potion quality is based on player level. $prefix = $this->getPotionPrefix($playerLevel); // Every shop has these items... $healthPotion = findItem($prefix . "health potion"); $magicPotion = findItem($prefix . "magic potion"); $tent = findItem("tent"); // ... but in random quantities. $numInStock = rand(0, 5); for ($i = 0; $i < $numInStock; ++$i) { $this->addStockItem($healthPotion); } $numInStock = rand(0, 3); for ($i = 0; $i < $numInStock; ++$i) { $this->addStockItem($magicPotion); } $numInStock = rand(0, 1); for ($i = 0; $i < $numInStock; ++$i) { $this->addStockItem($tent); } // Random weapons/armour. $this->InitRandomEquipment($playerLevel, $distance); }
$equipment = $adventuring->getEquippedItemsStr($charData); echo $equipment . "\n"; }); // Use an item from the inventory $adventuring->commands[] = new InputFragment("use item", function ($charData, $mapData) { global $usingItem; $inventory = lazyGetInventory($charData); if (empty($inventory->items)) { echo "After a quick rummage in your bag, it looks like you don't have anything of use.\n"; return; } $output = "Choose an item: "; // We are not in combat, hence the "true" $usingItem->generateInputFragments($charData, true); foreach ($usingItem->commands as $fragment) { $item = findItem($fragment->token); if (is_null($item)) { continue; } // Don't show combat-only items. if ($item->useLocation == ItemUse::CombatOnly) { continue; } $output .= "{$fragment->displayString}, "; } $output = rtrim($output, ", ") . "\n"; echo $output; StateManager::ChangeState($charData, GameStates::UsingItem); }); // Check your inventory. $adventuring->commands[] = new InputFragment("inventory", function ($charData, $mapData) {
$pdf->SetFont('', 'B'); $pdf->MultiCell(0, 12, utf8_decode("Liste des gardes et des astreintes qui sont attribuées à :" . requetemysql::gestion_string_maj(htmlentities($_POST['login'])) . " sur la période du :" . requetemysql::gestion_string_norm($_POST['date_debut']) . " au " . requetemysql::gestion_string_norm($_POST['date_fin'])), 0, '', true); $pdf->SetFont('Times', '', 12); // Largeurs des colonnes $w = array(190 / 6, 190 / 7, 190 / 10, 190 / 10, 190 / 10, 190 / 10, 190 / 7, 190 / 7); $header = array(utf8_decode('Date'), utf8_decode('Nature'), utf8_decode("jour sem"), utf8_decode("nuit sem"), utf8_decode("nuit we"), utf8_decode("jour we"), utf8_decode('heure de début'), utf8_decode('heure de fin')); // En-tête for ($i = 0; $i < count($header); $i++) { $pdf->Cell($w[$i], 7, $header[$i], 1, 0, 'C'); } $pdf->Ln(); // Données $pdf->SetFont('Times', '', 8); foreach ($planning2 as $row) { if ($row['login'] == $_POST['login']) { $mon_item = findItem($row['date_fin'], $row['login'], '00:00', $planning2, 'date_debut', 'login', 'start_heure'); if ($choix_affichage == 2) { $pdf->Cell($w[0], 6, requetemysql::gestion_string_maj($row['ma_date2']), 'LR', 0, 'C'); $pdf->Cell($w[1], 6, requetemysql::gestion_string_norm($row['nature'] == 0 ? "garde" : "astreinte"), 'LR', 0, 'R'); $pdf->Cell($w[2], 6, requetemysql::gestion_string_norm(touvelejour(date("w", $row['date_debut']), date("G", $row['date_debut'])) == 0 ? "X" : ""), 'LR', 0, 'R'); $pdf->Cell($w[3], 6, requetemysql::gestion_string_norm(touvelejour(date("w", $row['date_debut']), date("G", $row['date_debut'])) == 1 ? "X" : ""), 'LR', 0, 'R'); $pdf->Cell($w[4], 6, requetemysql::gestion_string_norm(touvelejour(date("w", $row['date_debut']), date("G", $row['date_debut'])) == 2 ? "X" : ""), 'LR', 0, 'R'); $pdf->Cell($w[5], 6, requetemysql::gestion_string_norm(touvelejour(date("w", $row['date_debut']), date("G", $row['date_debut'])) == 3 ? "X" : ""), 'LR', 0, 'R'); $pdf->Cell($w[6], 6, requetemysql::gestion_string_norm($row['start_heure']), 'LR', 0, 'R'); $pdf->Cell($w[7], 6, requetemysql::gestion_string_norm($row['end_heure']), 'LR', 0, 'R'); $pdf->Ln(); } else { if ($choix_affichage == 1) { if (count($mon_item) == 0 && $row['start_heure'] != '00:00') { $pdf->Cell($w[0], 6, requetemysql::gestion_string_maj($row['ma_date2']), 'LR', 0, 'C'); $pdf->Cell($w[1], 6, requetemysql::gestion_string_norm($row['nature'] == 0 ? "garde" : "astreinte"), 'LR', 0, 'R');
{ $sql_query = 'SELECT * FROM ITEM WHERE inventory_id="' . $invId . '" AND serial_number="' . $serial . '"'; return mysql_query($sql_query); } //Update an item record with values provided function updateItem($invId, $serial, $item, $model, $cat, $man, $pdate, $value, $notes, $database) { $sql_query = "UPDATE ITEM SET item_name=\"" . $item . "\",value=" . $value . ",model='" . $model . "',manufacturer=\"" . $man . "\",category=\"" . $cat . "\",item_purchase_date=\"" . $pdate . "\",notes=\"" . $notes . "\" WHERE inventory_id=" . $invId . " AND serial_number=" . $serial; mysql_query($sql_query); } //Checks method type passed and calls appropriate function if ($method == "addItem") { addNewItem($invId, $serial, $item, $model, $cat, $man, $pdate, $value, $notes, $database); } else { if ($method == "findItem") { $result = findItem($serial, $invId, $database); if (mysql_num_rows($result) == 1) { //Gathers table fields to insert into json response while ($row = mysql_fetch_array($result)) { echo '{"item":{'; echo '"itemName":"' . $row['item_name'] . '",'; echo '"value":"' . $row['value'] . '",'; echo '"model":"' . $row['model'] . '",'; echo '"man":"' . $row['manufacturer'] . '",'; echo '"cat":"' . $row['category'] . '",'; echo '"pdate":"' . $row['item_purchase_date'] . '",'; echo '"notes":"' . $row['notes'] . '"'; echo '}}'; } } else { echo '{"error":"Item could not be found in inventory."}';
/** * print_result * print a pdf file wich contain schedule of the shift * * @param array $arr : * @param array $arr['agenda'] schedule with param (login, job, job2, ma_date, date_debut, date_fin) * @param array $arr['team'] team with param (login, nom, adresse, code, commune, tel1, tel2, mail) * @param int $arr['choix_affichage'] choice concerning date in the schedule : 1 for put date j+1 2 for split date 1 to midnight 1 after * @param int $arr['cas_affichage'] choice concerning the goal : 1 for global schedule, 2 for global schedule and all schedule of member, 3 for distinct member schedule * @param string $arr['date_debut'] date of the begin of the selected month format : DD/MM/YYYY * @param string $arr['date_fin'] date of the end of the selected month format : DD/MM/YYYY * @param string $arr['date_debut2'] date of the begin of the selected month format : DD_MM_YYYY * @param string $arr['date_fin2'] date of the end of the selected month format : DD_MM_YYYY * @param int $arr['date_debut3'] date of the begin of the selected month format : millisecond unix * @param int $arr['date_fin3'] date of the end of the selected month format : millisecond unix * @param array $arr['liste_jour'] list of day name and order * @param string $arr['login'] login name for distinct member schedule search * @return json json of ok */ public static function print_result($arr) { try { require 'fpdf/fpdf.php'; require 'fpdi/fpdi.php'; $choix_affichage = $arr['choix_affichage']; $filename = 'planning/'; if (!file_exists($filename)) { if (!mkdir($filename, 0755, true)) { die('Echec lors de la création des répertoires...'); } } $pdf = new FPDF(); $date_debut = mktime(0, 0, 0, date("m", $arr['date_debut3'] / 1000), date("d", $arr['date_debut3'] / 1000), date("Y", $arr['date_debut3'] / 1000)); $date_debut_o = $date_debut; $date_fin = mktime(0, 0, 0, date("m", $arr['date_fin3'] / 1000), date("d", $arr['date_fin3'] / 1000), date("Y", $arr['date_fin3'] / 1000)); $planning2 = $arr['agenda']; while ($date_debut < $date_fin) { if ($date_debut == mktime(0, 0, 0, date("m", $date_debut), 1, date("Y", $date_debut)) || $date_debut == $date_debut_o) { $pdf->AddPage(); $pdf->SetFont('Times', '', 12); $pdf->Cell(90); $pdf->MultiCell(85, 5, "Le " . date("d.m.y"), 0, 'L'); if (isset($_SESSION['login2'])) { $pdf->MultiCell(85, 5, requetemysql::gestion_string_maj(TXT_CHARGEMENT_EXPORT8 . " " . $_SESSION['login2']), 0, 'L'); } else { $pdf->MultiCell(85, 5, requetemysql::gestion_string_maj(TXT_CHARGEMENT_EXPORT8 . " " . TXT_CHARGEMENT_EXPORT9), 0, 'L'); } $pdf->SetFont('Times', '', 18); $pdf->SetFillColor(153, 153, 153); $pdf->SetTextColor(0, 0, 0); $pdf->SetDrawColor(153, 153, 153); $pdf->SetLineWidth(0.3); $pdf->SetFont('', 'B'); if ($arr['cas_affichage'] == 1) { $pdf->MultiCell(0, 12, utf8_decode(TXT_CHARGEMENT_EXPORT5 . " " . requetemysql::gestion_string_norm(strftime("%B", $date_debut)) . " " . requetemysql::gestion_string_norm(date("Y", $date_debut))), 0, '', true); } else { if ($arr['cas_affichage'] == 2) { $pdf->MultiCell(0, 12, utf8_decode(TXT_CHARGEMENT_EXPORT6 . " " . requetemysql::gestion_string_norm(strftime("%B", $date_debut)) . " " . requetemysql::gestion_string_norm(date("Y", $date_debut))), 0, '', true); } else { if ($arr['cas_affichage'] == 3) { $pdf->MultiCell(0, 12, utf8_decode(TXT_CHARGEMENT_EXPORT7 . " " . requetemysql::gestion_string_maj(htmlentities($_POST['login'])) . " :" . requetemysql::gestion_string_norm(strftime("%B", $date_debut)) . " " . requetemysql::gestion_string_norm(date("Y", $date_debut))), 0, '', true); } } } $pdf->SetFont('Times', '', 10); // Largeurs des colonnes $w = array(190 / 7, 190 / 7, 190 / 7, 190 / 7, 190 / 7, 190 / 7, 190 / 7); $header = $arr['liste_jour']; $hauteur = 3; $x2 = $pdf->GetY(); // En-tête for ($i = 0; $i < count($header); $i++) { $pdf->SetXY($w[$i] * $i + 10, $x2); $pdf->MultiCell($w[$i], $hauteur, $header[$i]["nom"], 0, 'C'); if ($header[$i]["valeur"] == date("w", $date_debut)) { $case_vide = $i - 1; } } $pdf->Ln(); $x2 = $pdf->GetY(); if ($case_vide >= 0) { for ($i = 0; $i <= $case_vide; $i++) { $pdf->SetXY($w[$i] * $i + 10, $x2); $pdf->MultiCell($w[0], $hauteur, "--", 'LRTB', 'C'); } } $x3 = ($case_vide + 1) * $w[$i] + 10; $max_y = 0; } // Données $pdf->SetFont('Times', '', 8); $trouve = false; $mon_texte = date("d", $date_debut) . "\n"; foreach ($planning2 as $row) { if ($date_debut == $row->ma_date / 1000) { $mon_item = findItem($row->date_fin / 1000, $row->login, '00:00', $planning2, 'date_debut', 'login', 'start_heure'); if ($arr['cas_affichage'] == 1 || $arr['cas_affichage'] == 2) { if ($choix_affichage == 2) { $mon_texte .= $row->job2 . ": " . $row->login . " " . $row->start_heure . "h-" . $row->end_heure . "h \n"; } else { if ($choix_affichage == 1) { if (count($mon_item) == 0 && $row->start_heure != '00:00') { $mon_texte .= $row->job2 . ": " . $row->login . " " . $row->start_heure . "h-" . $row->end_heure . "h \n"; } else { if ($row->start_heure != '00:00') { $mon_texte .= $row->job2 . ": " . $row->login . " " . $row->start_heure . "h-" . $mon_item[0]->end_heure . "h(J+1) \n"; } } } } } else { if ($row->login == $arr['login']) { if ($choix_affichage == 2) { $mon_texte .= $row->job2 . ": " . $row->login . " " . $row->start_heure . "-" . $row->end_heure . " \n"; } else { if ($choix_affichage == 1) { if (count($mon_item) == 0 && $row->start_heure != '00:00') { $mon_texte .= $row->job2 . ": " . $row->login . " " . $row->start_heure . "h-" . $row->end_heure . "h \n"; } else { if ($row->start_heure != '00:00') { $mon_texte .= $row->job2 . ": " . $row->login . " " . $row->start_heure . "h-" . $mon_item[0]->end_heure . "h(J+1) \n"; } } } } } else { // $mon_texte .= ($row['nature']==0 ? "G" : "A").": ".$row->start_heure."-".$row->end_heure." \n" ; } } $trouve = true; } } if ($trouve == true) { $pdf->SetXY($x3, $x2); $pdf->MultiCell($w[0], $hauteur, requetemysql::gestion_string_maj($mon_texte), 'LRTB', 'C', false); $max_y2 = $pdf->GetY(); if ($max_y2 > $max_y) { $max_y = $max_y2; } } if ($trouve == false) { $pdf->SetXY($x3, $x2); $pdf->Cell($w[0], $hauteur, requetemysql::gestion_string_maj(date("d", $date_debut)), 'LRTB', 'C', false); $max_y2 = $pdf->GetY(); if ($max_y2 > $max_y) { $max_y = $max_y2; } } if (date("w", $date_debut) == $header[count($header) - 1]["valeur"]) { $x2 = $max_y; $x2 += $hauteur; $x3 = 10; $max_y = 0; } else { $x3 += $w[0]; } $date_debut = mktime(0, 0, 0, date("m", $date_debut), date("d", $date_debut) + 1, date("Y", $date_debut)); } if ($arr['cas_affichage'] == 2) { foreach ($arr['team'] as $row2) { $row2->login; $date_debut = mktime(0, 0, 0, date("m", $arr['date_debut3'] / 1000), date("d", $arr['date_debut3'] / 1000), date("Y", $arr['date_debut3'] / 1000)); $date_debut_o = $date_debut; $date_fin = mktime(0, 0, 0, date("m", $arr['date_fin3'] / 1000), date("d", $arr['date_fin3'] / 1000), date("Y", $arr['date_fin3'] / 1000)); $planning2 = $arr['agenda']; while ($date_debut < $date_fin) { if ($date_debut == mktime(0, 0, 0, date("m", $date_debut), 1, date("Y", $date_debut)) || $date_debut == $date_debut_o) { if (isset($_SESSION['login2'])) { $info_veto = requetemysql::info_veterinaire(array('login' => strtolower($_SESSION['login']))); if (empty($info_veto)) { throw new Exception("Erreur dans la recherche des informations sur le vétérinaire"); } else { $info_veto = json_decode($info_veto, true); } } $info_veto2 = $row2; $pdf->AddPage(); $pdf->Image('../images/logo/essai1.jpg', 10, 6, 30); if (isset($_SESSION['login2'])) { $pdf->SetFont('Times', '', 18); $titre3 = utf8_decode(stripslashes(ucfirst($info_veto[0]['nom']))); $w = $pdf->GetStringWidth(stripslashes($titre3)) + 6; $pdf->SetX((210 - $w) / 2); $pdf->Cell($w, 7, $titre3, 0, 'C'); $pdf->Ln(); $w = $pdf->GetStringWidth(utf8_decode(stripslashes($info_veto[0]['adresse']))) + 6; $pdf->SetX((210 - $w) / 2); $pdf->Cell($w, 7, utf8_decode(stripslashes($info_veto[0]['adresse'])), 0, 'C'); $pdf->Ln(); $w = $pdf->GetStringWidth(utf8_decode(stripslashes($info_veto[0]['code'] . " " . $info_veto[0]['commune']))) + 6; $pdf->SetX((210 - $w) / 2); $pdf->Cell($w, 7, utf8_decode(stripslashes($info_veto[0]['code'] . " " . $info_veto[0]['commune'])), 0, 'C'); $pdf->Ln(); $pdf->SetFont('Times', '', 12); $w = $pdf->GetStringWidth(utf8_decode(stripslashes($info_veto[0]['tel']))) + 6; $pdf->SetX((210 - $w) / 2); $pdf->Cell($w, 7, utf8_decode(stripslashes($info_veto[0]['tel'])), 0, 'C'); $pdf->Ln(15); } $pdf->Cell(90); $pdf->MultiCell(85, 5, requetemysql::gestion_string_maj($info_veto2->nom) . "\n" . requetemysql::gestion_string_norm($info_veto2->adresse) . "\n" . requetemysql::gestion_string_norm($info_veto2->code) . ' ' . requetemysql::gestion_string_norm($info_veto2->commune), 0, 'C'); $pdf->Ln(25); $pdf->Cell(90); $pdf->MultiCell(85, 5, "Le " . date("d.m.y"), 0, 'L'); if (isset($_SESSION['login2'])) { $pdf->MultiCell(85, 5, requetemysql::gestion_string_maj(TXT_CHARGEMENT_EXPORT8 . " " . $_SESSION['login2']), 0, 'L'); } else { $pdf->MultiCell(85, 5, requetemysql::gestion_string_maj(TXT_CHARGEMENT_EXPORT8 . " " . TXT_CHARGEMENT_EXPORT9), 0, 'L'); } $pdf->SetFont('Times', '', 18); $pdf->SetFillColor(153, 153, 153); $pdf->SetTextColor(0, 0, 0); $pdf->SetDrawColor(153, 153, 153); $pdf->SetLineWidth(0.3); $pdf->SetFont('', 'B'); $pdf->MultiCell(0, 12, utf8_decode(TXT_CHARGEMENT_EXPORT7 . " " . requetemysql::gestion_string_maj(htmlentities($row2->login)) . " :" . requetemysql::gestion_string_norm(strftime("%B", $date_debut)) . " " . requetemysql::gestion_string_norm(date("Y", $date_debut))), 0, '', true); $pdf->SetFont('Times', '', 10); // Largeurs des colonnes $w = array(190 / 7, 190 / 7, 190 / 7, 190 / 7, 190 / 7, 190 / 7, 190 / 7); $header = $arr['liste_jour']; $hauteur = 3; $x2 = $pdf->GetY(); // En-tête for ($i = 0; $i < count($header); $i++) { $pdf->SetXY($w[$i] * $i + 10, $x2); $pdf->MultiCell($w[$i], $hauteur, $header[$i]["nom"], 0, 'C'); if ($header[$i]["valeur"] == date("w", $date_debut)) { $case_vide = $i - 1; } } $pdf->Ln(); $x2 = $pdf->GetY(); if ($case_vide >= 0) { for ($i = 0; $i <= $case_vide; $i++) { $pdf->SetXY($w[$i] * $i + 10, $x2); $pdf->MultiCell($w[0], $hauteur, "--", 'LRTB', 'C'); } } $x3 = ($case_vide + 1) * $w[$i] + 10; $max_y = 0; } // Données $pdf->SetFont('Times', '', 8); $trouve = false; $mon_texte = date("d", $date_debut) . "\n"; foreach ($planning2 as $row) { if ($date_debut == $row->ma_date / 1000) { $mon_item = findItem($row->date_fin / 1000, $row->login, '00:00', $planning2, 'date_debut', 'login', 'start_heure'); if ($row->login == $row2->login) { if ($choix_affichage == 2) { $mon_texte .= $row->job2 . ": " . $row->login . " " . $row->start_heure . "-" . $row->end_heure . " \n"; } else { if ($choix_affichage == 1) { if (count($mon_item) == 0 && $row->start_heure != '00:00') { $mon_texte .= $row->job2 . ": " . $row->login . " " . $row->start_heure . "h-" . $row->end_heure . "h \n"; } else { if ($row->start_heure != '00:00') { $mon_texte .= $row->job2 . ": " . $row->login . " " . $row->start_heure . "h-" . $mon_item[0]->end_heure . "h(J+1) \n"; } } } } } else { // $mon_texte .= ($row['nature']==0 ? "G" : "A").": ".$row->start_heure."-".$row->end_heure." \n" ; } $trouve = true; } } if ($trouve == true) { $pdf->SetXY($x3, $x2); $pdf->MultiCell($w[0], $hauteur, requetemysql::gestion_string_maj($mon_texte), 'LRTB', 'C', false); $max_y2 = $pdf->GetY(); if ($max_y2 > $max_y) { $max_y = $max_y2; } } if ($trouve == false) { $pdf->SetXY($x3, $x2); $pdf->Cell($w[0], $hauteur, requetemysql::gestion_string_maj(date("d", $date_debut)), 'LRTB', 'C', false); $max_y2 = $pdf->GetY(); if ($max_y2 > $max_y) { $max_y = $max_y2; } } if (date("w", $date_debut) == $header[count($header) - 1]["valeur"]) { $x2 = $max_y; $x2 += $hauteur; $x3 = 10; $max_y = 0; } else { $x3 += $w[0]; } $date_debut = mktime(0, 0, 0, date("m", $date_debut), date("d", $date_debut) + 1, date("Y", $date_debut)); } } } if ($arr['cas_affichage'] == 3) { $date_debut = mktime(0, 0, 0, date("m", $arr['date_debut3'] / 1000), date("d", $arr['date_debut3'] / 1000), date("Y", $arr['date_debut3'] / 1000)); $date_debut_o = $date_debut; $date_fin = mktime(0, 0, 0, date("m", $arr['date_fin3'] / 1000), date("d", $arr['date_fin3'] / 1000), date("Y", $arr['date_fin3'] / 1000)); while ($date_debut < $date_fin) { if ($date_debut == mktime(0, 0, 0, date("m", $date_debut), 1, date("Y", $date_debut)) || $date_debut == $date_debut_o) { $pdf->AddPage(); $pdf->SetFont('Times', '', 12); $pdf->Cell(90); $pdf->MultiCell(85, 5, "Le " . date("d.m.y"), 0, 'L'); if (isset($_SESSION['login2'])) { $pdf->MultiCell(85, 5, requetemysql::gestion_string_maj(TXT_CHARGEMENT_EXPORT8 . " " . $_SESSION['login2']), 0, 'L'); } else { $pdf->MultiCell(85, 5, requetemysql::gestion_string_maj(TXT_CHARGEMENT_EXPORT8 . " " . TXT_CHARGEMENT_EXPORT9), 0, 'L'); } $pdf->SetFont('Times', '', 18); $pdf->SetFillColor(153, 153, 153); $pdf->SetTextColor(0, 0, 0); $pdf->SetDrawColor(153, 153, 153); $pdf->SetLineWidth(0.3); $pdf->SetFont('', 'B'); $pdf->MultiCell(0, 12, utf8_decode(TXT_CHARGEMENT_EXPORT10 . " " . requetemysql::gestion_string_norm(strftime("%B", $date_debut)) . " " . requetemysql::gestion_string_norm(date("Y", $date_debut))), 0, '', true); $pdf->SetFont('Times', '', 10); // Largeurs des colonnes $w = array(190 / 7, 190 / 7, 190 / 7, 190 / 7, 190 / 7, 190 / 7, 190 / 7); $hauteur = 3; $x2 = $pdf->GetY(); // En-tête for ($i = 0; $i < count($header); $i++) { $pdf->SetXY($w[$i] * $i + 10, $x2); $pdf->MultiCell($w[$i], $hauteur, $header[$i]["nom"], 0, 'C'); if ($header[$i]["valeur"] == date("w", $date_debut)) { $case_vide = $i - 1; } } $pdf->Ln(); $x2 = $pdf->GetY(); if ($case_vide >= 0) { for ($i = 0; $i <= $case_vide; $i++) { $pdf->SetXY($w[$i] * $i + 10, $x2); $pdf->MultiCell($w[0], $hauteur, "--", 'LRTB', 'C'); } } $x3 = ($case_vide + 1) * $w[$i] + 10; $max_y = 0; } // Données $pdf->SetFont('Times', '', 8); $trouve = false; $mon_texte = date("d", $date_debut) . "\n"; foreach ($planning2 as $row) { if ($date_debut == $row->ma_date / 1000) { $mon_item = findItem($row->date_fin / 1000, $row->login, '00:00', $planning2, 'date_debut', 'login', 'start_heure'); if ($choix_affichage == 2) { $mon_texte .= $row->job2 . ": " . $row->login . " " . $row->start_heure . "h-" . $row->end_heure . "h \n"; } else { if ($choix_affichage == 1) { if (count($mon_item) == 0 && $row->start_heure != '00:00') { $mon_texte .= $row->job2 . ": " . $row->login . " " . $row->start_heure . "h-" . $row->end_heure . "h \n"; } else { if ($row->start_heure != '00:00') { $mon_texte .= $row->job2 . ": " . $row->login . " " . $row->start_heure . "h-" . $mon_item[0]->end_heure . "h(J+1) \n"; } } } } $trouve = true; } } if ($trouve == true) { $pdf->SetXY($x3, $x2); $pdf->MultiCell($w[0], $hauteur, requetemysql::gestion_string_maj($mon_texte), 'LRTB', 'C', false); $max_y2 = $pdf->GetY(); if ($max_y2 > $max_y) { $max_y = $max_y2; } } if ($trouve == false) { $pdf->SetXY($x3, $x2); $pdf->Cell($w[0], $hauteur, requetemysql::gestion_string_maj(date("d", $date_debut)), 'LRTB', 'C', false); $max_y2 = $pdf->GetY(); if ($max_y2 > $max_y) { $max_y = $max_y2; } } if (date("w", $date_debut) == $header[count($header) - 1]["valeur"]) { $x2 = $max_y; $x2 += $hauteur; $x3 = 10; $max_y = 0; } else { $x3 += $w[0]; } $date_debut = mktime(0, 0, 0, date("m", $date_debut), date("d", $date_debut) + 1, date("Y", $date_debut)); } if (isset($_SESSION['login2'])) { $info_veto = requetemysql::info_veterinaire(array('login' => strtolower($_SESSION['login']))); if (empty($info_veto)) { throw new Exception("Erreur dans la recherche des informations sur le vétérinaire"); } else { $info_veto = json_decode($info_veto, true); } } $var_tempo = $arr['login']; $info_veto2 = array_values(array_filter($arr['team'], function ($var) use($var_tempo) { return $var->login == $var_tempo; })); // var_error_log($info_veto2[0]); $pdf->AddPage(); $pdf->Image('../images/logo/essai1.jpg', 10, 6, 30); if (isset($_SESSION['login2'])) { $pdf->SetFont('Times', '', 18); $titre3 = utf8_decode(stripslashes(ucfirst($info_veto[0]['nom']))); $w = $pdf->GetStringWidth(stripslashes($titre3)) + 6; $pdf->SetX((210 - $w) / 2); $pdf->Cell($w, 7, $titre3, 0, 'C'); $pdf->Ln(); $w = $pdf->GetStringWidth(utf8_decode(stripslashes($info_veto[0]['adresse']))) + 6; $pdf->SetX((210 - $w) / 2); $pdf->Cell($w, 7, utf8_decode(stripslashes($info_veto[0]['adresse'])), 0, 'C'); $pdf->Ln(); $w = $pdf->GetStringWidth(utf8_decode(stripslashes($info_veto[0]['code'] . " " . $info_veto[0]['commune']))) + 6; $pdf->SetX((210 - $w) / 2); $pdf->Cell($w, 7, utf8_decode(stripslashes($info_veto[0]['code'] . " " . $info_veto[0]['commune'])), 0, 'C'); $pdf->Ln(); $pdf->SetFont('Times', '', 12); $w = $pdf->GetStringWidth(utf8_decode(stripslashes($info_veto[0]['tel']))) + 6; $pdf->SetX((210 - $w) / 2); $pdf->Cell($w, 7, utf8_decode(stripslashes($info_veto[0]['tel'])), 0, 'C'); $pdf->Ln(15); } $pdf->Cell(90); $pdf->MultiCell(85, 5, requetemysql::gestion_string_maj($info_veto2[0]->nom) . "\n" . requetemysql::gestion_string_norm($info_veto2[0]->adresse) . "\n" . requetemysql::gestion_string_norm($info_veto2[0]->code) . ' ' . requetemysql::gestion_string_norm($info_veto2[0]->commune), 0, 'C'); $pdf->Ln(25); $pdf->MultiCell(85, 5, "Le " . date("d.m.y"), 0, 'L'); if (isset($_SESSION['login2'])) { $pdf->MultiCell(85, 5, requetemysql::gestion_string_maj(TXT_CHARGEMENT_EXPORT8 . $_SESSION['login2']), 0, 'L'); } else { $pdf->MultiCell(85, 5, requetemysql::gestion_string_maj(TXT_CHARGEMENT_EXPORT23), 0, 'L'); } $pdf->SetFont('Times', '', 18); $pdf->SetFillColor(153, 153, 153); $pdf->SetTextColor(0, 0, 0); $pdf->SetDrawColor(153, 153, 153); $pdf->SetLineWidth(0.3); $pdf->SetFont('', 'B'); $pdf->MultiCell(0, 12, utf8_decode("Liste des gardes et des astreintes qui sont attribuées à :" . requetemysql::gestion_string_maj(htmlentities($arr['login'])) . " sur la période du :" . requetemysql::gestion_string_norm($_POST['date_debut']) . " au " . requetemysql::gestion_string_norm($_POST['date_fin'])), 0, '', true); $pdf->SetFont('Times', '', 12); // Largeurs des colonnes $w = array(190 / 6, 190 / 7, 190 / 10, 190 / 10, 190 / 10, 190 / 10, 190 / 7, 190 / 7); $header = array(utf8_decode(TXT_CHARGEMENT_EXPORT25), utf8_decode(TXT_CHARGEMENT_EXPORT26), utf8_decode("jour sem"), utf8_decode("nuit sem"), utf8_decode("nuit we"), utf8_decode("jour we"), utf8_decode('heure de début'), utf8_decode('heure de fin')); // En-tête for ($i = 0; $i < count($header); $i++) { $pdf->Cell($w[$i], 7, $header[$i], 1, 0, 'C'); } $pdf->Ln(); // Données $pdf->SetFont('Times', '', 8); foreach ($planning2 as $row) { if ($row->login == $arr['login']) { $mon_item = findItem($row->date_fin / 1000, $row->login, '00:00', $planning2, 'date_debut', 'login', 'start_heure'); if ($choix_affichage == 2) { $pdf->Cell($w[0], 6, requetemysql::gestion_string_maj(date("d/m", $row->ma_date / 1000)), 'LR', 0, 'C'); $pdf->Cell($w[1], 6, requetemysql::gestion_string_norm($row->job2), 'LR', 0, 'R'); $pdf->Cell($w[2], 6, requetemysql::gestion_string_norm(touvelejour(date("w", $row->date_debut), date("G", $row->date_debut)) == 0 ? "X" : ""), 'LR', 0, 'R'); $pdf->Cell($w[3], 6, requetemysql::gestion_string_norm(touvelejour(date("w", $row->date_debut), date("G", $row->date_debut)) == 1 ? "X" : ""), 'LR', 0, 'R'); $pdf->Cell($w[4], 6, requetemysql::gestion_string_norm(touvelejour(date("w", $row->date_debut), date("G", $row->date_debut)) == 2 ? "X" : ""), 'LR', 0, 'R'); $pdf->Cell($w[5], 6, requetemysql::gestion_string_norm(touvelejour(date("w", $row->date_debut), date("G", $row->date_debut)) == 3 ? "X" : ""), 'LR', 0, 'R'); $pdf->Cell($w[6], 6, requetemysql::gestion_string_norm($row->start_heure), 'LR', 0, 'R'); $pdf->Cell($w[7], 6, requetemysql::gestion_string_norm($row->end_heure), 'LR', 0, 'R'); $pdf->Ln(); } else { if ($choix_affichage == 1) { if (count($mon_item) == 0 && $row->start_heure != '00:00') { $pdf->Cell($w[0], 6, requetemysql::gestion_string_maj(date("d/m", $row->ma_date / 1000)), 'LR', 0, 'C'); $pdf->Cell($w[1], 6, requetemysql::gestion_string_norm($row->job2), 'LR', 0, 'R'); $pdf->Cell($w[2], 6, requetemysql::gestion_string_norm(touvelejour(date("w", $row->date_debut), date("G", $row->date_debut)) == 0 ? "X" : ""), 'LR', 0, 'R'); $pdf->Cell($w[3], 6, requetemysql::gestion_string_norm(touvelejour(date("w", $row->date_debut), date("G", $row->date_debut)) == 1 ? "X" : ""), 'LR', 0, 'R'); $pdf->Cell($w[4], 6, requetemysql::gestion_string_norm(touvelejour(date("w", $row->date_debut), date("G", $row->date_debut)) == 2 ? "X" : ""), 'LR', 0, 'R'); $pdf->Cell($w[5], 6, requetemysql::gestion_string_norm(touvelejour(date("w", $row->date_debut), date("G", $row->date_debut)) == 3 ? "X" : ""), 'LR', 0, 'R'); $pdf->Cell($w[6], 6, requetemysql::gestion_string_norm($row->start_heure), 'LR', 0, 'R'); $pdf->Cell($w[7], 6, requetemysql::gestion_string_norm($row->end_heure), 'LR', 0, 'R'); $pdf->Ln(); } else { if ($row->start_heure != '00:00') { // $mon_texte .= ($row->nature==0 ? "G" : "A").": ".$row->login." ".$row->start_heure."h-".$mon_item[0]->end_heure."h(J+1) \n" ; $pdf->Cell($w[0], 6, requetemysql::gestion_string_maj(date("d/m", $row->ma_date / 1000)), 'LR', 0, 'C'); $pdf->Cell($w[1], 6, requetemysql::gestion_string_norm($row->job2), 'LR', 0, 'R'); $pdf->Cell($w[2], 6, requetemysql::gestion_string_norm(touvelejour(date("w", $row->date_debut), date("G", $row->date_debut)) == 0 ? "X" : ""), 'LR', 0, 'R'); $pdf->Cell($w[3], 6, requetemysql::gestion_string_norm(touvelejour(date("w", $row->date_debut), date("G", $row->date_debut)) == 1 ? "X" : ""), 'LR', 0, 'R'); $pdf->Cell($w[4], 6, requetemysql::gestion_string_norm(touvelejour(date("w", $row->date_debut), date("G", $row->date_debut)) == 2 ? "X" : ""), 'LR', 0, 'R'); $pdf->Cell($w[5], 6, requetemysql::gestion_string_norm(touvelejour(date("w", $row->date_debut), date("G", $row->date_debut)) == 3 ? "X" : ""), 'LR', 0, 'R'); $pdf->Cell($w[6], 6, requetemysql::gestion_string_norm($row->start_heure), 'LR', 0, 'R'); $pdf->Cell($w[7], 6, requetemysql::gestion_string_norm($mon_item[0]->end_heure . "(J+1)"), 'LR', 0, 'R'); $pdf->Ln(); } } } } } } // Trait de terminaison $pdf->Cell(array_sum($w), 0, '', 'T'); $pdf->Ln(20); } if ($arr['cas_affichage'] == 3) { $mon_url = $filename . $arr['login'] . '_planning_' . requetemysql::gestion_string_norm($arr['date_debut2']) . "_" . requetemysql::gestion_string_norm($arr['date_fin2']) . uniqid() . '.pdf'; } else { $mon_url = $filename . 'planning_' . requetemysql::gestion_string_norm($arr['date_debut2']) . "_" . requetemysql::gestion_string_norm($arr['date_fin2']) . uniqid() . '.pdf'; } //$pdf->Output($mon_url, F); $pdf->Output('../' . $mon_url, F); return json_encode($mon_url); } catch (Exception $e) { return 'Exception -> '; var_dump($e->getMessage()); } }
public function generateInputFragments(&$charData, &$mapData, $justItems = false) { // To be in here, we need to have a shop at our current location. $room = $mapData->map->GetRoom($mapData->playerX, $mapData->playerY); $shop = $room->occupant; if (!$justItems) { $this->commands[] = new InputFragment("check stock", function ($charData, $mapData) use($shop) { global $shopping; $shopStr = $shopping->getShopString($shop, $charData, $mapData); echo $shopStr; }); } if (!$justItems) { $this->commands[] = new InputFragment("leave", function ($charData, $mapData) { echo "\"Maybe next time, eh?\", the shopkeeper drawls at you as you walk away.\n"; StateManager::ChangeState($charData, GameStates::Adventuring); }); } if (!$justItems) { $this->commands[] = new InputFragment("equipment", function ($charData, $mapData) { global $adventuring; $equipment = $adventuring->getEquippedItemsStr($charData); echo $equipment . "\n"; }); } foreach ($shop->stock as $itemName => $quantity) { $item = findItem($itemName); $this->commands[] = new InputFragment($itemName, function ($charData, $mapData) use($item, $itemName, $shop, $room) { global $shopping; if (!$shopping->canAffordItem($charData, $item->getCost($charData))) { return; } // Remove item from shop. $shop->removeStockItem($itemName); // Add item to player inventory, and deduct gold. $inventory = lazyGetInventory($charData); $inventory->addItem($item); $shopping->takeMoney($item, $shop, $charData, $room); }); } foreach ($shop->equipment as $equipment) { $this->commands[] = new InputFragment($equipment->name, function ($charData, $mapData) use($equipment, $shop, $room) { global $shopping; if (!$shopping->canAffordItem($charData, $equipment->getCost($charData))) { return; } $equipString = "You equip your new {$equipment->name} immediately"; $isBarbarian = strcasecmp($charData->class, "Barbarian") == 0; if ($equipment->type == ShopEquipment::Weapon) { $weapon1Better = $charData->weaponVal >= $equipment->level; $weapon2Better = $charData->weapon2Val >= $equipment->level; if (!$isBarbarian && $weapon1Better || $isBarbarian && $weapon1Better && $weapon2Better) { echo "\"No point buying my wares if you've got better yourself!\"\n"; return; } // Bloody complicated Barbarians if ($isBarbarian) { // Going in the off-hand if ($weapon1Better) { $charData->weapon2 = $equipment->name; $charData->weapon2Val = $equipment->level; } else { $equipString .= ", moving your {$charData->weapon} to your off-hand"; $charData->weapon2 = $charData->weapon; $charData->weapon2Val = $charData->weaponVal; $charData->weapon = $equipment->name; $charData->weaponVal = $equipment->level; } } else { $charData->weapon = $equipment->name; $charData->weaponVal = $equipment->level; } } else { if ($equipment->type == ShopEquipment::Armour) { $armourBetter = $charData->armourVal >= $equipment->level; if ($isBarbarian) { echo "\"Not sure you'd know what to do with that!\"\n"; return; } else { if ($armourBetter) { echo "\"No point buying my wares if you've got better yourself!\"\n"; return; } } $charData->armour = $equipment->name; $charData->armourVal = $equipment->level; } } $equipString .= ". "; // Remove equipment from shop. $shop->removeEquipment($equipment->name); $shopping->takeMoney($equipment, $shop, $charData, $room, $equipString); }); } // Add unique identifiers to commands. $allocator = new UIDAllocator($this->commands); $allocator->Allocate(); }