/* $Id:$ */
/*19.05.2022	27.04.1999	Белых А.И.	sozkom.c
Распечатка проводок в файл
*/
#include        <errno.h>
#include        "buhg.h"



void sozkom(class iceb_tu_str *koment,
char *komentprov, //Коментарий из проводки
char *kto, //Из какой подсистемы сделана проводка
char *kodop) //Код операции
{
char   strsql[512];
SQL_str row1;
SQLCURSOR cur1;
koment->new_plus(komentprov);
if(koment->getdlinna() > 1)
  return;
  
if(koment->getdlinna() <= 1 && kto[0] == '\0' )
  return;

memset(strsql,'\0',sizeof(strsql));
if(iceb_tu_SRAV(kto,ICEB_MP_MATU,0) == 0)
 {
  sprintf(strsql,"select naik from Prihod where kod='%s'",kodop);
  if(iceb_t_sql_readkey(strsql,&row1,&cur1) == 1)
    koment->new_plus(row1[0]);
  else
   {
    sprintf(strsql,"select naik from Rashod where kod='%s'",kodop);
    if(iceb_t_sql_readkey(strsql,&row1,&cur1) == 1)
      koment->new_plus(row1[0]);
   }
 }

if(iceb_tu_SRAV(kto,ICEB_MP_PPOR,0) == 0)
 {
  sprintf(strsql,"select naik from Opltp where kod='%s'",kodop);
  if(iceb_t_sql_readkey(strsql,&row1,&cur1) == 1)
    koment->new_plus(row1[0]);
 }

if(iceb_tu_SRAV(kto,ICEB_MP_KASA,0) == 0)
 {
  sprintf(strsql,"select naik from Кasop1 where kod='%s'",kodop);
  if(iceb_t_sql_readkey(strsql,&row1,&cur1) == 1)
    koment->new_plus(row1[0]);
  else
   {
    sprintf(strsql,"select naik from Kasop2 where kod='%s'",kodop);
    if(iceb_t_sql_readkey(strsql,&row1,&cur1) == 1)
      koment->new_plus(row1[0]);
   }
 }

if(iceb_tu_SRAV(kto,ICEB_MP_USLUGI,0) == 0)
 {
  sprintf(strsql,"select naik from Usloper1 where kod='%s'",kodop);
  if(iceb_t_sql_readkey(strsql,&row1,&cur1) == 1)
      koment->new_plus(row1[0]);
  else
   {
    sprintf(strsql,"select naik from Usloper2 where kod='%s'",kodop);
    if(iceb_t_sql_readkey(strsql,&row1,&cur1) == 1)
      koment->new_plus(row1[0]);
   }
 }
   

}
