initializing git repo
This commit is contained in:
commit
3df8fc53b8
86 changed files with 5649 additions and 0 deletions
125
pages/add_part.php
Executable file
125
pages/add_part.php
Executable file
|
|
@ -0,0 +1,125 @@
|
|||
<?php
|
||||
|
||||
if (isset($_POST['NewPartType'])) $_SESSION['NewPartType'] = $_POST['NewPartType'];
|
||||
if (isset($_POST['NewPartStorage'])) $_SESSION['NewPartStorage'] = $_POST['NewPartStorage'];
|
||||
if (isset($_POST['NewPartPackage'])) $_SESSION['NewPartPackage'] = $_POST['NewPartPackage'];
|
||||
$_SESSION['NewPartObsolete'] = (isset($_POST['NewPartObsolete']))? $_POST['NewPartObsolete']:"";
|
||||
$_SESSION['NewPartName'] = (isset($_POST['NewPartName']))? $_POST['NewPartName']:"";
|
||||
$_SESSION['NewPartValue1'] = (isset($_POST['NewPartValue1']))? $_POST['NewPartValue1']:"";
|
||||
$_SESSION['NewPartValue2'] = (isset($_POST['NewPartValue2']))? $_POST['NewPartValue2']:"";
|
||||
$_SESSION['NewPartValue3'] = (isset($_POST['NewPartValue3']))? $_POST['NewPartValue3']:"";
|
||||
$_SESSION['NewPartShortDesc'] = (isset($_POST['NewPartShortDesc']))? $_POST['NewPartShortDesc']:"";
|
||||
$_SESSION['NewPartLongDesc'] = (isset($_POST['NewPartLongDesc']))? $_POST['NewPartLongDesc']:"";
|
||||
$_SESSION['NewPartVendor'] = (isset($_POST['NewPartVendor']))? $_POST['NewPartVendor']:"";
|
||||
$_SESSION['NewPartVedorLink'] = (isset($_POST['NewPartVedorLink']))? $_POST['NewPartVedorLink']:"";
|
||||
$_SESSION['NewPartManufactorLink'] = (isset($_POST['NewPartManufactorLink']))? $_POST['NewPartManufactorLink']:"";
|
||||
$_SESSION['NewPartPackageUnit'] = (isset($_POST['NewPartPackageUnit']))? $_POST['NewPartPackageUnit']:"";
|
||||
$_SESSION['NewPartPrice'] = (isset($_POST['NewPartPrice']))? $_POST['NewPartPrice']:"";
|
||||
$_SESSION['NewPartMinOrderQty'] = (isset($_POST['NewPartMinOrderQty']))? $_POST['NewPartMinOrderQty']:"";
|
||||
$_SESSION['NewPartQty'] = (isset($_POST['NewPartQty']))? $_POST['NewPartQty']:"";
|
||||
$_SESSION['NewPartMinQty'] = (isset($_POST['NewPartMinQty']))? $_POST['NewPartMinQty']:"";
|
||||
$AddNewPartSetp = (isset($_GET['AddNewPartSetp'])) ? $_GET['AddNewPartSetp']:"";
|
||||
|
||||
if (UserHasRight('EditParts'))
|
||||
{
|
||||
if ($AddNewPartSetp=="CreatePart")
|
||||
{
|
||||
if (!isset($_SESSION['NewPartPackage']) || !$_SESSION['NewPartPackage']) $AddNewPartSetp="SelectPackage" ;
|
||||
elseif (!isset($_SESSION['NewPartStorage']) || !$_SESSION['NewPartStorage']) $AddNewPartSetp="SelectStorage" ;
|
||||
elseif (!isset($_SESSION['NewPartType']) || !$_SESSION['NewPartType']) $AddNewPartSetp="" ;
|
||||
else
|
||||
{
|
||||
if (!$_SESSION['NewPartName'] && !$_SESSION['NewPartShortDesc'] && !$_SESSION['NewPartLongDesc']
|
||||
&& !$_SESSION['NewPartValue1'] && !$_SESSION['NewPartValue2'] && !$_SESSION['NewPartValue3'])
|
||||
{
|
||||
MessageError(LangSpell('SentenceNoNameOrValueOrDescriptionGiven'));
|
||||
ErrorLog("[add_part.php] No name, description or value given!");
|
||||
$AddNewPartSetp="SelectValues";
|
||||
}
|
||||
else
|
||||
{
|
||||
$InsertQuery = "INSERT INTO `Parts` (`Name`, `Value1`, `Value2`, `Value3`, `ShortDesc`, `LongDesc`"
|
||||
.", `TypeId`, `StorageId`, `PackageId`, `VendorId`, `VendorLink`, `ManufactorLink`"
|
||||
.", `PackageUnit`, `Price`, `MinOrderQty`, `Qty`, `MinQty`, `Obsolete`) VALUES "
|
||||
."('".$_SESSION['NewPartName']."', '".OtherSiPrefixToFloat ($_SESSION['NewPartValue1'])."'"
|
||||
.", '".OtherSiPrefixToFloat ($_SESSION['NewPartValue2'])."', '".OtherSiPrefixToFloat ($_SESSION['NewPartValue3'])."'"
|
||||
.", '".$_SESSION['NewPartShortDesc']."', '".$_SESSION['NewPartLongDesc']."'"
|
||||
.", '".$_SESSION['NewPartType']."', '".$_SESSION['NewPartStorage']."'"
|
||||
.", '".$_SESSION['NewPartPackage']."', '".$_SESSION['NewPartVendor']."'"
|
||||
.", '".$_SESSION['NewPartVedorLink']."', '".$_SESSION['NewPartManufactorLink']."'"
|
||||
.", '".$_SESSION['NewPartPackageUnit']."', '".OtherConvertToFloat ($_SESSION['NewPartPrice'])."'"
|
||||
.", '".$_SESSION['NewPartMinOrderQty']."', '".$_SESSION['NewPartQty']."'"
|
||||
.", '".$_SESSION['NewPartMinQty']."', '".((isset($_SESSION['NewPartObsolete']) && strtolower($_SESSION['NewPartObsolete'])=="true")? "True":"False")."');";
|
||||
global $GlobalMysqlHandler;
|
||||
if (mysqli_query($GlobalMysqlHandler, $InsertQuery))
|
||||
{
|
||||
unset($_SESSION['NewPartType'],$_SESSION['NewPartStorage'],$_SESSION['NewPartPackage']
|
||||
,$_SESSION['NewPartName'],$_SESSION['NewPartValue1'],$_SESSION['NewPartValue2']
|
||||
,$_SESSION['NewPartValue3'],$_SESSION['NewPartShortDesc'],$_SESSION['NewPartLongDesc']
|
||||
,$_SESSION['NewPartVendor'],$_SESSION['NewPartVedorLink'],$_SESSION['NewPartManufactorLink']
|
||||
,$_SESSION['NewPartPackageUnit'],$_SESSION['NewPartPrice'],$_SESSION['NewPartMinOrderQty']
|
||||
,$_SESSION['NewPartQty'],$_SESSION['NewPartMinQty']);
|
||||
$AddNewPartSetp = "";
|
||||
MessageSuccess(LangSpell('SentenceNewPartAdded'));
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageError(LangSpell('SentenceDatabaseError'));
|
||||
ErrorLog("[add_part.hp] Failed to Insert new part!");
|
||||
$AddNewPartSetp="SelectValues";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($AddNewPartSetp=="SelectValues")
|
||||
{
|
||||
if (isset($_SESSION['NewPartPackage']) && $_SESSION['NewPartPackage'])
|
||||
{
|
||||
include "./pages/add_part_values.php";
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageWarning(LangSpell('SentencePleaseSelectPackage'));
|
||||
$AddNewPartSetp="SelectPackage";
|
||||
}
|
||||
}
|
||||
|
||||
if ($AddNewPartSetp=="SelectPackage")
|
||||
{
|
||||
if (isset($_SESSION['NewPartStorage']) && $_SESSION['NewPartStorage'])
|
||||
{
|
||||
include "./pages/add_part_package.php";
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageWarning(LangSpell('SentencePleaseSelectPartStorage'));
|
||||
$AddNewPartSetp="SelectStorage";
|
||||
}
|
||||
}
|
||||
|
||||
if ($AddNewPartSetp=="SelectStorage")
|
||||
{
|
||||
if (isset($_SESSION['NewPartType']) && $_SESSION['NewPartType'])
|
||||
{
|
||||
include "./pages/add_part_storage.php";
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageWarning(LangSpell('SentencePleaseSelectPartType'));
|
||||
include "./pages/add_part_type.php";
|
||||
}
|
||||
}
|
||||
|
||||
if ($AddNewPartSetp=="")
|
||||
{
|
||||
$_SESSION['NewPartType'] = 0;
|
||||
$_SESSION['NewPartStorage'] = 0;
|
||||
include "./pages/add_part_type.php";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageError(LangSpell("ScentenceNoUserRights"));
|
||||
}
|
||||
?>
|
||||
73
pages/add_part_package.php
Executable file
73
pages/add_part_package.php
Executable file
|
|
@ -0,0 +1,73 @@
|
|||
<?php
|
||||
|
||||
$NewPartType = (isset($_POST['NewPartType']))? $_POST['NewPartType']:0;
|
||||
|
||||
function WritePackageList($ParentId, $ParentIsLocked)
|
||||
{
|
||||
global $GlobalMysqlHandler;
|
||||
global $GlobalContent;
|
||||
global $GlobalTemplate;
|
||||
global $EditTypesEditId;
|
||||
|
||||
$ListQuery="SELECT * FROM `Packages` WHERE `ParentId` =$ParentId";
|
||||
$ListQuery=mysqli_query($GlobalMysqlHandler, $ListQuery);
|
||||
|
||||
if (!$ParentId || NestedListVisibilityIsSet($ParentId, 'AddPartPackage'))
|
||||
$GlobalContent .= "<ul style=\"display:block;\">\n";
|
||||
else
|
||||
$GlobalContent .= "<ul style=\"display:none;\">\n";
|
||||
|
||||
if (mysqli_num_rows($ListQuery))
|
||||
{
|
||||
while ($ListData=mysqli_fetch_array($ListQuery))
|
||||
{
|
||||
$GlobalContent .= " <li>\n";
|
||||
if (LockIsActive('Types',$ListData['Id']) || $ParentIsLocked)
|
||||
{
|
||||
$GlobalContent .= OtherGetIcon('LockActive.png',0);
|
||||
$ParentIsLocked = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
$GlobalContent .= ' <input type="radio" name="NewPartPackage" value="'.$ListData['Id'].'">';
|
||||
}
|
||||
$GlobalContent .= " <a href=\"index.php?Page=AddPart&AddNewPartSetp=SelectPackage&ToDo=OpenSublist&SublistId=".$ListData['Id']."\">".LangStr2Html($ListData['Name'])."</a>";
|
||||
$GlobalContent .= " (".NestedListCountSubElements($ListData['Id'],'Packages').")";
|
||||
$GlobalContent .= " \n</li>\n";
|
||||
|
||||
WritePackageList($ListData['Id'],$ParentIsLocked);
|
||||
}
|
||||
}
|
||||
$GlobalContent .= "</ul>\n";
|
||||
}
|
||||
|
||||
|
||||
if (UserHasRight('EditParts'))
|
||||
{
|
||||
///////////////
|
||||
// open sublist
|
||||
if ($ToDo=="OpenSublist")
|
||||
{
|
||||
if (isset($_GET['SublistId']) && $_GET['SublistId'])
|
||||
{
|
||||
NestedListVisibilityToggle($_GET['SublistId'], 'AddPartPackage');
|
||||
}
|
||||
else
|
||||
{
|
||||
ErrorLog("[add_part1.php] No SublistId to open type!");
|
||||
MessageError(LangSpell('SentenceUnknownError'));
|
||||
}
|
||||
$ToDo="";
|
||||
}
|
||||
|
||||
$GlobalContent .= '<h1>'.LangSpellHtml('SentencePleaseSelectPackage').'</h1>';
|
||||
$GlobalContent .= '<form action="index.php?Page=AddPart&AddNewPartSetp=SelectValues" method="post">';
|
||||
WritePackageList(0, 0);
|
||||
$GlobalContent .= '<input type="submit" value="'.LangSpellHtml('ButtonProceed').'"class="Button">';
|
||||
$GlobalContent .= '</form>';
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageError(LangSpell("ScentenceNoUserRights"));
|
||||
}
|
||||
?>
|
||||
73
pages/add_part_storage.php
Executable file
73
pages/add_part_storage.php
Executable file
|
|
@ -0,0 +1,73 @@
|
|||
<?php
|
||||
|
||||
$NewPartType = (isset($_POST['NewPartType']))? $_POST['NewPartType']:0;
|
||||
|
||||
function WriteStorageList($ParentId, $ParentIsLocked)
|
||||
{
|
||||
global $GlobalMysqlHandler;
|
||||
global $GlobalContent;
|
||||
global $GlobalTemplate;
|
||||
global $EditTypesEditId;
|
||||
|
||||
$ListQuery="SELECT * FROM `Storages` WHERE `ParentId` =$ParentId";
|
||||
$ListQuery=mysqli_query($GlobalMysqlHandler, $ListQuery);
|
||||
|
||||
if (!$ParentId || NestedListVisibilityIsSet($ParentId, 'AddPartStorage'))
|
||||
$GlobalContent .= "<ul style=\"display:block;\">\n";
|
||||
else
|
||||
$GlobalContent .= "<ul style=\"display:none;\">\n";
|
||||
|
||||
if (mysqli_num_rows($ListQuery))
|
||||
{
|
||||
while ($ListData=mysqli_fetch_array($ListQuery))
|
||||
{
|
||||
$GlobalContent .= " <li>\n";
|
||||
if (LockIsActive('Types',$ListData['Id']) || $ParentIsLocked)
|
||||
{
|
||||
$GlobalContent .= OtherGetIcon('LockActive.png',0);
|
||||
$ParentIsLocked = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
$GlobalContent .= ' <input type="radio" name="NewPartStorage" value="'.$ListData['Id'].'">';
|
||||
}
|
||||
$GlobalContent .= " <a href=\"index.php?Page=AddPart&AddNewPartSetp=SelectStorage&ToDo=OpenSublist&SublistId=".$ListData['Id']."\">".LangStr2Html($ListData['Name'])."</a>";
|
||||
$GlobalContent .= " (".NestedListCountSubElements($ListData['Id'],'Storages').")";
|
||||
$GlobalContent .= " \n</li>\n";
|
||||
|
||||
WriteStorageList($ListData['Id'],$ParentIsLocked);
|
||||
}
|
||||
}
|
||||
$GlobalContent .= "</ul>\n";
|
||||
}
|
||||
|
||||
|
||||
if (UserHasRight('EditParts'))
|
||||
{
|
||||
///////////////
|
||||
// open sublist
|
||||
if ($ToDo=="OpenSublist")
|
||||
{
|
||||
if (isset($_GET['SublistId']) && $_GET['SublistId'])
|
||||
{
|
||||
NestedListVisibilityToggle($_GET['SublistId'], 'AddPartStorage');
|
||||
}
|
||||
else
|
||||
{
|
||||
ErrorLog("[add_part1.php] No SublistId to open type!");
|
||||
MessageError(LangSpell('SentenceUnknownError'));
|
||||
}
|
||||
$ToDo="";
|
||||
}
|
||||
|
||||
$GlobalContent .= '<h1>'.LangSpellHtml('SentencePleaseSelectPartStorage').'</h1>';
|
||||
$GlobalContent .= '<form action="index.php?Page=AddPart&AddNewPartSetp=SelectPackage" method="post">';
|
||||
WriteStorageList(0, 0);
|
||||
$GlobalContent .= '<input type="submit" value="'.LangSpellHtml('ButtonProceed').'"class="Button">';
|
||||
$GlobalContent .= '</form>';
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageError(LangSpell("ScentenceNoUserRights"));
|
||||
}
|
||||
?>
|
||||
75
pages/add_part_type.php
Executable file
75
pages/add_part_type.php
Executable file
|
|
@ -0,0 +1,75 @@
|
|||
<?php
|
||||
|
||||
function WriteTypeList($ParentId, $ParentIsLocked)
|
||||
{
|
||||
global $GlobalMysqlHandler;
|
||||
global $GlobalContent;
|
||||
global $GlobalTemplate;
|
||||
global $EditTypesEditId;
|
||||
|
||||
$ListQuery="SELECT * FROM `Types` WHERE `ParentId` =$ParentId";
|
||||
$ListQuery=mysqli_query($GlobalMysqlHandler, $ListQuery);
|
||||
|
||||
if (!$ParentId || NestedListVisibilityIsSet($ParentId, 'AddPartType'))
|
||||
$GlobalContent .= "<ul style=\"display:block;\">\n";
|
||||
else
|
||||
$GlobalContent .= "<ul style=\"display:none;\">\n";
|
||||
|
||||
if (mysqli_num_rows($ListQuery))
|
||||
{
|
||||
while ($ListData=mysqli_fetch_array($ListQuery))
|
||||
{
|
||||
$GlobalContent .= " <li>\n";
|
||||
if (LockIsActive('Types',$ListData['Id']) || $ParentIsLocked)
|
||||
{
|
||||
$GlobalContent .= OtherGetIcon('LockActive',0);
|
||||
$ParentIsLocked = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
$GlobalContent .= ' <input type="radio" name="NewPartType" value="'.$ListData['Id'].'">';
|
||||
}
|
||||
$GlobalContent .= " <a href=\"index.php?Page=AddPart&ToDo=OpenSublist&SublistId=".$ListData['Id']."\">".LangStr2Html($ListData['Name']);
|
||||
if (strlen($ListData['ShortName'])) $GlobalContent .= " [".LangStr2Html($ListData['ShortName'])."]";
|
||||
$GlobalContent .= "</a>";
|
||||
$GlobalContent .= " (".NestedListCountSubElements($ListData['Id'],'Types').")";
|
||||
$GlobalContent .= " \n</li>\n";
|
||||
|
||||
WriteTypeList($ListData['Id'],$ParentIsLocked);
|
||||
}
|
||||
}
|
||||
$GlobalContent .= "</ul>\n";
|
||||
}
|
||||
|
||||
|
||||
if (UserHasRight('EditParts'))
|
||||
{
|
||||
///////////////
|
||||
// open sublist
|
||||
if ($ToDo=="OpenSublist")
|
||||
{
|
||||
if (isset($_GET['SublistId']) && $_GET['SublistId'])
|
||||
{
|
||||
NestedListVisibilityToggle($_GET['SublistId'], 'AddPartType');
|
||||
}
|
||||
else
|
||||
{
|
||||
ErrorLog("[add_part1.php] No SublistId to open type!");
|
||||
MessageError(LangSpell('SentenceUnknownError'));
|
||||
}
|
||||
$ToDo="";
|
||||
}
|
||||
|
||||
//////////
|
||||
// Content
|
||||
$GlobalContent .= '<h1>'.LangSpellHtml('SentencePleaseSelectPartType').'</h1>';
|
||||
$GlobalContent .= '<form action="index.php?Page=AddPart&AddNewPartSetp=SelectStorage" method="post">';
|
||||
WriteTypeList(0, 0);
|
||||
$GlobalContent .= '<input type="submit" value="'.LangSpellHtml('ButtonProceed').'"class="Button">';
|
||||
$GlobalContent .= '</form>';
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageError(LangSpell("ScentenceNoUserRights"));
|
||||
}
|
||||
?>
|
||||
107
pages/add_part_values.php
Executable file
107
pages/add_part_values.php
Executable file
|
|
@ -0,0 +1,107 @@
|
|||
<?php
|
||||
|
||||
if (UserHasRight('EditParts'))
|
||||
{
|
||||
global $GlobalMysqlHandler;
|
||||
|
||||
/////////////
|
||||
// Type Array
|
||||
$TypeQuery = "SELECT * FROM `Types` WHERE `Id` = ".$_SESSION['NewPartType'];
|
||||
$TypeQuery = mysqli_query($GlobalMysqlHandler, $TypeQuery);
|
||||
$TypeValues = array();
|
||||
if (mysqli_num_rows($TypeQuery))
|
||||
{
|
||||
$TypeItem = mysql_fetch_array($TypeQuery);
|
||||
$TypeValues[0][0] = $TypeItem['NameValue1'];
|
||||
$TypeValues[0][1] = $TypeItem['UnitValue1'];
|
||||
$TypeValues[1][0] = $TypeItem['NameValue2'];
|
||||
$TypeValues[1][1] = $TypeItem['UnitValue2'];
|
||||
$TypeValues[2][0] = $TypeItem['NameValue3'];
|
||||
$TypeValues[2][1] = $TypeItem['UnitValue3'];
|
||||
}
|
||||
|
||||
//////////////
|
||||
// Value Table
|
||||
|
||||
$GlobalContent .= '<h1>'.LangSpellHtml('SentencePleaseSpecifyPartValues').'</h1>';
|
||||
$GlobalContent .= '<form action="index.php?Page=AddPart&AddNewPartSetp=CreatePart" method="post">';
|
||||
$GlobalContent .= '<table>';
|
||||
|
||||
$GlobalContent .= '<tr><th>'.LangSpellHtml('PartsObsolete').'</th><td>';
|
||||
$GlobalContent .= '<input type="checkbox" name="NewPartObsolete" value="True" '.((isset($_SESSION['NewPartObsolete']) && strtolower($_SESSION['NewPartObsolete'])=="true")? "checked":"").'"></td></tr>';
|
||||
|
||||
$GlobalContent .= '<tr><th>'.LangSpellHtml('PartsName').'</th><td>';
|
||||
$GlobalContent .= '<input type="text" name="NewPartName" value="'.((isset($_SESSION['NewPartName']))? $_SESSION['NewPartName']:"").'"></td></tr>';
|
||||
|
||||
if ($TypeValues[0][0])
|
||||
{
|
||||
$GlobalContent .= '<tr><th>'.$TypeValues[0][0].'</th><td>';
|
||||
$GlobalContent .= '<input type="text" name="NewPartValue1" value="'.((isset($_SESSION['NewPartValue1']))? $_SESSION['NewPartValue1']:"").'"></td>';
|
||||
$GlobalContent .= '<td> '.$TypeValues[0][1].'</td></tr>';
|
||||
}
|
||||
|
||||
if ($TypeValues[1][0])
|
||||
{
|
||||
$GlobalContent .= '<tr><th>'.$TypeValues[1][0].'</th><td>';
|
||||
$GlobalContent .= '<input type="text" name="NewPartValue2" value="'.((isset($_SESSION['NewPartValue2']))? $_SESSION['NewPartValue2']:"").'"></td>';
|
||||
$GlobalContent .= '<td> '.$TypeValues[1][1].'</td></tr>';
|
||||
}
|
||||
|
||||
if ($TypeValues[2][0])
|
||||
{
|
||||
$GlobalContent .= '<tr><th>'.$TypeValues[2][0].'</th><td>';
|
||||
$GlobalContent .= '<input type="text" name="NewPartValue3" value="'.((isset($_SESSION['NewPartValue3']))? $_SESSION['NewPartValue3']:"").'"></td>';
|
||||
$GlobalContent .= '<td> '.$TypeValues[2][1].'</td></tr>';
|
||||
}
|
||||
|
||||
$GlobalContent .= '<tr><th>'.LangSpellHtml('PartsShortDescription').'</th><td>';
|
||||
$GlobalContent .= '<input type="text" name="NewPartShortDesc" value="'.((isset($_SESSION['NewPartShortDesc']))? $_SESSION['NewPartShortDesc']:"").'"></td></tr>';
|
||||
|
||||
$GlobalContent .= '<tr><th>'.LangSpellHtml('PartsLongDescription').'</th><td>';
|
||||
$GlobalContent .= '<textarea name="NewPartLongDesc">'.((isset($_SESSION['NewPartLongDesc']))? $_SESSION['NewPartLongDesc']:"").'</textarea></td></tr>';
|
||||
|
||||
$GlobalContent .= '<tr><th>'.LangSpellHtml('PartsVendor').'</th><td>';
|
||||
$GlobalContent .= '<select name="NewPartVendor">';
|
||||
$VendorQuery = "SELECT `Id`,`Name` FROM `Vendors` ORDER BY `Name` ASC";
|
||||
$GlobalContent .= '<option value="0">'.LangSpellHtml('PartsNotSpecified').'</option>';
|
||||
$VendorQuery = mysqli_query($GlobalMysqlHandler, $VendorQuery);
|
||||
while ($VendorData = mysqli_fetch_array($VendorQuery))
|
||||
{
|
||||
$Selected = (isset($_SESSION['NewPartVendor']) && ($_SESSION['NewPartVendor']==$VendorData['Id']))? "selected":"";
|
||||
$GlobalContent .= '<option value="'.$VendorData['Id'].'" '.$Selected.'>'.$VendorData['Name'].'</option>';
|
||||
}
|
||||
$GlobalContent .= '</select></td></tr>';
|
||||
|
||||
$GlobalContent .= '<tr><th>'.LangSpellHtml('PartsVendorLink').'</th><td>';
|
||||
$GlobalContent .= '<input type="text" name="NewPartVedorLink" value="'.((isset($_SESSION['NewPartVedorLink']))? $_SESSION['NewPartVedorLink']:"").'"></td></tr>';
|
||||
|
||||
$GlobalContent .= '<tr><th>'.LangSpellHtml('PartsManufactorLink').'</th><td>';
|
||||
$GlobalContent .= '<input type="text" name="NewPartManufactorLink" value="'.((isset($_SESSION['NewPartManufactorLink']))? $_SESSION['NewPartManufactorLink']:"").'"></td></tr>';
|
||||
|
||||
$GlobalContent .= '<tr><th>'.LangSpellHtml('PartsPackageUnit').'</th><td>';
|
||||
$GlobalContent .= '<input type="text" name="NewPartPackageUnit" value="'.((isset($_SESSION['NewPartPackageUnit']))? $_SESSION['NewPartPackageUnit']:"").'"></td></tr>';
|
||||
|
||||
$GlobalContent .= '<tr><th>'.LangSpellHtml('PartsPrice').'</th><td>';
|
||||
$GlobalContent .= '<input type="text" name="NewPartPrice" value="'.((isset($_SESSION['NewPartPrice']))? $_SESSION['NewPartPrice']:"").'"></td></tr>';
|
||||
|
||||
$GlobalContent .= '<tr><th>'.LangSpellHtml('PartsMinOrderQuantity').'</th><td>';
|
||||
$GlobalContent .= '<input type="text" name="NewPartMinOrderQty" value="'.((isset($_SESSION['NewPartMinOrderQty']))? $_SESSION['NewPartMinOrderQty']:"").'"></td></tr>';
|
||||
|
||||
$GlobalContent .= '<tr><th>'.LangSpellHtml('PartsQuantity').'</th><td>';
|
||||
$GlobalContent .= '<input type="text" name="NewPartQty" value="'.((isset($_SESSION['NewPartQty']))? $_SESSION['NewPartQty']:"").'"></td></tr>';
|
||||
|
||||
$GlobalContent .= '<tr><th>'.LangSpellHtml('PartsMinQuantity').'</th><td>';
|
||||
$GlobalContent .= '<input type="text" name="NewPartMinQty" value="'.((isset($_SESSION['NewPartMinQty']))? $_SESSION['NewPartMinQty']:"").'"></td></tr>';
|
||||
|
||||
$GlobalContent .= '<tr><th></th><td>';
|
||||
$GlobalContent .= '<input type="submit" value="'.LangSpellHtml('ButtonProceed').'"class="Button">';
|
||||
$GlobalContent .= '</td></tr>';
|
||||
|
||||
$GlobalContent .= '</table>';
|
||||
$GlobalContent .= '</form>';
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageError(LangSpell("ScentenceNoUserRights"));
|
||||
}
|
||||
?>
|
||||
4
pages/consistency_check.php
Executable file
4
pages/consistency_check.php
Executable file
|
|
@ -0,0 +1,4 @@
|
|||
<?php
|
||||
include "./pages/consistency_check_databse.php";
|
||||
include "./pages/consistency_check_incorrect_types.php";
|
||||
?>
|
||||
146
pages/consistency_check_databse.php
Executable file
146
pages/consistency_check_databse.php
Executable file
|
|
@ -0,0 +1,146 @@
|
|||
<?php
|
||||
////////////////////////////
|
||||
// create database structure
|
||||
if (UserGetLogin()=="root")
|
||||
{
|
||||
if ($ToDo=="CreateDbStructure")
|
||||
{
|
||||
$CheckHandler=mysqli_connect($GlobalMysqlHost,$GlobalMysqlUser,$GlobalMysqlPwd);
|
||||
if (!$CheckHandler)
|
||||
{
|
||||
MessageError("Can not connect to database, check config!");
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageSuccess("Database connection successful.");
|
||||
$DatabaseExists = 0;
|
||||
if (mysqli_select_db$CheckHandler, ($GlobalMysqlDatabase)) $DatabaseExists=1;
|
||||
if (!$DatabaseExists)
|
||||
{
|
||||
if (mysqli_query($CheckHandler, "CREATE DATABASE `$GlobalMysqlDatabase` ;")) $DatabaseExists=1;
|
||||
else MessageError("Can not create database!");
|
||||
}
|
||||
if (mysqli_select_db($CheckHandler, $GlobalMysqlDatabase)) $DatabaseExists=1;
|
||||
if ($DatabaseExists)
|
||||
{
|
||||
////////////////
|
||||
// create tables
|
||||
mysqli_query($CheckHandler, 'SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";');
|
||||
//Downloads
|
||||
mysqli_query($CheckHandler, 'CREATE TABLE IF NOT EXISTS `Downloads` ( `Id` int(11) NOT NULL AUTO_INCREMENT, PRIMARY KEY (`Id`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; ');
|
||||
mysqli_query($CheckHandler, 'ALTER TABLE `Downloads` ADD `Id` int(11) NOT NULL AUTO_INCREMENT');
|
||||
mysqli_query($CheckHandler, 'ALTER TABLE `Downloads` DROP PRIMARY KEY , ADD PRIMARY KEY ( `Id` )');
|
||||
mysqli_query($CheckHandler, 'ALTER TABLE `Downloads` CHANGE `Id` `Id` INT( 11 ) NOT NULL AUTO_INCREMENT ');
|
||||
mysqli_query($CheckHandler, 'ALTER TABLE `Downloads` ADD `PartId` int(11) NOT NULL');
|
||||
mysqli_query($CheckHandler, 'ALTER TABLE `Downloads` ADD `Name` varchar(200) COLLATE utf8_unicode_ci NOT NULL');
|
||||
mysqli_query($CheckHandler, 'ALTER TABLE `Downloads` ADD `Path` varchar(200) COLLATE utf8_unicode_ci NOT NULL');
|
||||
mysqli_query($CheckHandler, 'ALTER TABLE `Downloads` ADD `Type` varchar(200) COLLATE utf8_unicode_ci NOT NULL');
|
||||
//Packages
|
||||
mysqli_query($CheckHandler, 'CREATE TABLE IF NOT EXISTS `Packages` ( `Id` int(11) NOT NULL AUTO_INCREMENT, PRIMARY KEY (`Id`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; ');
|
||||
mysqli_query($CheckHandler, 'ALTER TABLE `Packages` ADD `Id` int(11) NOT NULL AUTO_INCREMENT');
|
||||
mysqli_query($CheckHandler, 'ALTER TABLE `Packages` DROP PRIMARY KEY , ADD PRIMARY KEY ( `Id` )');
|
||||
mysqli_query($CheckHandler, 'ALTER TABLE `Packages` CHANGE `Id` `Id` INT( 11 ) NOT NULL AUTO_INCREMENT ');
|
||||
mysqli_query($CheckHandler, 'ALTER TABLE `Packages` ADD `Name` varchar(100) COLLATE utf8_unicode_ci NOT NULL');
|
||||
mysqli_query($CheckHandler, 'ALTER TABLE `Packages` ADD `ParentId` int(11) NOT NULL');
|
||||
mysqli_query($CheckHandler, 'ALTER TABLE `Packages` ADD `LockId` int(11) NOT NULL');
|
||||
mysqli_query($CheckHandler, 'ALTER TABLE `Packages` ADD `LockTime` int(11) NOT NULL');
|
||||
//Parts
|
||||
mysqli_query($CheckHandler, 'CREATE TABLE IF NOT EXISTS `Parts` ( `Id` int(11) NOT NULL AUTO_INCREMENT, PRIMARY KEY (`Id`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; ');
|
||||
mysqli_query($CheckHandler, 'ALTER TABLE `Parts` ADD `Id` int(11) NOT NULL AUTO_INCREMENT');
|
||||
mysqli_query($CheckHandler, 'ALTER TABLE `Parts` DROP PRIMARY KEY , ADD PRIMARY KEY ( `Id` )');
|
||||
mysqli_query($CheckHandler, 'ALTER TABLE `Parts` CHANGE `Id` `Id` INT( 11 ) NOT NULL AUTO_INCREMENT ');
|
||||
mysqli_query($CheckHandler, 'ALTER TABLE `Parts` ADD `Name` varchar(100) COLLATE utf8_unicode_ci NOT NULL');
|
||||
mysqli_query($CheckHandler, 'ALTER TABLE `Parts` ADD `Value1` float NOT NULL');
|
||||
mysqli_query($CheckHandler, 'ALTER TABLE `Parts` ADD `Value2` float NOT NULL');
|
||||
mysqli_query($CheckHandler, 'ALTER TABLE `Parts` ADD `Value3` float NOT NULL');
|
||||
mysqli_query($CheckHandler, 'ALTER TABLE `Parts` ADD `ShortDesc` varchar(250) COLLATE utf8_unicode_ci NOT NULL');
|
||||
mysqli_query($CheckHandler, 'ALTER TABLE `Parts` ADD `LongDesc` text COLLATE utf8_unicode_ci NOT NULL');
|
||||
mysqli_query($CheckHandler, 'ALTER TABLE `Parts` ADD `TypeId` int(11) NOT NULL');
|
||||
mysqli_query($CheckHandler, 'ALTER TABLE `Parts` ADD `StorageId` int(11) NOT NULL');
|
||||
mysqli_query($CheckHandler, 'ALTER TABLE `Parts` ADD `PackageId` int(11) NOT NULL');
|
||||
mysqli_query($CheckHandler, 'ALTER TABLE `Parts` ADD `VendorId` int(11) NOT NULL');
|
||||
mysqli_query($CheckHandler, 'ALTER TABLE `Parts` ADD `VendorLink` varchar(250) COLLATE utf8_unicode_ci NOT NULL');
|
||||
mysqli_query($CheckHandler, 'ALTER TABLE `Parts` ADD `ManufactorLink` varchar(250) COLLATE utf8_unicode_ci NOT NULL');
|
||||
mysqli_query($CheckHandler, 'ALTER TABLE `Parts` ADD `PackageUnit` int(11) NOT NULL DEFAULT \'1\'');
|
||||
mysqli_query($CheckHandler, 'ALTER TABLE `Parts` ADD `Price` float NOT NULL');
|
||||
mysqli_query($CheckHandler, 'ALTER TABLE `Parts` ADD `MinOrderQty` int(11) NOT NULL');
|
||||
mysqli_query($CheckHandler, 'ALTER TABLE `Parts` ADD `Qty` int(11) NOT NULL');
|
||||
mysqli_query($CheckHandler, 'ALTER TABLE `Parts` ADD `MinQty` int(11) NOT NULL');
|
||||
mysqli_query($CheckHandler, 'ALTER TABLE `Parts` ADD `Obsolete` enum(\'False\',\'True\') COLLATE utf8_unicode_ci NOT NULL');
|
||||
mysqli_query($CheckHandler, 'ALTER TABLE `Parts` ADD `PicturePath` varchar(200) COLLATE utf8_unicode_ci NOT NULL');
|
||||
mysqli_query($CheckHandler, 'ALTER TABLE `Parts` ADD `LockId` int(11) NOT NULL');
|
||||
mysqli_query($CheckHandler, 'ALTER TABLE `Parts` ADD `LockTime` int(11) NOT NULL');
|
||||
//Storages
|
||||
mysqli_query($CheckHandler, 'CREATE TABLE IF NOT EXISTS `Storages` ( `Id` int(11) NOT NULL AUTO_INCREMENT, PRIMARY KEY (`Id`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; ');
|
||||
mysqli_query($CheckHandler, 'ALTER TABLE `Storages` ADD `Id` int(11) NOT NULL AUTO_INCREMENT');
|
||||
mysqli_query($CheckHandler, 'ALTER TABLE `Storages` DROP PRIMARY KEY , ADD PRIMARY KEY ( `Id` )');
|
||||
mysqli_query($CheckHandler, 'ALTER TABLE `Storages` CHANGE `Id` `Id` INT( 11 ) NOT NULL AUTO_INCREMENT ');
|
||||
mysqli_query($CheckHandler, 'ALTER TABLE `Storages` ADD `Name` varchar(100) COLLATE utf8_unicode_ci NOT NULL');
|
||||
mysqli_query($CheckHandler, 'ALTER TABLE `Storages` ADD `ParentId` int(11) NOT NULL');
|
||||
mysqli_query($CheckHandler, 'ALTER TABLE `Storages` ADD `LockId` int(11) NOT NULL');
|
||||
mysqli_query($CheckHandler, 'ALTER TABLE `Storages` ADD `LockTime` int(11) NOT NULL');
|
||||
//Types
|
||||
mysqli_query($CheckHandler, 'CREATE TABLE IF NOT EXISTS `Types` ( `Id` int(11) NOT NULL AUTO_INCREMENT, PRIMARY KEY (`Id`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; ');
|
||||
mysqli_query($CheckHandler, 'ALTER TABLE `Types` ADD `Id` int(11) NOT NULL AUTO_INCREMENT');
|
||||
mysqli_query($CheckHandler, 'ALTER TABLE `Types` DROP PRIMARY KEY , ADD PRIMARY KEY ( `Id` )');
|
||||
mysqli_query($CheckHandler, 'ALTER TABLE `Types` CHANGE `Id` `Id` INT( 11 ) NOT NULL AUTO_INCREMENT ');
|
||||
mysqli_query($CheckHandler, 'ALTER TABLE `Types` ADD `Name` varchar(100) COLLATE utf8_unicode_ci NOT NULL');
|
||||
mysqli_query($CheckHandler, 'ALTER TABLE `Types` ADD `ShortName` varchar(10) COLLATE utf8_unicode_ci NOT NULL');
|
||||
mysqli_query($CheckHandler, 'ALTER TABLE `Types` ADD `NameValue1` varchar(50) COLLATE utf8_unicode_ci NOT NULL');
|
||||
mysqli_query($CheckHandler, 'ALTER TABLE `Types` ADD `UnitValue1` varchar(20) COLLATE utf8_unicode_ci NOT NULL');
|
||||
mysqli_query($CheckHandler, 'ALTER TABLE `Types` ADD `NameValue2` varchar(50) COLLATE utf8_unicode_ci NOT NULL');
|
||||
mysqli_query($CheckHandler, 'ALTER TABLE `Types` ADD `UnitValue2` varchar(20) COLLATE utf8_unicode_ci NOT NULL');
|
||||
mysqli_query($CheckHandler, 'ALTER TABLE `Types` ADD `NameValue3` varchar(50) COLLATE utf8_unicode_ci NOT NULL');
|
||||
mysqli_query($CheckHandler, 'ALTER TABLE `Types` ADD `UnitValue3` varchar(20) COLLATE utf8_unicode_ci NOT NULL');
|
||||
mysqli_query($CheckHandler, 'ALTER TABLE `Types` ADD `ParentId` int(11) NOT NULL');
|
||||
mysqli_query($CheckHandler, 'ALTER TABLE `Types` ADD `LockId` int(11) NOT NULL');
|
||||
mysqli_query($CheckHandler, 'ALTER TABLE `Types` ADD `LockTime` int(11) NOT NULL');
|
||||
//User
|
||||
mysqli_query($CheckHandler, 'CREATE TABLE IF NOT EXISTS `User` ( `Id` int(11) NOT NULL AUTO_INCREMENT, PRIMARY KEY (`Id`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; ');
|
||||
mysqli_query($CheckHandler, 'ALTER TABLE `User` ADD `Id` int(11) NOT NULL AUTO_INCREMENT');
|
||||
mysqli_query($CheckHandler, 'ALTER TABLE `User` DROP PRIMARY KEY , ADD PRIMARY KEY ( `Id` )');
|
||||
mysqli_query($CheckHandler, 'ALTER TABLE `User` CHANGE `Id` `Id` INT( 11 ) NOT NULL AUTO_INCREMENT ');
|
||||
mysqli_query($CheckHandler, 'ALTER TABLE `User` ADD `Login` varchar(100) COLLATE utf8_unicode_ci NOT NULL');
|
||||
mysqli_query($CheckHandler, 'ALTER TABLE `User` ADD `Password` varchar(35) COLLATE utf8_unicode_ci NOT NULL');
|
||||
mysqli_query($CheckHandler, 'ALTER TABLE `User` ADD `Template` varchar(100) COLLATE utf8_unicode_ci NOT NULL');
|
||||
mysqli_query($CheckHandler, 'ALTER TABLE `User` ADD `Language` varchar(100) COLLATE utf8_unicode_ci NOT NULL');
|
||||
//UserRights
|
||||
mysqli_query($CheckHandler, 'CREATE TABLE IF NOT EXISTS `UserRights` ( `Id` int(11) NOT NULL AUTO_INCREMENT, PRIMARY KEY (`Id`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; ');
|
||||
mysqli_query($CheckHandler, 'ALTER TABLE `UserRights` ADD `Id` int(11) NOT NULL AUTO_INCREMENT');
|
||||
mysqli_query($CheckHandler, 'ALTER TABLE `UserRights` DROP PRIMARY KEY , ADD PRIMARY KEY ( `Id` )');
|
||||
mysqli_query($CheckHandler, 'ALTER TABLE `UserRights` CHANGE `Id` `Id` INT( 11 ) NOT NULL AUTO_INCREMENT ');
|
||||
mysqli_query($CheckHandler, 'ALTER TABLE `UserRights` ADD `EditStores` enum(\'False\',\'True\') COLLATE utf8_unicode_ci NOT NULL DEFAULT \'False\'');
|
||||
mysqli_query($CheckHandler, 'ALTER TABLE `UserRights` ADD `EditTypes` enum(\'False\',\'True\') COLLATE utf8_unicode_ci NOT NULL DEFAULT \'False\'');
|
||||
mysqli_query($CheckHandler, 'ALTER TABLE `UserRights` ADD `EditPackages` enum(\'False\',\'True\') COLLATE utf8_unicode_ci NOT NULL DEFAULT \'False\'');
|
||||
mysqli_query($CheckHandler, 'ALTER TABLE `UserRights` ADD `EditVendors` enum(\'False\',\'True\') COLLATE utf8_unicode_ci NOT NULL DEFAULT \'False\'');
|
||||
mysqli_query($CheckHandler, 'ALTER TABLE `UserRights` ADD `ViewSTPV` enum(\'False\',\'True\') COLLATE utf8_unicode_ci NOT NULL');
|
||||
mysqli_query($CheckHandler, 'ALTER TABLE `UserRights` ADD `EditParts` enum(\'False\',\'True\') COLLATE utf8_unicode_ci NOT NULL');
|
||||
mysqli_query($CheckHandler, 'ALTER TABLE `UserRights` ADD `EditPartQuantity` enum(\'False\',\'True\') COLLATE utf8_unicode_ci NOT NULL');
|
||||
mysqli_query($CheckHandler, 'ALTER TABLE `UserRights` ADD `ConsistencyCheck` enum(\'False\',\'True\') COLLATE utf8_unicode_ci NOT NULL');
|
||||
//Vendors
|
||||
mysqli_query($CheckHandler, 'CREATE TABLE IF NOT EXISTS `Vendors` ( `Id` int(11) NOT NULL AUTO_INCREMENT, PRIMARY KEY (`Id`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; ');
|
||||
mysqli_query($CheckHandler, 'ALTER TABLE `Vendors` ADD `Id` int(11) NOT NULL AUTO_INCREMENT');
|
||||
mysqli_query($CheckHandler, 'ALTER TABLE `Vendors` DROP PRIMARY KEY , ADD PRIMARY KEY ( `Id` )');
|
||||
mysqli_query($CheckHandler, 'ALTER TABLE `Vendors` CHANGE `Id` `Id` INT( 11 ) NOT NULL AUTO_INCREMENT ');
|
||||
mysqli_query($CheckHandler, 'ALTER TABLE `Vendors` ADD `Name` varchar(200) COLLATE utf8_unicode_ci NOT NULL');
|
||||
mysqli_query($CheckHandler, 'ALTER TABLE `Vendors` ADD `Homepage` varchar(200) COLLATE utf8_unicode_ci NOT NULL');
|
||||
mysqli_query($CheckHandler, 'ALTER TABLE `Vendors` ADD `MinBill` float NOT NULL');
|
||||
mysqli_query($CheckHandler, 'ALTER TABLE `Vendors` ADD `ShippingCost` float NOT NULL');
|
||||
mysqli_query($CheckHandler, 'ALTER TABLE `Vendors` ADD `LockId` int(11) NOT NULL');
|
||||
mysqli_query($CheckHandler, 'ALTER TABLE `Vendors` ADD `LockTime` int(11) NOT NULL');
|
||||
|
||||
mysqli_close($CheckHandler);
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageError("No database to operate!");
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$GlobalContent .= "<h1>".LangSpellHtml('ConsCheckCreateDatabaseStructure')."</h1>";
|
||||
$GlobalContent .= '<a href="index.php?Page=ConsistencyCheck&ToDo=CreateDbStructure" class="Button">'.LangSpellHtml('ButtonProceed').'</a>';
|
||||
}
|
||||
}
|
||||
?>
|
||||
81
pages/consistency_check_incorrect_types.php
Executable file
81
pages/consistency_check_incorrect_types.php
Executable file
|
|
@ -0,0 +1,81 @@
|
|||
<?php
|
||||
//////////////
|
||||
// check types
|
||||
global $GlobalMysqlHandler;
|
||||
|
||||
function ElementExistInArray ( $Array, $Element )
|
||||
{
|
||||
$RetVal=0;
|
||||
foreach ($Array as $x)
|
||||
{
|
||||
if ($x==$Element) $RetVal=1;
|
||||
}
|
||||
return $RetVal;
|
||||
}
|
||||
|
||||
if (UserHasRight('ConsistencyCheck'))
|
||||
{
|
||||
$TypeQuery = "SELECT `Id` FROM `Types`";
|
||||
$TypeQuery = mysqli_query($GlobalMysqlHandler, $TypeQuery);
|
||||
$Types = array();
|
||||
while ($Type = mysqli_fetch_array($TypeQuery)) $Types[count($Types)]=$Type['Id'];
|
||||
|
||||
if ($ToDo=="RepairIncorrectTypes")
|
||||
{
|
||||
$CheckQuery = mysqli_query($GlobalMysqlHandler, "SELECT `Id`,`TypeId` FROM `Parts`");
|
||||
$LostPartsTypeId=0;
|
||||
$Error=0;
|
||||
$MovedParts=0;
|
||||
while ($Part = mysqli_fetch_array($CheckQuery))
|
||||
{
|
||||
if (!ElementExistInArray($Types,$Part['TypeId']))
|
||||
{
|
||||
if (!$LostPartsTypeId)
|
||||
{
|
||||
$LostPartypeQuery=mysqli_query($GlobalMysqlHandler, "SELECT `Id` FROM `Types` WHERE `Name` = 'LostTypeParts'");
|
||||
if (!mysql_num_rows($LostPartypeQuery))
|
||||
{
|
||||
mysqli_query($GlobalMysqlHandler, "INSERT INTO `Types` ( `Name` , `ParentId` ) VALUES ( 'LostTypeParts', '0' );");
|
||||
}
|
||||
$LostPartypeQuery=mysqli_query($GlobalMysqlHandler, "SELECT `Id` FROM `Types` WHERE `Name` = 'LostTypeParts'");
|
||||
if (mysqli_num_rows($LostPartypeQuery))
|
||||
{
|
||||
$Type=mysqli_fetch_array($LostPartypeQuery);
|
||||
$LostPartsTypeId=$Type['Id'];
|
||||
}
|
||||
else
|
||||
{
|
||||
$Error=1;
|
||||
MessageError(LangSpell('SentenceDatabaseError'));
|
||||
ErrorLog("Can not create 'LostTypeParts' type!");
|
||||
}
|
||||
}
|
||||
if (!$Error)
|
||||
{
|
||||
if (mysqli_query($GlobalMysqlHandler, "UPDATE `Parts` SET `TypeId` = '$LostPartsTypeId' WHERE `Id` =".$Part['Id']." LIMIT 1 ;"))
|
||||
$MovedParts++;
|
||||
else
|
||||
{
|
||||
MessageError(LangSpell('SentenceDatabaseError'));
|
||||
ErrorLog("Can not change type id from part '".$Part['Id']."'!");
|
||||
}
|
||||
}
|
||||
else
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ($MovedParts)
|
||||
{
|
||||
MessageSuccess("$MovedParts parts moved to type 'LostTypeParts'.");
|
||||
}
|
||||
}
|
||||
|
||||
//show content
|
||||
$CheckQuery = mysqli_query($GlobalMysqlHandler, "SELECT `TypeId` FROM `Parts`");
|
||||
$IncorrectTypes=0;
|
||||
while ($Part = mysqli_fetch_array($CheckQuery)) $IncorrectTypes+= ElementExistInArray($Types,$Part['TypeId'])? 0:1;
|
||||
$GlobalContent .= "<h1>".LangSpellHtml('ConsCheckRepairIncorrectType')."</h1>";
|
||||
$GlobalContent .= LangSpellHtml('COnsCheckIncorrectTypeParts') . ": " . $IncorrectTypes . "<br>";
|
||||
$GlobalContent .= '<a href="index.php?Page=ConsistencyCheck&ToDo=RepairIncorrectTypes" class="Button">'.LangSpellHtml('ButtonProceed').'</a>';
|
||||
}
|
||||
?>
|
||||
165
pages/edit_config.php
Executable file
165
pages/edit_config.php
Executable file
|
|
@ -0,0 +1,165 @@
|
|||
<?php
|
||||
|
||||
if (UserGetLogin()=="root")
|
||||
{
|
||||
//////////////////
|
||||
//save Config
|
||||
if ($ToDo=="SaveConfig")
|
||||
{
|
||||
//create new config file array
|
||||
$ConfigFileArray = array();
|
||||
$ConfigFileArray[count($ConfigFileArray)]=' $CfgStdTemplate = "'.$_POST['CfgStdTemplate'].'";'."\n";
|
||||
$ConfigFileArray[count($ConfigFileArray)]=' $CfgStdLanguage = "'.$_POST['CfgStdLanguage'].'";'."\n";
|
||||
$ConfigFileArray[count($ConfigFileArray)]=' $CfgStdTimeZone = "'.$_POST['CfgStdTimeZone'].'";'."\n";
|
||||
$ConfigFileArray[count($ConfigFileArray)]=' $CfgStdTimeFormat = "'.$_POST['CfgStdTimeFormat'].'";'."\n";
|
||||
if ( ($_POST['Password1']==$_POST['Password2']) && (trim($_POST['Password1'])) )
|
||||
{
|
||||
$ConfigFileArray[count($ConfigFileArray)]=' $CfgRootPassword = "'.md5($_POST['Password1']).'";'."\n";
|
||||
MessageWarning(LangSpellHtml('SentencePasswordChangedWarning'));
|
||||
UserLogout();
|
||||
}
|
||||
else
|
||||
{
|
||||
include "config.php";
|
||||
$ConfigFileArray[count($ConfigFileArray)] = ' $CfgRootPassword = "'.$CfgRootPassword.'";'."\n";
|
||||
}
|
||||
$ConfigFileArray[count($ConfigFileArray)]=' $CfgLogfile = "'.$_POST['CfgLogfile'].'";'."\n";
|
||||
$ConfigFileArray[count($ConfigFileArray)]=' $CfgLogfileMaxLines = "'.$_POST['CfgLogfileMaxLines'].'";'."\n";
|
||||
$ConfigFileArray[count($ConfigFileArray)]=' $CfgSetDebugMode = "'.$_POST['CfgSetDebugMode'].'";'."\n";
|
||||
$ConfigFileArray[count($ConfigFileArray)]=' $CfgMysqlHost = "'.$_POST['CfgMysqlHost'].'";'."\n";
|
||||
$ConfigFileArray[count($ConfigFileArray)]=' $CfgMysqlUser = "'.$_POST['CfgMysqlUser'].'";'."\n";
|
||||
$ConfigFileArray[count($ConfigFileArray)]=' $CfgMysqlPwd = "'.$_POST['CfgMysqlPwd'].'";'."\n";
|
||||
$ConfigFileArray[count($ConfigFileArray)]=' $CfgMysqlDatabase = "'.$_POST['CfgMysqlDatabase'].'";'."\n";
|
||||
$ConfigFileArray[count($ConfigFileArray)]=' $CfgLoginTimeout = "'.$_POST['CfgLoginTimeout'].'";'."\n";
|
||||
$ConfigFileArray[count($ConfigFileArray)]=' $CfgLockAutoReleaseTime = "'.$_POST['CfgLockAutoReleaseTime'].'";'."\n";
|
||||
|
||||
//save config file
|
||||
$ConfigFileHandler=fopen("./config.php","w");
|
||||
fputs($ConfigFileHandler,"<?php\n");
|
||||
foreach ($ConfigFileArray as $Line)
|
||||
{
|
||||
fputs($ConfigFileHandler,$Line);
|
||||
}
|
||||
fputs($ConfigFileHandler,"?>\n");
|
||||
fclose($ConfigFileHandler);
|
||||
}
|
||||
include("./includes/load_config.php");
|
||||
}
|
||||
|
||||
|
||||
if (UserGetLogin()=="root")
|
||||
{
|
||||
//////////////////
|
||||
//global content
|
||||
include ("config.php");
|
||||
$GlobalContent.='<form action="index.php?Page=EditConfig&ToDo=SaveConfig" method="post">'."\n";
|
||||
$GlobalContent.='<table>'."\n";
|
||||
|
||||
$GlobalContent.=' <tr>'."\n";
|
||||
$GlobalContent.=' <th>CfgStdTemplate</th>'."\n";
|
||||
$GlobalContent.=' <td><select name="CfgStdTemplate">'."\n";
|
||||
$AvailableTemplates=OtherGetAvailableTemplates();
|
||||
foreach ($AvailableTemplates as $x)
|
||||
{
|
||||
$GlobalContent.=' <option value="'.$x.'" '.(($x==$CfgStdTemplate)? 'selected':'').'>'.$x.'</option>'."\n";
|
||||
}
|
||||
$GlobalContent.=' </select><td>'."\n";
|
||||
$GlobalContent.=' <tr>'."\n";
|
||||
|
||||
$GlobalContent.=' <tr>'."\n";
|
||||
$GlobalContent.=' <th>CfgStdLanguage</th>'."\n";
|
||||
$GlobalContent.=' <td><select name="CfgStdLanguage">'."\n";
|
||||
$AvailableTemplates=LangGetAvailableLanguages();
|
||||
foreach ($AvailableTemplates as $x)
|
||||
{
|
||||
$GlobalContent.=' <option value="'.$x.'" '.(($x==$CfgStdLanguage)? 'selected':'').'>'.$x.'</option>'."\n";
|
||||
}
|
||||
$GlobalContent.=' </select><td>'."\n";
|
||||
$GlobalContent.=' <tr>'."\n";
|
||||
|
||||
$GlobalContent.=' <tr>'."\n";
|
||||
$GlobalContent.=' <th>CfgStdTimeZone</th>'."\n";
|
||||
$GlobalContent.=' <td><input type="text" name="CfgStdTimeZone" value="'.$CfgStdTimeZone.'"></td>'."\n";
|
||||
$GlobalContent.=' <td>'."\n";
|
||||
$GlobalContent.=' <a href="http://www.php.net/manual/en/timezones.php" title="" target="new">'."\n";
|
||||
$GlobalContent.=' '.OtherGetIcon('Help',"Button")."\n";
|
||||
$GlobalContent.=' </a>'."\n";
|
||||
$GlobalContent.=' </td>'."\n";
|
||||
$GlobalContent.=' <tr>'."\n";
|
||||
|
||||
$GlobalContent.=' <tr>'."\n";
|
||||
$GlobalContent.=' <th>CfgStdTimeFormat</th>'."\n";
|
||||
$GlobalContent.=' <td><input type="text" name="CfgStdTimeFormat" value="'.$CfgStdTimeFormat.'"></td>'."\n";
|
||||
$GlobalContent.=' <td>'."\n";
|
||||
$GlobalContent.=' <a href="http://www.php.net/manual/en/function.date.php" title="" target="new">'."\n";
|
||||
$GlobalContent.=' '.OtherGetIcon('Help',"Button")."\n";
|
||||
$GlobalContent.=' </a>'."\n";
|
||||
$GlobalContent.=' </td>'."\n";
|
||||
$GlobalContent.=' <tr>'."\n";
|
||||
|
||||
$GlobalContent.=' <tr>'."\n";
|
||||
$GlobalContent.=' <th>'.LangSpellHtml('UserSettingsSetNewPassword').'</th>'."\n";
|
||||
$GlobalContent.=' <td><input type="password" name="Password1" value=""></td>'."\n";
|
||||
$GlobalContent.=' <tr>'."\n";
|
||||
$GlobalContent.=' <tr>'."\n";
|
||||
$GlobalContent.=' <th>'.LangSpellHtml('UserSettingsConfirmNewPassword').'</th>'."\n";
|
||||
$GlobalContent.=' <td><input type="password" name="Password2" value=""></td>'."\n";
|
||||
$GlobalContent.=' <tr>'."\n";
|
||||
|
||||
$GlobalContent.=' <tr>'."\n";
|
||||
$GlobalContent.=' <th>CfgLogfile</th>'."\n";
|
||||
$GlobalContent.=' <td><input type="text" name="CfgLogfile" value="'.$CfgLogfile.'"></td>'."\n";
|
||||
$GlobalContent.=' <tr>'."\n";
|
||||
$GlobalContent.=' <tr>'."\n";
|
||||
$GlobalContent.=' <th>CfgLogfileMaxLines</th>'."\n";
|
||||
$GlobalContent.=' <td><input type="text" name="CfgLogfileMaxLines" value="'.$CfgLogfileMaxLines.'"></td>'."\n";
|
||||
$GlobalContent.=' <tr>'."\n";
|
||||
|
||||
$GlobalContent.=' <tr>'."\n";
|
||||
$GlobalContent.=' <th>CfgSetDebugMode</th>'."\n";
|
||||
$GlobalContent.=' <td><select name="CfgSetDebugMode">'."\n";
|
||||
$GlobalContent.=' <option value="True" '.((strtolower($CfgSetDebugMode)=="true")? "selected":"").'>True</option>'."\n";
|
||||
$GlobalContent.=' <option value="False" '.((strtolower($CfgSetDebugMode)!="true")? "selected":"").'>False</option>'."\n";
|
||||
$GlobalContent.=' </select></td>'."\n";
|
||||
$GlobalContent.=' <tr>'."\n";
|
||||
|
||||
$GlobalContent.=' <tr>'."\n";
|
||||
$GlobalContent.=' <th>CfgMysqlHost</th>'."\n";
|
||||
$GlobalContent.=' <td><input type="text" name="CfgMysqlHost" value="'.$CfgMysqlHost.'"></td>'."\n";
|
||||
$GlobalContent.=' <tr>'."\n";
|
||||
$GlobalContent.=' <tr>'."\n";
|
||||
$GlobalContent.=' <th>CfgMysqlUser</th>'."\n";
|
||||
$GlobalContent.=' <td><input type="text" name="CfgMysqlUser" value="'.$CfgMysqlUser.'"></td>'."\n";
|
||||
$GlobalContent.=' <tr>'."\n";
|
||||
$GlobalContent.=' <tr>'."\n";
|
||||
$GlobalContent.=' <th>CfgMysqlPwd</th>'."\n";
|
||||
$GlobalContent.=' <td><input type="text" name="CfgMysqlPwd" value="'.$CfgMysqlPwd.'"></td>'."\n";
|
||||
$GlobalContent.=' <tr>'."\n";
|
||||
$GlobalContent.=' <tr>'."\n";
|
||||
$GlobalContent.=' <th>CfgMysqlDatabase</th>'."\n";
|
||||
$GlobalContent.=' <td><input type="text" name="CfgMysqlDatabase" value="'.$CfgMysqlDatabase.'"></td>'."\n";
|
||||
$GlobalContent.=' <tr>'."\n";
|
||||
|
||||
$GlobalContent.=' <tr>'."\n";
|
||||
$GlobalContent.=' <th>CfgLoginTimeout</th>'."\n";
|
||||
$GlobalContent.=' <td><input type="text" name="CfgLoginTimeout" value="'.$CfgLoginTimeout.'"></td>'."\n";
|
||||
$GlobalContent.=' <tr>'."\n";
|
||||
|
||||
$GlobalContent.=' <tr>'."\n";
|
||||
$GlobalContent.=' <th>CfgLockAutoReleaseTime</th>'."\n";
|
||||
$GlobalContent.=' <td><input type="text" name="CfgLockAutoReleaseTime" value="'.$CfgLockAutoReleaseTime.'"></td>'."\n";
|
||||
$GlobalContent.=' <tr>'."\n";
|
||||
|
||||
$GlobalContent.=' <tr>'."\n";
|
||||
$GlobalContent.=' <th>'.LangSpellHtml('ButtonSave').'</th>'."\n";
|
||||
$GlobalContent.=' <td><input type="submit" value="'.LangSpellHtml('ButtonSave').'" class="Button"></td>'."\n";
|
||||
$GlobalContent.=' <tr>'."\n";
|
||||
|
||||
$GlobalContent.='</table>'."\n";
|
||||
$GlobalContent.='</form>'."\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageError(LangSpell("ScentenceNoUserRights"));
|
||||
}
|
||||
?>
|
||||
299
pages/edit_packages.php
Executable file
299
pages/edit_packages.php
Executable file
|
|
@ -0,0 +1,299 @@
|
|||
<?php
|
||||
|
||||
$EditPackagesEditId=0;
|
||||
|
||||
function WritePackagesList($ParentId, $ParentIsLocked)
|
||||
{
|
||||
global $GlobalMysqlHandler;
|
||||
global $GlobalContent;
|
||||
global $GlobalTemplate;
|
||||
global $EditPackagesEditId;
|
||||
|
||||
$ListQuery="SELECT `Id` , `Name` FROM `Packages` WHERE `ParentId` =$ParentId";
|
||||
$ListQuery=mysqli_query($GlobalMysqlHandler, $ListQuery);
|
||||
|
||||
if (!$ParentId || NestedListVisibilityIsSet($ParentId, 'EditPackages'))
|
||||
$GlobalContent .= "<ul style=\"display:block;\">\n";
|
||||
else
|
||||
$GlobalContent .= "<ul style=\"display:none;\">\n";
|
||||
|
||||
if (mysqli_num_rows($ListQuery))
|
||||
{
|
||||
while ($ListData=mysqli_fetch_array($ListQuery))
|
||||
{
|
||||
if ($EditPackagesEditId
|
||||
&& ($EditPackagesEditId==$ListData['Id'])
|
||||
&& !( LockIsActive('Packages',$ListData['Id']) || $ParentIsLocked)
|
||||
)
|
||||
{ //edit entry
|
||||
$GlobalContent .= " <li>\n";
|
||||
$GlobalContent .= ' <a href="index.php?Page=EditPackages&ToDo=DeletePackage&Id='.$ListData['Id'].'" title="'.LangSpellHtml('TagTitleDelete').'">'.OtherGetIcon('Delete',"Button").'</a>';
|
||||
$GlobalContent .= ' <form action="index.php?Page=EditPackages&ToDo=EditpackageSave" method="post">';
|
||||
$GlobalContent .= ' <input type="hidden" name="Id" value="'.$ListData['Id'].'">';
|
||||
$GlobalContent .= '<input type="text" name="Name" value="'.$ListData['Name'].'">';
|
||||
$GlobalContent .= '<select name="MoveToId" title="'.LangSpellHtml('TagTitleMove').'">';
|
||||
if ($ParentId)
|
||||
$GlobalContent .= '<option value="#MOVE#ITEM#UP#">'.LangSpellHtml('TagTitleMoveUp').'</option>';
|
||||
$GlobalContent .= '<option value="" selected>--- '.LangSpellHtml('TagTitleMove').' ---</option>';
|
||||
$MoveItems = NestedLisGetSubelements($ParentId,"Packages");
|
||||
foreach ($MoveItems as $MvItm)
|
||||
{
|
||||
if ($MvItm[0]==$ListData['Id']) continue;
|
||||
$GlobalContent .= '<option value="'.$MvItm[0].'">'.$MvItm[1].'</option>';
|
||||
}
|
||||
$GlobalContent .= "</select>";
|
||||
$GlobalContent .= '<input type="submit" value="'.LangSpellHtml('ButtonSave').'" class="Button">';
|
||||
$GlobalContent .= ' </form>';
|
||||
$GlobalContent .= ' <a href="index.php?Page=EditPackages&ToDo=CancelEditPackage&Id='.$ListData['Id'].'" title="'.LangSpellHtml('TagTitleCancel').'">'.OtherGetIcon('Cancel',"Button").'</a>' ."\n";
|
||||
$GlobalContent .= " </li>\n";
|
||||
}
|
||||
else
|
||||
{ //just show entry
|
||||
$GlobalContent .= " <li>\n";
|
||||
if (LockIsActive('Packages',$ListData['Id']) || $ParentIsLocked)
|
||||
{
|
||||
$GlobalContent .= ' '.OtherGetIcon('LockActive');
|
||||
$ParentIsLocked = 1;
|
||||
}
|
||||
elseif (UserHasRight('EditPackages'))
|
||||
{
|
||||
$GlobalContent .= ' <a href="index.php?Page=EditPackages&ToDo=EditPackage&Id='.$ListData['Id'].'" target="_top" title="'.LangSpellHtml('TagTitleEdit').'">';
|
||||
$GlobalContent .= OtherGetIcon('Edit',"Button");
|
||||
}
|
||||
$GlobalContent .= " <a href=\"index.php?Page=EditPackages&ToDo=OpenSublist&SublistId=".$ListData['Id']."\">".LangStr2Html($ListData['Name'])."</a>";
|
||||
$GlobalContent .= " (".NestedListCountSubElements($ListData['Id'],'Packages').")";
|
||||
$GlobalContent .= " \n</li>\n";
|
||||
}
|
||||
|
||||
WritePackagesList($ListData['Id'],$ParentIsLocked);
|
||||
}
|
||||
}
|
||||
if (!$EditPackagesEditId && UserHasRight('EditPackages'))
|
||||
{
|
||||
$GlobalContent .= " <li>\n";
|
||||
$GlobalContent .= ' <form action="index.php?Page=EditPackages&ToDo=NewPackage&ParentId='.$ParentId.'" method="post">'."\n";
|
||||
$GlobalContent .= ' <input type="text" name="NewPackageName" value="">'."\n";
|
||||
$GlobalContent .= ' <input type="submit" value="'.LangSpellHtml('ButtonNew').'" class="Button">'."\n";
|
||||
$GlobalContent .= ' </form>'."\n";
|
||||
$GlobalContent .= " </li>\n";
|
||||
}
|
||||
$GlobalContent .= "</ul>\n";
|
||||
}
|
||||
|
||||
if (UserHasRight('EditPackages'))
|
||||
{
|
||||
/////////////////
|
||||
//edit package save
|
||||
if ($ToDo=="EditpackageSave")
|
||||
{
|
||||
if (isset($_POST['Id']) && $_POST['Id'] && isset($_POST['Name']) && $_POST['Name'])
|
||||
{
|
||||
global $GlobalMysqlHandler;
|
||||
$Id = $_POST['Id'];
|
||||
$Name = $_POST['Name'];
|
||||
$MoveId = (isset($_POST['MoveToId']))? $_POST['MoveToId']:0;
|
||||
|
||||
if ($MoveId)
|
||||
{
|
||||
$MoveQuery = "";
|
||||
if ($MoveId=="#MOVE#ITEM#UP#")
|
||||
{
|
||||
$FirstParentId = NestedListGetParentId($Id,'Packages');
|
||||
$MoveId = NestedListGetParentId($FirstParentId,'Packages');
|
||||
}
|
||||
else
|
||||
{
|
||||
$FirstParentId = NestedListGetParentId($Id,'Packages');
|
||||
}
|
||||
|
||||
$MoveQuery="UPDATE `Packages` SET `ParentId` = '$MoveId' WHERE `Id` =$Id LIMIT 1 ;";
|
||||
|
||||
if (mysqli_query($GlobalMysqlHandler, $MoveQuery))
|
||||
{
|
||||
MessageSuccess(LangSpell('SentenceNestedListMoved'));
|
||||
NestedListVisibilityUnset($FirstParentId,'EditPackages');
|
||||
NestedListVisibilitySet($MoveId,'EditPackages');
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageError(LangSpell('SentenceDatabaseError'));
|
||||
ErrorLog("[edit_pacakges.php] Db error on moving element with id $Id to parent id $MoveId");
|
||||
}
|
||||
}
|
||||
|
||||
$ChangeNameQuery="UPDATE `Packages` SET `Name` = '$Name' WHERE `Id` =$Id LIMIT 1 ;";
|
||||
if (!mysqli_query($GlobalMysqlHandler, $ChangeNameQuery))
|
||||
{
|
||||
MessageError(LangSpell('SentenceDatabaseError'));
|
||||
ErrorLog("[edit_pacakges.php] Db error on naming element with id $Id");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (isset($_POST['Name']) && !trim($_POST['Name']))
|
||||
MessageError(LangSpell('EditPackagesNoPackageNameGiven'));
|
||||
else
|
||||
{
|
||||
ErrorLog("[edit_pacakges.php] No Id to move down!");
|
||||
MessageError(LangSpell('SentenceUnknownError'));
|
||||
}
|
||||
}
|
||||
|
||||
$ToDo="";
|
||||
}
|
||||
|
||||
/////////////////
|
||||
// delete package
|
||||
if ($ToDo=="DeletePackage")
|
||||
{
|
||||
if (isset($_GET['Id']) && $_GET['Id'])
|
||||
{
|
||||
$Id = $_GET['Id'];
|
||||
if (!LockIsActive('Packages',$Id))
|
||||
{
|
||||
global $GlobalMysqlHandler;
|
||||
$DeleteQuery="DELETE FROM `Packages` WHERE `Id` = $Id LIMIT 1";
|
||||
if (mysqli_query($GlobalMysqlHandler, $DeleteQuery))
|
||||
{
|
||||
MessageSuccess(LangSpell('EditPackagesPackageDeleted'));
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageError(LangSpell('SentenceDatabaseError'));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageError(LangSpell('SentenceLockIsActive'));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ErrorLog("[edit_pacakges.php] No Id to delete package!");
|
||||
MessageError(LangSpell('SentenceUnknownError'));
|
||||
}
|
||||
$ToDo="";
|
||||
}
|
||||
|
||||
////////////////
|
||||
// add new package
|
||||
if ($ToDo=="NewPackage")
|
||||
{
|
||||
if (isset($_GET['ParentId']) && isset($_POST['NewPackageName']))
|
||||
{
|
||||
$ParentId = $_GET['ParentId'];
|
||||
$NewPackageName = $_POST['NewPackageName'];
|
||||
if (LockActivate('Packages',$ParentId))
|
||||
{
|
||||
if (trim($NewPackageName)!="")
|
||||
{
|
||||
global $GlobalMysqlHandler;
|
||||
$InsertQuery="INSERT INTO `Packages` ( `Name` , `ParentId` ) VALUES ( '$NewPackageName', '$ParentId' );";
|
||||
if (mysqli_query($GlobalMysqlHandler, $InsertQuery))
|
||||
{
|
||||
MessageSuccess(LangSpell('EditPackagesNewPackageAdded'));
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageError(LangSpell('SentenceDatabaseError'));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageError(LangSpell('EditPackagesNoPackageNameGiven'));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageError(LangSpell('SentenceLockIsActive'));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!isset($_GET['ParentId']))
|
||||
ErrorLog("[edit_pacakges.php] No ParentId to add new package!");
|
||||
if (!isset($_POST['NewPackageName']))
|
||||
ErrorLog("[edit_pacakges.php] No NewPackageName to add new package!");
|
||||
MessageError(LangSpell('SentenceUnknownError'));
|
||||
}
|
||||
$ToDo="";
|
||||
}
|
||||
|
||||
///////////////
|
||||
// edit package
|
||||
if ($ToDo=="EditPackage")
|
||||
{
|
||||
if (isset($_GET['Id']) && $_GET['Id'])
|
||||
{
|
||||
$EditId = $_GET['Id'];
|
||||
if (LockActivate('Packages',$EditId))
|
||||
{
|
||||
$EditPackagesEditId=$EditId;
|
||||
//NestedListVisibilityUnset($EditId, 'EditPackages');
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageError(LangSpell('SentenceLockIsActive'));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ErrorLog("[edit_pacakges.php] No Id to edit package");
|
||||
MessageError(LangSpell('SentenceUnknownError'));
|
||||
}
|
||||
$ToDo = "";
|
||||
}
|
||||
|
||||
//////////////////////
|
||||
// cancel edit package
|
||||
if ($ToDo=="CancelEditPackage")
|
||||
{
|
||||
if (isset($_GET['Id']) && $_GET['Id'])
|
||||
{
|
||||
$EditId = $_GET['Id'];
|
||||
if (LockRelease('Packages',$EditId))
|
||||
{
|
||||
$EditPackagesEditId=0;
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageError(LangSpell('SentenceLockIsActive'));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ErrorLog("[edit_pacakges.php] No Id to release loack on package");
|
||||
MessageError(LangSpell('SentenceUnknownError'));
|
||||
}
|
||||
$ToDo = "";
|
||||
}
|
||||
}
|
||||
|
||||
if (UserHasRight('EditPackages') || UserHasRight('ViewSTPV'))
|
||||
{
|
||||
///////////////
|
||||
// open sublist
|
||||
if ($ToDo=="OpenSublist")
|
||||
{
|
||||
if (isset($_GET['SublistId']) && $_GET['SublistId'])
|
||||
{
|
||||
NestedListVisibilityToggle($_GET['SublistId'], 'EditPackages');
|
||||
}
|
||||
else
|
||||
{
|
||||
ErrorLog("[edit_pacakges.php] No SublistId to open package!");
|
||||
MessageError(LangSpell('SentenceUnknownError'));
|
||||
}
|
||||
$ToDo="";
|
||||
}
|
||||
|
||||
///////////////
|
||||
// sow packages
|
||||
if ($ToDo=="")
|
||||
WritePackagesList(0,0);
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageError(LangSpell("ScentenceNoUserRights"));
|
||||
}
|
||||
?>
|
||||
299
pages/edit_stores.php
Executable file
299
pages/edit_stores.php
Executable file
|
|
@ -0,0 +1,299 @@
|
|||
<?php
|
||||
|
||||
$EditStoresEditId=0;
|
||||
|
||||
function WriteStoreList($ParentId, $ParentIsLocked)
|
||||
{
|
||||
global $GlobalMysqlHandler;
|
||||
global $GlobalContent;
|
||||
global $GlobalTemplate;
|
||||
global $EditStoresEditId;
|
||||
|
||||
$ListQuery="SELECT `Id` , `Name` FROM `Storages` WHERE `ParentId` =$ParentId";
|
||||
$ListQuery=mysqli_query($GlobalMysqlHandler, $ListQuery);
|
||||
|
||||
if (!$ParentId || NestedListVisibilityIsSet($ParentId, 'EditStorage'))
|
||||
$GlobalContent .= "<ul style=\"display:block;\">\n";
|
||||
else
|
||||
$GlobalContent .= "<ul style=\"display:none;\">\n";
|
||||
|
||||
if (mysqli_num_rows($ListQuery))
|
||||
{
|
||||
while ($ListData=mysqli_fetch_array($ListQuery))
|
||||
{
|
||||
if ($EditStoresEditId
|
||||
&& ($EditStoresEditId==$ListData['Id'])
|
||||
&& !( LockIsActive('Storages',$ListData['Id']) || $ParentIsLocked)
|
||||
)
|
||||
{ //edit entry
|
||||
$GlobalContent .= " <li>\n";
|
||||
$GlobalContent .= ' <a href="index.php?Page=EditStores&ToDo=DeleteStore&Id='.$ListData['Id'].'" title="'.LangSpellHtml('TagTitleDelete').'">'.OtherGetIcon('Delete',"Button").'</a>';
|
||||
$GlobalContent .= ' <form action="index.php?Page=EditStores&ToDo=EditStoreSave" method="post">';
|
||||
$GlobalContent .= ' <input type="hidden" name="Id" value="'.$ListData['Id'].'">';
|
||||
$GlobalContent .= '<input type="text" name="Name" value="'.$ListData['Name'].'">';
|
||||
$GlobalContent .= '<select name="MoveToId" title="'.LangSpellHtml('TagTitleMove').'">';
|
||||
if ($ParentId)
|
||||
$GlobalContent .= '<option value="#MOVE#ITEM#UP#">'.LangSpellHtml('TagTitleMoveUp').'</option>';
|
||||
$GlobalContent .= '<option value="" selected>--- '.LangSpellHtml('TagTitleMove').' ---</option>';
|
||||
$MoveItems = NestedLisGetSubelements($ParentId,"Storages");
|
||||
foreach ($MoveItems as $MvItm)
|
||||
{
|
||||
if ($MvItm[0]==$ListData['Id']) continue;
|
||||
$GlobalContent .= '<option value="'.$MvItm[0].'">'.$MvItm[1].'</option>';
|
||||
}
|
||||
$GlobalContent .= "</select>";
|
||||
$GlobalContent .= '<input type="submit" value="'.LangSpellHtml('ButtonSave').'" class="Button">';
|
||||
$GlobalContent .= ' </form>';
|
||||
$GlobalContent .= ' <a href="index.php?Page=EditStores&ToDo=CancelEditStore&Id='.$ListData['Id'].'" title="'.LangSpellHtml('TagTitleCancel').'">'.OtherGetIcon('Cancel',"Button").'</a>' ."\n";
|
||||
$GlobalContent .= " </li>\n";
|
||||
}
|
||||
else
|
||||
{ //just show entry
|
||||
$GlobalContent .= " <li>\n";
|
||||
if (LockIsActive('Storages',$ListData['Id']) || $ParentIsLocked)
|
||||
{
|
||||
$GlobalContent .= ' '.OtherGetIcon('LockActive');
|
||||
$ParentIsLocked = 1;
|
||||
}
|
||||
elseif (UserHasRight('EditStores'))
|
||||
{
|
||||
$GlobalContent .= ' <a href="index.php?Page=EditStores&ToDo=EditStore&Id='.$ListData['Id'].'" target="_top" title="'.LangSpellHtml('TagTitleEdit').'">';
|
||||
$GlobalContent .= OtherGetIcon('Edit',"Button");
|
||||
}
|
||||
$GlobalContent .= " <a href=\"index.php?Page=EditStores&ToDo=OpenSublist&SublistId=".$ListData['Id']."\">".LangStr2Html($ListData['Name'])."</a>";
|
||||
$GlobalContent .= " (".NestedListCountSubElements($ListData['Id'],'Storages').")";
|
||||
$GlobalContent .= " \n</li>\n";
|
||||
}
|
||||
|
||||
WriteStoreList($ListData['Id'],$ParentIsLocked);
|
||||
}
|
||||
}
|
||||
if (!$EditStoresEditId && UserHasRight('EditStores'))
|
||||
{
|
||||
$GlobalContent .= " <li>\n";
|
||||
$GlobalContent .= ' <form action="index.php?Page=EditStores&ToDo=NewStore&ParentId='.$ParentId.'" method="post">'."\n";
|
||||
$GlobalContent .= ' <input type="text" name="NewStoreName" value="">'."\n";
|
||||
$GlobalContent .= ' <input type="submit" value="'.LangSpellHtml('ButtonNew').'" class="Button">'."\n";
|
||||
$GlobalContent .= ' </form>'."\n";
|
||||
$GlobalContent .= " </li>\n";
|
||||
}
|
||||
$GlobalContent .= "</ul>\n";
|
||||
}
|
||||
|
||||
if (UserHasRight('EditStores'))
|
||||
{
|
||||
/////////////////
|
||||
//edit store save
|
||||
if ($ToDo=="EditStoreSave")
|
||||
{
|
||||
if (isset($_POST['Id']) && $_POST['Id'] && isset($_POST['Name']) && $_POST['Name'])
|
||||
{
|
||||
global $GlobalMysqlHandler;
|
||||
$Id = $_POST['Id'];
|
||||
$Name = $_POST['Name'];
|
||||
$MoveId = (isset($_POST['MoveToId']))? $_POST['MoveToId']:0;
|
||||
|
||||
if ($MoveId)
|
||||
{
|
||||
$MoveQuery = "";
|
||||
if ($MoveId=="#MOVE#ITEM#UP#")
|
||||
{
|
||||
$FirstParentId = NestedListGetParentId($Id,'Storages');
|
||||
$MoveId = NestedListGetParentId($FirstParentId,'Storages');
|
||||
}
|
||||
else
|
||||
{
|
||||
$FirstParentId = NestedListGetParentId($Id,'Storages');
|
||||
}
|
||||
|
||||
$MoveQuery="UPDATE `Storages` SET `ParentId` = '$MoveId' WHERE `Id` =$Id LIMIT 1 ;";
|
||||
|
||||
if (mysqli_query($GlobalMysqlHandler, $MoveQuery))
|
||||
{
|
||||
MessageSuccess(LangSpell('SentenceNestedListMoved'));
|
||||
NestedListVisibilityUnset($FirstParentId,'EditStorage');
|
||||
NestedListVisibilitySet($MoveId,'EditStorage');
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageError(LangSpell('SentenceDatabaseError'));
|
||||
ErrorLog("[edit_stored.php] Db error on moving element with id $Id to parent id $MoveId");
|
||||
}
|
||||
}
|
||||
|
||||
$ChangeNameQuery="UPDATE `Storages` SET `Name` = '$Name' WHERE `Id` =$Id LIMIT 1 ;";
|
||||
if (!mysqli_query($GlobalMysqlHandler, $ChangeNameQuery))
|
||||
{
|
||||
MessageError(LangSpell('SentenceDatabaseError'));
|
||||
ErrorLog("[edit_stored.php] Db error on naming element with id $Id");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (isset($_POST['Name']) && !trim($_POST['Name']))
|
||||
MessageError(LangSpell('EditStoresNoStoreNameGiven'));
|
||||
else
|
||||
{
|
||||
ErrorLog("[edit_stores.php] No Id to move!");
|
||||
MessageError(LangSpell('SentenceUnknownError'));
|
||||
}
|
||||
}
|
||||
|
||||
$ToDo="";
|
||||
}
|
||||
|
||||
///////////////
|
||||
// delete store
|
||||
if ($ToDo=="DeleteStore")
|
||||
{
|
||||
if (isset($_GET['Id']) && $_GET['Id'])
|
||||
{
|
||||
$Id = $_GET['Id'];
|
||||
if (!LockIsActive('Storages',$Id))
|
||||
{
|
||||
global $GlobalMysqlHandler;
|
||||
$DeleteQuery="DELETE FROM `Storages` WHERE `Id` = $Id LIMIT 1";
|
||||
if (mysqli_query($GlobalMysqlHandler, $DeleteQuery))
|
||||
{
|
||||
MessageSuccess(LangSpell('EditStoresStoreDeleted'));
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageError(LangSpell('SentenceDatabaseError'));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageError(LangSpell('SentenceLockIsActive'));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ErrorLog("[edit_stores.php] No Id to delete store!");
|
||||
MessageError(LangSpell('SentenceUnknownError'));
|
||||
}
|
||||
$ToDo="";
|
||||
}
|
||||
|
||||
////////////////
|
||||
// add new store
|
||||
if ($ToDo=="NewStore")
|
||||
{
|
||||
if (isset($_GET['ParentId']) && isset($_POST['NewStoreName']))
|
||||
{
|
||||
$ParentId = $_GET['ParentId'];
|
||||
$NewStoreName = $_POST['NewStoreName'];
|
||||
if (LockActivate('Storages',$ParentId))
|
||||
{
|
||||
if (trim($NewStoreName)!="")
|
||||
{
|
||||
global $GlobalMysqlHandler;
|
||||
$InsertQuery="INSERT INTO `Storages` ( `Name` , `ParentId` ) VALUES ( '$NewStoreName', '$ParentId' );";
|
||||
if (mysqli_query($GlobalMysqlHandler, $InsertQuery))
|
||||
{
|
||||
MessageSuccess(LangSpell('EditStoresNewStoreAdded'));
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageError(LangSpell('SentenceDatabaseError'));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageError(LangSpell('EditStoresNoStoreNameGiven'));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageError(LangSpell('SentenceLockIsActive'));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!isset($_GET['ParentId']))
|
||||
ErrorLog("[edit_stores.php] No ParentId to add new store!");
|
||||
if (!isset($_POST['NewStoreName']))
|
||||
ErrorLog("[edit_stores.php] No NewStoreName to add new store!");
|
||||
MessageError(LangSpell('SentenceUnknownError'));
|
||||
}
|
||||
$ToDo="";
|
||||
}
|
||||
|
||||
/////////////
|
||||
// edit store
|
||||
if ($ToDo=="EditStore")
|
||||
{
|
||||
if (isset($_GET['Id']) && $_GET['Id'])
|
||||
{
|
||||
$EditId = $_GET['Id'];
|
||||
if (LockActivate('Storages',$EditId))
|
||||
{
|
||||
$EditStoresEditId=$EditId;
|
||||
//NestedListVisibilityUnset($EditId, 'EditStorage');
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageError(LangSpell('SentenceLockIsActive'));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ErrorLog("[edit_stores.php] No Id to edit store");
|
||||
MessageError(LangSpell('SentenceUnknownError'));
|
||||
}
|
||||
$ToDo = "";
|
||||
}
|
||||
|
||||
////////////////////
|
||||
// cancel edit store
|
||||
if ($ToDo=="CancelEditStore")
|
||||
{
|
||||
if (isset($_GET['Id']) && $_GET['Id'])
|
||||
{
|
||||
$EditId = $_GET['Id'];
|
||||
if (LockRelease('Storages',$EditId))
|
||||
{
|
||||
$EditStoresEditId=0;
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageError(LangSpell('SentenceLockIsActive'));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ErrorLog("[edit_stores.php] No Id to release loack on storage");
|
||||
MessageError(LangSpell('SentenceUnknownError'));
|
||||
}
|
||||
$ToDo = "";
|
||||
}
|
||||
}
|
||||
|
||||
if (UserHasRight('EditStores') || UserHasRight('ViewSTPV'))
|
||||
{
|
||||
///////////////
|
||||
// open sublist
|
||||
if ($ToDo=="OpenSublist")
|
||||
{
|
||||
if (isset($_GET['SublistId']) && $_GET['SublistId'])
|
||||
{
|
||||
NestedListVisibilityToggle($_GET['SublistId'], 'EditStorage');
|
||||
}
|
||||
else
|
||||
{
|
||||
ErrorLog("[edit_stores.php] No SublistId to open store!");
|
||||
MessageError(LangSpell('SentenceUnknownError'));
|
||||
}
|
||||
$ToDo="";
|
||||
}
|
||||
|
||||
///////////////
|
||||
// sow stores
|
||||
if ($ToDo=="")
|
||||
WriteStoreList(0,0);
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageError(LangSpell("ScentenceNoUserRights"));
|
||||
}
|
||||
?>
|
||||
310
pages/edit_types.php
Executable file
310
pages/edit_types.php
Executable file
|
|
@ -0,0 +1,310 @@
|
|||
<?php
|
||||
|
||||
$EditTypesEditId=0;
|
||||
|
||||
function WriteTypeList($ParentId, $ParentIsLocked)
|
||||
{
|
||||
global $GlobalMysqlHandler;
|
||||
global $GlobalContent;
|
||||
global $GlobalTemplate;
|
||||
global $EditTypesEditId;
|
||||
|
||||
$ListQuery="SELECT * FROM `Types` WHERE `ParentId` =$ParentId";
|
||||
$ListQuery=mysqli_query($GlobalMysqlHandler, $ListQuery);
|
||||
|
||||
if (!$ParentId || NestedListVisibilityIsSet($ParentId, 'EditTypes'))
|
||||
$GlobalContent .= "<ul style=\"display:block;\">\n";
|
||||
else
|
||||
$GlobalContent .= "<ul style=\"display:none;\">\n";
|
||||
|
||||
if (mysqli_num_rows($ListQuery))
|
||||
{
|
||||
while ($ListData=mysqli_fetch_array($ListQuery))
|
||||
{
|
||||
if ($EditTypesEditId
|
||||
&& ($EditTypesEditId==$ListData['Id'])
|
||||
&& !( LockIsActive('Types',$ListData['Id']) || $ParentIsLocked)
|
||||
)
|
||||
{ //edit entry
|
||||
$GlobalContent .= " <li>\n";
|
||||
$GlobalContent .= ' <a href="index.php?Page=EditTypes&ToDo=DeleteType&Id='.$ListData['Id'].'" title="'.LangSpellHtml('TagTitleDelete').'">'.OtherGetIcon('Delete',"Button").'</a>';
|
||||
$GlobalContent .= ' <form action="index.php?Page=EditTypes&ToDo=EditTypeSave" method="post">';
|
||||
$GlobalContent .= ' <input type="hidden" name="Id" value="'.$ListData['Id'].'">';
|
||||
$GlobalContent .= LangSpellHtml('EditTypesName').':<input type="text" name="Name" value="'.$ListData['Name'].'"> ';
|
||||
$GlobalContent .= LangSpellHtml('EditTypesShortName').':<input type="text" name="ShortName" value="'.$ListData['ShortName'].'">';
|
||||
$GlobalContent .= '<select name="MoveToId" title="'.LangSpellHtml('TagTitleMove').'">';
|
||||
if ($ParentId)
|
||||
$GlobalContent .= '<option value="#MOVE#ITEM#UP#">'.LangSpellHtml('TagTitleMoveUp').'</option>';
|
||||
$GlobalContent .= '<option value="" selected>--- '.LangSpellHtml('TagTitleMove').' ---</option>';
|
||||
$MoveItems = NestedLisGetSubelements($ParentId,"Types");
|
||||
foreach ($MoveItems as $MvItm)
|
||||
{
|
||||
if ($MvItm[0]==$ListData['Id']) continue;
|
||||
$GlobalContent .= '<option value="'.$MvItm[0].'">'.$MvItm[1].'</option>';
|
||||
}
|
||||
$GlobalContent .= "</select>";
|
||||
$GlobalContent .= '<input type="submit" value="'.LangSpellHtml('ButtonSave').'" class="Button">';
|
||||
$GlobalContent .= ' <a href="index.php?Page=EditTypes&ToDo=CancelEditType&Id='.$ListData['Id'].'" title="'.LangSpellHtml('TagTitleCancel').'">'.OtherGetIcon('Cancel',"Button").'</a><br>' ."\n";
|
||||
$GlobalContent .= LangSpellHtml('EditTypesNameValue1').':<input type="text" name="NameValue1" value="'.$ListData['NameValue1'].'"> ';
|
||||
$GlobalContent .= LangSpellHtml('EditTypesNameValue2').':<input type="text" name="NameValue2" value="'.$ListData['NameValue2'].'"> ';
|
||||
$GlobalContent .= LangSpellHtml('EditTypesNameValue3').':<input type="text" name="NameValue3" value="'.$ListData['NameValue3'].'"><br>';
|
||||
$GlobalContent .= LangSpellHtml('EditTypesUnitValue1').':<input type="text" name="UnitValue1" value="'.$ListData['UnitValue1'].'"> ';
|
||||
$GlobalContent .= LangSpellHtml('EditTypesUnitValue2').':<input type="text" name="UnitValue2" value="'.$ListData['UnitValue2'].'"> ';
|
||||
$GlobalContent .= LangSpellHtml('EditTypesUnitValue3').':<input type="text" name="UnitValue3" value="'.$ListData['UnitValue3'].'"><br>';
|
||||
$GlobalContent .= ' </form>';
|
||||
$GlobalContent .= " </li>\n";
|
||||
}
|
||||
else
|
||||
{ //just show entry
|
||||
$GlobalContent .= " <li>\n";
|
||||
if (LockIsActive('Types',$ListData['Id']) || $ParentIsLocked)
|
||||
{
|
||||
$GlobalContent .= ' '.OtherGetIcon('LockActive');
|
||||
$ParentIsLocked = 1;
|
||||
}
|
||||
elseif (UserHasRight('EditTypes'))
|
||||
{
|
||||
$GlobalContent .= ' <a href="index.php?Page=EditTypes&ToDo=EditType&Id='.$ListData['Id'].'" target="_top" title="'.LangSpellHtml('TagTitleEdit').'">';
|
||||
$GlobalContent .= OtherGetIcon('Edit',"Button");
|
||||
}
|
||||
$GlobalContent .= " <a href=\"index.php?Page=EditTypes&ToDo=OpenSublist&SublistId=".$ListData['Id']."\">".LangStr2Html($ListData['Name'])."</a>";
|
||||
$GlobalContent .= " (".NestedListCountSubElements($ListData['Id'],'Types').")";
|
||||
$GlobalContent .= " \n</li>\n";
|
||||
}
|
||||
|
||||
WriteTypeList($ListData['Id'],$ParentIsLocked);
|
||||
}
|
||||
}
|
||||
if (!$EditTypesEditId && UserHasRight('EditTypes'))
|
||||
{
|
||||
$GlobalContent .= " <li>\n";
|
||||
$GlobalContent .= ' <form action="index.php?Page=EditTypes&ToDo=NewType&ParentId='.$ParentId.'" method="post">'."\n";
|
||||
$GlobalContent .= ' <input type="text" name="NewTypeName" value="">'."\n";
|
||||
$GlobalContent .= ' <input type="submit" value="'.LangSpellHtml('ButtonNew').'" class="Button">'."\n";
|
||||
$GlobalContent .= ' </form>'."\n";
|
||||
$GlobalContent .= " </li>\n";
|
||||
}
|
||||
$GlobalContent .= "</ul>\n";
|
||||
}
|
||||
|
||||
if (UserHasRight('EditTypes'))
|
||||
{
|
||||
/////////////////
|
||||
//edit type save
|
||||
if ($ToDo=="EditTypeSave")
|
||||
{
|
||||
if (isset($_POST['Id']) && $_POST['Id'] && isset($_POST['Name']) && $_POST['Name']
|
||||
&& isset($_POST['ShortName'])
|
||||
&& isset($_POST['NameValue1']) && isset($_POST['NameValue2']) && isset($_POST['NameValue3'])
|
||||
&& isset($_POST['UnitValue1']) && isset($_POST['UnitValue2']) && isset($_POST['UnitValue3'])
|
||||
)
|
||||
{
|
||||
global $GlobalMysqlHandler;
|
||||
$Id = $_POST['Id'];
|
||||
$Name = $_POST['Name'];
|
||||
$MoveId = (isset($_POST['MoveToId']))? $_POST['MoveToId']:0;
|
||||
|
||||
if ($MoveId)
|
||||
{
|
||||
$MoveQuery = "";
|
||||
if ($MoveId=="#MOVE#ITEM#UP#")
|
||||
{
|
||||
$FirstParentId = NestedListGetParentId($Id,'Types');
|
||||
$MoveId = NestedListGetParentId($FirstParentId,'Types');
|
||||
}
|
||||
else
|
||||
{
|
||||
$FirstParentId = NestedListGetParentId($Id,'Types');
|
||||
}
|
||||
|
||||
$MoveQuery="UPDATE `Types` SET `ParentId` = '$MoveId' WHERE `Id` =$Id LIMIT 1 ;";
|
||||
|
||||
if (mysqli_query($GlobalMysqlHandler, $MoveQuery))
|
||||
{
|
||||
MessageSuccess(LangSpell('SentenceNestedListMoved'));
|
||||
NestedListVisibilityUnset($FirstParentId,'EditTypes');
|
||||
NestedListVisibilitySet($MoveId,'EditTypes');
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageError(LangSpell('SentenceDatabaseError'));
|
||||
ErrorLog("[edit_types.php] Db error on moving element with id $Id to parent id $MoveId");
|
||||
}
|
||||
}
|
||||
|
||||
//$ChangeItemQuery="UPDATE `Types` SET `Name` = '$Name' WHERE `Id` =$Id LIMIT 1 ;";
|
||||
$ChangeItemQuery="UPDATE `Types` SET `Name` = '$Name', `ShortName` = '".$_POST['ShortName']."', `NameValue1` = '".$_POST['NameValue1']."', `NameValue2` = '".$_POST['NameValue2']."', `NameValue3` = '".$_POST['NameValue3']."', `UnitValue1` = '".$_POST['UnitValue1']."', `UnitValue2` = '".$_POST['UnitValue2']."', `UnitValue3` = '".$_POST['UnitValue3']."' WHERE `Id` =$Id LIMIT 1 ;";
|
||||
if (!mysqli_query($GlobalMysqlHandler, $ChangeItemQuery))
|
||||
{
|
||||
MessageError(LangSpell('SentenceDatabaseError'));
|
||||
ErrorLog("[edit_types.php] Db error on updating element with id $Id");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (isset($_POST['Name']) && !trim($_POST['Name']))
|
||||
MessageError(LangSpell('EditTypesNoTypeNameGiven'));
|
||||
else
|
||||
{
|
||||
ErrorLog("[edit_types.php] No Id to move down!");
|
||||
MessageError(LangSpell('SentenceUnknownError'));
|
||||
}
|
||||
}
|
||||
$ToDo="";
|
||||
}
|
||||
|
||||
///////////////
|
||||
// delete type
|
||||
if ($ToDo=="DeleteType")
|
||||
{
|
||||
if (isset($_GET['Id']) && $_GET['Id'])
|
||||
{
|
||||
$Id = $_GET['Id'];
|
||||
if (!LockIsActive('Types',$Id))
|
||||
{
|
||||
global $GlobalMysqlHandler;
|
||||
$DeleteQuery="DELETE FROM `Types` WHERE `Id` = $Id LIMIT 1";
|
||||
if (mysqli_query($GlobalMysqlHandler, $DeleteQuery))
|
||||
{
|
||||
MessageSuccess(LangSpell('EditTypesTypeDeleted'));
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageError(LangSpell('SentenceDatabaseError'));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageError(LangSpell('SentenceLockIsActive'));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ErrorLog("[edit_types.php] No Id to delete type!");
|
||||
MessageError(LangSpell('SentenceUnknownError'));
|
||||
}
|
||||
$ToDo="";
|
||||
}
|
||||
|
||||
////////////////
|
||||
// add new type
|
||||
if ($ToDo=="NewType")
|
||||
{
|
||||
if (isset($_GET['ParentId']) && isset($_POST['NewTypeName']))
|
||||
{
|
||||
$ParentId = $_GET['ParentId'];
|
||||
$NewTypeName = $_POST['NewTypeName'];
|
||||
if (LockActivate('Types',$ParentId))
|
||||
{
|
||||
if (trim($NewTypeName)!="")
|
||||
{
|
||||
global $GlobalMysqlHandler;
|
||||
$InsertQuery="INSERT INTO `Types` ( `Name` , `ParentId` ) VALUES ( '$NewTypeName', '$ParentId' );";
|
||||
if (mysqli_query($GlobalMysqlHandler, $InsertQuery))
|
||||
{
|
||||
MessageSuccess(LangSpell('EditTypesNewTypeAdded'));
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageError(LangSpell('SentenceDatabaseError'));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageError(LangSpell('EditTypesNoTypeNameGiven'));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageError(LangSpell('SentenceLockIsActive'));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!isset($_GET['ParentId']))
|
||||
ErrorLog("[edit_types.php] No ParentId to add new type!");
|
||||
if (!isset($_POST['NewTypeName']))
|
||||
ErrorLog("[edit_types.php] No NewTypeName to add new type!");
|
||||
MessageError(LangSpell('SentenceUnknownError'));
|
||||
}
|
||||
$ToDo="";
|
||||
}
|
||||
|
||||
/////////////
|
||||
// edit type
|
||||
if ($ToDo=="EditType")
|
||||
{
|
||||
if (isset($_GET['Id']) && $_GET['Id'])
|
||||
{
|
||||
$EditId = $_GET['Id'];
|
||||
if (LockActivate('Types',$EditId))
|
||||
{
|
||||
$EditTypesEditId=$EditId;
|
||||
//NestedListVisibilityUnset($EditId, 'EditTypes');
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageError(LangSpell('SentenceLockIsActive'));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ErrorLog("[edit_types.php] No Id to edit type.");
|
||||
MessageError(LangSpell('SentenceUnknownError'));
|
||||
}
|
||||
$ToDo = "";
|
||||
}
|
||||
|
||||
////////////////////
|
||||
// cancel edit type
|
||||
if ($ToDo=="CancelEditType")
|
||||
{
|
||||
if (isset($_GET['Id']) && $_GET['Id'])
|
||||
{
|
||||
$EditId = $_GET['Id'];
|
||||
if (LockRelease('Types',$EditId))
|
||||
{
|
||||
$EditTypesEditId=0;
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageError(LangSpell('SentenceLockIsActive'));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ErrorLog("[edit_types.php] No Id to release loack on storage");
|
||||
MessageError(LangSpell('SentenceUnknownError'));
|
||||
}
|
||||
$ToDo = "";
|
||||
}
|
||||
}
|
||||
|
||||
if (UserHasRight('EditTypes') || UserHasRight('ViewSTPV'))
|
||||
{
|
||||
///////////////
|
||||
// open sublist
|
||||
if ($ToDo=="OpenSublist")
|
||||
{
|
||||
if (isset($_GET['SublistId']) && $_GET['SublistId'])
|
||||
{
|
||||
NestedListVisibilityToggle($_GET['SublistId'], 'EditTypes');
|
||||
}
|
||||
else
|
||||
{
|
||||
ErrorLog("[edit_types.php] No SublistId to open type!");
|
||||
MessageError(LangSpell('SentenceUnknownError'));
|
||||
}
|
||||
$ToDo="";
|
||||
}
|
||||
|
||||
///////////////
|
||||
// sow types
|
||||
if ($ToDo=="")
|
||||
WriteTypeList(0,0);
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageError(LangSpell("ScentenceNoUserRights"));
|
||||
}
|
||||
?>
|
||||
261
pages/edit_users.php
Executable file
261
pages/edit_users.php
Executable file
|
|
@ -0,0 +1,261 @@
|
|||
<?php
|
||||
|
||||
if (UserGetLogin()=="root")
|
||||
{
|
||||
////////////////
|
||||
//Add new user
|
||||
if ($ToDo=="NewUser")
|
||||
{
|
||||
//Get primary vars
|
||||
$Error=0;
|
||||
$Login = (isset($_POST['Login']))? $_POST['Login']:"";
|
||||
$Password = (isset($_POST['Password']))? $_POST['Password']:"";
|
||||
|
||||
//check primary vars
|
||||
$UserExistQuery="SELECT * FROM `User` WHERE `Login` LIKE '$Login'";
|
||||
$UserExistQuery=mysqli_query($GlobalMysqlHandler, $UserExistQuery);
|
||||
if ($Login=="" || $Login=="root" || mysqli_num_rows($UserExistQuery))
|
||||
{
|
||||
$Error=1;
|
||||
MessageError(LangSpell('SentenceLoginForbidden'));
|
||||
}
|
||||
|
||||
if ($Password=="")
|
||||
{
|
||||
$Error=1;
|
||||
MessageError(LangSpell('SentencePasswordForbidden'));
|
||||
}
|
||||
$Password=md5($Password);
|
||||
|
||||
if ($Error==0)
|
||||
{
|
||||
//insert into user table
|
||||
$InsertUserQuery = "INSERT INTO `User` ( `Login` , `Password` ) VALUES ( '$Login', '$Password' );";
|
||||
if (!mysqli_query($GlobalMysqlHandler, $InsertUserQuery))
|
||||
{
|
||||
ErrorLog("[edit_users.php] Database error while insert new user!");
|
||||
MessageError(LangSpell('SentenceDatabaseError'));
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageSuccess(LangSpell('SentenceNewUserAdded'));
|
||||
}
|
||||
|
||||
//get eactual inserted id
|
||||
$UserIdQuery="SELECT `Id` FROM `User` WHERE `Login` = '$Login' AND `Password` = '$Password'";
|
||||
$ActualInsertedUserId = 0;
|
||||
if (! ($UserIdQuery=mysqli_query($GlobalMysqlHandler, $UserIdQuery)) )
|
||||
ErrorLog("[edit_users.php] Database error while getting id from inserted user!");
|
||||
else
|
||||
{
|
||||
$ActualInsertedUserIdRecord=mysqli_fetch_array($UserIdQuery);
|
||||
$ActualInsertedUserId = $ActualInsertedUserIdRecord['Id'];
|
||||
|
||||
//insert user rights table
|
||||
|
||||
//generate rights query
|
||||
$RightsQuery="SELECT * FROM `UserRights` LIMIT 1";
|
||||
$RightsQuery=mysqli_query($GlobalMysqlHandler, $RightsQuery);
|
||||
$InsertRightValues = array();
|
||||
for ($i=1;$i<(mysqli_num_fields($RightsQuery));$i++)
|
||||
{
|
||||
if (isset($_POST[mysqli_field_name($RightsQuery,$i)]))
|
||||
{
|
||||
$x=count($InsertRightValues);
|
||||
$InsertRightValues[$x][0]=mysqli_field_name($RightsQuery,$i);
|
||||
$InsertRightValues[$x][1]=(strtoupper($_POST[mysqli_field_name($RightsQuery,$i)])=="TRUE")? "True":"False";
|
||||
}
|
||||
}
|
||||
|
||||
$InsertRightsQuery1 = "INSERT INTO `UserRights` ( `Id` ";
|
||||
$InsertRightsQuery2 = " ) VALUES ( '$ActualInsertedUserId' ";
|
||||
$InsertRightsQuery3 = " );";
|
||||
|
||||
for ($i=0;$i<count($InsertRightValues);$i++)
|
||||
{
|
||||
$InsertRightsQuery1 .= ", `".$InsertRightValues[$i][0]."` ";
|
||||
$InsertRightsQuery2 .= ", '".$InsertRightValues[$i][1]."'";
|
||||
}
|
||||
$InsertRightsQuery = $InsertRightsQuery1 . $InsertRightsQuery2 . $InsertRightsQuery3;
|
||||
|
||||
if (!mysqli_query($GlobalMysqlHandler, $InsertRightsQuery))
|
||||
{
|
||||
ErrorLog("[edit_users.php] Database error while insert new users rights (Id $ActualInsertedUserId)!");
|
||||
MessageError(LangSpell('SentenceDatabaseError'));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/////////////
|
||||
//Edit User
|
||||
if ($ToDo=="EditUser")
|
||||
{
|
||||
$Error=0;
|
||||
$Id = (isset($_POST['Id']))? $_POST['Id']:"";
|
||||
$Login = (isset($_POST['Login']))? $_POST['Login']:"";
|
||||
$Password = (isset($_POST['Password']))? $_POST['Password']:"";
|
||||
|
||||
$UserExistQuery="SELECT * FROM `User` WHERE `Login` LIKE '$Login' AND `Id` != '$Id'";
|
||||
$UserExistQuery=mysqli_query($GlobalMysqlHandler, $UserExistQuery);
|
||||
if ($Login=="" || $Login=="root" || mysqli_num_rows($UserExistQuery))
|
||||
{
|
||||
$Error=1;
|
||||
MessageError(LangSpell('SentenceLoginForbidden'));
|
||||
}
|
||||
|
||||
//check if user rights are existent, insert a record to UserRights if not
|
||||
$CheckRightsExistentQuery="SELECT * FROM `UserRights` WHERE `Id` =$Id";
|
||||
$CheckRightsExistentQuery=mysqli_query($GlobalMysqlHandler, $CheckRightsExistentQuery);
|
||||
if (!mysqli_num_rows($CheckRightsExistentQuery))
|
||||
{
|
||||
ErrorLog("[edit_users.php-EditUser] No record with Id=$Id in UserRights table!");
|
||||
$CheckRightsExistentQuery="INSERT INTO `ldtPartStock`.`UserRights` ( `Id` ) VALUES ( '$Id' );";
|
||||
if (!mysqli_query($GlobalMysqlHandler, $CheckRightsExistentQuery))
|
||||
ErrorLog("[edit_users.php-EditUser] Could not insert record with Id=$Id in UserRights table!");
|
||||
}
|
||||
|
||||
if ($Error==0)
|
||||
{
|
||||
//generate rights array var
|
||||
$UpdateRightValues = array();
|
||||
$RightsQuery="SELECT * FROM `UserRights` LIMIT 1";
|
||||
$RightsQuery=mysqli_query($GlobalMysqlHandler, $RightsQuery);
|
||||
for ($i=1;$i<(mysqli_num_fields($RightsQuery));$i++)
|
||||
{
|
||||
$x=count($UpdateRightValues);
|
||||
$UpdateRightValues[$x][0]=mysqli_field_name($RightsQuery,$i);
|
||||
$UpdateRightValues[$x][1]=( (isset($_POST[mysqli_field_name($RightsQuery,$i)]))
|
||||
&& (strtoupper($_POST[mysqli_field_name($RightsQuery,$i)])=="TRUE")
|
||||
)? "True":"False";
|
||||
}
|
||||
|
||||
//generate user query
|
||||
$UpdateUserQuery = "UPDATE `User` SET `Login` = '$Login'";
|
||||
if ($Password!="")
|
||||
$UpdateUserQuery .= ", `Password` = '".md5($Password)."'";
|
||||
$UpdateUserQuery .= " WHERE `Id` = '$Id' LIMIT 1;";
|
||||
|
||||
//generate user rights query
|
||||
$UpdateRightsQuery = "UPDATE `UserRights` SET ";
|
||||
for ($i=0;$i<count($UpdateRightValues);$i++)
|
||||
{
|
||||
$UpdateRightsQuery .= "`".$UpdateRightValues[$i][0]."` = '".$UpdateRightValues[$i][1]."'" . (($i<(count($UpdateRightValues)-1)) ? ", ":"");
|
||||
}
|
||||
$UpdateRightsQuery .= " WHERE `Id` = '$Id' LIMIT 1;";
|
||||
|
||||
$Error=0;
|
||||
|
||||
//update user table
|
||||
if (!mysqli_query($GlobalMysqlHandler, $UpdateUserQuery))
|
||||
{
|
||||
ErrorLog("[edit_users.php] Database error while update User table at Id = $Id!");
|
||||
MessageError(LangSpell('SentenceDatabaseError'));
|
||||
$Error=1;
|
||||
}
|
||||
|
||||
//update user rights table
|
||||
if (!mysqli_query($GlobalMysqlHandler, $UpdateRightsQuery))
|
||||
{
|
||||
ErrorLog("[edit_users.php] Database error while update UserRights table at Id = $Id!");
|
||||
MessageError(LangSpell('SentenceDatabaseError'));
|
||||
$Error=1;
|
||||
}
|
||||
|
||||
if (!$Error)
|
||||
MessageSuccess(LangSpell('SentenceUserUpdated'));
|
||||
}
|
||||
}
|
||||
|
||||
///////////////
|
||||
//Delete User
|
||||
if ($ToDo=="DeleteUser" && isset($_GET['Id']))
|
||||
{
|
||||
//generate querys
|
||||
$DeleteQuery1="DELETE FROM `User` WHERE `Id` = ".$_GET['Id'];
|
||||
$DeleteQuery2="DELETE FROM `UserRights` WHERE `Id` = ".$_GET['Id'];
|
||||
|
||||
//update DB
|
||||
if (!mysqli_query($GlobalMysqlHandler, $DeleteQuery1))
|
||||
{
|
||||
ErrorLog("[edit_users.php] Database error while delete user with Id=\"".$_GET['Id']."\" from User table!");
|
||||
MessageError(LangSpell('SentenceDatabaseError'));
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageSuccess(LangSpell('SentenceUserDeleted'));
|
||||
}
|
||||
|
||||
if (!mysqli_query($GlobalMysqlHandler, $DeleteQuery2))
|
||||
{
|
||||
ErrorLog("[edit_users.php] Database error while delete user with Id=\"".$_GET['Id']."\" from UserRihts table!");
|
||||
MessageError(LangSpell('SentenceDatabaseError'));
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////
|
||||
//Global content
|
||||
$UserQuery="SELECT * FROM `User`";
|
||||
$UserQuery=mysqli_query($GlobalMysqlHandler, $UserQuery);
|
||||
$RightsQuery="SELECT * FROM `UserRights` LIMIT 1";
|
||||
$RightsQuery=mysqli_query($GlobalMysqlHandler, $RightsQuery);
|
||||
|
||||
//table and head
|
||||
$GlobalContent.='<table>'."\n";
|
||||
$GlobalContent.=' <tr>'."\n";
|
||||
$GlobalContent.=' <th>Id</th>'."\n";
|
||||
$GlobalContent.=' <th>Login</th>'."\n";
|
||||
$GlobalContent.=' <th>Password</th>'."\n";
|
||||
for ($i=1;$i<mysqli_num_fields($RightsQuery);$i++)
|
||||
{
|
||||
$GlobalContent.=' <th>'.mysqli_field_name($RightsQuery,$i).'</th>'."\n";
|
||||
}
|
||||
$GlobalContent.=' <th> </th>'."\n";
|
||||
$GlobalContent.=' <th> </th>'."\n";
|
||||
$GlobalContent.=' </tr>'."\n";
|
||||
|
||||
//existing users
|
||||
while ($UserRecord=mysqli_fetch_array($UserQuery))
|
||||
{
|
||||
$GlobalContent.=' <tr>'."\n";
|
||||
$GlobalContent.=' <form action="index.php?Page=EditUsers&ToDo=EditUser" method="post">'."\n";
|
||||
$GlobalContent.=' <td><input type="hidden" name="Id" value="'.$UserRecord['Id'].'">'.$UserRecord['Id'].'</td>'."\n";
|
||||
$GlobalContent.=' <td><input type="text" name="Login" value="'.$UserRecord['Login'].'" title="'.LangSpellHtml('TagTitleEditUserLogin').'"></td>'."\n";
|
||||
$GlobalContent.=' <td><input type="password" name="Password" value="" title="'.LangSpellHtml('TagTitleEditUserPassword').'"></td>'."\n";
|
||||
|
||||
$RightsQuery="SELECT * FROM `UserRights` WHERE `Id` = ".$UserRecord['Id']." LIMIT 1";
|
||||
if (!$RightsQuery=mysqli_query($GlobalMysqlHandler, $RightsQuery))
|
||||
ErrorLog('[edit_users.php-$RightsQuery] Database error or user id '.$UserRecord['Id'].' not found in UserRights');
|
||||
$RightsRecord=mysqli_fetch_row($RightsQuery);
|
||||
for ($i=1;$i<(mysqli_num_fields($RightsQuery));$i++)
|
||||
{
|
||||
$GlobalContent.=' <td><input type="checkbox" name="'.mysqli_field_name($RightsQuery,$i).'" value="True" title="'.LangSpellHtml('TagTitleEditUserRight').'" '.((strtoupper($RightsRecord[$i])=="TRUE")? "checked":"").'></td>'."\n";
|
||||
}
|
||||
$GlobalContent.=' <td><input type="Submit" value="'.LangSpellHtml('ButtonSave').'" title="'.LangSpellHtml('ButtonSave').'" class="Button"></td>'."\n";
|
||||
$GlobalContent.=' <td><a href="index.php?Page=EditUsers&ToDo=DeleteUser&Id='.$UserRecord[0].'" title="'.LangSpellHtml('TagTitleDeleteUser').'" target="_top" class="Button">'.OtherGetIcon('Delete',0).'</a></td>'."\n";
|
||||
$GlobalContent.=' </form>'."\n";
|
||||
$GlobalContent.=' </tr>'."\n";
|
||||
}
|
||||
|
||||
//new user entry
|
||||
$GlobalContent.=' <tr>'."\n";
|
||||
$GlobalContent.=' <form action="index.php?Page=EditUsers&ToDo=NewUser" method="post">'."\n";
|
||||
$GlobalContent.=' <td><input type="hidden" name="Id" value="'.$UserRecord['Id'].'">'.$UserRecord[$i].'</td>'."\n";
|
||||
$GlobalContent.=' <td><input type="text" name="Login" value="'.$UserRecord['Login'].'" title="'.LangSpellHtml('TagTitleEditUserLogin').'"></td>'."\n";
|
||||
$GlobalContent.=' <td><input type="password" name="Password" value="" title="'.LangSpellHtml('TagTitleEditUserPassword').'"></td>'."\n";
|
||||
for ($i=1;$i<(mysqli_num_fields($RightsQuery));$i++)
|
||||
{
|
||||
$GlobalContent.=' <td><input type="checkbox" name="'.mysqli_field_name($RightsQuery,$i).'" value="True" title="'.LangSpellHtml('TagTitleEditUserRight').'"></td>'."\n";
|
||||
}
|
||||
$GlobalContent.=' <td><input type="Submit" value="'.LangSpellHtml('ButtonNew').'" class="Button"></td>'."\n";
|
||||
$GlobalContent.=' <td> </td>'."\n";
|
||||
$GlobalContent.=' </form>'."\n";
|
||||
$GlobalContent.=' </tr>'."\n";
|
||||
|
||||
$GlobalContent.='</table>'."\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageError(LangSpell("ScentenceNoUserRights"));
|
||||
}
|
||||
?>
|
||||
199
pages/edit_vendors.php
Executable file
199
pages/edit_vendors.php
Executable file
|
|
@ -0,0 +1,199 @@
|
|||
<?php
|
||||
|
||||
$EditVendorId=0;
|
||||
|
||||
if (UserHasRight('EditVendors'))
|
||||
{
|
||||
////////////////
|
||||
//save changes
|
||||
if ($ToDo=="SaveVendor")
|
||||
{
|
||||
$Id = (isset($_POST['Id']))? $_POST['Id']:"";
|
||||
$Name = (isset($_POST['Name']))? $_POST['Name']:"";
|
||||
$Homepage = (isset($_POST['Homepage']))? $_POST['Homepage']:"";
|
||||
$MinBill = (isset($_POST['MinBill']))? OtherConvertToFloat($_POST['MinBill']):0;
|
||||
$ShippingCost = (isset($_POST['ShippingCost']))? OtherConvertToFloat($_POST['ShippingCost']):0;
|
||||
|
||||
if (LockIsActive('Vendors',$_POST['Id']))
|
||||
{
|
||||
MessageError(LangSpellHtml('SentenceLockIsActive'));
|
||||
}
|
||||
elseif (!$Id)
|
||||
{
|
||||
MessageError(LangSpellHtml('SentenceUnknownError'));
|
||||
}
|
||||
elseif (!$Name)
|
||||
{
|
||||
$Error=1;
|
||||
MessageError(LangSpellHtml('EditVendorsSentenceVendorNameRequired'));
|
||||
}
|
||||
else
|
||||
{
|
||||
$InsertVendorQuery = "UPDATE `Vendors` SET `Name` = '$Name', `Homepage` = '$Homepage', `MinBill` = '$MinBill', `ShippingCost` = '$ShippingCost' WHERE `Id` =$Id LIMIT 1 ;";
|
||||
if (!mysqli_query($GlobalMysqlHandler, $InsertVendorQuery))
|
||||
{
|
||||
ErrorLog("[edit_vendors.php] Database error while save changes vendor!");
|
||||
MessageError(LangSpell('SentenceDatabaseError'));
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageSuccess(LangSpell('EditVendorsSentenceVendorUpated'));
|
||||
}
|
||||
LockRelease('Vendors',$_POST['Id']);
|
||||
}
|
||||
}
|
||||
|
||||
/////////////////
|
||||
//delete vendor
|
||||
if ($ToDo=="DeleteVendor")
|
||||
{
|
||||
global $GlobalMysqlHandler;
|
||||
$Id = (isset($_GET['Id']))? $_GET['Id']:0;
|
||||
$Vendor = (isset($_GET['Name']))? $_GET['Name']:0;
|
||||
if ($Id && !LockIsActive("Vendors",$Id))
|
||||
{
|
||||
if (!mysqli_query($GlobalMysqlHandler, "DELETE FROM `Vendors` WHERE `Id` = $Id LIMIT 1;"))
|
||||
{
|
||||
MessageError(LangSpellHtml('SentenceDatabaseError'));
|
||||
ErrorLog("[edit_vendors.php] Database error while delete vendor!");
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageSuccess(LangSpellHtml('EditVendorsSentenceVendorDeleted'));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageError(LangSpellHtml('SentenceLockIsActive'));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//////////////
|
||||
//new vendor
|
||||
if ($ToDo=="NewVendor")
|
||||
{
|
||||
$Name = (isset($_POST['Name']))? $_POST['Name']:"";
|
||||
$Homepage = (isset($_POST['Homepage']))? $_POST['Homepage']:"";
|
||||
$MinBill = (isset($_POST['MinBill']))? OtherConvertToFloat($_POST['MinBill']):0;
|
||||
$ShippingCost = (isset($_POST['ShippingCost']))? OtherConvertToFloat($_POST['ShippingCost']):0;
|
||||
|
||||
if (!$Name)
|
||||
{
|
||||
$Error=1;
|
||||
MessageError(LangSpellHtml('EditVendorsSentenceVendorNameRequired'));
|
||||
}
|
||||
else
|
||||
{
|
||||
$InsertVendorQuery = "INSERT INTO `Vendors` ( `Name` , `Homepage` , `MinBill` , `ShippingCost` ) VALUES ( '$Name', '$Homepage', '$MinBill', '$ShippingCost' );";
|
||||
if (!mysqli_query($GlobalMysqlHandler, $InsertVendorQuery))
|
||||
{
|
||||
ErrorLog("[edit_vendors.php] Database error while insert new vendor!");
|
||||
MessageError(LangSpell('SentenceDatabaseError'));
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageSuccess(LangSpell('EditVendorsSentenceVendorNewAdded'));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////
|
||||
//cancel editing
|
||||
if ($ToDo=="CancelEditVendor")
|
||||
{
|
||||
$Id = (isset($_GET['Id']))? $_GET['Id']:"";
|
||||
if ($Id) LockRelease("Vendors",$Id);
|
||||
}
|
||||
|
||||
//////////////////
|
||||
//enable editing
|
||||
if (($ToDo=="EditVendor") && isset($_POST['Id']))
|
||||
{
|
||||
if (LockActivate('Vendors',$_POST['Id'])) $EditVendorId=$_POST['Id'];
|
||||
else MessageError(LangSpellHtml('SentenceLockIsActive'));
|
||||
}
|
||||
}
|
||||
|
||||
if(UserHasRight('EditVendors') || UserHasRight('ViewSTPV'))
|
||||
{
|
||||
//////////////////
|
||||
//global content
|
||||
$GlobalContent.='<table>'."\n";
|
||||
|
||||
$GlobalContent.=' <tr>'."\n";
|
||||
$GlobalContent.=' <th>'.LangSpellHtml('EditVendorsId').'</th>'."\n";
|
||||
$GlobalContent.=' <th>'.LangSpellHtml('EditVendorsName').'</th>'."\n";
|
||||
$GlobalContent.=' <th>'.LangSpellHtml('EditVendorsHomepage').'</th>'."\n";
|
||||
$GlobalContent.=' <th>'.LangSpellHtml('EditVendorsMinBill').'</th>'."\n";
|
||||
$GlobalContent.=' <th>'.LangSpellHtml('EditVendorsShippingCost').'</th>'."\n";
|
||||
if (UserHasRight('EditVendors'))
|
||||
$GlobalContent.=' <th colspan="2">'.LangSpellHtml('EditVendorsEdit').'</th>'."\n";
|
||||
$GlobalContent.=' </tr>'."\n";
|
||||
|
||||
$VendorQuery = "SELECT * FROM `Vendors`";
|
||||
$VendorQuery = mysqli_query($GlobalMysqlHandler, $VendorQuery);
|
||||
while ($Vendor=mysqli_fetch_array($VendorQuery))
|
||||
{
|
||||
if ( ($EditVendorId==$Vendor['Id']) )
|
||||
{
|
||||
$GlobalContent.=' <form action="index.php?Page=EditVendors&ToDo=SaveVendor" method="post">'."\n";
|
||||
$GlobalContent.=' <tr>'."\n";
|
||||
$GlobalContent.=' <td><input type="hidden" name="Id" value="'.$Vendor['Id'].'">'.$Vendor['Id'].'</td>'."\n";
|
||||
$GlobalContent.=' <td><input type="text" name="Name" value="'.$Vendor['Name'].'"></td>'."\n";
|
||||
$GlobalContent.=' <td><input type="text" name="Homepage" value="'.$Vendor['Homepage'].'"></td>'."\n";
|
||||
$GlobalContent.=' <td><input type="text" name="MinBill" value="'.$Vendor['MinBill'].'"></td>'."\n";
|
||||
$GlobalContent.=' <td><input type="text" name="ShippingCost" value="'.$Vendor['ShippingCost'].'"></td>'."\n";
|
||||
$GlobalContent.=' <td><a href="index.php?Page=EditVendors&ToDo=CancelEditVendor&Id='.$Vendor['Id'].'" title="'.LangSpellHtml('TagTitleCancel').'" target="_top">'.OtherGetIcon('Cancel',"Button").'</a></td>'."\n";
|
||||
$GlobalContent.=' <td><input type="submit" value="'.LangSpellHtml('ButtonSave').'" class="Button"></td>'."\n";
|
||||
$GlobalContent.=' </tr>'."\n";
|
||||
$GlobalContent.=' </form>'."\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
$GlobalContent.=' <tr>'."\n";
|
||||
$GlobalContent.=' <td>'.$Vendor['Id'].'</td>'."\n";
|
||||
$GlobalContent.=' <td>'.$Vendor['Name'].'</td>'."\n";
|
||||
$GlobalContent.=' <td><a href="'.$Vendor['Homepage'].'" target="_new">'.$Vendor['Homepage'].'</a></td>'."\n";
|
||||
$GlobalContent.=' <td>'.$Vendor['MinBill'].'</td>'."\n";
|
||||
$GlobalContent.=' <td>'.$Vendor['ShippingCost'].'</td>'."\n";
|
||||
if (LockIsActive("Vendors",$Vendor['Id']))
|
||||
$GlobalContent.=' <td>'.OtherGetIcon('LockActive.png').'</td>'."\n";
|
||||
elseif (UserHasRight('EditVendors'))
|
||||
{
|
||||
$GlobalContent.=' <td>'."\n";
|
||||
$GlobalContent.=' <a href="index.php?Page=EditVendors&ToDo=DeleteVendor&Id='.$Vendor['Id'].'&Name='.$Vendor['Name'].'" title="'.LangSpellHtml('TagTitleDeleteEntry').'" target="_top">'.OtherGetIcon('Delete',"Button").'</a>'."\n";
|
||||
$GlobalContent.=' </td>'."\n";
|
||||
$GlobalContent.=' <td>'."\n";
|
||||
$GlobalContent.=' <form action="index.php?Page=EditVendors&ToDo=EditVendor" method="post">'."\n";
|
||||
$GlobalContent.=' <input type="hidden" name="Id" value="'.$Vendor['Id'].'">'."\n";
|
||||
$GlobalContent.=' <input type="submit" value="'.LangSpellHtml('ButtonEdit').'" class="Button">'."\n";
|
||||
$GlobalContent.=' </form>'."\n";
|
||||
$GlobalContent.=' </td>'."\n";
|
||||
}
|
||||
$GlobalContent.=' </tr>'."\n";
|
||||
}
|
||||
}
|
||||
|
||||
if (!$EditVendorId && UserHasRight('EditVendors'))
|
||||
{
|
||||
$GlobalContent.=' <form action="index.php?Page=EditVendors&ToDo=NewVendor" method="post">'."\n";
|
||||
$GlobalContent.=' <tr>'."\n";
|
||||
$GlobalContent.=' <td><input type="hidden" name="Id" value="">'.$Vendor['Id'].'</td>'."\n";
|
||||
$GlobalContent.=' <td><input type="text" name="Name" value=""></td>'."\n";
|
||||
$GlobalContent.=' <td><input type="text" name="Homepage" value=""></td>'."\n";
|
||||
$GlobalContent.=' <td><input type="text" name="MinBill" value=""></td>'."\n";
|
||||
$GlobalContent.=' <td><input type="text" name="ShippingCost" value=""></td>'."\n";
|
||||
$GlobalContent.=' <td></td>'."\n";
|
||||
$GlobalContent.=' <td><input type="submit" value="'.LangSpellHtml('ButtonNew').'" class="Button"></td>'."\n";
|
||||
$GlobalContent.=' </tr>'."\n";
|
||||
$GlobalContent.=' </form>'."\n";
|
||||
}
|
||||
|
||||
$GlobalContent.='</table>'."\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageError(LangSpell("ScentenceNoUserRights"));
|
||||
}
|
||||
?>
|
||||
5
pages/home.php
Executable file
5
pages/home.php
Executable file
|
|
@ -0,0 +1,5 @@
|
|||
<?php
|
||||
|
||||
$GlobalContent .= "Ich bin Inhalt!";
|
||||
|
||||
?>
|
||||
155
pages/parts_by_store.php
Executable file
155
pages/parts_by_store.php
Executable file
|
|
@ -0,0 +1,155 @@
|
|||
<?php
|
||||
global $GlobalMysqlHandler;
|
||||
if (!isset($_SESSION['PartsByStoreStoreId'])) $_SESSION['PartsByStoreStoreId']=0;
|
||||
|
||||
function WriteTypeSelector ($ParentId)
|
||||
{
|
||||
global $GlobalMysqlHandler;
|
||||
global $GlobalContent;
|
||||
global $GlobalTemplate;
|
||||
|
||||
$ListQuery="SELECT * FROM `Storages` WHERE `ParentId` =$ParentId";
|
||||
$ListQuery=mysqli_query($GlobalMysqlHandler, $ListQuery);
|
||||
|
||||
if (!$ParentId || NestedListVisibilityIsSet($ParentId, 'PartStoreSelector'))
|
||||
$GlobalContent .= "<ul style=\"display:block;\">\n";
|
||||
else
|
||||
$GlobalContent .= "<ul style=\"display:none;\">\n";
|
||||
|
||||
if (mysqli_num_rows($ListQuery))
|
||||
{
|
||||
while ($ListData=mysqli_fetch_array($ListQuery))
|
||||
{
|
||||
$GlobalContent .= "<li>";
|
||||
if (!(isset($_SESSION['PartsByStoreStoreId']) && $_SESSION['PartsByStoreStoreId']==$ListData['Id']))
|
||||
$GlobalContent .= " <a href=\"index.php?Page=PartsByStore&ToDo=ToggleTypeSelectorVisibility&SublistId=".$ListData['Id']."\">";
|
||||
$GlobalContent .= LangStr2Html($ListData['Name']);
|
||||
if (!(isset($_SESSION['PartsByStoreStoreId']) && $_SESSION['PartsByStoreStoreId']==$ListData['Id']))
|
||||
$GlobalContent .= "</a>\n";
|
||||
if (NestedListCountSubElements($ListData['Id'], 'Storages'))
|
||||
WriteTypeSelector($ListData['Id']);
|
||||
$GlobalContent .= "</li>\n";
|
||||
}
|
||||
}
|
||||
$GlobalContent .= "</ul>\n";
|
||||
}
|
||||
|
||||
|
||||
///////////////
|
||||
// open sublist
|
||||
if ($ToDo=="ToggleTypeSelectorVisibility")
|
||||
{
|
||||
if (isset($_GET['SublistId']) && $_GET['SublistId'])
|
||||
{
|
||||
$ParentId = NestedListGetParentId($_GET['SublistId'], 'Storages');
|
||||
NestedListVisibilityUnsetAllElements('PartStoreSelector');
|
||||
NestedListVisibilitySetAllParents($_GET['SublistId'], 'PartStoreSelector', 'Storages');
|
||||
NestedListVisibilitySet($_GET['SublistId'], 'PartStoreSelector');
|
||||
$_SESSION['PartsByStoreStoreId'] = $_GET['SublistId'];
|
||||
}
|
||||
else
|
||||
{
|
||||
ErrorLog("[parts_by_type.php] No SublistId to open type!");
|
||||
MessageError(LangSpell('SentenceUnknownError'));
|
||||
}
|
||||
$ToDo="";
|
||||
}
|
||||
|
||||
|
||||
///////////
|
||||
// Selector
|
||||
$GlobalContent .= '<div id="PartSelector">';
|
||||
$GlobalContent .= WriteTypeSelector (0);
|
||||
$GlobalContent .= '</div>'."\n";
|
||||
|
||||
////////////////
|
||||
// Sort Partlist
|
||||
if (!isset($_SESSION['SortPartListBy'])) $_SESSION['SortPartListBy']="Name";
|
||||
if (!isset($_SESSION['SortPartListOrder'])) $_SESSION['SortPartListOrder']="ASC";
|
||||
if (isset($_GET['SortBy']))
|
||||
{
|
||||
if ($_SESSION['SortPartListBy']==$_GET['SortBy']) //set order direction
|
||||
{
|
||||
if ($_SESSION['SortPartListOrder']=="ASC") $_SESSION['SortPartListOrder']="DESC";
|
||||
else $_SESSION['SortPartListOrder']="ASC";
|
||||
}
|
||||
else //set order by
|
||||
{
|
||||
$_SESSION['SortPartListBy']=$_GET['SortBy'];
|
||||
$_SESSION['SortPartListOrder']="ASC";
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////
|
||||
// Part List Begin
|
||||
$GlobalContent .= '<div id="PartList">';
|
||||
$GlobalContent .= '<table>'."\n";
|
||||
|
||||
//////////////////////
|
||||
// PartList Table Head
|
||||
$GlobalContent .= '<tr>';
|
||||
|
||||
//Name
|
||||
$GlobalContent .= '<th><a href="index.php?Page=PartsByStore&SortBy=Name" target="_top">';
|
||||
$GlobalContent .= LangSpellHtml('PartsName')." ";
|
||||
if ($_SESSION['SortPartListBy']=="Name" && $_SESSION['SortPartListOrder']=="ASC") $GlobalContent .= OtherGetIcon('SortUp',0);
|
||||
if ($_SESSION['SortPartListBy']=="Name" && $_SESSION['SortPartListOrder']=="DESC") $GlobalContent .= OtherGetIcon('SortDown',0);
|
||||
$GlobalContent .= '</a></th>';
|
||||
//Package
|
||||
$GlobalContent .= '<th><a href="index.php?Page=PartsByStore&SortBy=PackageId" target="_top">';
|
||||
$GlobalContent .= LangSpellHtml('PartsPackage')." ";
|
||||
if ($_SESSION['SortPartListBy']=="PackageId" && $_SESSION['SortPartListOrder']=="ASC") $GlobalContent .= OtherGetIcon('SortUp',0);
|
||||
if ($_SESSION['SortPartListBy']=="PackageId" && $_SESSION['SortPartListOrder']=="DESC") $GlobalContent .= OtherGetIcon('SortDown',0);
|
||||
$GlobalContent .= '</a></th>';
|
||||
//Quantity
|
||||
$GlobalContent .= '<th><a href="index.php?Page=PartsByStore&SortBy=Qty" target="_top">';
|
||||
$GlobalContent .= LangSpellHtml('PartsQuantity')." ";
|
||||
if ($_SESSION['SortPartListBy']=="Qty" && $_SESSION['SortPartListOrder']=="ASC") $GlobalContent .= OtherGetIcon('SortUp',0);
|
||||
if ($_SESSION['SortPartListBy']=="Qty" && $_SESSION['SortPartListOrder']=="DESC") $GlobalContent .= OtherGetIcon('SortDown',0);
|
||||
$GlobalContent .= '</a></th>';
|
||||
//Price
|
||||
$GlobalContent .= '<th><a href="index.php?Page=PartsByStore&SortBy=Price" target="_top">';
|
||||
$GlobalContent .= LangSpellHtml('PartsPrice')." ";
|
||||
if ($_SESSION['SortPartListBy']=="Price" && $_SESSION['SortPartListOrder']=="ASC") $GlobalContent .= OtherGetIcon('SortUp',0);
|
||||
if ($_SESSION['SortPartListBy']=="Price" && $_SESSION['SortPartListOrder']=="DESC") $GlobalContent .= OtherGetIcon('SortDown',0);
|
||||
$GlobalContent .= '</a></th>';
|
||||
//Obsolete
|
||||
$GlobalContent .= '<th>'.LangSpellHtml('PartsObsolete').'</th>';
|
||||
$GlobalContent .= '</tr>';
|
||||
|
||||
//////////////////////////
|
||||
// generate Partlist query
|
||||
$PartListQuery = "SELECT * FROM `Parts` WHERE `StorageId` = ".$_SESSION['PartsByStoreStoreId']."";
|
||||
$PartListQuery .= " ORDER BY `".$_SESSION['SortPartListBy']."` ".$_SESSION['SortPartListOrder'];
|
||||
//echo $PartListQuery;
|
||||
|
||||
/////////////////
|
||||
// Part List List
|
||||
$PartListQuery = mysqli_query($GlobalMysqlHandler, $PartListQuery);
|
||||
while ($Parts = mysqli_fetch_array($PartListQuery))
|
||||
{
|
||||
$GlobalContent .= ' <tr>';
|
||||
$GlobalContent .= ' <td><a href="index.php?Page=ShowPart&PartId='.$Parts['Id'].'" target="_top"><strong>'.$Parts['Name'].'</strong></a> '.$Parts['ShortDesc'].' </td>';
|
||||
//////////
|
||||
// Package
|
||||
$PackageQuery = "SELECT `Name` FROM `Packages` WHERE `Id` = ".$Parts['PackageId'];
|
||||
$PackageQuery = mysqli_query($GlobalMysqlHandler, $PackageQuery);
|
||||
if (mysqli_num_rows($PackageQuery))
|
||||
{
|
||||
$Package=mysqli_fetch_array($PackageQuery);
|
||||
$GlobalContent .= '<td>'.$Package['Name'].'</td>';
|
||||
}
|
||||
else
|
||||
{
|
||||
$GlobalContent .= '<td>-</td>';
|
||||
}
|
||||
$GlobalContent .= '<td>'.$Parts['Qty'].(($Parts['MinQty'])? "/".$Parts['MinQty']:"").'</td>';
|
||||
$GlobalContent .= '<td>'.OtherFormatPrice($Parts['Price']).'</td>';
|
||||
$GlobalContent .= '<td>'.((strtolower($Parts['Obsolete'])=="true")? LangSpellHtml('PartsObsolete'):"").'</td>';
|
||||
$GlobalContent .= ' </tr>';
|
||||
}
|
||||
|
||||
$GlobalContent .= '</table>'."\n";
|
||||
$GlobalContent .= '</div>'."\n";
|
||||
|
||||
?>
|
||||
241
pages/parts_by_type.php
Executable file
241
pages/parts_by_type.php
Executable file
|
|
@ -0,0 +1,241 @@
|
|||
<?php
|
||||
global $GlobalMysqlHandler;
|
||||
if (!isset($_SESSION['PartsByTypeTypeId'])) $_SESSION['PartsByTypeTypeId']=0;
|
||||
|
||||
function WriteTypeSelector ($ParentId)
|
||||
{
|
||||
global $GlobalMysqlHandler;
|
||||
global $GlobalContent;
|
||||
global $GlobalTemplate;
|
||||
|
||||
$ListQuery="SELECT * FROM `Types` WHERE `ParentId` =$ParentId";
|
||||
$ListQuery=mysqli_query($GlobalMysqlHandler, $ListQuery);
|
||||
|
||||
if (!$ParentId || NestedListVisibilityIsSet($ParentId, 'PartTypeSelector'))
|
||||
$GlobalContent .= "<ul style=\"display:block;\">\n";
|
||||
else
|
||||
$GlobalContent .= "<ul style=\"display:none;\">\n";
|
||||
|
||||
if (mysqli_num_rows($ListQuery))
|
||||
{
|
||||
while ($ListData=mysqli_fetch_array($ListQuery))
|
||||
{
|
||||
$GlobalContent .= "<li>";
|
||||
//if (!NestedListVisibilityIsSet($ListData['Id'], 'PartTypeSelector')) $GlobalContent .= "+";
|
||||
if (!(isset($_SESSION['PartsByTypeTypeId']) && $_SESSION['PartsByTypeTypeId']==$ListData['Id']))
|
||||
$GlobalContent .= " <a href=\"index.php?Page=PartsByType&ToDo=ToggleTypeSelectorVisibility&SublistId=".$ListData['Id']."\">";
|
||||
$GlobalContent .= LangStr2Html($ListData['Name']);
|
||||
//if (strlen($ListData['ShortName'])) $GlobalContent .= " [".LangStr2Html($ListData['ShortName'])."]";
|
||||
if (!(isset($_SESSION['PartsByTypeTypeId']) && $_SESSION['PartsByTypeTypeId']==$ListData['Id']))
|
||||
$GlobalContent .= "</a>\n";
|
||||
if (NestedListCountSubElements($ListData['Id'], 'Types'))
|
||||
WriteTypeSelector($ListData['Id']);
|
||||
$GlobalContent .= "</li>\n";
|
||||
}
|
||||
}
|
||||
$GlobalContent .= "</ul>\n";
|
||||
}
|
||||
|
||||
//////////////
|
||||
// Delete Part
|
||||
if ($ToDo=="ToggleTypeSelectorVisibility" && UserHasRight('EditParts')
|
||||
&& isset($_POST['DeletePartId']) && $_POST['DeletePartId']
|
||||
&& isset($_POST['DeletePartShure']) && $_POST['DeletePartShure']=="True"
|
||||
&& isset($_GET['SublistId']) && $_GET['SublistId']
|
||||
)
|
||||
{
|
||||
if (LockIsActive('Parts',$_POST['DeletePartId']))
|
||||
{
|
||||
MessageError(LangSpellHtml('SentenceLockIsActive'));
|
||||
}
|
||||
else
|
||||
{
|
||||
if (mysqli_query($GlobalMysqlHandler, "DELETE FROM `Parts` WHERE `Id` = ".$_POST['DeletePartId']." LIMIT 1"))
|
||||
{
|
||||
MessageSuccess(LangSpellHtml('SentencePartDeleted'));
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageError(LangSpellHtml('SentenceDatabaseError'));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
///////////////
|
||||
// open sublist
|
||||
if ($ToDo=="ToggleTypeSelectorVisibility")
|
||||
{
|
||||
if (isset($_GET['SublistId']) && $_GET['SublistId'])
|
||||
{
|
||||
$ParentId = NestedListGetParentId($_GET['SublistId'], 'Types');
|
||||
NestedListVisibilityUnsetAllElements('PartTypeSelector');
|
||||
NestedListVisibilitySetAllParents($_GET['SublistId'], 'PartTypeSelector', 'Types');
|
||||
NestedListVisibilitySet($_GET['SublistId'], 'PartTypeSelector');
|
||||
$_SESSION['PartsByTypeTypeId'] = $_GET['SublistId'];
|
||||
}
|
||||
else
|
||||
{
|
||||
ErrorLog("[parts_by_type.php] No SublistId to open type!");
|
||||
MessageError(LangSpell('SentenceUnknownError'));
|
||||
}
|
||||
$ToDo="";
|
||||
}
|
||||
|
||||
/////////////
|
||||
// Type Array
|
||||
$TypeQuery = "SELECT * FROM `Types` WHERE `Id` = ".$_SESSION['PartsByTypeTypeId'];
|
||||
$TypeQuery = mysqli_query($GlobalMysqlHandler, $TypeQuery);
|
||||
$TypeValues = array();
|
||||
if (mysqli_num_rows($TypeQuery))
|
||||
{
|
||||
$TypeItem = mysqli_fetch_array($TypeQuery);
|
||||
$TypeValues[0][0] = $TypeItem['NameValue1'];
|
||||
$TypeValues[0][1] = $TypeItem['UnitValue1'];
|
||||
$TypeValues[1][0] = $TypeItem['NameValue2'];
|
||||
$TypeValues[1][1] = $TypeItem['UnitValue2'];
|
||||
$TypeValues[2][0] = $TypeItem['NameValue3'];
|
||||
$TypeValues[2][1] = $TypeItem['UnitValue3'];
|
||||
}
|
||||
|
||||
///////////
|
||||
// Selector
|
||||
$GlobalContent .= '<div id="PartSelector">';
|
||||
$GlobalContent .= WriteTypeSelector (0);
|
||||
$GlobalContent .= '</div>'."\n";
|
||||
|
||||
/////////
|
||||
// Filter
|
||||
$GlobalContent .= '<div id="PartFilter">'."\n";
|
||||
//Obsolete Filter
|
||||
if (!isset($_SESSION['FilterObsolete'])) $_SESSION['FilterObsolete']="NonObsolete";
|
||||
if (isset($_POST['FilterObsolete'])) $_SESSION['FilterObsolete']=$_POST['FilterObsolete'];
|
||||
$GlobalContent .= ' <form action="index.php?Page=PartsByType" method="post">'."\n";
|
||||
$GlobalContent .= ' <input type="radio" name="FilterObsolete" value="NonObsolete" onClick="javascript:this.form.submit()" '.(($_SESSION['FilterObsolete']=="NonObsolete")? "checked":"").'>'.LangSpellHtml('PartsObsoleteNon')."\n";
|
||||
$GlobalContent .= ' <input type="radio" name="FilterObsolete" value="OnlyObsolete" onClick="javascript:this.form.submit()" '.(($_SESSION['FilterObsolete']=="OnlyObsolete")? "checked":"").'>'.LangSpellHtml('PartsObsoleteOnly')."\n";
|
||||
$GlobalContent .= ' <input type="radio" name="FilterObsolete" value="AllObsolete" onClick="javascript:this.form.submit()" '.(($_SESSION['FilterObsolete']=="AllObsolete")? "checked":"").'>'.LangSpellHtml('PartsObsoleteAll')."\n";
|
||||
$GlobalContent .= ' </form>'."\n";
|
||||
$GlobalContent .= '</div>'."\n";
|
||||
|
||||
////////////////
|
||||
// Sort Partlist
|
||||
if (!isset($_SESSION['SortPartListBy'])) $_SESSION['SortPartListBy']="Name";
|
||||
if (!isset($_SESSION['SortPartListOrder'])) $_SESSION['SortPartListOrder']="ASC";
|
||||
if (isset($_GET['SortBy']))
|
||||
{
|
||||
if ($_SESSION['SortPartListBy']==$_GET['SortBy']) //set order direction
|
||||
{
|
||||
if ($_SESSION['SortPartListOrder']=="ASC") $_SESSION['SortPartListOrder']="DESC";
|
||||
else $_SESSION['SortPartListOrder']="ASC";
|
||||
}
|
||||
else //set order by
|
||||
{
|
||||
$_SESSION['SortPartListBy']=$_GET['SortBy'];
|
||||
$_SESSION['SortPartListOrder']="ASC";
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////
|
||||
// Part List Begin
|
||||
$GlobalContent .= '<div id="PartList">';
|
||||
$GlobalContent .= '<table>'."\n";
|
||||
|
||||
//////////////////////
|
||||
// PartList Table Head
|
||||
$GlobalContent .= '<tr>';
|
||||
|
||||
//Name
|
||||
$GlobalContent .= '<th><a href="index.php?Page=PartsByType&SortBy=Name" target="_top">';
|
||||
$GlobalContent .= LangSpellHtml('PartsName')." ";
|
||||
if ($_SESSION['SortPartListBy']=="Name" && $_SESSION['SortPartListOrder']=="ASC") $GlobalContent .= OtherGetIcon('SortUp',0);
|
||||
if ($_SESSION['SortPartListBy']=="Name" && $_SESSION['SortPartListOrder']=="DESC") $GlobalContent .= OtherGetIcon('SortDown',0);
|
||||
$GlobalContent .= '</a></th>';
|
||||
//Value 1
|
||||
if (isset($TypeValues[0][0]) && $TypeValues[0][0])
|
||||
{
|
||||
$GlobalContent .= '<th><a href="index.php?Page=PartsByType&SortBy=Value1" target="_top">';
|
||||
$GlobalContent .= $TypeValues[0][0]." ";
|
||||
if ($_SESSION['SortPartListBy']=="Value1" && $_SESSION['SortPartListOrder']=="ASC") $GlobalContent .= OtherGetIcon('SortUp',0);
|
||||
if ($_SESSION['SortPartListBy']=="Value1" && $_SESSION['SortPartListOrder']=="DESC") $GlobalContent .= OtherGetIcon('SortDown',0);
|
||||
$GlobalContent .= '</a></th>';
|
||||
}
|
||||
//Value2
|
||||
if (isset($TypeValues[1][0]) && $TypeValues[1][0])
|
||||
{
|
||||
$GlobalContent .= '<th><a href="index.php?Page=PartsByType&SortBy=Value2" target="_top">';
|
||||
$GlobalContent .= $TypeValues[1][0]." ";
|
||||
if ($_SESSION['SortPartListBy']=="Value2" && $_SESSION['SortPartListOrder']=="ASC") $GlobalContent .= OtherGetIcon('SortUp',0);
|
||||
if ($_SESSION['SortPartListBy']=="Value2" && $_SESSION['SortPartListOrder']=="DESC") $GlobalContent .= OtherGetIcon('SortDown',0);
|
||||
$GlobalContent .= '</a></th>';
|
||||
}
|
||||
//Value3
|
||||
if (isset($TypeValues[2][0]) && $TypeValues[2][0])
|
||||
{
|
||||
$GlobalContent .= '<th><a href="index.php?Page=PartsByType&SortBy=Value3" target="_top">';
|
||||
$GlobalContent .= $TypeValues[2][0]." ";
|
||||
if ($_SESSION['SortPartListBy']=="Value3" && $_SESSION['SortPartListOrder']=="ASC") $GlobalContent .= OtherGetIcon('SortUp',0);
|
||||
if ($_SESSION['SortPartListBy']=="Value3" && $_SESSION['SortPartListOrder']=="DESC") $GlobalContent .= OtherGetIcon('SortDown',0);
|
||||
$GlobalContent .= '</a></th>';
|
||||
}
|
||||
//Package
|
||||
$GlobalContent .= '<th><a href="index.php?Page=PartsByType&SortBy=PackageId" target="_top">';
|
||||
$GlobalContent .= LangSpellHtml('PartsPackage')." ";
|
||||
if ($_SESSION['SortPartListBy']=="PackageId" && $_SESSION['SortPartListOrder']=="ASC") $GlobalContent .= OtherGetIcon('SortUp',0);
|
||||
if ($_SESSION['SortPartListBy']=="PackageId" && $_SESSION['SortPartListOrder']=="DESC") $GlobalContent .= OtherGetIcon('SortDown',0);
|
||||
$GlobalContent .= '</a></th>';
|
||||
//Quantity
|
||||
$GlobalContent .= '<th><a href="index.php?Page=PartsByType&SortBy=Qty" target="_top">';
|
||||
$GlobalContent .= LangSpellHtml('PartsQuantity')." ";
|
||||
if ($_SESSION['SortPartListBy']=="Qty" && $_SESSION['SortPartListOrder']=="ASC") $GlobalContent .= OtherGetIcon('SortUp',0);
|
||||
if ($_SESSION['SortPartListBy']=="Qty" && $_SESSION['SortPartListOrder']=="DESC") $GlobalContent .= OtherGetIcon('SortDown',0);
|
||||
$GlobalContent .= '</a></th>';
|
||||
//Price
|
||||
$GlobalContent .= '<th><a href="index.php?Page=PartsByType&SortBy=Price" target="_top">';
|
||||
$GlobalContent .= LangSpellHtml('PartsPrice')." ";
|
||||
if ($_SESSION['SortPartListBy']=="Price" && $_SESSION['SortPartListOrder']=="ASC") $GlobalContent .= OtherGetIcon('SortUp',0);
|
||||
if ($_SESSION['SortPartListBy']=="Price" && $_SESSION['SortPartListOrder']=="DESC") $GlobalContent .= OtherGetIcon('SortDown',0);
|
||||
$GlobalContent .= '</a></th>';
|
||||
//Obsolete
|
||||
$GlobalContent .= '<th>'.LangSpellHtml('PartsObsolete').'</th>';
|
||||
$GlobalContent .= '</tr>';
|
||||
|
||||
//////////////////////////
|
||||
// generate Partlist query
|
||||
$PartListQuery = "SELECT * FROM `Parts` WHERE `TypeId` = ".$_SESSION['PartsByTypeTypeId']."";
|
||||
if ($_SESSION['FilterObsolete']=="OnlyObsolete") $PartListQuery .= " AND `Obsolete` LIKE 'TRUE'";
|
||||
if ($_SESSION['FilterObsolete']=="NonObsolete") $PartListQuery .= " AND `Obsolete` LIKE 'FALSE'";
|
||||
$PartListQuery .= " ORDER BY `".$_SESSION['SortPartListBy']."` ".$_SESSION['SortPartListOrder'];
|
||||
//echo $PartListQuery;
|
||||
|
||||
/////////////////
|
||||
// Part List List
|
||||
$PartListQuery = mysqli_query($GlobalMysqlHandler, $PartListQuery);
|
||||
while ($Parts = mysqli_fetch_array($PartListQuery))
|
||||
{
|
||||
$GlobalContent .= ' <tr>';
|
||||
$GlobalContent .= ' <td><a href="index.php?Page=ShowPart&PartId='.$Parts['Id'].'" target="_top"><strong>'.$Parts['Name'].'</strong></a> '.$Parts['ShortDesc'].' </td>';
|
||||
if (isset($TypeValues[0][0]) && $TypeValues[0][0]) $GlobalContent .= ' <td>'.OtherFloatToSiPrefix ($Parts['Value1']).$TypeValues[0][1].'</td>';
|
||||
if (isset($TypeValues[1][0]) && $TypeValues[1][0]) $GlobalContent .= ' <td>'.OtherFloatToSiPrefix ($Parts['Value2']).$TypeValues[1][1].'</td>';
|
||||
if (isset($TypeValues[2][0]) && $TypeValues[2][0]) $GlobalContent .= ' <td>'.OtherFloatToSiPrefix ($Parts['Value3']).$TypeValues[2][1].'</td>';
|
||||
//////////
|
||||
// Package
|
||||
$PackageQuery = "SELECT `Name` FROM `Packages` WHERE `Id` = ".$Parts['PackageId'];
|
||||
$PackageQuery = mysqli_query($GlobalMysqlHandler, $PackageQuery);
|
||||
if (mysqli_num_rows($PackageQuery))
|
||||
{
|
||||
$Package=mysqli_fetch_array($PackageQuery);
|
||||
$GlobalContent .= '<td>'.$Package['Name'].'</td>';
|
||||
}
|
||||
else
|
||||
{
|
||||
$GlobalContent .= '<td>-</td>';
|
||||
}
|
||||
$GlobalContent .= '<td>'.$Parts['Qty'].(($Parts['MinQty'])? "/".$Parts['MinQty']:"").'</td>';
|
||||
$GlobalContent .= '<td>'.OtherFormatPrice($Parts['Price']).'</td>';
|
||||
$GlobalContent .= '<td>'.((strtolower($Parts['Obsolete'])=="true")? LangSpellHtml('PartsObsolete'):"").'</td>';
|
||||
$GlobalContent .= ' </tr>';
|
||||
}
|
||||
|
||||
$GlobalContent .= '</table>'."\n";
|
||||
$GlobalContent .= '</div>'."\n";
|
||||
|
||||
?>
|
||||
73
pages/repeat_order.php
Executable file
73
pages/repeat_order.php
Executable file
|
|
@ -0,0 +1,73 @@
|
|||
<?php
|
||||
|
||||
function RepeatOrderTableByVendor ($VendorName, $VendorId)
|
||||
{
|
||||
global $GlobalMysqlHandler;
|
||||
global $GlobalContent;
|
||||
|
||||
$RepOrdQuery="SELECT * FROM `Parts` WHERE `Qty` < `MinQty` AND `VendorId` = $VendorId ORDER BY `Name` ASC";
|
||||
$RepOrdQuery=mysqli_query($GlobalMysqlHandler, $RepOrdQuery);
|
||||
|
||||
$ShowTable=0;
|
||||
if (mysqli_num_rows($RepOrdQuery))
|
||||
{
|
||||
$GlobalContent .= '<table>';
|
||||
$GlobalContent .= ' <tr>';
|
||||
$GlobalContent .= ' <td colspan="8">{'.$VendorId.'} <strong>'.$VendorName.'</strong></td>';
|
||||
$GlobalContent .= ' </tr>';
|
||||
$GlobalContent .= ' <tr>';
|
||||
$GlobalContent .= ' <th>'.LangSpellHtml('PartsName').'</th>';
|
||||
$GlobalContent .= ' <th>'.LangSpellHtml('PartsQuantity').'</th>';
|
||||
$GlobalContent .= ' <th>'.LangSpellHtml('PartsMinQuantity').'</th>';
|
||||
$GlobalContent .= ' <th>'.LangSpellHtml('PartsPackageUnit').'</th>';
|
||||
$GlobalContent .= ' <th>'.LangSpellHtml('PartsPrice').'</th>';
|
||||
$GlobalContent .= ' <th>'.LangSpellHtml('PartsVendorLink').'</th>';
|
||||
$GlobalContent .= ' <th>'.LangSpellHtml('RepeatOrderPackagesToOrder').'</th>';
|
||||
$GlobalContent .= ' <th>'.LangSpellHtml('RepeatOrderSumPrice').'</th>';
|
||||
$GlobalContent .= ' </tr>';
|
||||
$ShowTable = 1;
|
||||
}
|
||||
|
||||
$AllSumPrice=0;
|
||||
while ($Part = mysqli_fetch_array($RepOrdQuery))
|
||||
{
|
||||
if (!$Part['PackageUnit']) $Part['PackageUnit']=1;
|
||||
$Price=OtherFormatPrice($Part['Price']);
|
||||
$VendorLink=($Part['VendorLink'])? '<a href="'.$Part['VendorLink'].'" target="_new">':'-';
|
||||
$OrderPackages = ceil(($Part['MinQty']-$Part['Qty'])/$Part['PackageUnit']);
|
||||
$SumPrice = OtherFormatPrice($OrderPackages * $Part['Price']);
|
||||
$AllSumPrice += $OrderPackages * $Part['Price'];
|
||||
|
||||
$GlobalContent .= ' <tr>';
|
||||
$GlobalContent .= ' <td><a href="'.$Part['VendorLink'].'" title="'.$Part['VendorLink'].'" target="_new">'.$Part['Name'].'</a></td>';
|
||||
$GlobalContent .= ' <td>'.$Part['Qty'].'</td>';
|
||||
$GlobalContent .= ' <td>'.$Part['MinQty'].'</td>';
|
||||
$GlobalContent .= ' <td>'.$Part['PackageUnit'].'</td>';
|
||||
$GlobalContent .= ' <td>'.$Price.'</td>';
|
||||
$GlobalContent .= ' <td>'.$VendorLink.'</td>';
|
||||
$GlobalContent .= ' <td>'.$OrderPackages.'</td>';
|
||||
$GlobalContent .= ' <td>'.OtherFormatPrice($SumPrice).'</td>';
|
||||
$GlobalContent .= ' </tr>';
|
||||
}
|
||||
if ($ShowTable)
|
||||
{
|
||||
$GlobalContent .= ' <tr>';
|
||||
$GlobalContent .= ' <td colspan="7"></td><td><strong>'.OtherFormatPrice($AllSumPrice).'</strong></td>';
|
||||
$GlobalContent .= ' </tr>';
|
||||
$GlobalContent .= '</table>';
|
||||
}
|
||||
}
|
||||
|
||||
global $GlobalMysqlHandler;
|
||||
|
||||
|
||||
$VendorQuery = "SELECT * FROM `Vendors` ORDER BY `Name` ASC";
|
||||
$VendorQuery = mysqli_query($GlobalMysqlHandler, $VendorQuery);
|
||||
RepeatOrderTableByVendor(LangSpellHtml('PartsNotSpecified'),0);
|
||||
while ($Vendor = mysqli_fetch_array($VendorQuery))
|
||||
{
|
||||
RepeatOrderTableByVendor($Vendor['Name'],$Vendor['Id']);
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
398
pages/show_part.php
Executable file
398
pages/show_part.php
Executable file
|
|
@ -0,0 +1,398 @@
|
|||
<?php
|
||||
global $GlobalMysqlHandler;
|
||||
global $GlobalDownloadDir;
|
||||
global $GlobalPictureDir;
|
||||
|
||||
//////////////
|
||||
// Get Part Id
|
||||
$PartId = 0;
|
||||
$PartId = (isset($_GET['PartId']) ) ? $_GET['PartId']:$PartId;
|
||||
$PartId = (isset($_POST['PartId'])) ? $_POST['PartId']:$PartId;
|
||||
|
||||
//mysql part request
|
||||
$PartSQLQuery = "SELECT * FROM `Parts` WHERE `Id` = $PartId LIMIT 1;";
|
||||
$PartQuery = mysqli_query($GlobalMysqlHandler, $PartSQLQuery);
|
||||
$Part = mysqli_fetch_array($PartQuery);
|
||||
|
||||
if (mysqli_num_rows($PartQuery))
|
||||
{
|
||||
/////////////////////
|
||||
// upload new picture
|
||||
if (($ToDo=="UploadNewPicture") && (UserHasRight('EditParts')))
|
||||
{
|
||||
if (!LockIsActive('Parts',$PartId))
|
||||
{
|
||||
if (!is_dir($GlobalPictureDir) && !mkdir($GlobalPictureDir))
|
||||
{
|
||||
MessageError(LangSpell('SentenceCanNotCopyFile'));
|
||||
ErrorLog("Can not create directory $GlobalPictureDir");
|
||||
}
|
||||
elseif (!isset($_FILES['NewPictureFile']))
|
||||
{
|
||||
MessageError(LangSpell('SentenceNoFileGiven'));
|
||||
$ToDo="EditPicture";
|
||||
}
|
||||
elseif ($_FILES['NewPictureFile']['error'])
|
||||
{
|
||||
MessageError($_FILES['NewPictureFile']['error'].': http://www.php.net/manual/de/features.file-upload.errors.php');
|
||||
ErrorLog("Picture upload error ".$_FILES['NewPictureFile']['error']);
|
||||
$ToDo="EditPicture";
|
||||
}
|
||||
elseif (diskfreespace($GlobalPictureDir)<$_FILES['NewPictureFile']['size'])
|
||||
{
|
||||
MessageError(LangSpell('SentenceNotEnoughDiskSpace'));
|
||||
$ToDo="EditPicture";
|
||||
}
|
||||
else
|
||||
{
|
||||
$DestinationFileName = "[".$PartId."]_".$_FILES["NewPictureFile"]["name"];
|
||||
$SqlInsertQuery="UPDATE `Parts` SET `PicturePath` = '$DestinationFileName' WHERE `Id` = $PartId LIMIT 1 ;";
|
||||
$OldFileNameQuery=mysqli_query($GlobalMysqlHandler, "SELECT `PicturePath` FROM `Parts` WHERE `Id` = $PartId");
|
||||
$OldFileNameArray=mysqli_fetch_array($OldFileNameQuery);
|
||||
$OldFileName=$OldFileNameArray['PicturePath'];
|
||||
if ($OldFileName && file_exists($GlobalPictureDir."/".$OldFileName) && !unlink($GlobalPictureDir."/".$OldFileName))
|
||||
{
|
||||
MessageError(LangSpell('SentenceCanNotCopyFile'));
|
||||
ErrorLog("Unable to delete old picture!");
|
||||
$ToDo="EditPicture";
|
||||
}
|
||||
elseif (!move_uploaded_file($_FILES["NewPictureFile"]["tmp_name"],$GlobalPictureDir."/".$DestinationFileName))
|
||||
{
|
||||
MessageError(LangSpell('SentenceCanNotCopyFile')." ($GlobalPictureDir)");
|
||||
$ToDo="EditPicture";
|
||||
}
|
||||
elseif (!mysqli_query($GlobalMysqlHandler, $SqlInsertQuery))
|
||||
{
|
||||
ErrorLog("Can not instert into table 'Parts'!");
|
||||
MessageError(LangSpell('SentenceDatabaseError'));
|
||||
unlink($GlobalPictureDir."/".$DestinationFileName);
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageSuccess(LangSpell('SentenceFileHasBeenUploaded'));
|
||||
$ToDo="";
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageError(LangSpell('SentenceLockIsActive'));
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////
|
||||
// Delete Download
|
||||
if (isset($_GET['DownloadId']) && ($ToDo=="DeleteDownload") && (UserHasRight('EditParts')))
|
||||
{
|
||||
if (!LockIsActive('Parts',$PartId))
|
||||
{
|
||||
$DownloadQuery = "SELECT * FROM `Downloads` WHERE `Id` = ".$_GET['DownloadId'];
|
||||
$DownloadQuery = mysqli_query($GlobalMysqlHandler, $DownloadQuery);
|
||||
if (mysqli_num_rows($DownloadQuery))
|
||||
{
|
||||
$Download=mysqli_fetch_array($DownloadQuery);
|
||||
if (file_exists($GlobalDownloadDir."/".$Download['Path']))
|
||||
{
|
||||
if (unlink($GlobalDownloadDir."/".$Download['Path']))
|
||||
{
|
||||
if (mysqli_query($GlobalMysqlHandler, "DELETE FROM `Downloads` WHERE `Id` = ".$_GET['DownloadId']." LIMIT 1"))
|
||||
MessageSuccess(LangSpell('SentenceDownloadDeleted'));
|
||||
else
|
||||
{
|
||||
ErrorLog("Can not update table 'Downloads' at id '".$_POST['EditDownloadId']."'!");
|
||||
MessageError(LangSpell('SentenceDatabaseError'));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ErrorLog("Deleting file '".$GlobalDownloadDir."/".$Download['Path']."' failed'!");
|
||||
MessageError(LangSpell('SentenceCanNotCopyFile'));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (mysqli_query($GlobalMysqlHandler, "DELETE FROM `Downloads` WHERE `Id` = ".$_GET['DownloadId']." LIMIT 1"))
|
||||
MessageSuccess(LangSpell('SentenceDownloadDeleted'));
|
||||
else
|
||||
{
|
||||
ErrorLog("Can not update table 'Downloads' at id '".$_POST['EditDownloadId']."'!");
|
||||
MessageError(LangSpell('SentenceDatabaseError'));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageError(LangSpell('SentenceLockIsActive'));
|
||||
}
|
||||
$ToDo="";
|
||||
}
|
||||
|
||||
////////////////
|
||||
// Edit Download
|
||||
if (isset($_POST['EditDownloadId']) && isset($_POST['EditDownloadName']) && ($ToDo=="EditDownload") && (UserHasRight('EditParts')))
|
||||
{
|
||||
if (!LockIsActive('Parts',$PartId))
|
||||
{
|
||||
if (!mysqli_query($GlobalMysqlHandler, "UPDATE `Downloads` SET `Name` = '".$_POST['EditDownloadName']."' WHERE `Id` =".$_POST['EditDownloadId']." LIMIT 1 ;"))
|
||||
{
|
||||
ErrorLog("Can not update table 'Downloads' at id '".$_POST['EditDownloadId']."'!");
|
||||
MessageError(LangSpell('SentenceDatabaseError'));
|
||||
}
|
||||
else
|
||||
MessageSuccess(LangSpell('SentenceDownloadEdited'));
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageError(LangSpell('SentenceLockIsActive'));
|
||||
}
|
||||
$ToDo="";
|
||||
}
|
||||
|
||||
//////////////////////
|
||||
// upload new downlaod
|
||||
if (($ToDo=="UploadNewDownload") && (UserHasRight('EditParts')))
|
||||
{
|
||||
if (!LockIsActive('Parts',$PartId))
|
||||
{
|
||||
if (!is_dir($GlobalDownloadDir) && !mkdir($GlobalDownloadDir))
|
||||
{
|
||||
MessageError(LangSpell('SentenceCanNotCopyFile'));
|
||||
ErrorLog("Can not create directory $GlobalDownloadDir");
|
||||
}
|
||||
elseif (!isset($_FILES['AddNewDownloadFile']))
|
||||
{
|
||||
MessageError(LangSpell('SentenceNoFileGiven'));
|
||||
$ToDo="EditDownloads";
|
||||
}
|
||||
elseif ($_FILES['AddNewDownloadFile']['error'])
|
||||
{
|
||||
MessageError($_FILES['AddNewDownloadFile']['error'].': http://www.php.net/manual/de/features.file-upload.errors.php');
|
||||
ErrorLog("Upload error ".$_FILES['AddNewDownloadFile']['error']);
|
||||
$ToDo="EditDownloads";
|
||||
}
|
||||
elseif (diskfreespace($GlobalDownloadDir)<$_FILES['AddNewDownloadFile']['size'])
|
||||
{
|
||||
MessageError(LangSpell('SentenceNotEnoughDiskSpace'));
|
||||
$ToDo="EditDownloads";
|
||||
}
|
||||
else
|
||||
{
|
||||
$DestinationFileName = "[".$PartId."]_".$_FILES["AddNewDownloadFile"]["name"];
|
||||
$SqlInsertQuery="INSERT INTO `Downloads` ( `PartId` , `Name` , `Path` , `Type` ) VALUES ( '$PartId', "
|
||||
."'".((isset($_POST['AddNewDownloadName']) && $_POST['AddNewDownloadName'])? $_POST['AddNewDownloadName']:$_FILES["AddNewDownloadFile"]["name"])."', "
|
||||
."'$DestinationFileName', '".$_FILES["AddNewDownloadFile"]["type"]."' );";
|
||||
if (file_exists($GlobalDownloadDir."/".$DestinationFileName))
|
||||
{
|
||||
MessageError(LangSpell('SentenceFileAlreadyExist'));
|
||||
$ToDo="EditDownloads";
|
||||
}
|
||||
elseif (!move_uploaded_file($_FILES["AddNewDownloadFile"]["tmp_name"],$GlobalDownloadDir."/".$DestinationFileName))
|
||||
{
|
||||
MessageError(LangSpell('SentenceCanNotCopyFile')." ($GlobalDownloadDir)");
|
||||
$ToDo="EditDownloads";
|
||||
}
|
||||
elseif (!mysqli_query($GlobalMysqlHandler, $SqlInsertQuery))
|
||||
{
|
||||
ErrorLog("Can not instert into table 'Downloads'!");
|
||||
MessageError(LangSpell('SentenceDatabaseError'));
|
||||
unlink($GlobalDownloadDir."/".$DestinationFileName);
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageSuccess(LangSpell('SentenceFileHasBeenUploaded'));
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageError(LangSpell('SentenceLockIsActive'));
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////
|
||||
// Save values of the part
|
||||
if (($ToDo=="SaveValues") && (UserHasRight('EditParts')))
|
||||
{
|
||||
if (!LockIsActive('Parts',$PartId))
|
||||
{
|
||||
$UpdateQuery = "UPDATE `Parts` SET `Name` = '".$_POST['EditValuesName']."', ";
|
||||
$UpdateQuery .= "`Value1` = '".((isset($_POST['EditValuesValue1']))? OtherSiPrefixToFloat($_POST['EditValuesValue1']):0)."', ";
|
||||
$UpdateQuery .= "`Value2` = '".((isset($_POST['EditValuesValue2']))? OtherSiPrefixToFloat($_POST['EditValuesValue2']):0)."', ";
|
||||
$UpdateQuery .= "`Value3` = '".((isset($_POST['EditValuesValue3']))? OtherSiPrefixToFloat($_POST['EditValuesValue3']):0)."', ";
|
||||
$UpdateQuery .= "`ShortDesc` = '".$_POST['EditValuesShortDesc']."', ";
|
||||
$UpdateQuery .= "`LongDesc` = '".$_POST['EditValuesLongDesc']."', ";
|
||||
$UpdateQuery .= "`VendorId` = '".$_POST['EditValuesVendor']."', ";
|
||||
$UpdateQuery .= "`VendorLink` = '".$_POST['NewPartVedorLink']."', ";
|
||||
$UpdateQuery .= "`ManufactorLink` = '".$_POST['NewPartManufactorLink']."', ";
|
||||
$UpdateQuery .= "`PackageUnit` = '".$_POST['EditValuesPackageUnit']."', ";
|
||||
$UpdateQuery .= "`Price` = '".OtherFormatPrice($_POST['EditValuesPrice'])."', ";
|
||||
$UpdateQuery .= "`MinOrderQty` = '".$_POST['EditValuesMinOrderQty']."', ";
|
||||
$UpdateQuery .= "`Qty` = '".$_POST['EditValuesQty']."', ";
|
||||
$UpdateQuery .= "`MinQty` = '".$_POST['EditValuesMinQty']."', ";
|
||||
$UpdateQuery .= "`Obsolete` = '".(((isset($_POST['EditValuesObsolete'])) && (strtolower($_POST['EditValuesObsolete'])=="true"))? "True":"False")."' ";
|
||||
$UpdateQuery .= "WHERE `Id` = $PartId LIMIT 1 ;";
|
||||
if (mysqli_query($GlobalMysqlHandler, $UpdateQuery))
|
||||
{
|
||||
MessageSuccess(LangSpell('SentencePartHasBeenUpdated'));
|
||||
}
|
||||
else
|
||||
{
|
||||
ErrorLog("Can not update table 'Parts' at id '$PartId'!");
|
||||
MessageError(LangSpell('SentenceDatabaseError'));
|
||||
}
|
||||
$ToDo="";
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageError(LangSpell('SentenceLockIsActive'));
|
||||
}
|
||||
$ToDo="";
|
||||
}
|
||||
|
||||
///////////////////////////
|
||||
// Save storage of the part
|
||||
if (isset($_POST['EditPartStorage']) && ($ToDo=="SaveStorage") && (UserHasRight('EditParts')))
|
||||
{
|
||||
if (!LockIsActive('Parts',$PartId))
|
||||
{
|
||||
if (!mysqli_query($GlobalMysqlHandler, "UPDATE `Parts` SET `StorageId` = '".$_POST['EditPartStorage']."' WHERE `Id` =$PartId LIMIT 1 ;"))
|
||||
{
|
||||
ErrorLog("Can not update table 'Parts' at id '$PartId'!");
|
||||
MessageError(LangSpell('SentenceDatabaseError'));
|
||||
}
|
||||
else
|
||||
MessageSuccess(LangSpell('SentencePartHasBeenUpdated'));
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageError(LangSpell('SentenceLockIsActive'));
|
||||
}
|
||||
$ToDo="";
|
||||
}
|
||||
|
||||
///////////////////////////
|
||||
// Save package of the part
|
||||
if (isset($_POST['EditPartPackage']) && ($ToDo=="SavePackage") && (UserHasRight('EditParts')))
|
||||
{
|
||||
if (!LockIsActive('Parts',$PartId))
|
||||
{
|
||||
if (!mysqli_query($GlobalMysqlHandler, "UPDATE `Parts` SET `PackageId` = '".$_POST['EditPartPackage']."' WHERE `Id` =$PartId LIMIT 1 ;"))
|
||||
{
|
||||
ErrorLog("Can not update table 'Parts' at id '$PartId'!");
|
||||
MessageError(LangSpell('SentenceDatabaseError'));
|
||||
}
|
||||
else
|
||||
MessageSuccess(LangSpell('SentencePartHasBeenUpdated'));
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageError(LangSpell('SentenceLockIsActive'));
|
||||
}
|
||||
$ToDo="";
|
||||
}
|
||||
|
||||
////////////////////////
|
||||
// Save type of the part
|
||||
if (isset($_POST['EditPartType']) && ($ToDo=="SaveType") && (UserHasRight('EditParts')))
|
||||
{
|
||||
if (!LockIsActive('Parts',$PartId))
|
||||
{
|
||||
if (!mysqli_query($GlobalMysqlHandler, "UPDATE `Parts` SET `TypeId` = '".$_POST['EditPartType']."' WHERE `Id` =$PartId LIMIT 1 ;"))
|
||||
{
|
||||
ErrorLog("Can not update table 'Parts' at id '$PartId'!");
|
||||
MessageError(LangSpell('SentenceDatabaseError'));
|
||||
}
|
||||
else
|
||||
MessageSuccess(LangSpell('SentencePartHasBeenUpdated'));
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageError(LangSpell('SentenceLockIsActive'));
|
||||
}
|
||||
$ToDo="";
|
||||
}
|
||||
|
||||
//////////////////////////////
|
||||
//Update Parts Actual Quantity
|
||||
if (isset($_POST['NewQuantity']) && ($ToDo=="SaveNewQuantity") && (UserHasRight('EditParts') || UserHasRight('EditPartQuantity')))
|
||||
{
|
||||
if (!LockIsActive('Parts',$PartId))
|
||||
{
|
||||
$NewQuantity=$_POST['NewQuantity'];
|
||||
if (!mysqli_query($GlobalMysqlHandler, "UPDATE `Parts` SET `Qty` = '$NewQuantity' WHERE `Id` =$PartId LIMIT 1 ;"))
|
||||
{
|
||||
ErrorLog("Can not update table 'Parts' at id '$PartId'!");
|
||||
MessageError(LangSpell('SentenceDatabaseError'));
|
||||
}
|
||||
else
|
||||
MessageSuccess(LangSpell('SentencePartHasBeenUpdated'));
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageError(LangSpell('SentenceLockIsActive'));
|
||||
}
|
||||
$ToDo="";
|
||||
}
|
||||
|
||||
/////////////////
|
||||
// Get Part Query
|
||||
$PartSQLQuery = "SELECT * FROM `Parts` WHERE `Id` = $PartId LIMIT 1;";
|
||||
$PartQuery = mysqli_query($GlobalMysqlHandler, $PartSQLQuery);
|
||||
$Part = mysqli_fetch_array($PartQuery);
|
||||
|
||||
/////////////
|
||||
// Type Array
|
||||
$TypeQuery = "SELECT * FROM `Types` WHERE `Id` = ".$Part['TypeId'];
|
||||
$TypeQuery = mysqli_query($GlobalMysqlHandler, $TypeQuery);
|
||||
$TypeValues = array();
|
||||
if (mysqli_num_rows($TypeQuery))
|
||||
{
|
||||
$TypeItem = mysqli_fetch_array($TypeQuery);
|
||||
$TypeValues[0][0] = $TypeItem['NameValue1'];
|
||||
$TypeValues[0][1] = $TypeItem['UnitValue1'];
|
||||
$TypeValues[1][0] = $TypeItem['NameValue2'];
|
||||
$TypeValues[1][1] = $TypeItem['UnitValue2'];
|
||||
$TypeValues[2][0] = $TypeItem['NameValue3'];
|
||||
$TypeValues[2][1] = $TypeItem['UnitValue3'];
|
||||
}
|
||||
|
||||
$GlobalContent .= '<div id="ShowPart">'."\n";
|
||||
|
||||
if ($ToDo=="EditType" && UserHasRight('EditParts') && LockActivate('Parts',$PartId))
|
||||
{
|
||||
include "./pages/show_part_edit_type.php";
|
||||
}
|
||||
elseif ($ToDo=="EditPackage" && UserHasRight('EditParts') && LockActivate('Parts',$PartId))
|
||||
{
|
||||
include "./pages/show_part_edit_package.php";
|
||||
}
|
||||
elseif ($ToDo=="EditStorage" && UserHasRight('EditParts') && LockActivate('Parts',$PartId))
|
||||
{
|
||||
include "./pages/show_part_edit_storage.php";
|
||||
}
|
||||
elseif ($ToDo=="EditValues" && UserHasRight('EditParts') && LockActivate('Parts',$PartId))
|
||||
{
|
||||
include "./pages/show_part_edit_values.php";
|
||||
}
|
||||
elseif ($ToDo=="EditDownloads" && UserHasRight('EditParts') && LockActivate('Parts',$PartId))
|
||||
{
|
||||
include "./pages/show_part_edit_downloads.php";
|
||||
}
|
||||
elseif ($ToDo=="DeletePart" && UserHasRight('EditParts') && LockActivate('Parts',$PartId))
|
||||
{
|
||||
include "./pages/show_part_delete_part.php";
|
||||
}
|
||||
else
|
||||
{
|
||||
include "./pages/show_part_show.php";
|
||||
}
|
||||
|
||||
$GlobalContent .= '</div>'."\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageError(LangSpell("SentenceDatabaseError"));
|
||||
ErrorLog("[show_part.php] Part Id '$PartId' not found!");
|
||||
}
|
||||
?>
|
||||
22
pages/show_part_delete_part.php
Executable file
22
pages/show_part_delete_part.php
Executable file
|
|
@ -0,0 +1,22 @@
|
|||
<?php
|
||||
|
||||
if (UserHasRight('EditParts'))
|
||||
{
|
||||
global $GlobalMysqlHandler;
|
||||
global $PartId;
|
||||
global $Part;
|
||||
|
||||
$GlobalContent .= "<h1>".LangSpellHtml('SentenceShureToDeletePart')."</h1>";
|
||||
$GlobalContent .= "<strong>".$Part['Name']."</strong> ".$Part['ShortDesc']."<br><br>\n";
|
||||
$GlobalContent .= '<form action="index.php?Page=PartsByType&ToDo=ToggleTypeSelectorVisibility&SublistId='.$Part['TypeId'].'" method="post">';
|
||||
$GlobalContent .= '<input type="hidden" name="DeletePartId" value="'.$PartId.'">';
|
||||
$GlobalContent .= LangSpellHtml('SentenceShureToDeletePart').': <input type="checkbox" name="DeletePartShure" value="True">';
|
||||
$GlobalContent .= ' <input type="submit" value="'.LangSpellHtml('ButtonProceed').'">';
|
||||
$GlobalContent .= '</form>';
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageError(LangSpell("ScentenceNoUserRights"));
|
||||
}
|
||||
?>
|
||||
63
pages/show_part_edit_downloads.php
Executable file
63
pages/show_part_edit_downloads.php
Executable file
|
|
@ -0,0 +1,63 @@
|
|||
<?php
|
||||
if (UserHasRight('EditParts'))
|
||||
{
|
||||
global $GlobalMysqlHandler;
|
||||
global $PartId;
|
||||
global $Part;
|
||||
global $GlobalDownloadDir;
|
||||
|
||||
//////////////
|
||||
// Value Table
|
||||
|
||||
$GlobalContent .= '<table>';
|
||||
|
||||
$GlobalContent .= '<tr>';
|
||||
$GlobalContent .= '<th></th>';
|
||||
$GlobalContent .= '<th>'.LangSpellHtml('DownloadsName').'</th>';
|
||||
$GlobalContent .= '<th>'.LangSpellHtml('DownloadsPath').'</th>';
|
||||
$GlobalContent .= '<th>'.LangSpellHtml('DownloadsSize').'</th>';
|
||||
$GlobalContent .= '<th>'.LangSpellHtml('DownloadsType').'</th>';
|
||||
$GlobalContent .= '<th>'.LangSpellHtml('ButtonEdit').'</th>';
|
||||
$GlobalContent .= '</tr>';
|
||||
|
||||
$DownloadQuery = "SELECT * FROM `Downloads` WHERE `PartId` = $PartId";
|
||||
$DownloadQuery = mysqli_query($GlobalMysqlHandler, $DownloadQuery);
|
||||
while ($Download = mysqli_fetch_array($DownloadQuery))
|
||||
{
|
||||
$Size="-";
|
||||
if (file_exists($GlobalDownloadDir."/".$Download['Path'])) $Size=sprintf("%.2f",filesize($GlobalDownloadDir."/".$Download['Path'])/(1024*1024))." MB";
|
||||
|
||||
$GlobalContent .= '<form action="index.php?Page=ShowPart&PartId='.$PartId.'&ToDo=EditDownload" method="post">';
|
||||
$GlobalContent .= '<input type="hidden" name="EditDownloadId" value="'.$Download['Id'].'">';
|
||||
$GlobalContent .= '<tr>';
|
||||
$GlobalContent .= '<td>{'.$Download['Id'].'}</td>';
|
||||
$GlobalContent .= '<td><input type="text" name="EditDownloadName" value="'.$Download['Name'].'"></td>';
|
||||
$GlobalContent .= '<td>'.$Download['Path'].'</td>';
|
||||
$GlobalContent .= '<td>'.$Size.'</td>';
|
||||
$GlobalContent .= '<td>'.$Download['Type'].'</td>';
|
||||
$GlobalContent .= '<td>';
|
||||
$GlobalContent .= '<a href="index.php?Page=ShowPart&PartId='.$PartId.'&ToDo=DeleteDownload&DownloadId='.$Download['Id'].'" target="_top">'.OtherGetIcon('Delete',"Button").'</a> ';
|
||||
$GlobalContent .= '<input type="submit" value="'.LangSpellHtml('ButtonSave').'"class="Button">';
|
||||
$GlobalContent .= '</td>';
|
||||
$GlobalContent .= '</tr>';
|
||||
$GlobalContent .= '</form>';
|
||||
}
|
||||
|
||||
|
||||
$GlobalContent .= '<form action="index.php?Page=ShowPart&PartId='.$PartId.'&ToDo=UploadNewDownload" method="post" enctype="multipart/form-data">';
|
||||
$GlobalContent .= '<input type="hidden" name="MAX_FILE_SIZE" value="200000000">';
|
||||
$GlobalContent .= '<tr><td></td>';
|
||||
$GlobalContent .= '<td><input type="text" name="AddNewDownloadName" value=""></td>';
|
||||
$GlobalContent .= '<td><input type="file" name="AddNewDownloadFile" value=""></td>';
|
||||
$GlobalContent .= '<td></td><td></td>';
|
||||
$GlobalContent .= '<td><input type="submit" value="'.LangSpellHtml('ButtonUpload').'"class="Button"></td>';
|
||||
$GlobalContent .= '</tr>';
|
||||
$GlobalContent .= '</form>';
|
||||
|
||||
$GlobalContent .= '</table>';
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageError(LangSpell("ScentenceNoUserRights"));
|
||||
}
|
||||
?>
|
||||
72
pages/show_part_edit_package.php
Executable file
72
pages/show_part_edit_package.php
Executable file
|
|
@ -0,0 +1,72 @@
|
|||
<?php
|
||||
|
||||
$NewPartType = (isset($_POST['NewPartType']))? $_POST['NewPartType']:0;
|
||||
|
||||
function WritePackageList($ParentId, $ParentIsLocked)
|
||||
{
|
||||
global $GlobalMysqlHandler;
|
||||
global $GlobalContent;
|
||||
global $GlobalTemplate;
|
||||
global $EditTypesEditId;
|
||||
global $PartId;
|
||||
global $Part;
|
||||
|
||||
$ListQuery="SELECT * FROM `Packages` WHERE `ParentId` =$ParentId";
|
||||
$ListQuery=mysqli_query($GlobalMysqlHandler, $ListQuery);
|
||||
|
||||
if (!$ParentId || NestedListVisibilityIsSet($ParentId, 'EditPartPackage'))
|
||||
$GlobalContent .= "<ul style=\"display:block;\">\n";
|
||||
else
|
||||
$GlobalContent .= "<ul style=\"display:none;\">\n";
|
||||
|
||||
if (mysqli_num_rows($ListQuery))
|
||||
{
|
||||
while ($ListData=mysqli_fetch_array($ListQuery))
|
||||
{
|
||||
$GlobalContent .= " <li>\n";
|
||||
if (LockIsActive('Types',$ListData['Id']) || $ParentIsLocked)
|
||||
{
|
||||
$GlobalContent .= ' '.OtherGetIcon('LockActive');
|
||||
$ParentIsLocked = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
$GlobalContent .= ' <input type="radio" name="EditPartPackage" value="'.$ListData['Id'].'" '.(($Part['PackageId']==$ListData['Id'])? "checked":"").'>';
|
||||
}
|
||||
$GlobalContent .= " <a href=\"index.php?Page=ShowPart&ToDo=EditPackage&PartId=$PartId&OpenSublistId=".$ListData['Id']."\">".LangStr2Html($ListData['Name'])."</a>";
|
||||
$GlobalContent .= " (".NestedListCountSubElements($ListData['Id'],'Packages').")";
|
||||
$GlobalContent .= " \n</li>\n";
|
||||
|
||||
WritePackageList($ListData['Id'],$ParentIsLocked);
|
||||
}
|
||||
}
|
||||
$GlobalContent .= "</ul>\n";
|
||||
}
|
||||
|
||||
|
||||
if (UserHasRight('EditParts'))
|
||||
{
|
||||
///////////////
|
||||
// open sublist
|
||||
if (isset($_GET['OpenSublistId']) && $_GET['OpenSublistId'])
|
||||
{
|
||||
NestedListVisibilityToggle($_GET['OpenSublistId'], 'EditPartPackage');
|
||||
}
|
||||
else
|
||||
{
|
||||
NestedListVisibilityUnsetAllElements ('EditPartPackage');
|
||||
NestedListVisibilitySetAllParents ($Part['PackageId'], 'EditPartPackage', 'Packages');
|
||||
NestedListVisibilitySet ($Part['PackageId'], 'EditPartPackage');
|
||||
}
|
||||
|
||||
$GlobalContent .= '<h1>'.LangSpellHtml('SentencePleaseSelectPackage').'</h1>';
|
||||
$GlobalContent .= '<form action="index.php?Page=ShowPart&ToDo=SavePackage&PartId='.$PartId.'" method="post">';
|
||||
WritePackageList(0, 0);
|
||||
$GlobalContent .= '<input type="submit" value="'.LangSpellHtml('ButtonSave').'"class="Button">';
|
||||
$GlobalContent .= '</form>';
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageError(LangSpell("ScentenceNoUserRights"));
|
||||
}
|
||||
?>
|
||||
72
pages/show_part_edit_storage.php
Executable file
72
pages/show_part_edit_storage.php
Executable file
|
|
@ -0,0 +1,72 @@
|
|||
<?php
|
||||
|
||||
$NewPartType = (isset($_POST['NewPartType']))? $_POST['NewPartType']:0;
|
||||
|
||||
function WriteStorageList($ParentId, $ParentIsLocked)
|
||||
{
|
||||
global $GlobalMysqlHandler;
|
||||
global $GlobalContent;
|
||||
global $GlobalTemplate;
|
||||
global $EditTypesEditId;
|
||||
global $PartId;
|
||||
global $Part;
|
||||
|
||||
$ListQuery="SELECT * FROM `Storages` WHERE `ParentId` =$ParentId";
|
||||
$ListQuery=mysqli_query($GlobalMysqlHandler, $ListQuery);
|
||||
|
||||
if (!$ParentId || NestedListVisibilityIsSet($ParentId, 'EditPartStorage'))
|
||||
$GlobalContent .= "<ul style=\"display:block;\">\n";
|
||||
else
|
||||
$GlobalContent .= "<ul style=\"display:none;\">\n";
|
||||
|
||||
if (mysqli_num_rows($ListQuery))
|
||||
{
|
||||
while ($ListData=mysqli_fetch_array($ListQuery))
|
||||
{
|
||||
$GlobalContent .= " <li>\n";
|
||||
if (LockIsActive('Types',$ListData['Id']) || $ParentIsLocked)
|
||||
{
|
||||
$GlobalContent .= ' '.OtherGetIcon('LockActive');
|
||||
$ParentIsLocked = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
$GlobalContent .= ' <input type="radio" name="EditPartStorage" value="'.$ListData['Id'].'" '.(($Part['StorageId']==$ListData['Id'])? "checked":"").'>';
|
||||
}
|
||||
$GlobalContent .= " <a href=\"index.php?Page=ShowPart&ToDo=EditStorage&PartId=$PartId&OpenSublistId=".$ListData['Id']."\">".LangStr2Html($ListData['Name'])."</a>";
|
||||
$GlobalContent .= " (".NestedListCountSubElements($ListData['Id'],'Storages').")";
|
||||
$GlobalContent .= " \n</li>\n";
|
||||
|
||||
WriteStorageList($ListData['Id'],$ParentIsLocked);
|
||||
}
|
||||
}
|
||||
$GlobalContent .= "</ul>\n";
|
||||
}
|
||||
|
||||
|
||||
if (UserHasRight('EditParts'))
|
||||
{
|
||||
///////////////
|
||||
// open sublist
|
||||
if (isset($_GET['OpenSublistId']) && $_GET['OpenSublistId'])
|
||||
{
|
||||
NestedListVisibilityToggle($_GET['OpenSublistId'], 'EditPartStorage');
|
||||
}
|
||||
else
|
||||
{
|
||||
NestedListVisibilityUnsetAllElements ('EditPartStorage');
|
||||
NestedListVisibilitySetAllParents ($Part['StorageId'], 'EditPartStorage', 'Storages');
|
||||
NestedListVisibilitySet ($Part['StorageId'], 'EditPartStorage');
|
||||
}
|
||||
|
||||
$GlobalContent .= '<h1>'.LangSpellHtml('SentencePleaseSelectPartStorage').'</h1>';
|
||||
$GlobalContent .= '<form action="index.php?Page=ShowPart&ToDo=SaveStorage&PartId='.$PartId.'" method="post">';
|
||||
WriteStorageList(0, 0);
|
||||
$GlobalContent .= '<input type="submit" value="'.LangSpellHtml('ButtonSave').'"class="Button">';
|
||||
$GlobalContent .= '</form>';
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageError(LangSpell("ScentenceNoUserRights"));
|
||||
}
|
||||
?>
|
||||
74
pages/show_part_edit_type.php
Executable file
74
pages/show_part_edit_type.php
Executable file
|
|
@ -0,0 +1,74 @@
|
|||
<?php
|
||||
|
||||
function WriteTypeList($ParentId, $ParentIsLocked)
|
||||
{
|
||||
global $GlobalMysqlHandler;
|
||||
global $GlobalContent;
|
||||
global $GlobalTemplate;
|
||||
global $EditTypesEditId;
|
||||
global $PartId;
|
||||
global $Part;
|
||||
|
||||
$ListQuery="SELECT * FROM `Types` WHERE `ParentId` =$ParentId";
|
||||
$ListQuery=mysqli_query($GlobalMysqlHandler, $ListQuery);
|
||||
|
||||
if (!$ParentId || NestedListVisibilityIsSet($ParentId, 'EditPartType'))
|
||||
$GlobalContent .= "<ul style=\"display:block;\">\n";
|
||||
else
|
||||
$GlobalContent .= "<ul style=\"display:none;\">\n";
|
||||
|
||||
if (mysqli_num_rows($ListQuery))
|
||||
{
|
||||
while ($ListData=mysqli_fetch_array($ListQuery))
|
||||
{
|
||||
$GlobalContent .= " <li>\n";
|
||||
if (LockIsActive('Types',$ListData['Id']) || $ParentIsLocked)
|
||||
{
|
||||
$GlobalContent .= ' '.OtherGetIcon('LockActive.png');
|
||||
$ParentIsLocked = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
$GlobalContent .= ' <input type="radio" name="EditPartType" value="'.$ListData['Id'].'" '.(($Part['TypeId']==$ListData['Id'])? "checked":"").'>';
|
||||
}
|
||||
$GlobalContent .= " <a href=\"index.php?Page=ShowPart&ToDo=EditType&PartId=$PartId&OpenSublistId=".$ListData['Id']."\">".LangStr2Html($ListData['Name']);
|
||||
if (strlen($ListData['ShortName'])) $GlobalContent .= " [".LangStr2Html($ListData['ShortName'])."]";
|
||||
$GlobalContent .= "</a>";
|
||||
$GlobalContent .= " (".NestedListCountSubElements($ListData['Id'],'Types').")";
|
||||
$GlobalContent .= " \n</li>\n";
|
||||
|
||||
WriteTypeList($ListData['Id'],$ParentIsLocked);
|
||||
}
|
||||
}
|
||||
$GlobalContent .= "</ul>\n";
|
||||
}
|
||||
|
||||
|
||||
if (UserHasRight('EditParts'))
|
||||
{
|
||||
///////////////
|
||||
// open sublist
|
||||
if (isset($_GET['OpenSublistId']) && $_GET['OpenSublistId'])
|
||||
{
|
||||
NestedListVisibilityToggle($_GET['OpenSublistId'], 'EditPartType');
|
||||
}
|
||||
else
|
||||
{
|
||||
NestedListVisibilityUnsetAllElements ('EditPartType');
|
||||
NestedListVisibilitySetAllParents ($Part['TypeId'], 'EditPartType', 'Types');
|
||||
NestedListVisibilitySet ($Part['TypeId'], 'EditPartType');
|
||||
}
|
||||
|
||||
//////////
|
||||
// Content
|
||||
$GlobalContent .= '<h1>'.LangSpellHtml('SentencePleaseSelectPartType').'</h1>';
|
||||
$GlobalContent .= '<form action="index.php?Page=ShowPart&ToDo=SaveType&PartId='.$PartId.'" method="post">';
|
||||
WriteTypeList(0, 0);
|
||||
$GlobalContent .= '<input type="submit" value="'.LangSpellHtml('ButtonSave').'"class="Button">';
|
||||
$GlobalContent .= '</form>';
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageError(LangSpell("ScentenceNoUserRights"));
|
||||
}
|
||||
?>
|
||||
119
pages/show_part_edit_values.php
Executable file
119
pages/show_part_edit_values.php
Executable file
|
|
@ -0,0 +1,119 @@
|
|||
<?php
|
||||
|
||||
if (UserHasRight('EditParts'))
|
||||
{
|
||||
global $GlobalMysqlHandler;
|
||||
global $PartId;
|
||||
global $Part;
|
||||
|
||||
/////////////
|
||||
// Type Array
|
||||
$TypeQuery = "SELECT * FROM `Types` WHERE `Id` = ".$Part['TypeId'];
|
||||
$TypeQuery = mysqli_query($GlobalMysqlHandler, $TypeQuery);
|
||||
$TypeValues = array();
|
||||
if (mysqli_num_rows($TypeQuery))
|
||||
{
|
||||
$TypeItem = mysqli_fetch_array($TypeQuery);
|
||||
$TypeValues[0][0] = $TypeItem['NameValue1'];
|
||||
$TypeValues[0][1] = $TypeItem['UnitValue1'];
|
||||
$TypeValues[1][0] = $TypeItem['NameValue2'];
|
||||
$TypeValues[1][1] = $TypeItem['UnitValue2'];
|
||||
$TypeValues[2][0] = $TypeItem['NameValue3'];
|
||||
$TypeValues[2][1] = $TypeItem['UnitValue3'];
|
||||
}
|
||||
|
||||
//////////////
|
||||
// Value Table
|
||||
|
||||
$GlobalContent .= '<h1>'.LangSpellHtml('SentencePleaseSpecifyPartValues').'</h1>';
|
||||
$GlobalContent .= '<form action="index.php?Page=ShowPart&PartId='.$PartId.'&ToDo=SaveValues" method="post">';
|
||||
$GlobalContent .= '<table>';
|
||||
|
||||
$GlobalContent .= '<tr><th>'.LangSpellHtml('PartsObsolete').'</th><td>';
|
||||
$GlobalContent .= '<input type="checkbox" name="EditValuesObsolete" value="TRUE" '.((strtolower($Part['Obsolete'])=="true")? "checked":"").'"></td></tr>';
|
||||
|
||||
$GlobalContent .= '<tr><th>'.LangSpellHtml('PartsName').'</th><td>';
|
||||
$GlobalContent .= '<input type="text" name="EditValuesName" value="'.$Part['Name'].'"></td></tr>';
|
||||
|
||||
$GlobalContent .= '<tr><td></td><td></td></tr>';
|
||||
|
||||
if ($TypeValues[0][0])
|
||||
{
|
||||
$GlobalContent .= '<tr><th>'.$TypeValues[0][0].'</th><td>';
|
||||
$GlobalContent .= '<input type="text" name="EditValuesValue1" value="'.$Part['Value1'].'"></td>';
|
||||
$GlobalContent .= '<td> '.$TypeValues[0][1].'</td></tr>';
|
||||
}
|
||||
|
||||
if ($TypeValues[1][0])
|
||||
{
|
||||
$GlobalContent .= '<tr><th>'.$TypeValues[1][0].'</th><td>';
|
||||
$GlobalContent .= '<input type="text" name="EditValuesValue2" value="'.$Part['Value2'].'"></td>';
|
||||
$GlobalContent .= '<td> '.$TypeValues[1][1].'</td></tr>';
|
||||
}
|
||||
|
||||
if ($TypeValues[2][0])
|
||||
{
|
||||
$GlobalContent .= '<tr><th>'.$TypeValues[2][0].'</th><td>';
|
||||
$GlobalContent .= '<input type="text" name="EditValuesValue3" value="'.$Part['Value3'].'"></td>';
|
||||
$GlobalContent .= '<td> '.$TypeValues[2][1].'</td></tr>';
|
||||
}
|
||||
|
||||
$GlobalContent .= '<tr><td></td><td></td></tr>';
|
||||
|
||||
$GlobalContent .= '<tr><th>'.LangSpellHtml('PartsShortDescription').'</th><td>';
|
||||
$GlobalContent .= '<input type="text" name="EditValuesShortDesc" value="'.$Part['ShortDesc'].'"></td></tr>';
|
||||
|
||||
$GlobalContent .= '<tr><th>'.LangSpellHtml('PartsLongDescription').'</th><td>';
|
||||
$GlobalContent .= '<textarea name="EditValuesLongDesc">'.$Part['LongDesc'].'</textarea></td></tr>';
|
||||
|
||||
$GlobalContent .= '<tr><td></td><td></td></tr>';
|
||||
|
||||
$GlobalContent .= '<tr><th>'.LangSpellHtml('PartsQuantity').'</th><td>';
|
||||
$GlobalContent .= '<input type="text" name="EditValuesQty" value="'.$Part['Qty'].'"></td></tr>';
|
||||
|
||||
$GlobalContent .= '<tr><th>'.LangSpellHtml('PartsMinQuantity').'</th><td>';
|
||||
$GlobalContent .= '<input type="text" name="EditValuesMinQty" value="'.$Part['MinQty'].'"></td></tr>';
|
||||
|
||||
$GlobalContent .= '<tr><td></td><td></td></tr>';
|
||||
|
||||
$GlobalContent .= '<tr><th>'.LangSpellHtml('PartsPackageUnit').'</th><td>';
|
||||
$GlobalContent .= '<input type="text" name="EditValuesPackageUnit" value="'.$Part['PackageUnit'].'"></td></tr>';
|
||||
|
||||
$GlobalContent .= '<tr><th>'.LangSpellHtml('PartsMinOrderQuantity').'</th><td>';
|
||||
$GlobalContent .= '<input type="text" name="EditValuesMinOrderQty" value="'.$Part['MinOrderQty'].'"></td></tr>';
|
||||
|
||||
$GlobalContent .= '<tr><th>'.LangSpellHtml('PartsPrice').'</th><td>';
|
||||
$GlobalContent .= '<input type="text" name="EditValuesPrice" value="'.OtherFormatPrice($Part['Price']).'"></td></tr>';
|
||||
|
||||
$GlobalContent .= '<tr><td></td><td></td></tr>';
|
||||
|
||||
$GlobalContent .= '<tr><th>'.LangSpellHtml('PartsVendor').'</th><td>';
|
||||
$GlobalContent .= '<select name="EditValuesVendor">';
|
||||
$VendorQuery = "SELECT `Id`,`Name` FROM `Vendors` ORDER BY `Name` ASC";
|
||||
$GlobalContent .= '<option value="0">'.LangSpellHtml('PartsNotSpecified').'</option>';
|
||||
$VendorQuery = mysqli_query($GlobalMysqlHandler, $VendorQuery);
|
||||
while ($VendorData = mysqli_fetch_array($VendorQuery))
|
||||
{
|
||||
$Selected = ($Part['VendorId']==$VendorData['Id'])? "selected":"";
|
||||
$GlobalContent .= '<option value="'.$VendorData['Id'].'" '.$Selected.'>'.$VendorData['Name'].'</option>';
|
||||
}
|
||||
$GlobalContent .= '</select></td></tr>';
|
||||
|
||||
$GlobalContent .= '<tr><th>'.LangSpellHtml('PartsVendorLink').'</th><td>';
|
||||
$GlobalContent .= '<input type="text" name="NewPartVedorLink" value="'.$Part['VendorLink'].'"></td></tr>';
|
||||
|
||||
$GlobalContent .= '<tr><th>'.LangSpellHtml('PartsManufactorLink').'</th><td>';
|
||||
$GlobalContent .= '<input type="text" name="NewPartManufactorLink" value="'.$Part['ManufactorLink'].'"></td></tr>';
|
||||
|
||||
$GlobalContent .= '<tr><th></th><td>';
|
||||
$GlobalContent .= '<input type="submit" value="'.LangSpellHtml('ButtonSave').'"class="Button">';
|
||||
$GlobalContent .= '</td></tr>';
|
||||
|
||||
$GlobalContent .= '</table>';
|
||||
$GlobalContent .= '</form>';
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageError(LangSpell("ScentenceNoUserRights"));
|
||||
}
|
||||
?>
|
||||
178
pages/show_part_show.php
Executable file
178
pages/show_part_show.php
Executable file
|
|
@ -0,0 +1,178 @@
|
|||
<?php
|
||||
|
||||
global $GlobalMysqlHandler;
|
||||
|
||||
|
||||
/////////////////////////////
|
||||
// Type, Package, Store, Name
|
||||
$GlobalContent .= '<div id="ShowPartHead">'."\n";
|
||||
//Part Head
|
||||
$GlobalContent .= '<h1>{'.$Part['Id'].'} '.$Part['Name'].'</h1>'."\n";
|
||||
//Type
|
||||
$TypeId = $Part['TypeId'];
|
||||
$TypeString = "";
|
||||
while ($TypeId)
|
||||
{
|
||||
$LocalTypeString = "";
|
||||
$LocalTypeString = NestedListGetName($TypeId,'Types');
|
||||
$LocalTypeString = '<a href="index.php?Page=PartsByType&ToDo=ToggleTypeSelectorVisibility&SublistId='.$TypeId.'" target="_top">'.$LocalTypeString . "</a>";
|
||||
$TypeId = NestedListGetParentId ($TypeId,'Types');
|
||||
if ($TypeId) $LocalTypeString = " > " . $LocalTypeString;
|
||||
$TypeString = $LocalTypeString . $TypeString;
|
||||
}
|
||||
$GlobalContent .= '<strong>'.LangSpellHtml('PartsType').":</strong> ".$TypeString."<br>"."\n";
|
||||
//Storage
|
||||
$StorageId = $Part['StorageId'];
|
||||
$StorageString = "";
|
||||
while ($StorageId)
|
||||
{
|
||||
$LocalStorageString = "";
|
||||
$LocalStorageString = NestedListGetName($StorageId,'Storages');
|
||||
$LocalStorageString = '<a href="index.php?Page=PartsByStore&ToDo=ToggleTypeSelectorVisibility&SublistId='.$StorageId.'" target="_top">'.$LocalStorageString . "</a>";
|
||||
$StorageId = NestedListGetParentId ($StorageId,'Storages');
|
||||
if ($StorageId) $LocalStorageString = " > " . $LocalStorageString;
|
||||
$StorageString = $LocalStorageString . $StorageString;
|
||||
}
|
||||
$GlobalContent .= '<strong>'.LangSpellHtml('PartsStorage').":</strong> ".$StorageString."<br>"."\n";
|
||||
//Package
|
||||
$PackageId = $Part['PackageId'];
|
||||
$PackageString = "";
|
||||
while ($PackageId)
|
||||
{
|
||||
$LocalPackageString = "";
|
||||
$LocalPackageString = NestedListGetName($PackageId,'Packages');
|
||||
$PackageId = NestedListGetParentId ($PackageId,'Packages');
|
||||
if ($PackageId) $LocalPackageString = " > " . $LocalPackageString;
|
||||
$PackageString = $LocalPackageString . $PackageString;
|
||||
}
|
||||
$GlobalContent .= '<strong>'.LangSpellHtml('PartsPackage').":</strong> ".$PackageString."<br>"."\n";
|
||||
//Edit Button
|
||||
if (UserHasRight('EditParts'))
|
||||
{
|
||||
if (LockIsActive('Parts',$PartId))
|
||||
{
|
||||
$GlobalContent .= '<strong>'.LangSpellHtml('ButtonEdit').':</strong> ';
|
||||
$GlobalContent .= OtherGetIcon('LockActive')."\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
$GlobalContent .= '<strong>'.LangSpellHtml('ButtonEdit').':</strong> '."\n";
|
||||
$GlobalContent .= '<a href="index.php?Page=ShowPart&PartId='.$PartId.'&ToDo=EditType" target="_top" class="Button">'.LangSpellHtml('PartsType').'</a> '."\n";
|
||||
$GlobalContent .= '<a href="index.php?Page=ShowPart&PartId='.$PartId.'&ToDo=EditPackage" target="_top" class="Button">'.LangSpellHtml('PartsPackage').'</a> '."\n";
|
||||
$GlobalContent .= '<a href="index.php?Page=ShowPart&PartId='.$PartId.'&ToDo=EditStorage" target="_top" class="Button">'.LangSpellHtml('PartsStorage').'</a> '."\n";
|
||||
$GlobalContent .= '<a href="index.php?Page=ShowPart&PartId='.$PartId.'&ToDo=EditValues" target="_top" class="Button">'.LangSpellHtml('PartsValues').'</a> '."\n";
|
||||
$GlobalContent .= '<a href="index.php?Page=ShowPart&PartId='.$PartId.'&ToDo=EditDownloads" target="_top" class="Button">'.LangSpellHtml('PartsDownloads').'</a> '."\n";
|
||||
$GlobalContent .= '<a href="index.php?Page=ShowPart&PartId='.$PartId.'&ToDo=EditPicture" target="_top" class="Button">'.LangSpellHtml('PartsPicture').'</a> '."\n";
|
||||
$GlobalContent .= '<a href="index.php?Page=ShowPart&PartId='.$PartId.'&ToDo=DeletePart" target="_top" title="'.LangSpellHtml('TagTitleDelete').'">'.OtherGetIcon('Delete',"Button").'</a> '."\n";
|
||||
}
|
||||
}
|
||||
$GlobalContent .= '</div>'."\n";
|
||||
|
||||
///////////
|
||||
// Pictures
|
||||
$GlobalContent .= '<div id="ShowPartPictures" style="float:left;">'."\n";
|
||||
if ($ToDo=="EditPicture" && UserHasRight('EditParts') && LockActivate('Parts',$PartId))
|
||||
{
|
||||
$GlobalContent .= '<form action="index.php?Page=ShowPart&PartId='.$PartId.'&ToDo=UploadNewPicture" method="post" enctype="multipart/form-data">';
|
||||
$GlobalContent .= '<input type="hidden" name="MAX_FILE_SIZE" value="1000000">';
|
||||
$GlobalContent .= '<input type="file" name="NewPictureFile" value="">';
|
||||
$GlobalContent .= '<input type="submit" value="'.LangSpellHtml('ButtonUpload').'"class="Button">';
|
||||
$GlobalContent .= '</form><br>';
|
||||
}
|
||||
$GlobalContent .= '<img src="'.$GlobalPictureDir.'/'.$Part['PicturePath'].'"><br><br>';
|
||||
echo "IMAGE: " . $Part['PicturePath'] . "<br>\n";
|
||||
$GlobalContent .= '</div>'."\n";
|
||||
|
||||
////////////////
|
||||
// Detail Values
|
||||
$GlobalContent .= '<div id="ShowPartValues" style="float:left; margin-left:10px;">'."\n";
|
||||
$GlobalContent .= '<table>';
|
||||
//Obsolete
|
||||
if (strtolower($Part['Obsolete'])=="true")
|
||||
$GlobalContent .= ' <tr><td colspan="2"><strong>'.LangSpellHtml('PartsObsolete').'</strong></td></tr>';
|
||||
//Value1
|
||||
if ($TypeValues[0][0])
|
||||
$GlobalContent .= ' <tr><th>'.$TypeValues[0][0].'</th><td>'.OtherFloatToSiPrefix($Part['Value1']).$TypeValues[0][1].'</td></tr>';
|
||||
//Value2
|
||||
if ($TypeValues[1][0])
|
||||
$GlobalContent .= ' <tr><th>'.$TypeValues[1][0].'</th><td>'.OtherFloatToSiPrefix($Part['Value2']).$TypeValues[1][1].'</td></tr>';
|
||||
//Value3
|
||||
if ($TypeValues[2][0])
|
||||
$GlobalContent .= ' <tr><th>'.$TypeValues[2][0].'</th><td>'.OtherFloatToSiPrefix($Part['Value3']).$TypeValues[2][1].'</td></tr>';
|
||||
//Empty Row
|
||||
$GlobalContent .= ' <tr><td></td><td></td></tr>';
|
||||
|
||||
//Quantity
|
||||
if (UserHasRight('EditParts') || UserHasRight('EditPartQuantity'))
|
||||
{
|
||||
$GlobalContent .= ' <tr><th>'.LangSpellHtml('PartsQuantity').'</th><td>';
|
||||
$GlobalContent .= '<form action="index.php?Page=ShowPart&PartId='.$PartId.'&ToDo=SaveNewQuantity" method="post">';
|
||||
$GlobalContent .= '<input type="text" name="NewQuantity" value="'.$Part['Qty'].'"> ';
|
||||
$GlobalContent .= '<input type="submit" value="'.LangSpellHtml('ButtonEdit').'" class="Button"></td></tr>';
|
||||
}
|
||||
else
|
||||
{
|
||||
$GlobalContent .= ' <tr><th>'.LangSpellHtml('PartsQuantity').'</th><td>'.$Part['Qty'].'</td></tr>';
|
||||
}
|
||||
//Minimum Quantity
|
||||
$GlobalContent .= ' <tr><th>'.LangSpellHtml('PartsMinQuantity').'</th><td>'.$Part['MinQty'].'</td></tr>';
|
||||
//Empty Row
|
||||
$GlobalContent .= ' <tr><td></td><td></td></tr>';
|
||||
|
||||
//Package Unit
|
||||
$GlobalContent .= ' <tr><th>'.LangSpellHtml('PartsPackageUnit').'</th><td>'.$Part['PackageUnit'].'</td></tr>';
|
||||
//Min Order Quantity
|
||||
$GlobalContent .= ' <tr><th>'.LangSpellHtml('PartsMinOrderQuantity').'</th><td>'.$Part['MinOrderQty'].'</td></tr>';
|
||||
//Price
|
||||
$GlobalContent .= ' <tr><th>'.LangSpellHtml('PartsPrice').'</th><td>'.OtherFormatPrice($Part['Price']).'</td></tr>';
|
||||
//Vendor
|
||||
$VendorQuery = "SELECT `Name` FROM `Vendors` WHERE `Id`= ".$Part['VendorId'];
|
||||
$VendorQuery = mysqli_query($GlobalMysqlHandler, $VendorQuery);
|
||||
if (mysqli_num_rows($VendorQuery))
|
||||
{
|
||||
$Vendor=mysqli_fetch_array($VendorQuery);
|
||||
$GlobalContent .= ' <tr><th>'.LangSpellHtml('PartsVendor').'</th><td>'.$Vendor['Name'].'</td></tr>';
|
||||
}
|
||||
else
|
||||
{
|
||||
$GlobalContent .= ' <tr><th>'.LangSpellHtml('PartsVendor').'</th><td>-</td></tr>';
|
||||
}
|
||||
//Vendor Link
|
||||
$GlobalContent .= ' <tr><th>'.LangSpellHtml('PartsVendorLink').'</th><td>';
|
||||
if ($Part['VendorLink']) $GlobalContent .= '<a href="'.$Part['VendorLink'].'" target="_new">';
|
||||
$GlobalContent .= substr($Part['VendorLink'],0,(strlen($Part['VendorLink'])<=20)? strlen($Part['VendorLink']):20);
|
||||
if ($Part['VendorLink']) $GlobalContent .= '</a>';
|
||||
$GlobalContent .= '</td></tr>';
|
||||
//Manufactor
|
||||
$GlobalContent .= ' <tr><th>'.LangSpellHtml('PartsManufactorLink').'</th><td>';
|
||||
if ($Part['ManufactorLink']) $GlobalContent .= '<a href="'.$Part['ManufactorLink'].'" target="_new">';
|
||||
$GlobalContent .= substr($Part['ManufactorLink'],0,(strlen($Part['ManufactorLink'])<=20)? strlen($Part['ManufactorLink']):20);
|
||||
if ($Part['ManufactorLink']) $GlobalContent .= '</a>';
|
||||
$GlobalContent .= '</td></tr>';
|
||||
//End
|
||||
$GlobalContent .= '</table>';
|
||||
$GlobalContent .= '</div>'."\n";
|
||||
|
||||
/////////////////////////
|
||||
// Description, Downloads
|
||||
$GlobalContent .= '<div id="ShowPartDownloads" style="clear:both;">'."\n";
|
||||
$GlobalContent .= LangStr2Html($Part['ShortDesc']).'<br><br>';
|
||||
$GlobalContent .= LangStr2Html($Part['LongDesc']).'<br><br>';
|
||||
$GlobalContent .= '<strong>'.LangSpellHtml('PartsDownloads').':</strong>'."\n<ul>";
|
||||
$DownloadQuery = "SELECT * FROM `Downloads` WHERE `PartId` = $PartId";
|
||||
$DownloadQuery = mysqli_query($GlobalMysqlHandler, $DownloadQuery);
|
||||
while ($Download = mysqli_fetch_array($DownloadQuery))
|
||||
{
|
||||
$Size="-";
|
||||
$FileExist = (file_exists($GlobalDownloadDir."/".$Download['Path']))? 1:0;
|
||||
if ($FileExist) $Size=sprintf("%.2f",filesize($GlobalDownloadDir."/".$Download['Path'])/(1024*1024))." MB";
|
||||
|
||||
$GlobalContent .= "<li>";
|
||||
if ($FileExist) $GlobalContent .= '<a href="'.$GlobalDownloadDir."/".$Download['Path'].'">';
|
||||
$GlobalContent .= $Download['Name']." (".$Size.")";
|
||||
if ($FileExist) $GlobalContent .= '</a>';
|
||||
$GlobalContent .= "</li>";
|
||||
}
|
||||
$GlobalContent .= '</ul></div>'."\n";
|
||||
|
||||
?>
|
||||
121
pages/user_settings.php
Executable file
121
pages/user_settings.php
Executable file
|
|
@ -0,0 +1,121 @@
|
|||
<?php
|
||||
|
||||
if (UserGetLogin() && UserGetLogin()!="root")
|
||||
{
|
||||
//////////////////
|
||||
//global content
|
||||
if ($ToDo=="SaveSettings")
|
||||
{
|
||||
//get vars
|
||||
$Login = (isset($_POST['Login'])) ? $_POST['Login']:"";
|
||||
$Password1 = (isset($_POST['Password1']))? $_POST['Password1']:"";
|
||||
$Password2 = (isset($_POST['Password2']))? $_POST['Password2']:"";
|
||||
$Language = (isset($_POST['Language'])) ? $_POST['Language']:"";
|
||||
($Template = (isset($_POST['Template'])) ? $_POST['Template']:"");
|
||||
|
||||
//check vars
|
||||
$Error=0;
|
||||
$UserExistQuery="SELECT * FROM `User` WHERE `Login` LIKE '$Login' AND `Id` != '$Id'";
|
||||
$UserExistQuery=mysqli_query($GlobalMysqlHandler, $UserExistQuery);
|
||||
if ($Login=="" || $Login=="root" || mysqli_num_rows($UserExistQuery))
|
||||
{
|
||||
$Error=1;
|
||||
MessageError(LangSpell('SentenceLoginForbidden'));
|
||||
}
|
||||
if ( ($Password1!=$Password2) || (trim($Password1)!=$Password1) )
|
||||
{
|
||||
$Error=1;
|
||||
MessageError(LangSpell('SentencePasswordForbidden'));
|
||||
}
|
||||
|
||||
if (!$Error)
|
||||
{
|
||||
$UpdateQuery="UPDATE `User` SET `Login` = '$Login'".(($Password1) ? ", `Password` = '".md5($Password1)."'":"").", `Template` = '$Template', `Language` = '$Language' WHERE `User`.`Id` =".UserGetId()." LIMIT 1 ;";
|
||||
if (!mysqli_query($GlobalMysqlHandler, $UpdateQuery))
|
||||
{
|
||||
ErrorLog("[user_settings.php] Database error while update User table at Id = $Id!");
|
||||
MessageError(LangSpell('SentenceDatabaseError'));
|
||||
$Error=1;
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageSuccess(LangSpell('SentenceUserUpdated'));
|
||||
if (trim($Password1)!="")
|
||||
{
|
||||
MessageWarning(LangSpell('SentencePasswordChangedWarning'));
|
||||
}
|
||||
}
|
||||
}
|
||||
UserLoadSettings();
|
||||
}
|
||||
|
||||
//////////////////
|
||||
//global content
|
||||
$UserQuery="SELECT * FROM `User` WHERE `Id` = ".UserGetId();
|
||||
$UserQuery=mysqli_query($GlobalMysqlHandler, $UserQuery);
|
||||
$UserRecord=mysqli_fetch_array($UserQuery);
|
||||
|
||||
$GlobalContent .= '<form action="index.php?Page=UserSettings&ToDo=SaveSettings" method="post">'."\n";
|
||||
$GlobalContent .= '<table>'."\n";
|
||||
|
||||
$GlobalContent .= ' <tr>'."\n";
|
||||
$GlobalContent .= ' <th colspan="2">'.LangSpellHtml('UserSettingsTableHead').'</th>'."\n";
|
||||
$GlobalContent .= ' </tr>'."\n";
|
||||
|
||||
$GlobalContent .= ' <tr>'."\n";
|
||||
$GlobalContent .= ' <th>Id</th>'."\n";
|
||||
$GlobalContent .= ' <td>'.$UserRecord['Id'].'</td>'."\n";
|
||||
$GlobalContent .= ' </tr>'."\n";
|
||||
|
||||
$GlobalContent .= ' <tr>'."\n";
|
||||
$GlobalContent .= ' <th>'.LangSpellHtml('MenuLogin').'</th>'."\n";
|
||||
$GlobalContent .= ' <td><input type="text" name="Login" value="'.$UserRecord['Login'].'" title="'.LangSpellHtml('TagTitleEditUserLogin').'"></td>'."\n";
|
||||
$GlobalContent .= ' </tr>'."\n";
|
||||
|
||||
$GlobalContent .= ' <tr>'."\n";
|
||||
$GlobalContent .= ' <th>'.LangSpellHtml('UserSettingsSetNewPassword').'</th>'."\n";
|
||||
$GlobalContent .= ' <td><input type="password" name="Password1" value="" title="'.LangSpellHtml('TagTitleEditUserPassword').'"></td>'."\n";
|
||||
$GlobalContent .= ' </tr>'."\n";
|
||||
|
||||
$GlobalContent .= ' <tr>'."\n";
|
||||
$GlobalContent .= ' <th>'.LangSpellHtml('UserSettingsConfirmNewPassword').'</th>'."\n";
|
||||
$GlobalContent .= ' <td><input type="password" name="Password2" value="" title="'.LangSpellHtml('TagTitleEditUserPassword').'"></td>'."\n";
|
||||
$GlobalContent .= ' </tr>'."\n";
|
||||
|
||||
$GlobalContent .= ' <tr>'."\n";
|
||||
$GlobalContent .= ' <th>'.LangSpellHtml('UserSettingsLanguage').'</th>'."\n";
|
||||
$GlobalContent .= ' <td><select name="Language" size="1">'."\n";
|
||||
$GlobalContent .= ' <option value="">'.LangSpellHtml('UserSettingsDefault').'</option>'."\n";
|
||||
$LanguageArray=LangGetAvailableLanguages();
|
||||
foreach ($LanguageArray as $Language)
|
||||
{
|
||||
$GlobalContent .= ' <option value="'.$Language.'" '.(($UserRecord['Language']==$Language)? "selected":"").'>'.$Language.'</option>'."\n";
|
||||
}
|
||||
$GlobalContent .= ' </select></td>'."\n";
|
||||
$GlobalContent .= ' </tr>'."\n";
|
||||
|
||||
$GlobalContent .= ' <tr>'."\n";
|
||||
$GlobalContent .= ' <th>'.LangSpellHtml('UserSettingsTemplate').'</th>'."\n";
|
||||
$GlobalContent .= ' <td><select name="Template" size="1">'."\n";
|
||||
$GlobalContent .= ' <option value="">'.LangSpellHtml('UserSettingsDefault').'</option>'."\n";
|
||||
$TemplateArray=OtherGetAvailableTemplates();
|
||||
foreach ($TemplateArray as $Template)
|
||||
{
|
||||
$GlobalContent .= ' <option value="'.$Template.'" '.(($UserRecord['Template']==$Template)? "selected":"").'>'.$Template.'</option>'."\n";
|
||||
}
|
||||
$GlobalContent .= ' </select></td>'."\n";
|
||||
$GlobalContent .= ' </tr>'."\n";
|
||||
|
||||
$GlobalContent .= ' <tr>'."\n";
|
||||
$GlobalContent .= ' <th> </th>'."\n";
|
||||
$GlobalContent .= ' <td><input type="submit" value="'.LangSpellHtml('ButtonSave').'" class="Button"></td>'."\n";
|
||||
$GlobalContent .= ' </tr>'."\n";
|
||||
|
||||
$GlobalContent .= '</table>'."\n";
|
||||
$GlobalContent .= '</form>'."\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageError(LangSpell("ScentenceNoUserRights"));
|
||||
}
|
||||
?>
|
||||
66
pages/version_history.php
Executable file
66
pages/version_history.php
Executable file
|
|
@ -0,0 +1,66 @@
|
|||
<?php
|
||||
$GlobalContent .='<ul>'."\n";
|
||||
$GlobalContent .=' <li>'."\n";
|
||||
$GlobalContent .=' Version 0'."\n";
|
||||
$GlobalContent .=' <ul>'."\n";
|
||||
$GlobalContent .=' <li>'."\n";
|
||||
$GlobalContent .=' Subversion 5'."\n";
|
||||
$GlobalContent .=' <ul>'."\n";
|
||||
$GlobalContent .=' <li>2010-11-11 Consistency check - repair incorrect parts type, Guide download (only german DeveloperGuide.pdf at this stage).</li>'."\n";
|
||||
$GlobalContent .=' <li>2010-11-10 Repeat order list, creating only one ErrorLog() out of LogShort() and LogLong().</li>'."\n";
|
||||
$GlobalContent .=' <li>2010-11-09 OtherGetIcon() for better icon control.</li>'."\n";
|
||||
$GlobalContent .=' <li>2010-11-05 Changed milestones, building helpsection as last milestone.</li>'."\n";
|
||||
$GlobalContent .=' <li>2010-11-05 Milestone 3 reached, gradation to subversion 5.</li>'."\n";
|
||||
$GlobalContent .=' </ul>'."\n";
|
||||
$GlobalContent .=' </li>'."\n";
|
||||
$GlobalContent .=' <li>'."\n";
|
||||
$GlobalContent .=' Subversion 4'."\n";
|
||||
$GlobalContent .=' <ul>'."\n";
|
||||
$GlobalContent .=' <li>2010-11-05 Consistency check - create database structure - ready for first testing.</li>'."\n";
|
||||
$GlobalContent .=' <li>2010-11-04 Handling downloads and parts picture, parts by store view.</li>'."\n";
|
||||
$GlobalContent .=' <li>2010-11-03 View and edit part (type, package, store and values).</li>'."\n";
|
||||
$GlobalContent .=' <li>2010-11-02 Adding new parts is possible, first partlist view (parts by type.</li>'."\n";
|
||||
$GlobalContent .=' <li>2010-10-04 Added ViewSTPV Rights.</li>'."\n";
|
||||
$GlobalContent .=' <li>2010-09-20 Milestone 2 reached, gradation to subversion 4.</li>'."\n";
|
||||
$GlobalContent .=' </ul>'."\n";
|
||||
$GlobalContent .=' </li>'."\n";
|
||||
$GlobalContent .=' <li>'."\n";
|
||||
$GlobalContent .=' Subversion 3'."\n";
|
||||
$GlobalContent .=' <ul>'."\n";
|
||||
$GlobalContent .=' <li>2010-09-20 Edit Stores, Types and packages.</li>'."\n";
|
||||
$GlobalContent .=' <li>2010-09-08 Add new stores, delete stores.</li>'."\n";
|
||||
$GlobalContent .=' <li>2010-08-31 Vendor editing.</li>'."\n";
|
||||
$GlobalContent .=' <li>2010-08-26 Milestone 1 reached, gradation to subversion 3.</li>'."\n";
|
||||
$GlobalContent .=' </ul>'."\n";
|
||||
$GlobalContent .=' </li>'."\n";
|
||||
$GlobalContent .=' <li>'."\n";
|
||||
$GlobalContent .=' Subversion 2'."\n";
|
||||
$GlobalContent .=' <ul>'."\n";
|
||||
$GlobalContent .=' <li>2010-08-26 Config editing.</li>'."\n";
|
||||
$GlobalContent .=' <li>2010-08-17 User settings.</li>'."\n";
|
||||
$GlobalContent .=' <li>2010-08-16 User management.</li>'."\n";
|
||||
$GlobalContent .=' <li>2010-08-15 Definition of milestones.'."\n";
|
||||
$GlobalContent .=' <ol>'."\n";
|
||||
$GlobalContent .=' <li>Basic system administration (config editing, user management, user settings).</li>'."\n";
|
||||
$GlobalContent .=' <li>Part administration (stores, types, vendors, packages).</li>'."\n";
|
||||
$GlobalContent .=' <li>Parts handling (view, edit, add, downloads, pictures).</li>'."\n";
|
||||
$GlobalContent .=' <li>Tools (repeat order, stats, check).</li>'."\n";
|
||||
$GlobalContent .=' <li>Global test by creating own partstock.</li>'."\n";
|
||||
$GlobalContent .=' <li>Build final Templates. Guide for publishing.</li>'."\n";
|
||||
$GlobalContent .=' <li>Help section / User Guides.</li>'."\n";
|
||||
$GlobalContent .=' </ol>'."\n";
|
||||
$GlobalContent .=' </li>'."\n";
|
||||
$GlobalContent .=' <li>2010-08-14 Creation of the Version History</li>'."\n";
|
||||
$GlobalContent .=' <li>before: Basic system like template design, login functionality, language functionality, message logging, etc.</li>'."\n";
|
||||
$GlobalContent .=' </ul>'."\n";
|
||||
$GlobalContent .=' </li>'."\n";
|
||||
$GlobalContent .=' <li>'."\n";
|
||||
$GlobalContent .=' Subversion 1'."\n";
|
||||
$GlobalContent .=' <ul>'."\n";
|
||||
$GlobalContent .=' <li>A simple GUI for to the database (some primary testings).</li>'."\n";
|
||||
$GlobalContent .=' </ul>'."\n";
|
||||
$GlobalContent .=' </li>'."\n";
|
||||
$GlobalContent .=' </ul>'."\n";
|
||||
$GlobalContent .=' </li>'."\n";
|
||||
$GlobalContent .='</ul>'."\n";
|
||||
?>
|
||||
Loading…
Add table
Add a link
Reference in a new issue