function generateIdDoc($type, $company, $order)
{
    //[X : typedocument][XX : Year][X : country][XXXX : id commande]
    $year = date('y');
    $country = 5;
    $typedocument = $type;
    $country_company = $company->getNationality();
    $extraction = new extraction();
    $allPartners = $extraction->get('partner');
    $id_order = $order->getId();
    $id_to_print = "";
    $count = strlen((string) $id_order);
    for ($i = 0; $i < 4 - $count; $i++) {
        $id_to_print .= "0";
    }
    $id_to_print .= $id_order;
    foreach ($allPartners as $partner) {
        if ($partner->getCountry() == $country_company) {
            $country = $partner->getRef();
            break;
        }
    }
    //id commande à replacer par référence commande quand ce sera fait
    $id_document = $typedocument . $year . $country . $id_to_print;
    return $id_document;
}
 public function getFromDatabase()
 {
     $stmt_get = $this->pdo->PDOInstance->prepare("SELECT * FROM group_product WHERE id = :id");
     $stmt_get->bindParam(':id', $this->id);
     try {
         $stmt_get->execute();
     } catch (Exception $e) {
         echo "Problem at " . $e->getLine() . " from model group_product :" . $e->getMessage();
     }
     if ($stmt_get->rowcount() != 0) {
         $stmt_get = $stmt_get->fetch(PDO::FETCH_ASSOC);
         foreach ($stmt_get as $key => $value) {
             $this->{$key} = $value;
         }
         $extraction = new extraction();
         $this->parameters = $extraction->getParametersFromType($this->type);
         return true;
     } else {
         return false;
     }
 }
Example #3
0
<?php

require_once '../model/extraction.php';
require_once '../model/' . $_GET["class"] . '.php';
$extraction = new extraction();
$needle = $_GET["needle"];
$results = $extraction->searchFor($_GET["class"], $needle);
$json = array();
if ($_GET["class"] == "company") {
    foreach ($results as $result) {
        $item = array("id" => $result->getId(), "text" => $result->printText(), "billing_period_bis" => $result->getNormal_billing_period());
        array_push($json, $item);
    }
} else {
    foreach ($results as $result) {
        $item = array("id" => $result->getId(), "text" => $result->printText());
        array_push($json, $item);
    }
}
$json = json_encode($json);
echo $json;
<?php

require_once 'checkSession.php';
require_once '../model/extraction.php';
require_once '../model/customer.php';
$extraction = new extraction();
$customers = $extraction->getCustomers();
include '../view/customers.php';
<?php

require "../model/extraction.php";
$extraction = new extraction(0, 0);
$clients = $extraction->extractClientMail();
include "../view/realBaseClient.php";
Example #6
0
    public function printToAdd($next)
    {
        $extraction = new extraction();
        $groups = $extraction->getRight_group();
        echo '
				<input type="hidden" name="id" value="' . $this->id . '">
				<input type="hidden" name="next" value="' . $next . '">
				<div class="form-group">
					<label for="name">' . $this->tf->getText(25) . '</label>
					<input name="name" type="text" class="form-control" value="">
				</div>
				<div class="form-group">
					<label for="surname">' . $this->tf->getText(53) . '</label>
					<input name="surname" type="text" class="form-control" value="">
				</div>
				<div class="form-group">
					<label for="mail">' . $this->tf->getText(51) . '</label>
					<input name="mail" type="text" class="form-control" value="">
				</div>
				<div class="form-group">
					<label for="short_phone">' . $this->tf->getText(54) . '</label>
					<input name="short_phone" type="number" class="form-control" value="">
				</div>
				<div class="form-group">
					<label for="phone_number">' . $this->tf->getText(45) . '</label>
					<input name="phone_number" type="text" class="form-control" value="">
				</div>
				<div class="form-group">
					<label for="right_group">' . $this->tf->getText(57) . '</label>
					<select name="right_group" class="form-control">
					';
        $a = 0;
        foreach ($groups as $group) {
            if ($a == 0) {
                echo '<option selected="selected" value="' . $group->getId() . '">' . ucfirst($group->getName()) . '</option>';
                $a = 1;
            } else {
                echo '<option value="' . $group->getId() . '">' . ucfirst($group->getName()) . '</option>';
            }
        }
        echo '
					</select>
				</div>
				<div class="form-group">
					<label for="birthdate">' . $this->tf->getText(56) . '</label>
					<input name="birthdate" type="date" class="form-control" value="">
				</div>
				<div class="form-group">
					<label for="login">' . $this->tf->getText(3) . '</label>
					<input name="login" type="text" class="form-control" value="">
				</div>
				<div class="form-group">
					<label for="password">' . $this->tf->getText(4) . '</label>
					<input name="password" type="password" class="form-control" value="">
				</div>
			';
    }
