Exemplo n.º 1
0
 function AddRow($rsold = NULL)
 {
     global $conn, $Language, $Security;
     // Load db values from rsold
     if ($rsold) {
         $this->LoadDbValues($rsold);
         $this->g_image->OldUploadPath = "/gallery";
         $this->g_image->UploadPath = $this->g_image->OldUploadPath;
         $this->gd_images->OldUploadPath = "/gallery";
         $this->gd_images->UploadPath = $this->gd_images->OldUploadPath;
     }
     $rsnew = array();
     // g_name
     $this->g_name->SetDbValueDef($rsnew, $this->g_name->CurrentValue, "", FALSE);
     // g_image
     if (!$this->g_image->Upload->KeepFile) {
         if ($this->g_image->Upload->FileName == "") {
             $rsnew['g_image'] = NULL;
         } else {
             $rsnew['g_image'] = $this->g_image->Upload->FileName;
         }
     }
     // gd_images
     if (!$this->gd_images->Upload->KeepFile) {
         if ($this->gd_images->Upload->FileName == "") {
             $rsnew['gd_images'] = NULL;
         } else {
             $rsnew['gd_images'] = $this->gd_images->Upload->FileName;
         }
     }
     if (!$this->g_image->Upload->KeepFile) {
         $this->g_image->UploadPath = "/gallery";
         if (!ew_Empty($this->g_image->Upload->Value)) {
             $rsnew['g_image'] = ew_UploadFileNameEx(ew_UploadPathEx(TRUE, $this->g_image->UploadPath), $rsnew['g_image']);
             // Get new file name
         }
     }
     if (!$this->gd_images->Upload->KeepFile) {
         $this->gd_images->UploadPath = "/gallery";
         $OldFiles = explode(",", $this->gd_images->Upload->DbValue);
         if (!ew_Empty($this->gd_images->Upload->FileName)) {
             $NewFiles = explode(",", $this->gd_images->Upload->FileName);
             $FileCount = count($NewFiles);
             for ($i = 0; $i < $FileCount; $i++) {
                 $fldvar = $this->gd_images->Upload->Index < 0 ? $this->gd_images->FldVar : substr($this->gd_images->FldVar, 0, 1) . $this->gd_images->Upload->Index . substr($this->gd_images->FldVar, 1);
                 if ($NewFiles[$i] != "") {
                     $file = ew_UploadTempPath($fldvar) . EW_PATH_DELIMITER . $NewFiles[$i];
                     if (file_exists($file)) {
                         if (!in_array($NewFiles[$i], $OldFiles)) {
                             $NewFiles[$i] = ew_UploadFileNameEx(ew_UploadPathEx(TRUE, $this->gd_images->UploadPath), $NewFiles[$i]);
                             // Get new file name
                             $file1 = ew_UploadTempPath($fldvar) . EW_PATH_DELIMITER . $NewFiles[$i];
                             if ($file1 != $file) {
                                 // Rename temp file
                                 rename($file, $file1);
                             }
                         }
                     }
                 }
             }
             $this->gd_images->Upload->FileName = implode(",", $NewFiles);
             $rsnew['gd_images'] = $this->gd_images->Upload->FileName;
         } else {
             $NewFiles = array();
         }
     }
     // Call Row Inserting event
     $rs = $rsold == NULL ? NULL : $rsold->fields;
     $bInsertRow = $this->Row_Inserting($rs, $rsnew);
     if ($bInsertRow) {
         $conn->raiseErrorFn = 'ew_ErrorFn';
         $AddRow = $this->Insert($rsnew);
         $conn->raiseErrorFn = '';
         if ($AddRow) {
             if (!$this->g_image->Upload->KeepFile) {
                 if (!ew_Empty($this->g_image->Upload->Value)) {
                     $this->g_image->Upload->SaveToFile($this->g_image->UploadPath, $rsnew['g_image'], TRUE);
                 }
             }
             if (!$this->gd_images->Upload->KeepFile) {
                 $OldFiles = explode(",", $this->gd_images->Upload->DbValue);
                 if (!ew_Empty($this->gd_images->Upload->FileName)) {
                     $NewFiles = explode(",", $this->gd_images->Upload->FileName);
                     $NewFiles2 = explode(",", $rsnew['gd_images']);
                     $FileCount = count($NewFiles);
                     for ($i = 0; $i < $FileCount; $i++) {
                         $fldvar = $this->gd_images->Upload->Index < 0 ? $this->gd_images->FldVar : substr($this->gd_images->FldVar, 0, 1) . $this->gd_images->Upload->Index . substr($this->gd_images->FldVar, 1);
                         if ($NewFiles[$i] != "") {
                             $file = ew_UploadTempPath($fldvar) . EW_PATH_DELIMITER . $NewFiles[$i];
                             if (file_exists($file)) {
                                 $this->gd_images->Upload->Value = file_get_contents($file);
                                 $this->gd_images->Upload->SaveToFile($this->gd_images->UploadPath, @$NewFiles2[$i] != "" ? $NewFiles2[$i] : $NewFiles[$i], TRUE);
                                 // Just replace
                             }
                         }
                     }
                 } else {
                     $NewFiles = array();
                 }
             }
         }
     } else {
         if ($this->getSuccessMessage() != "" || $this->getFailureMessage() != "") {
             // Use the message, do nothing
         } elseif ($this->CancelMessage != "") {
             $this->setFailureMessage($this->CancelMessage);
             $this->CancelMessage = "";
         } else {
             $this->setFailureMessage($Language->Phrase("InsertCancelled"));
         }
         $AddRow = FALSE;
     }
     // Get insert id if necessary
     if ($AddRow) {
         $this->gd_id->setDbValue($conn->Insert_ID());
         $rsnew['gd_id'] = $this->gd_id->DbValue;
     }
     if ($AddRow) {
         // Call Row Inserted event
         $rs = $rsold == NULL ? NULL : $rsold->fields;
         $this->Row_Inserted($rs, $rsnew);
     }
     // g_image
     ew_CleanUploadTempPath($this->g_image, $this->g_image->Upload->Index);
     // gd_images
     ew_CleanUploadTempPath($this->gd_images, $this->gd_images->Upload->Index);
     return $AddRow;
 }
Exemplo n.º 2
0
 function SaveToFile($Path, $NewFileName, $OverWrite)
 {
     if (!ew_Empty($this->Value)) {
         $Path = ew_UploadPathEx(TRUE, $Path);
         if (trim(strval($NewFileName)) == "") {
             $NewFileName = $this->FileName;
         }
         if ($OverWrite) {
             return ew_SaveFile($Path, $NewFileName, $this->Value);
         } else {
             return ew_SaveFile($Path, ew_UploadFileNameEx($Path, $NewFileName), $this->Value);
         }
     }
     return FALSE;
 }
Exemplo n.º 3
0
 function EditRow()
 {
     global $conn, $Security, $Language;
     $sFilter = $this->KeyFilter();
     $this->CurrentFilter = $sFilter;
     $sSql = $this->SQL();
     $conn->raiseErrorFn = 'ew_ErrorFn';
     $rs = $conn->Execute($sSql);
     $conn->raiseErrorFn = '';
     if ($rs === FALSE) {
         return FALSE;
     }
     if ($rs->EOF) {
         $EditRow = FALSE;
         // Update Failed
     } else {
         // Begin transaction
         if ($this->getCurrentDetailTable() != "") {
             $conn->BeginTrans();
         }
         // Save old values
         $rsold =& $rs->fields;
         $this->LoadDbValues($rsold);
         $rsnew = array();
         // Titulo
         $this->Titulo->SetDbValueDef($rsnew, $this->Titulo->CurrentValue, NULL, $this->Titulo->ReadOnly);
         // Descripcion
         $this->Descripcion->SetDbValueDef($rsnew, $this->Descripcion->CurrentValue, NULL, $this->Descripcion->ReadOnly);
         // archivo
         if (!$this->archivo->ReadOnly && !$this->archivo->Upload->KeepFile) {
             $this->archivo->Upload->DbValue = $rsold['archivo'];
             // Get original value
             if ($this->archivo->Upload->FileName == "") {
                 $rsnew['archivo'] = NULL;
             } else {
                 $rsnew['archivo'] = $this->archivo->Upload->FileName;
             }
         }
         // estado
         $this->estado->SetDbValueDef($rsnew, $this->estado->CurrentValue, NULL, $this->estado->ReadOnly);
         if (!$this->archivo->Upload->KeepFile) {
             $OldFiles = explode(EW_MULTIPLE_UPLOAD_SEPARATOR, $this->archivo->Upload->DbValue);
             if (!ew_Empty($this->archivo->Upload->FileName)) {
                 $NewFiles = explode(EW_MULTIPLE_UPLOAD_SEPARATOR, $this->archivo->Upload->FileName);
                 $FileCount = count($NewFiles);
                 for ($i = 0; $i < $FileCount; $i++) {
                     $fldvar = $this->archivo->Upload->Index < 0 ? $this->archivo->FldVar : substr($this->archivo->FldVar, 0, 1) . $this->archivo->Upload->Index . substr($this->archivo->FldVar, 1);
                     if ($NewFiles[$i] != "") {
                         $file = $NewFiles[$i];
                         if (file_exists(ew_UploadTempPath($fldvar) . EW_PATH_DELIMITER . $file)) {
                             if (!in_array($file, $OldFiles)) {
                                 $file1 = ew_UploadFileNameEx(ew_UploadPathEx(TRUE, $this->archivo->UploadPath), $file);
                                 // Get new file name
                                 if ($file1 != $file) {
                                     // Rename temp file
                                     while (file_exists(ew_UploadTempPath($fldvar) . EW_PATH_DELIMITER . $file1)) {
                                         // Make sure did not clash with existing upload file
                                         $file1 = ew_UniqueFilename(ew_UploadPathEx(TRUE, $this->archivo->UploadPath), $file1, TRUE);
                                     }
                                     // Use indexed name
                                     rename(ew_UploadTempPath($fldvar) . EW_PATH_DELIMITER . $file, ew_UploadTempPath($fldvar) . EW_PATH_DELIMITER . $file1);
                                     $NewFiles[$i] = $file1;
                                 }
                             }
                         }
                     }
                 }
                 $this->archivo->Upload->FileName = implode(EW_MULTIPLE_UPLOAD_SEPARATOR, $NewFiles);
                 $rsnew['archivo'] = $this->archivo->Upload->FileName;
             } else {
                 $NewFiles = array();
             }
         }
         // Call Row Updating event
         $bUpdateRow = $this->Row_Updating($rsold, $rsnew);
         if ($bUpdateRow) {
             $conn->raiseErrorFn = 'ew_ErrorFn';
             if (count($rsnew) > 0) {
                 $EditRow = $this->Update($rsnew, "", $rsold);
             } else {
                 $EditRow = TRUE;
             }
             // No field to update
             $conn->raiseErrorFn = '';
             if ($EditRow) {
                 if (!$this->archivo->Upload->KeepFile) {
                     $OldFiles = explode(EW_MULTIPLE_UPLOAD_SEPARATOR, $this->archivo->Upload->DbValue);
                     if (!ew_Empty($this->archivo->Upload->FileName)) {
                         $NewFiles = explode(EW_MULTIPLE_UPLOAD_SEPARATOR, $this->archivo->Upload->FileName);
                         $NewFiles2 = explode(EW_MULTIPLE_UPLOAD_SEPARATOR, $rsnew['archivo']);
                         $FileCount = count($NewFiles);
                         for ($i = 0; $i < $FileCount; $i++) {
                             $fldvar = $this->archivo->Upload->Index < 0 ? $this->archivo->FldVar : substr($this->archivo->FldVar, 0, 1) . $this->archivo->Upload->Index . substr($this->archivo->FldVar, 1);
                             if ($NewFiles[$i] != "") {
                                 $file = ew_UploadTempPath($fldvar) . EW_PATH_DELIMITER . $NewFiles[$i];
                                 if (file_exists($file)) {
                                     $this->archivo->Upload->SaveToFile($this->archivo->UploadPath, @$NewFiles2[$i] != "" ? $NewFiles2[$i] : $NewFiles[$i], TRUE, $i);
                                     // Just replace
                                 }
                             }
                         }
                     } else {
                         $NewFiles = array();
                     }
                     $FileCount = count($OldFiles);
                     for ($i = 0; $i < $FileCount; $i++) {
                         if ($OldFiles[$i] != "" && !in_array($OldFiles[$i], $NewFiles)) {
                             @unlink(ew_UploadPathEx(TRUE, $this->archivo->OldUploadPath) . $OldFiles[$i]);
                         }
                     }
                 }
             }
             // Update detail records
             if ($EditRow) {
                 $DetailTblVar = explode(",", $this->getCurrentDetailTable());
                 if (in_array("seguimiento_tramites", $DetailTblVar) && $GLOBALS["seguimiento_tramites"]->DetailEdit) {
                     if (!isset($GLOBALS["seguimiento_tramites_grid"])) {
                         $GLOBALS["seguimiento_tramites_grid"] = new cseguimiento_tramites_grid();
                     }
                     // Get detail page object
                     $EditRow = $GLOBALS["seguimiento_tramites_grid"]->GridUpdate();
                 }
             }
             // Commit/Rollback transaction
             if ($this->getCurrentDetailTable() != "") {
                 if ($EditRow) {
                     $conn->CommitTrans();
                     // Commit transaction
                 } else {
                     $conn->RollbackTrans();
                     // Rollback transaction
                 }
             }
         } else {
             if ($this->getSuccessMessage() != "" || $this->getFailureMessage() != "") {
                 // Use the message, do nothing
             } elseif ($this->CancelMessage != "") {
                 $this->setFailureMessage($this->CancelMessage);
                 $this->CancelMessage = "";
             } else {
                 $this->setFailureMessage($Language->Phrase("UpdateCancelled"));
             }
             $EditRow = FALSE;
         }
     }
     // Call Row_Updated event
     if ($EditRow) {
         $this->Row_Updated($rsold, $rsnew);
     }
     $rs->Close();
     // archivo
     ew_CleanUploadTempPath($this->archivo, $this->archivo->Upload->Index);
     return $EditRow;
 }
Exemplo n.º 4
0
 function AddRow($rsold = NULL)
 {
     global $conn, $Language, $Security;
     // Load db values from rsold
     if ($rsold) {
         $this->LoadDbValues($rsold);
         $this->g_image->OldUploadPath = "/gallery";
         $this->g_image->UploadPath = $this->g_image->OldUploadPath;
         $this->gd_images->OldUploadPath = "/gallery";
         $this->gd_images->UploadPath = $this->gd_images->OldUploadPath;
     }
     $rsnew = array();
     // g_name
     $this->g_name->SetDbValueDef($rsnew, $this->g_name->CurrentValue, "", FALSE);
     // g_image
     if (!$this->g_image->Upload->KeepFile) {
         if ($this->g_image->Upload->FileName == "") {
             $rsnew['g_image'] = NULL;
         } else {
             $rsnew['g_image'] = $this->g_image->Upload->FileName;
         }
     }
     if (!$this->g_image->Upload->KeepFile) {
         $this->g_image->UploadPath = "/gallery";
         if (!ew_Empty($this->g_image->Upload->Value)) {
             $rsnew['g_image'] = ew_UploadFileNameEx(ew_UploadPathEx(TRUE, $this->g_image->UploadPath), $rsnew['g_image']);
             // Get new file name
         }
     }
     // Call Row Inserting event
     $rs = $rsold == NULL ? NULL : $rsold->fields;
     $bInsertRow = $this->Row_Inserting($rs, $rsnew);
     if ($bInsertRow) {
         $conn->raiseErrorFn = 'ew_ErrorFn';
         $AddRow = $this->Insert($rsnew);
         $conn->raiseErrorFn = '';
         if ($AddRow) {
             if (!$this->g_image->Upload->KeepFile) {
                 if (!ew_Empty($this->g_image->Upload->Value)) {
                     $this->g_image->Upload->SaveToFile($this->g_image->UploadPath, $rsnew['g_image'], TRUE);
                 }
             }
         }
     } else {
         if ($this->getSuccessMessage() != "" || $this->getFailureMessage() != "") {
             // Use the message, do nothing
         } elseif ($this->CancelMessage != "") {
             $this->setFailureMessage($this->CancelMessage);
             $this->CancelMessage = "";
         } else {
             $this->setFailureMessage($Language->Phrase("InsertCancelled"));
         }
         $AddRow = FALSE;
     }
     // Get insert id if necessary
     if ($AddRow) {
         $this->gd_id->setDbValue($conn->Insert_ID());
         $rsnew['gd_id'] = $this->gd_id->DbValue;
     }
     if ($AddRow) {
         // Call Row Inserted event
         $rs = $rsold == NULL ? NULL : $rsold->fields;
         $this->Row_Inserted($rs, $rsnew);
     }
     // g_image
     ew_CleanUploadTempPath($this->g_image, $this->g_image->Upload->Index);
     return $AddRow;
 }
Exemplo n.º 5
0
 function SaveToFile($Path, $NewFileName, $OverWrite, $idx = -1)
 {
     if (!ew_Empty($this->Value)) {
         $Path = ew_UploadPathEx(TRUE, $Path);
         if (trim(strval($NewFileName)) == "") {
             $NewFileName = $this->FileName;
         }
         if (!$OverWrite) {
             $NewFileName = ew_UploadFileNameEx($Path, $NewFileName);
         }
         return ew_SaveFile($Path, $NewFileName, $this->Value);
     } elseif ($idx >= 0) {
         // Use file from upload temp folder
         $file = $this->GetTempFile($idx);
         if (file_exists($file)) {
             if (!$OverWrite) {
                 $NewFileName = ew_UploadFileNameEx($Path, $NewFileName);
             }
             return ew_CopyFile($Path, $NewFileName, $file);
         }
     }
     return FALSE;
 }
