Exemplo n.º 1
0
 public function report()
 {
     $errors = count($this->errors['sku']) + count($this->errors['name']);
     $success = count($this->products) - $errors;
     $tab = new Tabs();
     $report = new Report();
     $tab->start();
     $tab->start("buttons");
     $tab->button("info", false, true);
     $success > 0 ? $tab->button("success", $success) : $tab->button("success");
     $errors > 0 ? $tab->button("errors", $errors) : $tab->button("errors");
     $tab->end("buttons");
     $tab->start("entries");
     $tab->entry("info", true);
     $report->start("import data");
     $report->entry("info", "info", "Products to be added: " . count($this->products));
     $report->entry($errors > 0 ? "warning" : "success", $errors > 0 ? "warning" : "success", "Products added: {$success}");
     $report->entry($errors > 0 ? "warning" : "info", $errors > 0 ? "warning" : "info", "Errors: {$errors}");
     $report->entry("info", "info", "Clearing parsed data and import file");
     if (unlink($_SESSION['upload_file'])) {
         unset($_SESSION['upload_file']);
         unset($_SESSION['products']);
         $report->entry("success", "success", "Cleared parsed data");
     }
     if ($errors == 0) {
         $report->entry("success", "success", "Import completed without errors");
     } else {
         $report->entry("warning", "warning", "Import completed with errors please review");
     }
     $report->end();
     $tab->entry("end");
     $tab->entry("success");
     $report->start("Successful product creation");
     foreach ($this->products as $key => $product) {
         if (!in_array($product['sku'], $this->errors['sku']) && !in_array($product['name'], $this->errors['name'])) {
             $report->entry("success", "product: {$key}", "Added: " . $product['name']);
         }
     }
     if ($success == 0) {
         $report->entry("info", "info", "No products we're added");
     }
     $report->end();
     $tab->entry("end");
     $tab->entry("errors");
     if (count($this->errors['sku']) > 0) {
         $report->start("Sku duplicates");
         foreach ($this->products as $key => $product) {
             if (in_array($product['sku'], $this->errors['sku'])) {
                 $report->entry("warning", "product: {$key}", "Failed to add product: " . $product['name'] . "<br />Due to duplicated sku: " . $product['sku'] . "<br/>Existing product: " . $this->duplicates[$product['sku']]);
             }
         }
         $report->end();
     }
     if (count($this->errors['name']) > 0) {
         $report->start("Name duplicates");
         foreach ($this->products as $key => $product) {
             if (in_array($product['name'], $this->errors['name'])) {
                 $report->entry("warning", "product: {$key}", "Failed to add product: " . $product['name'] . "<br />Due to not having a valid sku and provided name already exists<br/>Existing product: " . $product['sku']);
             }
         }
         $report->end();
     }
     if ($errors == 0) {
         $report->start("Import errors");
         $report->entry("info", "info", "No products have errors");
         $report->end();
     }
     $tab->entry("end");
     $tab->end("entries");
     $tab->end();
 }
Exemplo n.º 2
0
foreach ($date as $tk => $td) {
    $products[$tk] = $db->time_range("products", $td, $marker);
    $count[$tk]['exported'] = 0;
    if ($products[$tk]) {
        foreach ($products[$tk] as $product) {
            if ($product['exported']) {
                $count[$tk]['exported']++;
            }
        }
    }
    $count[$tk]['created'] = $products[$tk] ? count($products[$tk]) : '0';
}
$tabs->start();
$tabs->start("buttons", "pills");
foreach ($date as $tk => $td) {
    $tabs->button($tk, false, $tk == "day" ? true : false);
}
$tabs->end("buttons");
echo "<br />";
$tabs->start("entries", "pills");
foreach ($date as $tk => $td) {
    $tabs->entry($tk, $tk == "day" ? 1 : 0, true);
    $table->start($tk . "_report", "table-bordered");
    $table->head("Product report, created: " . $count[$tk]['created'] . ", exported: " . $count[$tk]['exported']);
    foreach ($users as $user) {
        $count['personal']['exported'] = 0;
        $count['personal']['created'] = 0;
        if ($products[$tk]) {
            foreach ($products[$tk] as $product) {
                if ($user['id'] == $product['user_id']) {
                    $count['personal']['created']++;