Пример #1
0
             $error = 'no_receipt';
         } elseif (!isset($_GET['date']) || !$_GET['date']) {
             $error = 'no_purchase_date';
         } elseif (!isEditable($_GET['date'])) {
             $error = 'date_not_editable';
         }
         break;
     case 'update':
     case 'delete':
         if (!isset($_GET['id'])) {
             $error = 'no_purchase_id';
         } elseif (isNull($purchase = M('Purchase')->loadPurchaseById($_GET['id']))) {
             $error = 'no_purchase';
         } elseif ($purchase->user_id != me()->id()) {
             $error = 'not_my_purchase';
         } elseif (isNull($obVirtualReceipt = $purchase->getVirtualReceipt()) || !isEditable($obVirtualReceipt->bdate)) {
             $error = 'date_not_editable';
         }
         break;
     default:
         $error = 'bad_action';
         break;
 }
 $map = qw2('catalogue_id>catalogue_id is_factory_made>weighted_type unit_id>measure_unit_id');
 if (!$error) {
     try {
         switch (strtolower($_GET['action'])) {
             case 'add':
                 if (!isNull($purchase = M('Purchase')->registerPurchase($_GET['barcode'], array('bdate' => $_GET['date'], 'receipt_id' => $_GET['receipt_id'])))) {
                     foreach ($map as $k => $v) {
                         if (isset($_GET[$v])) {
Пример #2
0
function displayFiles($path)
{
    global $connection, $config;
    //calculate permissions
    $permissions = validatePermissions(validateUser());
    //Switch mode based on path
    echo "<table class='table table-hover file-list'>";
    if ($path == "/") {
        //Root: list containers
        echo "<thead><tr><th>Nome</th></tr></thead>";
        $request = "SELECT * FROM teachers_users";
        $result = $connection->query($request);
        while ($line = $result->fetch_assoc()) {
            $name = $line["user"];
            $title = ucfirst($name);
            if (file_exists($config->plugin_notes_engine_fpath . "/" . $name)) {
                echo "<tr><td><span class='fa-stack fa-3x'><i class='fa fa-folder'></i></span> <a href='#' id='{$name}' class='file-list-folder'>{$title}</a></td></tr>";
            }
        }
    } else {
        //check if it is a VFS folder then if it is not check if it is a container
        if (strpos($path, "/") !== false) {
            $folders = explode("/", $path);
            $folder = end($folders);
        } else {
            $folder = $path;
        }
        echo "<thead><tr><th>Nome</th><th>Insegnante</th><th>Dimensione</th><th>Ultima modifica</th></tr></thead>";
        $request = "SELECT * FROM notes_vfs WHERE id = '{$folder}'";
        $result = $connection->query($request);
        $line = $result->fetch_assoc();
        if (isset($line["name"])) {
            //it is a VFS folder, check for folders with parent=$folder, then download blob list and get items in that folder, save name for later use
            $folder_container = $line["container"];
            $request = "SELECT * FROM notes_vfs WHERE parent = '{$folder}'";
            $result = $connection->query($request);
        } else {
            //it is a container:
            $name = str_replace("/", "", $path);
            $request = "SELECT * FROM teachers_users WHERE user='******'";
            $result = $connection->query($request);
            $line = $result->fetch_assoc();
            $folder_container = $line["user"];
            if (file_exists($config->plugin_notes_engine_fpath . "/" . $folder_container)) {
                $request = "SELECT * FROM notes_vfs WHERE parent = '/' AND container='{$folder_container}'";
                $result = $connection->query($request);
            } else {
                echo "Error fetching container: name does not exists";
                return;
            }
        }
        $dir_array = [];
        while ($line = $result->fetch_assoc()) {
            $name = $line["name"];
            $id = $line["id"];
            $container = ucfirst($line["container"]);
            $dir_array[] = $id;
            echo "<tr><td><span class='fa-stack fa-2x'><i class='fa fa-folder'></i></span> <a href='#' id='{$id}' class='file-list-folder'>{$name}</a>";
            if ($permissions == $line["container"] or $permissions == "all") {
                echo "<button type='button' class='btn btn-link pull-right lmb remove-folder tooltipped' data-toggle='tooltip' title='Elimina' id='{$id}'><i class='fa fa-remove'></i></button>";
                echo "<button type='button' class='btn btn-link pull-right lmb edit-folder tooltipped' data-toggle='tooltip' title='Rinomina' id='{$id}'><i class='fa fa-edit'></i></button>";
            }
            echo "</td><td><span class='text-muted container-value'>{$container}</span></td><td></td><td></td></tr>";
        }
        //get file list
        $file_array = array_diff(array_diff(scandir($config->plugin_notes_engine_fpath . "/" . $path), array('..', '.', '.DS_Store')), $dir_array);
        foreach ($file_array as $file) {
            $url = $config->plugin_notes_engine_fpath . "/" . $path . "/" . $file;
            if (!is_dir($url)) {
                $finfo = finfo_open(FILEINFO_MIME_TYPE);
                $container = ucfirst($folder_container);
                $content_type = finfo_file($finfo, $url);
                $file_icon = getFileTypeIcon($content_type, $file);
                $size = formatBytes(filesize($url), 1);
                $date = date("d/m/Y", filemtime($url));
                $preview = canPreview($content_type);
                if ($preview == "no") {
                    echo "<tr><td><span class='fa-stack fa-2x'><i class='fa {$file_icon}'></i></span> <a href=\"{$url}\" class='file-list' target='_blank'>{$file}</a>";
                } else {
                    echo "<tr><td><span class='fa-stack fa-2x'><i class='fa {$file_icon}'></i></span> <a href='#' data-path=\"{$url}\" data-preview_mode='{$preview}' class='file-list-previewable'>{$file}</a>";
                }
                if ($permissions == $folder_container or $permissions == "all") {
                    echo "<button type='button' class='btn btn-link pull-right lmb remove-file tooltipped' data-toggle='tooltip' title='Elimina' data-path=\"{$url}\"><i class='fa fa-remove'></i></button>";
                    if (isEditable($content_type)) {
                        if ($content_type == "text/html") {
                            $mode = "html";
                        } else {
                            $mode = "code";
                        }
                        echo "<button type='button' class='btn btn-link pull-right lmb edit-file tooltipped' data-toggle='tooltip' title='Modifica' data-edit-mode='{$mode}' data-path='{$url}'><i class='fa fa-edit'></i></button>";
                    }
                }
                echo "</td><td><span class='text-muted container-value'>{$container}</span></td><td><span class='text-muted'>{$size}</span></td><td><span class='text-muted'>{$date}</span></td></tr>";
            }
        }
    }
    echo "</table>";
}
Пример #3
0
                        $purchase->delete();
                    }
                    foreach (M('Purchase')->receipt()->getReceiptListForDiary(me(), $date) as $receipt) {
                        $receipt->delete();
                    }
                    me()->setNoPurchase($date);
                } catch (RM_Validator_Exception $e) {
                    $tmp = iterFirst($e->getResult()->getErrors());
                    $error = $tmp['code'];
                }
            } elseif (me()->getDayStatusCode($date) == -1) {
                me()->refreshDay($date, $_GET['no_purchase']);
            }
        } else {
            $error = 'date_not_editable';
        }
    }
}
$root_params = array();
// атрибуты корневого тега
$root_params['status'] = 'ok';
$root_params = array_merge($root_params, MC('Message')->setXmlMessage(@$error, @$message, 'diary'));
$root = M('Ajax')->init('xml', $root_params);
if (!$error) {
    $root = $root->addNode('day', array(array('no_purchase' => me()->getDayStatus($date), 'date' => $_GET['date'], 'editable' => isEditable($_GET['date']))));
    if ($_GET['action'] == 'view') {
        $receipt = $root->addNode('receipt', M('Purchase')->receipt()->getReceiptListForDiary(me(), $date), qw2('id>id() number>number shop_id>shop_id discount>discount_virt'));
        $purchase = $receipt->addNode('purchase', 'getPurchases()', qw2('id>id() receipt_id>receipt_id barcode>barcode_value description>corrected_name quantity>quantity measure_unit_id>unit_id approx_quant>approx_quantity payed_price>price approx_price>approx_price purchaser>getPurchaserAsString() consumer>getConsumerAsString() status>status_id catalogue_id>catalogue_id weighted_type>weightedType() promo>is_promo'));
    }
}
M('Ajax')->xml();
Пример #4
0
         } elseif (me()->getDayStatusCode($_GET['date']) == -1) {
             $error = 'receipt_no_purchase';
         }
         break;
     case 'update':
         if (!isset($_GET['shop_id']) || empty($_GET['shop_id'])) {
             $error = 'no_shop_id';
         } elseif ($_GET['shop_id'] != -1 && isNull(M('Shop')->loadShopById($_GET['shop_id']))) {
             $error = 'no_shop';
         }
     case 'delete':
         if (!isset($_GET['id'])) {
             $error = 'no_receipt_id';
         } elseif (isNull($obReceipt = M('Purchase')->receipt()->loadVirtualById(@$_GET['id']))) {
             $error = 'no_receipt';
         } elseif (!isEditable($obReceipt->bdate)) {
             $error = 'date_not_editable';
         }
         break;
     default:
         $error = 'bad_action';
         break;
 }
 if (!$error) {
     try {
         switch (strtolower($_GET['action'])) {
             case 'add':
                 $obReceipt = M('Purchase')->receipt()->createVirtual(array('user_id' => me()->id(), 'bdate' => @$_GET['date'], 'shop_id' => @$_GET['shop_id'], 'discount_virt' => @$_GET['discount']));
                 $obReceipt->save();
                 if (!isNull($obLeave = M('User')->getCurrentLeave(me()))) {
                     MC('Leave')->dropDateToCurrent($obLeave);