Exemplo n.º 6
0
 function EditRow()
 {
     global $Security, $Language;
     $sFilter = $this->KeyFilter();
     $sFilter = $this->ApplyUserIDFilters($sFilter);
     $conn =& $this->Connection();
     $this->CurrentFilter = $sFilter;
     $sSql = $this->SQL();
     $conn->raiseErrorFn = $GLOBALS["EW_ERROR_FN"];
     $rs = $conn->Execute($sSql);
     $conn->raiseErrorFn = '';
     if ($rs === FALSE) {
         return FALSE;
     }
     if ($rs->EOF) {
         $this->setFailureMessage($Language->Phrase("NoRecord"));
         // Set no record message
         $EditRow = FALSE;
         // Update Failed
     } else {
         // Save old values
         $rsold =& $rs->fields;
         $this->LoadDbValues($rsold);
         $this->s_image->OldUploadPath = "/uploads/";
         $this->s_image->UploadPath = $this->s_image->OldUploadPath;
         $this->s_images->OldUploadPath = "/uploads/";
         $this->s_images->UploadPath = $this->s_images->OldUploadPath;
         $rsnew = array();
         // s_title
         $this->s_title->SetDbValueDef($rsnew, $this->s_title->CurrentValue, "", $this->s_title->ReadOnly);
         // s_image
         if (!$this->s_image->ReadOnly && !$this->s_image->Upload->KeepFile) {
             $this->s_image->Upload->DbValue = $rsold['s_image'];
             // Get original value
             if ($this->s_image->Upload->FileName == "") {
                 $rsnew['s_image'] = NULL;
             } else {
                 $rsnew['s_image'] = $this->s_image->Upload->FileName;
             }
         }
         // s_desc
         $this->s_desc->SetDbValueDef($rsnew, $this->s_desc->CurrentValue, "", $this->s_desc->ReadOnly);
         // s_longdesc
         $this->s_longdesc->SetDbValueDef($rsnew, $this->s_longdesc->CurrentValue, "", $this->s_longdesc->ReadOnly);
         // s_images
         if (!$this->s_images->ReadOnly && !$this->s_images->Upload->KeepFile) {
             $this->s_images->Upload->DbValue = $rsold['s_images'];
             // Get original value
             if ($this->s_images->Upload->FileName == "") {
                 $rsnew['s_images'] = NULL;
             } else {
                 $rsnew['s_images'] = $this->s_images->Upload->FileName;
             }
         }
         // s_caption
         $this->s_caption->SetDbValueDef($rsnew, $this->s_caption->CurrentValue, "", $this->s_caption->ReadOnly);
         if (!$this->s_image->Upload->KeepFile) {
             $this->s_image->UploadPath = "/uploads/";
             if (!ew_Empty($this->s_image->Upload->Value)) {
                 $rsnew['s_image'] = ew_UploadFileNameEx(ew_UploadPathEx(TRUE, $this->s_image->UploadPath), $rsnew['s_image']);
                 // Get new file name
             }
         }
         if (!$this->s_images->Upload->KeepFile) {
             $this->s_images->UploadPath = "/uploads/";
             $OldFiles = explode(EW_MULTIPLE_UPLOAD_SEPARATOR, $this->s_images->Upload->DbValue);
             if (!ew_Empty($this->s_images->Upload->FileName)) {
                 $NewFiles = explode(EW_MULTIPLE_UPLOAD_SEPARATOR, $this->s_images->Upload->FileName);
                 $FileCount = count($NewFiles);
                 for ($i = 0; $i < $FileCount; $i++) {
                     $fldvar = $this->s_images->Upload->Index < 0 ? $this->s_images->FldVar : substr($this->s_images->FldVar, 0, 1) . $this->s_images->Upload->Index . substr($this->s_images->FldVar, 1);
                     if ($NewFiles[$i] != "") {
                         $file = $NewFiles[$i];
                         if (file_exists(ew_UploadTempPath($fldvar, $this->s_images->TblVar) . EW_PATH_DELIMITER . $file)) {
                             if (!in_array($file, $OldFiles)) {
                                 $file1 = ew_UploadFileNameEx(ew_UploadPathEx(TRUE, $this->s_images->UploadPath), $file);
                                 // Get new file name
                                 if ($file1 != $file) {
                                     // Rename temp file
                                     while (file_exists(ew_UploadTempPath($fldvar, $this->s_images->TblVar) . EW_PATH_DELIMITER . $file1)) {
                                         // Make sure did not clash with existing upload file
                                         $file1 = ew_UniqueFilename(ew_UploadPathEx(TRUE, $this->s_images->UploadPath), $file1, TRUE);
                                     }
                                     // Use indexed name
                                     rename(ew_UploadTempPath($fldvar, $this->s_images->TblVar) . EW_PATH_DELIMITER . $file, ew_UploadTempPath($fldvar, $this->s_images->TblVar) . EW_PATH_DELIMITER . $file1);
                                     $NewFiles[$i] = $file1;
                                 }
                             }
                         }
                     }
                 }
                 $this->s_images->Upload->FileName = implode(EW_MULTIPLE_UPLOAD_SEPARATOR, $NewFiles);
                 $rsnew['s_images'] = $this->s_images->Upload->FileName;
             } else {
                 $NewFiles = array();
             }
         }
         // Call Row Updating event
         $bUpdateRow = $this->Row_Updating($rsold, $rsnew);
         if ($bUpdateRow) {
             $conn->raiseErrorFn = $GLOBALS["EW_ERROR_FN"];
             if (count($rsnew) > 0) {
                 $EditRow = $this->Update($rsnew, "", $rsold);
             } else {
                 $EditRow = TRUE;
             }
             // No field to update
             $conn->raiseErrorFn = '';
             if ($EditRow) {
                 if (!$this->s_image->Upload->KeepFile) {
                     if (!ew_Empty($this->s_image->Upload->Value)) {
                         $this->s_image->Upload->SaveToFile($this->s_image->UploadPath, $rsnew['s_image'], TRUE);
                     }
                 }
                 if (!$this->s_images->Upload->KeepFile) {
                     $OldFiles = explode(EW_MULTIPLE_UPLOAD_SEPARATOR, $this->s_images->Upload->DbValue);
                     if (!ew_Empty($this->s_images->Upload->FileName)) {
                         $NewFiles = explode(EW_MULTIPLE_UPLOAD_SEPARATOR, $this->s_images->Upload->FileName);
                         $NewFiles2 = explode(EW_MULTIPLE_UPLOAD_SEPARATOR, $rsnew['s_images']);
                         $FileCount = count($NewFiles);
                         for ($i = 0; $i < $FileCount; $i++) {
                             $fldvar = $this->s_images->Upload->Index < 0 ? $this->s_images->FldVar : substr($this->s_images->FldVar, 0, 1) . $this->s_images->Upload->Index . substr($this->s_images->FldVar, 1);
                             if ($NewFiles[$i] != "") {
                                 $file = ew_UploadTempPath($fldvar, $this->s_images->TblVar) . EW_PATH_DELIMITER . $NewFiles[$i];
                                 if (file_exists($file)) {
                                     $this->s_images->Upload->SaveToFile($this->s_images->UploadPath, @$NewFiles2[$i] != "" ? $NewFiles2[$i] : $NewFiles[$i], TRUE, $i);
                                     // Just replace
                                 }
                             }
                         }
                     } else {
                         $NewFiles = array();
                     }
                 }
             }
         } else {
             if ($this->getSuccessMessage() != "" || $this->getFailureMessage() != "") {
                 // Use the message, do nothing
             } elseif ($this->CancelMessage != "") {
                 $this->setFailureMessage($this->CancelMessage);
                 $this->CancelMessage = "";
             } else {
                 $this->setFailureMessage($Language->Phrase("UpdateCancelled"));
             }
             $EditRow = FALSE;
         }
     }
     // Call Row_Updated event
     if ($EditRow) {
         $this->Row_Updated($rsold, $rsnew);
     }
     $rs->Close();
     // s_image
     ew_CleanUploadTempPath($this->s_image, $this->s_image->Upload->Index);
     // s_images
     ew_CleanUploadTempPath($this->s_images, $this->s_images->Upload->Index);
     return $EditRow;
 }
Exemplo n.º 7
0
 function EditRow()
 {
     global $conn, $Security, $Language;
     $sFilter = $this->KeyFilter();
     $this->CurrentFilter = $sFilter;
     $sSql = $this->SQL();
     $conn->raiseErrorFn = 'ew_ErrorFn';
     $rs = $conn->Execute($sSql);
     $conn->raiseErrorFn = '';
     if ($rs === FALSE) {
         return FALSE;
     }
     if ($rs->EOF) {
         $EditRow = FALSE;
         // Update Failed
     } else {
         // Save old values
         $rsold =& $rs->fields;
         $this->LoadDbValues($rsold);
         $rsnew = array();
         // fecha_recepcion
         $this->fecha_recepcion->SetDbValueDef($rsnew, ew_UnFormatDateTime($this->fecha_recepcion->CurrentValue, 7), ew_CurrentDate(), $this->fecha_recepcion->ReadOnly);
         // cliente
         $this->cliente->SetDbValueDef($rsnew, $this->cliente->CurrentValue, NULL, $this->cliente->ReadOnly);
         // id_tipo_cliente
         $this->id_tipo_cliente->SetDbValueDef($rsnew, $this->id_tipo_cliente->CurrentValue, NULL, $this->id_tipo_cliente->ReadOnly);
         // tel
         $this->tel->SetDbValueDef($rsnew, $this->tel->CurrentValue, NULL, $this->tel->ReadOnly);
         // cel
         $this->cel->SetDbValueDef($rsnew, $this->cel->CurrentValue, NULL, $this->cel->ReadOnly);
         // objetos
         $this->objetos->SetDbValueDef($rsnew, $this->objetos->CurrentValue, NULL, $this->objetos->ReadOnly);
         // detalle_a_realizar
         $this->detalle_a_realizar->SetDbValueDef($rsnew, $this->detalle_a_realizar->CurrentValue, NULL, $this->detalle_a_realizar->ReadOnly);
         // fecha_entrega
         $this->fecha_entrega->SetDbValueDef($rsnew, ew_UnFormatDateTime($this->fecha_entrega->CurrentValue, 7), NULL, $this->fecha_entrega->ReadOnly);
         // observaciones
         $this->observaciones->SetDbValueDef($rsnew, $this->observaciones->CurrentValue, NULL, $this->observaciones->ReadOnly);
         // id_estado
         $this->id_estado->SetDbValueDef($rsnew, $this->id_estado->CurrentValue, 0, $this->id_estado->ReadOnly);
         // precio
         $this->precio->SetDbValueDef($rsnew, $this->precio->CurrentValue, NULL, $this->precio->ReadOnly);
         // entrega
         $this->entrega->SetDbValueDef($rsnew, $this->entrega->CurrentValue, NULL, $this->entrega->ReadOnly);
         // foto1
         if (!$this->foto1->ReadOnly && !$this->foto1->Upload->KeepFile) {
             $this->foto1->Upload->DbValue = $rs->fields('foto1');
             // Get original value
             if ($this->foto1->Upload->FileName == "") {
                 $rsnew['foto1'] = NULL;
             } else {
                 $rsnew['foto1'] = $this->foto1->Upload->FileName;
             }
         }
         // foto2
         if (!$this->foto2->ReadOnly && !$this->foto2->Upload->KeepFile) {
             $this->foto2->Upload->DbValue = $rs->fields('foto2');
             // Get original value
             if ($this->foto2->Upload->FileName == "") {
                 $rsnew['foto2'] = NULL;
             } else {
                 $rsnew['foto2'] = $this->foto2->Upload->FileName;
             }
         }
         if (!$this->foto1->Upload->KeepFile) {
             if (!ew_Empty($this->foto1->Upload->Value)) {
                 if ($this->foto1->Upload->FileName == $this->foto1->Upload->DbValue) {
                     // Overwrite if same file name
                     $this->foto1->Upload->DbValue = "";
                     // No need to delete any more
                 } else {
                     $rsnew['foto1'] = ew_UploadFileNameEx(ew_UploadPathEx(TRUE, $this->foto1->UploadPath), $rsnew['foto1']);
                     // Get new file name
                 }
             }
         }
         if (!$this->foto2->Upload->KeepFile) {
             if (!ew_Empty($this->foto2->Upload->Value)) {
                 if ($this->foto2->Upload->FileName == $this->foto2->Upload->DbValue) {
                     // Overwrite if same file name
                     $this->foto2->Upload->DbValue = "";
                     // No need to delete any more
                 } else {
                     $rsnew['foto2'] = ew_UploadFileNameEx(ew_UploadPathEx(TRUE, $this->foto2->UploadPath), $rsnew['foto2']);
                     // Get new file name
                 }
             }
         }
         // Call Row Updating event
         $bUpdateRow = $this->Row_Updating($rsold, $rsnew);
         if ($bUpdateRow) {
             $conn->raiseErrorFn = 'ew_ErrorFn';
             if (count($rsnew) > 0) {
                 $EditRow = $this->Update($rsnew, "", $rsold);
             } else {
                 $EditRow = TRUE;
             }
             // No field to update
             $conn->raiseErrorFn = '';
             if ($EditRow) {
                 if (!$this->foto1->Upload->KeepFile) {
                     if (!ew_Empty($this->foto1->Upload->Value)) {
                         $this->foto1->Upload->SaveToFile($this->foto1->UploadPath, $rsnew['foto1'], TRUE);
                     }
                     if ($this->foto1->Upload->DbValue != "") {
                         @unlink(ew_UploadPathEx(TRUE, $this->foto1->OldUploadPath) . $this->foto1->Upload->DbValue);
                     }
                 }
                 if (!$this->foto2->Upload->KeepFile) {
                     if (!ew_Empty($this->foto2->Upload->Value)) {
                         $this->foto2->Upload->SaveToFile($this->foto2->UploadPath, $rsnew['foto2'], TRUE);
                     }
                     if ($this->foto2->Upload->DbValue != "") {
                         @unlink(ew_UploadPathEx(TRUE, $this->foto2->OldUploadPath) . $this->foto2->Upload->DbValue);
                     }
                 }
             }
         } else {
             if ($this->getSuccessMessage() != "" || $this->getFailureMessage() != "") {
                 // Use the message, do nothing
             } elseif ($this->CancelMessage != "") {
                 $this->setFailureMessage($this->CancelMessage);
                 $this->CancelMessage = "";
             } else {
                 $this->setFailureMessage($Language->Phrase("UpdateCancelled"));
             }
             $EditRow = FALSE;
         }
     }
     // Call Row_Updated event
     if ($EditRow) {
         $this->Row_Updated($rsold, $rsnew);
     }
     $rs->Close();
     // foto1
     ew_CleanUploadTempPath($this->foto1, $this->foto1->Upload->Index);
     // foto2
     ew_CleanUploadTempPath($this->foto2, $this->foto2->Upload->Index);
     return $EditRow;
 }
Exemplo n.º 8
0
 function AddRow($rsold = NULL)
 {
     global $conn, $Language, $Security;
     // Load db values from rsold
     if ($rsold) {
         $this->LoadDbValues($rsold);
     }
     $rsnew = array();
     // Titulo
     $this->Titulo->SetDbValueDef($rsnew, $this->Titulo->CurrentValue, NULL, FALSE);
     // fecha
     $this->fecha->SetDbValueDef($rsnew, ew_CurrentDate(), NULL);
     $rsnew['fecha'] =& $this->fecha->DbValue;
     // archivo
     if (!$this->archivo->Upload->KeepFile) {
         $this->archivo->Upload->DbValue = "";
         // No need to delete old file
         if ($this->archivo->Upload->FileName == "") {
             $rsnew['archivo'] = NULL;
         } else {
             $rsnew['archivo'] = $this->archivo->Upload->FileName;
         }
     }
     // estado
     $this->estado->SetDbValueDef($rsnew, $this->estado->CurrentValue, NULL, FALSE);
     if (!$this->archivo->Upload->KeepFile) {
         $OldFiles = explode(EW_MULTIPLE_UPLOAD_SEPARATOR, $this->archivo->Upload->DbValue);
         if (!ew_Empty($this->archivo->Upload->FileName)) {
             $NewFiles = explode(EW_MULTIPLE_UPLOAD_SEPARATOR, $this->archivo->Upload->FileName);
             $FileCount = count($NewFiles);
             for ($i = 0; $i < $FileCount; $i++) {
                 $fldvar = $this->archivo->Upload->Index < 0 ? $this->archivo->FldVar : substr($this->archivo->FldVar, 0, 1) . $this->archivo->Upload->Index . substr($this->archivo->FldVar, 1);
                 if ($NewFiles[$i] != "") {
                     $file = $NewFiles[$i];
                     if (file_exists(ew_UploadTempPath($fldvar) . EW_PATH_DELIMITER . $file)) {
                         if (!in_array($file, $OldFiles)) {
                             $file1 = ew_UploadFileNameEx(ew_UploadPathEx(TRUE, $this->archivo->UploadPath), $file);
                             // Get new file name
                             if ($file1 != $file) {
                                 // Rename temp file
                                 while (file_exists(ew_UploadTempPath($fldvar) . EW_PATH_DELIMITER . $file1)) {
                                     // Make sure did not clash with existing upload file
                                     $file1 = ew_UniqueFilename(ew_UploadPathEx(TRUE, $this->archivo->UploadPath), $file1, TRUE);
                                 }
                                 // Use indexed name
                                 rename(ew_UploadTempPath($fldvar) . EW_PATH_DELIMITER . $file, ew_UploadTempPath($fldvar) . EW_PATH_DELIMITER . $file1);
                                 $NewFiles[$i] = $file1;
                             }
                         }
                     }
                 }
             }
             $this->archivo->Upload->FileName = implode(EW_MULTIPLE_UPLOAD_SEPARATOR, $NewFiles);
             $rsnew['archivo'] = $this->archivo->Upload->FileName;
         } else {
             $NewFiles = array();
         }
     }
     // Call Row Inserting event
     $rs = $rsold == NULL ? NULL : $rsold->fields;
     $bInsertRow = $this->Row_Inserting($rs, $rsnew);
     if ($bInsertRow) {
         $conn->raiseErrorFn = 'ew_ErrorFn';
         $AddRow = $this->Insert($rsnew);
         $conn->raiseErrorFn = '';
         if ($AddRow) {
             if (!$this->archivo->Upload->KeepFile) {
                 $OldFiles = explode(EW_MULTIPLE_UPLOAD_SEPARATOR, $this->archivo->Upload->DbValue);
                 if (!ew_Empty($this->archivo->Upload->FileName)) {
                     $NewFiles = explode(EW_MULTIPLE_UPLOAD_SEPARATOR, $this->archivo->Upload->FileName);
                     $NewFiles2 = explode(EW_MULTIPLE_UPLOAD_SEPARATOR, $rsnew['archivo']);
                     $FileCount = count($NewFiles);
                     for ($i = 0; $i < $FileCount; $i++) {
                         $fldvar = $this->archivo->Upload->Index < 0 ? $this->archivo->FldVar : substr($this->archivo->FldVar, 0, 1) . $this->archivo->Upload->Index . substr($this->archivo->FldVar, 1);
                         if ($NewFiles[$i] != "") {
                             $file = ew_UploadTempPath($fldvar) . EW_PATH_DELIMITER . $NewFiles[$i];
                             if (file_exists($file)) {
                                 $this->archivo->Upload->SaveToFile($this->archivo->UploadPath, @$NewFiles2[$i] != "" ? $NewFiles2[$i] : $NewFiles[$i], TRUE, $i);
                                 // Just replace
                             }
                         }
                     }
                 } else {
                     $NewFiles = array();
                 }
                 $FileCount = count($OldFiles);
                 for ($i = 0; $i < $FileCount; $i++) {
                     if ($OldFiles[$i] != "" && !in_array($OldFiles[$i], $NewFiles)) {
                         @unlink(ew_UploadPathEx(TRUE, $this->archivo->OldUploadPath) . $OldFiles[$i]);
                     }
                 }
             }
         }
     } else {
         if ($this->getSuccessMessage() != "" || $this->getFailureMessage() != "") {
             // Use the message, do nothing
         } elseif ($this->CancelMessage != "") {
             $this->setFailureMessage($this->CancelMessage);
             $this->CancelMessage = "";
         } else {
             $this->setFailureMessage($Language->Phrase("InsertCancelled"));
         }
         $AddRow = FALSE;
     }
     // Get insert id if necessary
     if ($AddRow) {
         $this->codigo->setDbValue($conn->Insert_ID());
         $rsnew['codigo'] = $this->codigo->DbValue;
     }
     if ($AddRow) {
         // Call Row Inserted event
         $rs = $rsold == NULL ? NULL : $rsold->fields;
         $this->Row_Inserted($rs, $rsnew);
     }
     // archivo
     ew_CleanUploadTempPath($this->archivo, $this->archivo->Upload->Index);
     return $AddRow;
 }
