Ejemplo n.º 1
0
 public function __construct($report, $values)
 {
     $this->data = array();
     $this->i = 0;
     $countedStock = array();
     if (!isset($values['location'])) {
         $locSrv = new \Pasteque\LocationsService();
         $locations = $locSrv->getAll();
         $defaultLocationId = $locations[0]->id;
         $values['location'] = $defaultLocationId;
     }
     foreach ($values as $key => $value) {
         if (strpos($key, "qty-") === 0) {
             $productId = substr($key, 4);
             $qty = $value;
             $countedStock[$productId] = $qty;
         }
     }
     $categories = \Pasteque\CategoriesService::getAll();
     $products = \Pasteque\ProductsService::getAll(TRUE);
     $prdCat = array();
     // Build listing by categories
     foreach ($products as $product) {
         if ($product->categoryId !== \Pasteque\CompositionsService::CAT_ID) {
             $prdCat[$product->categoryId][] = $product;
         }
     }
     // Get stock to compare with counted stock
     $levels = array();
     $rawLevels = \Pasteque\StocksService::getLevels($values['location']);
     foreach ($rawLevels as $level) {
         $levels[$level->productId] = $level;
     }
     foreach ($categories as $category) {
         if (isset($prdCat[$category->id])) {
             foreach ($prdCat[$category->id] as $product) {
                 $counted = 0;
                 if (isset($countedStock[$product->id])) {
                     $counted = $countedStock[$product->id];
                 }
                 $actual = 0;
                 if (isset($levels[$product->id])) {
                     $actual = $levels[$product->id]->qty;
                 }
                 if ($counted !== $actual) {
                     $this->data[] = array("ref" => $product->reference, "counted" => $counted, "actual" => $actual, "diff" => $counted - $actual);
                 }
             }
         }
     }
 }
Ejemplo n.º 2
0
//    Pastèque is distributed in the hope that it will be useful,
//    but WITHOUT ANY WARRANTY; without even the implied warranty of
//    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//    GNU General Public License for more details.
//
//    You should have received a copy of the GNU General Public License
//    along with Pastèque.  If not, see <http://www.gnu.org/licenses/>.
namespace BaseStocks;

$modules = \Pasteque\get_loaded_modules(\Pasteque\get_user_id());
$multilocations = false;
$defaultLocationId = null;
if (in_array("stock_multilocations", $modules)) {
    $multilocations = true;
}
$locSrv = new \Pasteque\LocationsService();
$locations = $locSrv->getAll();
$locNames = array();
$locIds = array();
foreach ($locations as $location) {
    $locNames[] = $location->label;
    $locIds[] = $location->id;
}
$currLocation = null;
if (isset($_POST['location'])) {
    $currLocation = $_POST['location'];
} else {
    $currLocation = $locations[0]->id;
}
$products = \Pasteque\ProductsService::getAll(true);
$categories = \Pasteque\CategoriesService::getAll();
Ejemplo n.º 3
0
//    it under the terms of the GNU General Public License as published by
//    the Free Software Foundation, either version 3 of the License, or
//    (at your option) any later version.
//
//    Pastèque is distributed in the hope that it will be useful,
//    but WITHOUT ANY WARRANTY; without even the implied warranty of
//    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//    GNU General Public License for more details.
//
//    You should have received a copy of the GNU General Public License
//    along with Pastèque.  If not, see <http://www.gnu.org/licenses/>.
namespace StockMultilocations;

$message = null;
$error = null;
$srv = new \Pasteque\LocationsService();
if (isset($_POST['delete-location'])) {
    if ($srv->delete($_POST['delete-location'])) {
        $message = \i18n("Changes saved");
    } else {
        $error = \i18n("Unable to delete location. A location cannot be deleted when stock is assigned to it.", PLUGIN_NAME);
    }
}
$locations = $srv->getAll();
?>
<h1><?php 
\pi18n("Locations", PLUGIN_NAME);
?>
</h1>

<?php 
Ejemplo n.º 4
0
//    the Free Software Foundation, either version 3 of the License, or
//    (at your option) any later version.
//
//    Pastèque is distributed in the hope that it will be useful,
//    but WITHOUT ANY WARRANTY; without even the implied warranty of
//    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//    GNU General Public License for more details.
//
//    You should have received a copy of the GNU General Public License
//    along with Pastèque.  If not, see <http://www.gnu.org/licenses/>.
// category_edit action
namespace StockMultilocations;

$message = null;
$error = null;
$srv = new \Pasteque\LocationsService();
if (isset($_POST['id']) && isset($_POST['label'])) {
    // Update location
    $location = \Pasteque\Location::__build($_POST['id'], $_POST['label']);
    if ($srv->update($location)) {
        $message = \i18n("Changes saved");
    } else {
        $error = \i18n("Unable to save changes");
    }
} else {
    if (isset($_POST['label'])) {
        // New location
        $location = new \Pasteque\Location($_POST['label']);
        $id = $srv->create($location);
        if ($id !== false) {
            $message = \i18n("Location saved. <a href=\"%s\">Go to the location page</a>.", PLUGIN_NAME, \Pasteque\get_module_url_action(PLUGIN_NAME, 'location_edit', array('id' => $id)));