<?php

require_once '../model/extraction.php';
require_once '../model/product.php';
$extraction = new extraction();
$needle = $_GET["needle"];
$results = $extraction->getProductForOrder($needle);
$json = array();
foreach ($results as $result) {
    $group = $result->getGroup_product();
    if (count($group->getParameters()) != 0) {
        $isParameter = true;
        $parameters = $group->getJSONParameters();
    } else {
        $isParameter = false;
        $parameters = null;
    }
    $item = array("id" => $result->getId(), "text" => $result->getName() . ' ' . $result->getDescription(), "price" => $result->getPrice(), "isParameter" => $isParameter, "parameters" => $parameters);
    array_push($json, $item);
}
$json = json_encode($json, JSON_FORCE_OBJECT);
echo $json;
<?php

require_once 'checkSession.php';
require_once '../model/parameter.php';
require_once '../model/extraction.php';
$extraction = new extraction();
$parameters = $extraction->get("parameter");
function compare($a, $b)
{
    return intval($a->getRef()) - intval($b->getRef());
}
usort($parameters, "compare");
include '../view/parameters.php';
<?php

require_once '../model/extraction.php';
if (isset($_GET["dateDeb"]) && isset($_GET["dateEnd"])) {
    $extraction = new extraction($_GET["dateDeb"], $_GET["dateEnd"]);
    $deb = $_GET["dateDeb"];
    $end = $_GET["dateEnd"];
    $startDate = DateTime::createFromFormat('j-m-y', $deb)->getTimestamp();
    $endDate = DateTime::createFromFormat('j-m-y', $end)->getTimestamp();
    $startMonth = date('m', $startDate);
    $startYear = date('y', $startDate);
    $nb_month = abs((date('Y', $endDate) - date('Y', $startDate)) * 12 + (date('m', $endDate) - date('m', $startDate))) + 1;
    $columns = array("GER" => array(), "ESP" => array());
    for ($i = 0; $i < $nb_month; $i++) {
        $month = ($startMonth - 1 + $i) % 12 + 1;
        if ($month < 10) {
            $month = '0' . $month;
        }
        $year = intval(strval(($startMonth - 1 + $i) / 12)) + $startYear;
        $key = $month . '-' . $year;
        if ($i == 0) {
            $deb_a = $deb;
            $end_a = date('t-m-y', $startDate);
        } else {
            if ($i == $nb_month - 1) {
                $deb_a = '01-' . $key;
                $end_a = $end;
            } else {
                $deb_a = '01-' . $key;
                $end_a = date('t', strtotime('01-' . $key)) . '-' . $key;
            }
<?php

$displayResult = false;
if (isset($_GET["dateBegin"]) && isset($_GET["dateEnd"])) {
    $displayResult = true;
    require '../model/extraction.php';
    $extraction = new extraction($_GET["dateBegin"], $_GET["dateEnd"]);
    $clients = $extraction->extractClient('RE');
    $debDateYear = intval(substr($_GET["dateBegin"], 0, 4));
    $endDateYear = intval(substr($_GET["dateEnd"], 0, 4));
    $nbYear = $endDateYear - $debDateYear;
    $debDateMounth = intval(substr($_GET["dateBegin"], 5, 2));
    $endDateMounth = intval(substr($_GET["dateEnd"], 5, 2));
    $nbMounth = $endDateMounth - $debDateMounth;
    if ($nbYear == 0) {
        $nbColumn = $nbMounth;
        $jtab = array(array($debDateMounth, $endDateMounth));
    } else {
        if ($nbYear == 1 && $endDateMounth < $debDateMounth) {
            $nbColumn = 13 - $debDateMounth + $endDateMounth;
            $jtab = array(array($debDateMounth, 12), array(1, $endDateMounth));
        } else {
            $nbColumn = 13 - $debDateMounth + 12 * $nbYear + $endDateMounth;
            $jtab = array(array($debDateMounth, 12));
            for ($i = 1; $i < $nbYear; $i++) {
                array_push($jtab, array(1, 12));
            }
            array_push($jtab, array(1, $endDateMounth));
        }
    }
    $clientsES1 = $extraction->extractClient('FA');
Example #11
0
<?php

require_once 'checkSession.php';
require_once '../model/extraction.php';
require_once '../model/order.php';
$extraction = new extraction();
if (isset($_GET["display"])) {
    $display = $_GET["display"];
} else {
    $display = "all";
}
$orders = $extraction->getOrders($display);
include_once '../view/orders.php';
<?php

require_once 'checkSession.php';
require_once '../model/employee.php';
require_once '../model/extraction.php';
$extraction = new extraction();
$employees = $extraction->getEmployee();
include '../view/employees.php';
<?php

require_once 'checkSession.php';
require_once '../model/group_products.php';
require_once '../model/extraction.php';
$extraction = new extraction();
$groups = $extraction->getGroup();
include '../view/groupProducts.php';
Example #14
0
    public function printToModify($next)
    {
        $extraction = new extraction();
        $groups = $extraction->getGroup();
        echo '
				<input type="hidden" name="id" value="' . $this->id . '">
				<input type="hidden" name="next" value="' . $next . '">
				<div class="form-group">
					<label for="ref">' . $this->tf->getText(59) . '</label>
					<input name="ref" type="text" class="form-control" value="' . $this->ref . '">
				</div>
				<div class="form-group">
					<label for="name">' . $this->tf->getText(25) . '</label>
					<input name="name" type="text" class="form-control" value="' . $this->name . '">
				</div>
				<div class="form-group">
					<label for="description">' . $this->tf->getText(42) . '</label>
					<input name="description" type="text" class="form-control" value="' . $this->description . '">
				</div>
				<div class="form-group">
					<label for="id_group">' . $this->tf->getText(34) . '</label>
					<select name="id_group" class="form-control">
					';
        foreach ($groups as $group) {
            if ($this->id_group == $group->getId()) {
                echo '<option selected="selected" value="' . $group->getId() . '">' . $group->getName() . '</option>';
            } else {
                echo '<option value="' . $group->getId() . '">' . $group->getName() . '</option>';
            }
        }
        echo '
					</select>
				</div>
				<div class="form-group">
					<label for="description">' . $this->tf->getText(89) . '</label>
					<input name="unit" type="text" class="form-control" value="' . $this->unit . '">
				</div>
				<div class="form-group">
					<label for="description">' . $this->tf->getText(90) . '</label>
					<input name="cost" type="text" class="form-control" value="' . $this->cost . '">
				</div>
				<div class="form-group">
					<label for="description">' . $this->tf->getText(75) . '</label>
					<input name="price" type="text" class="form-control" value="' . $this->price . '">
				</div>
				';
    }
Example #15
0
<?php

require_once 'checkSession.php';
require_once '../model/company.php';
require_once '../model/extraction.php';
if (isset($_GET["id"])) {
    $company = new company($_GET["id"]);
    $extraction = new extraction();
    $orders = $extraction->getOrderFromCompany($_GET["id"]);
} else {
    $error;
}
include '../view/company.php';
<?php

require_once '../model/order.php';
require_once '../model/company.php';
require_once '../model/extraction.php';
$order = new order($_GET['id']);
$company = new company($order->getId_company());
$receiving_address = new address($company->getId_receiving_address());
// Génération du n° Document
//[X : typedocument][XX : Year][X : country][XXXX : id commande]
$typedocument = 7;
$year = date('y');
$country = 5;
$country_company = $company->getNationality();
$extraction = new extraction();
$allPartners = $extraction->get('partner');
$id_order = $order->getId();
$id_to_print = "";
$count = strlen((string) $id_order);
for ($i = 0; $i < 4 - $count; $i++) {
    $id_to_print .= "0";
}
$id_to_print .= $id_order;
foreach ($allPartners as $partner) {
    if ($partner->getCountry() == $country_company) {
        $country = $partner->getRef();
        break;
    }
}
//id commande à replacer par référence commande quand ce sera fait
$id_document = $typedocument . $year . $country . $id_to_print;
<?php

require_once '../model/error.php';
require_once '../model/employee.php';
require_once '../model/extraction.php';
require_once 'checkSession.php';
if (isset($_GET["id"])) {
    $employee = new employee($_GET["id"]);
    if ($employee == NULL) {
        $error;
    }
    $extraction = new extraction();
    $orders = $extraction->getOrderFromEmployee($_GET["id"]);
} else {
    $error;
}
include '../view/employee.php';
<?php

require_once 'checkSession.php';
$display = false;
$extraction = new extraction();
$actualYears = date('y');
$actualMonth = date('m');
$debDateYear = '01-01-' . $actualYears;
$endDateYear = '31-12-' . $actualYears;
$debDateMonth = '01-' . $actualMonth . '-' . $actualYears;
$endDateMonth = date('t-m-y', strtotime($actualYears . '-' . $actualMonth . '-' . '31'));
$ordersYear = $extraction->getOrdersWithDate($debDateYear, $endDateYear);
$ordersMonth = $extraction->getOrdersWithDate($debDateMonth, $endDateMonth);
//Calcul of year turnover
$yearTurnover = 0;
foreach ($ordersYear as $order) {
    $yearTurnover += $order->getPrice();
}
$yearTurnover = number_format($yearTurnover, 2, ',', ' ');
//Calcul of month turnover
$monthTurnover = 0;
foreach ($ordersMonth as $order) {
    $monthTurnover += $order->getPrice();
}
$monthTurnover = number_format($monthTurnover, 2, ',', ' ');
//Calcul of the period if set
if (isset($_GET["dateDeb"]) && $_GET["dateDeb"] != "" && isset($_GET["dateEnd"]) && $_GET["dateEnd"] != "") {
    //Check if the period is in the new or the old Biothys
    $dateMigration = "15-08-15";
    $tsdateMigration = DateTime::createFromFormat('j-m-y', $dateMigration)->getTimestamp();
    $display = true;
Example #19
0
    public function printToAdd($next)
    {
        $extraction = new extraction();
        if ($this->billing_address == NULL) {
            $this->getBillingAddress();
        }
        $groups = $extraction->get("group_company");
        echo '
				<input type="hidden" name="id" value="' . $this->id . '">
				<input type="hidden" name="next" value="' . $next . '">
				<input type="hidden" name="class" value="company">
				<div class="form-group">
					<label for="name">' . $this->tf->getText(25) . '</label>
					<input name="name" type="text" class="form-control" value="' . $this->name . '">
				</div>
				<div class="form-group">
					<label for="nationality">' . $this->tf->getText(50) . '</label>
					<input name="nationality" type="text" class="form-control" value="' . $this->nationality . '">
				</div>
				<div class="form-group">
					<label for="countryWhoBill">Country who bill</label>
					<input name="countryWhoBill" type="text" class="form-control" value="' . $this->countryWhoBill . '">
				</div>
				<div class="form-group">
					<label for="description">' . $this->tf->getText(42) . '</label>
					<input name="description" type="text" class="form-control" value="' . $this->description . '">
				</div>
				<div class="form-group">
					<label for="phone_number">' . $this->tf->getText(45) . '</label>
					<input name="phone_number" type="text" class="form-control" value="' . $this->phone_number . '">
				</div>
				<div class="form-group">
					<label for="id_contact">' . $this->tf->getText(43) . ' ' . $this->tf->getText(69) . '</label>
					<input type="text" id="contact" class="form-control" value="' . $this->contact->getName() . ' | ' . $this->contact->getMail() . ' | ' . $this->contact->getPhone_number() . '">
					<input name="id_contact" type="hidden" class="form-control" value="' . $this->id_contact . '">
					<button id="getContact" alt="company" rel="' . $this->id . '" class="display btn btn-primary"><span class="glyphicon glyphicon-search" aria-hidden="true"></span></button></a>
					<button id="addContact" alt="company" rel="' . $this->id . '" class="display btn btn-primary"><span class="glyphicon glyphicon-plus" aria-hidden="true"></span></button></a>
				</div>
				<div class="form-group">
					<label for="id_billing_address">' . $this->tf->getText(87) . ' ' . $this->tf->getText(69) . '</label>
					<input type="text" id="billing_address" class="form-control" value="' . str_replace('<br/>', ' ', $this->billing_address->printAddress()) . '">
					<input name="id_billing_address" type="hidden" class="form-control" value="' . $this->id_billing_address . '">
					<button id="addAddress" alt="company" step="billing_address" rel="' . $this->id . '" class="display btn btn-primary"><span class="glyphicon glyphicon-plus" aria-hidden="true"></span></button></a>
					<button id="setAddress" alt="company" step="billing_address" rel="' . $this->id . '" class="display btn btn-primary"><span class="glyphicon glyphicon-cog" aria-hidden="true"></span></button></a>
					<button id="getAddress" alt="company" step="billing_address" rel="' . $this->id . '" class="display btn btn-primary"><span class="glyphicon glyphicon-search" aria-hidden="true"></span></button></a>
				</div>
				<div class="form-group">
					<label for="id_receiving_address">' . $this->tf->getText(88) . ' ' . $this->tf->getText(69) . '</label>
					<input type="text" id="receiving_address" class="form-control" value="' . str_replace('<br/>', ' ', $this->receiving_address->printAddress()) . '">
					<input name="id_receiving_address" type="hidden" class="form-control" value="' . $this->id_receiving_address . '">
					<button id="addAddress" alt="company" step="receiving_address" rel="' . $this->id . '" class="display btn btn-primary"><span class="glyphicon glyphicon-plus" aria-hidden="true"></span></button></a>
					<button id="setAddress" alt="company" step="receiving_address" rel="' . $this->id . '" class="display btn btn-primary"><span class="glyphicon glyphicon-cog" aria-hidden="true"></span></button></a>
					<button id="getAddress" alt="company" step="receiving_address" rel="' . $this->id . '" class="display btn btn-primary"><span class="glyphicon glyphicon-search" aria-hidden="true"></span></button></a>
				</div>
				';
        echo '
				<div class="form-group">
					<label for="id_group_company">' . $this->tf->getText(85) . '</label>
					<select name="id_group_company" class="form-control">
					';
        foreach ($groups as $group) {
            echo 'hey';
            if ($this->id_group_company == $group->getId()) {
                echo '<option selected="selected" value="' . $group->getId() . '">' . ucfirst($group->getDesignation()) . '</option>';
            } else {
                echo '<option value="' . $group->getId() . '">' . ucfirst($group->getDesignation()) . '</option>';
            }
        }
        echo '
					</select>
				</div>
				<div class="form-group">
					<label for="ust_id">UST Id</label>
					<input name="ust_id" type="text" class="form-control" value="' . $this->ust_id . '">
				</div>
				<div class="form-group">
					<label for="normal_billing_period">' . $this->tf->getText(86) . '</label>
					<input name="normal_billing_period" type="text" class="form-control" value="' . $this->normal_billing_period . '">
				</div>
			';
    }
<?php

require_once 'checkSession.php';
require_once '../model/group_company.php';
require_once '../model/extraction.php';
$extraction = new extraction();
$group_companies = $extraction->get("group_company");
include '../view/groupCompanies.php';
Example #21
0
<?php

require_once '../model/extraction.php';
require_once '../model/company.php';
$data = $_GET["address"];
$data = json_decode($data, true);
$extraction = new extraction();
$results = $extraction->get('company');
echo '<input id="lookCompany" class="form-control" type="text">';
foreach ($results as $company) {
    echo '<div class="ctn-addresses">';
    echo '<div class="ctn-address">';
    echo '<p>' . $company->printText() . '<p>';
    echo '</div>';
    echo '<button class=" btn btn-primary sendCompany" rel="' . $data["idFor"] . '" alt="' . $company->getId() . '"class="btn btn-success"><span class="glyphicon glyphicon-ok" aria-hidden="true"></span></button>';
    echo '</div>';
}
Example #22
0
<?php

require_once '../model/extraction.php';
require_once '../model/customer.php';
$data = $_GET["address"];
$data = json_decode($data, true);
$extraction = new extraction();
$results = $extraction->getCustomersFromCompany($data["idFor"]);
foreach ($results as $customer) {
    echo '<div class="ctn-addresses">';
    echo '<div class="ctn-address">';
    echo '<p>' . $customer->printText() . '<p>';
    echo '</div>';
    echo '<button class=" btn btn-primary sendContact" rel="' . $data["idFor"] . '" alt="' . $customer->getId() . '"class="btn btn-success"><span class="glyphicon glyphicon-ok" aria-hidden="true"></span></button>';
    echo '</div>';
}
Example #23
0
<?php

require_once '../model/extraction.php';
require_once '../model/address.php';
$extraction = new extraction();
$data = $_GET["address"];
$data = json_decode($data, true);
if ($data["for"] == "order") {
    $results = $extraction->searchForAddress(" ", $data["idFor"]);
} else {
    $results = $extraction->searchForAddress(" ");
}
foreach ($results as $address) {
    echo '<div class="ctn-addresses">';
    echo '<div class="ctn-address">';
    echo '<p>' . $address->getLine() . ' ' . $address->getComplement() . '<br/>' . $address->getZip() . ' ' . $address->getCity() . '<br/>' . $address->getState() . ' ' . $address->getCountry();
    echo '</div>';
    echo '<button class=" btn btn-primary sendAddress" rel="' . $data["idFor"] . '" alt="' . $address->getId() . '"class="btn btn-success"><span class="glyphicon glyphicon-ok" aria-hidden="true"></span></button>';
    echo '</div>';
}
<?php

require_once 'checkSession.php';
require_once '../model/company.php';
require_once '../model/extraction.php';
$extraction = new extraction();
$companies = $extraction->getCompany();
include '../view/companies.php';
<?php

require_once '../model/error.php';
require_once '../model/extraction.php';
require_once 'checkSession.php';
$extraction = new extraction();
$groups = $extraction->getProductByGroup();
include '../view/products.php';
<?php

require_once 'checkSession.php';
require_once '../model/employee.php';
require_once '../model/extraction.php';
if (isset($_GET["dateDeb"]) && $_GET["dateDeb"] != "" && isset($_GET["dateEnd"]) && $_GET["dateEnd"] != "") {
    $display = true;
    $deb = $_GET["dateDeb"];
    $end = $_GET["dateEnd"];
    $id_e = $_SESSION["employee"];
    $employee = new employee($id_e);
    $extraction = new extraction();
    $orders = $extraction->getOrdersFromEmployeeWithDate($id_e, $deb, $end);
    $ca = 0;
    $count = count($orders);
    foreach ($orders as $order) {
        $ca += $order->getPrice();
    }
    $ca = number_format($ca, 2, ',', ' ');
    //On regroupe les commandes par leur client
    $companies = array();
    function search($id, $company)
    {
        $mag = false;
        foreach ($company as $i => $item) {
            if ($item->getId() == $id) {
                $mag = $i;
            }
        }
        return $mag;
    }
if (isset($_GET["dateBegin"]) && isset($_GET["dateEnd"])) {
    $displayResult = true;
    $displayOrderPrice = false;
    if (isset($_GET["display-order-price"])) {
        $displayOrderPrice = true;
    }
    $typeOfExtract = $_GET["type-of-extract"];
    require "../model/extraction.php";
    $dateBegin = $_GET["dateBegin"];
    $dateEnd = $_GET["dateEnd"];
    if ($typeOfExtract == "ES") {
        $extraction = new extraction($dateBegin, $dateEnd, "FA");
        $result = $extraction->extract();
        $extraction2 = new extraction($dateBegin, $dateEnd, "FA-R");
        $result2 = $extraction2->extract();
        foreach ($result2 as $order) {
            $order->markAsESRectific();
        }
        $result = array_merge($result, $result2);
        function cmp($a, $b)
        {
            return $a->getDate() < $b->getDate() ? -1 : 1;
        }
        usort($result, "cmp");
        $extraction->addToFinalPrice(-$extraction2->getFinalPrice());
    } else {
        $extraction = new extraction($dateBegin, $dateEnd, $typeOfExtract);
        $result = $extraction->extract();
    }
}
include "../view/detailCommande.php";