Exemplo n.º 9
0
 function AddRow($rsold = NULL)
 {
     global $Language, $Security;
     // Set up foreign key field value from Session
     if ($this->getCurrentMasterTable() == "sub_category") {
         $this->scat_id->CurrentValue = $this->scat_id->getSessionValue();
     }
     $conn =& $this->Connection();
     // Load db values from rsold
     if ($rsold) {
         $this->LoadDbValues($rsold);
     }
     $rsnew = array();
     // category_id
     $this->category_id->SetDbValueDef($rsnew, $this->category_id->CurrentValue, 0, FALSE);
     // scat_id
     $this->scat_id->SetDbValueDef($rsnew, $this->scat_id->CurrentValue, 0, FALSE);
     // product_name
     $this->product_name->SetDbValueDef($rsnew, $this->product_name->CurrentValue, "", FALSE);
     // product_image
     if (!$this->product_image->Upload->KeepFile) {
         $this->product_image->Upload->DbValue = "";
         // No need to delete old file
         if ($this->product_image->Upload->FileName == "") {
             $rsnew['product_image'] = NULL;
         } else {
             $rsnew['product_image'] = $this->product_image->Upload->FileName;
         }
     }
     // product_secimage
     if (!$this->product_secimage->Upload->KeepFile) {
         $this->product_secimage->Upload->DbValue = "";
         // No need to delete old file
         if ($this->product_secimage->Upload->FileName == "") {
             $rsnew['product_secimage'] = NULL;
         } else {
             $rsnew['product_secimage'] = $this->product_secimage->Upload->FileName;
         }
     }
     if (!$this->product_image->Upload->KeepFile) {
         if (!ew_Empty($this->product_image->Upload->Value)) {
             if ($this->product_image->Upload->FileName == $this->product_image->Upload->DbValue) {
                 // Overwrite if same file name
                 $this->product_image->Upload->DbValue = "";
                 // No need to delete any more
             } else {
                 $rsnew['product_image'] = ew_UploadFileNameEx(ew_UploadPathEx(TRUE, $this->product_image->UploadPath), $rsnew['product_image']);
                 // Get new file name
             }
         }
     }
     if (!$this->product_secimage->Upload->KeepFile) {
         if (!ew_Empty($this->product_secimage->Upload->Value)) {
             if ($this->product_secimage->Upload->FileName == $this->product_secimage->Upload->DbValue) {
                 // Overwrite if same file name
                 $this->product_secimage->Upload->DbValue = "";
                 // No need to delete any more
             } else {
                 $rsnew['product_secimage'] = ew_UploadFileNameEx(ew_UploadPathEx(TRUE, $this->product_secimage->UploadPath), $rsnew['product_secimage']);
                 // Get new file name
             }
         }
     }
     // Call Row Inserting event
     $rs = $rsold == NULL ? NULL : $rsold->fields;
     $bInsertRow = $this->Row_Inserting($rs, $rsnew);
     if ($bInsertRow) {
         $conn->raiseErrorFn = $GLOBALS["EW_ERROR_FN"];
         $AddRow = $this->Insert($rsnew);
         $conn->raiseErrorFn = '';
         if ($AddRow) {
             // Get insert id if necessary
             $this->product_id->setDbValue($conn->Insert_ID());
             $rsnew['product_id'] = $this->product_id->DbValue;
             if (!$this->product_image->Upload->KeepFile) {
                 if (!ew_Empty($this->product_image->Upload->Value)) {
                     $this->product_image->Upload->SaveToFile($this->product_image->UploadPath, $rsnew['product_image'], TRUE);
                 }
                 if ($this->product_image->Upload->DbValue != "") {
                     @unlink(ew_UploadPathEx(TRUE, $this->product_image->OldUploadPath) . $this->product_image->Upload->DbValue);
                 }
             }
             if (!$this->product_secimage->Upload->KeepFile) {
                 if (!ew_Empty($this->product_secimage->Upload->Value)) {
                     $this->product_secimage->Upload->SaveToFile($this->product_secimage->UploadPath, $rsnew['product_secimage'], TRUE);
                 }
                 if ($this->product_secimage->Upload->DbValue != "") {
                     @unlink(ew_UploadPathEx(TRUE, $this->product_secimage->OldUploadPath) . $this->product_secimage->Upload->DbValue);
                 }
             }
         }
     } else {
         if ($this->getSuccessMessage() != "" || $this->getFailureMessage() != "") {
             // Use the message, do nothing
         } elseif ($this->CancelMessage != "") {
             $this->setFailureMessage($this->CancelMessage);
             $this->CancelMessage = "";
         } else {
             $this->setFailureMessage($Language->Phrase("InsertCancelled"));
         }
         $AddRow = FALSE;
     }
     if ($AddRow) {
         // Call Row Inserted event
         $rs = $rsold == NULL ? NULL : $rsold->fields;
         $this->Row_Inserted($rs, $rsnew);
     }
     // product_image
     ew_CleanUploadTempPath($this->product_image, $this->product_image->Upload->Index);
     // product_secimage
     ew_CleanUploadTempPath($this->product_secimage, $this->product_secimage->Upload->Index);
     return $AddRow;
 }
Exemplo n.º 10
0
 function EditRow()
 {
     global $conn, $Security, $ItemDetails;
     $sFilter = $ItemDetails->KeyFilter();
     $ItemDetails->CurrentFilter = $sFilter;
     $sSql = $ItemDetails->SQL();
     $conn->raiseErrorFn = 'ew_ErrorFn';
     $rs = $conn->Execute($sSql);
     $conn->raiseErrorFn = '';
     if ($rs === FALSE) {
         return FALSE;
     }
     if ($rs->EOF) {
         $EditRow = FALSE;
         // Update Failed
     } else {
         // Save old values
         $rsold =& $rs->fields;
         $rsnew = array();
         // Field ItemID
         // Field Time_to_Table
         $ItemDetails->Time_to_Table->SetDbValueDef($ItemDetails->Time_to_Table->CurrentValue, NULL);
         $rsnew['Time_to_Table'] =& $ItemDetails->Time_to_Table->DbValue;
         // Field Level_Of_Difficulty
         $ItemDetails->Level_Of_Difficulty->SetDbValueDef($ItemDetails->Level_Of_Difficulty->CurrentValue, NULL);
         $rsnew['Level_Of_Difficulty'] =& $ItemDetails->Level_Of_Difficulty->DbValue;
         // Field Beverage_Pairing
         $ItemDetails->Beverage_Pairing->SetDbValueDef($ItemDetails->Beverage_Pairing->CurrentValue, NULL);
         $rsnew['Beverage_Pairing'] =& $ItemDetails->Beverage_Pairing->DbValue;
         // Field Vegetarian_Subsitution
         $ItemDetails->Vegetarian_Subsitution->SetDbValueDef($ItemDetails->Vegetarian_Subsitution->CurrentValue, NULL);
         $rsnew['Vegetarian_Subsitution'] =& $ItemDetails->Vegetarian_Subsitution->DbValue;
         // Field Calories
         $ItemDetails->Calories->SetDbValueDef($ItemDetails->Calories->CurrentValue, NULL);
         $rsnew['Calories'] =& $ItemDetails->Calories->DbValue;
         // Field Other
         $ItemDetails->Other->SetDbValueDef($ItemDetails->Other->CurrentValue, NULL);
         $rsnew['Other'] =& $ItemDetails->Other->DbValue;
         // Field Image
         $ItemDetails->Image->Upload->SaveToSession();
         // Save file value to Session
         if ($ItemDetails->Image->Upload->Action == "2" || $ItemDetails->Image->Upload->Action == "3") {
             // Update/Remove
             $ItemDetails->Image->Upload->DbValue = $rs->fields('Image');
             // Get original value
             if (is_null($ItemDetails->Image->Upload->Value)) {
                 $rsnew['Image'] = NULL;
             } else {
                 $rsnew['Image'] = ew_UploadFileNameEx(ew_UploadPathEx(True, "../images/items/"), $ItemDetails->Image->Upload->FileName);
             }
         }
         // Call Row Updating event
         $bUpdateRow = $ItemDetails->Row_Updating($rsold, $rsnew);
         if ($bUpdateRow) {
             // Field Image
             if (!is_null($ItemDetails->Image->Upload->Value)) {
                 $ItemDetails->Image->Upload->SaveToFile("../images/items/", $rsnew['Image'], FALSE);
             }
             $conn->raiseErrorFn = 'ew_ErrorFn';
             $EditRow = $conn->Execute($ItemDetails->UpdateSQL($rsnew));
             $conn->raiseErrorFn = '';
         } else {
             if ($ItemDetails->CancelMessage != "") {
                 $this->setMessage($ItemDetails->CancelMessage);
                 $ItemDetails->CancelMessage = "";
             } else {
                 $this->setMessage("Update cancelled");
             }
             $EditRow = FALSE;
         }
     }
     // Call Row_Updated event
     if ($EditRow) {
         $ItemDetails->Row_Updated($rsold, $rsnew);
     }
     $rs->Close();
     // Field Image
     $ItemDetails->Image->Upload->RemoveFromSession();
     // Remove file value from Session
     return $EditRow;
 }
Exemplo n.º 11
0
 function EditRow()
 {
     global $conn, $Security, $Language;
     $sFilter = $this->KeyFilter();
     $this->CurrentFilter = $sFilter;
     $sSql = $this->SQL();
     $conn->raiseErrorFn = 'ew_ErrorFn';
     $rs = $conn->Execute($sSql);
     $conn->raiseErrorFn = '';
     if ($rs === FALSE) {
         return FALSE;
     }
     if ($rs->EOF) {
         $EditRow = FALSE;
         // Update Failed
     } else {
         // Save old values
         $rsold =& $rs->fields;
         $rsnew = array();
         // teacher_name
         $this->teacher_name->SetDbValueDef($rsnew, $this->teacher_name->CurrentValue, NULL, $this->teacher_name->ReadOnly);
         // teacher_personal_page
         $this->teacher_personal_page->SetDbValueDef($rsnew, $this->teacher_personal_page->CurrentValue, NULL, $this->teacher_personal_page->ReadOnly);
         // teacher_avatar
         if (!$this->teacher_avatar->ReadOnly) {
             $this->teacher_avatar->UploadPath = 'themes\\classic\\assets\\img\\Teacher_img';
             if ($this->teacher_avatar->Upload->Action == "1") {
                 // Keep
             } elseif ($this->teacher_avatar->Upload->Action == "2" || $this->teacher_avatar->Upload->Action == "3") {
                 // Update/Remove
                 $this->teacher_avatar->Upload->DbValue = $rs->fields('teacher_avatar');
                 // Get original value
                 if (is_null($this->teacher_avatar->Upload->Value)) {
                     $rsnew['teacher_avatar'] = NULL;
                 } else {
                     $rsnew['teacher_avatar'] = ew_UploadFileNameEx(ew_UploadPathEx(TRUE, $this->teacher_avatar->UploadPath), $this->teacher_avatar->Upload->FileName);
                 }
             }
         }
         // teacher_description
         $this->teacher_description->SetDbValueDef($rsnew, $this->teacher_description->CurrentValue, NULL, $this->teacher_description->ReadOnly);
         // teacher_work_place
         $this->teacher_work_place->SetDbValueDef($rsnew, $this->teacher_work_place->CurrentValue, NULL, $this->teacher_work_place->ReadOnly);
         // teacher_active
         $this->teacher_active->SetDbValueDef($rsnew, $this->teacher_active->CurrentValue, NULL, $this->teacher_active->ReadOnly);
         // teacher_acadamic_title
         $this->teacher_acadamic_title->SetDbValueDef($rsnew, $this->teacher_acadamic_title->CurrentValue, NULL, $this->teacher_acadamic_title->ReadOnly);
         // teacher_birthday
         $this->teacher_birthday->SetDbValueDef($rsnew, $this->teacher_birthday->CurrentValue, NULL, $this->teacher_birthday->ReadOnly);
         // teacher_sex
         $this->teacher_sex->SetDbValueDef($rsnew, $this->teacher_sex->CurrentValue, NULL, $this->teacher_sex->ReadOnly);
         // teacher_faculty
         $this->teacher_faculty->SetDbValueDef($rsnew, $this->teacher_faculty->CurrentValue, NULL, $this->teacher_faculty->ReadOnly);
         // teacher_dept
         $this->teacher_dept->SetDbValueDef($rsnew, $this->teacher_dept->CurrentValue, NULL, $this->teacher_dept->ReadOnly);
         // teacher_rate
         $this->teacher_rate->SetDbValueDef($rsnew, $this->teacher_rate->CurrentValue, NULL, $this->teacher_rate->ReadOnly);
         // teacher_personality
         $this->teacher_personality->SetDbValueDef($rsnew, $this->teacher_personality->CurrentValue, NULL, $this->teacher_personality->ReadOnly);
         // advices
         $this->advices->SetDbValueDef($rsnew, $this->advices->CurrentValue, NULL, $this->advices->ReadOnly);
         // teacher_research
         $this->teacher_research->SetDbValueDef($rsnew, $this->teacher_research->CurrentValue, NULL, $this->teacher_research->ReadOnly);
         // Call Row Updating event
         $bUpdateRow = $this->Row_Updating($rsold, $rsnew);
         if ($bUpdateRow) {
             if (!ew_Empty($this->teacher_avatar->Upload->Value)) {
                 $this->teacher_avatar->Upload->SaveToFile($this->teacher_avatar->UploadPath, $rsnew['teacher_avatar'], FALSE);
             }
             $conn->raiseErrorFn = 'ew_ErrorFn';
             if (count($rsnew) > 0) {
                 $EditRow = $this->Update($rsnew);
             } else {
                 $EditRow = TRUE;
             }
             // No field to update
             $conn->raiseErrorFn = '';
         } else {
             if ($this->getSuccessMessage() != "" || $this->getFailureMessage() != "") {
                 // Use the message, do nothing
             } elseif ($this->CancelMessage != "") {
                 $this->setFailureMessage($this->CancelMessage);
                 $this->CancelMessage = "";
             } else {
                 $this->setFailureMessage($Language->Phrase("UpdateCancelled"));
             }
             $EditRow = FALSE;
         }
     }
     // Call Row_Updated event
     if ($EditRow) {
         $this->Row_Updated($rsold, $rsnew);
     }
     $rs->Close();
     // teacher_avatar
     $this->teacher_avatar->Upload->RemoveFromSession();
     // Remove file value from Session
     return $EditRow;
 }
