|
|
@@ -1,6 +1,7 @@
|
|
|
<?php
|
|
|
|
|
|
Lib::loadClass('RouteBase');
|
|
|
+Lib::loadClass('Typespecial');
|
|
|
Lib::loadClass('TypespecialVariable');
|
|
|
Lib::loadClass('Request');
|
|
|
Lib::loadClass('Response');
|
|
|
@@ -28,24 +29,44 @@ class Route_UrlAction_ProjektyProNetMediaZamZlec extends RouteBase {// TODO: Url
|
|
|
$fld = V::get('fld', '', $_GET);
|
|
|
switch ($fld) {
|
|
|
case 'id_company': {
|
|
|
- $typeSpecialCompanies = TypespecialVariable::getInstance(-1, '__COMPANIES');
|
|
|
-
|
|
|
- $query = V::get('q', '', $_REQUEST);
|
|
|
- $rawRows = null;
|
|
|
- $rows = $typeSpecialCompanies->getValuesWithExports($query);
|
|
|
- if($DBG){echo'<pre style="max-height:200px;overflow:auto;border:1px solid red;text-align:left;">rows('.$query.') (' . __CLASS__ . '::' . __FUNCTION__ . ':' . __LINE__ . '): ';print_r($rows);echo'</pre>';}
|
|
|
- foreach ($rows as $kID => $vItem) {
|
|
|
- $itemJson = new stdClass();
|
|
|
- $itemJson->id = $vItem->id;
|
|
|
- $itemJson->name = $vItem->param_out;
|
|
|
- if (!empty($vItem->exports)) {
|
|
|
- $itemJson->exports = $vItem->exports;
|
|
|
- }
|
|
|
- $jsonData[] = $itemJson;
|
|
|
+ $typeSpecialCompanies = TypespecialVariable::getInstance(-1, '__COMPANIES');
|
|
|
+
|
|
|
+ $query = V::get('q', '', $_REQUEST);
|
|
|
+ $rawRows = null;
|
|
|
+ $rows = $typeSpecialCompanies->getValuesWithExports($query);
|
|
|
+ if($DBG){echo'<pre style="max-height:200px;overflow:auto;border:1px solid red;text-align:left;">rows('.$query.') (' . __CLASS__ . '::' . __FUNCTION__ . ':' . __LINE__ . '): ';print_r($rows);echo'</pre>';}
|
|
|
+ foreach ($rows as $kID => $vItem) {
|
|
|
+ $itemJson = new stdClass();
|
|
|
+ $itemJson->id = $vItem->id;
|
|
|
+ $itemJson->name = $vItem->param_out;
|
|
|
+ if (!empty($vItem->exports)) {
|
|
|
+ $itemJson->exports = $vItem->exports;
|
|
|
+ }
|
|
|
+ $jsonData[] = $itemJson;
|
|
|
+ }
|
|
|
+ echo json_encode($jsonData);
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case 'ID_PROJECT': {
|
|
|
+ $widgetProject = $this->getWidgetProject();
|
|
|
+ $typeSpecialIdProject = Typespecial::getInstance($widgetProject['idKomorka'], $colName = $widgetProject['fieldName']);
|
|
|
+
|
|
|
+ $query = V::get('q', '', $_REQUEST);
|
|
|
+ $rawRows = null;
|
|
|
+ $rows = $typeSpecialIdProject->getValuesWithExports($query);
|
|
|
+ if($DBG){echo'<pre style="max-height:200px;overflow:auto;border:1px solid red;text-align:left;">rows('.$query.') (' . __CLASS__ . '::' . __FUNCTION__ . ':' . __LINE__ . '): ';print_r($rows);echo'</pre>';}
|
|
|
+ foreach ($rows as $kID => $vItem) {
|
|
|
+ $itemJson = new stdClass();
|
|
|
+ $itemJson->id = $vItem->id;
|
|
|
+ $itemJson->name = $vItem->param_out;
|
|
|
+ if (!empty($vItem->exports)) {
|
|
|
+ $itemJson->exports = $vItem->exports;
|
|
|
}
|
|
|
- echo json_encode($jsonData);
|
|
|
+ $jsonData[] = $itemJson;
|
|
|
}
|
|
|
- break;
|
|
|
+ echo json_encode($jsonData);
|
|
|
+ }
|
|
|
+ break;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -61,6 +82,8 @@ class Route_UrlAction_ProjektyProNetMediaZamZlec extends RouteBase {// TODO: Url
|
|
|
$data['widgetCompanies']['fieldName'] = 'id_company';
|
|
|
$data['widgetCompanies']['dataUrl'] = "index.php?_route=UrlAction_ProjektyProNetMediaZamZlec&_task=typespecial&fld={$data['widgetCompanies']['fieldName']}";
|
|
|
$data['widgetCompanies']['typeSpecial'] = TypespecialVariable::getInstance(-1, '__COMPANIES');
|
|
|
+ $data['widgetProject'] = $this->getWidgetProject();
|
|
|
+
|
|
|
$this->zamZlecFormView($data);
|
|
|
} catch (Exception $e) {
|
|
|
UI::alert('danger', "Error #" . $e->getCode() . "|" . $e->getLine() . ": " . $e->getMessage());
|
|
|
@@ -68,6 +91,21 @@ class Route_UrlAction_ProjektyProNetMediaZamZlec extends RouteBase {// TODO: Url
|
|
|
if (1 != V::get('_print', '', $_GET)) UI::dol();
|
|
|
}
|
|
|
|
|
|
+ public function getWidgetProject() {
|
|
|
+ $widgetProject = array();
|
|
|
+ $widgetProject['idTabela'] = 1656;// TODO: idZasob for TABELA Projekty
|
|
|
+ $widgetProject['idKomorka'] = 1658;// TODO: idZasob for KOMORKA Projekty.P_ID
|
|
|
+ $widgetProject['fieldName'] = 'ID_PROJECT';
|
|
|
+ $widgetProject['dataUrl'] = "index.php?_route=UrlAction_ProjektyProNetMediaZamZlec&_task=typespecial&fld={$widgetProject['fieldName']}";
|
|
|
+ $widgetProject['typeSpecial'] = null;
|
|
|
+ $acl = User::getAcl()->getObjectAcl('default_db', 'IN7_MK_BAZA_DYSTRYBUCJI');
|
|
|
+ if ($acl) {
|
|
|
+ $acl->init($force = false);
|
|
|
+ $widgetProject['typeSpecial'] = Typespecial::getInstance($widgetProject['idKomorka'], $colName = $widgetProject['fieldName']);
|
|
|
+ }
|
|
|
+ return $widgetProject;
|
|
|
+ }
|
|
|
+
|
|
|
public function addZlecenieAction() {
|
|
|
$id_company = V::get('id_company', 0, $_REQUEST, 'int');
|
|
|
$id_project = V::get('ID_PROJECT', 0, $_REQUEST, 'int');
|
|
|
@@ -436,20 +474,21 @@ class Route_UrlAction_ProjektyProNetMediaZamZlec extends RouteBase {// TODO: Url
|
|
|
$id_company = V::get('id_company', 0, $data);
|
|
|
$items_count = V::get('items_count', 0, $data);
|
|
|
$widgetCompanies = V::get('widgetCompanies', array(), $data);
|
|
|
+ $widgetProject = V::get('widgetProject', array(), $data);
|
|
|
$saveOrderNotesLink = "index.php?_route=UrlAction_ProjektyProNetMediaZamZlec&_task=updateOrderNoteAjax";
|
|
|
|
|
|
- $sqlWhere = '';
|
|
|
- if ($id_project > 0) $sqlWhere = "where o.ID_PROJECT = {$id_project}";
|
|
|
- $projOrders = DB::getPDO()->fetchAll("
|
|
|
- select o.*
|
|
|
- , p.M_DIST_DEALNUM as obcy_nr_sprawy
|
|
|
- from CRM_LISTA_ZASOBOW_ORDERS o
|
|
|
- left join IN7_MK_BAZA_DYSTRYBUCJI p on(p.ID = o.ID_PROJECT)
|
|
|
- left join COMPANIES c on(c.ID = o.ID_COMPANIES)
|
|
|
- {$sqlWhere}
|
|
|
- order by ID DESC
|
|
|
- limit 100
|
|
|
- ");
|
|
|
+ $projOrders = ($id_project > 0)
|
|
|
+ ? DB::getPDO()->fetchAll("
|
|
|
+ select o.*
|
|
|
+ , p.M_DIST_DEALNUM as obcy_nr_sprawy
|
|
|
+ from CRM_LISTA_ZASOBOW_ORDERS o
|
|
|
+ left join IN7_MK_BAZA_DYSTRYBUCJI p on(p.ID = o.ID_PROJECT)
|
|
|
+ left join COMPANIES c on(c.ID = o.ID_COMPANIES)
|
|
|
+ where o.ID_PROJECT = {$id_project}
|
|
|
+ order by ID DESC
|
|
|
+ limit 100
|
|
|
+ ")
|
|
|
+ : array();
|
|
|
|
|
|
?>
|
|
|
<div class="container" style="margin-top:2em">
|
|
|
@@ -458,7 +497,24 @@ class Route_UrlAction_ProjektyProNetMediaZamZlec extends RouteBase {// TODO: Url
|
|
|
<div class="form-group">
|
|
|
<label for="id_project" class="col-sm-2 control-label">Projekt</label>
|
|
|
<div class="col-sm-4">
|
|
|
- <input type="number" name="ID_PROJECT" value="<?php echo $id_project; ?>" class="form-control">
|
|
|
+ <?php if ($widgetProject['typeSpecial']) : ?>
|
|
|
+ <?php
|
|
|
+ $fName = $widgetProject['fieldName'];
|
|
|
+ $fldParams = array();
|
|
|
+ $fldParams['allowCreate'] = false;
|
|
|
+ $fldParams['ajaxDataUrlBase'] = $widgetProject['dataUrl'];
|
|
|
+ if ($data['id_project'] > 0) {
|
|
|
+ $tsValues = $widgetProject['typeSpecial']->getValuesWithExports($q = $data['id_project']);
|
|
|
+ if (!empty($tsValues[ $data['id_project'] ])) {
|
|
|
+ $fldParams['typespecialValue'] = $tsValues[ $data['id_project'] ]->param_out;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //$fldParams['ajaxDataUrlBase'] .= "&DBG_TS=3";
|
|
|
+ echo $widgetProject['typeSpecial']->showFormItem($idTbl = $widgetProject['idTabela'], $fName, $selValue = $data['id_project'], $fldParams);
|
|
|
+ ?>
|
|
|
+ <?php else : ?>
|
|
|
+ <input type="number" name="<?= $widgetProject['fieldName']; ?>" value="<?= $data['id_project']; ?>" class="form-control">
|
|
|
+ <?php endif; ?>
|
|
|
</div>
|
|
|
</div>
|
|
|
<div class="form-group">
|
|
|
@@ -508,6 +564,7 @@ class Route_UrlAction_ProjektyProNetMediaZamZlec extends RouteBase {// TODO: Url
|
|
|
.orders_cell__order_notes .edit_note_btn { display:none }
|
|
|
.orders_cell__order_notes:hover .edit_note_btn { display:inline-block }
|
|
|
</style>
|
|
|
+<?php if (!empty($projOrders)) : ?>
|
|
|
<table class="table table-bordered table-hover">
|
|
|
<thead>
|
|
|
<tr>
|
|
|
@@ -572,6 +629,7 @@ class Route_UrlAction_ProjektyProNetMediaZamZlec extends RouteBase {// TODO: Url
|
|
|
</tbody>
|
|
|
</table>
|
|
|
</div>
|
|
|
+<?php endif; ?>
|
|
|
<link rel="stylesheet" type="text/css" href="static/sweetalert2.min.css">
|
|
|
<script src="static/sweetalert2.min.js"></script>
|
|
|
<script>
|