if ($searchGroup) { $groupID = $searchGroup[global_mapping::PropertyGroupID]; } else { $groupID = $objPropertyGroup->insert($group, $group, $catalogueID, $orderGroup, $createdBy, null); $orderGroup++; } } $propertyName = $item[global_mapping::PropertyID]; $propertyID = global_common::convertToInt($propertyName); //if is real propery name if ($propertyID <= 0) { $searchProperty = $objProperty->getPropertyByName($groupID, $propertyName); if ($searchProperty) { $propertyID = $searchProperty[global_mapping::PropertyID]; } else { $propertyID = $objProperty->insert($groupID, $propertyName, null, null, $createdBy, null); } } if ($propertyID) { $objProductProperty->insert($resultID, $propertyID, $item[global_mapping::PropertyValue], $orderProductProperty, 11, $item[global_mapping::Status]); $orderProductProperty++; } } $arrHeader = global_common::getMessageHeaderArr($banCode); //$banCode echo global_common::convertToXML($arrHeader, array("rs", "inf"), array(1, 'Đăng bài viết thành công'), array(0, 1)); return; } else { echo global_common::convertToXML($arrHeader, array("rs", "inf"), array(0, "Input data is invalid"), array(0, 1)); return; }
$objDataType = new Model_Datatype($objConnection); $objGroup = new Model_PropertyGroup($objConnection); $allCats = $objArticleType->getAllArticleType(0, null, '', null); if ($_pgR["act"] == Model_Property::ACT_ADD || $_pgR["act"] == Model_Property::ACT_UPDATE) { //get user info $c_userInfo = $_SESSION[global_common::SES_C_USERINFO]; $propertyName = $_pgR[global_mapping::PropertyName]; $propertyName = html_entity_decode($propertyName, ENT_COMPAT, 'UTF-8'); $dataTypeID = html_entity_decode($_pgR[global_mapping::DataTypeID], ENT_COMPAT, 'UTF-8'); $propertyGroupID = html_entity_decode($_pgR[global_mapping::PropertyGroupID], ENT_COMPAT, 'UTF-8'); $propertyValue = html_entity_decode($_pgR[global_mapping::PropertyValue], ENT_COMPAT, 'UTF-8'); $order = html_entity_decode($_pgR[global_mapping::Order], ENT_COMPAT, 'UTF-8'); $status = 1; if ($_pgR["act"] == Model_Property::ACT_ADD) { $createdBy = $c_userInfo[global_mapping::UserID]; $resultID = $objProperty->insert($propertyGroupID, $propertyName, $propertyValue, $dataTypeID, $order, $createdBy, $status); if ($resultID) { $arrHeader = global_common::getMessageHeaderArr($banCode); //$banCode echo global_common::convertToXML($arrHeader, array("rs", "inf"), array(1, 'Tạo mới thành công'), array(0, 1)); return; } else { echo global_common::convertToXML($arrHeader, array("rs", "inf"), array(0, "Input data is invalid"), array(0, 1)); return; } } else { $modifiedBy = $c_userInfo[global_mapping::UserID]; $propertyID = html_entity_decode($_pgR[global_mapping::PropertyID], ENT_COMPAT, 'UTF-8'); // $currentProperty = $objProperty->getPropertyByID($propertyID); $resultID = $objProperty->update($propertyID, $propertyGroupID, $propertyName, $propertyValue, $dataTypeID, $order, $modifiedBy, $status); if ($resultID) {
//} $propertyID = $_pgR['PropertyID']; $propertyID = global_editor::rteSafe(html_entity_decode($propertyID, ENT_COMPAT, 'UTF-8')); $propertyName = $_pgR['PropertyName']; $propertyName = global_editor::rteSafe(html_entity_decode($propertyName, ENT_COMPAT, 'UTF-8')); $productID = $_pgR['ProductID']; $productID = global_editor::rteSafe(html_entity_decode($productID, ENT_COMPAT, 'UTF-8')); $propertyValue = $_pgR['PropertyValue']; $propertyValue = global_editor::rteSafe(html_entity_decode($propertyValue, ENT_COMPAT, 'UTF-8')); $dataTypeID = $_pgR['DataTypeID']; $dataTypeID = global_editor::rteSafe(html_entity_decode($dataTypeID, ENT_COMPAT, 'UTF-8')); $status = $_pgR['Status']; $status = global_editor::rteSafe(html_entity_decode($status, ENT_COMPAT, 'UTF-8')); //$strName = $_pgR['name']; //$strName = global_editor::rteSafe(html_entity_decode($strName,ENT_COMPAT ,'UTF-8' )); $resultID = $objProperty->insert($propertyID, $propertyName, $productID, $propertyValue, $dataTypeID, $status); if ($resultID) { $arrHeader = global_common::getMessageHeaderArr($banCode); //$banCode echo global_common::convertToXML($arrHeader, array("rs", "inf"), array(1, $result), array(0, 1)); return; } else { echo global_common::convertToXML($arrHeader, array("rs", "info"), array(0, "Input data is invalid"), array(0, 1)); return; } } else { echo global_common::convertToXML($arrHeader, array("rs", 'info'), array(0, global_common::STRING_REQUIRE_LOGIN), array(0, 1)); } return; } elseif ($_pgR['act'] == model_Property::ACT_UPDATE) { if (global_common::isCLogin()) {
} fclose($handle); $count = count($stack); echo '<br>Count:' . $count; for ($i = 0; $i < $count; $i++) { $where = global_mapping::ArticleTypeID . '=' . $stack[$i][4] . ' and ' . global_mapping::PropertyGroupName . '=\'' . trim($stack[$i][1]) . '\''; $existedGroups = $objPropertyGroup->getAllPropertyGroup(0, '*', $where, ''); if (count($existedGroups) <= 0) { $groupID = $objPropertyGroup->insert($stack[$i][1], $stack[$i][1], $stack[$i][4], $i + 10, $createdBy); } else { $groupID = $existedGroups[0][0]; } $where = global_mapping::PropertyGroupID . '=' . $groupID . ' and ' . global_mapping::PropertyName . '=\'' . trim($stack[$i][0]) . '\''; $existedProperties = $objProperty->getAllProperty(0, '*', $where, ''); if (count($existedProperties) <= 0) { $objProperty->insert($groupID, $stack[$i][0], $stack[$i][2], 1, $stack[$i][3], $createdBy, 1); echo 'Inserted a new property ' . $stack[$i][0] . ' Group:' . $stack[$i][1] . 'Cat: ' . $stack[$i][4]; echo "<br>"; } else { echo 'Existed property ' . $stack[$i][0] . ' Group:' . $stack[$i][1] . 'Cat: ' . $stack[$i][4]; echo "<br>"; } //$stack[$i][4] = 1; } /*$fp = fopen($filePath, 'w'); fputcsv($fp, array('ID','Name','Address','Email','Sent')); foreach ($stack as $item) { fputcsv($fp, $item); } fclose($fp);