Exemplo n.º 12
0
 function AddRow()
 {
     global $conn, $Security, $ItemDetails;
     $rsnew = array();
     // Field Time_to_Table
     $ItemDetails->Time_to_Table->SetDbValueDef($ItemDetails->Time_to_Table->CurrentValue, NULL);
     $rsnew['Time_to_Table'] =& $ItemDetails->Time_to_Table->DbValue;
     // Field Level_Of_Difficulty
     $ItemDetails->Level_Of_Difficulty->SetDbValueDef($ItemDetails->Level_Of_Difficulty->CurrentValue, NULL);
     $rsnew['Level_Of_Difficulty'] =& $ItemDetails->Level_Of_Difficulty->DbValue;
     // Field Beverage_Pairing
     $ItemDetails->Beverage_Pairing->SetDbValueDef($ItemDetails->Beverage_Pairing->CurrentValue, NULL);
     $rsnew['Beverage_Pairing'] =& $ItemDetails->Beverage_Pairing->DbValue;
     // Field Vegetarian_Subsitution
     $ItemDetails->Vegetarian_Subsitution->SetDbValueDef($ItemDetails->Vegetarian_Subsitution->CurrentValue, NULL);
     $rsnew['Vegetarian_Subsitution'] =& $ItemDetails->Vegetarian_Subsitution->DbValue;
     // Field Calories
     $ItemDetails->Calories->SetDbValueDef($ItemDetails->Calories->CurrentValue, NULL);
     $rsnew['Calories'] =& $ItemDetails->Calories->DbValue;
     // Field Other
     $ItemDetails->Other->SetDbValueDef($ItemDetails->Other->CurrentValue, NULL);
     $rsnew['Other'] =& $ItemDetails->Other->DbValue;
     // Field Image
     $ItemDetails->Image->Upload->SaveToSession();
     // Save file value to Session
     if (is_null($ItemDetails->Image->Upload->Value)) {
         $rsnew['Image'] = NULL;
     } else {
         $rsnew['Image'] = ew_UploadFileNameEx(ew_UploadPathEx(True, "../images/items/"), $ItemDetails->Image->Upload->FileName);
     }
     // Field ItemID
     if ($ItemDetails->ItemID->getSessionValue() != "") {
         $rsnew['ItemID'] = $ItemDetails->ItemID->getSessionValue();
     }
     // Call Row Inserting event
     $bInsertRow = $ItemDetails->Row_Inserting($rsnew);
     if ($bInsertRow) {
         // Field Image
         if (!is_null($ItemDetails->Image->Upload->Value)) {
             $ItemDetails->Image->Upload->SaveToFile("../images/items/", $rsnew['Image'], FALSE);
         }
         $conn->raiseErrorFn = 'ew_ErrorFn';
         $AddRow = $conn->Execute($ItemDetails->InsertSQL($rsnew));
         $conn->raiseErrorFn = '';
     } else {
         if ($ItemDetails->CancelMessage != "") {
             $this->setMessage($ItemDetails->CancelMessage);
             $ItemDetails->CancelMessage = "";
         } else {
             $this->setMessage("Insert cancelled");
         }
         $AddRow = FALSE;
     }
     if ($AddRow) {
         $ItemDetails->ItemID->setDbValue($conn->Insert_ID());
         $rsnew['ItemID'] =& $ItemDetails->ItemID->DbValue;
         // Call Row Inserted event
         $ItemDetails->Row_Inserted($rsnew);
     }
     // Field Image
     $ItemDetails->Image->Upload->RemoveFromSession();
     // Remove file value from Session
     return $AddRow;
 }
Exemplo n.º 13
0
 function AddRow($rsold = NULL)
 {
     global $Language, $Security;
     $conn =& $this->Connection();
     // Load db values from rsold
     if ($rsold) {
         $this->LoadDbValues($rsold);
     }
     $rsnew = array();
     // category_id
     $this->category_id->SetDbValueDef($rsnew, $this->category_id->CurrentValue, 0, FALSE);
     // scat_id
     $this->scat_id->SetDbValueDef($rsnew, $this->scat_id->CurrentValue, 0, FALSE);
     // product_name
     $this->product_name->SetDbValueDef($rsnew, $this->product_name->CurrentValue, "", FALSE);
     // product_image
     if (!$this->product_image->Upload->KeepFile) {
         $this->product_image->Upload->DbValue = "";
         // No need to delete old file
         if ($this->product_image->Upload->FileName == "") {
             $rsnew['product_image'] = NULL;
         } else {
             $rsnew['product_image'] = $this->product_image->Upload->FileName;
         }
     }
     // product_secimage
     if (!$this->product_secimage->Upload->KeepFile) {
         $this->product_secimage->Upload->DbValue = "";
         // No need to delete old file
         if ($this->product_secimage->Upload->FileName == "") {
             $rsnew['product_secimage'] = NULL;
         } else {
             $rsnew['product_secimage'] = $this->product_secimage->Upload->FileName;
         }
     }
     // product_description
     $this->product_description->SetDbValueDef($rsnew, $this->product_description->CurrentValue, "", FALSE);
     // feature_ledtype
     $this->feature_ledtype->SetDbValueDef($rsnew, $this->feature_ledtype->CurrentValue, NULL, FALSE);
     // feature_power
     $this->feature_power->SetDbValueDef($rsnew, $this->feature_power->CurrentValue, NULL, FALSE);
     // feature_lumen
     $this->feature_lumen->SetDbValueDef($rsnew, $this->feature_lumen->CurrentValue, NULL, FALSE);
     // feature_viewangle
     $this->feature_viewangle->SetDbValueDef($rsnew, $this->feature_viewangle->CurrentValue, NULL, FALSE);
     // feature_cri
     $this->feature_cri->SetDbValueDef($rsnew, $this->feature_cri->CurrentValue, NULL, FALSE);
     // feature_iprating
     $this->feature_iprating->SetDbValueDef($rsnew, $this->feature_iprating->CurrentValue, NULL, FALSE);
     // feature_colortemp
     $this->feature_colortemp->SetDbValueDef($rsnew, $this->feature_colortemp->CurrentValue, NULL, FALSE);
     // feature_body
     $this->feature_body->SetDbValueDef($rsnew, $this->feature_body->CurrentValue, NULL, FALSE);
     // feature_cutoutsize
     $this->feature_cutoutsize->SetDbValueDef($rsnew, $this->feature_cutoutsize->CurrentValue, NULL, FALSE);
     // feature_colors
     $this->feature_colors->SetDbValueDef($rsnew, $this->feature_colors->CurrentValue, NULL, FALSE);
     // feature_dimmable
     $this->feature_dimmable->SetDbValueDef($rsnew, $this->feature_dimmable->CurrentValue, NULL, FALSE);
     // feature_warranty
     $this->feature_warranty->SetDbValueDef($rsnew, $this->feature_warranty->CurrentValue, NULL, FALSE);
     // feature_application
     $this->feature_application->SetDbValueDef($rsnew, $this->feature_application->CurrentValue, NULL, FALSE);
     if (!$this->product_image->Upload->KeepFile) {
         if (!ew_Empty($this->product_image->Upload->Value)) {
             if ($this->product_image->Upload->FileName == $this->product_image->Upload->DbValue) {
                 // Overwrite if same file name
                 $this->product_image->Upload->DbValue = "";
                 // No need to delete any more
             } else {
                 $rsnew['product_image'] = ew_UploadFileNameEx(ew_UploadPathEx(TRUE, $this->product_image->UploadPath), $rsnew['product_image']);
                 // Get new file name
             }
         }
     }
     if (!$this->product_secimage->Upload->KeepFile) {
         if (!ew_Empty($this->product_secimage->Upload->Value)) {
             if ($this->product_secimage->Upload->FileName == $this->product_secimage->Upload->DbValue) {
                 // Overwrite if same file name
                 $this->product_secimage->Upload->DbValue = "";
                 // No need to delete any more
             } else {
                 $rsnew['product_secimage'] = ew_UploadFileNameEx(ew_UploadPathEx(TRUE, $this->product_secimage->UploadPath), $rsnew['product_secimage']);
                 // Get new file name
             }
         }
     }
     // Call Row Inserting event
     $rs = $rsold == NULL ? NULL : $rsold->fields;
     $bInsertRow = $this->Row_Inserting($rs, $rsnew);
     if ($bInsertRow) {
         $conn->raiseErrorFn = $GLOBALS["EW_ERROR_FN"];
         $AddRow = $this->Insert($rsnew);
         $conn->raiseErrorFn = '';
         if ($AddRow) {
             // Get insert id if necessary
             $this->product_id->setDbValue($conn->Insert_ID());
             $rsnew['product_id'] = $this->product_id->DbValue;
             if (!$this->product_image->Upload->KeepFile) {
                 if (!ew_Empty($this->product_image->Upload->Value)) {
                     $this->product_image->Upload->SaveToFile($this->product_image->UploadPath, $rsnew['product_image'], TRUE);
                 }
                 if ($this->product_image->Upload->DbValue != "") {
                     @unlink(ew_UploadPathEx(TRUE, $this->product_image->OldUploadPath) . $this->product_image->Upload->DbValue);
                 }
             }
             if (!$this->product_secimage->Upload->KeepFile) {
                 if (!ew_Empty($this->product_secimage->Upload->Value)) {
                     $this->product_secimage->Upload->SaveToFile($this->product_secimage->UploadPath, $rsnew['product_secimage'], TRUE);
                 }
                 if ($this->product_secimage->Upload->DbValue != "") {
                     @unlink(ew_UploadPathEx(TRUE, $this->product_secimage->OldUploadPath) . $this->product_secimage->Upload->DbValue);
                 }
             }
         }
     } else {
         if ($this->getSuccessMessage() != "" || $this->getFailureMessage() != "") {
             // Use the message, do nothing
         } elseif ($this->CancelMessage != "") {
             $this->setFailureMessage($this->CancelMessage);
             $this->CancelMessage = "";
         } else {
             $this->setFailureMessage($Language->Phrase("InsertCancelled"));
         }
         $AddRow = FALSE;
     }
     if ($AddRow) {
         // Call Row Inserted event
         $rs = $rsold == NULL ? NULL : $rsold->fields;
         $this->Row_Inserted($rs, $rsnew);
     }
     // product_image
     ew_CleanUploadTempPath($this->product_image, $this->product_image->Upload->Index);
     // product_secimage
     ew_CleanUploadTempPath($this->product_secimage, $this->product_secimage->Upload->Index);
     return $AddRow;
 }
Exemplo n.º 14
0
 function AddRow($rsold = NULL)
 {
     global $conn, $Language, $Security;
     $rsnew = array();
     // teacher_name
     $this->teacher_name->SetDbValueDef($rsnew, $this->teacher_name->CurrentValue, NULL, FALSE);
     // teacher_personal_page
     $this->teacher_personal_page->SetDbValueDef($rsnew, $this->teacher_personal_page->CurrentValue, NULL, FALSE);
     // teacher_avatar
     $this->teacher_avatar->UploadPath = 'themes\\classic\\assets\\img\\Teacher_img';
     if ($this->teacher_avatar->Upload->Action == "1") {
         // Keep
         if ($rsold) {
             $rsnew['teacher_avatar'] = $rsold->fields['teacher_avatar'];
         }
     } elseif ($this->teacher_avatar->Upload->Action == "2" || $this->teacher_avatar->Upload->Action == "3") {
         // Update/Remove
         if (is_null($this->teacher_avatar->Upload->Value)) {
             $rsnew['teacher_avatar'] = NULL;
         } else {
             $rsnew['teacher_avatar'] = ew_UploadFileNameEx(ew_UploadPathEx(TRUE, $this->teacher_avatar->UploadPath), $this->teacher_avatar->Upload->FileName);
         }
     }
     // teacher_description
     $this->teacher_description->SetDbValueDef($rsnew, $this->teacher_description->CurrentValue, NULL, FALSE);
     // teacher_work_place
     $this->teacher_work_place->SetDbValueDef($rsnew, $this->teacher_work_place->CurrentValue, NULL, FALSE);
     // teacher_active
     $this->teacher_active->SetDbValueDef($rsnew, $this->teacher_active->CurrentValue, NULL, FALSE);
     // teacher_acadamic_title
     $this->teacher_acadamic_title->SetDbValueDef($rsnew, $this->teacher_acadamic_title->CurrentValue, NULL, FALSE);
     // teacher_birthday
     $this->teacher_birthday->SetDbValueDef($rsnew, $this->teacher_birthday->CurrentValue, NULL, FALSE);
     // teacher_sex
     $this->teacher_sex->SetDbValueDef($rsnew, $this->teacher_sex->CurrentValue, NULL, FALSE);
     // teacher_faculty
     $this->teacher_faculty->SetDbValueDef($rsnew, $this->teacher_faculty->CurrentValue, NULL, FALSE);
     // teacher_dept
     $this->teacher_dept->SetDbValueDef($rsnew, $this->teacher_dept->CurrentValue, NULL, FALSE);
     // teacher_rate
     $this->teacher_rate->SetDbValueDef($rsnew, $this->teacher_rate->CurrentValue, NULL, FALSE);
     // teacher_personality
     $this->teacher_personality->SetDbValueDef($rsnew, $this->teacher_personality->CurrentValue, NULL, FALSE);
     // advices
     $this->advices->SetDbValueDef($rsnew, $this->advices->CurrentValue, NULL, FALSE);
     // teacher_research
     $this->teacher_research->SetDbValueDef($rsnew, $this->teacher_research->CurrentValue, NULL, FALSE);
     // Call Row Inserting event
     $rs = $rsold == NULL ? NULL : $rsold->fields;
     $bInsertRow = $this->Row_Inserting($rs, $rsnew);
     if ($bInsertRow) {
         $conn->raiseErrorFn = 'ew_ErrorFn';
         $AddRow = $this->Insert($rsnew);
         $conn->raiseErrorFn = '';
         if ($AddRow) {
             if (!ew_Empty($this->teacher_avatar->Upload->Value)) {
                 $this->teacher_avatar->Upload->SaveToFile($this->teacher_avatar->UploadPath, $rsnew['teacher_avatar'], FALSE);
             }
         }
     } else {
         if ($this->getSuccessMessage() != "" || $this->getFailureMessage() != "") {
             // Use the message, do nothing
         } elseif ($this->CancelMessage != "") {
             $this->setFailureMessage($this->CancelMessage);
             $this->CancelMessage = "";
         } else {
             $this->setFailureMessage($Language->Phrase("InsertCancelled"));
         }
         $AddRow = FALSE;
     }
     // Get insert id if necessary
     if ($AddRow) {
         $this->teacher_id->setDbValue($conn->Insert_ID());
         $rsnew['teacher_id'] = $this->teacher_id->DbValue;
     }
     if ($AddRow) {
         // Call Row Inserted event
         $rs = $rsold == NULL ? NULL : $rsold->fields;
         $this->Row_Inserted($rs, $rsnew);
     }
     // teacher_avatar
     $this->teacher_avatar->Upload->RemoveFromSession();
     // Remove file value from Session
     return $AddRow;
 }
Exemplo n.º 15
0
 function EditRow()
 {
     global $conn, $Security, $Language;
     $sFilter = $this->KeyFilter();
     $this->CurrentFilter = $sFilter;
     $sSql = $this->SQL();
     $conn->raiseErrorFn = 'ew_ErrorFn';
     $rs = $conn->Execute($sSql);
     $conn->raiseErrorFn = '';
     if ($rs === FALSE) {
         return FALSE;
     }
     if ($rs->EOF) {
         $EditRow = FALSE;
         // Update Failed
     } else {
         // Save old values
         $rsold =& $rs->fields;
         $this->LoadDbValues($rsold);
         $this->g_image->OldUploadPath = "/gallery";
         $this->g_image->UploadPath = $this->g_image->OldUploadPath;
         $this->gd_images->OldUploadPath = "/gallery";
         $this->gd_images->UploadPath = $this->gd_images->OldUploadPath;
         $rsnew = array();
         // g_name
         $this->g_name->SetDbValueDef($rsnew, $this->g_name->CurrentValue, "", $this->g_name->ReadOnly);
         // g_image
         if (!$this->g_image->ReadOnly && !$this->g_image->Upload->KeepFile) {
             $this->g_image->Upload->DbValue = $rs->fields('g_image');
             // Get original value
             if ($this->g_image->Upload->FileName == "") {
                 $rsnew['g_image'] = NULL;
             } else {
                 $rsnew['g_image'] = $this->g_image->Upload->FileName;
             }
         }
         // gd_images
         if (!$this->gd_images->ReadOnly && !$this->gd_images->Upload->KeepFile) {
             $this->gd_images->Upload->DbValue = $rs->fields('gd_images');
             // Get original value
             if ($this->gd_images->Upload->FileName == "") {
                 $rsnew['gd_images'] = NULL;
             } else {
                 $rsnew['gd_images'] = $this->gd_images->Upload->FileName;
             }
         }
         if (!$this->g_image->Upload->KeepFile) {
             $this->g_image->UploadPath = "/gallery";
             if (!ew_Empty($this->g_image->Upload->Value)) {
                 $rsnew['g_image'] = ew_UploadFileNameEx(ew_UploadPathEx(TRUE, $this->g_image->UploadPath), $rsnew['g_image']);
                 // Get new file name
             }
         }
         if (!$this->gd_images->Upload->KeepFile) {
             $this->gd_images->UploadPath = "/gallery";
             $OldFiles = explode(",", $this->gd_images->Upload->DbValue);
             if (!ew_Empty($this->gd_images->Upload->FileName)) {
                 $NewFiles = explode(",", $this->gd_images->Upload->FileName);
                 $FileCount = count($NewFiles);
                 for ($i = 0; $i < $FileCount; $i++) {
                     $fldvar = $this->gd_images->Upload->Index < 0 ? $this->gd_images->FldVar : substr($this->gd_images->FldVar, 0, 1) . $this->gd_images->Upload->Index . substr($this->gd_images->FldVar, 1);
                     if ($NewFiles[$i] != "") {
                         $file = ew_UploadTempPath($fldvar) . EW_PATH_DELIMITER . $NewFiles[$i];
                         if (file_exists($file)) {
                             if (!in_array($NewFiles[$i], $OldFiles)) {
                                 $NewFiles[$i] = ew_UploadFileNameEx(ew_UploadPathEx(TRUE, $this->gd_images->UploadPath), $NewFiles[$i]);
                                 // Get new file name
                                 $file1 = ew_UploadTempPath($fldvar) . EW_PATH_DELIMITER . $NewFiles[$i];
                                 if ($file1 != $file) {
                                     // Rename temp file
                                     rename($file, $file1);
                                 }
                             }
                         }
                     }
                 }
                 $this->gd_images->Upload->FileName = implode(",", $NewFiles);
                 $rsnew['gd_images'] = $this->gd_images->Upload->FileName;
             } else {
                 $NewFiles = array();
             }
         }
         // Call Row Updating event
         $bUpdateRow = $this->Row_Updating($rsold, $rsnew);
         if ($bUpdateRow) {
             $conn->raiseErrorFn = 'ew_ErrorFn';
             if (count($rsnew) > 0) {
                 $EditRow = $this->Update($rsnew, "", $rsold);
             } else {
                 $EditRow = TRUE;
             }
             // No field to update
             $conn->raiseErrorFn = '';
             if ($EditRow) {
                 if (!$this->g_image->Upload->KeepFile) {
                     if (!ew_Empty($this->g_image->Upload->Value)) {
                         $this->g_image->Upload->SaveToFile($this->g_image->UploadPath, $rsnew['g_image'], TRUE);
                     }
                 }
                 if (!$this->gd_images->Upload->KeepFile) {
                     $OldFiles = explode(",", $this->gd_images->Upload->DbValue);
                     if (!ew_Empty($this->gd_images->Upload->FileName)) {
                         $NewFiles = explode(",", $this->gd_images->Upload->FileName);
                         $NewFiles2 = explode(",", $rsnew['gd_images']);
                         $FileCount = count($NewFiles);
                         for ($i = 0; $i < $FileCount; $i++) {
                             $fldvar = $this->gd_images->Upload->Index < 0 ? $this->gd_images->FldVar : substr($this->gd_images->FldVar, 0, 1) . $this->gd_images->Upload->Index . substr($this->gd_images->FldVar, 1);
                             if ($NewFiles[$i] != "") {
                                 $file = ew_UploadTempPath($fldvar) . EW_PATH_DELIMITER . $NewFiles[$i];
                                 if (file_exists($file)) {
                                     $this->gd_images->Upload->Value = file_get_contents($file);
                                     $this->gd_images->Upload->SaveToFile($this->gd_images->UploadPath, @$NewFiles2[$i] != "" ? $NewFiles2[$i] : $NewFiles[$i], TRUE);
                                     // Just replace
                                 }
                             }
                         }
                     } else {
                         $NewFiles = array();
                     }
                 }
             }
         } else {
             if ($this->getSuccessMessage() != "" || $this->getFailureMessage() != "") {
                 // Use the message, do nothing
             } elseif ($this->CancelMessage != "") {
                 $this->setFailureMessage($this->CancelMessage);
                 $this->CancelMessage = "";
             } else {
                 $this->setFailureMessage($Language->Phrase("UpdateCancelled"));
             }
             $EditRow = FALSE;
         }
     }
     // Call Row_Updated event
     if ($EditRow) {
         $this->Row_Updated($rsold, $rsnew);
     }
     $rs->Close();
     // g_image
     ew_CleanUploadTempPath($this->g_image, $this->g_image->Upload->Index);
     // gd_images
     ew_CleanUploadTempPath($this->gd_images, $this->gd_images->Upload->Index);
     return $EditRow;
 }
Exemplo n.º 16
0
 function AddRow()
 {
     global $conn, $Security, $Items;
     $rsnew = array();
     // Field MenuID
     $Items->MenuID->SetDbValueDef($Items->MenuID->CurrentValue, 0);
     $rsnew['MenuID'] =& $Items->MenuID->DbValue;
     // Field ItemName
     $Items->ItemName->SetDbValueDef($Items->ItemName->CurrentValue, "");
     $rsnew['ItemName'] =& $Items->ItemName->DbValue;
     // Field Description
     $Items->Description->SetDbValueDef($Items->Description->CurrentValue, "");
     $rsnew['Description'] =& $Items->Description->DbValue;
     // Field Price
     $Items->Price->SetDbValueDef($Items->Price->CurrentValue, NULL);
     $rsnew['Price'] =& $Items->Price->DbValue;
     // Field Image
     $Items->Image->Upload->SaveToSession();
     // Save file value to Session
     if (is_null($Items->Image->Upload->Value)) {
         $rsnew['Image'] = NULL;
     } else {
         $rsnew['Image'] = ew_UploadFileNameEx(ew_UploadPathEx(True, "../images/items/"), $Items->Image->Upload->FileName);
     }
     // Field Vegetarian
     $Items->Vegetarian->SetDbValueDef($Items->Vegetarian->CurrentValue, "");
     $rsnew['Vegetarian'] =& $Items->Vegetarian->DbValue;
     // Field Vegetarian_Price
     $Items->Vegetarian_Price->SetDbValueDef($Items->Vegetarian_Price->CurrentValue, NULL);
     $rsnew['Vegetarian_Price'] =& $Items->Vegetarian_Price->DbValue;
     // Field Color
     $Items->Color->SetDbValueDef($Items->Color->CurrentValue, NULL);
     $rsnew['Color'] =& $Items->Color->DbValue;
     // Field Sequence
     $Items->Sequence->SetDbValueDef($Items->Sequence->CurrentValue, 0);
     $rsnew['Sequence'] =& $Items->Sequence->DbValue;
     // Field PDF
     $Items->PDF->Upload->SaveToSession();
     // Save file value to Session
     if (is_null($Items->PDF->Upload->Value)) {
         $rsnew['PDF'] = NULL;
     } else {
         $rsnew['PDF'] = ew_UploadFileNameEx(ew_UploadPathEx(True, "../recipes/"), $Items->PDF->Upload->FileName);
     }
     // Field Active
     $Items->Active->SetDbValueDef($Items->Active->CurrentValue, "");
     $rsnew['Active'] =& $Items->Active->DbValue;
     // Call Row Inserting event
     $bInsertRow = $Items->Row_Inserting($rsnew);
     if ($bInsertRow) {
         // Field Image
         if (!is_null($Items->Image->Upload->Value)) {
             $Items->Image->Upload->SaveToFile("../images/items/", $rsnew['Image'], FALSE);
         }
         // Field PDF
         if (!is_null($Items->PDF->Upload->Value)) {
             $Items->PDF->Upload->SaveToFile("../recipes/", $rsnew['PDF'], FALSE);
         }
         $conn->raiseErrorFn = 'ew_ErrorFn';
         $AddRow = $conn->Execute($Items->InsertSQL($rsnew));
         $conn->raiseErrorFn = '';
     } else {
         if ($Items->CancelMessage != "") {
             $this->setMessage($Items->CancelMessage);
             $Items->CancelMessage = "";
         } else {
             $this->setMessage("Insert cancelled");
         }
         $AddRow = FALSE;
     }
     if ($AddRow) {
         $Items->ItemID->setDbValue($conn->Insert_ID());
         $rsnew['ItemID'] =& $Items->ItemID->DbValue;
         // Call Row Inserted event
         $Items->Row_Inserted($rsnew);
     }
     // Field Image
     $Items->Image->Upload->RemoveFromSession();
     // Remove file value from Session
     // Field PDF
     $Items->PDF->Upload->RemoveFromSession();
     // Remove file value from Session
     return $AddRow;
 }
Exemplo n.º 17
0
 function EditRow()
 {
     global $Security, $Language;
     $sFilter = $this->KeyFilter();
     $conn =& $this->Connection();
     $this->CurrentFilter = $sFilter;
     $sSql = $this->SQL();
     $conn->raiseErrorFn = $GLOBALS["EW_ERROR_FN"];
     $rs = $conn->Execute($sSql);
     $conn->raiseErrorFn = '';
     if ($rs === FALSE) {
         return FALSE;
     }
     if ($rs->EOF) {
         $EditRow = FALSE;
         // Update Failed
     } else {
         // Begin transaction
         if ($this->getCurrentDetailTable() != "") {
             $conn->BeginTrans();
         }
         // Save old values
         $rsold =& $rs->fields;
         $this->LoadDbValues($rsold);
         $this->images->OldUploadPath = "/uploads";
         $this->images->UploadPath = $this->images->OldUploadPath;
         $rsnew = array();
         // title
         $this->title->SetDbValueDef($rsnew, $this->title->CurrentValue, "", $this->title->ReadOnly);
         // images
         if (!$this->images->ReadOnly && !$this->images->Upload->KeepFile) {
             $this->images->Upload->DbValue = $rsold['images'];
             // Get original value
             if ($this->images->Upload->FileName == "") {
                 $rsnew['images'] = NULL;
             } else {
                 $rsnew['images'] = $this->images->Upload->FileName;
             }
         }
         // intro
         $this->intro->SetDbValueDef($rsnew, $this->intro->CurrentValue, "", $this->intro->ReadOnly);
         // full_intro
         $this->full_intro->SetDbValueDef($rsnew, $this->full_intro->CurrentValue, "", $this->full_intro->ReadOnly);
         // details
         $this->details->SetDbValueDef($rsnew, $this->details->CurrentValue, "", $this->details->ReadOnly);
         // livelink
         $this->livelink->SetDbValueDef($rsnew, $this->livelink->CurrentValue, NULL, $this->livelink->ReadOnly);
         if (!$this->images->Upload->KeepFile) {
             $this->images->UploadPath = "/uploads";
             if (!ew_Empty($this->images->Upload->Value)) {
                 $rsnew['images'] = ew_UploadFileNameEx(ew_UploadPathEx(TRUE, $this->images->UploadPath), $rsnew['images']);
                 // Get new file name
             }
         }
         // Call Row Updating event
         $bUpdateRow = $this->Row_Updating($rsold, $rsnew);
         if ($bUpdateRow) {
             $conn->raiseErrorFn = $GLOBALS["EW_ERROR_FN"];
             if (count($rsnew) > 0) {
                 $EditRow = $this->Update($rsnew, "", $rsold);
             } else {
                 $EditRow = TRUE;
             }
             // No field to update
             $conn->raiseErrorFn = '';
             if ($EditRow) {
                 if (!$this->images->Upload->KeepFile) {
                     if (!ew_Empty($this->images->Upload->Value)) {
                         $this->images->Upload->SaveToFile($this->images->UploadPath, $rsnew['images'], TRUE);
                     }
                 }
             }
             // Update detail records
             if ($EditRow) {
                 $DetailTblVar = explode(",", $this->getCurrentDetailTable());
                 if (in_array("images", $DetailTblVar) && $GLOBALS["images"]->DetailEdit) {
                     if (!isset($GLOBALS["images_grid"])) {
                         $GLOBALS["images_grid"] = new cimages_grid();
                     }
                     // Get detail page object
                     $EditRow = $GLOBALS["images_grid"]->GridUpdate();
                 }
             }
             // Commit/Rollback transaction
             if ($this->getCurrentDetailTable() != "") {
                 if ($EditRow) {
                     $conn->CommitTrans();
                     // Commit transaction
                 } else {
                     $conn->RollbackTrans();
                     // Rollback transaction
                 }
             }
         } else {
             if ($this->getSuccessMessage() != "" || $this->getFailureMessage() != "") {
                 // Use the message, do nothing
             } elseif ($this->CancelMessage != "") {
                 $this->setFailureMessage($this->CancelMessage);
                 $this->CancelMessage = "";
             } else {
                 $this->setFailureMessage($Language->Phrase("UpdateCancelled"));
             }
             $EditRow = FALSE;
         }
     }
     // Call Row_Updated event
     if ($EditRow) {
         $this->Row_Updated($rsold, $rsnew);
     }
     $rs->Close();
     // images
     ew_CleanUploadTempPath($this->images, $this->images->Upload->Index);
     return $EditRow;
 }
Exemplo n.º 18
0
 function EditRow()
 {
     global $Security, $Language;
     $sFilter = $this->KeyFilter();
     $sFilter = $this->ApplyUserIDFilters($sFilter);
     $conn =& $this->Connection();
     $this->CurrentFilter = $sFilter;
     $sSql = $this->SQL();
     $conn->raiseErrorFn = $GLOBALS["EW_ERROR_FN"];
     $rs = $conn->Execute($sSql);
     $conn->raiseErrorFn = '';
     if ($rs === FALSE) {
         return FALSE;
     }
     if ($rs->EOF) {
         $this->setFailureMessage($Language->Phrase("NoRecord"));
         // Set no record message
         $EditRow = FALSE;
         // Update Failed
     } else {
         // Save old values
         $rsold =& $rs->fields;
         $this->LoadDbValues($rsold);
         $rsnew = array();
         // PATH
         if ($this->PATH->Visible && !$this->PATH->ReadOnly && !$this->PATH->Upload->KeepFile) {
             $this->PATH->Upload->DbValue = $rsold['PATH'];
             // Get original value
             if ($this->PATH->Upload->FileName == "") {
                 $rsnew['PATH'] = NULL;
             } else {
                 $rsnew['PATH'] = $this->PATH->Upload->FileName;
             }
         }
         // PROCESS
         $this->PROCESS->SetDbValueDef($rsnew, $this->PROCESS->CurrentValue, 0, $this->PROCESS->ReadOnly);
         // BANK_ACCOUNT_ID
         $this->BANK_ACCOUNT_ID->SetDbValueDef($rsnew, $this->BANK_ACCOUNT_ID->CurrentValue, 0, $this->BANK_ACCOUNT_ID->ReadOnly);
         // UPLOAD_FILE_STATUS_ID
         $this->UPLOAD_FILE_STATUS_ID->SetDbValueDef($rsnew, $this->UPLOAD_FILE_STATUS_ID->CurrentValue, 0, $this->UPLOAD_FILE_STATUS_ID->ReadOnly);
         // DATETIME
         $this->DATETIME->SetDbValueDef($rsnew, ew_UnFormatDateTime($this->DATETIME->CurrentValue, 7), ew_CurrentDate(), $this->DATETIME->ReadOnly);
         if ($this->PATH->Visible && !$this->PATH->Upload->KeepFile) {
             if (!ew_Empty($this->PATH->Upload->Value)) {
                 $rsnew['PATH'] = ew_UploadFileNameEx(ew_UploadPathEx(TRUE, $this->PATH->UploadPath), $rsnew['PATH']);
                 // Get new file name
             }
         }
         // Call Row Updating event
         $bUpdateRow = $this->Row_Updating($rsold, $rsnew);
         if ($bUpdateRow) {
             $conn->raiseErrorFn = $GLOBALS["EW_ERROR_FN"];
             if (count($rsnew) > 0) {
                 $EditRow = $this->Update($rsnew, "", $rsold);
             } else {
                 $EditRow = TRUE;
             }
             // No field to update
             $conn->raiseErrorFn = '';
             if ($EditRow) {
                 if ($this->PATH->Visible && !$this->PATH->Upload->KeepFile) {
                     if (!ew_Empty($this->PATH->Upload->Value)) {
                         $this->PATH->Upload->SaveToFile($this->PATH->UploadPath, $rsnew['PATH'], TRUE);
                     }
                 }
             }
         } else {
             if ($this->getSuccessMessage() != "" || $this->getFailureMessage() != "") {
                 // Use the message, do nothing
             } elseif ($this->CancelMessage != "") {
                 $this->setFailureMessage($this->CancelMessage);
                 $this->CancelMessage = "";
             } else {
                 $this->setFailureMessage($Language->Phrase("UpdateCancelled"));
             }
             $EditRow = FALSE;
         }
     }
     // Call Row_Updated event
     if ($EditRow) {
         $this->Row_Updated($rsold, $rsnew);
     }
     $rs->Close();
     // PATH
     ew_CleanUploadTempPath($this->PATH, $this->PATH->Upload->Index);
     return $EditRow;
 }
Exemplo n.º 19
0
 function EditRow()
 {
     global $Security, $Language;
     $sFilter = $this->KeyFilter();
     $sFilter = $this->ApplyUserIDFilters($sFilter);
     $conn =& $this->Connection();
     $this->CurrentFilter = $sFilter;
     $sSql = $this->SQL();
     $conn->raiseErrorFn = $GLOBALS["EW_ERROR_FN"];
     $rs = $conn->Execute($sSql);
     $conn->raiseErrorFn = '';
     if ($rs === FALSE) {
         return FALSE;
     }
     if ($rs->EOF) {
         $this->setFailureMessage($Language->Phrase("NoRecord"));
         // Set no record message
         $EditRow = FALSE;
         // Update Failed
     } else {
         // Save old values
         $rsold =& $rs->fields;
         $this->LoadDbValues($rsold);
         $this->vl_media_file_custom->OldUploadPath = "uploads_custom/";
         $this->vl_media_file_custom->UploadPath = $this->vl_media_file_custom->OldUploadPath;
         $rsnew = array();
         // vl_media_type
         $this->vl_media_type->SetDbValueDef($rsnew, $this->vl_media_type->CurrentValue, NULL, $this->vl_media_type->ReadOnly);
         // vl_media_name
         $this->vl_media_name->SetDbValueDef($rsnew, $this->vl_media_name->CurrentValue, NULL, $this->vl_media_name->ReadOnly);
         // vl_media_file
         if ($this->vl_media_file->Visible && !$this->vl_media_file->ReadOnly && !$this->vl_media_file->Upload->KeepFile) {
             $this->vl_media_file->Upload->DbValue = $rsold['vl_media_file'];
             // Get original value
             if ($this->vl_media_file->Upload->FileName == "") {
                 $rsnew['vl_media_file'] = NULL;
             } else {
                 $rsnew['vl_media_file'] = $this->vl_media_file->Upload->FileName;
             }
         }
         // vl_media_file_custom
         if ($this->vl_media_file_custom->Visible && !$this->vl_media_file_custom->ReadOnly && !$this->vl_media_file_custom->Upload->KeepFile) {
             $this->vl_media_file_custom->Upload->DbValue = $rsold['vl_media_file_custom'];
             // Get original value
             if ($this->vl_media_file_custom->Upload->FileName == "") {
                 $rsnew['vl_media_file_custom'] = NULL;
             } else {
                 $rsnew['vl_media_file_custom'] = $this->vl_media_file_custom->Upload->FileName;
             }
         }
         if ($this->vl_media_file->Visible && !$this->vl_media_file->Upload->KeepFile) {
             if (!ew_Empty($this->vl_media_file->Upload->Value)) {
                 $rsnew['vl_media_file'] = ew_UploadFileNameEx(ew_UploadPathEx(TRUE, $this->vl_media_file->UploadPath), $rsnew['vl_media_file']);
                 // Get new file name
             }
         }
         if ($this->vl_media_file_custom->Visible && !$this->vl_media_file_custom->Upload->KeepFile) {
             $this->vl_media_file_custom->UploadPath = "uploads_custom/";
             if (!ew_Empty($this->vl_media_file_custom->Upload->Value)) {
                 $rsnew['vl_media_file_custom'] = ew_UploadFileNameEx(ew_UploadPathEx(TRUE, $this->vl_media_file_custom->UploadPath), $rsnew['vl_media_file_custom']);
                 // Get new file name
             }
         }
         // Call Row Updating event
         $bUpdateRow = $this->Row_Updating($rsold, $rsnew);
         if ($bUpdateRow) {
             $conn->raiseErrorFn = $GLOBALS["EW_ERROR_FN"];
             if (count($rsnew) > 0) {
                 $EditRow = $this->Update($rsnew, "", $rsold);
             } else {
                 $EditRow = TRUE;
             }
             // No field to update
             $conn->raiseErrorFn = '';
             if ($EditRow) {
                 if ($this->vl_media_file->Visible && !$this->vl_media_file->Upload->KeepFile) {
                     if (!ew_Empty($this->vl_media_file->Upload->Value)) {
                         $this->vl_media_file->Upload->SaveToFile($this->vl_media_file->UploadPath, $rsnew['vl_media_file'], TRUE);
                     }
                 }
                 if ($this->vl_media_file_custom->Visible && !$this->vl_media_file_custom->Upload->KeepFile) {
                     if (!ew_Empty($this->vl_media_file_custom->Upload->Value)) {
                         $this->vl_media_file_custom->Upload->SaveToFile($this->vl_media_file_custom->UploadPath, $rsnew['vl_media_file_custom'], TRUE);
                     }
                 }
             }
         } else {
             if ($this->getSuccessMessage() != "" || $this->getFailureMessage() != "") {
                 // Use the message, do nothing
             } elseif ($this->CancelMessage != "") {
                 $this->setFailureMessage($this->CancelMessage);
                 $this->CancelMessage = "";
             } else {
                 $this->setFailureMessage($Language->Phrase("UpdateCancelled"));
             }
             $EditRow = FALSE;
         }
     }
     // Call Row_Updated event
     if ($EditRow) {
         $this->Row_Updated($rsold, $rsnew);
     }
     $rs->Close();
     // vl_media_file
     ew_CleanUploadTempPath($this->vl_media_file, $this->vl_media_file->Upload->Index);
     // vl_media_file_custom
     ew_CleanUploadTempPath($this->vl_media_file_custom, $this->vl_media_file_custom->Upload->Index);
     return $EditRow;
 }
Exemplo n.º 20
0
 function AddRow($rsold = NULL)
 {
     global $conn, $Language, $Security;
     // Begin transaction
     if ($this->getCurrentDetailTable() != "") {
         $conn->BeginTrans();
     }
     // Load db values from rsold
     if ($rsold) {
         $this->LoadDbValues($rsold);
         $this->g_image->OldUploadPath = "gallery/";
         $this->g_image->UploadPath = $this->g_image->OldUploadPath;
     }
     $rsnew = array();
     // g_name
     $this->g_name->SetDbValueDef($rsnew, $this->g_name->CurrentValue, "", FALSE);
     // g_image
     if (!$this->g_image->Upload->KeepFile) {
         if ($this->g_image->Upload->FileName == "") {
             $rsnew['g_image'] = NULL;
         } else {
             $rsnew['g_image'] = $this->g_image->Upload->FileName;
         }
     }
     if (!$this->g_image->Upload->KeepFile) {
         $this->g_image->UploadPath = "gallery/";
         if (!ew_Empty($this->g_image->Upload->Value)) {
             $rsnew['g_image'] = ew_UploadFileNameEx(ew_UploadPathEx(TRUE, $this->g_image->UploadPath), $rsnew['g_image']);
             // Get new file name
         }
     }
     // Call Row Inserting event
     $rs = $rsold == NULL ? NULL : $rsold->fields;
     $bInsertRow = $this->Row_Inserting($rs, $rsnew);
     if ($bInsertRow) {
         $conn->raiseErrorFn = 'ew_ErrorFn';
         $AddRow = $this->Insert($rsnew);
         $conn->raiseErrorFn = '';
         if ($AddRow) {
             if (!$this->g_image->Upload->KeepFile) {
                 if (!ew_Empty($this->g_image->Upload->Value)) {
                     $this->g_image->Upload->SaveToFile($this->g_image->UploadPath, $rsnew['g_image'], TRUE);
                 }
             }
         }
     } else {
         if ($this->getSuccessMessage() != "" || $this->getFailureMessage() != "") {
             // Use the message, do nothing
         } elseif ($this->CancelMessage != "") {
             $this->setFailureMessage($this->CancelMessage);
             $this->CancelMessage = "";
         } else {
             $this->setFailureMessage($Language->Phrase("InsertCancelled"));
         }
         $AddRow = FALSE;
     }
     // Get insert id if necessary
     if ($AddRow) {
         $this->g_id->setDbValue($conn->Insert_ID());
         $rsnew['g_id'] = $this->g_id->DbValue;
     }
     // Add detail records
     if ($AddRow) {
         $DetailTblVar = explode(",", $this->getCurrentDetailTable());
         if (in_array("gallery_detail", $DetailTblVar) && $GLOBALS["gallery_detail"]->DetailAdd) {
             $GLOBALS["gallery_detail"]->g_id->setSessionValue($this->g_id->CurrentValue);
             // Set master key
             if (!isset($GLOBALS["gallery_detail_grid"])) {
                 $GLOBALS["gallery_detail_grid"] = new cgallery_detail_grid();
             }
             // Get detail page object
             $AddRow = $GLOBALS["gallery_detail_grid"]->GridInsert();
             if (!$AddRow) {
                 $GLOBALS["gallery_detail"]->g_id->setSessionValue("");
             }
             // Clear master key if insert failed
         }
     }
     // Commit/Rollback transaction
     if ($this->getCurrentDetailTable() != "") {
         if ($AddRow) {
             $conn->CommitTrans();
             // Commit transaction
         } else {
             $conn->RollbackTrans();
             // Rollback transaction
         }
     }
     if ($AddRow) {
         // Call Row Inserted event
         $rs = $rsold == NULL ? NULL : $rsold->fields;
         $this->Row_Inserted($rs, $rsnew);
     }
     // g_image
     ew_CleanUploadTempPath($this->g_image, $this->g_image->Upload->Index);
     return $AddRow;
 }
Exemplo n.º 21
0
 function SaveToFile($Path, $NewFileName, $OverWrite, $idx = -1)
 {
     if (!ew_Empty($this->Value)) {
         $Path = ew_UploadPathEx(TRUE, $Path);
         if (trim(strval($NewFileName)) == "") {
             $NewFileName = $this->FileName;
         }
         if (!$OverWrite) {
             $NewFileName = ew_UploadFileNameEx($Path, $NewFileName);
         }
         return ew_SaveFile($Path, $NewFileName, $this->Value);
     } elseif ($idx >= 0) {
         // Use file from upload temp folder
         $ar = explode(EW_MULTIPLE_UPLOAD_SEPARATOR, $this->FileName);
         if ($idx < count($ar)) {
             $fn = $ar[$idx];
             $fldvar = $this->Index < 0 ? $this->FldVar : substr($this->FldVar, 0, 1) . $this->Index . substr($this->FldVar, 1);
             $file = ew_UploadTempPath($fldvar) . EW_PATH_DELIMITER . $fn;
             if (file_exists($file)) {
                 if (!$OverWrite) {
                     $NewFileName = ew_UploadFileNameEx($Path, $NewFileName);
                 }
                 return ew_CopyFile($Path, $NewFileName, $file);
             }
         }
     }
     return FALSE;
 }
Exemplo n.º 22
0
 function EditRow()
 {
     global $Security, $Language;
     $sFilter = $this->KeyFilter();
     $conn =& $this->Connection();
     $this->CurrentFilter = $sFilter;
     $sSql = $this->SQL();
     $conn->raiseErrorFn = $GLOBALS["EW_ERROR_FN"];
     $rs = $conn->Execute($sSql);
     $conn->raiseErrorFn = '';
     if ($rs === FALSE) {
         return FALSE;
     }
     if ($rs->EOF) {
         $EditRow = FALSE;
         // Update Failed
     } else {
         // Save old values
         $rsold =& $rs->fields;
         $this->LoadDbValues($rsold);
         $rsnew = array();
         // category_id
         $this->category_id->SetDbValueDef($rsnew, $this->category_id->CurrentValue, 0, $this->category_id->ReadOnly);
         // scat_id
         $this->scat_id->SetDbValueDef($rsnew, $this->scat_id->CurrentValue, 0, $this->scat_id->ReadOnly);
         // product_name
         $this->product_name->SetDbValueDef($rsnew, $this->product_name->CurrentValue, "", $this->product_name->ReadOnly);
         // product_image
         if (!$this->product_image->ReadOnly && !$this->product_image->Upload->KeepFile) {
             $this->product_image->Upload->DbValue = $rsold['product_image'];
             // Get original value
             if ($this->product_image->Upload->FileName == "") {
                 $rsnew['product_image'] = NULL;
             } else {
                 $rsnew['product_image'] = $this->product_image->Upload->FileName;
             }
         }
         // product_secimage
         if (!$this->product_secimage->ReadOnly && !$this->product_secimage->Upload->KeepFile) {
             $this->product_secimage->Upload->DbValue = $rsold['product_secimage'];
             // Get original value
             if ($this->product_secimage->Upload->FileName == "") {
                 $rsnew['product_secimage'] = NULL;
             } else {
                 $rsnew['product_secimage'] = $this->product_secimage->Upload->FileName;
             }
         }
         // product_description
         $this->product_description->SetDbValueDef($rsnew, $this->product_description->CurrentValue, "", $this->product_description->ReadOnly);
         // feature_ledtype
         $this->feature_ledtype->SetDbValueDef($rsnew, $this->feature_ledtype->CurrentValue, NULL, $this->feature_ledtype->ReadOnly);
         // feature_power
         $this->feature_power->SetDbValueDef($rsnew, $this->feature_power->CurrentValue, NULL, $this->feature_power->ReadOnly);
         // feature_lumen
         $this->feature_lumen->SetDbValueDef($rsnew, $this->feature_lumen->CurrentValue, NULL, $this->feature_lumen->ReadOnly);
         // feature_viewangle
         $this->feature_viewangle->SetDbValueDef($rsnew, $this->feature_viewangle->CurrentValue, NULL, $this->feature_viewangle->ReadOnly);
         // feature_cri
         $this->feature_cri->SetDbValueDef($rsnew, $this->feature_cri->CurrentValue, NULL, $this->feature_cri->ReadOnly);
         // feature_iprating
         $this->feature_iprating->SetDbValueDef($rsnew, $this->feature_iprating->CurrentValue, NULL, $this->feature_iprating->ReadOnly);
         // feature_colortemp
         $this->feature_colortemp->SetDbValueDef($rsnew, $this->feature_colortemp->CurrentValue, NULL, $this->feature_colortemp->ReadOnly);
         // feature_body
         $this->feature_body->SetDbValueDef($rsnew, $this->feature_body->CurrentValue, NULL, $this->feature_body->ReadOnly);
         // feature_cutoutsize
         $this->feature_cutoutsize->SetDbValueDef($rsnew, $this->feature_cutoutsize->CurrentValue, NULL, $this->feature_cutoutsize->ReadOnly);
         // feature_colors
         $this->feature_colors->SetDbValueDef($rsnew, $this->feature_colors->CurrentValue, NULL, $this->feature_colors->ReadOnly);
         // feature_dimmable
         $this->feature_dimmable->SetDbValueDef($rsnew, $this->feature_dimmable->CurrentValue, NULL, $this->feature_dimmable->ReadOnly);
         // feature_warranty
         $this->feature_warranty->SetDbValueDef($rsnew, $this->feature_warranty->CurrentValue, NULL, $this->feature_warranty->ReadOnly);
         // feature_application
         $this->feature_application->SetDbValueDef($rsnew, $this->feature_application->CurrentValue, NULL, $this->feature_application->ReadOnly);
         if (!$this->product_image->Upload->KeepFile) {
             if (!ew_Empty($this->product_image->Upload->Value)) {
                 if ($this->product_image->Upload->FileName == $this->product_image->Upload->DbValue) {
                     // Overwrite if same file name
                     $this->product_image->Upload->DbValue = "";
                     // No need to delete any more
                 } else {
                     $rsnew['product_image'] = ew_UploadFileNameEx(ew_UploadPathEx(TRUE, $this->product_image->UploadPath), $rsnew['product_image']);
                     // Get new file name
                 }
             }
         }
         if (!$this->product_secimage->Upload->KeepFile) {
             if (!ew_Empty($this->product_secimage->Upload->Value)) {
                 if ($this->product_secimage->Upload->FileName == $this->product_secimage->Upload->DbValue) {
                     // Overwrite if same file name
                     $this->product_secimage->Upload->DbValue = "";
                     // No need to delete any more
                 } else {
                     $rsnew['product_secimage'] = ew_UploadFileNameEx(ew_UploadPathEx(TRUE, $this->product_secimage->UploadPath), $rsnew['product_secimage']);
                     // Get new file name
                 }
             }
         }
         // Call Row Updating event
         $bUpdateRow = $this->Row_Updating($rsold, $rsnew);
         if ($bUpdateRow) {
             $conn->raiseErrorFn = $GLOBALS["EW_ERROR_FN"];
             if (count($rsnew) > 0) {
                 $EditRow = $this->Update($rsnew, "", $rsold);
             } else {
                 $EditRow = TRUE;
             }
             // No field to update
             $conn->raiseErrorFn = '';
             if ($EditRow) {
                 if (!$this->product_image->Upload->KeepFile) {
                     if (!ew_Empty($this->product_image->Upload->Value)) {
                         $this->product_image->Upload->SaveToFile($this->product_image->UploadPath, $rsnew['product_image'], TRUE);
                     }
                     if ($this->product_image->Upload->DbValue != "") {
                         @unlink(ew_UploadPathEx(TRUE, $this->product_image->OldUploadPath) . $this->product_image->Upload->DbValue);
                     }
                 }
                 if (!$this->product_secimage->Upload->KeepFile) {
                     if (!ew_Empty($this->product_secimage->Upload->Value)) {
                         $this->product_secimage->Upload->SaveToFile($this->product_secimage->UploadPath, $rsnew['product_secimage'], TRUE);
                     }
                     if ($this->product_secimage->Upload->DbValue != "") {
                         @unlink(ew_UploadPathEx(TRUE, $this->product_secimage->OldUploadPath) . $this->product_secimage->Upload->DbValue);
                     }
                 }
             }
         } else {
             if ($this->getSuccessMessage() != "" || $this->getFailureMessage() != "") {
                 // Use the message, do nothing
             } elseif ($this->CancelMessage != "") {
                 $this->setFailureMessage($this->CancelMessage);
                 $this->CancelMessage = "";
             } else {
                 $this->setFailureMessage($Language->Phrase("UpdateCancelled"));
             }
             $EditRow = FALSE;
         }
     }
     // Call Row_Updated event
     if ($EditRow) {
         $this->Row_Updated($rsold, $rsnew);
     }
     $rs->Close();
     // product_image
     ew_CleanUploadTempPath($this->product_image, $this->product_image->Upload->Index);
     // product_secimage
     ew_CleanUploadTempPath($this->product_secimage, $this->product_secimage->Upload->Index);
     return $EditRow;
 }
Exemplo n.º 23
0
 function AddRow($rsold = NULL)
 {
     global $Language, $Security;
     $conn =& $this->Connection();
     // Begin transaction
     if ($this->getCurrentDetailTable() != "") {
         $conn->BeginTrans();
     }
     // Load db values from rsold
     if ($rsold) {
         $this->LoadDbValues($rsold);
     }
     $rsnew = array();
     // category_id
     $this->category_id->SetDbValueDef($rsnew, $this->category_id->CurrentValue, 0, FALSE);
     // scat_name
     $this->scat_name->SetDbValueDef($rsnew, $this->scat_name->CurrentValue, "", FALSE);
     // scat_description
     $this->scat_description->SetDbValueDef($rsnew, $this->scat_description->CurrentValue, "", FALSE);
     // scat_picture
     if (!$this->scat_picture->Upload->KeepFile) {
         $this->scat_picture->Upload->DbValue = "";
         // No need to delete old file
         if ($this->scat_picture->Upload->FileName == "") {
             $rsnew['scat_picture'] = NULL;
         } else {
             $rsnew['scat_picture'] = $this->scat_picture->Upload->FileName;
         }
     }
     if (!$this->scat_picture->Upload->KeepFile) {
         if (!ew_Empty($this->scat_picture->Upload->Value)) {
             if ($this->scat_picture->Upload->FileName == $this->scat_picture->Upload->DbValue) {
                 // Overwrite if same file name
                 $this->scat_picture->Upload->DbValue = "";
                 // No need to delete any more
             } else {
                 $rsnew['scat_picture'] = ew_UploadFileNameEx(ew_UploadPathEx(TRUE, $this->scat_picture->UploadPath), $rsnew['scat_picture']);
                 // Get new file name
             }
         }
     }
     // Call Row Inserting event
     $rs = $rsold == NULL ? NULL : $rsold->fields;
     $bInsertRow = $this->Row_Inserting($rs, $rsnew);
     if ($bInsertRow) {
         $conn->raiseErrorFn = $GLOBALS["EW_ERROR_FN"];
         $AddRow = $this->Insert($rsnew);
         $conn->raiseErrorFn = '';
         if ($AddRow) {
             // Get insert id if necessary
             $this->scat_id->setDbValue($conn->Insert_ID());
             $rsnew['scat_id'] = $this->scat_id->DbValue;
             if (!$this->scat_picture->Upload->KeepFile) {
                 if (!ew_Empty($this->scat_picture->Upload->Value)) {
                     $this->scat_picture->Upload->SaveToFile($this->scat_picture->UploadPath, $rsnew['scat_picture'], TRUE);
                 }
                 if ($this->scat_picture->Upload->DbValue != "") {
                     @unlink(ew_UploadPathEx(TRUE, $this->scat_picture->OldUploadPath) . $this->scat_picture->Upload->DbValue);
                 }
             }
         }
     } else {
         if ($this->getSuccessMessage() != "" || $this->getFailureMessage() != "") {
             // Use the message, do nothing
         } elseif ($this->CancelMessage != "") {
             $this->setFailureMessage($this->CancelMessage);
             $this->CancelMessage = "";
         } else {
             $this->setFailureMessage($Language->Phrase("InsertCancelled"));
         }
         $AddRow = FALSE;
     }
     // Add detail records
     if ($AddRow) {
         $DetailTblVar = explode(",", $this->getCurrentDetailTable());
         if (in_array("products", $DetailTblVar) && $GLOBALS["products"]->DetailAdd) {
             $GLOBALS["products"]->scat_id->setSessionValue($this->scat_id->CurrentValue);
             // Set master key
             if (!isset($GLOBALS["products_grid"])) {
                 $GLOBALS["products_grid"] = new cproducts_grid();
             }
             // Get detail page object
             $AddRow = $GLOBALS["products_grid"]->GridInsert();
             if (!$AddRow) {
                 $GLOBALS["products"]->scat_id->setSessionValue("");
             }
             // Clear master key if insert failed
         }
     }
     // Commit/Rollback transaction
     if ($this->getCurrentDetailTable() != "") {
         if ($AddRow) {
             $conn->CommitTrans();
             // Commit transaction
         } else {
             $conn->RollbackTrans();
             // Rollback transaction
         }
     }
     if ($AddRow) {
         // Call Row Inserted event
         $rs = $rsold == NULL ? NULL : $rsold->fields;
         $this->Row_Inserted($rs, $rsnew);
     }
     // scat_picture
     ew_CleanUploadTempPath($this->scat_picture, $this->scat_picture->Upload->Index);
     return $AddRow;
 }
Exemplo n.º 24
0
 function AddRow($rsold = NULL)
 {
     global $Language, $Security;
     $conn =& $this->Connection();
     // Load db values from rsold
     if ($rsold) {
         $this->LoadDbValues($rsold);
         $this->s_image->OldUploadPath = "/uploads/";
         $this->s_image->UploadPath = $this->s_image->OldUploadPath;
         $this->s_images->OldUploadPath = "/uploads/";
         $this->s_images->UploadPath = $this->s_images->OldUploadPath;
     }
     $rsnew = array();
     // s_title
     $this->s_title->SetDbValueDef($rsnew, $this->s_title->CurrentValue, "", FALSE);
     // s_image
     if (!$this->s_image->Upload->KeepFile) {
         $this->s_image->Upload->DbValue = "";
         // No need to delete old file
         if ($this->s_image->Upload->FileName == "") {
             $rsnew['s_image'] = NULL;
         } else {
             $rsnew['s_image'] = $this->s_image->Upload->FileName;
         }
     }
     // s_desc
     $this->s_desc->SetDbValueDef($rsnew, $this->s_desc->CurrentValue, "", FALSE);
     // s_longdesc
     $this->s_longdesc->SetDbValueDef($rsnew, $this->s_longdesc->CurrentValue, "", FALSE);
     // s_images
     if (!$this->s_images->Upload->KeepFile) {
         $this->s_images->Upload->DbValue = "";
         // No need to delete old file
         if ($this->s_images->Upload->FileName == "") {
             $rsnew['s_images'] = NULL;
         } else {
             $rsnew['s_images'] = $this->s_images->Upload->FileName;
         }
     }
     // s_caption
     $this->s_caption->SetDbValueDef($rsnew, $this->s_caption->CurrentValue, "", FALSE);
     if (!$this->s_image->Upload->KeepFile) {
         $this->s_image->UploadPath = "/uploads/";
         if (!ew_Empty($this->s_image->Upload->Value)) {
             $rsnew['s_image'] = ew_UploadFileNameEx(ew_UploadPathEx(TRUE, $this->s_image->UploadPath), $rsnew['s_image']);
             // Get new file name
         }
     }
     if (!$this->s_images->Upload->KeepFile) {
         $this->s_images->UploadPath = "/uploads/";
         $OldFiles = explode(EW_MULTIPLE_UPLOAD_SEPARATOR, $this->s_images->Upload->DbValue);
         if (!ew_Empty($this->s_images->Upload->FileName)) {
             $NewFiles = explode(EW_MULTIPLE_UPLOAD_SEPARATOR, $this->s_images->Upload->FileName);
             $FileCount = count($NewFiles);
             for ($i = 0; $i < $FileCount; $i++) {
                 $fldvar = $this->s_images->Upload->Index < 0 ? $this->s_images->FldVar : substr($this->s_images->FldVar, 0, 1) . $this->s_images->Upload->Index . substr($this->s_images->FldVar, 1);
                 if ($NewFiles[$i] != "") {
                     $file = $NewFiles[$i];
                     if (file_exists(ew_UploadTempPath($fldvar, $this->s_images->TblVar) . EW_PATH_DELIMITER . $file)) {
                         if (!in_array($file, $OldFiles)) {
                             $file1 = ew_UploadFileNameEx(ew_UploadPathEx(TRUE, $this->s_images->UploadPath), $file);
                             // Get new file name
                             if ($file1 != $file) {
                                 // Rename temp file
                                 while (file_exists(ew_UploadTempPath($fldvar, $this->s_images->TblVar) . EW_PATH_DELIMITER . $file1)) {
                                     // Make sure did not clash with existing upload file
                                     $file1 = ew_UniqueFilename(ew_UploadPathEx(TRUE, $this->s_images->UploadPath), $file1, TRUE);
                                 }
                                 // Use indexed name
                                 rename(ew_UploadTempPath($fldvar, $this->s_images->TblVar) . EW_PATH_DELIMITER . $file, ew_UploadTempPath($fldvar, $this->s_images->TblVar) . EW_PATH_DELIMITER . $file1);
                                 $NewFiles[$i] = $file1;
                             }
                         }
                     }
                 }
             }
             $this->s_images->Upload->FileName = implode(EW_MULTIPLE_UPLOAD_SEPARATOR, $NewFiles);
             $rsnew['s_images'] = $this->s_images->Upload->FileName;
         } else {
             $NewFiles = array();
         }
     }
     // Call Row Inserting event
     $rs = $rsold == NULL ? NULL : $rsold->fields;
     $bInsertRow = $this->Row_Inserting($rs, $rsnew);
     if ($bInsertRow) {
         $conn->raiseErrorFn = $GLOBALS["EW_ERROR_FN"];
         $AddRow = $this->Insert($rsnew);
         $conn->raiseErrorFn = '';
         if ($AddRow) {
             // Get insert id if necessary
             $this->s_id->setDbValue($conn->Insert_ID());
             $rsnew['s_id'] = $this->s_id->DbValue;
             if (!$this->s_image->Upload->KeepFile) {
                 if (!ew_Empty($this->s_image->Upload->Value)) {
                     $this->s_image->Upload->SaveToFile($this->s_image->UploadPath, $rsnew['s_image'], TRUE);
                 }
             }
             if (!$this->s_images->Upload->KeepFile) {
                 $OldFiles = explode(EW_MULTIPLE_UPLOAD_SEPARATOR, $this->s_images->Upload->DbValue);
                 if (!ew_Empty($this->s_images->Upload->FileName)) {
                     $NewFiles = explode(EW_MULTIPLE_UPLOAD_SEPARATOR, $this->s_images->Upload->FileName);
                     $NewFiles2 = explode(EW_MULTIPLE_UPLOAD_SEPARATOR, $rsnew['s_images']);
                     $FileCount = count($NewFiles);
                     for ($i = 0; $i < $FileCount; $i++) {
                         $fldvar = $this->s_images->Upload->Index < 0 ? $this->s_images->FldVar : substr($this->s_images->FldVar, 0, 1) . $this->s_images->Upload->Index . substr($this->s_images->FldVar, 1);
                         if ($NewFiles[$i] != "") {
                             $file = ew_UploadTempPath($fldvar, $this->s_images->TblVar) . EW_PATH_DELIMITER . $NewFiles[$i];
                             if (file_exists($file)) {
                                 $this->s_images->Upload->SaveToFile($this->s_images->UploadPath, @$NewFiles2[$i] != "" ? $NewFiles2[$i] : $NewFiles[$i], TRUE, $i);
                                 // Just replace
                             }
                         }
                     }
                 } else {
                     $NewFiles = array();
                 }
             }
         }
     } else {
         if ($this->getSuccessMessage() != "" || $this->getFailureMessage() != "") {
             // Use the message, do nothing
         } elseif ($this->CancelMessage != "") {
             $this->setFailureMessage($this->CancelMessage);
             $this->CancelMessage = "";
         } else {
             $this->setFailureMessage($Language->Phrase("InsertCancelled"));
         }
         $AddRow = FALSE;
     }
     if ($AddRow) {
         // Call Row Inserted event
         $rs = $rsold == NULL ? NULL : $rsold->fields;
         $this->Row_Inserted($rs, $rsnew);
     }
     // s_image
     ew_CleanUploadTempPath($this->s_image, $this->s_image->Upload->Index);
     // s_images
     ew_CleanUploadTempPath($this->s_images, $this->s_images->Upload->Index);
     return $AddRow;
 }
Exemplo n.º 25
0
 function AddRow($rsold = NULL)
 {
     global $Language, $Security;
     $conn =& $this->Connection();
     // Load db values from rsold
     if ($rsold) {
         $this->LoadDbValues($rsold);
         $this->image_name->OldUploadPath = "/projectimages";
         $this->image_name->UploadPath = $this->image_name->OldUploadPath;
     }
     $rsnew = array();
     // p_id
     $this->p_id->SetDbValueDef($rsnew, $this->p_id->CurrentValue, 0, FALSE);
     // image_name
     if (!$this->image_name->Upload->KeepFile) {
         $this->image_name->Upload->DbValue = "";
         // No need to delete old file
         if ($this->image_name->Upload->FileName == "") {
             $rsnew['image_name'] = NULL;
         } else {
             $rsnew['image_name'] = $this->image_name->Upload->FileName;
         }
     }
     // image_detail
     $this->image_detail->SetDbValueDef($rsnew, $this->image_detail->CurrentValue, "", FALSE);
     if (!$this->image_name->Upload->KeepFile) {
         $this->image_name->UploadPath = "/projectimages";
         if (!ew_Empty($this->image_name->Upload->Value)) {
             $rsnew['image_name'] = ew_UploadFileNameEx(ew_UploadPathEx(TRUE, $this->image_name->UploadPath), $rsnew['image_name']);
             // Get new file name
         }
     }
     // Call Row Inserting event
     $rs = $rsold == NULL ? NULL : $rsold->fields;
     $bInsertRow = $this->Row_Inserting($rs, $rsnew);
     if ($bInsertRow) {
         $conn->raiseErrorFn = $GLOBALS["EW_ERROR_FN"];
         $AddRow = $this->Insert($rsnew);
         $conn->raiseErrorFn = '';
         if ($AddRow) {
             // Get insert id if necessary
             $this->image_id->setDbValue($conn->Insert_ID());
             $rsnew['image_id'] = $this->image_id->DbValue;
             if (!$this->image_name->Upload->KeepFile) {
                 if (!ew_Empty($this->image_name->Upload->Value)) {
                     $this->image_name->Upload->SaveToFile($this->image_name->UploadPath, $rsnew['image_name'], TRUE);
                 }
             }
         }
     } else {
         if ($this->getSuccessMessage() != "" || $this->getFailureMessage() != "") {
             // Use the message, do nothing
         } elseif ($this->CancelMessage != "") {
             $this->setFailureMessage($this->CancelMessage);
             $this->CancelMessage = "";
         } else {
             $this->setFailureMessage($Language->Phrase("InsertCancelled"));
         }
         $AddRow = FALSE;
     }
     if ($AddRow) {
         // Call Row Inserted event
         $rs = $rsold == NULL ? NULL : $rsold->fields;
         $this->Row_Inserted($rs, $rsnew);
     }
     // image_name
     ew_CleanUploadTempPath($this->image_name, $this->image_name->Upload->Index);
     return $AddRow;
 }
Exemplo n.º 26
0
 function EditRow()
 {
     global $conn, $Security, $Items;
     $sFilter = $Items->KeyFilter();
     $Items->CurrentFilter = $sFilter;
     $sSql = $Items->SQL();
     $conn->raiseErrorFn = 'ew_ErrorFn';
     $rs = $conn->Execute($sSql);
     $conn->raiseErrorFn = '';
     if ($rs === FALSE) {
         return FALSE;
     }
     if ($rs->EOF) {
         $EditRow = FALSE;
         // Update Failed
     } else {
         // Save old values
         $rsold =& $rs->fields;
         $rsnew = array();
         // Field ItemID
         // Field MenuID
         $Items->MenuID->SetDbValueDef($Items->MenuID->CurrentValue, 0);
         $rsnew['MenuID'] =& $Items->MenuID->DbValue;
         // Field ItemName
         $Items->ItemName->SetDbValueDef($Items->ItemName->CurrentValue, "");
         $rsnew['ItemName'] =& $Items->ItemName->DbValue;
         // Field Description
         $Items->Description->SetDbValueDef($Items->Description->CurrentValue, "");
         $rsnew['Description'] =& $Items->Description->DbValue;
         // Field Price
         $Items->Price->SetDbValueDef($Items->Price->CurrentValue, NULL);
         $rsnew['Price'] =& $Items->Price->DbValue;
         // Field Image
         $Items->Image->Upload->SaveToSession();
         // Save file value to Session
         if ($Items->Image->Upload->Action == "2" || $Items->Image->Upload->Action == "3") {
             // Update/Remove
             $Items->Image->Upload->DbValue = $rs->fields('Image');
             // Get original value
             if (is_null($Items->Image->Upload->Value)) {
                 $rsnew['Image'] = NULL;
             } else {
                 $rsnew['Image'] = ew_UploadFileNameEx(ew_UploadPathEx(True, "../images/items/"), $Items->Image->Upload->FileName);
             }
         }
         // Field Vegetarian
         $Items->Vegetarian->SetDbValueDef($Items->Vegetarian->CurrentValue, "");
         $rsnew['Vegetarian'] =& $Items->Vegetarian->DbValue;
         // Field Vegetarian_Price
         $Items->Vegetarian_Price->SetDbValueDef($Items->Vegetarian_Price->CurrentValue, NULL);
         $rsnew['Vegetarian_Price'] =& $Items->Vegetarian_Price->DbValue;
         // Field Color
         $Items->Color->SetDbValueDef($Items->Color->CurrentValue, NULL);
         $rsnew['Color'] =& $Items->Color->DbValue;
         // Field Sequence
         $Items->Sequence->SetDbValueDef($Items->Sequence->CurrentValue, 0);
         $rsnew['Sequence'] =& $Items->Sequence->DbValue;
         // Field PDF
         $Items->PDF->Upload->SaveToSession();
         // Save file value to Session
         if ($Items->PDF->Upload->Action == "2" || $Items->PDF->Upload->Action == "3") {
             // Update/Remove
             $Items->PDF->Upload->DbValue = $rs->fields('PDF');
             // Get original value
             if (is_null($Items->PDF->Upload->Value)) {
                 $rsnew['PDF'] = NULL;
             } else {
                 $rsnew['PDF'] = ew_UploadFileNameEx(ew_UploadPathEx(True, "../recipes/"), $Items->PDF->Upload->FileName);
             }
         }
         // Field Active
         $Items->Active->SetDbValueDef($Items->Active->CurrentValue, "");
         $rsnew['Active'] =& $Items->Active->DbValue;
         // Call Row Updating event
         $bUpdateRow = $Items->Row_Updating($rsold, $rsnew);
         if ($bUpdateRow) {
             // Field Image
             if (!is_null($Items->Image->Upload->Value)) {
                 $Items->Image->Upload->SaveToFile("../images/items/", $rsnew['Image'], FALSE);
             }
             // Field PDF
             if (!is_null($Items->PDF->Upload->Value)) {
                 $Items->PDF->Upload->SaveToFile("../recipes/", $rsnew['PDF'], FALSE);
             }
             $conn->raiseErrorFn = 'ew_ErrorFn';
             $EditRow = $conn->Execute($Items->UpdateSQL($rsnew));
             $conn->raiseErrorFn = '';
         } else {
             if ($Items->CancelMessage != "") {
                 $this->setMessage($Items->CancelMessage);
                 $Items->CancelMessage = "";
             } else {
                 $this->setMessage("Update cancelled");
             }
             $EditRow = FALSE;
         }
     }
     // Call Row_Updated event
     if ($EditRow) {
         $Items->Row_Updated($rsold, $rsnew);
     }
     $rs->Close();
     // Field Image
     $Items->Image->Upload->RemoveFromSession();
     // Remove file value from Session
     // Field PDF
     $Items->PDF->Upload->RemoveFromSession();
     // Remove file value from Session
     return $EditRow;
 }
Exemplo n.º 27
0
 function AddRow($rsold = NULL)
 {
     global $Language, $Security;
     $conn =& $this->Connection();
     // Load db values from rsold
     if ($rsold) {
         $this->LoadDbValues($rsold);
     }
     $rsnew = array();
     // PATH
     if ($this->PATH->Visible && !$this->PATH->Upload->KeepFile) {
         $this->PATH->Upload->DbValue = "";
         // No need to delete old file
         if ($this->PATH->Upload->FileName == "") {
             $rsnew['PATH'] = NULL;
         } else {
             $rsnew['PATH'] = $this->PATH->Upload->FileName;
         }
     }
     // PROCESS
     $this->PROCESS->SetDbValueDef($rsnew, $this->PROCESS->CurrentValue, 0, FALSE);
     // BANK_ACCOUNT_ID
     $this->BANK_ACCOUNT_ID->SetDbValueDef($rsnew, $this->BANK_ACCOUNT_ID->CurrentValue, 0, FALSE);
     // UPLOAD_FILE_STATUS_ID
     $this->UPLOAD_FILE_STATUS_ID->SetDbValueDef($rsnew, $this->UPLOAD_FILE_STATUS_ID->CurrentValue, 0, FALSE);
     // DATETIME
     $this->DATETIME->SetDbValueDef($rsnew, ew_UnFormatDateTime($this->DATETIME->CurrentValue, 7), ew_CurrentDate(), FALSE);
     if ($this->PATH->Visible && !$this->PATH->Upload->KeepFile) {
         if (!ew_Empty($this->PATH->Upload->Value)) {
             $rsnew['PATH'] = ew_UploadFileNameEx(ew_UploadPathEx(TRUE, $this->PATH->UploadPath), $rsnew['PATH']);
             // Get new file name
         }
     }
     // Call Row Inserting event
     $rs = $rsold == NULL ? NULL : $rsold->fields;
     $bInsertRow = $this->Row_Inserting($rs, $rsnew);
     if ($bInsertRow) {
         $conn->raiseErrorFn = $GLOBALS["EW_ERROR_FN"];
         $AddRow = $this->Insert($rsnew);
         $conn->raiseErrorFn = '';
         if ($AddRow) {
             // Get insert id if necessary
             $this->UPLOAD_FILE_ID->setDbValue($conn->Insert_ID());
             $rsnew['UPLOAD_FILE_ID'] = $this->UPLOAD_FILE_ID->DbValue;
             if ($this->PATH->Visible && !$this->PATH->Upload->KeepFile) {
                 if (!ew_Empty($this->PATH->Upload->Value)) {
                     $this->PATH->Upload->SaveToFile($this->PATH->UploadPath, $rsnew['PATH'], TRUE);
                 }
             }
         }
     } else {
         if ($this->getSuccessMessage() != "" || $this->getFailureMessage() != "") {
             // Use the message, do nothing
         } elseif ($this->CancelMessage != "") {
             $this->setFailureMessage($this->CancelMessage);
             $this->CancelMessage = "";
         } else {
             $this->setFailureMessage($Language->Phrase("InsertCancelled"));
         }
         $AddRow = FALSE;
     }
     if ($AddRow) {
         // Call Row Inserted event
         $rs = $rsold == NULL ? NULL : $rsold->fields;
         $this->Row_Inserted($rs, $rsnew);
     }
     // PATH
     ew_CleanUploadTempPath($this->PATH, $this->PATH->Upload->Index);
     return $AddRow;
 }
Exemplo n.º 28
0
 function AddRow($rsold = NULL)
 {
     global $conn, $Language, $Security;
     // Load db values from rsold
     if ($rsold) {
         $this->LoadDbValues($rsold);
         $this->cat_file->OldUploadPath = "/catalogues/";
         $this->cat_file->UploadPath = $this->cat_file->OldUploadPath;
     }
     $rsnew = array();
     // cat_name
     $this->cat_name->SetDbValueDef($rsnew, $this->cat_name->CurrentValue, "", FALSE);
     // cat_file
     if (!$this->cat_file->Upload->KeepFile) {
         if ($this->cat_file->Upload->FileName == "") {
             $rsnew['cat_file'] = NULL;
         } else {
             $rsnew['cat_file'] = $this->cat_file->Upload->FileName;
         }
         $this->cat_file->ImageWidth = EW_THUMBNAIL_DEFAULT_WIDTH;
         // Resize width
         $this->cat_file->ImageHeight = EW_THUMBNAIL_DEFAULT_HEIGHT;
         // Resize height
     }
     // cat_date
     $this->cat_date->SetDbValueDef($rsnew, ew_UnFormatDateTime($this->cat_date->CurrentValue, 5), ew_CurrentDate(), FALSE);
     if (!$this->cat_file->Upload->KeepFile) {
         $this->cat_file->UploadPath = "/catalogues/";
         if (!ew_Empty($this->cat_file->Upload->Value)) {
             $rsnew['cat_file'] = ew_UploadFileNameEx(ew_UploadPathEx(TRUE, $this->cat_file->UploadPath), $rsnew['cat_file']);
             // Get new file name
         }
     }
     // Call Row Inserting event
     $rs = $rsold == NULL ? NULL : $rsold->fields;
     $bInsertRow = $this->Row_Inserting($rs, $rsnew);
     if ($bInsertRow) {
         $conn->raiseErrorFn = 'ew_ErrorFn';
         $AddRow = $this->Insert($rsnew);
         $conn->raiseErrorFn = '';
         if ($AddRow) {
             if (!$this->cat_file->Upload->KeepFile) {
                 if (!ew_Empty($this->cat_file->Upload->Value)) {
                     $this->cat_file->Upload->Resize($this->cat_file->ImageWidth, $this->cat_file->ImageHeight, EW_THUMBNAIL_DEFAULT_QUALITY);
                     $this->cat_file->Upload->SaveToFile($this->cat_file->UploadPath, $rsnew['cat_file'], TRUE);
                 }
             }
         }
     } else {
         if ($this->getSuccessMessage() != "" || $this->getFailureMessage() != "") {
             // Use the message, do nothing
         } elseif ($this->CancelMessage != "") {
             $this->setFailureMessage($this->CancelMessage);
             $this->CancelMessage = "";
         } else {
             $this->setFailureMessage($Language->Phrase("InsertCancelled"));
         }
         $AddRow = FALSE;
     }
     // Get insert id if necessary
     if ($AddRow) {
         $this->cat_id->setDbValue($conn->Insert_ID());
         $rsnew['cat_id'] = $this->cat_id->DbValue;
     }
     if ($AddRow) {
         // Call Row Inserted event
         $rs = $rsold == NULL ? NULL : $rsold->fields;
         $this->Row_Inserted($rs, $rsnew);
     }
     // cat_file
     ew_CleanUploadTempPath($this->cat_file, $this->cat_file->Upload->Index);
     return $AddRow;
 }
 function AddRow($rsold = NULL)
 {
     global $conn, $Language, $Security;
     // Check referential integrity for master table 'tramites'
     $bValidMasterRecord = TRUE;
     $sMasterFilter = $this->SqlMasterFilter_tramites();
     if (strval($this->id_tramite->CurrentValue) != "") {
         $sMasterFilter = str_replace("@codigo@", ew_AdjustSql($this->id_tramite->CurrentValue), $sMasterFilter);
     } else {
         $bValidMasterRecord = FALSE;
     }
     if ($bValidMasterRecord) {
         $rsmaster = $GLOBALS["tramites"]->LoadRs($sMasterFilter);
         $bValidMasterRecord = $rsmaster && !$rsmaster->EOF;
         $rsmaster->Close();
     }
     if (!$bValidMasterRecord) {
         $sRelatedRecordMsg = str_replace("%t", "tramites", $Language->Phrase("RelatedRecordRequired"));
         $this->setFailureMessage($sRelatedRecordMsg);
         return FALSE;
     }
     // Load db values from rsold
     if ($rsold) {
         $this->LoadDbValues($rsold);
     }
     $rsnew = array();
     // id_tramite
     $this->id_tramite->SetDbValueDef($rsnew, $this->id_tramite->CurrentValue, 0, FALSE);
     // fecha
     $this->fecha->SetDbValueDef($rsnew, ew_CurrentDate(), ew_CurrentDate());
     $rsnew['fecha'] =& $this->fecha->DbValue;
     // hora
     $this->hora->SetDbValueDef($rsnew, ew_CurrentTime(), ew_CurrentTime());
     $rsnew['hora'] =& $this->hora->DbValue;
     // titulo
     $this->titulo->SetDbValueDef($rsnew, $this->titulo->CurrentValue, NULL, FALSE);
     // archivo
     if (!$this->archivo->Upload->KeepFile) {
         $this->archivo->Upload->DbValue = "";
         // No need to delete old file
         if ($this->archivo->Upload->FileName == "") {
             $rsnew['archivo'] = NULL;
         } else {
             $rsnew['archivo'] = $this->archivo->Upload->FileName;
         }
     }
     if (!$this->archivo->Upload->KeepFile) {
         $OldFiles = explode(EW_MULTIPLE_UPLOAD_SEPARATOR, $this->archivo->Upload->DbValue);
         if (!ew_Empty($this->archivo->Upload->FileName)) {
             $NewFiles = explode(EW_MULTIPLE_UPLOAD_SEPARATOR, $this->archivo->Upload->FileName);
             $FileCount = count($NewFiles);
             for ($i = 0; $i < $FileCount; $i++) {
                 $fldvar = $this->archivo->Upload->Index < 0 ? $this->archivo->FldVar : substr($this->archivo->FldVar, 0, 1) . $this->archivo->Upload->Index . substr($this->archivo->FldVar, 1);
                 if ($NewFiles[$i] != "") {
                     $file = $NewFiles[$i];
                     if (file_exists(ew_UploadTempPath($fldvar) . EW_PATH_DELIMITER . $file)) {
                         if (!in_array($file, $OldFiles)) {
                             $file1 = ew_UploadFileNameEx(ew_UploadPathEx(TRUE, $this->archivo->UploadPath), $file);
                             // Get new file name
                             if ($file1 != $file) {
                                 // Rename temp file
                                 while (file_exists(ew_UploadTempPath($fldvar) . EW_PATH_DELIMITER . $file1)) {
                                     // Make sure did not clash with existing upload file
                                     $file1 = ew_UniqueFilename(ew_UploadPathEx(TRUE, $this->archivo->UploadPath), $file1, TRUE);
                                 }
                                 // Use indexed name
                                 rename(ew_UploadTempPath($fldvar) . EW_PATH_DELIMITER . $file, ew_UploadTempPath($fldvar) . EW_PATH_DELIMITER . $file1);
                                 $NewFiles[$i] = $file1;
                             }
                         }
                     }
                 }
             }
             $this->archivo->Upload->FileName = implode(EW_MULTIPLE_UPLOAD_SEPARATOR, $NewFiles);
             $rsnew['archivo'] = $this->archivo->Upload->FileName;
         } else {
             $NewFiles = array();
         }
     }
     // Call Row Inserting event
     $rs = $rsold == NULL ? NULL : $rsold->fields;
     $bInsertRow = $this->Row_Inserting($rs, $rsnew);
     // Check if key value entered
     if ($bInsertRow && $this->ValidateKey && strval($rsnew['id_tramite']) == "") {
         $this->setFailureMessage($Language->Phrase("InvalidKeyValue"));
         $bInsertRow = FALSE;
     }
     // Check if key value entered
     if ($bInsertRow && $this->ValidateKey && strval($rsnew['fecha']) == "") {
         $this->setFailureMessage($Language->Phrase("InvalidKeyValue"));
         $bInsertRow = FALSE;
     }
     // Check if key value entered
     if ($bInsertRow && $this->ValidateKey && strval($rsnew['hora']) == "") {
         $this->setFailureMessage($Language->Phrase("InvalidKeyValue"));
         $bInsertRow = FALSE;
     }
     // Check for duplicate key
     if ($bInsertRow && $this->ValidateKey) {
         $sFilter = $this->KeyFilter();
         $rsChk = $this->LoadRs($sFilter);
         if ($rsChk && !$rsChk->EOF) {
             $sKeyErrMsg = str_replace("%f", $sFilter, $Language->Phrase("DupKey"));
             $this->setFailureMessage($sKeyErrMsg);
             $rsChk->Close();
             $bInsertRow = FALSE;
         }
     }
     if ($bInsertRow) {
         $conn->raiseErrorFn = 'ew_ErrorFn';
         $AddRow = $this->Insert($rsnew);
         $conn->raiseErrorFn = '';
         if ($AddRow) {
             if (!$this->archivo->Upload->KeepFile) {
                 $OldFiles = explode(EW_MULTIPLE_UPLOAD_SEPARATOR, $this->archivo->Upload->DbValue);
                 if (!ew_Empty($this->archivo->Upload->FileName)) {
                     $NewFiles = explode(EW_MULTIPLE_UPLOAD_SEPARATOR, $this->archivo->Upload->FileName);
                     $NewFiles2 = explode(EW_MULTIPLE_UPLOAD_SEPARATOR, $rsnew['archivo']);
                     $FileCount = count($NewFiles);
                     for ($i = 0; $i < $FileCount; $i++) {
                         $fldvar = $this->archivo->Upload->Index < 0 ? $this->archivo->FldVar : substr($this->archivo->FldVar, 0, 1) . $this->archivo->Upload->Index . substr($this->archivo->FldVar, 1);
                         if ($NewFiles[$i] != "") {
                             $file = ew_UploadTempPath($fldvar) . EW_PATH_DELIMITER . $NewFiles[$i];
                             if (file_exists($file)) {
                                 $this->archivo->Upload->SaveToFile($this->archivo->UploadPath, @$NewFiles2[$i] != "" ? $NewFiles2[$i] : $NewFiles[$i], TRUE, $i);
                                 // Just replace
                             }
                         }
                     }
                 } else {
                     $NewFiles = array();
                 }
                 $FileCount = count($OldFiles);
                 for ($i = 0; $i < $FileCount; $i++) {
                     if ($OldFiles[$i] != "" && !in_array($OldFiles[$i], $NewFiles)) {
                         @unlink(ew_UploadPathEx(TRUE, $this->archivo->OldUploadPath) . $OldFiles[$i]);
                     }
                 }
             }
         }
     } else {
         if ($this->getSuccessMessage() != "" || $this->getFailureMessage() != "") {
             // Use the message, do nothing
         } elseif ($this->CancelMessage != "") {
             $this->setFailureMessage($this->CancelMessage);
             $this->CancelMessage = "";
         } else {
             $this->setFailureMessage($Language->Phrase("InsertCancelled"));
         }
         $AddRow = FALSE;
     }
     // Get insert id if necessary
     if ($AddRow) {
     }
     if ($AddRow) {
         // Call Row Inserted event
         $rs = $rsold == NULL ? NULL : $rsold->fields;
         $this->Row_Inserted($rs, $rsnew);
     }
     // archivo
     ew_CleanUploadTempPath($this->archivo, $this->archivo->Upload->Index);
     return $AddRow;
 }
Exemplo n.º 30
0
 function AddRow($rsold = NULL)
 {
     global $conn, $Language, $Security;
     // Load db values from rsold
     if ($rsold) {
         $this->LoadDbValues($rsold);
     }
     $rsnew = array();
     // fecha_recepcion
     $this->fecha_recepcion->SetDbValueDef($rsnew, ew_UnFormatDateTime($this->fecha_recepcion->CurrentValue, 7), ew_CurrentDate(), FALSE);
     // cliente
     $this->cliente->SetDbValueDef($rsnew, $this->cliente->CurrentValue, NULL, FALSE);
     // id_tipo_cliente
     $this->id_tipo_cliente->SetDbValueDef($rsnew, $this->id_tipo_cliente->CurrentValue, NULL, FALSE);
     // tel
     $this->tel->SetDbValueDef($rsnew, $this->tel->CurrentValue, NULL, FALSE);
     // cel
     $this->cel->SetDbValueDef($rsnew, $this->cel->CurrentValue, NULL, FALSE);
     // objetos
     $this->objetos->SetDbValueDef($rsnew, $this->objetos->CurrentValue, NULL, FALSE);
     // detalle_a_realizar
     $this->detalle_a_realizar->SetDbValueDef($rsnew, $this->detalle_a_realizar->CurrentValue, NULL, FALSE);
     // fecha_entrega
     $this->fecha_entrega->SetDbValueDef($rsnew, ew_UnFormatDateTime($this->fecha_entrega->CurrentValue, 7), NULL, FALSE);
     // observaciones
     $this->observaciones->SetDbValueDef($rsnew, $this->observaciones->CurrentValue, NULL, FALSE);
     // id_estado
     $this->id_estado->SetDbValueDef($rsnew, $this->id_estado->CurrentValue, 0, FALSE);
     // precio
     $this->precio->SetDbValueDef($rsnew, $this->precio->CurrentValue, NULL, FALSE);
     // entrega
     $this->entrega->SetDbValueDef($rsnew, $this->entrega->CurrentValue, NULL, FALSE);
     // foto1
     if (!$this->foto1->Upload->KeepFile) {
         if ($this->foto1->Upload->FileName == "") {
             $rsnew['foto1'] = NULL;
         } else {
             $rsnew['foto1'] = $this->foto1->Upload->FileName;
         }
     }
     // foto2
     if (!$this->foto2->Upload->KeepFile) {
         if ($this->foto2->Upload->FileName == "") {
             $rsnew['foto2'] = NULL;
         } else {
             $rsnew['foto2'] = $this->foto2->Upload->FileName;
         }
     }
     if (!$this->foto1->Upload->KeepFile) {
         if (!ew_Empty($this->foto1->Upload->Value)) {
             if ($this->foto1->Upload->FileName == $this->foto1->Upload->DbValue) {
                 // Overwrite if same file name
                 $this->foto1->Upload->DbValue = "";
                 // No need to delete any more
             } else {
                 $rsnew['foto1'] = ew_UploadFileNameEx(ew_UploadPathEx(TRUE, $this->foto1->UploadPath), $rsnew['foto1']);
                 // Get new file name
             }
         }
     }
     if (!$this->foto2->Upload->KeepFile) {
         if (!ew_Empty($this->foto2->Upload->Value)) {
             if ($this->foto2->Upload->FileName == $this->foto2->Upload->DbValue) {
                 // Overwrite if same file name
                 $this->foto2->Upload->DbValue = "";
                 // No need to delete any more
             } else {
                 $rsnew['foto2'] = ew_UploadFileNameEx(ew_UploadPathEx(TRUE, $this->foto2->UploadPath), $rsnew['foto2']);
                 // Get new file name
             }
         }
     }
     // Call Row Inserting event
     $rs = $rsold == NULL ? NULL : $rsold->fields;
     $bInsertRow = $this->Row_Inserting($rs, $rsnew);
     if ($bInsertRow) {
         $conn->raiseErrorFn = 'ew_ErrorFn';
         $AddRow = $this->Insert($rsnew);
         $conn->raiseErrorFn = '';
         if ($AddRow) {
             if (!$this->foto1->Upload->KeepFile) {
                 if (!ew_Empty($this->foto1->Upload->Value)) {
                     $this->foto1->Upload->SaveToFile($this->foto1->UploadPath, $rsnew['foto1'], TRUE);
                 }
                 if ($this->foto1->Upload->DbValue != "") {
                     @unlink(ew_UploadPathEx(TRUE, $this->foto1->OldUploadPath) . $this->foto1->Upload->DbValue);
                 }
             }
             if (!$this->foto2->Upload->KeepFile) {
                 if (!ew_Empty($this->foto2->Upload->Value)) {
                     $this->foto2->Upload->SaveToFile($this->foto2->UploadPath, $rsnew['foto2'], TRUE);
                 }
                 if ($this->foto2->Upload->DbValue != "") {
                     @unlink(ew_UploadPathEx(TRUE, $this->foto2->OldUploadPath) . $this->foto2->Upload->DbValue);
                 }
             }
         }
     } else {
         if ($this->getSuccessMessage() != "" || $this->getFailureMessage() != "") {
             // Use the message, do nothing
         } elseif ($this->CancelMessage != "") {
             $this->setFailureMessage($this->CancelMessage);
             $this->CancelMessage = "";
         } else {
             $this->setFailureMessage($Language->Phrase("InsertCancelled"));
         }
         $AddRow = FALSE;
     }
     // Get insert id if necessary
     if ($AddRow) {
         $this->nro_orden->setDbValue($conn->Insert_ID());
         $rsnew['nro_orden'] = $this->nro_orden->DbValue;
     }
     if ($AddRow) {
         // Call Row Inserted event
         $rs = $rsold == NULL ? NULL : $rsold->fields;
         $this->Row_Inserted($rs, $rsnew);
     }
     // foto1
     ew_CleanUploadTempPath($this->foto1, $this->foto1->Upload->Index);
     // foto2
     ew_CleanUploadTempPath($this->foto2, $this->foto2->Upload->Index);
     return $AddRow;
 }